diff --git a/assets/core.js b/assets/core.js index 36a116ab..97f24ea1 100644 --- a/assets/core.js +++ b/assets/core.js @@ -1 +1 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{39:function(e,t,n){e.exports=n(82)},81:function(e,t,n){},82:function(e,t,n){"use strict";n.r(t);var a,r=n(1),o=n(10),i=n(13),c=n.n(i),s=n(20),l=n(0),u=n.n(l),d=n(2),p=n.n(d),f=n(3),b=n(12),m=b.a.div(a||(a=Object(f.a)(["\n color: red;\n font-size: 11px;\n position: relative;\n padding: 5px 5px 5px 0px;\n display: block;\n"]))),g=function(e){var t=Object(l.useState)(""),n=t[0],a=t[1],r=function(t){t?"maxSelectedOptions"===t.type&&a(e.selectErrorMessage):a("")};return u.a.createElement("div",null,u.a.Children.map(e.children,(function(e){return u.a.isValidElement(e)?u.a.cloneElement(e,{onError:r}):e})),n?u.a.createElement(m,{className:"data-selector--wrapper"},n):null)};g.propTypes={selectErrorMessage:p.a.string,children:p.a.node};var h=g,v=n(31),y=n(21),O=n(22),w=n.n(O),j=n(38),x={control:function(e){return Object.assign({},e,{borderColor:"#ddd",borderRadius:"none",boxShadow:"none",":hover":{borderColor:"#8f1b13"},":active":{borderColor:"#8f1b13"}})},menu:function(e){return Object.assign({},e,{color:"#443e42",backgroundColor:"#FFFFFF"})},option:function(e,t){return Object.assign({},e,{fontSize:"14px",":hover":{backgroundColor:"#f0826d"},backgroundColor:t.isSelected?"#8f1b13":"transparent"})},singleValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValueLabel:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{paddingRight:6})},multiValueRemove:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{display:"none"})},input:function(e){return Object.assign({},e,{fontSize:"14px"})},indicatorsContainer:function(e){return Object.assign({},e,{pointerEvents:"none"})}},C=function(e){var t=e.label,n=e.onError,a=e.maxSelectedOptions,o=e.defaultValue,i=e.singleSelectOptions,c=e.className,s=Object(y.a)(e,["label","onError","maxSelectedOptions","defaultValue","singleSelectOptions","className"]),u=Object(l.useState)(o),d=u[0],p=u[1];Object(l.useEffect)((function(){s.onChange&&s.onChange(d),n&&n()}),[d]);return Object(r.c)("div",{className:w()("labelled-data-selector--wrapper",c)},Object(r.c)("label",null,Object(r.c)("b",null,t)),Object(r.c)(j.a,Object(v.a)({},s,{value:d,onChange:function(e){if(s.isMulti)if(e.length){var t=e.findIndex((function(e){return i.find((function(t){return t.value===e.value}))}));s.isMulti&&e.length>1&&-1!==t?p(0===t?e.slice(1):[e[t]]):a&&e.length>a?n&&n({type:"maxSelectedOptions",message:"Only up to "+a+" selections allowed"}):p(e)}else p(o);else p(e)},css:{marginRight:"25px"},styles:x,isClearable:"undefined"!==s.isClearable?s.isClearable:d.length>1})))};C.propTypes={label:p.a.string,options:p.a.array,maxSelectedOptions:p.a.number,onChange:p.a.func,onError:p.a.func,defaultValue:p.a.array,singleSelectOptions:p.a.array,isMulti:p.a.bool,isClearable:p.a.bool,className:p.a.string},C.defaultProps={maxSelectedOptions:2,singleSelectOptions:[]};var E=C,S=n(32);function L(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return N(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n"+e.title+""}}}},color:M.rainbow,xAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13},splitLine:{show:!1}},yAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13},splitLine:{show:!1}},axisPointer:{type:"none"},grid:{top:10}},B=(n(7),function(){return u.a.createElement("div",{className:"no-data"},"No Data")}),W=function(e,t,n){var a=e.slice();return t.forEach((function(t,r){void 0===a[r]?a[r]=n.cloneUnlessOtherwiseSpecified(t,n):n.isMergeableObject(t)?a[r]=q()(e[r],t,n):-1===e.indexOf(t)&&a.push(t)})),a},G=function(e,t,n,a,r,o){var i=e.series,c=e.mapping,s=i.map((function(l,u){return Object.assign({name:l,type:(d=e.type,d?"area"===d?"line":d:"bar")},"dicharts--ple-performance-analysis"!==e.className&&{stack:!e.type||["area","bar","column"].includes(e.type)?"School Type":void 0},{areaStyle:"area"===e.type?{}:void 0,smooth:!0,emphasis:{focus:"series"},label:{show:"dicharts--ple-performance-analysis"===e.className||u===i.length-1,position:"top",formatter:function(t){for(var n=0,a=0;aparseFloat(t[t.length-1])?[r,n[n.length-1]]:[r,"#b3adad"]})):[]},re=function(e,t){return t&&"number"==typeof t.value?(e.dataPrefix||"")+''+(n=t.value,void 0===a&&(a=1),(n>=1e12?(n/1e12).toFixed(a)+"tn":n>=1e9?(n/1e9).toFixed(a)+"bn":n>=1e6?(n/1e6).toFixed(a)+"m":n>=1e3?(n/1e3).toFixed(a)+"k":n>=0?""+n.toFixed(a):n<=-1e12?(n/1e12).toFixed(a)+"tn":n<=-1e9?(n/1e9).toFixed(a)+"bn":n<=-1e6?(n/1e6).toFixed(a)+"m":n<=1e3?(n/1e3).toFixed(a)+"k":""+n.toFixed(a))+"")+(e.dataSuffix||""):"No Data";var n,a},oe=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new X.LngLat(t[0],t[1]):null},ie=function(e,t,n){var a=e.querySourceFeatures("composite",{sourceLayer:n.sourceLayer,filter:["in",n.nameProperty,ne(t,n.formatter)]});return a&&a.length?function(e){if(Array.isArray(e)){var t=e.map((function(e){return Object(ee.a)(e.geometry).geometry.coordinates}));return t.push(t[0]),oe(Object(ee.a)(Object(te.f)([t])))}return oe(Object(ee.a)(e))}(a):null},ce=function(e,t,n,a,r){return t.setLngLat(n).setHTML('\n
\n
\n '+a.toLowerCase()+"\n
\n "+(r?''+r+"":"")+"\n
\n ").addTo(e)},se=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},le=Object(l.createContext)(),ue=Object(l.createContext)(),de=n(35),pe=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(de.a)(t,e),t.getDerivedStateFromError=function(){return{hasError:!0}};var n=t.prototype;return n.componentDidCatch=function(e,t){window.console.log("Error Boundary:",e,t)},n.render=function(){return this.state.hasError?u.a.createElement("div",null,"Something went wrong! Please contact your administrator"):this.props.children},t}(l.Component);pe.propTypes={children:p.a.any};var fe,be=pe,me=function(e,t){return e.find((function(e){return e.id===t}))},ge=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},he=function(e,t){var n=me(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},ve=function(e,t,n){if(t&&n){var a=me(e,t),r=a&&a.indicators&&a.indicators.length?a.indicators[0]:null;if(r&&r.yearRange)return k(r.yearRange).map((function(e){return{value:e,label:e}}))}return[]},ye=function(e){var t=Object(l.useContext)(ue),n=t.filterOptions,a=t.updateFilterOptions;return Object(l.useEffect)((function(){!n.topic&&e.length&&a({topic:e[0].id})}),[]),Object(l.useEffect)((function(){if(n.topic){var t=me(e,n.topic),r=t&&t.indicators&&t.indicators.length?t.indicators[0]:null;r&&a({indicator:r.id})}}),[n.topic]),{topicOptions:ge(e||[]),indicatorOptions:he(e,n.topic),yearOptions:ve(e,n.topic,n.indicator)}},Oe=function(){var e=Object(l.useContext)(ue),t=e.filters,n=e.topics,a=e.updateFilterOptions,o=ye(n),i=o.topicOptions,c=o.indicatorOptions,s=o.yearOptions;return Object(r.c)("form",{className:"form"},Object(r.c)("div",{className:w()("form-field","form-field--inline-block"),css:Object(r.b)(fe||(fe=Object(f.a)(["\n z-index: auto;\n margin-left: 5px;\n "])))},Object(r.c)(E,{label:t.topicLabel,options:i,defaultValue:[i[0]],classNamePrefix:"topic-selector",isClearable:!1,css:{minWidth:"100%"},onChange:function(e){return a({topic:e&&e.value})}}),c&&c.length?Object(r.c)(E,{label:t.indicatorLabel,options:c,defaultValue:[c[0]],classNamePrefix:"indicator-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return a({indicator:e&&e.value})}}):null,s&&s.length?Object(r.c)(E,{label:t.yearLabel,options:s,defaultValue:[s[0]],classNamePrefix:"year-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){Array.isArray(e)&&e.length?a({year:e[0].value}):e&&!Array.isArray(e)&&a({year:e.value})}}):null))},we=function(e){var t=e.children;return u.a.createElement("div",{className:"spotlight-legend","data-testid":"spotlight-legend"},l.Children.map(t,(function(e){return e})))};we.propTypes={children:p.a.any};var je=we,xe=function(e){var t=e.children,n=e.className,a=e.bgColor,r=e.textColor;return u.a.createElement("span",{className:n,"data-testid":"spotlight-legend-item"},t,u.a.createElement("style",null,"\n span."+n+" {\n background-color: "+(a||"#D1CBCF")+" !important;\n color: "+(r||"inherit")+";\n }\n "))};xe.propTypes={children:p.a.any,className:p.a.string,bgColor:p.a.string,textColor:p.a.string};var Ce,Ee=xe,Se=function(){var e,t,n=Object(l.useContext)(ue).activeIndicator;return u.a.createElement("div",{className:"spotlight__content"},u.a.createElement(be,null,u.a.createElement(Oe,null)),n?u.a.createElement(je,null,(e=n.range,t=n.colours,e&&t?e.map((function(n,a){return u.a.createElement(Ee,{className:"item-"+n,bgColor:t[a],key:n},0===a?"< "+e[0]:e[a-1]+"-"+n)})).concat([u.a.createElement(Ee,{className:"item-last",bgColor:t[t.length-1],key:e.length},"> "+e[e.length-1])]):null),u.a.createElement(Ee,null,"no data / not applicable")):null)},Le=n(36),Ne={type:"shapefile",style:"mapbox://styles/edwinmp/ck42rrx240t8p1cqpkhgy2g0m/draft",sourceLayer:"Uganda_Sub-Counties_2019-8w0zb5",layerName:"uganda-Sub-counties-2019-8w0zb5",center:[32.655221,1.344666],zoom:8,minZoom:8,maxZoom:9,districtNameProperty:"District",nameProperty:"Subcounty",codeProperty:"scode2019",formatter:function(e,t){return void 0===t&&(t="map"),e.toUpperCase()}},Ie=function(e,t,n,a){n&&(e.setFilter(t,["==",a.nameProperty,ne(n.name,a.formatter)]),setTimeout((function(){if(n.coordinates)e.flyTo({center:n.coordinates,zoom:8.5});else{var t=a.formatter?a.formatter(n.name):n.name;!function e(t,n,a,r){return void 0===r&&(r=!0),new Promise((function(o,i){var c=ie(t,n,a);c?(t.flyTo({center:c,zoom:16}),o(c)):r?(t.flyTo({center:a.center,zoom:a.zoom||6.1}),setTimeout((function(){e(t,n,a,!1).then((function(e){return o(e)})).catch(i)}),500)):i(new Error("Location "+n+" not found!"))}))}(e,t,a)}}),500))},ke=function(e,t,n){if(!t)return[];if(!t.mapping)throw new Error("Mapping is required for indicator "+t.id);var a=t.mapping,r=a.location,o=a.value,i=a.year,c=n?e.filter((function(e){return e[i]===""+n})).map((function(e){return{name:e[r],value:Number(e[o])}})):e.map((function(e){return{name:e[r],value:Number(e[o])}}));return t.aggregator?function(e,t){var n=Object(Le.groupBy)(e,(function(e){return e.name}));return Object.keys(n).map((function(e){var a=n[e].reduce((function(e,t){return e+t.value}),0),r=a/n[e].length;return{name:e,value:"sum"===t?a:r}}))}(c,t.aggregator):c},Te=function(e,t,n,a){!function(e,t,n){var a=n.popup,r=n.nameProperty,o=n.formatter,i=n.data,c=function(e,t){if(e.features&&e.features[0].properties){var n=e.features[0].geometry;if("Polygon"===n.type||"MultiPolygon"===n.type)return e.features[0].properties[t]||null}return null}(t,r);if(c){var s=o?o(c,"tooltip"):c;if(i){var l=se(s,i);ce(e,a,t.lngLat,s,re(n,l))}else ce(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},De=new X.Popup({offset:5}),Ae=function(e,t,n){void 0===n&&(n={});var a=Object(l.useState)(),r=a[0],o=a[1],i=Object(l.useState)(n),u=i[0],d=i[1],p=Object(l.useState)([]),f=p[0],b=p[1],m=Object(l.useCallback)((function(e){r.getCanvas().style.cursor="pointer",Te(De,r,e,Object.assign({},t,{data:f},u))}),[r,f,u]),g=Object(l.useCallback)((function(){r.getCanvas().style.cursor="",De.remove()}),[r,e]);return Object(l.useEffect)((function(){r&&(r.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||r.setLayoutProperty(e.id,"visibility","none")})),function(e,t,n){t.clientWidth<700?e.setZoom(n.zoom?n.zoom-1:5):t.clientWidth<900?e.setZoom(n.minZoom?n.minZoom+.8:5.8):e.setZoom(n.zoom||6.1)}(r,r.getContainer(),t),r.off("mouseleave","highlight",g),r.off("mousemove","highlight",m),r.on("mousemove","highlight",m),r.on("mouseleave","highlight",g))}),[r,e,u,f]),Object(l.useEffect)((function(){var e=function(){var e=Object(s.a)(c.a.mark((function e(t){var n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,T(t);case 2:n=e.sent,b(ke(n,u.indicator,u.year));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();u.indicator&&u.year&&e(u.indicator.url)}),[u.indicator,u.year]),{map:r,data:f,setData:b,setMap:o,setOptions:d}},Pe={topic:null,indicator:null,year:null},ze=b.a.div(Ce||(Ce=Object(f.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function Fe(e,t){switch(t.type){case"UPDATE_FILTERS":return Object.assign({},e,{filterOptions:t.merge?Object.assign({},e.filterOptions,t.filterOptions):t.filterOptions,activeTopic:t.activeTopic,activeIndicator:t.activeIndicator});case"SET_DATA":return Object.assign({},e,{data:t.data});case"RESET_FILTERS":return Object.assign({},e,{filterOptions:Pe});default:throw new Error}}var _e={filterOptions:Pe},Re=function(e){var t=Object(l.useState)(!0),n=t[0],a=t[1],o=Object(l.useReducer)(Fe,_e),i=o[0],c=o[1],s=i.filterOptions,u=i.activeIndicator,d=i.activeTopic,p=Ae(e.location,Ne),f=p.data,b=p.setMap,m=p.setOptions;Object(l.useEffect)((function(){if(u){var e=s.year;m({dataPrefix:u.name+": ",dataSuffix:e&&" in "+e,indicator:u,year:e})}}),[u,s.year]);var g,h,v=function(t,n){void 0===n&&(n=!0);var a=function(e,t){var n=t.topic,a=t.indicator,r=t.year;if(n){var o=e.find((function(e){return e.id===n}));if(o&&a){var i=o.indicators.find((function(e){return e.id===a}));if(i)return{topic:o,indicator:i,year:r}}return{topic:o}}return{}}(e.configs.data,Object.assign({},s,t)),r=a.topic,o=a.indicator;c({type:"UPDATE_FILTERS",merge:n,filterOptions:t,activeTopic:r,activeIndicator:o})},y=(g=e.configs.data,h=s.topic,g.find((function(e){return e.id===h}))),O=Object(l.useMemo)((function(){return{filters:e.filters,topics:e.configs.data,filterOptions:s,updateFilterOptions:v,activeTopic:d,activeIndicator:u}}));return Object(r.c)(ue.Provider,{value:O},Object(r.c)("div",{className:"spotlight"},Object(r.c)("div",{className:"spotlight__aside spotlight__aside--no-margin",css:{minHeight:"600px"}},Object(r.c)(Se,null)),Object(r.c)("div",{className:"spotlight__main spotlight__main--map"},n?Object(r.c)("div",null,"Loading ..."):null,y&&y.dashboardUrl?Object(r.c)(ze,null,Object(r.c)("a",{href:y.dashboardUrl,className:"button button--secondary--fill"},y.dashboardButtonCaption)):null,Object(r.c)(Q,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",options:Object.assign({style:Ne.style,center:Ne.center,minZoom:Ne.minZoom||6,zoom:Ne.zoom||6.1,maxZoom:Ne.maxZoom||7,scrollZoom:!1},e.configs.options),style:{width:"100%",background:"#ffffff"},onLoad:function(e){a(!1),b(e)}},function(e,t,n,a,o){var i=[a].map((function(e){return Object(r.c)(K,{key:"highlight-hidden",id:e.layerName,source:"composite","source-layer":e.sourceLayer,show:!1})}));function c(e,t){Ie(e,t,n,Object.assign({},a,{nameProperty:a.districtNameProperty}))}return!e&&t.length?i.concat(Object(r.c)(K,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+1,type:"fill",paint:{"fill-color":{property:a.nameProperty,type:"categorical",default:"#D1CBCF",stops:ae(t,o.range,o.colours,a.formatter)},"fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c})):i.concat(Object(r.c)(K,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+1,type:"fill",paint:{"fill-color":"#D1CBCF","fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c}))}(n,f,e.location,Ne,u?{range:u.range,colours:u.colours}:{})))))};Re.defaultProps={data:[]},Re.propTypes={configs:p.a.object,filters:p.a.object,data:p.a.array,location:p.a.shape({name:p.a.string,fullName:p.a.string,coordinates:p.a.array})};var qe,Ve,Ue,Me,Ze,Be,We,Ge=Re,Je=b.a.div(qe||(qe=Object(f.a)(["\n background: #ffffff;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n"]))),He=function(){return u.a.createElement(Je,null,u.a.createElement(B,null))},Xe=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.map,r=e.location;a?n.render(u.a.createElement(Ge,{configs:a,location:r,filters:a.filters})):n.render(u.a.createElement(He,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Ye=n(37),Ke=function(e){var t=e.close,n=e.description,a=e.source;return Object(r.c)("div",{className:"spotlight-modal",css:Object(r.b)(Ue||(Ue=Object(f.a)(["\n font-size: 12px;\n "])))},Object(r.c)("a",{className:"close",onClick:t,css:Object(r.b)(Me||(Me=Object(f.a)(["\n cursor: pointer;\n position: absolute;\n display: block;\n padding: 5px 10px;\n line-height: 20px;\n right: 0px;\n top: 0px;\n font-size: 20px;\n background: transparent;\n color: #333131;\n font-weight: 900;\n "])))},"×"),Object(r.c)("div",{className:"content",css:Object(r.b)(Ze||(Ze=Object(f.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(r.c)("p",{className:"description",css:Object(r.b)(Be||(Be=Object(f.a)(["\n font-size: 14px;\n "])))},n),a?Object(r.c)(u.a.Fragment,null,Object(r.c)("br",null),Object(r.c)("p",{className:"source",css:Object(r.b)(We||(We=Object(f.a)(["\n text-align: left;\n "])))},a?Object(r.c)(u.a.Fragment,null,Object(r.c)("b",{css:Object(r.b)(Ve||(Ve=Object(f.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};Ke.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var $e,Qe,et=Ke,tt=function(e){return Object(r.c)(Ye.a,{trigger:Object(r.c)("span",{className:"spotlight__stat-icon",css:Object(r.b)($e||($e=Object(f.a)(["\n display: inline-flex;\n margin-left: 2px;\n cursor: pointer;\n padding: 8px;\n "])))},Object(r.c)("i",{onClick:function(){document.querySelectorAll(".popup-content ").forEach((function(e){e.setAttribute("style","display:none;")}))},role:"presentation","aria-hidden":"true",className:"ico ico--12 ico-info-slate",css:Object(r.b)(Qe||(Qe=Object(f.a)(["\n top: -1px;\n "])))})),offsetX:20,arrowStyle:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(225deg)",margin:"-5px",zIndex:-1,boxShadow:"rgb(0 0 0 / 20%) 1px 1px 1px",bottom:"0%",left:"82px"},position:"bottom center",closeOnDocumentClick:!0,contentStyle:{zIndex:200,width:"350px",background:"#fff",fontWeight:400,fontStyle:"normal",fontSize:"12px",color:"#60575d",border:0,borderRadius:"0.28571429rem",boxShadow:"0 2px 4px 0 rgba(34, 36, 38, 0.12), 0 2px 10px 0 rgba(34, 36, 38, 0.15)",padding:"5px"}},(function(t){return Object(r.c)(et,{close:t,description:e.description,source:e.source})}))};tt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string};var nt=tt,at=function(e){var t=e.meta,n=void 0===t?{}:t,a=e.heading,r=e.children;return u.a.createElement("div",{className:"spotlight__stat"},u.a.createElement("h3",{className:"spotlight__stat-heading"},a,n.description||n.source?u.a.createElement(nt,{description:n.description,source:n.source}):null),r)};at.defaultProps={meta:{}},at.propTypes={heading:p.a.string,meta:p.a.shape({description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string}),children:p.a.any};var rt,ot=at,it=function(e){var t=e.value,n=e.note;return Object(r.c)("p",{className:"spotlight__stat-data"},t,n&&n.content?Object(r.c)("span",{className:"spotlight__stat-data__note",css:Object(r.b)(rt||(rt=Object(f.a)(["\n transform: none;\n position: relative;\n top: -10px;\n "])))},n.content," ",n.meta?Object(r.c)(nt,{description:n.meta.description,source:n.meta.source}):null):null)};it.propTypes={note:p.a.object,value:p.a.string};var ct,st=it,lt=function(e){var t=e.children;return Object(r.c)("article",{className:"tabs__content",css:Object(r.b)(ct||(ct=Object(f.a)(["\n z-index: 200;\n "])))},t)};lt.propTypes={children:p.a.any};var ut=lt,dt=function(e){var t=e.id,n=e.active,a=e.label,r=e.children,o=e.onActivate;return u.a.createElement("section",{className:"tabs__container",id:t},u.a.createElement("input",{className:"tabs__input",type:"radio",name:"sections",id:t+"-option",defaultChecked:n}),u.a.createElement("label",{className:"tabs__label",htmlFor:t+"-option",onClick:o},a),l.Children.map(r,(function(e){return Object(l.isValidElement)(e)&&e.type===ut?e:null})))};dt.propTypes={id:p.a.string.isRequired,label:p.a.string.isRequired,active:p.a.bool,onActivate:p.a.func,children:p.a.any};var pt=dt,ft=function(e){var t=e.children,n=e.onClick;return u.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};ft.propTypes={children:p.a.any,onClick:p.a.func};var bt,mt,gt,ht,vt,yt=ft,Ot=function(e,t){return t&&e?e.find((function(e){return e.id===t})):null},wt=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,o=t.options,i="education",c=Ot(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.education?n.education.find((function(e){return"Number of Schools"===e.caption})):null;return Object(r.c)(pt,{id:i,label:c.label||"Education",active:!!e.active||c.active},Object(r.c)(ut,null,Object(r.c)(yt,null,s?Object(r.c)("div",{css:Object(r.b)(bt||(bt=Object(f.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(mt||(mt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(gt||(gt=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(ht||(ht=Object(f.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(r.c)(nt,{description:"Last updated: "+s.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.education?n.education.filter((function(e){return"Number of Schools"!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(ot,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(vt||(vt=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(st,{value:e.value})))})):null)))};wt.propTypes={active:p.a.bool};var jt,xt,Ct,Et,St,Lt=wt,Nt=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,o=t.options,i="overview",c=Ot(o.tabs,i);return void 0===c.show||c.show?Object(r.c)(pt,{id:i,label:c.label||"Overview",active:!!e.active||c.active},Object(r.c)(ut,null,Object(r.c)(yt,null,n&&n.population?Object(r.c)("div",{css:Object(r.b)(jt||(jt=Object(f.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(xt||(xt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Ct||(Ct=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Et||(Et=Object(f.a)(["\n font-size: 3rem;\n "])))},I(n.population.value)),Object(r.c)(nt,{description:"Last updated: "+n.population.lastUpdated})),c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(r.c)("div",{className:"l-2up"},n&&n.administration?n.administration.map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(ot,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(St||(St=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(st,{value:e.value})))})):null))):null};Nt.propTypes={active:p.a.bool};var It,kt,Tt,Dt,At,Pt,zt=Nt,Ft=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,o=t.options,i="production",c=Ot(o.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.production?n.production.find((function(e){return""===e.caption})):null,u=function(){return c.dashboardURL?Object(r.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null};return Object(r.c)(pt,{id:i,label:c.label||"Production",active:!!e.active||c.active},Object(r.c)(ut,null,s?Object(r.c)(yt,null,Object(r.c)("div",{css:Object(r.b)(It||(It=Object(f.a)(["\n display: flex;\n "])))},Object(r.c)("div",{css:Object(r.b)(kt||(kt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(r.c)("span",{css:Object(r.b)(Tt||(Tt=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(r.c)("b",{css:Object(r.b)(Dt||(Dt=Object(f.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(r.c)(nt,{description:"Last updated: "+s.lastUpdated})),u())):u(),n&&n.production&&n.production.length?Object(r.c)("div",{className:"l-2up"},n.production.filter((function(e){return""!==e.caption})).map((function(e){return Object(r.c)("div",{className:"l-2up__col",key:e.caption},Object(r.c)(ot,{heading:e.caption,meta:{description:Object(r.c)("span",{css:Object(r.b)(At||(At=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(r.c)(st,{value:e.value})))}))):Object(r.c)("div",{css:Object(r.b)(Pt||(Pt=Object(f.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};Ft.propTypes={active:p.a.bool};var _t,Rt=Ft,qt=function(e){var t=e.children;return Object(r.c)("div",{className:"tabs",css:Object(r.b)(_t||(_t=Object(f.a)(["\n z-index: 0;\n "])))},t)};qt.propTypes={children:p.a.any};var Vt=qt,Ut=function(e){var t=Object(l.useState)({}),n=t[0],a=t[1];return Object(l.useEffect)((function(){e.data&&a(function(e){var t={},n=function(e){return{caption:e.Item,value:e.Value,lastUpdated:e["Last Updated"]}},a=e.find((function(e){return"Total Population"===e.Item}));return a&&(t.population=n(a)),t.administration=e.filter((function(e){return"Total Population"!==e.Item&&"Administration"===e.Department})).map(n),t.education=e.filter((function(e){return"Total Population"!==e.Item&&"Education"===e.Department})).map(n),t.production=e.filter((function(e){return"Total Population"!==e.Item&&"Production"===e.Department})).map(n),t}(e.data))}),[e.data]),Object(r.c)(le.Provider,{value:Object.assign({},e,{data:n})},Object(r.c)(Vt,null,Object(r.c)(zt,{active:!0}),Object(r.c)(Lt,null),Object(r.c)(Rt,null)))};Ut.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var Mt=Ut,Zt=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(o.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.keyFacts,r=e.location;a&&a.url?T(a.url).then((function(e){Array.isArray(e)?n.render(u.a.createElement(Mt,{data:e,options:a,location:r})):e.results?n.render(u.a.createElement(Mt,{data:e.results,options:a,location:r})):(window.console.error("Invalid data shape. Expected an array or an object with a results property.",e),n.render(u.a.createElement(He,null)))})).catch((function(e){window.console.log(e),n.render(u.a.createElement(He,null))})):a&&a.data?n.render(u.a.createElement(Mt,{data:a.data,options:a,location:r})):n.render(u.a.createElement(He,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Bt=function(e){return u.a.createElement("div",{className:"table-styled"},u.a.createElement("table",null,e.children))};Bt.propTypes={children:p.a.any};var Wt=Bt,Gt=function(e){var t=function(e,t){return void 0===t&&(t=!1),e.map((function(e,n){return u.a.createElement("tr",{key:n},e.map((function(e,n){return t?u.a.createElement("th",{key:n},e):u.a.createElement("td",{key:n},e)})))}))};return u.a.createElement(Wt,null,u.a.createElement("thead",null,t(e.rows.filter((function(e,t){return 0===t})),!0)),u.a.createElement("tbody",null,t(e.rows.filter((function(e,t){return t>0})))))};Gt.propTypes={rows:p.a.arrayOf(p.a.array)};var Jt=Gt,Ht=function(e){(function(e){return e.className?e.mapping?e.mapping.rows?e.mapping.year?e.mapping.value?e.mapping.subCounty?!!e.mapping.level||(window.console.error("Invalid table config: mapping[mapping.level] is required!"),!1):(window.console.error("Invalid table config: mapping.subCounty is required!"),!1):(window.console.error("Invalid table config: mapping.value is required!"),!1):(window.console.error("Invalid table config: mapping.year is required!"),!1):(window.console.error("Invalid table config: mapping.series is required!"),!1):(window.console.error("Invalid table config: mapping is required!"),!1):(window.console.error("Invalid table config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,d3:{onAdd:function(t){T(e.url).then((function(n){Array.prototype.forEach.call(t,(function(t){var a=new window.DICharts.Chart(t.parentElement);a.showLoading();var r=Object(o.createRoot)(t),i="all",c="all";window.DIState.addListener((function(){a.showLoading();var o=window.DIState.getState,s=o.subCounty,u=o.level;if(s!==c||u!==i){c=s||"all",i=u||"all";var d=e.filters&&e.filters.subCounties?n.filter((function(t){return e.filters.subCounties.includes(t[e.mapping.subCounty])})):n,p=function(e,t,n,a){var r=e.rows,o=e.mapping,i=k(e.yearRange),c=["School Type"].concat(i),s=r.map((function(r){var c={};t.filter((function(e){return i.includes(Number(e[o.year]))&&e[o.rows]===r})).filter((function(e){return"all"===n||e[o.subCounty].toLowerCase()===n.toLowerCase()})).filter((function(e){return"all"===a||e[o.level].toLowerCase()===a.toLowerCase()})).forEach((function(e){var t=c[e[o.year]]||[];c[e[o.year]]=[].concat(t,[Number(e[o.value])])}));var s={};Object.keys(c).forEach((function(t){if(e.aggregator&&"sum"!==e.aggregator){if(e.aggregator&&"avg"===e.aggregator){var n=c[t].reduce((function(e,t){return e+t}),0);s[t]=n/c[t].length}}else s[t]=c[t].reduce((function(e,t){return e+t}),0)}));var l=i.map((function(e){return s[e]?s[e]:0}));return[r].concat(l)})),l=c.map((function(e,t){return 0===t?"Total":I(s.reduce((function(e,n){return"number"==typeof n[t]?e+n[t]:e}),0))})),u=s.map((function(e){return e.map((function(e){return"number"==typeof e?I(e):e}))}));return[c].concat(u,[l])}(e,d,c,i);r.render(Object(l.createElement)(Jt,{rows:p})),a.hideLoading(),t.parentElement.classList.add("auto-height")}}))}))}))}}})},Xt=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.tables;t&&e.length!==t.length&&(e=t.filter((function(e){return"education"===e.target}))).forEach(Ht)}))}else window.console.log("State is not defined")};n(81);window.addEventListener("load",(function(){P("district-selectors","subcounty, level"),P("ple-performance-selectors","ownership"),Xe("dicharts--district-map"),Xt(),Zt("dicharts--keyfacts"),H()}))}},[[39,1,2]]]); \ No newline at end of file +(window.webpackJsonp=window.webpackJsonp||[]).push([[0],{39:function(e,t,n){e.exports=n(82)},81:function(e,t,n){},82:function(e,t,n){"use strict";n.r(t);var a,o=n(1),r=n(10),i=n(13),c=n.n(i),s=n(20),l=n(0),u=n.n(l),d=n(2),p=n.n(d),f=n(3),b=n(12),m=b.a.div(a||(a=Object(f.a)(["\n color: red;\n font-size: 11px;\n position: relative;\n padding: 5px 5px 5px 0px;\n display: block;\n"]))),g=function(e){var t=Object(l.useState)(""),n=t[0],a=t[1],o=function(t){t?"maxSelectedOptions"===t.type&&a(e.selectErrorMessage):a("")};return u.a.createElement("div",null,u.a.Children.map(e.children,(function(e){return u.a.isValidElement(e)?u.a.cloneElement(e,{onError:o}):e})),n?u.a.createElement(m,{className:"data-selector--wrapper"},n):null)};g.propTypes={selectErrorMessage:p.a.string,children:p.a.node};var h=g,v=n(31),y=n(21),w=n(22),O=n.n(w),j=n(38),x={control:function(e){return Object.assign({},e,{borderColor:"#ddd",borderRadius:"none",boxShadow:"none",":hover":{borderColor:"#8f1b13"},":active":{borderColor:"#8f1b13"}})},menu:function(e){return Object.assign({},e,{color:"#443e42",backgroundColor:"#FFFFFF"})},option:function(e,t){return Object.assign({},e,{fontSize:"14px",":hover":{backgroundColor:"#f0826d"},backgroundColor:t.isSelected?"#8f1b13":"transparent"})},singleValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValue:function(e){return Object.assign({},e,{fontSize:"14px"})},multiValueLabel:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{paddingRight:6})},multiValueRemove:function(e,t){return t.data.isCloseable?e:Object.assign({},e,{display:"none"})},input:function(e){return Object.assign({},e,{fontSize:"14px"})},indicatorsContainer:function(e){return Object.assign({},e,{pointerEvents:"none"})}},C=function(e){var t=e.label,n=e.onError,a=e.maxSelectedOptions,r=e.defaultValue,i=e.singleSelectOptions,c=e.className,s=Object(y.a)(e,["label","onError","maxSelectedOptions","defaultValue","singleSelectOptions","className"]),u=Object(l.useState)(r),d=u[0],p=u[1];Object(l.useEffect)((function(){s.onChange&&s.onChange(d),n&&n()}),[d]);return Object(o.c)("div",{className:O()("labelled-data-selector--wrapper",c)},Object(o.c)("label",null,Object(o.c)("b",null,t)),Object(o.c)(j.a,Object(v.a)({},s,{value:d,onChange:function(e){if(s.isMulti)if(e.length){var t=e.findIndex((function(e){return i.find((function(t){return t.value===e.value}))}));s.isMulti&&e.length>1&&-1!==t?p(0===t?e.slice(1):[e[t]]):a&&e.length>a?n&&n({type:"maxSelectedOptions",message:"Only up to "+a+" selections allowed"}):p(e)}else p(r);else p(e)},css:{marginRight:"25px"},styles:x,isClearable:"undefined"!==s.isClearable?s.isClearable:d.length>1})))};C.propTypes={label:p.a.string,options:p.a.array,maxSelectedOptions:p.a.number,onChange:p.a.func,onError:p.a.func,defaultValue:p.a.array,singleSelectOptions:p.a.array,isMulti:p.a.bool,isClearable:p.a.bool,className:p.a.string},C.defaultProps={maxSelectedOptions:2,singleSelectOptions:[]};var L=C,E=n(32);function S(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return N(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return N(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}function N(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n"+e.title+""}}}},color:M.rainbow,xAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13},splitLine:{show:!1}},yAxis:{axisLabel:{fontFamily:"Geomanist Regular,sans-serif",fontSize:13},splitLine:{show:!1}},axisPointer:{type:"none"},grid:{top:10}},B=(n(7),function(){return u.a.createElement("div",{className:"no-data"},"No Data")}),W=function(e,t,n){var a=e.slice();return t.forEach((function(t,o){void 0===a[o]?a[o]=n.cloneUnlessOtherwiseSpecified(t,n):n.isMergeableObject(t)?a[o]=q()(e[o],t,n):-1===e.indexOf(t)&&a.push(t)})),a},G=function(e,t,n,a,o,r){var i=e.series,c=e.mapping,s=i.map((function(l,u){return Object.assign({name:l,type:(d=e.type,d?"area"===d?"line":d:"bar")},"dicharts--ple-performance-analysis"!==e.className&&{stack:!e.type||["area","bar","column"].includes(e.type)?"School Type":void 0},{areaStyle:"area"===e.type?{}:void 0,smooth:!0,emphasis:{focus:"series"},label:{show:"dicharts--ple-performance-analysis"===e.className||u===i.length-1,position:"top",formatter:function(t){for(var n=0,a=0;aparseFloat(t[t.length-1])?[o,n[n.length-1]]:[o,"#b3adad"]})):[]},oe=function(e,t){return t&&"number"==typeof t.value?(e.dataPrefix||"")+''+(n=t.value,void 0===a&&(a=1),(n>=1e12?(n/1e12).toFixed(a)+"tn":n>=1e9?(n/1e9).toFixed(a)+"bn":n>=1e6?(n/1e6).toFixed(a)+"m":n>=1e3?(n/1e3).toFixed(a)+"k":n>=0?""+n.toFixed(a):n<=-1e12?(n/1e12).toFixed(a)+"tn":n<=-1e9?(n/1e9).toFixed(a)+"bn":n<=-1e6?(n/1e6).toFixed(a)+"m":n<=1e3?(n/1e3).toFixed(a)+"k":""+n.toFixed(a))+"")+(e.dataSuffix||""):"No Data";var n,a},re=function(e){var t=e.geometry&&e.geometry.coordinates;return t?new X.LngLat(t[0],t[1]):null},ie=function(e,t,n){var a=e.querySourceFeatures("composite",{sourceLayer:n.sourceLayer,filter:["in",n.nameProperty,ne(t,n.formatter)]});return a&&a.length?function(e){if(Array.isArray(e)){var t=e.map((function(e){return Object(ee.a)(e.geometry).geometry.coordinates}));return t.push(t[0]),re(Object(ee.a)(Object(te.f)([t])))}return re(Object(ee.a)(e))}(a):null},ce=function(e,t,n,a,o){return t.setLngLat(n).setHTML('\n
\n
\n '+a.toLowerCase()+"\n
\n "+(o?''+o+"":"")+"\n
\n ").addTo(e)},se=function(e,t,n){return t.find((function(t){var a=n?n(t.name):t.name;return e.toLowerCase()===(""+a).toLowerCase()}))},le=Object(l.createContext)(),ue=Object(l.createContext)(),de=n(35),pe=function(e){function t(t){var n;return(n=e.call(this,t)||this).state={hasError:!1},n}Object(de.a)(t,e),t.getDerivedStateFromError=function(){return{hasError:!0}};var n=t.prototype;return n.componentDidCatch=function(e,t){window.console.log("Error Boundary:",e,t)},n.render=function(){return this.state.hasError?u.a.createElement("div",null,"Something went wrong! Please contact your administrator"):this.props.children},t}(l.Component);pe.propTypes={children:p.a.any};var fe,be=pe,me=function(e,t){return e.find((function(e){return e.id===t}))},ge=function(e){return e.map((function(e){return{value:e.id,label:e.name}}))},he=function(e,t){var n=me(e,t);return n?n.indicators.map((function(e){return{value:e.id,label:e.name}})):[]},ve=function(e,t,n){if(t&&n){var a=me(e,t),o=a&&a.indicators&&a.indicators.length?a.indicators[0]:null;if(o&&o.yearRange)return k(o.yearRange).map((function(e){return{value:e,label:e}}))}return[]},ye=function(e){var t=Object(l.useContext)(ue),n=t.filterOptions,a=t.updateFilterOptions;return Object(l.useEffect)((function(){!n.topic&&e.length&&a({topic:e[0].id})}),[]),Object(l.useEffect)((function(){if(n.topic){var t=me(e,n.topic),o=t&&t.indicators&&t.indicators.length?t.indicators[0]:null;o&&a({indicator:o.id})}}),[n.topic]),{topicOptions:ge(e||[]),indicatorOptions:he(e,n.topic),yearOptions:ve(e,n.topic,n.indicator)}},we=function(){var e=Object(l.useContext)(ue),t=e.filters,n=e.topics,a=e.updateFilterOptions,r=ye(n),i=r.topicOptions,c=r.indicatorOptions,s=r.yearOptions;return Object(o.c)("form",{className:"form"},Object(o.c)("div",{className:O()("form-field","form-field--inline-block"),css:Object(o.b)(fe||(fe=Object(f.a)(["\n z-index: auto;\n margin-left: 5px;\n "])))},Object(o.c)(L,{label:t.topicLabel,options:i,defaultValue:[i[0]],classNamePrefix:"topic-selector",isClearable:!1,css:{minWidth:"100%"},onChange:function(e){return a({topic:e&&e.value})}}),c&&c.length?Object(o.c)(L,{label:t.indicatorLabel,options:c,defaultValue:[c[0]],classNamePrefix:"indicator-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){return a({indicator:e&&e.value})}}):null,s&&s.length?Object(o.c)(L,{label:t.yearLabel,options:s,defaultValue:[s[0]],classNamePrefix:"year-selector",isClearable:!1,css:{minWidth:"100%",marginTop:"1em"},onChange:function(e){Array.isArray(e)&&e.length?a({year:e[0].value}):e&&!Array.isArray(e)&&a({year:e.value})}}):null))},Oe=function(e){var t=e.children;return u.a.createElement("div",{className:"spotlight-legend","data-testid":"spotlight-legend"},l.Children.map(t,(function(e){return e})))};Oe.propTypes={children:p.a.any};var je=Oe,xe=function(e){var t=e.children,n=e.className,a=e.bgColor,o=e.textColor;return u.a.createElement("span",{className:n,"data-testid":"spotlight-legend-item"},t,u.a.createElement("style",null,"\n span."+n+" {\n background-color: "+(a||"#D1CBCF")+" !important;\n color: "+(o||"inherit")+";\n }\n "))};xe.propTypes={children:p.a.any,className:p.a.string,bgColor:p.a.string,textColor:p.a.string};var Ce,Le=xe,Ee=function(){var e,t,n=Object(l.useContext)(ue).activeIndicator;return u.a.createElement("div",{className:"spotlight__content"},u.a.createElement(be,null,u.a.createElement(we,null)),n?u.a.createElement(je,null,(e=n.range,t=n.colours,e&&t?e.map((function(n,a){return u.a.createElement(Le,{className:"item-"+n,bgColor:t[a],key:n},0===a?"< "+e[0]:e[a-1]+"-"+n)})).concat([u.a.createElement(Le,{className:"item-last",bgColor:t[t.length-1],key:e.length},"> "+e[e.length-1])]):null),u.a.createElement(Le,null,"no data / not applicable")):null)},Se=n(36),Ne={type:"shapefile",style:"mapbox://styles/edwinmp/ck42rrx240t8p1cqpkhgy2g0m/draft",sourceLayer:"Uganda_Sub-Counties_2019-8w0zb5",layerName:"uganda-Sub-counties-2019-8w0zb5",center:[32.655221,1.344666],zoom:8,minZoom:8,maxZoom:9,districtNameProperty:"District",nameProperty:"Subcounty",codeProperty:"scode2019",formatter:function(e,t){return void 0===t&&(t="map"),e.toUpperCase()}},Ie=function(e,t,n,a){n&&(e.setFilter(t,["==",a.nameProperty,ne(n.name,a.formatter)]),setTimeout((function(){if(n.coordinates)e.flyTo({center:n.coordinates,zoom:8.5});else{var t=a.formatter?a.formatter(n.name):n.name;!function e(t,n,a,o){return void 0===o&&(o=!0),new Promise((function(r,i){var c=ie(t,n,a);c?(t.flyTo({center:c,zoom:16}),r(c)):o?(t.flyTo({center:a.center,zoom:a.zoom||6.1}),setTimeout((function(){e(t,n,a,!1).then((function(e){return r(e)})).catch(i)}),500)):i(new Error("Location "+n+" not found!"))}))}(e,t,a)}}),500))},ke=function(e,t,n){if(!t)return[];if(!t.mapping)throw new Error("Mapping is required for indicator "+t.id);var a=t.mapping,o=a.location,r=a.value,i=a.year,c=n?e.filter((function(e){return e[i]===""+n})).map((function(e){return{name:e[o],value:Number(e[r])}})):e.map((function(e){return{name:e[o],value:Number(e[r])}}));return t.aggregator?function(e,t){var n=Object(Se.groupBy)(e,(function(e){return e.name}));return Object.keys(n).map((function(e){var a=n[e].reduce((function(e,t){return e+t.value}),0),o=a/n[e].length;return{name:e,value:"sum"===t?a:o}}))}(c,t.aggregator):c},Te=function(e,t,n,a){!function(e,t,n){var a=n.popup,o=n.nameProperty,r=n.formatter,i=n.data,c=function(e,t){if(e.features&&e.features[0].properties){var n=e.features[0].geometry;if("Polygon"===n.type||"MultiPolygon"===n.type)return e.features[0].properties[t]||null}return null}(t,o);if(c){var s=r?r(c,"tooltip"):c;if(i){var l=se(s,i);ce(e,a,t.lngLat,s,oe(n,l))}else ce(e,a,t.lngLat,s,"")}}(t,n,Object.assign({},a,{popup:e}))},De=new X.Popup({offset:5}),Ae=function(e,t,n){void 0===n&&(n={});var a=Object(l.useState)(),o=a[0],r=a[1],i=Object(l.useState)(n),u=i[0],d=i[1],p=Object(l.useState)([]),f=p[0],b=p[1],m=Object(l.useCallback)((function(e){o.getCanvas().style.cursor="pointer",Te(De,o,e,Object.assign({},t,{data:f},u))}),[o,f,u]),g=Object(l.useCallback)((function(){o.getCanvas().style.cursor="",De.remove()}),[o,e]);return Object(l.useEffect)((function(){o&&(o.getStyle().layers.forEach((function(e){["background","highlight"].includes(e.id)||o.setLayoutProperty(e.id,"visibility","none")})),function(e,t,n){t.clientWidth<700?e.setZoom(n.zoom?n.zoom-1:5):t.clientWidth<900?e.setZoom(n.minZoom?n.minZoom+.8:5.8):e.setZoom(n.zoom||6.1)}(o,o.getContainer(),t),o.off("mouseleave","highlight",g),o.off("mousemove","highlight",m),o.on("mousemove","highlight",m),o.on("mouseleave","highlight",g))}),[o,e,u,f]),Object(l.useEffect)((function(){var e=function(){var e=Object(s.a)(c.a.mark((function e(t){var n;return c.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,T(t);case 2:n=e.sent,b(ke(n,u.indicator,u.year));case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();u.indicator&&u.year&&e(u.indicator.url)}),[u.indicator,u.year]),{map:o,data:f,setData:b,setMap:r,setOptions:d}},Pe={topic:null,indicator:null,year:null},ze=b.a.div(Ce||(Ce=Object(f.a)(["\n position: absolute;\n top: 1.75em;\n z-index: 1;\n left: 1.4em;\n"])));function Fe(e,t){switch(t.type){case"UPDATE_FILTERS":return Object.assign({},e,{filterOptions:t.merge?Object.assign({},e.filterOptions,t.filterOptions):t.filterOptions,activeTopic:t.activeTopic,activeIndicator:t.activeIndicator});case"SET_DATA":return Object.assign({},e,{data:t.data});case"RESET_FILTERS":return Object.assign({},e,{filterOptions:Pe});default:throw new Error}}var _e={filterOptions:Pe},Re=function(e){var t=Object(l.useState)(!0),n=t[0],a=t[1],r=Object(l.useReducer)(Fe,_e),i=r[0],c=r[1],s=i.filterOptions,u=i.activeIndicator,d=i.activeTopic,p=Ae(e.location,Ne),f=p.data,b=p.setMap,m=p.setOptions;Object(l.useEffect)((function(){if(u){var e=s.year;m({dataPrefix:u.name+": ",dataSuffix:e&&" in "+e,indicator:u,year:e})}}),[u,s.year]);var g,h,v=function(t,n){void 0===n&&(n=!0);var a=function(e,t){var n=t.topic,a=t.indicator,o=t.year;if(n){var r=e.find((function(e){return e.id===n}));if(r&&a){var i=r.indicators.find((function(e){return e.id===a}));if(i)return{topic:r,indicator:i,year:o}}return{topic:r}}return{}}(e.configs.data,Object.assign({},s,t)),o=a.topic,r=a.indicator;c({type:"UPDATE_FILTERS",merge:n,filterOptions:t,activeTopic:o,activeIndicator:r})},y=(g=e.configs.data,h=s.topic,g.find((function(e){return e.id===h}))),w=Object(l.useMemo)((function(){return{filters:e.filters,topics:e.configs.data,filterOptions:s,updateFilterOptions:v,activeTopic:d,activeIndicator:u}}));return Object(o.c)(ue.Provider,{value:w},Object(o.c)("div",{className:"spotlight"},Object(o.c)("div",{className:"spotlight__aside spotlight__aside--no-margin",css:{minHeight:"600px"}},Object(o.c)(Ee,null)),Object(o.c)("div",{className:"spotlight__main spotlight__main--map"},n?Object(o.c)("div",null,"Loading ..."):null,y&&y.dashboardUrl?Object(o.c)(ze,null,Object(o.c)("a",{href:y.dashboardUrl,className:"button button--secondary--fill"},y.dashboardButtonCaption)):null,Object(o.c)(Q,{accessToken:"pk.eyJ1IjoiZWR3aW5tcCIsImEiOiJjazFsdHVtcG0wOG9mM2RueWJscHhmcXZqIn0.cDR43UvfMaOY9cNJsEKsvg",options:Object.assign({style:Ne.style,center:Ne.center,minZoom:Ne.minZoom||6,zoom:Ne.zoom||6.1,maxZoom:Ne.maxZoom||7,scrollZoom:!1},e.configs.options),style:{width:"100%",background:"#ffffff"},onLoad:function(e){a(!1),b(e)}},function(e,t,n,a,r){var i=[a].map((function(e){return Object(o.c)(K,{key:"highlight-hidden",id:e.layerName,source:"composite","source-layer":e.sourceLayer,show:!1})}));function c(e,t){Ie(e,t,n,Object.assign({},a,{nameProperty:a.districtNameProperty}))}return!e&&t.length?i.concat(Object(o.c)(K,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+1,type:"fill",paint:{"fill-color":{property:a.nameProperty,type:"categorical",default:"#D1CBCF",stops:ae(t,r.range,r.colours,a.formatter)},"fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c})):i.concat(Object(o.c)(K,{key:"highlight",id:"highlight",source:"composite","source-layer":a.sourceLayer,maxzoom:a.maxZoom&&a.maxZoom+1,type:"fill",paint:{"fill-color":"#D1CBCF","fill-opacity":.75,"fill-outline-color":"#ffffff"},onAdd:c}))}(n,f,e.location,Ne,u?{range:u.range,colours:u.colours}:{})))))};Re.defaultProps={data:[]},Re.propTypes={configs:p.a.object,filters:p.a.object,data:p.a.array,location:p.a.shape({name:p.a.string,fullName:p.a.string,coordinates:p.a.array})};var qe,Ve,Ue,Me,Ze,Be,We,Ge=Re,Je=b.a.div(qe||(qe=Object(f.a)(["\n background: #ffffff;\n width: 100%;\n height: 100%;\n display: flex;\n justify-content: center;\n align-items: center;\n position: absolute;\n"]))),He=function(){return u.a.createElement(Je,null,u.a.createElement(B,null))},Xe=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(r.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.map,o=e.location;a?n.render(u.a.createElement(Ge,{configs:a,location:o,filters:a.filters})):n.render(u.a.createElement(He,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Ye=n(37),Ke=function(e){var t=e.close,n=e.description,a=e.source;return Object(o.c)("div",{className:"spotlight-modal",css:Object(o.b)(Ue||(Ue=Object(f.a)(["\n font-size: 12px;\n "])))},Object(o.c)("a",{className:"close",onClick:t,css:Object(o.b)(Me||(Me=Object(f.a)(["\n cursor: pointer;\n position: absolute;\n display: block;\n padding: 5px 10px;\n line-height: 20px;\n right: 0px;\n top: 0px;\n font-size: 20px;\n background: transparent;\n color: #333131;\n font-weight: 900;\n "])))},"×"),Object(o.c)("div",{className:"content",css:Object(o.b)(Ze||(Ze=Object(f.a)(["\n width: 100%;\n padding: 10px 5px 10px 5px;\n "])))},Object(o.c)("p",{className:"description",css:Object(o.b)(Be||(Be=Object(f.a)(["\n font-size: 14px;\n "])))},n),a?Object(o.c)(u.a.Fragment,null,Object(o.c)("br",null),Object(o.c)("p",{className:"source",css:Object(o.b)(We||(We=Object(f.a)(["\n text-align: left;\n "])))},a?Object(o.c)(u.a.Fragment,null,Object(o.c)("b",{css:Object(o.b)(Ve||(Ve=Object(f.a)(["\n font-family: Geomanist Bold, sans-serif;\n "])))},"Source:"," "),a):null)," "):null))};Ke.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string,close:p.a.func.isRequired};var $e,Qe,et=Ke,tt=function(e){return Object(o.c)(Ye.a,{trigger:Object(o.c)("span",{className:"spotlight__stat-icon",css:Object(o.b)($e||($e=Object(f.a)(["\n display: inline-flex;\n margin-left: 2px;\n cursor: pointer;\n padding: 8px;\n "])))},Object(o.c)("i",{onClick:function(){document.querySelectorAll(".popup-content ").forEach((function(e){e.setAttribute("style","display:none;")}))},role:"presentation","aria-hidden":"true",className:"ico ico--12 ico-info-slate",css:Object(o.b)(Qe||(Qe=Object(f.a)(["\n top: -1px;\n "])))})),offsetX:20,arrowStyle:{height:"10px",width:"10px",position:"absolute",background:"rgb(255, 255, 255)",transform:"rotate(225deg)",margin:"-5px",zIndex:-1,boxShadow:"rgb(0 0 0 / 20%) 1px 1px 1px",bottom:"0%",left:"82px"},position:"bottom center",closeOnDocumentClick:!0,contentStyle:{zIndex:200,width:"350px",background:"#fff",fontWeight:400,fontStyle:"normal",fontSize:"12px",color:"#60575d",border:0,borderRadius:"0.28571429rem",boxShadow:"0 2px 4px 0 rgba(34, 36, 38, 0.12), 0 2px 10px 0 rgba(34, 36, 38, 0.15)",padding:"5px"}},(function(t){return Object(o.c)(et,{close:t,description:e.description,source:e.source})}))};tt.propTypes={description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string};var nt=tt,at=function(e){var t=e.meta,n=void 0===t?{}:t,a=e.heading,o=e.children;return u.a.createElement("div",{className:"spotlight__stat"},u.a.createElement("h3",{className:"spotlight__stat-heading"},a,n.description||n.source?u.a.createElement(nt,{description:n.description,source:n.source}):null),o)};at.defaultProps={meta:{}},at.propTypes={heading:p.a.string,meta:p.a.shape({description:p.a.oneOfType([p.a.string,p.a.element]),source:p.a.string}),children:p.a.any};var ot,rt=at,it=function(e){var t=e.value,n=e.note;return Object(o.c)("p",{className:"spotlight__stat-data"},t,n&&n.content?Object(o.c)("span",{className:"spotlight__stat-data__note",css:Object(o.b)(ot||(ot=Object(f.a)(["\n transform: none;\n position: relative;\n top: -10px;\n "])))},n.content," ",n.meta?Object(o.c)(nt,{description:n.meta.description,source:n.meta.source}):null):null)};it.propTypes={note:p.a.object,value:p.a.string};var ct,st=it,lt=function(e){var t=e.children;return Object(o.c)("article",{className:"tabs__content",css:Object(o.b)(ct||(ct=Object(f.a)(["\n z-index: 200;\n "])))},t)};lt.propTypes={children:p.a.any};var ut=lt,dt=function(e){var t=e.id,n=e.active,a=e.label,o=e.children,r=e.onActivate;return u.a.createElement("section",{className:"tabs__container",id:t},u.a.createElement("input",{className:"tabs__input",type:"radio",name:"sections",id:t+"-option",defaultChecked:n}),u.a.createElement("label",{className:"tabs__label",htmlFor:t+"-option",onClick:r},a),l.Children.map(o,(function(e){return Object(l.isValidElement)(e)&&e.type===ut?e:null})))};dt.propTypes={id:p.a.string.isRequired,label:p.a.string.isRequired,active:p.a.bool,onActivate:p.a.func,children:p.a.any};var pt=dt,ft=function(e){var t=e.children,n=e.onClick;return u.a.createElement("div",{className:"tabs__content__header",onClick:n},t)};ft.propTypes={children:p.a.any,onClick:p.a.func};var bt,mt,gt,ht,vt,yt=ft,wt=function(e,t){return t&&e?e.find((function(e){return e.id===t})):null},Ot=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,r=t.options,i="education",c=wt(r.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.education?n.education.find((function(e){return"Number of Schools"===e.caption})):null;return Object(o.c)(pt,{id:i,label:c.label||"Education",active:!!e.active||c.active},Object(o.c)(ut,null,Object(o.c)(yt,null,s?Object(o.c)("div",{css:Object(o.b)(bt||(bt=Object(f.a)(["\n display: flex;\n "])))},Object(o.c)("div",{css:Object(o.b)(mt||(mt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(o.c)("span",{css:Object(o.b)(gt||(gt=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(o.c)("b",{css:Object(o.b)(ht||(ht=Object(f.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(o.c)(nt,{description:"Last updated: "+s.lastUpdated})),c.dashboardURL?Object(o.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(o.c)("div",{className:"l-2up"},n&&n.education?n.education.filter((function(e){return"Number of Schools"!==e.caption})).map((function(e){return Object(o.c)("div",{className:"l-2up__col",key:e.caption},Object(o.c)(rt,{heading:e.caption,meta:{description:Object(o.c)("span",{css:Object(o.b)(vt||(vt=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(o.c)(st,{value:e.value})))})):null)))};Ot.propTypes={active:p.a.bool};var jt,xt,Ct,Lt,Et,St=Ot,Nt=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,r=t.options,i="overview",c=wt(r.tabs,i);return void 0===c.show||c.show?Object(o.c)(pt,{id:i,label:c.label||"Overview",active:!!e.active||c.active},Object(o.c)(ut,null,Object(o.c)(yt,null,n&&n.population?Object(o.c)("div",{css:Object(o.b)(jt||(jt=Object(f.a)(["\n display: flex;\n "])))},Object(o.c)("div",{css:Object(o.b)(xt||(xt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(o.c)("span",{css:Object(o.b)(Ct||(Ct=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Total Population in ",a.name," is"," "),Object(o.c)("b",{css:Object(o.b)(Lt||(Lt=Object(f.a)(["\n font-size: 3rem;\n "])))},I(n.population.value)),Object(o.c)(nt,{description:"Last updated: "+n.population.lastUpdated})),c.dashboardURL?Object(o.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null):null),Object(o.c)("div",{className:"l-2up"},n&&n.administration?n.administration.map((function(e){return Object(o.c)("div",{className:"l-2up__col",key:e.caption},Object(o.c)(rt,{heading:e.caption,meta:{description:Object(o.c)("span",{css:Object(o.b)(Et||(Et=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(o.c)(st,{value:e.value})))})):null))):null};Nt.propTypes={active:p.a.bool};var It,kt,Tt,Dt,At,Pt,zt=Nt,Ft=function(e){var t=Object(l.useContext)(le),n=t.data,a=t.location,r=t.options,i="production",c=wt(r.tabs,i);if(void 0!==c.show&&!c.show)return null;var s=n&&n.production?n.production.find((function(e){return""===e.caption})):null,u=function(){return c.dashboardURL?Object(o.c)("a",{href:c.dashboardURL,className:"button button--secondary--fill"},c.dashboardButtonCaption||"View Full Dashboard"):null};return Object(o.c)(pt,{id:i,label:c.label||"Production",active:!!e.active||c.active},Object(o.c)(ut,null,s?Object(o.c)(yt,null,Object(o.c)("div",{css:Object(o.b)(It||(It=Object(f.a)(["\n display: flex;\n "])))},Object(o.c)("div",{css:Object(o.b)(kt||(kt=Object(f.a)(["\n margin-right: 1rem;\n "])))},Object(o.c)("span",{css:Object(o.b)(Tt||(Tt=Object(f.a)(["\n font-size: 2.5rem;\n "])))},"Number of Schools in ",a.name," is"," "),Object(o.c)("b",{css:Object(o.b)(Dt||(Dt=Object(f.a)(["\n font-size: 3rem;\n "])))},I(s.value)),Object(o.c)(nt,{description:"Last updated: "+s.lastUpdated})),u())):u(),n&&n.production&&n.production.length?Object(o.c)("div",{className:"l-2up"},n.production.filter((function(e){return""!==e.caption})).map((function(e){return Object(o.c)("div",{className:"l-2up__col",key:e.caption},Object(o.c)(rt,{heading:e.caption,meta:{description:Object(o.c)("span",{css:Object(o.b)(At||(At=Object(f.a)(["\n display: flex;\n justify-content: center;\n "])))},"Last updated: "+e.lastUpdated)}},Object(o.c)(st,{value:e.value})))}))):Object(o.c)("div",{css:Object(o.b)(Pt||(Pt=Object(f.a)(["\n font-size: 16px;\n display: flex;\n justify-content: center;\n width: 100%;\n "])))},"No Production Data")))};Ft.propTypes={active:p.a.bool};var _t,Rt=Ft,qt=function(e){var t=e.children;return Object(o.c)("div",{className:"tabs",css:Object(o.b)(_t||(_t=Object(f.a)(["\n z-index: 0;\n "])))},t)};qt.propTypes={children:p.a.any};var Vt=qt,Ut=function(e){var t=Object(l.useState)({}),n=t[0],a=t[1];return Object(l.useEffect)((function(){e.data&&a(function(e){var t={},n=function(e){return{caption:e.Item,value:e.Value,lastUpdated:e["Last Updated"]}},a=e.find((function(e){return"Total Population"===e.Item}));return a&&(t.population=n(a)),t.administration=e.filter((function(e){return"Total Population"!==e.Item&&"Administration"===e.Department})).map(n),t.education=e.filter((function(e){return"Total Population"!==e.Item&&"Education"===e.Department})).map(n),t.production=e.filter((function(e){return"Total Population"!==e.Item&&"Production"===e.Department})).map(n),t}(e.data))}),[e.data]),Object(o.c)(le.Provider,{value:Object.assign({},e,{data:n})},Object(o.c)(Vt,null,Object(o.c)(zt,{active:!0}),Object(o.c)(St,null),Object(o.c)(Rt,null)))};Ut.propTypes={data:p.a.array.isRequired,location:p.a.object.isRequired,options:p.a.object.isRequired};var Mt=Ut,Zt=function(e){window.DICharts.handler.addChart({className:e,echarts:{onAdd:function(e){Array.prototype.forEach.call(e,(function(e){var t=new window.DICharts.Chart(e.parentElement);if(t.showLoading(),window.DIState){var n=Object(r.createRoot)(e);window.DIState.addListener((function(){t.showLoading();var e=window.DIState.getState,a=e.keyFacts,o=e.location;a&&a.url?T(a.url).then((function(e){Array.isArray(e)?n.render(u.a.createElement(Mt,{data:e,options:a,location:o})):e.results?n.render(u.a.createElement(Mt,{data:e.results,options:a,location:o})):(window.console.error("Invalid data shape. Expected an array or an object with a results property.",e),n.render(u.a.createElement(He,null)))})).catch((function(e){window.console.log(e),n.render(u.a.createElement(He,null))})):a&&a.data?n.render(u.a.createElement(Mt,{data:a.data,options:a,location:o})):n.render(u.a.createElement(He,null)),t.hideLoading()}))}else window.console.log("State is not defined")}))}}})},Bt=function(e){return u.a.createElement("div",{className:"table-styled"},u.a.createElement("table",null,e.children))};Bt.propTypes={children:p.a.any};var Wt=Bt,Gt=function(e){var t=function(e,t){return void 0===t&&(t=!1),e.map((function(e,n){return u.a.createElement("tr",{key:n},e.map((function(e,n){return t?u.a.createElement("th",{key:n},e):u.a.createElement("td",{key:n},e)})))}))};return u.a.createElement(Wt,null,u.a.createElement("thead",null,t(e.rows.filter((function(e,t){return 0===t})),!0)),u.a.createElement("tbody",null,t(e.rows.filter((function(e,t){return t>0})))))};Gt.propTypes={rows:p.a.arrayOf(p.a.array)};var Jt=Gt,Ht=function(e){(function(e){return e.className?e.mapping?e.mapping.rows?e.mapping.year?e.mapping.value?e.mapping.subCounty?!!e.mapping.level||(window.console.error("Invalid table config: mapping[mapping.level] is required!"),!1):(window.console.error("Invalid table config: mapping.subCounty is required!"),!1):(window.console.error("Invalid table config: mapping.value is required!"),!1):(window.console.error("Invalid table config: mapping.year is required!"),!1):(window.console.error("Invalid table config: mapping.series is required!"),!1):(window.console.error("Invalid table config: mapping is required!"),!1):(window.console.error("Invalid table config: className is required!"),!1)})(e)&&window.DICharts.handler.addChart({className:e.className,d3:{onAdd:function(t){T(e.url).then((function(n){Array.prototype.forEach.call(t,(function(t){var a=new window.DICharts.Chart(t.parentElement);a.showLoading();var o=Object(r.createRoot)(t),i="all",c="all";window.DIState.addListener((function(){a.showLoading();var r=window.DIState.getState,s=r.subCounty,u=r.level;if(s!==c||u!==i){c=s||"all",i=u||"all";var d=e.filters&&e.filters.subCounties?n.filter((function(t){return e.filters.subCounties.includes(t[e.mapping.subCounty])})):n,p=function(e,t,n,a){var o=e.rows,r=e.mapping,i=k(e.yearRange),c=["School Type"].concat(i),s=o.map((function(o){var c={};t.filter((function(e){return i.includes(Number(e[r.year]))&&e[r.rows]===o})).filter((function(e){return"all"===n||e[r.subCounty].toLowerCase()===n.toLowerCase()})).filter((function(e){return"all"===a||e[r.level].toLowerCase()===a.toLowerCase()})).forEach((function(e){var t=c[e[r.year]]||[];c[e[r.year]]=[].concat(t,[Number(e[r.value])])}));var s={};Object.keys(c).forEach((function(t){if(e.aggregator&&"sum"!==e.aggregator){if(e.aggregator&&"avg"===e.aggregator){var n=c[t].reduce((function(e,t){return e+t}),0);s[t]=n/c[t].length}}else s[t]=c[t].reduce((function(e,t){return e+t}),0)}));var l=i.map((function(e){return s[e]?s[e]:0}));return[o].concat(l)})),l=c.map((function(e,t){return 0===t?"Total":I(s.reduce((function(e,n){return"number"==typeof n[t]?e+n[t]:e}),0))})),u=s.map((function(e){return e.map((function(e){return"number"==typeof e?I(e):e}))}));return[c].concat(u,[l])}(e,d,c,i);o.render(Object(l.createElement)(Jt,{rows:p})),a.hideLoading(),t.parentElement.classList.add("auto-height")}}))}))}))}}})},Xt=function(){if(window.DIState){var e=[];window.DIState.addListener((function(){var t=window.DIState.getState.tables;t&&e.length!==t.length&&(e=t.filter((function(e){return"education"===e.target}))).forEach(Ht)}))}else window.console.log("State is not defined")};n(81);window.addEventListener("load",(function(){P("district-selectors"),Xe("dicharts--district-map"),Xt(),Zt("dicharts--keyfacts"),H()}))}},[[39,1,2]]]); \ No newline at end of file diff --git a/assets/vendor.js b/assets/vendor.js index 150d031f..bfbc693a 100644 --- a/assets/vendor.js +++ b/assets/vendor.js @@ -1,16 +1,16 @@ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(41)},function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"d",(function(){return h}));var r=n(0),i=(n(17),n(5)),o=(n(52),n(16),n(25),n(6)),a=n(9),s=n(8),l=function(e,t){var n=arguments;if(null==t||!i.e.call(t,"css"))return r.createElement.apply(void 0,n);var o=n.length,a=new Array(o);a[0]=i.b,a[1]=Object(i.d)(e,t);for(var s=2;s=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)},i={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},o=n(15),a=/[A-Z]|^ms/g,s=/_EMO_([^_]+?)_([^]*?)_EMO_/g,l=function(e){return 45===e.charCodeAt(1)},u=function(e){return null!=e&&"boolean"!=typeof e},c=Object(o.a)((function(e){return l(e)?e:e.replace(a,"-$&").toLowerCase()})),h=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(s,(function(e,t,n){return f={name:t,styles:n,next:f},t}))}return 1===i[e]||l(e)||"number"!=typeof t||0===t?t:t+"px"};function d(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(typeof n){case"boolean":return"";case"object":if(1===n.anim)return f={name:n.name,styles:n.styles,next:f},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)f={name:r.name,styles:r.styles,next:f},r=r.next;return n.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var i=0;i1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:s=n,n=.5*(s-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var m=_;function _(e,t){this.x=e,this.y=t}_.prototype={clone:function(){return new _(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},_.convert=function(e){return e instanceof _?e:Array.isArray(e)?new _(e[0],e[1]):e};const g=Math.PI/180,y=180/Math.PI;function v(e){return e*g}function x(e){return e*y}const b=[[0,0],[1,0],[1,1],[0,1]];function w(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function T(e,t,n,r){const i=new f(e,t,n,r);return function(e){return i.solve(e)}}const E=T(.25,.1,.25,1);function S(e,t,n){return Math.min(n,Math.max(t,e))}function k(e,t,n){return(n=S((n-e)/(t-e),0,1))*n*(3-2*n)}function C(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function M(e,t,n){if(!e.length)return n(null,[]);let r=e.length;const i=new Array(e.length);let o=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(o=e),i[a]=t,0==--r&&n(o,i)})})}function A(e){const t=[];for(const n in e)t.push(e[n]);return t}function I(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}let z=1;function P(){return z++}function O(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function D(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function L(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function R(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function B(e,t){return-1!==e.indexOf(t,e.length-t.length)}function F(e,t,n){const r={};for(const i in e)r[i]=t.call(n||this,e[i],i,e);return r}function j(e,t,n){const r={};for(const i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function U(e){return Array.isArray(e)?e.map(U):"object"==typeof e&&e?F(e,U):e}const V={};function N(e){V[e]||("undefined"!=typeof console&&console.warn(e),V[e]=!0)}function G(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function q(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,n,r,i)=>{const o=r||i;return t[n]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let W=null;function X(e){if(null==W){const t=e.navigator?e.navigator.userAgent:null;W=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return W}function H(e){try{const t=n[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Y(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const K="mapbox-tiles";let J,Q,ee=500,te=50;function ne(){try{return n.caches}catch(e){}}function re(){ne()&&!J&&(J=n.caches.open(K))}function ie(e){const t=e.indexOf("?");if(t<0)return e;const n=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e).filter(e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]});return n.length?`${e.slice(0,t)}?${n.join("&")}`:e.slice(0,t)}let oe=1/0;const ae={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(ae);class se extends Error{constructor(e,t,n){401===t&&ye(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const le=$()?()=>self.worker&&self.worker.referrer:()=>("blob:"===n.location.protocol?n.parent:n).location.href,ue=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(le())&&!/^\w+:/.test(r))){if(n.fetch&&n.Request&&n.AbortController&&n.Request.prototype.hasOwnProperty("signal"))return function(e,t){const r=new n.AbortController,i=new n.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:le(),signal:r.signal});let o=!1,a=!1;const s=(l=i.url).indexOf("sku=")>0&&ye(l);var l;"json"===e.type&&i.headers.set("Accept","application/json");const u=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&N(r),o&&l)return c(o);const u=Date.now();n.fetch(i).then(n=>{if(n.ok){const e=s?n.clone():null;return c(n,e,u)}return t(new se(n.statusText,n.status,e.url))}).catch(e=>{20!==e.code&&t(new Error(e.message))})},c=(r,s,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{a||(s&&l&&function(e,t,r){if(re(),!J)return;const i={status:t.status,statusText:t.statusText,headers:new n.Headers};t.headers.forEach((e,t)=>i.headers.set(t,e));const o=Z(t.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&i.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const a=i.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(e,t){if(void 0===Q)try{new Response(new ReadableStream),Q=!0}catch(e){Q=!1}Q?t(e.body):e.blob().then(t)}(t,t=>{const r=new n.Response(t,i);re(),J&&J.then(t=>t.put(ie(e.url),r)).catch(e=>N(e.message))}))}(i,s,l),o=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))}).catch(e=>{a||t(new Error(e.message))})};return s?function(e,t){if(re(),!J)return t(null);const n=ie(e.url);J.then(e=>{e.match(n).then(r=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=Z(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(r);e.delete(n),i&&e.put(n,r.clone()),t(null,r,i)}).catch(t)}).catch(t)}(i,u):u(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(e,t);if($()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return function(e,t){const r=new n.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response)}catch(e){return t(e)}t(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new se(r.statusText,r.status,e.url))},r.send(e.body),{cancel:()=>r.abort()}}(e,t)},ce=function(e,t){return ue(I(e,{type:"arrayBuffer"}),t)};function he(e){const t=n.document.createElement("a");return t.href=e,t.protocol===n.document.location.protocol&&t.host===n.document.location.host}const de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let fe,pe;fe=[],pe=0;const me=function(e,t){if(a.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),pe>=o.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return fe.push(n),n}pe++;let r=!1;const i=()=>{if(!r)for(r=!0,pe--;fe.length&&pe{i(),e?t(e):r&&(n.createImageBitmap?function(e,t){const r=new n.Blob([new Uint8Array(e)],{type:"image/png"});n.createImageBitmap(r).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(r,(e,n)=>t(e,n,o,a)):function(e,t){const r=new n.Image,i=n.URL;r.onload=()=>{t(null,r),i.revokeObjectURL(r.src),r.onload=null,n.requestAnimationFrame(()=>{r.src=de})},r.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new n.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?i.createObjectURL(o):de}(r,(e,n)=>t(e,n,o,a)))});return{cancel:()=>{s.cancel(),i()}}},_e="NO_ACCESS_TOKEN";function ge(e){return 0===e.indexOf("mapbox:")}function ye(e){return o.API_URL_REGEX.test(e)}function ve(e){return o.API_STYLE_REGEX.test(e)&&!xe(e)}function xe(e){return o.API_SPRITE_REGEX.test(e)}const be=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function we(e){const t=e.match(be);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Te(e){const t=e.params.length?"?"+e.params.join("&"):"";return`${e.protocol}://${e.authority}${e.path}${t}`}function Ee(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(n.atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}class Se{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Ee(o.ACCESS_TOKEN);let r="";return r=t&&t.u?n.btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):o.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${r}`:"mapbox.eventData:"+r}fetchEventData(){const e=H("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=n.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const i=n.localStorage.getItem(r);i&&(this.anonId=i)}catch(e){N("Unable to read from LocalStorage")}}saveEventData(){const e=H("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{n.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&n.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){N("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,r){if(!o.EVENTS_URL)return;const i=we(o.EVENTS_URL);i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},s=t?I(a,t):a,l={url:Te(i),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return ue(I(e,{method:"POST"}),t)}(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const ke=new class extends Se{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){o.EVENTS_URL&&o.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>ge(e)||ye(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Ee(o.ACCESS_TOKEN),n=t?t.u:o.ACCESS_TOKEN;let i=n!==this.eventData.tokenU;L(this.anonId)||(this.anonId=O(),i=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;i=i||n>=1||n<-1||e.getDate()!==t.getDate()}else i=!0;i?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=n)},e):this.processRequests()}},Ce=ke.postTurnstileEvent.bind(ke),Me=new class extends Se{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,r){this.skuToken=t,this.errorCb=r,o.EVENTS_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(_e)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),L(this.anonId)||(this.anonId=O()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},Ae=Me.postMapLoadEvent.bind(Me),Ie=new class extends Se{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){o.EVENTS_URL&&(e||o.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i}=this.queue.shift(),o=function(e){const t=n.performance.getEntriesByType("resource"),i=n.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const r of e[n]){const e=n+"RequestCount",i=n+"ResolveRangeMin",o=n+"ResolveRangeMax";t[i]=Math.min(t[i]||1/0,r.startTime),t[o]=Math.max(t[o]||-1/0,r.responseEnd),void 0===t[e]&&(t[e]=0),++t[e]}return t}(function(e,t){const n={};if(e)for(const r of e){const e=t(r);void 0===n[e]&&(n[e]=[]),n[e].push(r)}return n}(t,Be)),a=n.devicePixelRatio,s=n.navigator.connection||n.navigator.mozConnection||n.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},u=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const e in o)u(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(l.counters,"interactionRangeMin",e.interactionRange[0]),u(l.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const e of Object.keys(Le)){const t=Le[e],n=i.find(e=>e.name===t);n&&u(l.counters,t,n.startTime)}return u(l.counters,"visibilityHidden",e.visibilityHidden),u(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(ve(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}}(t)),u(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(l.attributes,"projection",e.projection.name),u(l.attributes,"zoom",e.zoom),u(l.metadata,"devicePixelRatio",a),u(l.metadata,"connectionEffectiveType",s?s.effectiveType:void 0),u(l.metadata,"navigatorUserAgent",n.navigator.userAgent),u(l.metadata,"screenWidth",n.screen.width),u(l.metadata,"screenHeight",n.screen.height),u(l.metadata,"windowWidth",n.innerWidth),u(l.metadata,"windowHeight",n.innerHeight),u(l.metadata,"mapWidth",e.width/a),u(l.metadata,"mapHeight",e.height/a),u(l.metadata,"webglRenderer",e.renderer),u(l.metadata,"webglVendor",e.vendor),u(l.metadata,"sdkVersion",r),u(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(i);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(t,o,()=>{},e)}},ze=Ie.postPerformanceEvent.bind(Ie),Pe=new class extends Se{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,r){if(!o.API_URL||!o.SESSION_PATH)return;const i=we(o.API_URL+o.SESSION_PATH);i.params.push("sku="+(t||"")),i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={url:Te(i),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return ue(I(e,{method:"GET"}),t)}(a,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,n,r){this.skuToken=t,this.errorCb=r,o.SESSION_PATH&&o.API_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(_e)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},Oe=Pe.getSessionAPI.bind(Pe),De=new Set,Le={create:"create",load:"load",fullLoad:"fullLoad"},Re={mark(e){n.performance.mark(e)},measure(e,t,r){n.performance.measure(e,t,r)}};function Be(e){const t=e.name.split("?")[0];return t.includes("mapbox-gl.js")?"javascript":t.includes("mapbox-gl.css")?"css":function(e){return o.API_FONTS_REGEX.test(e)}(t)?"fontRange":xe(t)?"sprite":ve(t)?"style":function(e){return o.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const Fe=n.performance;function je(e){const t=e?e.url.toString():void 0;return Fe.getEntriesByName(t)}let Ue,Ve,Ne,Ge;const qe={now:()=>void 0!==Ne?Ne:n.performance.now(),setNow(e){Ne=e},restoreNow(){Ne=void 0},frame(e){const t=n.requestAnimationFrame(e);return{cancel:()=>n.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:i}=e;Ge||(Ge=n.document.createElement("canvas"));const o=Ge.getContext("2d");if(!o)throw new Error("failed to create canvas 2d context");return(r>Ge.width||i>Ge.height)&&(Ge.width=r,Ge.height=i),o.clearRect(-t,-t,r+2*t,i+2*t),o.drawImage(e,0,0,r,i),o.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:e=>(Ue||(Ue=n.document.createElement("a")),Ue.href=e,Ue.href),get devicePixelRatio(){return n.devicePixelRatio},get prefersReducedMotion(){return!!n.matchMedia&&(null==Ve&&(Ve=n.matchMedia("(prefers-reduced-motion: reduce)")),Ve.matches)}};function $e(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function Ze(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class We{constructor(e,t={}){I(this,t),this.type=e}}class Xe extends We{constructor(e,t={}){super("error",I({error:e},t))}}class He{on(e,t){return this._listeners=this._listeners||{},$e(e,t,this._listeners),this}off(e,t){return Ze(e,t,this._listeners),Ze(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},$e(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new We(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of r)Ze(n,t,this._oneTimeListeners),t.call(this,e);const i=this._eventedParent;i&&(I(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof Xe&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var Ye=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":true,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"cross-faded"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"cross-faded":{"type":"property-type"},"cross-faded-data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Ke(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}function Je(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function Qe(e){if(Array.isArray(e))return e.map(Qe);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const n in e)t[n]=Qe(e[n]);return t}return Je(e)}class et extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var tt=et;class nt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,n]of t)this.bindings[e]=n}concat(e){return new nt(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(e+" not found in scope.")}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var rt=nt;const it={kind:"null"},ot={kind:"number"},at={kind:"string"},st={kind:"boolean"},lt={kind:"color"},ut={kind:"object"},ct={kind:"value"},ht={kind:"collator"},dt={kind:"formatted"},ft={kind:"resolvedImage"};function pt(e,t){return{kind:"array",itemType:e,N:t}}function mt(e){if("array"===e.kind){const t=mt(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const _t=[it,ot,at,st,lt,dt,ut,pt(ct),ft];function gt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!gt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of _t)if(!gt(e,t))return null}return`Expected ${mt(e)} but found ${mt(t)} instead.`}function yt(e,t){return t.some(t=>t.kind===e.kind)}function vt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}var xt,bt={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 wt(e){return(e=Math.round(e))<0?0:e>255?255:e}function Tt(e){return wt("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function Et(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function St(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{xt={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in bt)return bt[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var o=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=Et(a.pop());case"rgb":return 3!==a.length?null:[Tt(a[0]),Tt(a[1]),Tt(a[2]),s];case"hsla":if(4!==a.length)return null;s=Et(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=Et(a[1]),c=Et(a[2]),h=c<=.5?c*(u+1):c+u-c*u,d=2*c-h;return[wt(255*St(d,h,l+1/3)),wt(255*St(d,h,l)),wt(255*St(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class kt{constructor(e,t,n,r=1){this.r=e,this.g=t,this.b=n,this.a=r}static parse(e){if(!e)return;if(e instanceof kt)return e;if("string"!=typeof e)return;const t=xt(e);return t?new kt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,n,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(n)},${r})`}toArray(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*n/r,r]}toArray01(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,n/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}}kt.black=new kt(0,0,0,1),kt.white=new kt(1,1,1,1),kt.transparent=new kt(0,0,0,0),kt.red=new kt(1,0,0,1),kt.blue=new kt(0,0,1,1);var Ct=kt;class Mt{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class At{constructor(e,t,n,r,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i}}class It{constructor(e){this.sections=e}static fromString(e){return new It([new At(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof It?e:It.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class zt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new zt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Pt(e,t,n,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ot(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Ct)return!0;if(e instanceof Mt)return!0;if(e instanceof It)return!0;if(e instanceof zt)return!0;if(Array.isArray(e)){for(const t of e)if(!Ot(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Ot(e[t]))return!1;return!0}return!1}function Dt(e){if(null===e)return it;if("string"==typeof e)return at;if("boolean"==typeof e)return st;if("number"==typeof e)return ot;if(e instanceof Ct)return lt;if(e instanceof Mt)return ht;if(e instanceof It)return dt;if(e instanceof zt)return ft;if(Array.isArray(e)){const t=e.length;let n;for(const t of e){const e=Dt(t);if(n){if(n===e)continue;n=ct;break}n=e}return pt(n||ct,t)}return ut}function Lt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Ct||e instanceof It||e instanceof zt?e.toString():JSON.stringify(e)}class Rt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ot(e[1]))return t.error("invalid value");const n=e[1];let r=Dt(n);const i=t.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Rt(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Ct?["rgba"].concat(this.value.toArray()):this.value instanceof It?this.value.serialize():this.value}}var Bt=Rt,Ft=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const jt={string:at,number:ot,boolean:st,object:ut};class Ut{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,r=1;const i=e[0];if("array"===i){let i,o;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in jt)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=jt[n],r++}else i=ct;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}n=pt(i,o)}else n=jt[i];const o=[];for(;re.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}var Vt=Ut;class Nt{constructor(e){this.type=dt,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=e.length-1;++n){const o=e[n];if(i&&"object"==typeof o&&!Array.isArray(o)){i=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,ot),!e))return null;let n=null;if(o["text-font"]&&(n=t.parse(o["text-font"],1,pt(at)),!n))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,lt),!a))return null;const s=r[r.length-1];s.scale=e,s.font=n,s.textColor=a}else{const o=t.parse(e[n],1,ct);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Nt(r)}evaluate(e){return new It(this.sections.map(t=>{const n=t.content.evaluate(e);return Dt(n)===ft?new At("",n,null,null,null):new At(Lt(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class Gt{constructor(e){this.type=ft,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,at);return n?new Gt(n):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),n=zt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const qt={"to-boolean":st,"to-color":lt,"to-number":ot,"to-string":at};class $t{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0];if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return t.error("Expected one argument.");const r=qt[n],i=[];for(let n=1;n4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Pt(t[0],t[1],t[2],t[3]),!n))return new Ct(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ft(n||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ft(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?It.fromString(Lt(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?zt.fromString(Lt(this.args[0].evaluate(e))):Lt(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Nt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new Gt(this.args[0]).serialize();const e=["to-"+this.type.kind];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Zt=$t;const Wt=["Unknown","Point","LineString","Polygon"];var Xt=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Wt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Ct.parse(e)),t}};class Ht{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const n=e[0],r=Ht.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let s=null;for(const[r,o]of a){s=new Tn(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(mt).join(", ")})`:`(${mt(t.type)}...)`;var t}).join(" | "),r=[];for(let n=1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function tn(e,t){const n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*Jt),Math.round(r*i*Jt)]}function nn(e,t,n){const r=e[0]-t[0],i=e[1]-t[1],o=e[0]-n[0],a=e[1]-n[1];return r*a-o*i==0&&r*o<=0&&i*a<=0}function rn(e,t){let n=!1;for(let a=0,s=t.length;a(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-i[0])*(r[1]-i[1])/(o[1]-i[1])+i[0]&&(n=!n)}}var r,i,o;return n}function on(e,t){for(let n=0;n0&&s<0||a<0&&s>0}function sn(e,t,n){for(const u of n)for(let n=0;nn[2]){const t=.5*r;let i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;0===i&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}Qt(t,e)}function fn(e,t,n,r){const i=Math.pow(2,r.z)*Jt,o=[r.x*Jt,r.y*Jt],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];dn(r,t,n,i),a.push(r)}return a}function pn(e,t,n,r){const i=Math.pow(2,r.z)*Jt,o=[r.x*Jt,r.y*Jt],a=[];if(!e)return a;for(const n of e){const e=[];for(const r of n){const n=[r.x+o[0],r.y+o[1]];Qt(t,n),e.push(n)}a.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)dn(r,t,n,i)}var s;return a}class mn{constructor(e,t){this.type=st,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ot(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!gn(e)&&(t=!1)}),t}function yn(e){if(e instanceof Yt&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!yn(e)&&(t=!1)}),t}function vn(e,t){if(e instanceof Yt&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!vn(e,t)&&(n=!1)}),n}class xn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new xn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var bn=xn;class wn{constructor(e,t=[],n,r=new rt,i=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=i,this.expectedType=n}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Vt(t,[e]):"coerce"===n?new Zt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,i=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||"coerce");else r=n(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Bt)&&"resolvedImage"!==r.type.kind&&function e(t){if(t instanceof bn)return e(t.boundExpression);if(t instanceof Yt&&"error"===t.name)return!1;if(t instanceof Kt)return!1;if(t instanceof _n)return!1;const n=t instanceof Zt||t instanceof Vt;let r=!0;return t.eachChild(t=>{r=n?r&&e(t):r&&t instanceof Bt}),!!r&&gn(t)&&vn(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}(r)){const t=new Xt;try{r=new Bt(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){const r="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new wn(this.registry,r,t||null,i,this.errors)}error(e,...t){const n=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new tt(n,e))}checkSubtype(e,t){const n=gt(e,t);return n&&this.error(n),n}}var Tn=wn;function En(e,t){const n=e.length-1;let r,i,o=0,a=n,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],i=e[s+1],r<=t){if(s===n||tt))throw new Ft("Input is not a number.");a=s-1}return 0}class Sn{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,ot);if(!n)return null;const r=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let n=1;n=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,r.push([o,u])}return new Sn(i,n,r)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[En(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var kn=Sn;function Cn(e,t,n){return e*(1-n)+t*n}var Mn=Object.freeze({__proto__:null,number:Cn,color:function(e,t,n){return new Ct(Cn(e.r,t.r,n),Cn(e.g,t.g,n),Cn(e.b,t.b,n),Cn(e.a,t.a,n))},array:function(e,t,n){return e.map((e,r)=>Cn(e,t[r],n))}});const An=6/29*3*(6/29),In=Math.PI/180,zn=180/Math.PI;function Pn(e){return e>.008856451679035631?Math.pow(e,1/3):e/An+4/29}function On(e){return e>6/29?e*e*e:An*(e-4/29)}function Dn(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Ln(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Rn(e){const t=Ln(e.r),n=Ln(e.g),r=Ln(e.b),i=Pn((.4124564*t+.3575761*n+.1804375*r)/.95047),o=Pn((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-Pn((.0193339*t+.119192*n+.9503041*r)/1.08883)),alpha:e.a}}function Bn(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*On(t),n=.95047*On(n),r=1.08883*On(r),new Ct(Dn(3.2404542*n-1.5371385*t-.4985314*r),Dn(-.969266*n+1.8760108*t+.041556*r),Dn(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function Fn(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const jn={forward:Rn,reverse:Bn,interpolate:function(e,t,n){return{l:Cn(e.l,t.l,n),a:Cn(e.a,t.a,n),b:Cn(e.b,t.b,n),alpha:Cn(e.alpha,t.alpha,n)}}},Un={forward:function(e){const{l:t,a:n,b:r}=Rn(e),i=Math.atan2(r,n)*zn;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*In,n=e.c;return Bn({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:Fn(e.h,t.h,n),c:Cn(e.c,t.c,n),l:Cn(e.l,t.l,n),alpha:Cn(e.alpha,t.alpha,n)}}};var Vn=Object.freeze({__proto__:null,lab:jn,hcl:Un});class Nn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if("exponential"===e.name)i=Gn(t,e.base,n,r);else if("linear"===e.name)i=Gn(t,1,n,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;i=new f(o[0],o[1],o[2],o[3]).solve(Gn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error("Unknown interpolation type "+String(r[0]),1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,ot),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=lt:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e=n)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(r,l,s);if(!u)return null;s=s||u.type,a.push([n,u])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Nn(s,n,r,i,a):t.error(`Type ${mt(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);const o=En(t,r),a=Nn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?Mn[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Un.reverse(Un.interpolate(Un.forward(s),Un.forward(l),a)):jn.reverse(jn.interpolate(jn.forward(s),jn.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;egt(r,e.type));return new $n(o?ct:n,i)}evaluate(e){let t,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(e),n&&n instanceof zt&&!n.available&&(t||(t=n),n=null,r===this.args.length))return t;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Zn=$n;class Wn{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 n=[];for(let r=1;r=n.length)throw new Ft(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new Ft(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Yn=Hn;class Kn{constructor(e,t){this.type=st,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ct),r=t.parse(e[2],2,ct);return n&&r?yt(n.type,[st,at,ot,it,ct])?new Kn(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${mt(n.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!vt(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${mt(Dt(t))} instead.`);if(!vt(n,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${mt(Dt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Jn=Kn;class Qn{constructor(e,t,n){this.type=ot,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ct),r=t.parse(e[2],2,ct);if(!n||!r)return null;if(!yt(n.type,[st,at,ot,it,ct]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${mt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ot);return i?new Qn(n,r,i):null}return new Qn(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!vt(t,["boolean","string","number","null"]))throw new Ft(`Expected first argument to be of type boolean, string, number or null, but found ${mt(Dt(t))} instead.`);if(!vt(n,["string","array"]))throw new Ft(`Expected second argument to be of type array or string, but found ${mt(Dt(n))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return n.indexOf(t,r)}return n.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var er=Qn;class tr{constructor(e,t,n,r,i,o){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i={},o=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,Dt(e)))return null}else n=Dt(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=o.length}const c=t.parse(l,a,r);if(!c)return null;r=r||c.type,o.push(c)}const a=t.parse(e[1],1,ct);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new tr(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(Dt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=n.length,n.push([this.cases[e],[e]])):n[t][1].push(e)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of n)e.push(1===r.length?i(r[0]):r.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var nr=tr;class rr{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var ir=rr;class or{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ct),r=t.parse(e[2],2,ot);if(!n||!r)return null;if(!yt(n.type,[pt(ct),at,ct]))return t.error(`Expected first argument to be of type array or string, but found ${mt(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,ot);return i?new or(n.type,n,r,i):null}return new or(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!vt(t,["string","array"]))throw new Ft(`Expected first argument to be of type array or string, but found ${mt(Dt(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(n,r)}return t.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var ar=or;function sr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function lr(e,t,n,r){return 0===r.compare(t,n)}function ur(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=st,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const n=e[0];let o=t.parse(e[1],1,ct);if(!o)return null;if(!sr(n,o.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${mt(o.type)}'.`);let a=t.parse(e[2],2,ct);if(!a)return null;if(!sr(n,a.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${mt(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${mt(o.type)}' and '${mt(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Vt(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Vt(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,ht),!s)return null}return new i(o,a,s)}evaluate(i){const o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const t=Dt(o),n=Dt(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new Ft(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Dt(o),n=Dt(a);if("string"!==e.kind||"string"!==n.kind)return t(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):t(i,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const cr=ur("==",(function(e,t,n){return t===n}),lr),hr=ur("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!lr(0,t,n,r)})),dr=ur("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),pr=ur("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),mr=ur(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class _r{constructor(e,t,n,r,i,o){this.type=at,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,ot);if(!n)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=t.parse(r.locale,1,at),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,at),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,at),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,ot),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,ot),!l)?null:new _r(n,i,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class gr{constructor(e){this.type=ot,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error(`Expected argument of type string or array, but found ${mt(n.type)} instead.`):new gr(n):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new Ft(`Expected value to be of type string or array, but found ${mt(Dt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const yr={"==":cr,"!=":hr,">":fr,"<":dr,">=":mr,"<=":pr,array:Vt,at:Yn,boolean:Vt,case:ir,coalesce:Zn,collator:Kt,format:Nt,image:Gt,in:Jn,"index-of":er,interpolate:qn,"interpolate-hcl":qn,"interpolate-lab":qn,length:gr,let:Xn,literal:Bt,match:nr,number:Vt,"number-format":_r,object:Vt,slice:ar,step:kn,string:Vt,"to-boolean":Zt,"to-color":Zt,"to-number":Zt,"to-string":Zt,var:bn,within:_n};function vr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);const o=i?i.evaluate(e):1,a=Pt(t,n,r,o);if(a)throw new Ft(a);return new Ct(t/255*o,n/255*o,r/255*o,o)}function xr(e,t){return e in t}function br(e,t){const n=t[e];return void 0===n?null:n}function wr(e){return{type:e}}Yt.register(yr,{error:[{kind:"error"},[at],(e,[t])=>{throw new Ft(t.evaluate(e))}],typeof:[at,[ct],(e,[t])=>mt(Dt(t.evaluate(e)))],"to-rgba":[pt(ot,4),[lt],(e,[t])=>t.evaluate(e).toArray()],rgb:[lt,[ot,ot,ot],vr],rgba:[lt,[ot,ot,ot,ot],vr],has:{type:st,overloads:[[[at],(e,[t])=>xr(t.evaluate(e),e.properties())],[[at,ut],(e,[t,n])=>xr(t.evaluate(e),n.evaluate(e))]]},get:{type:ct,overloads:[[[at],(e,[t])=>br(t.evaluate(e),e.properties())],[[at,ut],(e,[t,n])=>br(t.evaluate(e),n.evaluate(e))]]},"feature-state":[ct,[at],(e,[t])=>br(t.evaluate(e),e.featureState||{})],properties:[ut,[],e=>e.properties()],"geometry-type":[at,[],e=>e.geometryType()],id:[ct,[],e=>e.id()],zoom:[ot,[],e=>e.globals.zoom],pitch:[ot,[],e=>e.globals.pitch||0],"distance-from-center":[ot,[],e=>e.distanceFromCenter()],"heatmap-density":[ot,[],e=>e.globals.heatmapDensity||0],"line-progress":[ot,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[ot,[],e=>e.globals.skyRadialProgress||0],accumulated:[ct,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[ot,wr(ot),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[ot,wr(ot),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:ot,overloads:[[[ot,ot],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[ot],(e,[t])=>-t.evaluate(e)]]},"/":[ot,[ot,ot],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[ot,[ot,ot],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[ot,[],()=>Math.LN2],pi:[ot,[],()=>Math.PI],e:[ot,[],()=>Math.E],"^":[ot,[ot,ot],(e,[t,n])=>Math.pow(t.evaluate(e),n.evaluate(e))],sqrt:[ot,[ot],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[ot,[ot],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[ot,[ot],(e,[t])=>Math.log(t.evaluate(e))],log2:[ot,[ot],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[ot,[ot],(e,[t])=>Math.sin(t.evaluate(e))],cos:[ot,[ot],(e,[t])=>Math.cos(t.evaluate(e))],tan:[ot,[ot],(e,[t])=>Math.tan(t.evaluate(e))],asin:[ot,[ot],(e,[t])=>Math.asin(t.evaluate(e))],acos:[ot,[ot],(e,[t])=>Math.acos(t.evaluate(e))],atan:[ot,[ot],(e,[t])=>Math.atan(t.evaluate(e))],min:[ot,wr(ot),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[ot,wr(ot),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[ot,[ot],(e,[t])=>Math.abs(t.evaluate(e))],round:[ot,[ot],(e,[t])=>{const n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[ot,[ot],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[ot,[ot],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[st,[at,ct],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[st,[ct],(e,[t])=>e.id()===t.value],"filter-type-==":[st,[at],(e,[t])=>e.geometryType()===t.value],"filter-<":[st,[at,ct],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{const n=e.id(),r=t.value;return typeof n==typeof r&&n":[st,[at,ct],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[st,[ct],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[st,[at,ct],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[st,[ct],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[st,[at,ct],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[st,[ct],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[st,[ct],(e,[t])=>t.value in e.properties()],"filter-has-id":[st,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[st,[pt(at)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[st,[pt(ct)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[st,[at,pt(ct)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[st,[at,pt(ct)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){const i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:st,overloads:[[[st,st],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[wr(st),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:st,overloads:[[[st,st],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[wr(st),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[st,[st],(e,[t])=>!t.evaluate(e)],"is-supported-script":[st,[at],(e,[t])=>{const n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[at,[at],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[at,[at],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[at,wr(ct),(e,t)=>t.map(t=>Lt(t.evaluate(e))).join("")],"resolved-locale":[at,[ht],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Tr=yr;function Er(e){return{result:"success",value:e}}function Sr(e){return{result:"error",value:e}}function kr(e){return"data-driven"===e["property-type"]||"cross-faded-data-driven"===e["property-type"]}function Cr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Mr(e){return!!e.expression&&e.expression.interpolated}function Ar(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Ir(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function zr(e){return e}function Pr(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function Or(e,t,n,r,i){return Pr(typeof n===i?r[n]:void 0,e.default,t.default)}function Dr(e,t,n){if("number"!==Ar(n))return Pr(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];const i=En(e.stops.map(e=>e[0]),n);return e.stops[i][1]}function Lr(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Ar(n))return Pr(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const o=En(e.stops.map(e=>e[0]),n),a=function(e,t,n,r){const i=r-n,o=e-n;return 0===i?0:1===t?o/i:(Math.pow(t,o)-1)/(Math.pow(t,i)-1)}(n,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let u=Mn[t.type]||zr;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Vn[e.colorSpace];u=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==n)return u(t,n,a)}}:u(s,l,a)}function Rr(e,t,n){return"color"===t.type?n=Ct.parse(n):"formatted"===t.type?n=It.fromString(n.toString()):"resolvedImage"===t.type?n=zt.fromString(n.toString()):Ar(n)===t.type||"enum"===t.type&&t.values[n]||(n=void 0),Pr(n,e.default,t.default)}class Br{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Xt,this._defaultValue=t?function(e){return"color"===e.type&&(Ir(e.default)||Array.isArray(e.default))?new Ct(0,0,0,0):"color"===e.type?Ct.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,n,r,i,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new Ft(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function Fr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Tr}function jr(e,t){const n=new Tn(Tr,[],t?function(e){const t={color:lt,string:at,number:ot,enum:at,boolean:st,formatted:dt,resolvedImage:ft};return"array"===e.type?pt(t[e.value]||ct,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Er(new Br(r,t)):Sr(n.errors)}class Ur{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!yn(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}}class Vr{constructor(e,t,n,r){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!yn(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}interpolationFactor(e,t,n){return this.interpolationType?qn.interpolationFactor(this.interpolationType,e,t,n):0}}function Nr(e,t){if("error"===(e=jr(e,t)).result)return e;const n=e.value.expression,r=gn(n);if(!r&&!kr(t))return Sr([new tt("","data expressions not supported")]);const i=vn(n,["zoom","pitch","distance-from-center"]);if(!i&&!Cr(t))return Sr([new tt("","zoom expressions not supported")]);const o=function e(t){let n=null;if(t instanceof Xn)n=e(t.result);else if(t instanceof Zn){for(const r of t.args)if(n=e(r),n)break}else(t instanceof kn||t instanceof qn)&&t.input instanceof Yt&&"zoom"===t.input.name&&(n=t);return n instanceof tt||t.eachChild(t=>{const r=e(t);r instanceof tt?n=r:!n&&r?n=new tt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new tt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}(n);return o||i?o instanceof tt?Sr([o]):o instanceof qn&&!Mr(t)?Sr([new tt("",'"interpolate" expressions cannot be used with this property')]):Er(o?new Vr(r?"camera":"composite",e.value,o.labels,o instanceof qn?o.interpolation:void 0):new Ur(r?"constant":"source",e.value)):Sr([new tt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Gr{constructor(e,t){this._parameters=e,this._specification=t,Ke(this,function e(t,n){const r="color"===n.type,i=t.stops&&"object"==typeof t.stops[0][0],o=i||!(i||void 0!==t.property),a=t.type||(Mr(n)?"exponential":"interval");if(r&&((t=Ke({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],Ct.parse(e[1])])),t.default=Ct.parse(t.default?t.default:n.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Vn[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,l,u;if("exponential"===a)s=Lr;else if("interval"===a)s=Dr;else if("categorical"===a){s=Or,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=Rr}if(i){const r={},i=[];for(let e=0;ee[0]),evaluate:({zoom:e},r)=>Lr({stops:o,base:t.base},n,e).evaluate(e,r)}}if(o){const e="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:qn.interpolationFactor.bind(void 0,e),zoomStops:t.stops.map(e=>e[0]),evaluate:({zoom:e})=>s(t,n,e,l,u)}}return{kind:"source",evaluate(e,r){const i=r&&r.properties?r.properties[t.property]:void 0;return void 0===i?Pr(t.default,n.default):s(t,n,i,l,u)}}}(this._parameters,this._specification))}static deserialize(e){return new Gr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}class qr{constructor(e,t,n,r){this.message=(e?e+": ":"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function $r(e){const t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=Ar(n);if("object"!==l)return[new qr(t,n,`object expected, ${l} found`)];for(const e in n){const l=e.split(".")[0],u=r[l]||r["*"];let c;i[l]?c=i[l]:r[l]?c=xi:i["*"]?c=i["*"]:r["*"]&&(c=xi),c?s=s.concat(c({key:(t?t+".":t)+e,value:n[e],valueSpec:u,style:o,styleSpec:a,object:n,objectKey:e},n)):s.push(new qr(t,n[e],`unknown property "${e}"`))}for(const e in r)i[e]||r[e].required&&void 0===r[e].default&&void 0===n[e]&&s.push(new qr(t,n,`missing required property "${e}"`));return s}function Zr(e){const t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,o=e.key,a=e.arrayElementValidator||xi;if("array"!==Ar(t))return[new qr(o,t,`array expected, ${Ar(t)} found`)];if(n.length&&t.length!==n.length)return[new qr(o,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.lengthi)return[new qr(t,n,`${n} is greater than the maximum value ${i}`)]}return[]}function Xr(e){const t=e.valueSpec,n=Je(e.value.type);let r,i,o,a={};const s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===Ar(e.value.stops)&&"array"===Ar(e.value.stops[0])&&"object"===Ar(e.value.stops[0][0]),c=$r({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new qr(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Zr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Ar(r)&&0===r.length&&t.push(new qr(e.key,r,"array must have at least one stop")),t},default:function(e){return xi({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&c.push(new qr(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new qr(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Mr(e.valueSpec)&&c.push(new qr(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!kr(e.valueSpec)?c.push(new qr(e.key,e.value,"property functions not supported")):s&&!Cr(e.valueSpec)&&c.push(new qr(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new qr(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const r=e.value,s=e.key;if("array"!==Ar(r))return[new qr(s,r,`array expected, ${Ar(r)} found`)];if(2!==r.length)return[new qr(s,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Ar(r[0]))return[new qr(s,r,`object expected, ${Ar(r[0])} found`)];if(void 0===r[0].zoom)return[new qr(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new qr(s,r,"object stop key must have value")];const t=Je(r[0].zoom);if("number"!=typeof t)return[new qr(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new qr(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,i=void 0,a={}),n=n.concat($r({key:s+"[0]",value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Wr,value:d}}))}else n=n.concat(d({key:s+"[0]",value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return Fr(Qe(r[1]))?n.concat([new qr(s+"[1]",r[1],"expressions are not allowed in function stops.")]):n.concat(xi({key:s+"[1]",value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const s=Ar(e.value),l=Je(e.value),u=null!==e.value?e.value:o;if(r){if(s!==r)return[new qr(e.key,u,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new qr(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let r=`number expected, ${s} found`;return kr(t)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new qr(e.key,u,r)]}return"categorical"!==n||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&"number"==typeof l&&"number"==typeof i&&void 0!==i&&lnew qr(`${e.key}${t.key}`,e.value,t.message));const n=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!n.outputDefined())return[new qr(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!yn(n))return[new qr(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return function e(t,n){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const e of n.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return t instanceof Yt&&r.has(t.name)?[new qr(n.key,n.value,`["${t.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(t.eachChild(t=>{i.push(...e(t,n))}),i)}(n,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!vn(n,["zoom","feature-state"]))return[new qr(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!gn(n))return[new qr(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Yr(e){const t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(Je(n))&&i.push(new qr(t,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(Je(n))&&i.push(new qr(t,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function Kr(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Kr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Jr(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Kr(e)||(e=ri(e));const n=e;let r=!0;try{r=function(e){if(!Qr(e))return e;let t=Qe(e);return function e(t){let n=!1;const r=[];if("case"===t[0]){for(let e=1;ee(t))}(t),t}(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n `)}const i=Ye["filter_"+t],o=jr(r,i);let a=null;if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(e,t,n)=>o.value.evaluate(e,t,{},n);let s=null,l=null;if(r!==n){const e=jr(n,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,n,r,i,o)=>e.value.evaluate(t,n,{},r,void 0,void 0,i,o),l=!gn(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:ni(r),needFeature:!!l}}function Qr(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t",">=","<","<=","to-boolean"]);function ti(e,t){return et?1:0}function ni(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?ii(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(ri))):"all"===t?["all"].concat(e.slice(1).map(ri)):"none"===t?["all"].concat(e.slice(1).map(ri).map(si)):"in"===t?oi(e[1],e.slice(2)):"!in"===t?si(oi(e[1],e.slice(2))):"has"===t?ai(e[1]):"!has"===t?si(ai(e[1])):"within"!==t||e;var n}function ii(e,t,n){switch(e){case"$type":return["filter-type-"+n,t];case"$id":return["filter-id-"+n,t];default:return["filter-"+n,e,t]}}function oi(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(ti)]]:["filter-in-small",e,["literal",t]]}}function ai(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function si(e){return["!",e]}function li(e){return Kr(Qe(e.value))?Hr(Ke({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_"+(e.layerType||"fill")]})):function e(t){const n=t.value,r=t.key;if("array"!==Ar(n))return[new qr(r,n,`array expected, ${Ar(n)} found`)];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new qr(r,n,"filter array must have at least 1 element")];switch(a=a.concat(Yr({key:r+"[0]",value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),Je(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===Je(n[1])&&a.push(new qr(r,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&a.push(new qr(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(o=Ar(n[1]),"string"!==o&&a.push(new qr(r+"[1]",n[1],`string expected, ${o} found`)));for(let e=2;e{e in n&&t.push(new qr(r,n[e],`"${e}" is prohibited for ref layers`))}),i.layers.forEach(t=>{Je(t.id)===s&&(e=t)}),e?e.ref?t.push(new qr(r,n.ref,"ref cannot reference another ref layer")):a=Je(e.type):"string"==typeof s&&t.push(new qr(r,n.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(n.source){const e=i.sources&&i.sources[n.source],o=e&&Je(e.type);e?"vector"===o&&"raster"===a?t.push(new qr(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new qr(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new qr(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new qr(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new qr(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new qr(r,n.source,`source "${n.source}" not found`))}else t.push(new qr(r,n,'missing required property "source"'));return t=t.concat($r({key:r,value:n,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>xi({key:r+".type",value:n.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>li(Ke({layerType:a},e)),layout:e=>$r({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>hi(Ke({layerType:a},e))}}),paint:e=>$r({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>ci(Ke({layerType:a},e))}})}})),t}function fi(e){const t=e.value,n=e.key,r=Ar(t);return"string"!==r?[new qr(n,t,`string expected, ${r} found`)]:[]}const pi={promoteId:function({key:e,value:t}){if("string"===Ar(t))return fi({key:e,value:t});{const n=[];for(const r in t)n.push(...fi({key:`${e}.${r}`,value:t[r]}));return n}}};function mi(e){const t=e.value,n=e.key,r=e.styleSpec,i=e.style;if(!t.type)return[new qr(n,t,'"type" is required')];const o=Je(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=$r({key:n,value:t,valueSpec:r["source_"+o.replace("-","_")],style:e.style,styleSpec:r,objectElementValidators:pi}),a;case"geojson":if(a=$r({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:pi}),t.cluster)for(const e in t.clusterProperties){const[r,i]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Hr({key:`${n}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...Hr({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return $r({key:n,value:t,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return $r({key:n,value:t,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new qr(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Yr({key:n+".type",value:t.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:i,styleSpec:r})}}function _i(e){const t=e.value,n=e.styleSpec,r=n.light,i=e.style;let o=[];const a=Ar(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new qr("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?xi({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?xi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new qr(e,t[e],`unknown property "${e}"`)])}return o}function gi(e){const t=e.value,n=e.key,r=e.style,i=e.styleSpec,o=i.terrain;let a=[];const s=Ar(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new qr("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const n=e.match(/^(.*)-transition$/);a=a.concat(n&&o[n[1]]&&o[n[1]].transition?xi({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):o[e]?xi({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:i}):[new qr(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],i=e&&Je(e.type);e?"raster-dem"!==i&&a.push(new qr(n,t.source,`terrain cannot be used with a source of type ${String(i)}, it only be used with a "raster-dem" source type`)):a.push(new qr(n,t.source,`source "${t.source}" not found`))}else a.push(new qr(n,t,'terrain is missing required property "source"'));return a}function yi(e){const t=e.value,n=e.style,r=e.styleSpec,i=r.fog;let o=[];const a=Ar(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new qr("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&i[a[1]]&&i[a[1]].transition?xi({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):i[e]?xi({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}):[new qr(e,t[e],`unknown property "${e}"`)])}return o}const vi={"*":()=>[],array:Zr,boolean:function(e){const t=e.value,n=e.key,r=Ar(t);return"boolean"!==r?[new qr(n,t,`boolean expected, ${r} found`)]:[]},number:Wr,color:function(e){const t=e.key,n=e.value,r=Ar(n);return"string"!==r?[new qr(t,n,`color expected, ${r} found`)]:null===xt(n)?[new qr(t,n,`color expected, "${n}" found`)]:[]},enum:Yr,filter:li,function:Xr,layer:di,object:$r,source:mi,light:_i,terrain:gi,fog:yi,string:fi,formatted:function(e){return 0===fi(e).length?[]:Hr(e)},resolvedImage:function(e){return 0===fi(e).length?[]:Hr(e)},projection:function(e){const t=e.value,n=e.styleSpec,r=n.projection,i=e.style;let o=[];const a=Ar(t);if("object"===a)for(const e in t)o=o.concat(xi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}));else"string"!==a&&(o=o.concat([new qr("projection",t,`object or string expected, ${a} found`)]));return o}};function xi(e){const t=e.value,n=e.valueSpec,r=e.styleSpec;return n.expression&&Ir(Je(t))?Xr(e):n.expression&&Fr(Qe(t))?Hr(e):n.type&&vi[n.type]?vi[n.type](e):$r(Ke({},e,{valueSpec:n.type?r[n.type]:n}))}function bi(e){const t=e.value,n=e.key,r=fi(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new qr(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new qr(n,t,'"glyphs" url must include a "{range}" token'))),r}function wi(e,t=Ye){return Si(xi({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:bi,"*":()=>[]}}))}const Ti=e=>Si(ci(e)),Ei=e=>Si(hi(e));function Si(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function ki(e,t){let n=!1;if(t&&t.length)for(const r of t)e.fire(new Xe(new Error(r.message))),n=!0;return n}var Ci=Mi;function Mi(e,t,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var o=0;o=c[f+0]&&r>=c[f+1])?(a[d]=!0,o.push(u[d])):a[d]=!1}}},Mi.prototype._forEachCell=function(e,t,n,r,i,o,a,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),d=l;d<=c;d++)for(var f=u;f<=h;f++){var p=this.d*f+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(f),this._convertFromCellCoord(d+1),this._convertFromCellCoord(f+1)))&&i.call(this,e,t,n,r,p,o,a,s))return}},Mi.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Mi.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Mi.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,n=0,r=0;r=0||(i[n]=Oi(e[n],t)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}throw new Error("can't serialize object of type "+typeof e)}function Di(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||zi(e)||Pi(e)||ArrayBuffer.isView(e)||e instanceof n.ImageData)return e;if(Array.isArray(e))return e.map(Di);if("object"==typeof e){const t=e.$name||"Object",{klass:n}=Ai[t];if(!n)throw new Error("can't deserialize unregistered class "+t);if(n.deserialize)return n.deserialize(e);const r=Object.create(n.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Di(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}class Li{constructor(){this.first=!0}update(e,t){const n=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=n,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=n,!0):(this.lastFloorZoom>n?(this.lastIntegerZoom=n+1,this.lastIntegerZoomTime=t):this.lastFloorZoome>=1536&&e<=1791,Bi=e=>e>=1872&&e<=1919,Fi=e=>e>=2208&&e<=2303,ji=e=>e>=11904&&e<=12031,Ui=e=>e>=12032&&e<=12255,Vi=e=>e>=12272&&e<=12287,Ni=e=>e>=12288&&e<=12351,Gi=e=>e>=12352&&e<=12447,qi=e=>e>=12448&&e<=12543,$i=e=>e>=12544&&e<=12591,Zi=e=>e>=12704&&e<=12735,Wi=e=>e>=12736&&e<=12783,Xi=e=>e>=12784&&e<=12799,Hi=e=>e>=12800&&e<=13055,Yi=e=>e>=13056&&e<=13311,Ki=e=>e>=13312&&e<=19903,Ji=e=>e>=19968&&e<=40959,Qi=e=>e>=40960&&e<=42127,eo=e=>e>=42128&&e<=42191,to=e=>e>=44032&&e<=55215,no=e=>e>=63744&&e<=64255,ro=e=>e>=64336&&e<=65023,io=e=>e>=65040&&e<=65055,oo=e=>e>=65072&&e<=65103,ao=e=>e>=65104&&e<=65135,so=e=>e>=65136&&e<=65279,lo=e=>e>=65280&&e<=65519;function uo(e){for(const t of e)if(fo(t.charCodeAt(0)))return!0;return!1}function co(e){for(const t of e)if(!ho(t.charCodeAt(0)))return!1;return!0}function ho(e){return!(Ri(e)||Bi(e)||Fi(e)||ro(e)||so(e))}function fo(e){return!(746!==e&&747!==e&&(e<4352||!(Zi(e)||$i(e)||oo(e)&&!(e>=65097&&e<=65103)||no(e)||Yi(e)||ji(e)||Wi(e)||!(!Ni(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Ki(e)||Ji(e)||Hi(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||to(e)||Gi(e)||Vi(e)||(e=>e>=12688&&e<=12703)(e)||Ui(e)||Xi(e)||qi(e)&&12540!==e||!(!lo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!ao(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||io(e)||(e=>e>=19904&&e<=19967)(e)||Qi(e)||eo(e))))}function po(e){return!(fo(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ni(e)||qi(e)||(e=>e>=57344&&e<=63743)(e)||oo(e)||ao(e)||lo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function mo(e){return e>=1424&&e<=2303||ro(e)||so(e)}function _o(e,t){return!(!t&&mo(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function go(e){for(const t of e)if(mo(t.charCodeAt(0)))return!0;return!1}const yo="deferred",vo="loading",xo="loaded";let bo=null,wo="unavailable",To=null;const Eo=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(wo="error"),bo&&bo(e)};function So(){ko.fire(new We("pluginStateChange",{pluginStatus:wo,pluginURL:To}))}const ko=new He,Co=function(){return wo},Mo=function(){if(wo!==yo||!To)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");wo=vo,So(),To&&ce({url:To},e=>{e?Eo(e):(wo=xo,So())})},Ao={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>wo===xo||null!=Ao.applyArabicShaping,isLoading:()=>wo===vo,setState(e){wo=e.pluginStatus,To=e.pluginURL},isParsed:()=>null!=Ao.applyArabicShaping&&null!=Ao.processBidirectionalText&&null!=Ao.processStyledBidirectionalText,getPluginURL:()=>To};class Io{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.zoomHistory=t.zoomHistory,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.zoomHistory=new Li,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!_o(n.charCodeAt(0),t))return!1;return!0}(e,Ao.isLoaded())}crossFadingFactor(){return 0===this.fadeDuration?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,t=e-Math.floor(e),n=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:t+(1-t)*n}:{fromScale:.5,toScale:1,t:1-(1-n)*t}}}class zo{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Ir(e))return new Gr(e,t);if(Fr(e)){const n=Nr(e,t);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Ct.parse(e)),{kind:"constant",evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Po{constructor(e){this.property=e,this.value=new zo(e,void 0)}transitioned(e,t){return new Do(this.property,this.value,t,I({},e.transition,this.transition),e.now)}untransitioned(){return new Do(this.property,this.value,null,{},0)}}class Oo{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return U(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Po(this._values[e].property)),this._values[e].value=new zo(this._values[e].property,null===t?void 0:U(t))}getTransition(e){return U(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Po(this._values[e].property)),this._values[e].transition=U(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const r=this.getTransition(t);void 0!==r&&(e[t+"-transition"]=r)}return e}transitioned(e,t){const n=new Lo(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){const e=new Lo(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Do{constructor(e,t,n,r,i){const o=r.delay||0,a=r.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(rr.zoomHistory.lastIntegerZoom?{from:e,to:t,other:n}:{from:n,to:t,other:e}}interpolate(e){return e}}class No{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){if(void 0!==e.value){if("constant"===e.expression.kind){const i=e.expression.evaluate(t,null,{},n,r);return this._calculate(i,i,i,t)}return this._calculate(e.expression.evaluate(new Io(Math.floor(t.zoom-1),t)),e.expression.evaluate(new Io(Math.floor(t.zoom),t)),e.expression.evaluate(new Io(Math.floor(t.zoom+1),t)),t)}}_calculate(e,t,n,r){return r.zoom>r.zoomHistory.lastIntegerZoom?{from:e,to:t}:{from:n,to:t}}interpolate(e){return e}}class Go{constructor(e){this.specification=e}possiblyEvaluate(e,t,n,r){return!!e.expression.evaluate(t,null,{},n,r)}interpolate(){return!1}}class qo{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];const t=new Io(0,{});for(const n in e){const r=e[n];r.specification.overridable&&this.overridableProperties.push(n);const i=this.defaultPropertyValues[n]=new zo(r,void 0),o=this.defaultTransitionablePropertyValues[n]=new Po(r);this.defaultTransitioningPropertyValues[n]=o.untransitioned(),this.defaultPossiblyEvaluatedValues[n]=i.possiblyEvaluate(t)}}}function $o(e,t){return 256*(e=S(Math.floor(e),0,255))+S(Math.floor(t),0,255)}Ii(Uo,"DataDrivenProperty"),Ii(jo,"DataConstantProperty"),Ii(Vo,"CrossFadedDataDrivenProperty"),Ii(No,"CrossFadedProperty"),Ii(Go,"ColorRampProperty");const Zo={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class Wo{constructor(e,t){this._structArray=e,this._pos1=t*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Xo{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,t){return e._trim(),t&&(e.isTransferred=!0,t.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const t=Object.create(this.prototype);return t.arrayBuffer=e.arrayBuffer,t.length=e.length,t.capacity=e.arrayBuffer.byteLength/t.bytesPerElement,t._refreshViews(),t}_trim(){this.length!==this.capacity&&(this.capacity=this.length,this.arrayBuffer=this.arrayBuffer.slice(0,this.length*this.bytesPerElement),this._refreshViews())}clear(){this.length=0}resize(e){this.reserve(e),this.length=e}reserve(e){if(e>this.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Ho(e,t=1){let n=0,r=0;return{members:e.map(e=>{const i=Zo[e.type].BYTES_PER_ELEMENT,o=n=Yo(n,Math.max(t,i)),a=e.components||1;return r=Math.max(r,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:o}}),size:Yo(n,Math.max(r,t)),alignment:t}}function Yo(e,t){return Math.ceil(e/t)*t}class Ko extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Ko.prototype.bytesPerElement=4,Ii(Ko,"StructArrayLayout2i4");class Jo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}Jo.prototype.bytesPerElement=6,Ii(Jo,"StructArrayLayout3i6");class Qo extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,e}}Qo.prototype.bytesPerElement=8,Ii(Qo,"StructArrayLayout4i8");class ea extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[u+4]=r,this.uint8[u+5]=i,this.uint8[u+6]=o,this.uint8[u+7]=a,this.float32[c+2]=s,e}}ea.prototype.bytesPerElement=12,Ii(ea,"StructArrayLayout2i4ub1f12");class ta extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,e}}ta.prototype.bytesPerElement=16,Ii(ta,"StructArrayLayout4f16");class na extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u){const c=this.length;return this.resize(c+1),this.emplace(c,e,t,n,r,i,o,a,s,l,u)}emplace(e,t,n,r,i,o,a,s,l,u,c){const h=10*e;return this.uint16[h+0]=t,this.uint16[h+1]=n,this.uint16[h+2]=r,this.uint16[h+3]=i,this.uint16[h+4]=o,this.uint16[h+5]=a,this.uint16[h+6]=s,this.uint16[h+7]=l,this.uint16[h+8]=u,this.uint16[h+9]=c,e}}na.prototype.bytesPerElement=20,Ii(na,"StructArrayLayout10ui20");class ra extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s){const l=this.length;return this.resize(l+1),this.emplace(l,e,t,n,r,i,o,a,s)}emplace(e,t,n,r,i,o,a,s,l){const u=8*e;return this.uint16[u+0]=t,this.uint16[u+1]=n,this.uint16[u+2]=r,this.uint16[u+3]=i,this.uint16[u+4]=o,this.uint16[u+5]=a,this.uint16[u+6]=s,this.uint16[u+7]=l,e}}ra.prototype.bytesPerElement=16,Ii(ra,"StructArrayLayout8ui16");class ia extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,e}}ia.prototype.bytesPerElement=12,Ii(ia,"StructArrayLayout6i12");class oa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,r,i,o,a,s,l,u,c,h)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=d,e}}oa.prototype.bytesPerElement=24,Ii(oa,"StructArrayLayout4i4ui4i24");class aa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=a,e}}aa.prototype.bytesPerElement=20,Ii(aa,"StructArrayLayout3i3f20");class sa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint32[1*e+0]=t,e}}sa.prototype.bytesPerElement=4,Ii(sa,"StructArrayLayout1ul4");class la extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,o,a,s,l,u,c,h,d)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.int16[p+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}la.prototype.bytesPerElement=40,Ii(la,"StructArrayLayout5i4f1i1ul2ui40");class ua extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=r,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}ua.prototype.bytesPerElement=16,Ii(ua,"StructArrayLayout3i2i2i16");class ca extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,e}}ca.prototype.bytesPerElement=16,Ii(ca,"StructArrayLayout2f1f2i16");class ha extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,e}}ha.prototype.bytesPerElement=12,Ii(ha,"StructArrayLayout2ub2f12");class da extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}da.prototype.bytesPerElement=12,Ii(da,"StructArrayLayout3f12");class fa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}fa.prototype.bytesPerElement=6,Ii(fa,"StructArrayLayout3ui6");class pa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b){const w=30*e,T=15*e,E=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[T+2]=i,this.float32[T+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[T+5]=l,this.uint32[T+6]=u,this.uint32[T+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[T+10]=p,this.float32[T+11]=m,this.uint8[E+48]=_,this.uint8[E+49]=g,this.uint8[E+50]=y,this.uint32[T+13]=v,this.int16[w+28]=x,this.uint8[E+58]=b,e}}pa.prototype.bytesPerElement=60,Ii(pa,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class ma extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,E,S,k,C,M,A){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,E,S,k,C,M,A)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,E,S,k,C,M,A,I){const z=38*e,P=19*e;return this.int16[z+0]=t,this.int16[z+1]=n,this.int16[z+2]=r,this.float32[P+2]=i,this.float32[P+3]=o,this.int16[z+8]=a,this.int16[z+9]=s,this.int16[z+10]=l,this.int16[z+11]=u,this.int16[z+12]=c,this.int16[z+13]=h,this.uint16[z+14]=d,this.uint16[z+15]=f,this.uint16[z+16]=p,this.uint16[z+17]=m,this.uint16[z+18]=_,this.uint16[z+19]=g,this.uint16[z+20]=y,this.uint16[z+21]=v,this.uint16[z+22]=x,this.uint16[z+23]=b,this.uint16[z+24]=w,this.uint16[z+25]=T,this.uint16[z+26]=E,this.uint16[z+27]=S,this.uint16[z+28]=k,this.uint32[P+15]=C,this.float32[P+16]=M,this.float32[P+17]=A,this.float32[P+18]=I,e}}ma.prototype.bytesPerElement=76,Ii(ma,"StructArrayLayout3i2f6i15ui1ul3f76");class _a extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.float32[1*e+0]=t,e}}_a.prototype.bytesPerElement=4,Ii(_a,"StructArrayLayout1f4");class ga extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,this.float32[a+4]=o,e}}ga.prototype.bytesPerElement=20,Ii(ga,"StructArrayLayout5f20");class ya extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=n,this.uint16[o+3]=r,this.uint16[o+4]=i,e}}ya.prototype.bytesPerElement=12,Ii(ya,"StructArrayLayout1ul3ui12");class va extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}va.prototype.bytesPerElement=4,Ii(va,"StructArrayLayout2ui4");class xa extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const t=this.length;return this.resize(t+1),this.emplace(t,e)}emplace(e,t){return this.uint16[1*e+0]=t,e}}xa.prototype.bytesPerElement=2,Ii(xa,"StructArrayLayout1ui2");class ba extends Xo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}ba.prototype.bytesPerElement=8,Ii(ba,"StructArrayLayout2f8");class wa extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}wa.prototype.size=12;class Ta extends ia{get(e){return new wa(this,e)}}Ii(Ta,"FillExtrusionExtArray");class Ea extends Wo{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]}}Ea.prototype.size=40;class Sa extends la{get(e){return new Ea(this,e)}}Ii(Sa,"CollisionBoxArray");class ka extends Wo{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}}ka.prototype.size=60;class Ca extends pa{get(e){return new ka(this,e)}}Ii(Ca,"PlacedSymbolArray");class Ma extends Wo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Ma.prototype.size=76;class Aa extends ma{get(e){return new Ma(this,e)}}Ii(Aa,"SymbolInstanceArray");class Ia extends _a{getoffsetX(e){return this.float32[1*e+0]}}Ii(Ia,"GlyphOffsetArray");class za extends Jo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Ii(za,"SymbolLineVertexArray");class Pa extends Wo{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]}}Pa.prototype.size=12;class Oa extends ya{get(e){return new Pa(this,e)}}Ii(Oa,"FeatureIndexArray");class Da extends Wo{get a_centroid_pos0(){return this._structArray.uint16[this._pos2+0]}get a_centroid_pos1(){return this._structArray.uint16[this._pos2+1]}}Da.prototype.size=4;class La extends va{get(e){return new Da(this,e)}}Ii(La,"FillExtrusionCentroidArray");class Ra extends Wo{get a_pos_30(){return this._structArray.int16[this._pos2+0]}get a_pos_31(){return this._structArray.int16[this._pos2+1]}get a_pos_32(){return this._structArray.int16[this._pos2+2]}get a_pos_normal_30(){return this._structArray.int16[this._pos2+3]}get a_pos_normal_31(){return this._structArray.int16[this._pos2+4]}get a_pos_normal_32(){return this._structArray.int16[this._pos2+5]}}Ra.prototype.size=12;class Ba extends ia{get(e){return new Ra(this,e)}}Ii(Ba,"CircleGlobeExtArray");const Fa=Ho([{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"}]),ja=Ho([{name:"a_dash_to",components:4,type:"Uint16"},{name:"a_dash_from",components:4,type:"Uint16"}]);var Ua={exports:{}},Va={exports:{}};Va.exports=function(e,t){var n,r,i,o,a,s,l,u;for(r=e.length-(n=3&e.length),i=t,a=3432918353,s=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Na={exports:{}};Na.exports=function(e,t){for(var n,r=e.length,i=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Ga=Va.exports,qa=Na.exports;Ua.exports=Ga,Ua.exports.murmur3=Ga,Ua.exports.murmur2=qa;class $a{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(Za(e)),this.positions.push(t,n,r)}getPositions(e){const t=Za(e);let n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}const i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){const n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return function e(t,n,r,i){for(;r>1];let a=r-1,s=i+1;for(;;){do{a++}while(t[a]o);if(a>=s)break;Wa(t,a,s),Wa(n,3*a,3*s),Wa(n,3*a+1,3*s+1),Wa(n,3*a+2,3*s+2)}s-r"u_"+e),this.type=n}setUniform(e,t,n,r,i){t.set(e,i,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new Ka(e):new Ha(e)}}class rs{constructor(e,t){this.uniformNames=t.map(e=>"u_"+e),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,t){this.pixelRatioFrom=t.pixelRatio||1,this.pixelRatioTo=e.pixelRatio||1,this.patternFrom=t.tl.concat(t.br),this.patternTo=e.tl.concat(e.br)}setUniform(e,t,n,r,i){const o="u_pattern_to"===i||"u_dash_to"===i?this.patternTo:"u_pattern_from"===i||"u_dash_from"===i?this.patternFrom:"u_pixel_ratio_to"===i?this.pixelRatioTo:"u_pixel_ratio_from"===i?this.pixelRatioFrom:null;o&&t.set(e,i,o)}getBinding(e,t){return"u_pattern_from"===t||"u_pattern_to"===t||"u_dash_from"===t||"u_dash_to"===t?new Ya(e):new Ha(e)}}class is{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n,r,i,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new Io(0),t,{},i,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:0},n,r,void 0,i);this._setPaintValue(e,t,o)}_setPaintValue(e,t,n){if("color"===this.type){const r=ts(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,n,r,i,o){const a=this.expression.evaluate(new Io(this.zoom),t,{},i,r,o),s=this.expression.evaluate(new Io(this.zoom+1),t,{},i,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:this.zoom},n,r,void 0,i),a=this.expression.evaluate({zoom:this.zoom+1},n,r,void 0,i);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=ts(n),o=ts(r);for(let n=e;n!0)){this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){if(!n(i))continue;const o=e.paint.get(i);if(!(o instanceof Bo&&kr(o.property.specification)))continue;const a=cs(i,e.type),s=o.value,l=o.property.specification.type,u=o.property.useIntegerZoom,c=o.property.specification["property-type"],h="cross-faded"===c||"cross-faded-data-driven"===c,d="line-dasharray"===String(i)&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||d)if("source"===s.kind||d||h){const n=fs(i,l,"source");this.binders[i]=h?new as(s,a,l,u,t,n,e.id):new is(s,a,l,n),r.push("/a_"+i)}else{const e=fs(i,l,"composite");this.binders[i]=new os(s,a,l,u,t,e),r.push("/z_"+i)}else this.binders[i]=h?new rs(s.value,a):new ns(s.value,a,l),r.push("/u_"+i)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof is||t instanceof os?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o){for(const a in this.binders){const s=this.binders[a];(s instanceof is||s instanceof os||s instanceof as)&&s.populatePaintArray(e,t,n,r,i,o)}}setConstantPatternPositions(e,t){for(const n in this.binders){const r=this.binders[n];r instanceof rs&&r.setConstantPatternPositions(e,t)}}updatePaintArrays(e,t,n,r,i,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=n.feature(t.index);for(const n in this.binders){const u=this.binders[n];if((u instanceof is||u instanceof os||u instanceof as)&&!0===u.expression.isStateDependent){const c=r.paint.get(n);u.expression=c.value,u.updatePaintArray(t.start,t.end,l,e[s],i,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof ns||n instanceof rs)&&e.push(...n.uniformNames.map(e=>"#define HAS_UNIFORM_"+e))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof is||n instanceof os||n instanceof as)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ss(r,t,n);this.needsUpload=!1,this._featureMap=new $a,this._bufferOffset=0}populatePaintArrays(e,t,n,r,i,o,a){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r,i,o,a);void 0!==t.id&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i){for(const o of n)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,i)||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 us={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"line-dasharray":["dash_to","dash_from"]};function cs(e,t){return us[e]||[e.replace(t+"-","").replace(/-/g,"_")]}const hs={"line-pattern":{source:na,composite:na},"fill-pattern":{source:na,composite:na},"fill-extrusion-pattern":{source:na,composite:na},"line-dasharray":{source:ra,composite:ra}},ds={color:{source:ba,composite:ta},number:{source:_a,composite:ba}};function fs(e,t,n){const r=hs[e];return r&&r[n]||ds[t][n]}Ii(ns,"ConstantBinder"),Ii(rs,"CrossFadedConstantBinder"),Ii(is,"SourceExpressionBinder"),Ii(as,"CrossFadedCompositeBinder"),Ii(os,"CompositeExpressionBinder"),Ii(ss,"ProgramConfiguration",{omit:["_buffers"]}),Ii(ls,"ProgramConfigurationSet");const ps="-transition";class ms extends He{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Ro(t.layout)),t.paint)){this._transitionablePaint=new Oo(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new Fo(t.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,n={}){null!=t&&this._validate(Ei,`layers.${this.id}.layout.${e}`,e,t,n)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return B(e,ps)?this._transitionablePaint.getTransition(e.slice(0,-ps.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(null!=t&&this._validate(Ti,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(B(e,ps))return this._transitionablePaint.setTransition(e.slice(0,-ps.length),t||void 0),!1;{const n=this._transitionablePaint._values[e],r="cross-faded-data-driven"===n.property.specification["property-type"],i=n.value.isDataDriven(),o=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const a=this._transitionablePaint._values[e].value;return a.isDataDriven()||i||r||this._handleOverridablePaintPropertyUpdate(e,o,a)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),j(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,n,r,i={}){return(!i||!1!==i.validate)&&ki(this,e.call(wi,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:Ye,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Bo&&kr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Jr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const _s=Ho([{name:"a_pos",components:2,type:"Int16"}],4),gs=Ho([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ys{constructor(e=[]){this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>ys.MAX_VERTEX_ARRAY_LENGTH&&N(`Max vertices per segment is ${ys.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>ys.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new ys([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}ys.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ii(ys,"SegmentVector");var vs=8192;class xs{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof ws?new ws(e.lng,e.lat):ws.convert(e),this}setSouthWest(e){return this._sw=e instanceof ws?new ws(e.lng,e.lat):ws.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof ws)r=e,i=e;else{if(!(e instanceof xs))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(xs.convert(e)):this.extend(ws.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&e.hasOwnProperty("lon")?this.extend(ws.convert(e)):this;if(r=e._sw,i=e._ne,!r||!i)return this}return t||n?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new ws(r.lng,r.lat),this._ne=new ws(i.lng,i.lat)),this}getCenter(){return new ws((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 ws(this.getWest(),this.getNorth())}getSouthEast(){return new ws(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:n}=ws.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return!e||e instanceof xs?e:new xs(e)}}const bs=6371008.8;class ws{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 ws(C(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,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return bs*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new xs(new ws(this.lng-n,this.lat-t),new ws(this.lng+n,this.lat+t))}static convert(e){if(e instanceof ws)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new ws(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new ws(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const Ts=2*Math.PI*bs;function Es(e){return Ts*Math.cos(e*Math.PI/180)}function Ss(e){return(180+e)/360}function ks(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function Cs(e,t){return e/Es(t)}function Ms(e){return 360*e-180}function As(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Is(e,t){return e*Es(As(t))}const zs=85.051129;function Ps(e){return 1/Math.cos(e*Math.PI/180)}class Os{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){const n=ws.convert(e);return new Os(Ss(n.lng),ks(n.lat),Cs(t,n.lat))}toLngLat(){return new ws(Ms(this.x),As(this.y))}toAltitude(){return Is(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/Ts*Ps(As(this.y))}}function Ds(e,t,n,r,i,o,a,s,l){const u=(t+r)/2,c=(n+i)/2,h=new m(u,c);s(h),function(e,t,n,r,i,o){const a=n-i,s=r-o;return Math.abs((r-t)*a-(n-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Ds(e,t,n,u,c,o,h,s,l),Ds(e,u,c,r,i,h,a,s,l)):e.push(a)}function Ls(e,t,n){let r=e[0],i=r.x,o=r.y;t(r);const a=[r];for(let s=1;se.x+1||re.y+1)&&N("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Vs(e,t,n){const r=e.loadGeometry(),i=e.extent,o=vs/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=Ms((t.x+e.x/i)/o),r=As((t.y+e.y/i)/o),c=u.project(n,r);e.x=(c.x*a-s)*i,e.y=(c.y*a-l)*i};for(let t=0;t=i||n.y<0||n.y>=i||(c(n),e.push(n));r[t]=e}}for(const e of r)for(const t of e)Us(t,o);return r}function Ns(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Vs(e):[]}}function Gs(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function qs(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class $s{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Ko,this.indexArray=new fa,this.segments=new ys,this.programConfigurations=new ls(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){const i=this.layers[0],o=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:t,id:i,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ns(t,e);if(!this.layers[0]._featureFilter.filter(new Io(this.zoom),u,n))continue;const c=a?a.evaluate(u,{},n):void 0,h={id:i,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Vs(t,n,r),patterns:{},sortKey:c};o.push(h)}a&&o.sort((e,t)=>e.sortKey-t.sortKey);let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new Ba,s=r.projection);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,i,o,t.availableImages,n,s),t.featureIndex.insert(l,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,_s.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,gs.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,n,r,i,o){for(const n of t)for(const t of n){const n=t.x,r=t.y;if(n<0||n>=vs||r<0||r>=vs)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;qs(a,e,t),qs(a,e,t),qs(a,e,t),qs(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;Gs(this.layoutVertexArray,n,r,-1,-1),Gs(this.layoutVertexArray,n,r,1,-1),Gs(this.layoutVertexArray,n,r,1,1),Gs(this.layoutVertexArray,n,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},r,i)}}function Zs(e,t){for(let n=0;n1){if(Ys(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function el(e,t){let n,r,i,o=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}function tl(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function nl(e,t,n,r,i){for(const o of e)if(t<=o.x&&n<=o.y&&r>=o.x&&i>=o.y)return!0;const o=[new m(t,n),new m(t,i),new m(r,i),new m(r,n)];if(e.length>2)for(const t of o)if(tl(e,t))return!0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const o=G(e,t,n[0]);return o!==G(e,t,n[1])||o!==G(e,t,n[2])||o!==G(e,t,n[3])}function il(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function ol(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function al(e,t,n,r,i){if(!t[0]&&!t[1])return e;const o=m.convert(t)._mult(i);"viewport"===n&&o._rotate(-r);const a=[];for(let t=0;t0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Rl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Bl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e}function Fl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/(a=a||1),e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e}function jl(e,t,n){var r=n[0],i=n[1],o=n[2],a=t[0],s=t[1],l=t[2],u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,d=i*h-o*c,f=o*u-r*h,p=r*c-i*u,m=2*n[3];return c*=m,h*=m,f*=2,p*=2,e[0]=a+(u*=m)+(d*=2),e[1]=s+c+f,e[2]=l+h+p,e}var Ul,Vl=Al,Nl=Il,Gl=kl;function ql(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function $l(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e}function Zl(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e}function Wl(){var e=new hl(4);return hl!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Xl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Hl(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e}function Yl(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e}El(),Ul=new hl(4),hl!=Float32Array&&(Ul[0]=0,Ul[1]=0,Ul[2]=0,Ul[3]=0);var Kl=$l;El(),Cl(1,0,0),Cl(0,1,0),Wl(),Wl(),dl();class Jl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const r=Rl(t,this.dir);if(Math.abs(r)<1e-6)return!1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return n[0]=this.pos[0]+this.dir[0]*i,n[1]=this.pos[1]+this.dir[1]*i,n[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(n-o)<=cl*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=cl*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=cl*Math.max(1,Math.abs(i),Math.abs(s))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[r,i,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],u=r*r+i*i+o*o,c=2*(a*r+s*i+l*o),h=c*c-4*u*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-c/2,0),u=a+r*e,h=s+i*e,d=l+o*e,f=Math.hypot(u,h,d);return n[0]=u*t/f,n[1]=h*t/f,n[2]=d*t/f,!1}{const e=(-c-Math.sqrt(h))/(2*u);if(e<0){const e=Math.hypot(a,s,l);return n[0]=a*t/e,n[1]=s*t/e,n[2]=l*t/e,!1}return n[0]=a+r*e,n[1]=s+i*e,n[2]=l+o*e,!0}}}class Ql{constructor(e,t,n,r,i){this.TL=e,this.TR=t,this.BR=n,this.BL=r,this.horizon=i}static fromInvProjectionMatrix(e,t,n){const r=[-1,1,1],i=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=Fl(r,r,e),l=Fl(i,i,e),u=Fl(o,o,e),c=Fl(a,a,e);return new Ql(s,l,u,c,t/n)}}class eu{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,n,r){const i=Math.pow(2,n),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>{const o=Zl([],n,e),a=1/o[3]/t*i;return function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}(o,o,[a,a,r?1/o[3]:a,a])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=Ll([],Bl([],Vl([],o[e[0]],o[e[1]]),Vl([],o[e[2]],o[e[1]]))),n=-Rl(t,o[e[1]]);return t.concat(n)});return new eu(o,a)}}class tu{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)zl(t,t,r),Pl(n,n,r);return new tu(t,n)}static applyTransform(e,t){const n=e.getCorners();for(let e=0;e=0;if(0===o)return 0;o!==t.length&&(n=!1)}if(n)return 2;for(let t=0;t<3;t++){let n=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let i=0;ithis.max[t]-this.min[t])return 0}return 1}}function nu(e,t,n,r,i,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=n.projection.upVectorScale(u,n.center.lat,n.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),d=i&&n.elevation?n.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=n.projection.upVector(u,h.x,h.y);f.x+=e[0]*c*d,f.y+=e[1]*c*d,f.z+=e[2]*c*d}const p=o?h:ru(f.x,f.y,f.z,r),m=o?e.tilespaceRays.map(e=>au(e,d)):e.queryGeometry.screenGeometry,_=Zl([],[f.x,f.y,f.z,1],r);if(!a&&o?l*=_[3]/n.cameraToCenterDistance:a&&!o&&(l*=n.cameraToCenterDistance/_[3]),o){const e=As((t.y/vs+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,i=0;t80*n){r=o=e[0],i=a=e[1];for(var p=n;po&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?32767/u:0}return wu(d,f,n,r,i,u,0),f}function xu(e,t,n,r,i){var o,a;if(i===qu(e,t,n,r)>0)for(o=t;o=t;o-=r)a=Vu(o,e[o],e[o+1],a);return a&&Lu(a,a.next)&&(Nu(a),a=a.next),a}function bu(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Lu(r,r.next)&&0!==Du(r.prev,r,r.next))r=r.next;else{if(Nu(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function wu(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=Iu(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?Eu(e,r,i,o):Tu(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Nu(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?wu(e=Su(bu(e),t,n),t,n,r,i,o,2):2===a&&ku(e,t,n,r,i,o):wu(bu(e),t,n,r,i,o,1);break}}}function Tu(e){var t=e.prev,n=e,r=e.next;if(Du(t,n,r)>=0)return!1;for(var i=t.x,o=n.x,a=r.x,s=t.y,l=n.y,u=r.y,c=io?i>a?i:a:o>a?o:a,f=s>l?s>u?s:u:l>u?l:u,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&Pu(i,s,o,l,a,u,p.x,p.y)&&Du(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function Eu(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Du(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,u=a.x,c=i.y,h=o.y,d=a.y,f=sl?s>u?s:u:l>u?l:u,_=c>h?c>d?c:d:h>d?h:d,g=Iu(f,p,t,n,r),y=Iu(m,_,t,n,r),v=e.prevZ,x=e.nextZ;v&&v.z>=g&&x&&x.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&Pu(s,c,l,h,u,d,v.x,v.y)&&Du(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&Pu(s,c,l,h,u,d,x.x,x.y)&&Du(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&Pu(s,c,l,h,u,d,v.x,v.y)&&Du(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&Pu(s,c,l,h,u,d,x.x,x.y)&&Du(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function Su(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Lu(i,o)&&Ru(i,r,r.next,o)&&ju(i,o)&&ju(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),Nu(r),Nu(r.next),r=e=o),r=r.next}while(r!==e);return bu(r)}function ku(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Ou(a,s)){var l=Uu(a,s);return a=bu(a,a.next),l=bu(l,l.next),wu(a,t,n,r,i,o,0),void wu(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function Cu(e,t){return e.x-t.x}function Mu(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,n=r.x=r.x&&r.x>=c&&i!==r.x&&Pu(on.x||r.x===n.x&&Au(n,r)))&&(n=r,d=l)),r=r.next}while(r!==u);return n}(e,t);if(!n)return t;var r=Uu(n,e);return bu(r,r.next),bu(n,n.next)}function Au(e,t){return Du(e.prev,e,t.prev)<0&&Du(t.next,e,e.next)<0}function Iu(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function zu(e){var t=e,n=e;do{(t.x=(e-a)*(o-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(o-s)>=(i-a)*(r-s)}function Ou(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Ru(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(ju(e,t)&&ju(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Du(e.prev,e,t.prev)||Du(e,t.prev,t))||Lu(e,t)&&Du(e.prev,e,e.next)>0&&Du(t.prev,t,t.next)>0)}function Du(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Lu(e,t){return e.x===t.x&&e.y===t.y}function Ru(e,t,n,r){var i=Fu(Du(e,t,n)),o=Fu(Du(e,t,r)),a=Fu(Du(n,r,e)),s=Fu(Du(n,r,t));return i!==o&&a!==s||!(0!==i||!Bu(e,n,t))||!(0!==o||!Bu(e,r,t))||!(0!==a||!Bu(n,e,r))||!(0!==s||!Bu(n,t,r))}function Bu(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function Fu(e){return e>0?1:e<0?-1:0}function ju(e,t){return Du(e.prev,e,e.next)<0?Du(e,t,e.next)>=0&&Du(e,e.prev,t)>=0:Du(e,t,e.prev)<0||Du(e,e.next,t)<0}function Uu(e,t){var n=new Gu(e.i,e.x,e.y),r=new Gu(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Vu(e,t,n,r){var i=new Gu(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Nu(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Gu(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function qu(e,t,n,r){for(var i=0,o=t,a=n-r;or;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=t[n],d=r,f=i;for(Zu(t,r,n),o(t[i],h)>0&&Zu(t,r,i);d0;)f--}0===o(t[r],h)?Zu(t,r,f):Zu(t,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(e,t,n||0,r||e.length-1,i||Wu)}function Zu(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Wu(e,t){return et?1:0}function Xu(e,t){const n=e.length;if(n<=1)return[e];const r=[];let i,o;for(let t=0;t1)for(let e=0;e0&&n.holes.push(r+=e[i-1].length)}return n};class Ju{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Ko,this.indexArray=new fa,this.indexArray2=new va,this.programConfigurations=new ls(e.layers,e.zoom),this.segments=new ys,this.segments2=new ys,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=Yu("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Ns(a,e);if(!this.layers[0]._featureFilter.filter(new Io(this.zoom),c,n))continue;const h=i?i.evaluate(c,{},n,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Vs(a,n,r),patterns:{},sortKey:h};o.push(d)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=Ku("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,{},t.availableImages);t.featureIndex.insert(e[o].feature,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,gu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,o=[]){for(const e of Xu(t,500)){let t=0;for(const n of e)t+=n.length;const n=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=n.vertexLength,i=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(i.length/2);const n=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=n.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),i.push(t[0].x),i.push(t[0].y);for(let e=1;e>3}if(i--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&s.push(t),t=[]),t.push(new ac(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},lc.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(r--,1===n||2===n)(i+=e.readSVarint())s&&(s=i),(o+=e.readSVarint())u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},lc.prototype.toGeoJSON=function(e,t,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),u=lc.types[this.type];function c(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}fc.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new hc(this._pbf,t,this.extent,this._keys,this._values)};var mc=dc;function _c(e,t,n){if(3===e){var r=new mc(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var gc=oc.VectorTile=function(e,t){this.layers=e.readFields(_c,{},t)},yc=oc.VectorTileFeature=sc;function vc(e,t,n,r){const i=[],o=0===r?(e,t,n,r,i,o)=>{e.push(new m(o,n+(o-t)/(r-t)*(i-n)))}:(e,t,n,r,i,o)=>{e.push(new m(t+(o-n)/(i-n)*(r-t),o))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&o(a,s,l,u,c,t):h>n?d=t&&o(a,s,l,u,c,t),d>n&&h<=n&&o(a,s,l,u,c,n)}let s=i[i.length-1];const l=0===r?s.x:s.y;l>=t&&l<=n&&a.push(s),a.length&&(s=a[a.length-1],a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}oc.VectorTileLayer=dc;const xc=yc.types,bc=Math.pow(2,13);function wc(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*bc)<<1)+i,Math.round(s))}function Tc(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class Ec{constructor(){this.acc=new m(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new m(e.x,e.y),this.max=new m(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,r=this.max;e.xr.x&&(r.x=e.x),e.yr.y&&(r.y=e.y),((0===e.x||e.x===vs)&&e.x===t.x)!=((0===e.y||e.y===vs)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,Cn(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>vs!=e.x>vs&&this.addBorderIntersection(1,Cn(t.y,e.y,(vs-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Cn(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>vs!=e.y>vs&&this.addBorderIntersection(3,Cn(t.x,e.x,(vs-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new m(0,0)}span(){return new m(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class Sc{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new Qo,this.centroidVertexArray=new La,this.indexArray=new fa,this.programConfigurations=new ls(e.layers,e.zoom),this.segments=new ys,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,n,r){this.features=[],this.hasPattern=Yu("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;e--){const t=d[e];(0===t.length||(f=t[0]).every(e=>e.x<=0)||f.every(e=>e.x>=vs)||f.every(e=>e.y<=0)||f.every(e=>e.y>=vs))&&d.splice(e,1)}var f;let p;if(u)p=Oc(d,s,r);else{p=[];for(const e of d)p.push({polygon:e,bounds:s})}const _=h?this.edgeRadius:0;for(const{polygon:e,bounds:t}of p){let n=0,i=0;for(const t of e)h&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=h?t.length-1:t.length;const o=this.segments.prepareSegment((h?5:4)*i,this.layoutVertexArray,this.indexArray);if(h){const t=[],i=[];n=o.vertexLength;for(const n of e){let a,s;n.length&&n!==e[0]&&i.push(t.length/2),a=n[1].sub(n[0])._perp()._unit();for(let e=1;e4&&Ic(i[i.length-2],i[0],i[1]),f=_?Cc(i[i.length-2],i[0],i[1],_):0;a=i[1].sub(i[0])._perp()._unit();let p=!0;for(let m=1,g=0;m0?1:0,E=y.dist(v);if(g+E>32768&&(g=0),_){s=x.sub(v)._perp()._unit();let e=Mc(y,v,x,kc(a,s),_);isNaN(e)&&(e=0);const t=v.sub(y)._unit();y=y.add(t.mult(f))._round(),v=v.add(t.mult(-e))._round(),f=e,a=s}const S=o.vertexLength,k=i.length>4&&Ic(y,v,x);let C=zc(g,d,p);if(wc(this.layoutVertexArray,y.x,y.y,w,T,0,0,C),wc(this.layoutVertexArray,y.x,y.y,w,T,0,1,C),g+=E,C=zc(g,k,!p),d=k,wc(this.layoutVertexArray,v.x,v.y,w,T,0,0,C),wc(this.layoutVertexArray,v.x,v.y,w,T,0,1,C),o.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),o.primitiveLength+=2,_){const r=n+(1===m?i.length-2:m-2),a=1===m?n:r+1;if(this.indexArray.emplaceBack(S+1,r,S+3),this.indexArray.emplaceBack(r,a,S+3),o.primitiveLength+=2,void 0===e&&(e=S),!Ac(x,i[m],t)){const t=m===i.length-1?e:o.vertexLength;this.indexArray.emplaceBack(S+2,S+3,t),this.indexArray.emplaceBack(S+3,t+1,t),this.indexArray.emplaceBack(S+3,a,t+1),o.primitiveLength+=3}p=!p}if(u){const e=this.layoutVertexExtArray,t=l.projectTilePoint(y.x,y.y,r),n=l.projectTilePoint(v.x,v.y,r),i=l.upVector(r,y.x,y.y),o=l.upVector(r,v.x,v.y);Tc(e,t,i),Tc(e,t,i),Tc(e,n,o),Tc(e,n,o)}}h&&(n+=i.length-1)}}if(c&&c.polyCount.length>0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const e=c.borders,t=this.featuresOnBorder.push(c)-1;for(let n=0;n<4;n++)e[n][0]!==Number.MAX_VALUE&&this.borders[n].push(t)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,t,n=!0){let r,i;if(e)if(0!==e.y){const n=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(n.x/10)),i=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(n.y/10))}else r=Math.ceil(7*(e.x+450)),i=0;else r=0,i=+n;let o=n?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;tn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Ic(e,t,n){if(e.x<0||e.x>=vs||t.x<0||t.x>=vs||n.x<0||n.x>=vs)return!1;const r=n.sub(t),i=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function zc(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function Pc(){const e=Math.PI/32,t=Math.tan(e),n=bs;return n*Math.sqrt(1+2*t*t)-n}function Oc(e,t,n){const r=1<{for(const n of e)a.push({polygon:n,bounds:t})},l=Math.ceil(Math.log2(n)),u=Math.ceil(Math.log2(r)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e)}if(p.length){const e=[new m(0===n?c:r.x,1===n?c:r.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e)}}return a}(e,t,Math.ceil((o-i)/11.25),Math.ceil((a-s)/11.25),1,(e,t,i)=>{if(0===e)return.5*(t+i);{const e=As((n.y+t/vs)/r);return(ks(.5*(As((n.y+i/vs)/r)+e))*r-n.y)*vs}})}Ii(Sc,"FillExtrusionBucket",{omit:["layers","features"]}),Ii(Ec,"PartMetadata");const Dc=new qo({"fill-extrusion-edge-radius":new jo(Ye["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Lc={paint:new qo({"fill-extrusion-opacity":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Vo(Ye["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Uo(Ye["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new jo(Ye["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:Dc};function Rc(e,t,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Bc{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=Uc(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=function(e,t,n){var r=Rc(256*e,256*(t=Math.pow(2,n)-t-1),n),i=Rc(256*(e+1),256*(t+1),n);return r[0]+","+r[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),r=function(e,t,n){let r,i="";for(let o=e;o>0;o--)r=1<this.canonical.z?new jc(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new jc(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 Uc(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return Uc(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new jc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new jc(t,this.wrap,t,n,r),new jc(t,this.wrap,t,n+1,r),new jc(t,this.wrap,t,n,r+1),new jc(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new ea,this.layoutVertexArray2=new ta,this.indexArray=new fa,this.programConfigurations=new ls(e.layers,e.zoom),this.segments=new ys,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=Yu("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Ns(t,e);if(!this.layers[0]._featureFilter.filter(new Io(this.zoom),u,n))continue;const c=i?i.evaluate(u,{},n):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Vs(t,n,r),patterns:{},sortKey:c};o.push(h)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:u}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=Ku("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages);s.insert(e[o].feature,i,o,u,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=r.value;if(!n)continue;e.addDash(n.from,t),e.addDash(n.to,t),n.other&&e.addDash(n.other,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let a,s,l,u,c,h;if("constant"===i.kind){const e=i.value;if(!e)continue;a=e.other||e.to,s=e.to,l=e.from}else a=i.evaluate({zoom:n-1},e),s=i.evaluate({zoom:n},e),l=i.evaluate({zoom:n+1},e);"constant"===o.kind?u=c=h=o.value:(u=o.evaluate({zoom:n-1},e),c=o.evaluate({zoom:n},e),h=o.evaluate({zoom:n+1},e)),t.addDash(a,u),t.addDash(s,c),t.addDash(l,h);const d=t.getKey(a,u),f=t.getKey(s,c),p=t.getKey(l,h);e.patterns[r.id]={min:d,mid:f,max:p}}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Xc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Zc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,r,i,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,s,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}addLine(e,t,n,r,i,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l0;if(b&&t>l){const e=h.dist(d);if(e>2*u){const t=h.sub(h.sub(d)._mult(u/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,p,0,0,c),d=t}}const T=d&&f;let E=T?n:a?"butt":r;if(T&&"round"===E&&(vi&&(E="bevel"),"bevel"===E&&(v>2&&(E="flipbevel"),v100)_=m.mult(-1);else{const e=v*p.add(m).mag()/p.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,c),this.addCurrentVertex(h,_.mult(-1),0,0,c)}else if("bevel"===E||"fakeround"===E){const e=-Math.sqrt(v*v-1),t=w?e:0,n=w?0:e;if(d&&this.addCurrentVertex(h,p,t,n,c),"fakeround"===E){const e=Math.round(180*x/Math.PI/20);for(let t=1;t2*u){const t=h.add(f.sub(h)._mult(u/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,c),h=t}}}}addCurrentVertex(e,t,n,r,i,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,o,!1,n,i),this.addHalfVertex(e,a,s,o,!0,-r,i)}addHalfVertex({x:e,y:t},n,r,i,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(o?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}Ii(Kc,"LineBucket",{omit:["layers","patternFeatures"]});const Jc=new qo({"line-cap":new Uo(Ye.layout_line["line-cap"]),"line-join":new Uo(Ye.layout_line["line-join"]),"line-miter-limit":new jo(Ye.layout_line["line-miter-limit"]),"line-round-limit":new jo(Ye.layout_line["line-round-limit"]),"line-sort-key":new Uo(Ye.layout_line["line-sort-key"])});var Qc={paint:new qo({"line-opacity":new Uo(Ye.paint_line["line-opacity"]),"line-color":new Uo(Ye.paint_line["line-color"]),"line-translate":new jo(Ye.paint_line["line-translate"]),"line-translate-anchor":new jo(Ye.paint_line["line-translate-anchor"]),"line-width":new Uo(Ye.paint_line["line-width"]),"line-gap-width":new Uo(Ye.paint_line["line-gap-width"]),"line-offset":new Uo(Ye.paint_line["line-offset"]),"line-blur":new Uo(Ye.paint_line["line-blur"]),"line-dasharray":new Vo(Ye.paint_line["line-dasharray"]),"line-pattern":new Vo(Ye.paint_line["line-pattern"]),"line-gradient":new Go(Ye.paint_line["line-gradient"]),"line-trim-offset":new jo(Ye.paint_line["line-trim-offset"])}),layout:Jc};const eh=new class extends Uo{possiblyEvaluate(e,t){return t=new Io(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,zoomHistory:t.zoomHistory,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=I({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}(Qc.paint.properties["line-width"].specification);function th(e,t){return t>0?t+2*e:e}eh.useIntegerZoom=!0;const nh=Ho([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),rh=Ho([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),ih=Ho([{name:"a_projected_pos",components:4,type:"Float32"}],4);Ho([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const oh=Ho([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),ah=Ho([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Ho([{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 sh=Ho([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),lh=Ho([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Ho([{name:"triangle",components:3,type:"Uint16"}]),Ho([{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"}]),Ho([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Ho([{type:"Float32",name:"offsetX"}]),Ho([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]);const uh=128;function ch(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new Io(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=n;let i=0;for(;i{e.text=function(e,t,n){const r=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Ao.applyArabicShaping&&(e=Ao.applyArabicShaping(e)),e}(e.text,t,n)}),e}const mh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function _h(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function gh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var yh=bh,vh=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},xh=function(e,t,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[n+f]=255&a,f+=p,a/=256,u-=8);e[n+f-p]|=128*m}; -/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function bh(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}bh.Varint=0,bh.Fixed64=1,bh.Bytes=2,bh.Fixed32=5;var wh=4294967296,Th=1/wh,Eh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function Sh(e){return e.type===bh.Bytes?e.readVarint()+e.pos:e.pos+1}function kh(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function Ch(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function Mh(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function jh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Uh(e,t,n){t.glyphs=[],1===e&&n.readMessage(Vh,t)}function Vh(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(Nh,{});t.glyphs.push({id:e,bitmap:new hu({width:i+6,height:o+6},r),metrics:{width:i,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function Nh(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}function Gh(e){let t=0,n=0;for(const r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,o=Math.max(o,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){const t=r.pop();e>3,o=this.pos;this.type=7&r,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Bh(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=jh(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Bh(this.buf,this.pos)+Bh(this.buf,this.pos+4)*wh;return this.pos+=8,e},readSFixed64:function(){var e=Bh(this.buf,this.pos)+jh(this.buf,this.pos+4)*wh;return this.pos+=8,e},readFloat:function(){var e=vh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=vh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return kh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return kh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return kh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return kh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return kh(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return kh(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&Eh?function(e,t,n){return Eh.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var r="",i=t;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=e[i+2],128==(192&(o=e[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=e[i+2],s=e[i+3],128==(192&(o=e[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==bh.Bytes)return e.push(this.readVarint(t));var n=Sh(this);for(e=e||[];this.pos127;);else if(t===bh.Bytes)this.pos=this.readVarint()+this.pos;else if(t===bh.Fixed32)this.pos+=4;else{if(t!==bh.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&Ch(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),xh(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),xh(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&Ch(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,bh.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,Mh,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Ah,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,Ph,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Ih,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,zh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Oh,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Dh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Lh,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Rh,t)},writeBytesField:function(e,t){this.writeTag(e,bh.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,bh.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,bh.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,bh.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,bh.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,bh.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,bh.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,bh.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,bh.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,bh.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class qh{constructor(e,{pixelRatio:t,version:n,stretchX:r,stretchY:i,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=i,this.content=o,this.version=n}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class $h{constructor(e,t){const n={},r={};this.haveRenderCallbacks=[];const i=[];this.addImages(e,n,i),this.addImages(t,r,i);const{w:o,h:a}=Gh(i),s=new du({width:o||1,height:a||1});for(const t in e){const r=e[t],i=n[t].paddedRect;du.copy(r.data,s,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data)}for(const e in t){const n=t[e],i=r[e].paddedRect,o=i.x+1,a=i.y+1,l=n.data.width,u=n.data.height;du.copy(n.data,s,{x:0,y:0},{x:o,y:a},n.data),du.copy(n.data,s,{x:0,y:u-1},{x:o,y:a-1},{width:l,height:1}),du.copy(n.data,s,{x:0,y:0},{x:o,y:a+u},{width:l,height:1}),du.copy(n.data,s,{x:l-1,y:0},{x:o-1,y:a},{width:1,height:u}),du.copy(n.data,s,{x:0,y:0},{x:o+l,y:a},{width:1,height:u})}this.image=s,this.iconPositions=n,this.patternPositions=r}addImages(e,t,n){for(const r in e){const i=e[r],o={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(o),t[r]=new qh(o,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}Ii(qh,"ImagePosition"),Ii($h,"ImageAtlas");const Zh={horizontal:1,vertical:2,horizontalOnly:3};class Wh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new Wh;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new Wh;return t.imageName=e,t}}class Xh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new Xh;for(let r=0;r=0&&n>=e&&Yh[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new Xh;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Wh.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Hh(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=Xh.fromFeature(e,i);h===Zh.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,n,r,i,o){if(!e)return[];const a=[],s=function(e,t,n,r,i,o){let a=0;for(let n=0;n=0;let u=0;for(let n=0;n0&&o>b&&(b=o)}else{const e=n[s.fontStack];if(!e)continue;e[m]&&(E=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,k=8203!==m?24:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,n=(e+t)*g;w-n/2;){if(a--,a<0)return!1;s-=e[a].dist(o),o=e[a]}s+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;sr;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=t.dist(n)}return!0}function ld(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=Cn(r.x,i.x,c),d=Cn(r.y,i.y,c),f=new ad(h,d,0,i.angleTo(r),n);return!a||sd(e,f,s,a,t)?f:void 0}l+=o}}function dd(e,t,n,r,i,o,a,s,l){const u=ud(r,o,a),c=cd(r,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&y=0&&f+c<=h){const n=new ad(g,y,0,m,e);n._round(),i&&!sd(t,n,a,i,o)||p.push(n)}}d+=l}return l||p.length||s||(p=e(t,d/2,r,i,o,a,s,!0,u)),p}(e,d?t/2*s%t:(c/2+2*o)*a*s%t,t,u,n,h,d,!1,l)}function fd(e,t,n,r,i){const o=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new m(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new m(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new m(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new m(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(u)))))}}return o}Ii(ad,"Anchor");const pd=1e20;function md(e,t,n,r,i,o,a,s,l){for(let u=t;u-1);l++,o[l]=s,a[l]=u,a[l+1]=pd}for(let s=0,l=0;s{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=r.glyphs[t];if(void 0!==i)return void n(null,{stack:e,id:t,glyph:i});if(i=this._tinySDF(r,e,t),i)return r.glyphs[t]=i,void n(null,{stack:e,id:t,glyph:i});const o=Math.floor(t/256);if(256*o>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void n(null,{stack:e,id:t,glyph:i});let a=r.requests[o];a||(a=r.requests[o]=[],yd.loadGlyphRange(e,o,this.url,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const n of a)n(e,t);delete r.requests[o]})),a.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,n)=>{if(e)t(e);else if(n){const e={};for(const{stack:t,id:r,glyph:i}of n)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==gd.none&&(this.localGlyphMode===gd.all?!!this.localFontFamily:!!this.localFontFamily&&(Ji(e)||to(e)||Gi(e)||qi(e)||Ni(e)))}_tinySDF(e,t,n){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new yd.TinySDF({fontFamily:r,fontWeight:n,fontSize:48,buffer:6,radius:16}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const o=String.fromCharCode(n),{data:a,width:s,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:d,glyphAdvance:f}=i.draw(o);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new hu({width:s,height:l},a),metrics:{width:u/2,height:c/2,left:h/2,top:d/2-27,advance:f/2,localGlyph:!0}}}}function vd(e,t,n,r){const i=[],o=e.image,a=o.pixelRatio,s=o.paddedRect.w-2,l=o.paddedRect.h-2,u=e.right-e.left,c=e.bottom-e.top,h=o.stretchX||[[0,s]],d=o.stretchY||[[0,l]],f=(e,t)=>e+t[1]-t[0],p=h.reduce(f,0),_=d.reduce(f,0),g=s-p,y=l-_;let v=0,x=p,b=0,w=_,T=0,E=g,S=0,k=y;if(o.content&&r){const e=o.content;v=xd(h,0,e[0]),b=xd(d,0,e[1]),x=xd(h,e[0],e[2]),w=xd(d,e[1],e[3]),T=e[0]-v,S=e[1]-b,E=e[2]-e[0]-x,k=e[3]-e[1]-w}const C=(r,i,s,l)=>{const h=wd(r.stretch-v,x,u,e.left),d=Td(r.fixed-T,E,r.stretch,p),f=wd(i.stretch-b,w,c,e.top),g=Td(i.fixed-S,k,i.stretch,_),y=wd(s.stretch-v,x,u,e.left),C=Td(s.fixed-T,E,s.stretch,p),M=wd(l.stretch-b,w,c,e.top),A=Td(l.fixed-S,k,l.stretch,_),I=new m(h,f),z=new m(y,f),P=new m(y,M),O=new m(h,M),D=new m(d/a,g/a),L=new m(C/a,A/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),n=[t,-e,e,t];I._matMult(n),z._matMult(n),O._matMult(n),P._matMult(n)}const B=r.stretch+r.fixed,F=i.stretch+i.fixed;return{tl:I,tr:z,bl:O,br:P,tex:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+F,w:s.stretch+s.fixed-B,h:l.stretch+l.fixed-F},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:L,minFontScaleX:E/a/u,minFontScaleY:k/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=bd(h,g,p),t=bd(d,y,_);for(let n=0;n{if(e)i(e);else if(t){const e={},n=function(e){return new yh(e).readFields(Uh,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},yd.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,l=this._createCanvas(s),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.min(this.size-this.buffer,Math.ceil(o-i)),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),u=s+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),d=new Uint8ClampedArray(h),f={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return f;const{ctx:p,buffer:m,gridInner:_,gridOuter:g}=this;p.clearRect(m,m,s,l),p.fillText(e,m,m+a);const y=p.getImageData(m,m,s,l);g.fill(pd,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}md(g,0,0,u,c,u,this.f,this.v,this.z),md(_,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;e0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,r=t[e];for(;e>0;){const i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r}_down(e){const{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=o,e=r}t[e]=i}}function kd(e,t){return et?1:0}function Cd(e,t=1,n=!1){let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=e[0];for(let e=0;eo)&&(o=t.x),(!e||t.y>a)&&(a=t.y)}const l=Math.min(o-r,a-i);let u=l/2;const c=new Sd([],Md);if(0===l)return new m(r,i);for(let t=r;th.d||!h.d)&&(h=r,n&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(u=r.h/2,c.push(new Ad(r.p.x-u,r.p.y-u,u,e)),c.push(new Ad(r.p.x+u,r.p.y-u,u,e)),c.push(new Ad(r.p.x-u,r.p.y+u,u,e)),c.push(new Ad(r.p.x+u,r.p.y+u,u,e)),d+=4)}return n&&(console.log("num probes: "+d),console.log("best distance: "+h.d)),h.p}function Md(e,t){return t.max-e.max}function Ad(e,t,n,r){this.p=new m(e,t),this.h=n,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;ie.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Qs(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const Id=Number.POSITIVE_INFINITY,zd=Math.sqrt(2);function Pd(e,t){return t[1]!==Id?function(e,t,n){let r=0,i=0;switch(t=Math.abs(t),n=Math.abs(n),e){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}return[r,i]}(e,t[0],t[1]):function(e,t){let n=0,r=0;t<0&&(t=0);const i=t/zd;switch(e){case"top-right":case"top-left":r=i-7;break;case"bottom-right":case"bottom-left":r=7-i;break;case"bottom":r=7-t;break;case"top":r=t-7}switch(e){case"top-right":case"bottom-right":n=-i;break;case"top-left":case"bottom-left":n=i;break;case"left":n=t;break;case"right":n=-t}return[n,r]}(e,t[0])}function Od(e,t,n,r,i,o,a,s,l,u){e.createArrays(),e.tilePixelRatio=vs/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const c=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,d={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;d.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Io(t),s),h["text-size"].possiblyEvaluate(new Io(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;d.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Io(t),s),h["icon-size"].possiblyEvaluate(new Io(n),s)]}d.layoutTextSize=h["text-size"].possiblyEvaluate(new Io(l+1),s),d.layoutIconSize=h["icon-size"].possiblyEvaluate(new Io(l+1),s),d.textMaxSize=h["text-size"].possiblyEvaluate(new Io(18),s);const f="map"===c.get("text-rotation-alignment")&&"point"!==c.get("symbol-placement"),p=c.get("text-size");for(const o of e.features){const l=c.get("text-font").evaluate(o,{},s).join(","),h=p.evaluate(o,{},s),m=d.layoutTextSize.evaluate(o,{},s),_=(d.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),g=o.text;let y,v=[0,0];if(g){const r=g.toString(),a=24*c.get("text-letter-spacing").evaluate(o,{},s),u=24*c.get("text-line-height").evaluate(o,{},s),d=co(r)?a:0,p=c.get("text-anchor").evaluate(o,{},s),y=c.get("text-variable-anchor");if(!y){const e=c.get("text-radial-offset").evaluate(o,{},s);v=e?Pd(p,[24*e,Id]):c.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let x=f?"center":c.get("text-justify").evaluate(o,{},s);const b="point"===c.get("symbol-placement"),w=b?24*c.get("text-max-width").evaluate(o,{},s):1/0,T=o=>{e.allowVerticalPlacement&&uo(r)&&(_.vertical=Hh(g,t,n,i,l,w,u,p,o,d,v,Zh.vertical,!0,m,h))};if(!f&&y){const e="auto"===x?y.map(e=>Dd(e)):[x];let r=!1;for(let o=0;o=0||!uo(r)){const e=Hh(g,t,n,i,l,w,u,p,x,d,v,Zh.horizontal,!1,m,h);e&&(_.horizontal[x]=e)}T(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=r[o.icon.name];t&&(y=id(i[o.icon.name],c.get("icon-offset").evaluate(o,{},s),c.get("icon-anchor").evaluate(o,{},s)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&N("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=Fd(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Ld(e,o,_,y,r,d,m,0,v,x,a,s,u)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Dd(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Ld(e,t,n,r,i,o,a,s,l,u,c,h,d){let f=o.textMaxSize.evaluate(t,{},h);void 0===f&&(f=a);const p=e.layers[0].layout,m=p.get("icon-offset").evaluate(t,{},h),_=Fd(n.horizontal)||n.vertical,g="globe"===d.name,y=a/24,x=e.tilePixelRatio*f/24,b=(A=e.overscaling,e.zoom>18&&A>2&&(A>>=1),Math.max(vs/(512*A),1)*p.get("symbol-spacing")),w=p.get("text-padding")*e.tilePixelRatio,T=p.get("icon-padding")*e.tilePixelRatio,E=v(p.get("text-max-angle")),S="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),k="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),C=p.get("symbol-placement"),M=b/2;var A;const I=p.get("icon-text-fit");let z;r&&"none"!==I&&(e.allowVerticalPlacement&&n.vertical&&(z=od(r,n.vertical,I,p.get("icon-text-fit-padding"),m,y)),_&&(r=od(r,_,I,p.get("icon-text-fit-padding"),m,y)));const P=(a,s,f)=>{if(s.x<0||s.x>=vs||s.y<0||s.y>=vs)return;let p=null;if(g){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,f);p={anchor:new ad(e,t,n,0,void 0),up:d.upVector(f,s.x,s.y)}}!function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,T,E){const S=e.addToLineVertexArray(t,r);let k,C,M,A,I,z,P,O=0,D=0,L=0,R=0,B=-1,F=-1;const j={};let U=Ua.exports("");const V=n?n.anchor:t;let G=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,q]=l.layout.get("text-offset").evaluate(x,{},E).map(e=>24*e):(G=24*l.layout.get("text-radial-offset").evaluate(x,{},E),q=Id),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)z=Ud(e),s&&(P=Ud(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},E)+90;M=jd(u,V,t,c,h,d,e,f,n,m),s&&(A=jd(u,V,t,c,h,d,s,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},E),i="none"!==l.layout.get("icon-text-fit"),a=vd(o,r,w,i),f=s?vd(s,r,w,i):void 0;C=jd(u,V,t,c,h,d,o,g,r),O=4*a.length;const p=e.iconSizeData;let m=null;"source"===p.kind?(m=[uh*l.layout.get("icon-size").evaluate(x,{},E)],m[0]>Rd&&N(e.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')):"composite"===p.kind&&(m=[uh*b.compositeIconSizes[0].evaluate(x,{},E),uh*b.compositeIconSizes[1].evaluate(x,{},E)],(m[0]>Rd||m[1]>Rd)&&N(e.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')),e.addSymbols(e.icon,a,m,v,y,x,!1,n,t,S.lineStartIndex,S.lineLength,-1,T,E),B=e.icon.placedSymbolArray.length-1,f&&(D=4*f.length,e.addSymbols(e.icon,f,m,v,y,x,Zh.vertical,n,t,S.lineStartIndex,S.lineLength,-1,T,E),F=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];k||(U=Ua.exports(o.text),p?I=Ud(o):k=jd(u,V,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},E),m));const s=1===o.positionedLines.length;if(L+=Bd(e,n,t,o,a,l,p,x,m,S,i.vertical?Zh.horizontal:Zh.horizontalOnly,s?Object.keys(i.horizontal):[r],j,B,b,T,E),s)break}i.vertical&&(R+=Bd(e,n,t,i.vertical,a,l,p,x,m,S,Zh.vertical,["vertical"],j,F,b,T,E));let $=-1;const Z=(e,t)=>e?Math.max(e,t):t;$=Z(I,$),$=Z(z,$),$=Z(P,$);const W=$>-1?1:0;e.glyphOffsetArray.length>=Jf.MAX_GLYPHS&&N("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(V.x,V.y,V.z,t.x,t.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,B,F,U,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,void 0!==M?M:e.collisionBoxArray.length,void 0!==M?M+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,A||e.collisionBoxArray.length,A?A+1:e.collisionBoxArray.length,c,L,R,O,D,W,0,G,q,$)}(e,s,p,a,n,r,i,z,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,w,S,l,0,T,k,m,t,o,u,c,h)};if("line"===C)for(const i of fd(t.geometry,0,0,vs,vs)){const t=dd(i,b,E,n.vertical||_,r,24,x,e.overscaling,vs);for(const n of t){const t=_;t&&Vd(e,t.text,M,n)||P(i,n,h)}}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=hd(e,E,n.vertical||_,r,24,x);t&&P(e,t,h)}}else if("Polygon"===t.type)for(const e of Xu(t.geometry,0)){const t=Cd(e,16);P(e[0],new ad(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)P(e,new ad(e[0].x,e[0].y,0,0,void 0),h);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)P([t],new ad(t.x,t.y,0,0,void 0),h)}const Rd=32640;function Bd(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,_,g){const y=function(e,t,n,r,i,o,a,s){const l=[];if(0===t.positionedLines.length)return l;const u=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(e){const t=e[0],n=e[1],r=t*n;return r>0?[t,-n]:r<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,f=h/d;let p=t.top-n[1];for(let e=0;eRd&&N(e.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')):"composite"===v.kind&&(x=[uh*p.compositeTextSizes[0].evaluate(s,{},g),uh*p.compositeTextSizes[1].evaluate(s,{},g)],(x[0]>Rd||x[1]>Rd)&&N(e.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')),e.addSymbols(e.text,y,x,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,_,g);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function Fd(e){for(const t in e)return e[t];return null}function jd(e,t,n,r,i,o,a,s,l,u){let c=a.top,h=a.bottom,d=a.left,f=a.right;const p=a.collisionPadding;if(p&&(d-=p[0],c-=p[1],f+=p[2],h+=p[3]),l){const e=new m(d,c),t=new m(f,c),n=new m(d,h),r=new m(f,h),i=v(l);let o=new m(0,0);u&&(o=new m(u[0],u[1])),e._rotateAround(i,o),t._rotateAround(i,o),n._rotateAround(i,o),r._rotateAround(i,o),d=Math.min(e.x,t.x,n.x,r.x),f=Math.max(e.x,t.x,n.x,r.x),c=Math.min(e.y,t.y,n.y,r.y),h=Math.max(e.y,t.y,n.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,d,c,f,h,s,r,i,o),e.length-1}function Ud(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Vd(e,t,n,r){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])1?null:function(e,t,n,r){const i=Math.sin(n);return e*(Math.sin((1-r)*n)/i)+t*(Math.sin(r*n)/i)}(e.a[t],e.b[t],e.angle,S(n,0,1))+e.center[t]}function tf(e){if(e.z<=1)return Kd[e.z+2*e.y+e.x];const t=sf(af(e));return tu.fromPoints(t)}function nf(e,t,n){return Ol(e,e,1-n),Dl(e,e,t,n)}function rf(e,t){const n=_f(t.zoom);if(0===n)return tf(e);const r=af(e),i=sf(r),o=Ss(r.getWest())*t.worldSize,a=Ss(r.getEast())*t.worldSize,s=ks(r.getNorth())*t.worldSize,l=ks(r.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=ml([],t.globeMatrix);return Fl(u,u,f),Fl(c,c,f),Fl(h,h,f),Fl(d,d,f),i[0]=nf(i[0],h,n),i[1]=nf(i[1],d,n),i[2]=nf(i[2],c,n),i[3]=nf(i[3],u,n),tu.fromPoints(i)}function of(e,t,n){for(const r of e)Fl(r,r,t),Ol(r,r,n)}function af({x:e,y:t,z:n}){const r=1/(1<v&&(x(e,u,r,i,s,l),x(u,n,s,l,o,a))}x(h,d,r,o,i,o),x(d,f,i,o,i,a),x(f,p,i,a,r,a),x(p,h,r,a,r,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}const Tf=pl(new Float32Array(16));class Ef{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 ws(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t,n=!0){return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return Cs(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return bf(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,r){const i=e.horizonLineFromTop(!1),o=new m(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,n){const r=new m(t,n);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-Of+n&&(t=-Of+n):t>Of-n&&(t=Of-n);const o=i/Math.pow(Df(t),r);let a=o*Math.sin(r*e),s=i-o*Math.cos(r*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:r}=this,i=r-t,o=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let s=Math.atan2(e,Math.abs(i))*o;i*n<0&&(s-=Math.PI*Math.sign(e)*o);const l=S(x(s/n)+this.center[0],-180,180),u=S(x(2*Math.atan(Math.pow(r/a,1/n))-Of),-85.051129,zs);return new ws(l,this.southernCenter?-u:u)}}class Rf extends Ef{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:Ss(e),y:ks(t),z:0}}unproject(e,t){const n=Ms(e),r=As(t);return new ws(n,r)}}const Bf=v(zs);class Ff extends Ef{project(e,t){const n=(t=v(t))*t,r=n*n;return{x:.5*((e=v(e))*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,r=25,i=0,o=n*n;do{o=n*n;const e=o*o;i=(n*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),n=S(n-i,-Bf,Bf)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=S(x(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=x(n);return new ws(a,s)}}const jf=v(zs);class Uf extends Ef{project(e,t){t=v(t),e=v(e);const n=Math.cos(t),r=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),o=Math.sin(i)/i,a=.5*(e*r+2*n*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,i=25;const o=1e-6;let a=0,s=0;do{const i=Math.cos(r),o=Math.sin(r),l=2*o*i,u=o*o,c=i*i,h=Math.cos(n/2),d=Math.sin(n/2),f=2*h*d,p=d*d,m=1-c*h*h,_=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,y=.5*(2*g*i*d+2*n/Math.PI)-e,v=.5*(g*o+r)-t,x=.5*_*(c*p+g*i*h*u)+1/Math.PI,b=_*(f*l/4-g*o*d),w=.125*_*(l*d-g*o*c*f),T=.5*_*(u*h+g*p*i)+.5,E=b*w-T*x;a=(v*b-y*T)/E,s=(y*w-v*x)/E,n=S(n-a,-Math.PI,Math.PI),r=S(r-s,-jf,jf)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new ws(x(n),x(r))}}class Vf extends Ef{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(v(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:r}=this;return{x:v(e)*r*n+.5,y:-Math.sin(v(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=S(x((e-.5)/n)/r,-180,180),a=Math.asin(S(i*r,-1,1)),s=S(x(a),-85.051129,zs);return new ws(o,s)}}class Nf extends Rf{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,n){const r=cf(e,t,n);return Fl(r,r,ff(tf(n))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=uf(t.lat,t.lng),r=Ll([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Dl(n,n,r,Cs(1,0)*vs*i);const o=pl(new Float64Array(16));return _l(o,e.pixelMatrix,e.globeMatrix),Fl(n,n,o),new m(n[0],n[1])}pixelsPerMeter(e,t){return Cs(1,0)*t}pixelSpaceConversion(e,t,n){const r=Cs(1,e)*t,i=Cn(Cs(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=pf(tf(n.canonical));return _l(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=ff(tf(t));return xl(r,r,v(n.lng)),vl(r,r,v(n.lat)),yl(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Jd(e,t,n,!0)||new Os(0,0)}pointCoordinate3D(e,t,n){const r=this.pointCoordinate(e,t,n,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Jd(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const n=e.cameraToCenterDistance,r=e._centerAltitude*t,i=e._camera,o=e._camera.forward(),a=Ml([],Ol([],o,-n),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=Ol([],i.up(),c),d=Ol([],i.right(),c*u),f=Ll([],Ml([],Ml([],o,h),d)),p=[];let m;if(new Jl(a,f).closestPointOnSphere(l,s,p)){const t=Ml([],p,l),n=Vl([],t,a);m=Math.cos(e.fovAboveCenter)*kl(n)}else{const e=Vl([],a,l),t=Vl([],l,a);Ll(t,t);const n=kl(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(Rl(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=_f(e.zoom);if(n>0){const r=bf(e,Cs(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Cn(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return cf(t,n,e,1)}upVectorScale(e){return{metersToTile:Wd*hf(tf(e))}}}function Gf(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Rf(e);case"equirectangular":return new Pf(e);case"naturalEarth":return new Ff(e);case"equalEarth":return new zf(e);case"winkelTripel":return new Uf(e);case"albers":return n?new Vf(e):new Sf(e);case"lambertConformalConic":return n?new Vf(e):new Lf(e);case"globe":return new Nf(e)}throw new Error("Invalid projection name: "+e.name)}const qf=yc.types,$f=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Zf(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Rd,Math.round(s[0])):0,p=s?Math.min(Rd,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),p,16*u,16*c,256*h,256*d)}function Wf(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function Xf(e,t,n,r,i){e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i)}function Hf(e){for(const t of e.sections)if(go(t.text))return!0;return!1}class Yf{constructor(e){this.layoutVertexArray=new oa,this.indexArray=new fa,this.programConfigurations=e,this.segments=new ys,this.dynamicLayoutVertexArray=new ta,this.opacityVertexArray=new sa,this.placedSymbolArray=new Ca,this.globeExtVertexArray=new aa}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,nh.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,ih.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,$f,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,rh.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}Ii(Yf,"SymbolBuffers");class Kf{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new ys,this.collisionVertexArray=new ha,this.collisionVertexArrayExt=new da}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,oh.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,ah.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}Ii(Kf,"CollisionBuffers");class Jf{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=pl([]),this.placementViewportMatrix=pl([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ch(this.zoom,t["text-size"]),this.iconSizeData=ch(this.zoom,t["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(e=>Zh[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new Yf(new ls(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Yf(new ls(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Ia,this.lineVertexArray=new za,this.symbolInstances=new Aa}calculateGlyphDependencies(e,t,n,r,i){for(let n=0;n0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=t.iconDependencies,p=t.glyphDependencies,m=t.availableImages,_=new Io(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Ns(t,e);if(!i._featureFilter.filter(_,y,n))continue;if(e||(y.geometry=Vs(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>Rl(cf(e.x,e.y,n,1),cf(r.x,r.y,n,1))=0;for(const n of v.sections)if(n.image)f[n.image.name]=!0;else{const r=uo(v.toString()),i=n.fontStack||e,o=p[i]=p[i]||{};this.calculateGlyphDependencies(n.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},n={},r=[];let i=0;function o(t){r.push(e[t]),i++}function a(e,t,i){const o=n[e];return delete n[e],n[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(e,n,i){const o=t[n];return delete t[n],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(e,t,n){const r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let u=0;ue.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,n,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,n,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Gf(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length,r=e.segment;if(void 0!==r){let n=e.dist(t[r+1]),i=e.dist(t[r]);const o={};for(let e=r+1;e=0;e--)o[e]={x:t[e].x,y:t[e].y,tileUnitDistanceFromAnchor:i},e>0&&(i+=t[e-1].dist(t[e]));for(let e=0;e=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=hh(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=hh(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n){e.emplaceBack(t,-n,-n),e.emplaceBack(t,n,-n),e.emplaceBack(t,n,n),e.emplaceBack(t,-n,n)}_updateTextDebugCollisionBoxes(e,t,n,r,i,o){for(let a=r;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),o}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex),[t.rightJustifiedTextSymbolIndex,t.centerJustifiedTextSymbolIndex,t.leftJustifiedTextSymbolIndex].forEach((e,t,n)=>{e>=0&&n.indexOf(e)===t&&this.addIndicesForPlacedSymbol(this.text,e)}),t.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,t.verticalPlacedTextSymbolIndex),t.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.placedIconSymbolIndex),t.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,t.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}Ii(Jf,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Jf.MAX_GLYPHS=65535,Jf.addDynamicAttributes=Xf;const Qf=new qo({"symbol-placement":new jo(Ye.layout_symbol["symbol-placement"]),"symbol-spacing":new jo(Ye.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new jo(Ye.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Uo(Ye.layout_symbol["symbol-sort-key"]),"symbol-z-order":new jo(Ye.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new jo(Ye.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new jo(Ye.layout_symbol["icon-ignore-placement"]),"icon-optional":new jo(Ye.layout_symbol["icon-optional"]),"icon-rotation-alignment":new jo(Ye.layout_symbol["icon-rotation-alignment"]),"icon-size":new Uo(Ye.layout_symbol["icon-size"]),"icon-text-fit":new jo(Ye.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new jo(Ye.layout_symbol["icon-text-fit-padding"]),"icon-image":new Uo(Ye.layout_symbol["icon-image"]),"icon-rotate":new Uo(Ye.layout_symbol["icon-rotate"]),"icon-padding":new jo(Ye.layout_symbol["icon-padding"]),"icon-keep-upright":new jo(Ye.layout_symbol["icon-keep-upright"]),"icon-offset":new Uo(Ye.layout_symbol["icon-offset"]),"icon-anchor":new Uo(Ye.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new jo(Ye.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new jo(Ye.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new jo(Ye.layout_symbol["text-rotation-alignment"]),"text-field":new Uo(Ye.layout_symbol["text-field"]),"text-font":new Uo(Ye.layout_symbol["text-font"]),"text-size":new Uo(Ye.layout_symbol["text-size"]),"text-max-width":new Uo(Ye.layout_symbol["text-max-width"]),"text-line-height":new Uo(Ye.layout_symbol["text-line-height"]),"text-letter-spacing":new Uo(Ye.layout_symbol["text-letter-spacing"]),"text-justify":new Uo(Ye.layout_symbol["text-justify"]),"text-radial-offset":new Uo(Ye.layout_symbol["text-radial-offset"]),"text-variable-anchor":new jo(Ye.layout_symbol["text-variable-anchor"]),"text-anchor":new Uo(Ye.layout_symbol["text-anchor"]),"text-max-angle":new jo(Ye.layout_symbol["text-max-angle"]),"text-writing-mode":new jo(Ye.layout_symbol["text-writing-mode"]),"text-rotate":new Uo(Ye.layout_symbol["text-rotate"]),"text-padding":new jo(Ye.layout_symbol["text-padding"]),"text-keep-upright":new jo(Ye.layout_symbol["text-keep-upright"]),"text-transform":new Uo(Ye.layout_symbol["text-transform"]),"text-offset":new Uo(Ye.layout_symbol["text-offset"]),"text-allow-overlap":new jo(Ye.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new jo(Ye.layout_symbol["text-ignore-placement"]),"text-optional":new jo(Ye.layout_symbol["text-optional"])});var ep={paint:new qo({"icon-opacity":new Uo(Ye.paint_symbol["icon-opacity"]),"icon-color":new Uo(Ye.paint_symbol["icon-color"]),"icon-halo-color":new Uo(Ye.paint_symbol["icon-halo-color"]),"icon-halo-width":new Uo(Ye.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Uo(Ye.paint_symbol["icon-halo-blur"]),"icon-translate":new jo(Ye.paint_symbol["icon-translate"]),"icon-translate-anchor":new jo(Ye.paint_symbol["icon-translate-anchor"]),"text-opacity":new Uo(Ye.paint_symbol["text-opacity"]),"text-color":new Uo(Ye.paint_symbol["text-color"],{runtimeType:lt,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Uo(Ye.paint_symbol["text-halo-color"]),"text-halo-width":new Uo(Ye.paint_symbol["text-halo-width"]),"text-halo-blur":new Uo(Ye.paint_symbol["text-halo-blur"]),"text-translate":new jo(Ye.paint_symbol["text-translate"]),"text-translate-anchor":new jo(Ye.paint_symbol["text-translate-anchor"])}),layout:Qf};class tp{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:it,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}}Ii(tp,"FormatSectionOverride",{omit:["defaultValue"]});class np extends ms{constructor(e){super(e,ep)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){const i=this.layout.get(e).evaluate(t,{},n,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||Fr(o.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>n in e?String(e[n]):"")}(t.properties,i)}createBucket(e){return new Jf(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of ep.paint.overridableProperties){if(!np.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new tp(t),r=new Br(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Ur("source",r):new Vr("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Bo(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&np.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=ep.paint.properties[t];let i=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof It)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof Bt&&Dt(t.value)===dt?o(t.value.sections):t instanceof Nt?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramConfiguration(e){return new ss(this,e)}}var rp={paint:new qo({"background-color":new jo(Ye.paint_background["background-color"]),"background-pattern":new No(Ye.paint_background["background-pattern"]),"background-opacity":new jo(Ye.paint_background["background-opacity"])})},ip={paint:new qo({"raster-opacity":new jo(Ye.paint_raster["raster-opacity"]),"raster-hue-rotate":new jo(Ye.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new jo(Ye.paint_raster["raster-brightness-min"]),"raster-brightness-max":new jo(Ye.paint_raster["raster-brightness-max"]),"raster-saturation":new jo(Ye.paint_raster["raster-saturation"]),"raster-contrast":new jo(Ye.paint_raster["raster-contrast"]),"raster-resampling":new jo(Ye.paint_raster["raster-resampling"]),"raster-fade-duration":new jo(Ye.paint_raster["raster-fade-duration"])})};class op extends ms{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var ap={paint:new qo({"sky-type":new jo(Ye.paint_sky["sky-type"]),"sky-atmosphere-sun":new jo(Ye.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new jo(Ye.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new jo(Ye.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new jo(Ye.paint_sky["sky-gradient-radius"]),"sky-gradient":new Go(Ye.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new jo(Ye.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new jo(Ye.paint_sky["sky-atmosphere-color"]),"sky-opacity":new jo(Ye.paint_sky["sky-opacity"])})};function sp(e,t,n){const r=[0,0,1],i=Xl([]);return Yl(i,i,n?-v(e)+Math.PI:v(e)),Hl(i,i,-v(t)),jl(r,r,i),Ll(r,r)}const lp={circle:class extends ms{constructor(e){super(e,ul)}createBucket(e){return new $s(e)}queryRadius(e){const t=e;return il("circle-radius",this,t)+il("circle-stroke-width",this,t)+ol(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=sl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,n)+this.paint.get("circle-stroke-width").evaluate(t,n);return nu(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ss(this,e)}},heatmap:class extends ms{createBucket(e){return new su(e)}constructor(e){super(e,fu),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=pu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return il("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return nu(e,r,o,a,s,!0,!0,new m(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ss(this,e)}},hillshade:class extends ms{constructor(e){super(e,mu)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends ms{constructor(e){super(e,ec)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),n=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(e){return new ss(this,e)}recalculate(e,t){super.recalculate(e,t);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Ju(e)}queryRadius(){return ol(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&Xs(al(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends ms{constructor(e){super(e,Lc)}createBucket(e){return new Sc(e)}queryRadius(){return ol(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ss(this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=sl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,n),h=this.paint.get("fill-extrusion-base").evaluate(t,n),d=[0,0],f=s&&o.elevation,p=o.elevation?o.elevation.exaggeration():1,_=e.tile.getBucket(this);if(f&&_ instanceof Sc){const e=_.centroidVertexArray,t=l+1;if(te.polygon).flat());const g=f?s:null,[y,v]=function(e,t,n,r,i,o,a,s,l,u,c){return"globe"===e.projection.name?function(e,t,n,r,i,o,a,s,l,u,c){const h=[],d=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,p=[0,0,0,1],m=[0,0,0,1],_=(e,t,n,r)=>{e[0]=t,e[1]=n,e[2]=r,e[3]=1},g=Pc();n>0&&(n+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(d,g,c),x=e.projection.upVector(c,h.x,h.y);let b=n,w=r;if(a){const e=qc(d,g,n,r,a,s,l,u);b+=e.base,w+=e.top}0!==n?_(p,v.x+x[0]*f*b,v.y+x[1]*f*b,v.z+x[2]*f*b):_(p,v.x,v.y,v.z),_(m,v.x+x[0]*f*w,v.y+x[1]*f*w,v.z+x[2]*f*w),Fl(p,p,o),Fl(m,m,o),t.push(new Vc(p[0],p[1],p[2])),y.push(new Vc(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,n,r,i,o,a,s,l,u,c):a?function(e,t,n,r,i,o,a,s,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],f=[];for(const u of d){const c=u.x+r.x,d=u.y+r.y,p=qc(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,Zl(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Vc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=p.top,h[3]=1,Zl(h,h,i),h[3]=Math.max(h[3],1e-5);const _=new Vc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),f.push(_)}u.push(e),c.push(f)}return[u,c]}(t,n,r,i,o,a,s,l,u):function(e,t,n,r,i){const o=[],a=[],s=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*n,d=i[9]*n,f=i[10]*n,p=i[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x+r.x,a=o.y+r.y,m=i[0]*t+i[4]*a+i[12],_=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],y=i[3]*t+i[7]*a+i[15],v=m+s,x=_+l,b=g+u,w=Math.max(y+c,1e-5),T=m+h,E=_+d,S=g+f,k=Math.max(y+p,1e-5);e.push(new Vc(v/w,x/w,b/w)),n.push(new Vc(T/k,E/k,S/k))}o.push(e),a.push(n)}return[o,a]}(t,n,r,i,o)}(o,r,h,c,u,a,g,d,p,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(e,t,n){let r=1/0;Xs(n,t)&&(r=Gc(n,t[0]));for(let i=0;i=3)for(let t=0;t{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 hp{constructor(){this.tasks={},this.taskQueue=[],R(["process"],this),this.invoker=new cp(this.process),this.nextId=0}add(e,t){const n=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:n}){return n=n||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-n:"maybePrepare"===e&&t?400-n:500:200-n:100-n}(t);if(0===r){$();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:t,priority:r,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){$();try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let n=0;n>=1)>1;){const e=n+i>>1,l=r+o>>1;1&t?(i=n,o=r,n=a,r=s):(n=i,r=o,i=a,o=s),a=e,s=l}const l=4*e;mp[l+0]=n,mp[l+1]=r,mp[l+2]=i,mp[l+3]=o}const _p=new Uint16Array(2178),gp=new Uint8Array(1089),yp=new Uint16Array(1089);function vp(e){return 0===e?-.03125:32===e?.03125:0}var xp=Ho([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const bp={type:2,extent:vs,loadGeometry:()=>[[new m(0,0),new m(8193,0),new m(8193,8193),new m(0,8193),new m(0,0)]]};class wp{constructor(e,t,n,r,i){this.tileID=e,this.uid=P(),this.uses=0,this.tileSize=t,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;tt.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)n[t.id]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Jf){if(this.hasSymbolBuckets=!0,!n)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Jf&&t.hasRTLText){this.hasRTLText=!0,Ao.isLoading()||Ao.isLoaded()||"deferred"!==Co()||Mo();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new Sa}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const n=this.buckets[t];n.uploadPending()&&n.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new up(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new up(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new up(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(e,t){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),i=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[i];if(!o)return;const a=Jr(t&&t.filter),{z:s,x:l,y:u}=this.tileID.canonical,c={z:s,x:l,y:u};for(let t=0;te)n=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,n=mp[t+0],r=mp[t+1],i=mp[t+2],o=mp[t+3],a=n+i>>1,s=r+o>>1,l=a+s-r,u=s+n-a,c=33*r+n,h=33*o+i,d=33*s+a,f=Math.hypot((_p[2*c+0]+_p[2*h+0])/2-_p[2*d+0],(_p[2*c+1]+_p[2*h+1])/2-_p[2*d+1])>=16;if(gp[d]=gp[d]||(f?1:0),e<1022){const e=33*(r+u>>1)+(n+l>>1),t=33*(o+u>>1)+(i+l>>1);gp[d]=gp[d]||gp[e]||gp[t]}}const i=new Qo,o=new fa;let a=0;function s(e,t){const n=33*t+e;return 0===yp[n]&&(i.emplaceBack(_p[2*n+0],_p[2*n+1],e*vs/32,t*vs/32),yp[n]=++a),yp[n]-1}function l(e,t,n,r,i,a){const u=e+n>>1,c=t+r>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&gp[33*c+u])l(i,a,e,t,u,c),l(n,r,i,a,u,c);else{const l=s(e,t),u=s(n,r),c=s(i,a);o.emplaceBack(l,u,c)}}return l(0,0,32,32,32,0),l(32,32,0,0,0,32),{vertices:i,indices:o}}(this.tileID.canonical,t);r=e.vertices,i=e.indices}else{r=new Qo,i=new fa;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=yu.exports(r.int16,void 0,4);for(let t=0;t0&&(a=ml(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,i,a,o),this._makeGlobeTileDebugTextBuffer(e,r,t,i,a,o)}_globePoint(e,t,n,r,i,o,a){let s=cf(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/vs+n.x)/i+h,f=(t/vs+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];Fl(p,p,o),s=nf(s,p,a)}return Fl(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new Ko,s=new xa,l=new Jo,u=(e,u,c,h,d)=>{const f=(c-e)/(d-1),p=(h-u)/(d-1),m=a.length;for(let c=0;cu*e+t;for(let e=0;et[a])return null}else{const s=1/r[a];let l=(e[a]-n[a])*s,u=(t[a]-n[a])*s;if(l>u){const e=l;l=u,u=e}if(l>i&&(i=l),uo)return null}return i}function kp(e,t,n,r,i,o,a,s,l,u,c){const h=r-e,d=i-t,f=o-n,p=a-e,m=s-t,_=l-n,g=c[1]*_-c[2]*m,y=c[2]*p-c[0]*_,v=c[0]*m-c[1]*p,x=h*g+d*y+f*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=u[0]-e,T=u[1]-t,E=u[2]-n,S=(w*g+T*y+E*v)*b;if(S<0||S>1)return null;const k=T*f-E*d,C=E*h-w*f,M=w*d-T*h,A=(c[0]*k+c[1]*C+c[2]*M)*b;return A<0||S+A>1?null:(p*k+m*C+_*M)*b}function Cp(e,t,n){return(e-t)/(n-t)}function Mp(e,t,n,r,i,o,a,s,l){const u=1<{const o=r?1:0,a=(e+1)*n-o,s=t*n,l=(t+1)*n-o;i[0]=e*n,i[1]=s,i[2]=a,i[3]=l};let a=new Ep(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new Ep(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:_}=d.pop();if(this.leaves[s]){Mp(p,m,_,e,t,n,r,c,h);const s=1<<_,l=(p+0)/s,u=(p+1)/s,d=(m+0)/s,g=(m+1)/s,y=zp(l,d,this.dem)*a,v=zp(u,d,this.dem)*a,x=zp(u,g,this.dem)*a,b=zp(l,g,this.dem)*a,w=kp(c[0],c[1],y,h[0],c[1],v,h[0],h[1],x,i,o),T=kp(h[0],h[1],x,c[0],h[1],b,c[0],c[1],y,i,o),E=Math.min(null!==w?w:Number.MAX_VALUE,null!==T?T:Number.MAX_VALUE);if(E!==Number.MAX_VALUE)return E;{const e=Dl([],i,o,f);if(Ip(y,v,b,x,Cp(e[0],c[0],h[0]),Cp(e[1],c[1],h[1]))>=e[2])return f}continue}let g=0;for(let d=0;d=l[u[n]]&&(u.splice(n,0,d),t=!0);t||(u[g]=d),g++}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,n){return(256*e*256+256*t+n)/10-1e4}_unpackTerrarium(e,t,n){return 256*e+t+n/256-32768}static pack(e,t){const n=[0,0,0,0],r=Op.getUnpackVector(t);let i=Math.floor((e+r[3])/r[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new du({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,i=t*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-n*this.dim;for(let t=o;t{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,r=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const n in this.data)for(const r of this.data[n])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Lp{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Lp.ReadOnly=!1,Lp.ReadWrite=!0,Lp.disabled=new Lp(519,Lp.ReadOnly,[0,1]);class Rp{constructor(e,t,n,r,i,o){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o}}Rp.disabled=new Rp({func:519,mask:0},0,0,7680,7680,7680);class Bp{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}Bp.Replace=[1,0],Bp.disabled=new Bp(Bp.Replace,Ct.transparent,[!1,!1,!1,!1]),Bp.unblended=new Bp(Bp.Replace,Ct.transparent,[!0,!0,!0,!0]),Bp.alphaBlended=new Bp([1,771],Ct.transparent,[!0,!0,!0,!0]);class Fp{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}Fp.disabled=new Fp(!1,1029,2305),Fp.backCCW=new Fp(!0,1029,2305),Fp.backCW=new Fp(!0,1029,2304),Fp.frontCW=new Fp(!0,1028,2304),Fp.frontCCW=new Fp(!0,1028,2305);class jp extends He{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Dp(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new Tp,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return A(this._tiles).map(e=>e.tileID).sort(Up).map(e=>e.key)}getRenderableIds(e){const t=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&t.push(this._tiles[n]);return e?t.sort((e,t)=>{const n=e.tileID,r=t.tileID,i=new m(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new m(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||o.y-i.y||o.x-i.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(Up).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(e,t,n,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new Xe(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=qe.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new We("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,r){for(const i in this._tiles){let o=this._tiles[i];if(r[i]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>n)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const n=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,i=Math.floor(n*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new jc(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[];const i=this._updateRetainedTiles(r);if(Vp(this._source.type)&&0!==r.length){const e={},t={},n=Object.keys(i);for(const r of n){const n=i[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=qe.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-jp.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(i[e]||!n.hasData())continue;let r=n.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){i[e]=n.tileID;break}}}for(const t in e)i[t]||(this._coveredTiles[t]=!0,i[t]=e[t])}for(const e in i)this._tiles[e].clearFadeHold();const o=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,i);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const n={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),i=e[0].overscaledZ,o=Math.max(i-jp.maxOverzooming,this._source.minzoom),a=Math.max(i+jp.maxUnderzooming,this._source.minzoom),s={};for(const n of e){const e=this._addTile(n);t[n.key]=n,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let i=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(n[o.key])break;if(n[o.key]=!0,e=this.getTile(o),!e&&i&&(e=this._addTile(o)),e&&(t[o.key]=o,i=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(e){let t=this._tiles[e.key];if(t)return t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const n=Boolean(t);if(!n){const n=this.map?this.map.painter:null;t=new wp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,n||this._source.fire(new We("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,n){const r=[],i=this.transform;if(!i)return r;const o="globe"===i.projection.name,a=Ss(i.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(S(a,...Np(e,-1))-a),Math.abs(S(a,...Np(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(S(a,...Np(e,-1))-a),Math.abs(S(a,...Np(e,0))-a),Math.abs(S(a,...Np(e,1))-a)];u=[t.indexOf(Math.min(...t))-1]}}else u=[0];for(const n of u){const o=e.containsTile(l,i,t,n);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Vp(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=qe.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,t))}_preloadTiles(e,t){const n=new Map,r=Array.isArray(e)?e:[e],i=this.map.painter.terrain,o=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}M(Array.from(n.values()),(e,t)=>{const n=new wp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)})},t)}}function Up(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Vp(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Np(e,t){const n=1<=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new gc(new yh(this.rawTileData)).layers,this.sourceLayerCoder=new dp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,n,r){this.loadVTLayers();const i=e.params||{},o=Jr(i.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,(e,t,n,r)=>nl(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(Zp);let c=null;s.elevation&&u.length>0&&(c=Gp.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Vs(t,this.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(a,t,r,p,this.z,e.transform,e.pixelPosMatrix,c,i)))}return h}loadMatchingFeature(e,t,n,r,i,o,a,s,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,f=this.bucketLayerIDs[c];if(r&&!function(e,t){for(let n=0;n=0)return!0;return!1}(r,f))return;const p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(u);if(n.needGeometry){const e=Ns(m,!0);if(!n.filter(new Io(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new Io(this.tileID.overscaledZ),m))return;const _=this.getId(m,p);for(let t=0;t{const a=t instanceof Fo?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function Zp(e,t){return t-e}Ii(qp,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Wp{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new hu({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=D(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const r=[];let i=e.length%2==1?-e[e.length-1]*n:0,o=e[0]*n,a=!0;r.push({left:i,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t1&&(a=e[++o]);const l=Math.abs(s-a.left),u=Math.abs(s-a.right),c=Math.min(l,u);let h;const d=t/n*(r+1);if(a.isDash){const e=r-Math.abs(d);h=Math.sqrt(c*c+e*e)}else h=r-Math.sqrt(c*c+d*d);this.image.data[i+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}const n=e[0],r=e[e.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);const i=this.width*this.nextRow;let o=0,a=e[o];for(let n=0;n1&&(a=e[++o]);const r=Math.abs(n-a.left),s=Math.abs(n-a.right),l=Math.min(r,s);this.image.data[i+n]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const r="round"===t,i=r?7:0,o=2*i+1;if(this.nextRow+o>this.height)return N("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&(Yp(e,this.zoom,n),(s[t.id]=t.createBucket({index:a.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(d,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(e.map(e=>e.id)))}}let h,d,f,p;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=F(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},(e,t)=>{h||(h=e,d=t,v.call(this))},void 0,!1,m):d={};const g=Object.keys(u.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,v.call(this))},void 0,!1,m):f={};const y=Object.keys(u.patternDependencies);function v(){if(h)return i(h);if(d&&f&&p){const e=new Xp(d),t=new $h(f,p);for(const r in s){const i=s[r];i instanceof Jf?(Yp(i.layers,this.zoom,n),Od(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof Kc||i instanceof Ju||i instanceof Sc)&&(Yp(i.layers,this.zoom,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",i(null,{buckets:A(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,v.call(this))},void 0,!1,m):p={},v.call(this)}}function Yp(e,t,n){const r=new Io(t);for(const t of e)t.recalculate(r,n)}class Kp{constructor(e){this.entries={},this.scheduler=e}request(e,t,n,r){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,n]=i.result;return this.scheduler?this.scheduler.add(()=>{r(e,n)},t):r(e,n),()=>{}}return i.callbacks.push(r),i.cancel||(i.cancel=n((n,r)=>{i.result=[n,r];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(n,r)},t):e(n,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==r),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}}function Jp(e,t,n){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const r=ce(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new gc(new yh(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}e.ARRAY_TYPE=hl,e.AUTH_ERR_MSG=_e,e.Aabb=tu,e.Actor=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.callbacks={},this.cancelCallbacks={},R(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=$()?e:n,this.scheduler=new hp}send(e,t,n,r,i=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[a]=n);const s=X(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:Oi(t,s)},s),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||$()){const e=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,t),e&&e.metadata||{type:"message"})}else this.processTask(n,t)}processTask(e,t){if(""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n(Di(t.error)):n(null,Di(t.data)))}else{const n=X(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Oi(t):null,data:Oi(r,n)},n)}:e=>{},i=Di(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source)[e[1]](i,r)}else r(new Error("Could not find function "+t.type))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Bc,e.Color=Ct,e.ColorMode=Bp,e.CullFaceMode=Fp,e.DEMData=Op,e.DataConstantProperty=jo,e.DedupedRequest=Kp,e.DepthMode=Lp,e.EXTENT=vs,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const n=t.getSource().maxzoom,r=1<1)return t;const i=r.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,i.x,i.y),a=r.upVector(e.canonical,i.x,i.y);return Ol(a,a,o*r.upVectorScale(e.canonical,t,n).metersToTile),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=Gp.create(this,e,r);return!!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,r=t.tileID,i=1<this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!ge(e))return e;const n=we(e);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!ge(e))return e;const n=we(e);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!ge(e))return e;const i=we(e);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),n&&i.params.push("language="+n),r&&i.params.push("worldview="+r),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,r){const i=we(e);return ge(e)?(i.path=`/styles/v1${i.path}/sprite${t}${n}`,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=`${t}${n}`,Te(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!ge(e))return e;const r=we(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||n&&"raster"!==r.authority&&512===n?"@2x":""}${a.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${o.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${o.TILE_URL_VERSION}${r.path}`);const i=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||o.ACCESS_TOKEN;return o.REQUIRE_ACCESS_TOKEN&&i&&this._skuToken&&r.params.push("sku="+this._skuToken),this._makeAPIURL(r,i)}canonicalizeTileURL(e,t){const n=we(e);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+="raster/"+n.path.replace(`/${o.RASTER_URL_PREFIX}/`,""):r+="tiles/"+n.path.replace(`/${o.TILE_URL_VERSION}/`,"");let i=n.params;return t&&(i=i.filter(e=>!e.match(/^access_token=/))),i.length&&(r+="?"+i.join("&")),r}canonicalizeTileset(e,t){const n=!!t&&ge(t),r=[];for(const t of e.tiles||[])ye(t)?r.push(this.canonicalizeTileURL(t,n)):r.push(t);return r}_makeAPIURL(e,t){const n="See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes",r=we(o.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!o.REQUIRE_ACCESS_TOKEN)return Te(e);if(t=t||o.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push("access_token="+(t||"")),Te(e)}},e.ResourceType=ae,e.SegmentVector=ys,e.SourceCache=jp,e.StencilMode=Rp,e.StructArrayLayout1ui2=xa,e.StructArrayLayout2f1f2i16=ca,e.StructArrayLayout2i4=Ko,e.StructArrayLayout2ui4=va,e.StructArrayLayout3f12=da,e.StructArrayLayout3ui6=fa,e.StructArrayLayout4i8=Qo,e.StructArrayLayout5f20=ga,e.Texture=up,e.Tile=wp,e.Transitionable=Oo,e.Uniform1f=Ha,e.Uniform1i=class extends Xa{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},e.Uniform2f=class extends Xa{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},e.Uniform3f=class extends Xa{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},e.Uniform4f=Ya,e.UniformColor=Ka,e.UniformMatrix2f=class extends Xa{constructor(e){super(e),this.current=es}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},e.UniformMatrix3f=class extends Xa{constructor(e){super(e),this.current=Qa}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.UniformMatrix4f=class extends Xa{constructor(e){super(e),this.current=Ja}set(e,t,n){if(this.fetchUniformLocation(e,t)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},e.UnwrappedTileID=Fc,e.ValidationError=qr,e.VectorTileFeature=yc,e.VectorTileWorkerSource=class extends He{constructor(e,t,n,r,i){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Jp,this.loading={},this.loaded={},this.deduped=new Kp(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new Hp(e);o.abort=this.loadVectorData(e,(a,s)=>{const l=!this.loading[n];if(delete this.loading[n],l||a||!s)return o.status="done",l||(this.loaded[n]=o),t(a);const u=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl),o.vectorTile=s.vectorTile||new gc(new yh(u));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,n)=>{if(e||!n)return t(e);const o={};if(i){const e=je(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,I({rawTileData:u.slice(0)},n,c,o))})};this.isSpriteLoaded?h():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()}),this.loaded=this.loaded||{},this.loaded[n]=o})}reloadTile(e,t){const n=this.loaded,r=e.uid,i=this;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=wf(e.tileID.canonical,e.projection);const a=(e,n)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,this.availableImages,i.actor,r)),t(e,n)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(e,t){const n=e.uid,r=this.loading[n];r&&(r.abort&&r.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}},e.WritingMode=Zh,e.ZoomHistory=Li,e.add=Ml,e.addDynamicAttributes=Xf,e.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},e.asyncAll=M,e.bezier=T,e.bindAll=R,e.boundsAttributes=xp,e.bufferConvexPolygon=function(e,t){const n=[];for(let r=0;rte&&(e.getActor().send("enforceCacheSizeLimit",ee),oe=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:n,y:r}=e.point,i=mf(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return _l(i,i,pf(tf(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return mf(t,n,e.worldSize,r,i)},e.calculateGlobeMercatorMatrix=function(e){const t=e.pixelsPerMeter,n=t/Cs(1,e.center.lat),r=pl(new Float64Array(16));return gl(r,r,[e.point.x,e.point.y,0]),yl(r,r,[n,n,t]),Float32Array.from(r)},e.circumferenceAtLatitude=Es,e.clamp=S,e.clearTileCache=function(e){if(!ne())return;const t=n.caches.delete(K);e&&t.catch(e).then(()=>e())},e.clipLine=fd,e.clone=function(e){var t=new hl(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=U,e.collisionCircleLayout=lh,e.config=o,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new hl(16);return hl!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=dl,e.createExpression=jr,e.createLayout=Ho,e.createStyleLayer=function(e){return"custom"===e.type?new op(e):new lp[e.type](e)},e.cross=Bl,e.degToRad=v,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},e.dot=Rl,e.earthRadius=bs,e.ease=E,e.easeCubicInOut=w,e.ecefToLatLng=function([e,t,n]){const r=Math.hypot(e,t,n),i=Math.atan2(e,n),o=.5*Math.PI-Math.acos(-t/r);return new ws(x(i),x(o))},e.emitValidationErrors=ki,e.endsWith=B,e.enforceCacheSizeLimit=function(e){re(),J&&J.then(t=>{t.keys().then(n=>{for(let r=0;ro&&(r+=(e[i]-o)*(e[i]-o)),t[i]0){const e=180/r;fl(f,f,[e/u+1,0,0,0,e/c+1,0,-.5*e/h,.5*e/d,1])}return f[2]=l,f[5]=e.x,f[8]=e.y,f},e.getImage=me,e.getJSON=function(e,t){return ue(I(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=80.051129;e=S(e,-80.051129,t)/t*90;const n=Math.pow(Math.abs(Math.sin(v(e))),3);return Math.round(n*(Xd.length-1))},e.getMapSessionAPI=Oe,e.getPerformanceMeasurement=je,e.getProjection=Gf,e.getRTLTextPluginStatus=Co,e.getReferrer=le,e.getTilePoint=function(e,{x:t,y:n},r=0){return new m(((t-r)*e.scale-e.x)*vs,(n*e.scale-e.y)*vs)},e.getTileVec3=function(e,t,n=0){return Cl(((t.x-n)*e.scale-e.x)*vs,(t.y*e.scale-e.y)*vs,Is(t.z,t.y))},e.getVideo=function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],n=pl(new Float64Array(16));return _l(n,e.pixelMatrix,e.globeMatrix),Fl(t,t,n),new m(t[0],t[1])},e.globeDenormalizeECEF=pf,e.globeECEFOrigin=function(e,t){const n=[0,0,0];return Fl(n,n,ff(tf(t.canonical))),Fl(n,n,e),n},e.globeNormalizeECEF=ff,e.globePixelsToTileUnits=function(e,t){return vs/(512*Math.pow(2,e))*hf(tf(t))},e.globePoleMatrixForTile=function(e,t,n){const r=pl(new Float64Array(16)),i=(t/(1<0;return 0===r&&!i&&!a&&o},e.identity=pl,e.identity$1=Xl,e.invert=ml,e.isFullscreen=function(){return!!n.document.fullscreenElement||!!n.document.webkitFullscreenElement},e.isLngLatBehindGlobe=function(e,t){return gf(e,t)>Math.PI/2*1.01},e.isMapAuthenticated=function(e){return De.has(e)},e.isMapboxURL=ge,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!X(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=As,e.latLngToECEF=uf,e.len=Gl,e.length=kl,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.lngFromMercatorX=Ms,e.loadVectorTile=Jp,e.makeRequest=ue,e.mapValue=function(e,t,n,r,i){return S((e-t)/(n-t)*(i-r)+r,r,i)},e.mercatorScale=Ps,e.mercatorXfromLng=Ss,e.mercatorYfromLat=ks,e.mercatorZfromAltitude=Cs,e.mul=Tl,e.mul$1=Nl,e.multiply=_l,e.multiply$1=fl,e.multiply$2=Il,e.nextPowerOfTwo=D,e.normalize=Ll,e.normalize$1=Kl,e.normalize$2=$l,e.number=Cn,e.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},e.pbf=yh,e.perspective=function(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+r)*(o=1/(r-i)),e[14]=2*i*r*o):(e[10]=-1,e[14]=-2*r),e},e.pick=function(e,t){const n={};for(let r=0;r.5?_-=1:_<-.5&&(_+=1);let y=0;Math.abs(_)>Math.abs(g)?y=_>=0?1:3:(y=g>=0?0:2,Dl(c,c,[i[4]*r,i[5]*r,i[6]*r],-Math.sin(v(g>=0?o.getSouth():o.getNorth()))*Zd));const x=a[y],b=a[(y+1)%4],w=new Qd(x,b,c),T=[ef(w,0)||x[0],ef(w,1)||x[1],ef(w,2)||x[2]],E=_f(e.zoom);if(E>0){const r=function({x:e,y:t,z:n},r,i,o,a){const s=1/(1<.5?d=-1:f<-.5&&(d=1),l=((l+d)*r-(o*=r))*i+o,u=((u+d)*r-o)*i+o,c=(c*r-(a*=r))*i+a,h=(h*r-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,t,e._pixelsPerMercatorPixel,p,m);for(let e=0;eSi(li(e)),e.validateFog=e=>Si(yi(e)),e.validateLayer=e=>Si(di(e)),e.validateLight=e=>Si(_i(e)),e.validateSource=e=>Si(mi(e)),e.validateStyle=wi,e.validateTerrain=e=>Si(gi(e)),e.values=A,e.vectorTile=oc,e.version=r,e.warnOnce=N,e.window=n,e.wrap=C})),i(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(const r of e)n+=t(r)+",";return n+"]"}let n="{";for(const r of Object.keys(e).sort())n+=`${r}:${t(e[r])},`;return n+"}"}function n(n){let r="";for(const i of e.refProperties)r+="/"+t(n[i]);return r}class r{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,r){for(const n of t)this._layerConfigs[n.id]=n,(this._layers[n.id]=e.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const r={};for(let i=0;ithis._layers[e.id]),n=t[0];if("none"===n.visibility)continue;const r=n.source||"";let i=this.familiesBySource[r];i||(i=this.familiesBySource[r]={});const o=n.sourceLayer||"_geojsonTileLayer";let a=i[o];a||(a=i[o]=[]),a.push(t)}}}class i{loadTile(t,n){const{uid:r,encoding:i,rawImageData:o,padding:a,buildQuadTree:s}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,a):o;n(null,new e.DEMData(r,l,i,a<1,s))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d")),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}var o=function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r=Math.abs(s)?n-l+s:s-l+n,n=l}n+r>=0!=!!t&&e.reverse()}const l=e.VectorTileFeature.prototype.toGeoJSON;class u{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const n of this._feature.geometry)t.push([new e.pointGeometry(n[0],n[1])]);return t}{const t=[];for(const n of this._feature.geometry){const r=[];for(const t of n)r.push(new e.pointGeometry(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,n){return l.call(this,e,t,n)}}class c{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new u(this._features[e])}}var h={exports:{}},d=e.pointGeometry,f=e.vectorTile.VectorTileFeature,p=m;function m(e,t){this.options=t||{},this.features=e,this.length=e.length}function _(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}m.prototype.feature=function(e){return new _(this.features[e],this.options.extent)},_.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t>31}function S(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;s>1;(function e(t,n,r,i,o,a){for(;o>i;){if(o-i>600){const s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);e(t,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}const s=n[2*r+a];let l=i,u=o;for(M(t,n,i,r),n[2*o+a]>s&&M(t,n,i,o);ls;)u--}n[2*i+a]===s?M(t,n,i,u):(u++,M(t,n,u,o)),u<=r&&(i=u+1),r<=u&&(o=u-1)}})(e,t,a,r,i,o%2),C(e,t,n,r,a-1,o+1),C(e,t,n,a+1,i,o+1)}function M(e,t,n,r){A(e,n,r),A(t,2*n,2*r),A(t,2*n+1,2*r+1)}function A(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function I(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}h.exports=v,h.exports.fromVectorTileJs=v,h.exports.fromGeojsonVt=function(e,t){t=t||{};var n={};for(var r in e)n[r]=new y(e[r].features,t),n[r].name=r,n[r].version=t.version,n[r].extent=t.extent;return v({layers:n})},h.exports.GeoJSONWrapper=y;const z=e=>e[0],P=e=>e[1];class O{constructor(e,t=z,n=P,r=64,i=Float64Array){this.nodeSize=r,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(e.length),s=this.coords=new i(2*e.length);for(let r=0;r=n&&u<=i&&c>=r&&c<=o&&l.push(e[a]);continue}const p=Math.floor((f+d)/2);u=t[2*p],c=t[2*p+1],u>=n&&u<=i&&c>=r&&c<=o&&l.push(e[p]);const m=(h+1)%2;(0===h?n<=u:r<=c)&&(s.push(f),s.push(p-1),s.push(m)),(0===h?i>=u:o>=c)&&(s.push(p+1),s.push(d),s.push(m))}return l}(this.ids,this.coords,e,t,n,r,this.nodeSize)}within(e,t,n){return function(e,t,n,r,i,o){const a=[0,e.length-1,0],s=[],l=i*i;for(;a.length;){const u=a.pop(),c=a.pop(),h=a.pop();if(c-h<=o){for(let i=h;i<=c;i++)I(t[2*i],t[2*i+1],n,r)<=l&&s.push(e[i]);continue}const d=Math.floor((h+c)/2),f=t[2*d],p=t[2*d+1];I(f,p,n,r)<=l&&s.push(e[d]);const m=(u+1)%2;(0===u?n-i<=f:r-i<=p)&&(a.push(h),a.push(d-1),a.push(m)),(0===u?n+i>=f:r+i>=p)&&(a.push(d+1),a.push(c),a.push(m))}return s}(this.ids,this.coords,e,t,n,this.nodeSize)}}const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(R=new Float32Array(1),e=>(R[0]=+e,R[0]));var R;class B{constructor(e){this.options=$(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:n,maxZoom:r,nodeSize:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let a=[];for(let t=0;t=n;e--){const n=+Date.now();a=this._cluster(a,e),this.trees[e]=new O(a,Z,W,i,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-n)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){const e=this.getClusters([n,r,180,o],t),a=this.getClusters([-180,r,i,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(N(n),G(o),N(i),G(r)),l=[];for(const e of s){const t=a.points[e];l.push(t.numPoints?U(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);const o=i.points[t];if(!o)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=i.within(o.x,o.y,a),l=[];for(const t of s){const n=i.points[t];n.parentId===e&&l.push(n.numPoints?U(n):this.points[n.index])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,n){const r=[];return this._appendLeaves(r,e,t=t||10,n=n||0,0),r}getTile(e,t,n){const r=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(n-s)/i,u=(n+1+s)/i,c={features:[]};return this._addTileFeatures(r.range((t-s)/i,l,(t+1+s)/i,u),r.points,t,n,i,c),0===t&&this._addTileFeatures(r.range(1-s/i,l,1,u),r.points,i,n,i,c),t===i-1&&this._addTileFeatures(r.range(0,l,s/i,u),r.points,-1,n,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?i+o.point_count<=r?i+=o.point_count:i=this._appendLeaves(e,o.cluster_id,n,r,i):it&&(h+=n.numPoints||1)}if(h>c&&h>=a){let e=i.x*c,a=i.y*c,s=o&&c>1?this._map(i,!0):null;const d=(r<<5)+(t+1)+this.points.length;for(const n of u){const r=l.points[n];if(r.zoom<=t)continue;r.zoom=t;const u=r.numPoints||1;e+=r.x*u,a+=r.y*u,r.parentId=d,o&&(s||(s=this._map(i,!0)),o(s,this._map(r)))}i.parentId=d,n.push(F(e/h,a/h,d,h,s))}else if(n.push(i),h>1)for(const e of u){const r=l.points[e];r.zoom<=t||(r.zoom=t,n.push(r))}}return n}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?$({},e.properties):e.properties;const n=this.points[e.index].properties,r=this.options.map(n);return t&&r===n?$({},r):r}}function F(e,t,n,r,i){return{x:L(e),y:L(t),zoom:1/0,id:n,parentId:-1,numPoints:r,properties:i}}function j(e,t){const[n,r]=e.geometry.coordinates;return{x:L(N(n)),y:L(G(r)),zoom:1/0,index:t,parentId:-1}}function U(e){return{type:"Feature",id:e.id,properties:V(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),q(e.y)]}};var t}function V(e){const t=e.numPoints,n=t>=1e4?Math.round(t/1e3)+"k":t>=1e3?Math.round(t/100)/10+"k":t;return $($({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:n})}function N(e){return e/360+.5}function G(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t){for(const n in t)e[n]=t[n];return e}function Z(e){return e.x}function W(e){return e.y}function X(e,t,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((e-n)*a+(t-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=e-n)*a+(s=t-r)*s}function H(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Y(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=t.length-3;t[2]=1,function e(t,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=t[n],c=t[n+1],h=t[r],d=t[r+1],f=n+3;fa)o=f,a=p;else if(p===a){var m=Math.abs(f-s);mi&&(o-n>3&&e(t,n,o,i),t[o+2]=a,r-o>3&&e(t,o,r,i))}(t,0,c,n),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function ee(e,t,n,r){for(var i=0;i1?1:n}function re(e,t,n,r,i,o,a,s){if(r/=t,o>=(n/=t)&&a=r)return null;for(var l=[],u=0;u=n&&p=r)){var m=[];if("Point"===d||"MultiPoint"===d)ie(h,m,n,r,i);else if("LineString"===d)oe(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===d)se(h,m,n,r,i,!1);else if("Polygon"===d)se(h,m,n,r,i,!0);else if("MultiPolygon"===d)for(var _=0;_=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,n,r,i,o,a){for(var s,l,u=ae(e),c=0===i?ue:ce,h=e.start,d=0;dn&&(l=c(u,f,p,_,g,n),a&&(u.start=h+s*l)):y>r?v=n&&(l=c(u,f,p,_,g,n),x=!0),v>r&&y<=r&&(l=c(u,f,p,_,g,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),t.push(u),u=ae(e)),a&&(h+=s)}var b=e.length-3;f=e[b],p=e[b+1],m=e[b+2],(y=0===i?f:p)>=n&&y<=r&&le(u,f,p,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&le(u,u[0],u[1],u[2]),u.length&&t.push(u)}function ae(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function se(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function _e(e,t,n,r){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&t.size<(i?a:r))n.numPoints+=t.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(t[l]),s.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,o=i-2;r0===t)for(r=0,i=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),d=this.tiles[h]=me(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<1&&console.time("clipping");var m,_,g,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,T=.5+b,E=1+b;m=_=g=y=null,v=re(e,c,n-b,n+T,0,d.minX,d.maxX,l),x=re(e,c,n+w,n+E,0,d.minX,d.maxX,l),e=null,v&&(m=re(v,c,r-b,r+T,1,d.minY,d.maxY,l),_=re(v,c,r+w,r+E,1,d.minY,d.maxY,l),v=null),x&&(g=re(x,c,r-b,r+T,1,d.minY,d.maxY,l),y=re(x,c,r+w,r+E,1,d.minY,d.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],t+1,2*n,2*r),s.push(_||[],t+1,2*n,2*r+1),s.push(g||[],t+1,2*n+1,2*r),s.push(y||[],t+1,2*n+1,2*r+1)}}},ye.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,o=r.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[ve(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?fe(this.tiles[s],i):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,n,r,i){super(e,t,n,r,xe),i&&(this.loadGeoJSON=i)}loadData(t,n){const r=t&&t.request,i=r&&r.collectResourceTiming;this.loadGeoJSON(t,(a,s)=>{if(a||!s)return n(a);if("object"!=typeof s)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{o(s,!0);try{if(t.filter){const n=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=s.features.filter(e=>n.value.evaluate({zoom:0},e));s={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new B(function({superclusterOptions:t,clusterProperties:n}){if(!n||!t)return t;const r={},i={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(n);for(const t of s){const[o,a]=n[t],s=e.createExpression(a),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=s.value,i[t]=l.value}return t.map=e=>{a.properties=e;const t={};for(const e of s)t[e]=r[e].evaluate(o,a);return t},t.reduce=(e,t)=>{a.properties=t;for(const t of s)o.accumulated=e[t],e[t]=i[t].evaluate(o,a)},t}(t)).load(s.features):function(e,t){return new ye(e,t)}(s,t.geojsonVtOptions)}catch(a){return n(a)}this.loaded={};const l={};if(i){const n=e.getPerformanceMeasurement(r);n&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(n)))}n(null,l)}})}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.getJSON(t.request,n);else{if("string"!=typeof t.data)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class we{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){this.isSpriteLoaded[t]=n;for(const r in this.workerSources[t]){const i=this.workerSources[t][r];for(const t in i)i[t]instanceof e.VectorTileWorkerSource&&(i[t].isSpriteLoaded=n,i[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,n){this.availableImages[e]=t;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e].availableImages=t}n()}enableTerrain(e,t,n){this.terrain=t,n()}setProjection(t,n){this.projections[t]=e.getProjection(n)}setLayers(e,t,n){this.getLayerIndex(e).replace(t),n()}updateLayers(e,t,n){this.getLayerIndex(e).update(t.layers,t.removedIds),n()}loadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).loadTile(i,r)}loadDEMTile(t,n,r){const i=this.enableTerrain?e.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(t,n.source).loadTile(i,r)}reloadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).reloadTile(i,r)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source).removeTile(t,n)}removeSource(e,t,n){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,r){try{e.plugin.setState(n);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const n=e.plugin.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new r),t}getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){const r={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][t][n]=new this.workerSourceTypes[t](r,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][n]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new i),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,n){e.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we})),i(0,(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r{e.window.removeEventListener("click",d,!0)},0)}function p(e,t){const n=e.getBoundingClientRect();return g(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:t.button}function g(t,n,r){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.pointGeometry((r.clientX-n.left)*i,(r.clientY-n.top)*i)}function y(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,n){let r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(const r of e){if(r[0]{this.ready=!0})}broadcast(t,n,r){e.asyncAll(this.actors,(e,r)=>{e.send(t,n,r)},r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}function O(t,n,r){return n*(e.EXTENT/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}P.Actor=e.Actor;class D{constructor(e,t,n,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,n){let r,i;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);r=[o],i=n.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),a=e.pointGeometry.convert(t[1]);r=[o,a],i=e.polygonizeBounds(o,a).every(e=>n.isPointAboveHorizon(e))}return new D(r,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=r.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.bufferConvexPolygon(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,t),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>r.y))+((o.x>n.x)+(o.x>r.x))){case 0:i[0]=o,i[4]=o.clone();break;case 1:i.splice(1,0,o);break;case 2:i[1]=o;break;case 3:i.splice(4,0,o);break;case 5:i.splice(2,0,o);break;case 6:i[3]=o;break;case 7:i.splice(3,0,o);break;case 8:i[2]=o}return i}containsTile(t,n,r,i=0){const o=t.queryPadding/n._pixelsPerMercatorPixel+1,a=r?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let s=t.tileID.wrap+(a.unwrapped?i:0);const l=a.polygon.map(n=>e.getTilePoint(t.tileTransform,n,s));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const u=this.screenGeometryMercator.polygon.map(n=>e.getTileVec3(t.tileTransform,n,s)),c=u.map(t=>new e.pointGeometry(t[0],t[1])),h=n.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),d=e.getTileVec3(t.tileTransform,h,s),f=u.map(t=>{const n=e.sub(t,t,d);return e.normalize(n,n),new e.Ray(d,n)}),p=O(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m}_bufferedScreenMercator(e,t){const n=B(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[n]=r,r}}_bufferedCameraMercator(e,t){const n=B(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[n]=r,r}}_projectAndResample(t,n){const r=function(t,n){const r=e.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(i,i,r),e.transformMat4$1(o,o,r),e.transformMat4$1(a,a,r);const s=new e.pointGeometry(i[0]/i[3],i[1]/i[3]),l=new e.pointGeometry(o[0]/o[3],o[1]/o[3]),u=e.polygonContainsPoint(t,s)&&i[3]1?L(t.slice(0,d),n):[],m=dnew e.pointGeometry(R(t.x),t.y)),m=m.map(t=>new e.pointGeometry(R(t.x),t.y));const _=[...p];0===_.length&&_.push(m[m.length-1]);const g=e.number(_[_.length-1].y,(0===m.length?p[0]:m[0]).y,f);let y;return y=u?[new e.pointGeometry(0,g),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,g)]:[new e.pointGeometry(1,g),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(p[0]):_.push(...m),{polygon:_.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:!1}}(t,n);if(r)return r;const i=function(t,n){let r=!1,i=-1/0,o=0;for(let e=0;ei&&(i=t[e].x,o=e);for(let e=0;e.5&&(i.x{e.x-=1}),{polygon:t,unwrapped:r}}(L(t,n).map(t=>new e.pointGeometry(R(t.x),t.y)),n);return{polygon:i.polygon.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:i.unwrapped}}}function L(t,n){return e.resample(t,e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function R(e){return e<0?1+e%1:e%1}function B(e){return 100*e|0}function F(t,n,r,i,o){const a=function(r,i){if(r)return o(r);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const r=e.pick(e.extend(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(r.vectorLayers=i.vector_layers,r.vectorLayerIds=r.vectorLayers.map(e=>e.id)),r.tiles=n.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.getJSON(n.transformRequest(n.normalizeSourceURL(t.url,null,r,i),e.ResourceType.Source),a):e.exported.frame(()=>a(null,t))}class j{constructor(t,n,r){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),r=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=r&&t.x=i&&t.y{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(e.extend(this,n),n.bounds&&(this.tileBounds=new j(n.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(n.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const r=e.exported.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),(r,i,o,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):r?(t.state="errored",n(r)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null)))}static loadTileData(e,t,n){e.setTexture(t,n)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let Me;function Ae(t,n,r,i,o,a,s,l){const u=[t,r,o,n,i,a,1,1,1],c=[s,l,1],h=e.adjoint([],u),[d,f,p]=e.transformMat3(c,c,e.transpose(h,h));return e.multiply$1(u,[d,0,0,0,f,0,0,0,p],u)}class Ie extends e.Evented{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(t,n){this._loaded=n||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),(n,r)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new e.ErrorEvent(n));else if(r){const{HTMLImageElement:n}=e.window;this.image=r instanceof n?e.exported.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._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}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const n=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let n=1/0,r=1/0,i=-1/0,o=-1/0;for(const e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),o=Math.max(o,e.y);const a=Math.max(i-n,o-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new e.CanonicalTileID(s,Math.floor((n+i)/2*l),Math.floor((r+o)/2*l))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const n=e.tileTransform(this.tileID,this.map.transform.projection),[r,i,o,a]=this.coordinates.map(t=>{const r=n.projection.project(t[0],t[1]);return e.getTilePoint(n,r)._round()});this.perspectiveTransform=function(t,n,r,i,o,a,s,l,u,c){const h=Ae(0,0,t,0,0,n,t,n),d=Ae(r,i,o,a,s,l,u,c);return e.multiply$1(d,e.adjoint(h,h),d),[d[6]/d[8]*t/e.EXTENT,d[7]/d[8]*n/e.EXTENT]}(this.width,this.height,r.x,r.y,i.x,i.y,a.x,a.y,o.x,o.y);const s=this._boundsArray=new e.StructArrayLayout4i8;s.emplaceBack(r.x,r.y,0,0),s.emplaceBack(i.x,i.y,e.EXTENT,0),s.emplaceBack(a.x,a.y,0,e.EXTENT),s.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(s,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,n=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const ze={vector:class extends e.Evented{constructor(t,n,r,i){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(n,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=F(this._options,this.map._requestManager,n,r,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+n),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+r),this.fire(new e.ErrorEvent(i))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new j(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()})}setSourceProperty(e){e(),this.reload()}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);else{const n=e.loadVectorTile.call({deduped:this._deduped},i,(e,n)=>{e||!n?o.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,o.bind(this),void 0,!0))},!0);t.request={cancel:n}}function o(r,i){return delete t.request,t.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}},raster:Ce,"raster-dem":class extends Ce{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,r){e&&(t.state="errored",n(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(r)t.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const n=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==Me&&(Me=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),Me),r=1-(o.width-e.prevPowerOfTwo(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=n?o:e.exported.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(t.resourceTiming=n.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,n){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(r,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(e,i)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===r),n(null))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ie{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.ResourceType.Source).url);e.getVideo(this.urls,(t,n)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(this.video=n,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError("sources."+this.id,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ie,canvas:class extends Ie{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const n=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new j(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:n,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const{x:r,y:i,z:o}=t.tileID.canonical,a=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete t.request,t.aborted?(t.state="unloaded",n(null)):void 0===r?(t.state="errored",n(null)):null===r?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",n(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(r)?(this.loadTileData(t,r),t.state="loaded",void n(null)):(t.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(e=>{20!==e.code&&(t.state="errored",n(e))}),t.request.cancel=()=>a.abort()}loadTileData(e,t){Ce.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ce.unloadTileData(e,this._map.painter)}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:n,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:n,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},Pe=function(t,n,r,i){const o=new ze[n.type](t,n,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function Oe(t,n){const r=e.identity([]);return e.scale(r,r,[.5*t.width,.5*-t.height,1]),e.translate(r,r,[1,-1,0]),e.multiply(r,r,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(r)}function De(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Re);const u=[];for(const r of l)u.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e._state,r,i,o,Oe(e.transform,r.tile.tileID),s)});const c=function(e){const t={},n={};for(const r of e){const e=r.queryResults,i=r.wrappedTileID,o=n[i]=n[i]||{};for(const n in e){const r=e[n],i=o[n]=o[n]||{},a=t[n]=t[n]||[];for(const e of r)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(u);for(const t in c)c[t].forEach(t=>{const n=t.feature,r=n.layer;r&&"background"!==r.type&&"sky"!==r.type&&(n.source=r.source,r["source-layer"]&&(n.sourceLayer=r["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(r["source-layer"],n.id):{})});return c}function Le(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let Ue;function Ve(){return Ue||(Ue=new je),Ue}function Ne(t,n){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.refProperties.forEach(e=>{e in n&&(r[e]=n[e])}),r}function Ge(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class Qe{constructor(e,t,n){const r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;ethis.width||r<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,r,i){const o=e-n,a=e+n,s=t-n,l=t+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u}query(e,t,n,r,i){return this._query(e,t,n,r,!1,i)}hitTest(e,t,n,r,i){return this._query(e,t,n,r,!0,i)}hitTestCircle(e,t,n,r){return this._queryCircle(e,t,n,!0,r)}_queryCell(e,t,n,r,i,o,a,s){const l=a.seenUids,u=this.boxCells[i];if(null!==u){const i=this.bboxes;for(const c of u)if(!l.box[c]){l.box[c]=!0;const u=4*c;if(e<=i[u+2]&&t<=i[u+3]&&n>=i[u+0]&&r>=i[u+1]&&(!s||s(this.boxKeys[c]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[c],x1:i[u],y1:i[u+1],x2:i[u+2],y2:i[u+3]})}}}const c=this.circleCells[i];if(null!==c){const i=this.circles;for(const u of c)if(!l.circle[u]){l.circle[u]=!0;const c=3*u;if(this._circleAndRectCollide(i[c],i[c+1],i[c+2],e,t,n,r)&&(!s||s(this.circleKeys[u]))){if(a.hitTest)return o.push(!0),!0;{const e=i[c],t=i[c+1],n=i[c+2];o.push({key:this.circleKeys[u],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,r,i,o,a,s){const l=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c){const e=this.bboxes;for(const t of c)if(!u.box[t]){u.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!u.circle[t]){u.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,n,r,i,o,a,s){const l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r);for(let d=l;d<=c;d++)for(let l=u;l<=h;l++)if(i.call(this,e,t,n,r,this.xCellCount*l+d,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,o){const a=r-e,s=i-t,l=n+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,n,r,i,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+n)return!1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;const h=l-s,d=c-u;return h*h+d*d<=n*n}}const et=Math.tan(85*Math.PI/180);function tt(t,n,r,i,o,a,s){const l=e.create();if(r)if("globe"===a.name){const t=e.calculateGlobeLabelMatrix(o,n);e.multiply(l,l,t)}else{const t=y([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],i||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function nt(e,t,n,r,i,o,a){const s=tt(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function rt(t,n,r,i,o,a,s){if(r){if("globe"===a.name){const l=tt(t,n,r,i,o,a,s);return e.invert(l,l),e.multiply(l,t,l),l}{const n=e.clone(t),r=e.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.multiply(n,n,r),i||e.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function it(t,n,r=0){const i=[t.x,t.y,r,1];r?e.transformMat4$1(i,i,n):gt(i,i,n);const o=i[3];return{point:[i[0]/o,i[1]/o,i[2]/o],signedDistanceFromCamera:o}}function ot(t,n){const r=[t[0],t[1],t[2],1];e.transformMat4$1(r,r,n);const i=r[3];return{point:[r[0]/i,r[1]/i,r[2]/i],signedDistanceFromCamera:i}}function at(e,t){return Math.min(.5+e/t*.5,1.5)}function st(e,t){const n=e[0]/e[3],r=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&r>=-t[1]&&r<=t[1]}function lt(t,n,r,i,o,a,s,l,u,c){const h=r.transform,d=i?t.textSizeData:t.iconSizeData,f=e.evaluateSizeForZoom(d,r.transform.zoom),p="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;p&&(g=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b=!1;for(let i=0;iMath.abs(r.x-n.x)*i?{useVertical:!0}:t.writingMode===e.WritingMode.vertical?n.yet}(n,r,i)?1===t.flipState?{needsFlipping:!0}:null:n.x>r.x?{needsFlipping:!0}:null}function ht(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v){const x=n/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x;let T=[];if(t.numGlyphs>1){const n=t.glyphStartIndex+t.numGlyphs,o=t.lineStartIndex,c=t.lineStartIndex+t.lineLength,h=ut(x,l,b,w,r,d,f,t,u,a,p,_,!1,g,y,v);if(!h)return{notEnoughRoom:!0};const E=ot(h.first.point,s).point,S=ot(h.last.point,s).point,k=new e.pointGeometry(E[0],E[1]),C=new e.pointGeometry(S[0],S[1]);if(i&&!r){const e=ct(t,k,C,m);if(t.flipState=e&&e.needsFlipping?1:2,e)return e}T=[h.first];for(let e=t.glyphStartIndex+1;e0?a.point:ft(f,i,n,1,o,void 0,g,y.canonical),l=ct(t,new e.pointGeometry(n[0],n[1]),new e.pointGeometry(s[0],s[1]),m);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const n=pt(x*l.getoffsetX(t.glyphStartIndex),b,w,r,d,f,t.segment,t.lineStartIndex,t.lineStartIndex+t.lineLength,u,a,p,_,!1,!1,g,y,v);if(!n)return{notEnoughRoom:!0};T=[n]}if(h)for(const t of T)e.updateGlobeVertexNormal(h,c.length+0,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,c.length+1,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,c.length+2,t.up[0],t.up[1],t.up[2]),e.updateGlobeVertexNormal(h,c.length+3,t.up[0],t.up[1],t.up[2]),e.addDynamicAttributes(c,t.point[0],t.point[1],t.point[2],t.angle);else for(const t of T)e.addDynamicAttributes(c,t.point[0],t.point[1],t.point[2],t.angle);return{}}function dt(t,n,r,i,o){const a=i.projectTilePoint(t.x,t.y,n);if(!o)return it(a,r,a.z);const s=o(t);return it(new e.pointGeometry(a.x+s[0],a.y+s[1]),r,a.z+s[2])}function ft(t,n,r,i,o,a,s,l){const u=dt(t.add(t.sub(n)._unit()),l,o,s,a).point,c=e.sub([],r,u);return e.scaleAndAdd([],r,c,i/e.length(c))}function pt(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const v=i?t-n:t+n;let x=v>0?1:-1,b=0;i&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=x>0?l+s:l+s+1,T=o,E=o,S=0,k=0;const C=Math.abs(v),M=[],A=[];let I=a;const z=()=>{const t=w-x;return 0===S?a:new e.pointGeometry(c.getx(t),c.gety(t))},P=()=>{const e=z();return ft(e,I||e,E,C-S+1,h,f,_,g.canonical)};for(;S+k<=C;){if(w+=x,w=u)return null;if(E=T,M.push(T),p&&A.push(I||z()),T=d[w],void 0===T){I=new e.pointGeometry(c.getx(w),c.gety(w));const t=dt(I,g.canonical,h,_,f);T=t.signedDistanceFromCamera>0?d[w]=t.point:P()}else I=null;S+=k,k=e.distance(E,T)}I=I||new e.pointGeometry(c.getx(w),c.gety(w));const O=z();m&&f&&(d[w]=T=void 0===d[w]?T:P(),k=e.distance(E,T));const D=(C-S)/k,L=I.sub(O).mult(D)._add(O),R=e.sub([],T,E),B=e.scaleAndAdd([],E,R,D);let F=[0,0,1],j=R[0],U=R[1];if(y&&(F=_.upVector(g.canonical,L.x,L.y),0!==F[0]||0!==F[1]||1!==F[2])){const t=[1,0,0],n=[0,1,0];t[0]=F[2],t[1]=0,t[2]=-F[0],e.cross(n,F,t),e.normalize(t,t),e.normalize(n,n),j=e.dot(R,t),U=e.dot(R,n)}if(r){const t=e.cross([],F,R);e.normalize(t,t),e.scaleAndAdd(B,B,t,r*x)}const V=b+Math.atan2(U,j);return M.push(B),p&&A.push(L),{point:B,angle:V,path:M,tilePath:A,up:F}}const mt=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function _t(e,t){for(let n=0;n0,e.getProjection()),p=o*f.perspectiveRatio,m=(n.x1*t+r.x-n.padding)*p+f.point.x,_=(n.y1*t+r.y-n.padding)*p+f.point.y,g=(n.x2*t+r.x+n.padding)*p+f.point.x,y=(n.y2*t+r.y+n.padding)*p+f.point.y,v=f.perspectiveRatio<=.55||f.occluded;return!this.isInsideGrid(m,_,g,y)||!i&&this.grid.hitTest(m,_,g,y,s)||v?{box:[],offscreen:!1,occluded:f.occluded}:{box:[m,_,g,y],offscreen:this.isOffscreen(m,_,g,y),occluded:!1}}placeCollisionCircles(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=[],g=this.transform.elevation,y=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,t.getProjection()):e=>[0,0,0],v=new e.pointGeometry(r.tileAnchorX,r.tileAnchorY),x=t.getProjection().projectTilePoint(r.tileAnchorX,r.tileAnchorY,m.canonical),b=y(v),w=[x.x+b[0],x.y+b[1],x.z+b[2]],T="globe"===t.projection.name,E=this.projectAndGetPerspectiveRatio(s,[w[0],w[1],w[2]],m,T||!!g||this.transform.pitch>0,t.getProjection()),{perspectiveRatio:S}=E,k=(h?a/S:a*S)/e.ONE_EM,C=it(new e.pointGeometry(w[0],w[1]),l,w[2]).point,M=E.signedDistanceFromCamera>0?ut(k,o,r.lineOffsetX*k,r.lineOffsetY*k,!1,C,v,r,i,l,{},g&&!h?y:null,h&&!!g,t.getProjection(),m,h):null;let A=!1,I=!1,z=!0;if(M&&!E.occluded){const t=.5*f*S+p,r=new e.pointGeometry(-100,-100),i=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Je,a=M.first,s=M.last;let l=[];for(let e=a.path.length-1;e>=1;e--)l.push(a.path[e]);for(let e=1;e{const n=y(tot(e,u));l=e.some(e=>e.signedDistanceFromCamera<=0)?[]:e.map(e=>e.point)}let m=[];if(l.length>0){const t=l.map(t=>new e.pointGeometry(t[0],t[1]));let n=1/0,o=-1/0,a=1/0,s=-1/0;for(let e=0;e=r.x&&o<=i.x&&a>=r.y&&s<=i.y?[t]:oi.x||si.y?[]:e.clipLine([t],r.x,r.y,i.x,i.y)}for(const e of m){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/h)+1;for(let e=0;e0){e.transformMat4$1(a,a,t);const i="globe"===o.name;this.fogState&&r&&!i&&(s=function(t,n,r,i,o,a){const s=a.calculateFogTileMatrix(o),l=[n,r,i];return e.transformMat4(l,l,s),C(t,l,a.pitch,a._fov)}(this.fogState,n[0],n[1],n[2],r.toUnwrapped(),this.transform)>.9)}else gt(a,a,t);return{point:new e.pointGeometry((a[0]/a[3]+1)/2*this.transform.width+yt,(-a[1]/a[3]+1)/2*this.transform.height+yt),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(o)/a[3]*.5,1.5),signedDistanceFromCamera:a[3],occluded:i&&a[2]>a[3]||s}}isOffscreen(e,t,n,r){return n=this.screenRightBoundary||rthis.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function At(t,n,r,i,o){const{horizontalAlign:a,verticalAlign:s}=e.getAnchorAlignment(t),l=-(a-.5)*n,u=-(s-.5)*r,c=e.evaluateVariableOffset(t,i);return new e.pointGeometry(l+c[0]*o,u+c[1]*o)}function It(t,n,r,i,o){const a=new e.pointGeometry(t,n);return r&&a._rotate(i?o:-o),a}class zt{constructor(e,t,n,r,i){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new vt(this.transform,i),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new Mt(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,r,i){const o=r.getBucket(n),a=r.latestFeatureIndex;if(!o||!a||n.id!==o.layerIds[0])return;const s=o.layers[0].layout,l=r.collisionBoxArray,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/e.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(f=r.tileID,p=o.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(f.toUnwrapped()):xt(m,p,f));var f,p,m;const _="map"===s.get("text-pitch-alignment"),g="map"===s.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=nt(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);let w=null;if(_){const t=rt(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let T=null;y&&r.latestFeatureIndex&&(T={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new Ct(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const E={bucket:o,layout:s,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:T,scale:u,textPixelRatio:c,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(const e of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:E})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:E})}attemptAnchorPlacement(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const y=[h.textOffset0,h.textOffset1],v=At(e,n,r,y,i),x=this.collisionIndex.placeCollisionBox(f,i,t,It(v.x,v.y,o,a,this.transform.angle),c,s,l,u.predicate);if(m){const e=f.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(f,e,m,It(v.x,v.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(x.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID]&&this.prevPlacement.placements[h.crossTileID].text&&(t=this.prevPlacement.variableOffsets[h.crossTileID].anchor),this.variableOffsets[h.crossTileID]={textOffset:y,width:n,height:r,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(f,e,h,p),f.allowVerticalPlacement&&(this.markUsedOrientation(f,p,h),this.placedOrientations[h.crossTileID]=p),{shift:v,placedGlyphBoxes:x}}}placeLayerBucketPart(t,n,r,i){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:u,clippingData:c,textPixelRatio:h,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=a.get("text-optional"),y=a.get("icon-optional"),v=a.get("text-allow-overlap"),x=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),T="none"!==a.get("icon-text-fit"),E="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),k=x&&(v||!o.hasTextData()||g);!o.collisionArrays&&f&&o.deserializeCollisionBoxes(f),r&&i&&o.updateCollisionDebugBuffers(this.transform.zoom,f);const C=(t,i,f)=>{if(c){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(c.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];i=c.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,c.dynamicFilter)(r,i,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[t.crossTileID]=new St(!1,!1,!1,!0),void(n[t.crossTileID]=!0)}if(n[t.crossTileID])return;if(d)return void(this.placements[t.crossTileID]=new St(!1,!1,!1));let E=!1,C=!1,M=!0,A=!1,I=!1,z=null,P={box:null,offscreen:null,occluded:null},O={box:null,offscreen:null,occluded:null},D=null,L=null,R=null,B=0,F=0,j=0;f.textFeatureIndex?B=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(B=t.featureIndex),f.verticalTextFeatureIndex&&(F=f.verticalTextFeatureIndex);const U=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID,(this.transform.elevation||e.elevation)&&(e.elevation=this.transform.elevation?this.transform.elevation.getAtTileOffset(this.retainedQueryData[o.bucketInstanceId].tileID,e.tileAnchorX,e.tileAnchorY):0)},V=f.textBox;if(V){U(V);const n=n=>{let r=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[t.crossTileID];e&&(this.placedOrientations[t.crossTileID]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(n,r)=>{if(o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&f.verticalTextBox){for(const t of o.writingModes)if(t===e.WritingMode.vertical?(P=r(),O=P):P=n(),P&&P.box&&P.box.length)break}else P=n()};if(a.get("text-variable-anchor")){let l=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[t.crossTileID]){const e=this.prevPlacement.variableOffsets[t.crossTileID];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor))}const u=(e,n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),u=(e.x2-e.x1)*a+2*e.padding,c=(e.y2-e.y1)*a+2*e.padding,d=T&&!x?n:null;d&&U(d);let f={box:[],offscreen:!1,occluded:!1};const g=v?2*l.length:l.length;for(let n=0;n=l.length,t,i,o,r,d,p,m);if(g&&(f=g.placedGlyphBoxes,f&&f.box&&f.box.length)){E=!0,z=g.shift;break}}return f};r(()=>u(V,f.iconBox,e.WritingMode.horizontal),()=>{const n=f.verticalTextBox;return n&&U(n),o.allowVerticalPlacement&&!(P&&P.box&&P.box.length)&&t.numVerticalGlyphVertices>0&&n?u(n,f.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),P&&(E=P.box,M=P.offscreen,A=P.occluded);const c=n(P&&P.box);if(!E&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[t.crossTileID];e&&(this.variableOffsets[t.crossTileID]=e,this.markUsedJustification(o,e.anchor,t,c))}}else{const a=(n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),l=this.collisionIndex.placeCollisionBox(o,a,n,new e.pointGeometry(0,0),v,h,s,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[t.crossTileID]=r),l};r(()=>a(V,e.WritingMode.horizontal),()=>{const n=f.verticalTextBox;return o.allowVerticalPlacement&&t.numVerticalGlyphVertices>0&&n?(U(n),a(n,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),n(P&&P.box&&P.box.length)}}if(D=P,E=D&&D.box&&D.box.length>0,M=D&&D.offscreen,A=D&&D.occluded,t.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.evaluateSizeForFeature(o.textSizeData,p,n),c=a.get("text-padding");L=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,i,s,l,u,r,w,_.predicate,t.collisionCircleDiameter*i/e.ONE_EM,c,this.retainedQueryData[o.bucketInstanceId].tileID),E=v||L.circles.length>0&&!L.collisionDetected,M=M&&L.offscreen,A=L.occluded}if(f.iconFeatureIndex&&(j=f.iconFeatureIndex),f.iconBox){const n=n=>{U(n);const r=T&&z?It(z.x,z.y,b,w,this.transform.angle):new e.pointGeometry(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,i,n,r,x,h,s,_.predicate)};O&&O.box&&O.box.length&&f.verticalIconBox?(R=n(f.verticalIconBox),C=R.box.length>0):(R=n(f.iconBox),C=R.box.length>0),M=M&&R.offscreen,I=R.occluded}const N=g||0===t.numHorizontalGlyphVertices&&0===t.numVerticalGlyphVertices,G=y||0===t.numIconVertices;if(N||G?G?N||(C=C&&E):E=C&&E:C=E=C&&E,E&&D&&D.box&&this.collisionIndex.insertCollisionBox(D.box,a.get("text-ignore-placement"),o.bucketInstanceId,O&&O.box&&F?F:B,_.ID),C&&R&&this.collisionIndex.insertCollisionBox(R.box,a.get("icon-ignore-placement"),o.bucketInstanceId,j,_.ID),L&&(E&&this.collisionIndex.insertCollisionCircles(L.circles,a.get("text-ignore-placement"),o.bucketInstanceId,B,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new kt);for(let e=0;e=0;--t){const n=e[t];C(o.symbolInstances.get(n),n,o.collisionArrays[n])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(e).crossTileID=o>=0&&e!==o?0:r.crossTileID)}markUsedOrientation(t,n,r){const i=n===e.WritingMode.horizontal||n===e.WritingMode.horizontalOnly?n:0,o=n===e.WritingMode.vertical?n:0,a=[r.leftJustifiedTextSymbolIndex,r.centerJustifiedTextSymbolIndex,r.rightJustifiedTextSymbolIndex].filter(e=>-1!==e);for(const e of a)t.text.placedSymbolArray.get(e).placedOrientation=i;-1!==r.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(r.verticalPlacedTextSymbolIndex).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=i[e];o?(this.opacities[e]=new Et(o,r,t.text,t.icon,null,t.clipped),n=n||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new Et(null,r,t.text,t.icon,t.skipFade,t.clipped),n=n||t.text||t.icon)}for(const e in i){const t=i[e];if(!this.opacities[e]){const i=new Et(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n=n||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n,r.collisionBoxArray)}}updateBucketOpacities(t,n,r){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const i=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),a=new Et(null,0,!1,!1,!0),s=i.get("text-allow-overlap"),l=i.get("icon-allow-overlap"),u=i.get("text-variable-anchor"),c="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),d="none"!==i.get("icon-text-fit"),f=new Et(null,0,s&&(l||!t.hasIconData()||i.get("icon-optional")),l&&(s||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const p=(e,t,n)=>{for(let r=0;r0||l>0,v=i.numIconVertices>0,x=this.placedOrientations[i.crossTileID],b=x===e.WritingMode.vertical,w=x===e.WritingMode.horizontal||x===e.WritingMode.horizontalOnly;if(!y&&!v||g.isHidden()||m++,y){const e=Ut(g.text);p(t.text,s,b?Vt:e),p(t.text,l,w?Vt:e);const n=g.text.isHidden();[i.rightJustifiedTextSymbolIndex,i.centerJustifiedTextSymbolIndex,i.leftJustifiedTextSymbolIndex].forEach(e=>{e>=0&&(t.text.placedSymbolArray.get(e).hidden=n||b?1:0)}),i.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(i.verticalPlacedTextSymbolIndex).hidden=n||w?1:0);const r=this.variableOffsets[i.crossTileID];r&&this.markUsedJustification(t,r.anchor,i,x);const o=this.placedOrientations[i.crossTileID];o&&(this.markUsedJustification(t,"left",i,o),this.markUsedOrientation(t,o,i))}if(v){const e=Ut(g.icon);i.placedIconSymbolIndex>=0&&(p(t.icon,i.numIconVertices,b?Vt:e),t.icon.placedSymbolArray.get(i.placedIconSymbolIndex).hidden=g.icon.isHidden()),i.verticalPlacedIconSymbolIndex>=0&&(p(t.icon,i.numVerticalIconVertices,w?Vt:e),t.icon.placedSymbolArray.get(i.verticalPlacedIconSymbolIndex).hidden=g.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.pointGeometry(0,0),i=!0;if(n.textBox||n.verticalTextBox){if(u){const e=this.variableOffsets[_];e?(r=At(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):i=!1}o&&(i=!g.clipped),n.textBox&&Pt(t.textCollisionBox.collisionVertexArray,g.text.placed,!i||b,r.x,r.y),n.verticalTextBox&&Pt(t.textCollisionBox.collisionVertexArray,g.text.placed,!i||w,r.x,r.y)}const a=i&&Boolean(!w&&n.verticalIconBox);n.iconBox&&Pt(t.iconCollisionBox.collisionVertexArray,g.icon.placed,a,d?r.x:0,d?r.y:0),n.verticalIconBox&&Pt(t.iconCollisionBox.collisionVertexArray,g.icon.placed,!a,d?r.x:0,d?r.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function Pt(e,t,n,r,i){e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0)}const Ot=Math.pow(2,25),Dt=Math.pow(2,24),Lt=Math.pow(2,17),Rt=Math.pow(2,16),Bt=Math.pow(2,9),Ft=Math.pow(2,8),jt=Math.pow(2,1);function Ut(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*Ot+t*Dt+n*Lt+t*Rt+n*Bt+t*Ft+n*jt+t}const Vt=0;class Nt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.exported.now()-i;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=n[t[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=i)&&(!e.maxzoom||e.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new Nt(e)),this._inProgressLayer.continuePlacement(r[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const qt=512/e.EXTENT/2;class $t{constructor(e,t,n){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let n=0;ne.overscaledZ)for(const n in i){const o=i[n];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=i[e.scaledTo(Number(n)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Ht=(t,n)=>e.emitValidationErrors(t,n&&n.filter(e=>"source.canvas"!==e.identifier)),Yt=e.pick(qe,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Kt=e.pick(qe,["setCenter","setZoom","setBearing","setPitch"]),Jt={version:8,layers:[],sources:{}},Qt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class en extends e.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new P(Ve(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,n.localFontFamily?e.LocalGlyphMode.all:n.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new Xt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this.zoomHistory=new e.ZoomHistory,this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const r=this;this._rtlTextPluginCallback=en.registerForPluginStateChange(t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,n)=>{if(e.triggerPluginCompletionEvent(t),n&&n.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const n=this._layers[e];n.source===t.id&&this._validateLayer(n)}})}loadURL(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof n.validate?n.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,n.accessToken);const i=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(i,(t,n)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):n&&this._load(n,r)})}loadJSON(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame(()=>{this._request=null,this._load(t,!1!==n.validate)})}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Jt,!1)}_updateLayerCount(e,t){const n=t?1:-1;e.is3D()&&(this._num3DLayers+=n),"circle"===e.type&&(this._numCircleLayers+=n),"symbol"===e.type&&(this._numSymbolLayers+=n)}_load(t,n){if(n&&Ht(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const r=Ge(this.stylesheet.layers);this._order=r.map(e=>e.id),this._layers={},this._serializedLayers={};for(let t of r)t=e.createStyleLayer(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new T(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(t){this._spriteRequest=function(t,n,r){let i,o,a;const s=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(n.transformRequest(n.normalizeSpriteURL(t,s,".json"),e.ResourceType.SpriteJSON),(e,t)=>{l=null,a||(a=e,i=t,c())}),u=e.getImage(n.transformRequest(n.normalizeSpriteURL(t,s,".png"),e.ResourceType.SpriteImage),(e,t)=>{u=null,a||(a=e,o=t,c())});function c(){if(a)r(a);else if(i&&o){const t=e.exported.getImageData(o),n={};for(const r in i){const{width:o,height:a,x:s,y:l,sdf:u,pixelRatio:c,stretchX:h,stretchY:d,content:f}=i[r],p=new e.RGBAImage({width:o,height:a});e.RGBAImage.copy(t,p,{x:s,y:l},{x:0,y:0},{width:o,height:a}),n[r]={data:p,pixelRatio:c,sdf:u,stretchX:h,stretchY:d,content:f}}r(null,n)}}return{cancel(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(t,this.map._requestManager,(t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(n)for(const e in n)this.imageManager.addImage(e,n[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))})}_validateLayer(t){const n=this.getSource(t.source);if(!n)return;const r=t.sourceLayer;r&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Qt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(e.length||n.length)&&this._updateWorkerLayers(e,n);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const r={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];r[e]=t.used,t.used=!1}for(const e of this._order){const n=this._layers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this._getLayerSourceCache(n);e&&(e.used=!0)}const r=this.map.painter;if(r){const e=n.getProgramIds();if(!e)continue;const i=n.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,i)}}for(const t in r){const n=this._sourceCaches[t];r[t]!==n.used&&n.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),Ht(this,e.validateStyle(n)))return!1;(n=e.clone$1(n)).layers=Ge(n.layers);const r=function(e,n){if(!e)return[{command:qe.setStyle,args:[n]}];let r=[];try{if(!t(e.version,n.version))return[{command:qe.setStyle,args:[n]}];t(e.center,n.center)||r.push({command:qe.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||r.push({command:qe.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||r.push({command:qe.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||r.push({command:qe.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||r.push({command:qe.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||r.push({command:qe.setGlyphs,args:[n.glyphs]}),t(e.transition,n.transition)||r.push({command:qe.setTransition,args:[n.transition]}),t(e.light,n.light)||r.push({command:qe.setLight,args:[n.light]}),t(e.fog,n.fog)||r.push({command:qe.setFog,args:[n.fog]}),t(e.projection,n.projection)||r.push({command:qe.setProjection,args:[n.projection]});const i={},o=[];!function(e,n,r,i){let o;for(o in n=n||{},e=e||{})e.hasOwnProperty(o)&&(n.hasOwnProperty(o)||Ze(o,r,i));for(o in n)n.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t(e[o],n[o])||("geojson"===e[o].type&&"geojson"===n[o].type&&Xe(e,n,o)?r.push({command:qe.setGeoJSONSourceData,args:[o,n[o].data]}):We(o,n,r,i)):$e(o,n,r))}(e.sources,n.sources,o,i);const a=[];e.layers&&e.layers.forEach(e=>{e.source&&i[e.source]?r.push({command:qe.removeLayer,args:[e.id]}):a.push(e)});let s=e.terrain;s&&i[s.source]&&(r.push({command:qe.setTerrain,args:[void 0]}),s=void 0),r=r.concat(o),t(s,n.terrain)||r.push({command:qe.setTerrain,args:[n.terrain]}),function(e,n,r){n=n||[];const i=(e=e||[]).map(Ye),o=n.map(Ye),a=e.reduce(Ke,{}),s=n.reduce(Ke,{}),l=i.slice(),u=Object.create(null);let c,h,d,f,p,m,_;for(c=0,h=0;c!(e.command in Kt));if(0===r.length)return!1;const i=r.filter(e=>!(e.command in Yt));if(i.length>0)throw new Error(`Unimplemented: ${i.map(e=>e.command).join(", ")}.`);return r.forEach(e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=n,this._updateMapProjection(),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,n,r={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(e.validateSource,"sources."+t,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=Pe(t,n,this.dispatcher,this);i.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:i.serialize(),sourceId:t}));const o=n=>{const r=(n?"symbol:":"other:")+t,o=this._sourceCaches[r]=new e.SourceCache(r,i,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),i.onAdd&&i.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const n=this.getSource(t);if(!n)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(t);for(const t of r)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}_getSources(){const e=[];for(const t in this._otherSourceCaches){const n=this._getSourceCache(t);n&&e.push(n.getSource())}return e}addLayer(t,n,r={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" already exists on this map`)));let o;if("custom"===t.type){if(Ht(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})),this._validate(e.validateLayer,"layers."+i,t,{arrayIndex:-1},r))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o;const s=this._getLayerSourceCache(o);if(this._removedLayers[i]&&o.source&&s&&"custom"!==o.type){const e=this._removedLayers[i];delete this._removedLayers[i],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",s.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const r=this._order.indexOf(t);this._order.splice(r,1);const i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,n,r){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,r,i={}){this._checkLoaded();const o=this.getLayer(n);if(o){if(!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,r,{layerType:o.type},i)||(o.filter=e.clone$1(r),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const n=this.getLayer(t);return n&&e.clone$1(n.filter)}setLayoutProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getLayoutProperty(r),i)||(a.setLayoutProperty(r,i,o),this._updateLayer(a)):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,n){const r=this.getLayer(t);if(r)return r.getLayoutProperty(n);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getPaintProperty(r),i)||(a.setPaintProperty(r,i,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const n=this.getLayer(e);return n&&n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const r=t.source,i=t.sourceLayer,o=this.getSource(r);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.type;if("geojson"===a&&i)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this._getSourceCaches(r);for(const e of s)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const r=t.source,i=this.getSource(r);if(!i)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=i.type,a="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!a)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this._getSourceCaches(r);for(const e of s)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,r=t.sourceLayer,i=this.getSource(n);if(i){if("vector"!==i.type||r)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(r,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const n=this._sourceCaches[e].getSource();t[n.id]||(t[n.id]=n.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:t,layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,n={},r=[];for(let i=this._order.length-1;i>=0;i--){const o=this._order[i];if(t(o)){n[o]=i;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const i=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(n[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=D.createFromScreenPoints(t,r);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;n.layers&&!i[t]||o.push(De(this._sourceCaches[e],this._layers,this._serializedLayers,s,n,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,n,r,i,o,a){const s={},l=o.queryRenderedSymbols(r),u=[];for(const e of Object.keys(l).map(Number))u.push(a[e]);u.sort(Re);for(const n of u){const r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],i=r[e];i.sort((e,t)=>{const r=n.featureSortOrder;if(r){const n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex});for(const e of i)t.push(e)}}for(const t in s)s[t].forEach(r=>{const i=r.feature,o=n(e[t]).getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o});return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),s.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,n){n&&n.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const r=this._getSourceCaches(t);let i=[];for(const e of r)i=i.concat(Le(e,n));return i}addSourceType(e,t,n){return en.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(en.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const n in e)if(!t(e[n],r[n])){i=!0;break}if(!i)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,r=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===r){if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.clone$1(n),n=e.extend(n,{source:t})}if(this._validate(e.validateTerrain,"terrain",n))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode)this._createTerrain(n,r);else{const r=this.terrain,i=r.get();for(const t of Object.keys(e.spec.terrain))!n.hasOwnProperty(t)&&e.spec.terrain[t].default&&(n[t]=e.spec.terrain[t].default);for(const e in n)if(!t(n[e],i[e])){r.set(n),this.stylesheet.terrain=n;const e=this._setTransitionParameters({duration:0});r.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new z(e,this.map.transform);this.stylesheet.fog=e;const n=this._setTransitionParameters({duration:0});t.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,r=n.get();0===Object.keys(e).length&&n.set(e);for(const i in e)if(!t(e[i],r[i])){n.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter(e=>this.isLayerDraped(this._layers[e])),t=this._order.filter(e=>!this.isLayerDraped(this._layers[e]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new k(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});n.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,n,r,i,o={}){return(!o||!1!==o.validate)&&Ht(this,t.call(e.validateStyle,e.extend({key:n,style:this.serialize(),value:r,styleSpec:e.spec},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_reloadSources(){for(const e of this._getSources())e.reload&&e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,r,i,o=!1){let a=!1,s=!1;const l={};for(const e of this._order){const n=this._layers[e];if("symbol"!==n.type)continue;if(!l[n.source]){const e=this._getLayerSourceCache(n);if(!e)continue;l[n.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(n,l[n.source],t.center.lng,t.projection);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Gt(t,this._order,o,n,r,i,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,n){this.imageManager.getImages(t.icons,n),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,n)}getResource(t,n,r){return e.makeRequest(n,r)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this._getSourceCaches(t);return 0===n.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):n.every(e=>e.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}en.getSourceType=function(e){return ze[e]},en.setSourceType=function(e,t){ze[e]=t},en.registerForPluginStateChange=e.registerForPluginStateChange;var tn="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",nn="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",rn="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {float nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {return currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;vec4 bounds=vec4(d,vec2(1.0)-d);h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",on="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",an="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif";let sn={},ln={};const un=[];pn(tn,un),pn(rn,un),pn(on,un),pn(an,un),sn=mn("",rn),ln=mn(an,on);const cn=mn("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),hn=tn,dn="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var fn={background:mn("uniform vec4 u_color;uniform float u_opacity;void main() {vec4 out_color=u_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:mn("uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_mix);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:mn("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:mn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:mn("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:mn("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:mn("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:mn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:mn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:mn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:mn("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:mn("uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:mn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:mn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_color.rgb+=clamp(color.rgb*directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);float roof_radiance=clamp(u_lightpos.z,0.0,1.0);roof_radiance=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roof_radiance);v_roof_color.rgb+=clamp(color.rgb*roof_radiance*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:mn("uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 out_color=mix(color1,color2,u_fade);out_color=out_color*v_lighting;\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);directional*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\nv_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:mn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos);float f=getElevation(v_pos+vec2(epsilon.x,0));float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float h=getElevation(v_pos+vec2(0,epsilon.y));float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:mn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:mn("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;uniform float u_mix;uniform vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist_a=texture2D(u_dash_image,v_tex_a).a;float sdfdist_b=texture2D(u_dash_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);float sdfwidth=min(dash_from.z*u_scale.y,dash_to.z*u_scale.z);float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/sdfwidth;alpha*=smoothstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\n#ifdef RENDER_LINE_GRADIENT\nhighp vec4 out_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nvec4 out_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb,out_color.rgb,smoothAlpha);\n#endif\n}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform mediump vec3 u_scale;varying vec2 v_tex_a;varying vec2 v_tex_b;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash_from\n#pragma mapbox: define lowp vec4 dash_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash_from\n#pragma mapbox: initialize lowp vec4 dash_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;float scaleA=dash_from.z==0.0 ? 0.0 : tileZoomRatio/(dash_from.z*fromScale);float scaleB=dash_to.z==0.0 ? 0.0 : tileZoomRatio/(dash_to.z*toScale);float heightA=dash_from.y;float heightB=dash_to.y;v_tex_a=vec2(a_linesofar*scaleA/floorwidth,(-normal.y*heightA+dash_from.x+0.5)/u_texsize.y);v_tex_b=vec2(a_linesofar*scaleB/floorwidth,(-normal.y*heightB+dash_to.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:mn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern_from\n#pragma mapbox: define lowp vec4 pattern_to\n#pragma mapbox: define lowp float pixel_ratio_from\n#pragma mapbox: define lowp float pixel_ratio_to\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern_from\n#pragma mapbox: initialize mediump vec4 pattern_to\n#pragma mapbox: initialize lowp float pixel_ratio_from\n#pragma mapbox: initialize lowp float pixel_ratio_to\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:mn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:mn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:mn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:mn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:mn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:mn("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:mn("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",nn),skyboxGradient:mn("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",nn),skyboxCapture:mn("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:mn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;\n#ifdef GLOBE_POLES\nvec3 up_vector=normalize(globe_pos)*u_tile_up_scale;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:mn("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function pn(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of n)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const n=e.split(" ");for(const e of n)t.includes(e)||t.push(e)}}function mn(e,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),i={},o=[...un];return pn(e,o),pn(t,o),{fragmentSource:e=e.replace(n,(e,t,n,r,o)=>(i[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = u_${o};\n#endif\n`)),vertexSource:t=t.replace(n,(e,t,n,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return i[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`}),staticAttributes:r,usedDefines:o}}class _n{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,r,i,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color");let s=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:gn(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:o,u_accent:a}})(t,r,i,t.terrain?n.projMatrix:null);t.prepareDrawProgram(l,h,n.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=t.getTileBoundsBuffers(r);h.draw(l,u.TRIANGLES,o,a,s,e.CullFaceMode.disabled,d,i.id,f,p,m)}function vn(t,n,r){if(!n.needsDEMTextureUpload)return;const i=t.context,o=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(r.stride);const a=r.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.Texture(i,a,o.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function xn(t,n,r,i,o,a){const s=t.context,l=s.gl;if(!n.dem)return;const u=n.dem;if(s.activeTexture.set(l.TEXTURE1),vn(t,n,u),!n.demTexture)return;n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const c=u.dim;s.activeTexture.set(l.TEXTURE0);let h=n.fbo;if(!h){const t=new e.Texture(s,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=n.fbo=s.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}s.bindFramebuffer.set(h.framebuffer),s.viewport.set([0,0,c,c]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:p}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,i,o,a,e.CullFaceMode.disabled,((t,n)=>{const r=n.stride,i=e.create();return e.ortho(i,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(i,i,[0,-e.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,u),r.id,d,f,p),n.needsHillshadePrepare=!1}const bn=t=>({u_matrix:new e.UniformMatrix4f(t),u_image0:new e.Uniform1i(t),u_skirt_height:new e.Uniform1f(t)}),wn=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),Tn=(e,t,n,r,i,o,a,s,l,u,c,h,d,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9)});function En(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const Sn=new class{constructor(){this.operations={}}newMorphing(e,t,n,r,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:r,phase:0,duration:i,from:t,to:n,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},kn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Cn(e,t){const n=1<({u_matrix:e});function An(t,n,r,i,o){if(o>0){const a=e.exported.now(),s=(a-t.timeAdded)/o,l=n?(a-n.timeAdded)/o:-1,u=r.getSource(),c=i.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),d=h&&t.refreshedUponExpiration?1:e.clamp(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class In extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new P(Ve(),null),r=Pe("mock-dem",t,n,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class zn extends e.SourceCache{constructor(e){const t=Pe("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new P(Ve(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,r){if(t.freezeTileCoverage)return;this.transform=t;const i=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((n,r)=>{if(n[r.key]="",!this._tiles[r.key]){const n=new e.Tile(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);n.state="loaded",this._tiles[r.key]=n}return n},{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class Pn extends e.OverscaledTileID{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class On extends e.Elevation{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,i,o]=function(t){const n=new e.StructArrayLayout4i8,r=new e.StructArrayLayout3ui6,i=131;n.reserve(17161),r.reserve(33800);const o=e.EXTENT/128,a=e.EXTENT+o/2,s=a+o;for(let t=-o;ta||t<0||t>a?24575:0,o=e.clamp(Math.round(r),0,e.EXTENT),s=e.clamp(Math.round(t),0,e.EXTENT);n.emplaceBack(o+i,s,o,s)}const l=(e,t)=>{const n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)}),[n,r,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(r,e.boundsAttributes.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.SegmentVector.simpleSegment(0,0,r.length,i.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new zn(n.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.EXTENT,0,e.EXTENT,0,1);const s=a.gl;this._overlapStencilMode=new e.StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new In(n.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,n,r){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const i=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(i.get("source")),this._exaggeration=i.get("exaggeration");const o=()=>{this.sourceCache.used&&e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),n.updateElevation(!r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map(e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,n){const r=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.pointGeometry(r.x,r.y);t.sort((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const r=new e.pointGeometry(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],o),n.usedForTerrain)continue;const r=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[n.id]=i.map(e=>new Pn(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in s||(this._visibleDemTiles.push(t),s[n]=n)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const n in this.terrainTileForTile){const r=this.terrainTileForTile[n],i=r.dem;!i||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),vn(this.painter,r,i))}}_prepareDemTileUniforms(e,t,n,r){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-i.z),a=r||"";return n["u_dem_tl"+a]=[i.x*o%1,i.y*o%1],n["u_dem_scale"+a]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,r,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce((t,n)=>{if(!n.dem)return t;const r=n.dem.tree.minimums[0];return r>0&&e++,t+r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const r=this._getLoadedAreaMinimum(),i=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,i,n.RGBA,{premultiply:!1}),o}setupElevationDraw(t,n,r){const i=this.painter.context,o=i.gl,a=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var s;a.u_dem_size=this.sourceCache.getSource().tileSize,a.u_exaggeration=this.exaggeration();let l=null,u=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,n=r.morphing.dstDemTile;c=r.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(u=e),this._prepareDemTileUniforms(t,n,a)&&(l=n))}if(u&&l?(i.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),i.activeTexture.set(o.TEXTURE4),u.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),a.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,l,a)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),i.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&l){const t=(1<{if(u===e)return;const r=[kn[e],"PROJECTION_GLOBE_VIEW"];d&&r.push("CUSTOM_ANTIALIASING"),n&&r.push(kn[c]),l=t.useProgram("globeRaster",null,r),u=e},p=t.colorModeForRenderPass(),m=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Sn.update(o);const _=e.calculateGlobeMercatorMatrix(h),g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=c?[!1,!0]:[!1],v=t.globeSharedBuffers,x=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach(c=>{u=-1;const d=c?s.LINES:s.TRIANGLES;for(const u of i){const i=r.getTile(u),y=e.StencilMode.disabled,T=n.prevTerrainTileForTile[u.key],E=n.terrainTileForTile[u.key];En(T,E)&&Sn.newMorphing(u.key,T,E,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const S=Sn.getMorphValuesForProxy(u.key),k=S?1:0;S&&e.extend$1(w,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.easeCubicInOut(S.phase)}});const C=e.tileCornersToBounds(u.canonical),M=e.getLatitudinalLod(C.getCenter().lat),A=e.getGridMatrix(u.canonical,C,M,h.worldSize/h._pixelsPerMercatorPixel),I=e.globeNormalizeECEF(e.globeTileBounds(u.canonical)),z=Tn(h.projMatrix,b,_,I,e.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,A);if(f(k,c),n.setupElevationDraw(i,l,w),t.prepareDrawProgram(a,l,u.toUnwrapped()),v){const[n,r,i]=c?v.getWirefameBuffers(t.context,M):v.getGridBuffers(M);l.draw(a,d,m,y,p,e.CullFaceMode.backCCW,z,"globe_raster",n,r,i)}}}),v){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of i){const{x:i,y:u,z:c}=o.canonical,d=0===u,f=u===(1<t.draw(a,s.TRIANGLES,m,e.StencilMode.disabled,p,e.CullFaceMode.disabled,Tn(h.projMatrix,v,v,E,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x),"globe_pole_raster",n,b,T);n.setupElevationDraw(u,l,w),t.prepareDrawProgram(a,l,o.toUnwrapped()),d&&S(l,_),f&&(v=e.scale(e.create(),v,[1,-1,1]),S(l,y))}}}}(t,n,r,i,o);else{const a=t.context,s=a.gl;let l,u;const c=t.options.showTerrainWireframe?2:0,h=(e,n)=>{if(u===e)return;const r=[kn[e]];n&&r.push(kn[c]),l=t.useProgram("terrainRaster",null,r),u=e},d=t.colorModeForRenderPass(),f=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);Sn.update(o);const p=t.transform,m=6*Math.pow(1.5,22-p.zoom)*n.exaggeration();(c?[!1,!0]:[!1]).forEach(c=>{u=-1;const _=c?s.LINES:s.TRIANGLES,[g,y]=c?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const u of i){const i=r.getTile(u),v=e.StencilMode.disabled,x=n.prevTerrainTileForTile[u.key],b=n.terrainTileForTile[u.key];En(x,b)&&Sn.newMorphing(u.key,x,b,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST);const w=Sn.getMorphValuesForProxy(u.key),T=w?1:0;let E;w&&(E={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=wn(u.projMatrix,Cn(u.canonical,p.renderWorldCopies)?m/10:m);h(T,c),n.setupElevationDraw(i,l,E),t.prepareDrawProgram(a,l,u.toUnwrapped()),l.draw(a,_,f,v,d,e.CullFaceMode.backCCW,S,"terrain_raster",n.gridBuffer,g,y)}})}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,r=this.painter.context,i=this.proxySourceCache,o=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),s=[],l=n.style.order;let u=0;for(const c of o){const o=i.getTileByID(c.proxyTileKey),h=i.proxyCachedFBO[c.key]?i.proxyCachedFBO[c.key][t]:void 0,d=void 0!==h?i.renderCache[h]:this.pool[u++],f=void 0!==h;if(o.texture=d.tex,f&&!d.dirty){s.push(o.tileID);continue}let p;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.Color.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._layers[l[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style._getLayerSourceCache(t),o=i?this.proxyToSource[c.key][i.id]:[c];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(d.dirty=!0,s.push(o.tileID)):f||--u,5===u&&(u=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let n,r=0,i=0,o=!1;for(let a=0;ae.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,n){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const i=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const i of r){if(null==i.t)return null;const r=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,n=t.gl,r=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.Texture(t,{width:r[0],height:r[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(i.texture),o.depthAttachment=new Ee(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],n=t.isHidden(this.painter.transform.zoom),r=t.getCrossfadeParameters(),i=!!r&&1!==r.t,o=t.hasTransition();return"custom"!==t.type&&!n&&(i||o)})}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ce){e=!0;break}if(e)for(let e=0;et.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let n=0;n=0;i--){const o=n[i];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const n=e[o.key],i=this.proxyToSource[o.key];let a=0;for(const e in i){const t=i[e],o=n[e];if(!o||o.length!==t.length||t.some((t,n)=>t!==o[n]||r[e]&&r[e].hasOwnProperty(t.key))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of i)for(const r of n){if(t.proxyCachedFBO[r.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,o=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,n){const r=this.painter,i=this.painter.context,o=i.gl;r._tileClippingMaskIDs={},i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=r.useProgram("clippingMask");for(const s of t){const t=r._tileClippingMaskIDs[s.key]=--n;a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(s.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const r=[t.x,t.y,1,1];e.transformMat4$1(r,r,n.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),r[0]/=n.worldSize,r[1]/=n.worldSize;const i=n._camera.position,o=e.mercatorZfromAltitude(1,n.center.lat),a=[i[0],i[1],i[2]/o,0],s=e.subtract([],r.slice(0,3),a);e.normalize(s,s);const l=this.raycast(a,s,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(a,a,s,l),a[3]=a[2],a[2]*=o,a):null}drawDepth(){const t=this.painter,n=t.context,r=this.proxySourceCache,i=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,r=n.createFramebuffer(i,o,!0);n.activeTexture.set(t.TEXTURE0);const a=new e.Texture(n,{width:i,height:o,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(a.texture);const s=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,o);r.depthAttachment.set(s),this._depthFBO=r,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,o]),function(t,n,r,i){if("globe"===t.transform.projection.name)return;const o=t.context,a=o.gl;o.clear({depth:1});const s=t.useProgram("terrainDepth"),l=new e.DepthMode(a.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of i){const i=r.getTile(t),u=wn(t.projMatrix,0);n.setupElevationDraw(i,s),s.draw(o,a.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,u,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof Ie)return this._setupProxiedCoordsForImageSource(e,t,n);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],i=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e),{min:new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const r=t.wrap+t.canonical.x/(1<a+l.max.x||i+os+l.max.y};for(let e=0;ee.key===n.tileID.key);if(e)return e}if(n.tileID.key!==t.key){const r=t.canonical.z-n.tileID.canonical.z;let o,a,s;i=e.create();const l=n.tileID.wrap-t.wrap<0?(o=e.EXTENT>>r,a=o*((n.tileID.canonical.x<=i){const r=t.canonical.z-i;n.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(s=i,a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r))}a.key!==t.key&&(u.push(a.key),r=n.getTile(a))}const c=e=>{u.forEach(t=>{i[t]=e}),u.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&c(r.tileID.key);const e=a.calculateScaledKey(s);if(r=n.getTileByID(e),r&&r.hasData())break;const t=i[e];if(null===t)break;void 0===t?u.push(e):r=n.getTileByID(t)}return c(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let n=0;const r=new e.StructArrayLayout2ui4,i=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)n=e*i+t,r.emplaceBack(n,n+1),r.emplaceBack(n,n+i),r.emplaceBack(n+1,n+i),128===e&&r.emplaceBack(n+i,n+i+1);r.emplaceBack(n+1,n+1+i)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class Dn{static cacheKey(e,t,n,r){let i=`${t}${r?r.cacheKey:""}`;for(const t of n)e.usedDefines.includes(t)&&(i+="/"+t);return i}constructor(t,n,r,i,o,a){const s=t.gl;this.program=s.createProgram();const l=function(e){const t=[];for(let n=0;n"#define "+e));const d=h.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(dn):dn,dn,hn,cn.fragmentSource,ln.fragmentSource,r.fragmentSource).join("\n"),f=h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",hn,cn.vertexSource,ln.vertexSource,sn.vertexSource,r.vertexSource).join("\n"),p=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(p,d),s.compileShader(p),s.attachShader(this.program,p);const m=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else{s.shaderSource(m,f),s.compileShader(m),s.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.Uniform1i(t),u_dem_prev:new e.Uniform1i(t),u_dem_unpack:new e.Uniform4f(t),u_dem_tl:new e.Uniform2f(t),u_dem_scale:new e.Uniform1f(t),u_dem_tl_prev:new e.Uniform2f(t),u_dem_scale_prev:new e.Uniform1f(t),u_dem_size:new e.Uniform1f(t),u_dem_lerp:new e.Uniform1f(t),u_exaggeration:new e.Uniform1f(t),u_depth:new e.Uniform1i(t),u_depth_size_inv:new e.Uniform2f(t),u_meter_to_dem:new e.Uniform1f(t),u_label_plane_matrix_inv:new e.UniformMatrix4f(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.Uniform3f(t),u_tile_tr_up:new e.Uniform3f(t),u_tile_br_up:new e.Uniform3f(t),u_tile_bl_up:new e.Uniform3f(t),u_tile_up_scale:new e.Uniform1f(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.UniformMatrix4f(t),u_fog_range:new e.Uniform2f(t),u_fog_color:new e.Uniform4f(t),u_fog_horizon_blend:new e.Uniform1f(t),u_fog_temporal_offset:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_globe_transition:new e.Uniform1f(t),u_is_globe:new e.Uniform1i(t),u_viewport:new e.Uniform2f(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,e,this.binderUniforms,h,{zoom:d});const _={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const n of c.get()){const r=n.vaos||(n.vaos={});(r[s]||(r[s]=new _n)).bind(e,this,l,f?f.getPaintVertexBuffers():[],u,n.vertexOffset,p||[]),m.drawElements(t,n.primitiveLength*_,m.UNSIGNED_SHORT,n.primitiveOffset*_*2)}}}function Ln(e,t,n){const r=1/O(n,1,t.transform.tileZoom),i=Math.pow(2,n.tileID.overscaledZ),o=n.tileSize*Math.pow(2,t.transform.tileZoom)/i,a=o*(n.tileID.canonical.x+n.tileID.wrap*i),s=o*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[r,e.fromScale,e.toScale],u_fade:e.t,u_pixel_coord_upper:[a>>16,s>>16],u_pixel_coord_lower:[65535&a,65535&s]}}const Rn=e.create(),Bn=(t,n,r,i,o,a,s,l,u,c,h)=>{const d=n.style.light,f=d.properties.get("position"),p=[f.x,f.y,f.z],m=e.create$1();"viewport"===d.properties.get("anchor")&&(e.fromRotation(m,-n.transform.angle),e.transformMat3(p,p,m));const _=d.properties.get("color"),g=n.transform,y={u_matrix:t,u_lightpos:p,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[_.r,_.g,_.b],u_vertical_gradient:+r,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Rn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:a};return"globe"===g.projection.name&&(y.u_tile_id=[s.canonical.x,s.canonical.y,1<{const p=Bn(t,n,r,i,o,a,s,c,h,d,f),m={u_height_factor:-Math.pow(2,s.overscaledZ)/u.tileSize/8};return e.extend(p,Ln(l,n,u),m)},jn=e=>({u_matrix:e}),Un=(t,n,r,i)=>e.extend(jn(t),Ln(r,n,i)),Vn=(e,t)=>({u_matrix:e,u_world:t}),Nn=(t,n,r,i,o)=>e.extend(Un(t,n,r,i),{u_world:o}),Gn=e.create(),qn=(t,n,r,i,o,a)=>{const s=t.transform,l="globe"===s.projection.name;let u;if("map"===a.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(s.zoom,n.canonical)*s._pixelsPerMercatorPixel;u=Float32Array.from([t,0,0,t])}else u=s.calculatePixelsToTileUnitsMatrix(r);else u=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:s.cameraToCenterDistance,u_matrix:t.translatePosMatrix(n.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:u,u_inv_rot_matrix:Gn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[n.canonical.x,n.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},Zn=(t,n,r,i)=>{const o=e.EXTENT/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},Wn=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),Xn=e.create(),Hn=(t,n,r,i,o,a,s)=>{const l=t.transform,u="globe"===l.projection.name,c=u?e.globePixelsToTileUnits(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:O(r,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:Xn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=i,h.u_merc_center=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<{const l=e.transform,u=l.calculatePixelsToTileUnitsMatrix(t),c={u_matrix:Qn(e,t,n,i),u_pixels_to_tile_units:u,u_device_pixel_ratio:a,u_units_to_pixels:[1/l.pixelsToGLUnits[0],1/l.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:o,u_texsize:[0,0],u_scale:[0,0,0],u_mix:0,u_alpha_discard_threshold:0,u_trim_offset:s};if(er(n)){const n=Jn(t,e.transform);c.u_texsize=t.lineAtlasTexture.size,c.u_scale=[n,r.fromScale,r.toScale],c.u_mix=r.t}return c},Kn=(e,t,n,r,i,o)=>{const a=e.transform,s=Jn(t,a);return{u_matrix:Qn(e,t,n,i),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:a.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:o,u_image:0,u_scale:[s,r.fromScale,r.toScale],u_fade:r.t,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Jn(e,t){return 1/O(e,1,t.tileZoom)}function Qn(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function er(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const tr=(e,t,n,r,i,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(s=i.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:nr(i.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function nr(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const rr=e.create(),ir=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>{const g=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:g.width/g.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+i,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:rr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:rr,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(ir(t,n,r,i,o,a,s,l,u,c,d,f,p,m,_,g),{u_gamma_scale:i?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),ar=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>e.extend(or(t,n,r,i,o,a,s,l,!0,u,!0,h,d,f,p,m,_),{u_texsize_icon:c,u_texture_icon:1}),sr=(e,t,n)=>({u_matrix:e,u_opacity:t,u_color:n}),lr=(t,n,r,i,o,a)=>e.extend(function(e,t,n,r){const i=n.imageManager.getPattern(e.from.toString()),o=n.imageManager.getPattern(e.to.toString()),{width:a,height:s}=n.imageManager.getPixelSize(),l=Math.pow(2,r.tileID.overscaledZ),u=r.tileSize*Math.pow(2,n.transform.tileZoom)/l,c=u*(r.tileID.canonical.x+r.tileID.wrap*l),h=u*r.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:i.tl,u_pattern_br_a:i.br,u_pattern_tl_b:o.tl,u_pattern_br_b:o.br,u_texsize:[a,s],u_mix:t.t,u_pattern_size_a:i.displaySize,u_pattern_size_b:o.displaySize,u_scale_a:t.fromScale,u_scale_b:t.toScale,u_tile_units_to_pixels:1/O(r,1,n.transform.tileZoom),u_pixel_coord_upper:[c>>16,h>>16],u_pixel_coord_lower:[65535&c,65535&h]}}(i,a,r,o),{u_matrix:t,u_opacity:n}),ur={fillExtrusion:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t)}),fillExtrusionPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_height_factor:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_scale:new e.Uniform3f(t),u_fade:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t)}),fill:t=>({u_matrix:new e.UniformMatrix4f(t)}),fillPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_scale:new e.Uniform3f(t),u_fade:new e.Uniform1f(t)}),fillOutline:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t)}),fillOutlinePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_scale:new e.Uniform3f(t),u_fade:new e.Uniform1f(t)}),circle:t=>({u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),collisionBox:t=>({u_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.Uniform2f(t)}),collisionCircle:t=>({u_matrix:new e.UniformMatrix4f(t),u_inv_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_viewport_size:new e.Uniform2f(t)}),debug:t=>({u_color:new e.UniformColor(t),u_matrix:new e.UniformMatrix4f(t),u_overlay:new e.Uniform1i(t),u_overlay_scale:new e.Uniform1f(t)}),clippingMask:t=>({u_matrix:new e.UniformMatrix4f(t)}),heatmap:t=>({u_extrude_scale:new e.Uniform1f(t),u_intensity:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),heatmapTexture:t=>({u_image:new e.Uniform1i(t),u_color_ramp:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t)}),hillshade:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_latrange:new e.Uniform2f(t),u_light:new e.Uniform2f(t),u_shadow:new e.UniformColor(t),u_highlight:new e.UniformColor(t),u_accent:new e.UniformColor(t)}),hillshadePrepare:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_dimension:new e.Uniform2f(t),u_zoom:new e.Uniform1f(t),u_unpack:new e.Uniform4f(t)}),line:t=>({u_matrix:new e.UniformMatrix4f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_units_to_pixels:new e.Uniform2f(t),u_dash_image:new e.Uniform1i(t),u_gradient_image:new e.Uniform1i(t),u_image_height:new e.Uniform1f(t),u_texsize:new e.Uniform2f(t),u_scale:new e.Uniform3f(t),u_mix:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t),u_trim_offset:new e.Uniform2f(t)}),linePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_texsize:new e.Uniform2f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_units_to_pixels:new e.Uniform2f(t),u_scale:new e.Uniform3f(t),u_fade:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t)}),raster:t=>({u_matrix:new e.UniformMatrix4f(t),u_tl_parent:new e.Uniform2f(t),u_scale_parent:new e.Uniform1f(t),u_fade_t:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_image0:new e.Uniform1i(t),u_image1:new e.Uniform1i(t),u_brightness_low:new e.Uniform1f(t),u_brightness_high:new e.Uniform1f(t),u_saturation_factor:new e.Uniform1f(t),u_contrast_factor:new e.Uniform1f(t),u_spin_weights:new e.Uniform3f(t),u_perspective_transform:new e.Uniform2f(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_texture:new e.Uniform1i(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_is_halo:new e.Uniform1i(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texsize_icon:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_texture_icon:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_is_halo:new e.Uniform1i(t)}),background:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_color:new e.UniformColor(t)}),backgroundPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_pattern_tl_a:new e.Uniform2f(t),u_pattern_br_a:new e.Uniform2f(t),u_pattern_tl_b:new e.Uniform2f(t),u_pattern_br_b:new e.Uniform2f(t),u_texsize:new e.Uniform2f(t),u_mix:new e.Uniform1f(t),u_pattern_size_a:new e.Uniform2f(t),u_pattern_size_b:new e.Uniform2f(t),u_scale_a:new e.Uniform1f(t),u_scale_b:new e.Uniform1f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),terrainRaster:bn,terrainDepth:bn,skybox:t=>({u_matrix:new e.UniformMatrix4f(t),u_sun_direction:new e.Uniform3f(t),u_cubemap:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxGradient:t=>({u_matrix:new e.UniformMatrix4f(t),u_color_ramp:new e.Uniform1i(t),u_center_direction:new e.Uniform3f(t),u_radius:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxCapture:t=>({u_matrix_3f:new e.UniformMatrix3f(t),u_sun_direction:new e.Uniform3f(t),u_sun_intensity:new e.Uniform1f(t),u_color_tint_r:new e.Uniform4f(t),u_color_tint_m:new e.Uniform4f(t),u_luminance:new e.Uniform1f(t)}),globeRaster:t=>({u_proj_matrix:new e.UniformMatrix4f(t),u_globe_matrix:new e.UniformMatrix4f(t),u_normalize_matrix:new e.UniformMatrix4f(t),u_merc_matrix:new e.UniformMatrix4f(t),u_zoom_transition:new e.Uniform1f(t),u_merc_center:new e.Uniform2f(t),u_image0:new e.Uniform1i(t),u_grid_matrix:new e.UniformMatrix3f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_viewport:new e.Uniform2f(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_horizon:new e.Uniform1f(t),u_transition:new e.Uniform1f(t),u_fadeout_range:new e.Uniform1f(t),u_color:new e.Uniform4f(t),u_high_color:new e.Uniform4f(t),u_space_color:new e.Uniform4f(t),u_star_intensity:new e.Uniform1f(t),u_star_density:new e.Uniform1f(t),u_star_size:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t),u_horizon_angle:new e.Uniform1f(t),u_rotation_matrix:new e.UniformMatrix4f(t)})};let cr;function hr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=t.useProgram("collisionBox"),d=[];let f=0,p=0;for(let m=0;m0){const t=e.create(),n=x;e.mul(t,y.placementInvProjMatrix,c.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),d.push({circleArray:w,circleOffset:p,transform:n,invTransform:t,projection:y.getProjection()}),f+=w.length/4,p=f}b&&(t.terrain&&t.terrain.setupElevationDraw(g,h),h.draw(l,u.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,Zn(x,c,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!s||!d.length)return;const m=t.useProgram("collisionCircle"),_=new e.StructArrayLayout2f1f2i16;_.resize(4*f),_._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[v.associatedIconIndex]={shiftedAnchor:I,angle:z})}else _t(v.numGlyphs,f)}if(h){p.clear();const n=t.icon.placedSymbolArray;for(let t=0;t[0,0,0],r=nt(U,i.tileID.canonical,g,_,m,u.getProjection(),V);lt(u,U,t,o,r,q,g,c,n,l)}const W=y||o&&E||Z,X=t.translatePosMatrix(U,i,a,s),H=W?dr:N,Y=t.translatePosMatrix(q,i,a,s,!0),K=u.getProjection().createInversionMatrix(m,l.canonical),J=[];t.terrainRenderModeElevated()&&g&&J.push("PITCH_WITH_MAP_TERRAIN"),B&&J.push("PROJECTION_GLOBE_VIEW"),W&&J.push("PROJECTED_POS_ON_VIEWPORT");const Q=f&&0!==r.paint.get(o?"text-halo-width":"icon-halo-width").constantOr(1);let ee;ee=f?u.iconsInText?ar(w.kind,I,v,g,t,X,H,Y,z,L,l,j,T,K,F,u.getProjection()):or(w.kind,I,v,g,t,X,H,Y,o,z,!0,l,j,T,K,F,u.getProjection()):ir(w.kind,I,v,g,t,X,H,Y,o,z,l,j,T,K,F,u.getProjection());const te={program:t.useProgram(mr(f,o,u),d,J),buffers:h,uniformValues:ee,atlasTexture:P,atlasTextureIcon:R,atlasInterpolation:O,atlasInterpolationIcon:D,isSDF:f,hasHalo:Q,tile:i,labelPlaneMatrixInv:G};if(x&&u.canOverlap){b=!0;const t=h.segments.get();for(const n of t)k.push({segments:new e.SegmentVector([n]),sortKey:n.sortKey,state:te})}else k.push({segments:h.segments,sortKey:0,state:te})}b&&k.sort((e,t)=>e.sortKey-t.sortKey);for(const e of k){const n=e.state;if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,p.CLAMP_TO_EDGE),n.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,gr(n.buffers,e.segments,r,t,n.program,w,h,d,i)),i.u_is_halo=0}gr(n.buffers,e.segments,r,t,n.program,w,h,d,n.uniformValues)}}function gr(t,n,r,i,o,a,s,l,u){const c=i.context,h=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer];o.draw(c,c.gl.TRIANGLES,a,s,l,e.CullFaceMode.disabled,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),h)}function yr(t,n,r,i,o,a,s){const l=t.context.gl,u=r.paint.get("fill-pattern"),c=u&&u.constantOr(1),h=r.getCrossfadeParameters();let d,f,p,m,_;s?(f=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",d=l.LINES):(f=c?"fillPattern":"fill",d=l.TRIANGLES);for(const g of i){const i=n.getTile(g);if(c&&!i.patternsLoaded())continue;const y=i.getBucket(r);if(!y)continue;t.prepareDrawTile();const v=y.programConfigurations.get(r.id),x=t.useProgram(f,v);c&&(t.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),v.updatePaintBuffers(h));const b=u.constantOr(null);if(b&&i.imageAtlas){const e=i.imageAtlas,t=e.patternPositions[b.to.toString()],n=e.patternPositions[b.from.toString()];t&&n&&v.setConstantPatternPositions(t,n)}const w=t.translatePosMatrix(g.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(s){m=y.indexBuffer2,_=y.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];p="fillOutlinePattern"===f&&c?Nn(w,t,h,i,e):Vn(w,e)}else m=y.indexBuffer,_=y.segments,p=c?Un(w,t,h,i):jn(w);t.prepareDrawProgram(t.context,x,g.toUnwrapped()),x.draw(t.context,d,o,t.stencilModeForClipping(g),a,e.CullFaceMode.disabled,p,r.id,y.layoutVertexBuffer,m,_,r.paint,t.transform.zoom,v)}}function vr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=r.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=r.getCrossfadeParameters(),p=r.paint.get("fill-extrusion-opacity"),m=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),r.paint.get("fill-extrusion-ambient-occlusion-radius")],_=r.layout.get("fill-extrusion-edge-radius"),g="globe"===c.projection.name?e.fillExtrusionHeightLift():0,y="globe"===c.projection.name,v=y?e.globeToMercatorTransition(c.zoom):0,x=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)],b=[];y&&(b.push("PROJECTION_GLOBE_VIEW"),t.style.terrainSetForDrapingOnly()&&b.push("TERRAIN")),m[0]>0&&b.push("FAUX_AO");for(const w of i){const i=n.getTile(w),T=i.getBucket(r);if(!T||T.projection.name!==c.projection.name)continue;const E=T.programConfigurations.get(r.id),S=t.useProgram(d?"fillExtrusionPattern":"fillExtrusion",E,b);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(i,S,{useMeterToDem:!0});else{if(!T.enableTerrain)continue;if(e.setupElevationDraw(i,S,{useMeterToDem:!0}),xr(l,n,w,T,r,e),!T.centroidVertexBuffer){const e=S.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}}}d&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),E.updatePaintBuffers(f));const k=h.constantOr(null);if(k&&i.imageAtlas){const e=i.imageAtlas,t=e.patternPositions[k.to.toString()],n=e.patternPositions[k.from.toString()];t&&n&&E.setConstantPatternPositions(t,n)}const C=t.translatePosMatrix(w.projMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),M=c.projection.createInversionMatrix(c,w.canonical),A=r.paint.get("fill-extrusion-vertical-gradient"),I=d?Fn(C,t,A,p,m,_,w,f,i,g,v,x,M):Bn(C,t,A,p,m,_,w,g,v,x,M);t.prepareDrawProgram(l,S,w.toUnwrapped());const z=[];t.terrain&&z.push(T.centroidVertexBuffer),y&&z.push(T.layoutVertexExtBuffer),S.draw(l,l.gl.TRIANGLES,o,a,s,e.CullFaceMode.backCCW,I,r.id,T.layoutVertexBuffer,T.indexBuffer,T.segments,r.paint,t.transform.zoom,E,z)}}function xr(t,n,r,i,o,a){const s=[t=>{let n=t.canonical.x-1,r=t.wrap;return n<0&&(n=(1<{let n=t.canonical.x+1,r=t.wrap;return n===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=n.getSource().minzoom,r=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(u[0]=Math.min(t.min.y,n.min.y),u[1]=Math.max(t.max.y,n.max.y),u[2]=e.EXTENT-n.min.x>t.max.x?n.min.x-e.EXTENT:t.max.x,u),h=(t,n)=>(u[0]=Math.min(t.min.x,n.min.x),u[1]=Math.max(t.max.x,n.max.x),u[2]=e.EXTENT-n.min.y>t.max.y?n.min.y-e.EXTENT:t.max.y,u),d=[(e,t)=>c(e,t),(e,t)=>c(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],f=new e.pointGeometry(0,0);let p,m,_;const g=(t,n,i,o,s)=>{const l=[[o?i:t,o?t:i,0],[o?i:n,o?n:i,0]],u=s<0?e.EXTENT+s:s,c=[o?u:(t+n)/2,o?(t+n)/2:u,0];return 0===i&&s<0||0!==i&&s>0?a.getForTilePoints(_,[c],!0,m):l.push(c),a.getForTilePoints(r,l,!0,p),Math.max(l[0][2],l[1][2],c[2])/a.exaggeration()};for(let t=0;t<4;t++){const n=(t<2?1:5)-t,o=i.borders[t];if(0===o.length)continue;const u=_=s[t](r),c=l(u);if(!(c&&c instanceof e.FillExtrusionBucket&&c.enableTerrain))continue;if(i.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[n]===i.canonical.z)continue;if(m=a.findDEMTileFor(u),!m||!m.dem)continue;if(!p){const e=a.findDEMTileFor(r);if(!e||!e.dem)return;p=e}const h=c.borders[n];let y=0;const v=c.borderDoneWithNeighborZ[n]!==i.canonical.z;if(i.canonical.z===c.canonical.z){for(let r=0;rs[0]+3));)v&&c.encodeCentroid(void 0,l,!1),y++;if(l&&ys[1]-3)&&(o++,++y!==h.length);)l=c.featuresOnBorder[h[y]];if(l=c.featuresOnBorder[h[r]],a.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=r),i.encodeCentroid(void 0,a,!1),v&&c.encodeCentroid(void 0,l,!1);continue}const u=d[t](a,l),p=t%2?e.EXTENT-1:0;f.x=g(u[0],Math.min(e.EXTENT-1,u[1]),p,t<2,u[2]),f.y=0,i.encodeCentroid(f,a,!1),v&&c.encodeCentroid(f,l,!1)}else i.encodeCentroid(void 0,a,!1)}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0,v&&(c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of o)i.encodeCentroid(void 0,i.featuresOnBorder[e],!1);if(v){for(const e of h)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0}}(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const br=new e.Color(1,0,0,1),wr=new e.Color(0,1,0,1),Tr=new e.Color(0,0,1,1),Er=new e.Color(1,0,1,1),Sr=new e.Color(0,1,1,1);function kr(t,n,r){const i=t.context,o=t.transform,a=i.gl,s="globe"===o.projection.name,l=s?["PROJECTION_GLOBE_VIEW"]:null;let u=r.projMatrix;if(s&&e.globeToMercatorTransition(o.zoom)>0){const t=e.transitionTileAABBinECEF(r.canonical,o),n=e.globeDenormalizeECEF(t);u=e.multiply(new Float32Array(16),o.globeMatrix,n),e.multiply(u,o.projMatrix,u)}const c=t.useProgram("debug",null,l),h=n.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(h,c);const d=e.DepthMode.disabled,f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="$debug";i.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(t.context,o):h._makeDebugTileBoundsBuffers(t.context,o.projection);const _=h._tileDebugBuffer||t.debugBuffer,g=h._tileDebugIndexBuffer||t.debugIndexBuffer,y=h._tileDebugSegments||t.debugSegments;c.draw(i,a.LINE_STRIP,d,f,p,e.CullFaceMode.disabled,Wn(u,e.Color.red),m,_,g,y,null,null,null,[h._globeTileDebugBorderBuffer]);const v=h.latestRawTileData,x=Math.floor((v&&v.byteLength||0)/1024),b=n.getTile(r).tileSize,w=512/Math.min(b,512)*(r.overscaledZ/o.zoom)*.5;let T=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(T+=" => "+r.overscaledZ),T+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,T);const E=h._tileDebugTextBuffer||t.debugBuffer,S=h._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,k=h._tileDebugTextSegments||t.debugSegments;c.draw(i,a.TRIANGLES,d,f,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,Wn(u,e.Color.transparent,w),m,E,S,k,null,null,null,[h._globeTileDebugTextBuffer])}function Cr(e,t,n,r){Ar(e,0,t+n/2,e.transform.width,n,r)}function Mr(e,t,n,r){Ar(e,t-n/2,0,n,e.transform.height,r)}function Ar(t,n,r,i,o,a){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}const Ir=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:zr}=Ir;function Pr(e,t,n,r){e.emplaceBack(t,n,r)}class Or{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Pr(this.vertexArray,-1,-1,1),Pr(this.vertexArray,1,-1,1),Pr(this.vertexArray,-1,1,1),Pr(this.vertexArray,1,1,1),Pr(this.vertexArray,-1,-1,-1),Pr(this.vertexArray,1,-1,-1),Pr(this.vertexArray,-1,1,-1),Pr(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,zr),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function Dr(t,n,r,i,o,a){const s=t.gl,l=n.paint.get("sky-atmosphere-color"),u=n.paint.get("sky-atmosphere-halo-color"),c=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,r,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),i),o,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),r.draw(t,s.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Lr=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Rr{constructor(t){const n=new e.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const r=new e.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Lr.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Br={symbol:function(t,n,r,i,o){if("translucent"!==t.renderPass)return;const a=e.StencilMode.disabled,s=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,n,r,i,o,a,s){const l=n.transform,u="map"===o,c="map"===a;for(const n of t){const t=i.getTile(n),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const a=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=wt(n,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),f=tt(h,t.tileID.canonical,c,u,l,o.getProjection(),d),p="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(a){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);pr(o,u,c,s,e.symbolSize,l,f,n,r,a,p)}}}(i,t,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&_r(t,n,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&_r(t,n,r,i,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,s),n.map.showCollisionBoxes&&(hr(t,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),hr(t,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const u=t.context,c=u.gl,h=t.transform,d=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="globe"===h.projection.name,_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],g=[];for(let o=0;oe.sortKey-t.sortKey);const y={useDepthForOcclusion:!m};for(const n of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,globeExtVertexBuffer:s,indexBuffer:l,uniformValues:m,tile:_}=n.state,g=n.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,y),t.prepareDrawProgram(u,o,_.tileID.toUnwrapped()),o.draw(u,c.TRIANGLES,d,f,p,e.CullFaceMode.disabled,m,r.id,a,l,g,r.paint,h.zoom,i,[s])}},heatmap:function(t,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,a=o.gl,s=e.StencilMode.disabled,l=new e.ColorMode([a.ONE,a.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,n,r){const i=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,o,a]);let s=n.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),s=n.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(e,0,t,s,o,a)}else i.bindTexture(i.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const u=t.transform,c="globe"===u.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,d=c?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,f=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)];for(let p=0;p({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,r))},line:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,c=r.paint.get("line-dasharray"),h=c.constantOr(1),d=r.layout.get("line-cap"),f=r.paint.get("line-pattern"),p=f.constantOr(1),m=r.paint.get("line-gradient"),_=r.getCrossfadeParameters(),g=p?"linePattern":"line",y=t.context,v=y.gl,x=(e=>{const t=[];er(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),i=1!==e.paint.get("line-opacity").constantOr(1);return!r&&i&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(r);let b=x.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(b=!1);for(const o of i){const i=n.getTile(o);if(p&&!i.patternsLoaded())continue;const a=i.getBucket(r);if(!a)continue;t.prepareDrawTile();const w=a.programConfigurations.get(r.id),T=t.useProgram(g,w,x),E=f.constantOr(null);if(E&&i.imageAtlas){const e=i.imageAtlas,t=e.patternPositions[E.to.toString()],n=e.patternPositions[E.from.toString()];t&&n&&w.setConstantPatternPositions(t,n)}const S=c.constantOr(null),k=d.constantOr(null);if(!p&&S&&k&&i.lineAtlas){const e=i.lineAtlas,t=e.getDash(S.to,k),n=e.getDash(S.from,k);t&&n&&w.setConstantPatternPositions(t,n)}let[C,M]=r.paint.get("line-trim-offset");if("round"===k||"square"===k){const e=1;C!==M&&(0===C&&(C-=e),1===M&&(M+=e))}const A=t.terrain?o.projMatrix:null,I=p?Kn(t,i,r,_,A,u):Yn(t,i,r,_,A,a.lineClipsArray.length,u,[C,M]);if(m){const i=a.gradients[r.id];let s=i.texture;if(r.gradientVersion!==i.version){let l=256;if(r.stepInterpolant){const r=n.getSource().maxzoom,i=o.canonical.z===r?Math.ceil(1<{T.draw(y,v.TRIANGLES,s,n,l,e.CullFaceMode.disabled,I,r.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,r.paint,t.transform.zoom,w,[a.layoutVertexBuffer2])};if(b){const n=t.stencilModeForClipping(o).ref;0===n&&t.terrain&&y.clear({stencil:0});const r={func:v.EQUAL,mask:255};I.u_alpha_discard_threshold=.8,z(new e.StencilMode(r,n,255,v.KEEP,v.KEEP,v.INVERT)),I.u_alpha_discard_threshold=0,z(new e.StencilMode(r,n,255,v.KEEP,v.KEEP,v.KEEP))}else z(t.stencilModeForClipping(o))}b&&(t.resetStencilClippingMasks(),t.terrain&&y.clear({stencil:0}))},fill:function(t,n,r,i){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=t.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);yr(t,n,r,i,o,s,!0)}},"fill-extrusion":function(t,n,r,i){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const a=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))vr(t,n,r,i,a,e.StencilMode.disabled,e.ColorMode.disabled),vr(t,n,r,i,a,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();vr(t,n,r,i,a,e.StencilMode.disabled,o)}}},hillshade:function(t,n,r,i){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),s=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[u,c]="translucent"!==t.renderPass||l?[{},i]:t.stencilConfigForOverlap(i);for(const i of c){const o=n.getTile(i);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)xn(t,o,r,a,e.StencilMode.disabled,s);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(i):u[i.overscaledZ];yn(t,i,o,r,a,e,s)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,n,r,i,o,a){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!i.length)return;const s=t.context,l=s.gl,u=n.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),d=t.terrain&&t.terrain.renderingToTexture,[f,p]=u instanceof Ie||d?[{},i]:t.stencilConfigForOverlap(i),m=p[p.length-1].overscaledZ,_=!t.options.moving;for(const i of p){const o=d?e.DepthMode.disabled:t.depthModeForSublayer(i.overscaledZ-m,1===r.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),p=i.toUnwrapped(),g=n.getTile(i);if(d&&(!g||!g.hasData()))continue;const y=d?i.projMatrix:t.transform.calculateProjMatrix(p,_),v=t.terrain&&d?t.terrain.stencilModeForRTTOverlap(i):f[i.overscaledZ],x=a?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(x);const b=n.findLoadedParent(i,0),w=An(g,b,n,t.transform,x);let T,E;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;s.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),T=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),E=[g.tileID.canonical.x*T%1,g.tileID.canonical.y*T%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const k=tr(y,E||[0,0],T||1,w,r,u instanceof Ie?u.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(s,c,p),u instanceof Ie)u.boundsBuffer&&u.boundsSegments&&c.draw(s,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,k,r.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:i,tileBoundsSegments:a}=t.getTileBoundsBuffers(g);c.draw(s,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,k,r.id,n,i,a)}}t.resetStencilClippingMasks()},background:function(t,n,r,i){const o=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const s=t.context,l=s.gl,u=t.transform,c=u.tileSize,h=r.paint.get("background-pattern");if(t.isPatternMissing(h))return;const d=!h&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;const f=e.StencilMode.disabled,p=t.depthModeForSublayer(0,"opaque"===d?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),_=t.useProgram(h?"backgroundPattern":"background");let g,y=i;y||(g=t.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));const v=r.getCrossfadeParameters();for(const d of y){const y=d.toUnwrapped(),x=i?d.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const b=n?n.getTile(d):g?g[d.key]:new e.Tile(d,c,u.zoom,t),w=h?lr(x,a,t,h,{tileID:d,tileSize:c},v):sr(x,a,o);t.prepareDrawProgram(s,_,y);const{tileBoundsBuffer:T,tileBoundsIndexBuffer:E,tileBoundsSegments:S}=t.getTileBoundsBuffers(b);_.draw(s,l.TRIANGLES,p,f,m,e.CullFaceMode.disabled,w,r.id,T,E,S)}},sky:function(t,n,r){const i=t.transform,o="mercator"===i.projection.name||"globe"===i.projection.name?1:e.smoothstep(7,8,i.zoom),a=r.paint.get("sky-opacity")*o;if(0===a)return;const s=t.context,l=r.paint.get("sky-type"),u=new e.DepthMode(s.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,n,r,i){const o=t.context,a=o.gl;let s=n.skyboxFbo;if(!s){s=n.skyboxFbo=o.createFramebuffer(32,32,!1),n.skyboxGeometry=new Or(o),n.skyboxTexture=o.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(s.framebuffer),o.viewport.set([0,0,32,32]);const l=n.getCenter(t,!0),u=t.useProgram("skyboxCapture"),c=new Float64Array(16);e.identity(c),e.rotateY(c,c,.5*-Math.PI),Dr(o,n,u,c,l,0),e.identity(c),e.rotateY(c,c,.5*Math.PI),Dr(o,n,u,c,l,1),e.identity(c),e.rotateX(c,c,.5*-Math.PI),Dr(o,n,u,c,l,2),e.identity(c),e.rotateX(c,c,.5*Math.PI),Dr(o,n,u,c,l,3),e.identity(c),Dr(o,n,u,c,l,4),e.identity(c),e.rotateY(c,c,Math.PI),Dr(o,n,u,c,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skybox");a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,n.skyboxTexture);const c=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(l.skyboxMatrix,n.getCenter(t,!1),0,i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,c,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c):"gradient"===l&&"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new Or(a)),a.activeTexture.set(s.TEXTURE0);let c=n.colorRampTexture;c||(c=n.colorRampTexture=new e.Texture(a,n.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((t,n,r,i,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.degToRad(r),u_opacity:i,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c)},debug:function(e,t,n){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const i=n+.78*(r-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,n){if(this.width=t*e.exported.devicePixelRatio,this.height=n*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const i=new e.StructArrayLayout2i4;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const a=new e.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Rr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,n.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,r){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=n.id;const i=this.context,o=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=n.getTile(t),s=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=this.getTileBoundsBuffers(r);a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},s,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,Mn(t.projMatrix),"$clipping",l,u,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new e.StencilMode({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new e.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,r=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],n=t._getLayerSourceCache(e);if(e.isSky())continue;const i=n?a[n.id]:void 0;this._renderTileClippingMasks(e,n,i),this.renderLayer(this,n,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,n){const r=t.context,i=r.gl,o=t.transform,a=new e.DepthMode(i.LEQUAL,e.DepthMode.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),u=n.properties.get("color").toArray01(),c=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),d=e.identity$1([]);e.rotateY$1(d,d,-e.degToRad(o._center.lng)),e.rotateX$1(d,d,e.degToRad(o._center.lat)),e.rotateZ$1(d,d,o.angle),e.rotateX$1(d,d,-o._pitch);const f=e.fromQuat(new Float32Array(16),d),p=e.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=e.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),g=e.globeUseCustomAntiAliasing(t,r,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),b=Math.acos(x/v),w=((t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_frustum_tl:t,u_frustum_tr:n,u_frustum_br:r,u_frustum_bl:i,u_horizon:o,u_transition:a,u_fadeout_range:s,u_color:l,u_high_color:u,u_space_color:c,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:d,u_horizon_angle:f,u_rotation_matrix:p}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,_,u,c,h,p,y,b,f);t.prepareDrawProgram(r,s);const T=t.atmosphereBuffer;T&&s.draw(r,i.TRIANGLES,a,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",T.vertexBuffer,T.indexBuffer,T.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=t._getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e){if(!e)return!1;if(!e.from||!e.to)return!0;const t=this.imageManager.getPattern(e.from.toString()),n=this.imageManager.getPattern(e.to.toString());return!t||!n}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.style&&this.style.fog,n=[];return this.terrainRenderModeElevated()&&n.push("TERRAIN"),"globe"===this.transform.projection.name&&n.push("GLOBE"),t&&!e&&0!==t.getOpacity(this.transform.pitch)&&n.push("FOG"),e&&n.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&n.push("OVERDRAW_INSPECTOR"),n}useProgram(e,t,n){this.cache=this.cache||{};const r=n||[],i=this.currentGlobalDefines().concat(r),o=Dn.cacheKey(fn[e],e,i,t);return this.cache[o]||(this.cache[o]=new Dn(this.context,e,fn[e],t,ur[e],i)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,n,r){if(this.terrain&&this.terrain.renderingToTexture)return;const i=this.style.fog;if(i){const o=i.getOpacity(this.transform.pitch),a=((t,n,r,i,o,a,s,l,u,c,h)=>{const d=t.transform,f=n.properties.get("color").toArray01();f[3]=i;const p=t.frameCounter/1e3%1;return{u_fog_matrix:r?d.calculateFogTileMatrix(r):t.identityMat,u_fog_range:n.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:p,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,i,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);n.setFogUniformValues(t,a)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)n[i.key]=t[i.key]||new e.Tile(i,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class jr{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(t,n,r){return null!=n.top&&null!=t.top&&(this.top=e.number(t.top,n.top,r)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,n.bottom,r)),null!=n.left&&null!=t.left&&(this.left=e.number(t.left,n.left,r)),null!=n.right&&null!=t.right&&(this.right=e.number(t.right,n.right,r)),this}getCenter(t,n){const r=e.clamp((this.left+t-this.right)/2,0,t),i=e.clamp((this.top+n-this.bottom)/2,0,n);return new e.pointGeometry(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new jr(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Ur(t,n){const r=e.getColumn(t,3);e.fromQuat(t,n),e.setColumn(t,3,r)}function Vr(t,n){const r=e.identity$1([]);return e.rotateZ$1(r,r,-n),e.rotateX$1(r,r,-t),r}function Nr(t,n){const r=[t[0],t[1],0],i=[n[0],n[1],0];if(e.length(r)>=1e-15){const t=e.normalize([],r);e.scale$2(i,t,e.dot(i,t)),n[0]=i[0],n[1]=i[1]}const o=e.cross([],n,t);if(e.len(o)<1e-15)return null;const a=Math.atan2(-o[1],o[0]);return Vr(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class Gr{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,i=this.position,o=e.MercatorCoordinate.fromLngLat(t,r),a=[o.x-i.x,o.y-i.y,o.z-i.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=Nr(a,n)}setPitchBearing(t,n){this.orientation=Vr(e.degToRad(t),e.degToRad(-n))}}class qr{constructor(t,n){this._transform=e.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.setColumn(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Ur(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=Vr(e,t),Ur(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const r=new Float64Array(16);return e.invert(r,this.getWorldToCamera(t,n)),r}getWorldToCameraPosition(t,n,r){const i=this.position;e.scale$2(i,i,-t);const o=new Float64Array(16);return e.fromScaling(o,[r,r,r]),e.translate(o,o,i),o[10]*=n,o}getWorldToCamera(t,n){const r=new Float64Array(16),i=new Float64Array(4),o=this.position;return e.conjugate(i,this._orientation),e.scale$2(o,o,-t),e.fromQuat(r,i),e.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=n,r[9]*=n,r[10]*=n,r[11]*=n,r}getCameraToClipPerspective(t,n,r,i){const o=new Float64Array(16);return e.perspective(o,t,n,r,i),o}getDistanceToElevation(t){const n=0===t?0:e.mercatorZfromAltitude(t,this.position[1]),r=this.forward();return(n-this.position[2])/r[2]}clone(){return new qr([...this.position],[...this.orientation])}}function $r(t,n){const r=Wr(t.projection,t.zoom,t.width,t.height),i=function(t,n,r,i,o){const a=new e.LngLat(r.lng-180*Xr,r.lat),s=new e.LngLat(r.lng+180*Xr,r.lat),l=t.project(a.lng,a.lat),u=t.project(s.lng,s.lat),c=-Math.atan2(u.y-l.y,u.x-l.x),h=e.MercatorCoordinate.fromLngLat(r);h.y=e.clamp(h.y,-.999975,.999975);const d=h.toLngLat(),f=t.project(d.lng,d.lat),p=e.MercatorCoordinate.fromLngLat(d);p.x+=Xr;const m=p.toLngLat(),_=t.project(m.lng,m.lat),g=Yr(_.x-f.x,_.y-f.y,c),y=e.MercatorCoordinate.fromLngLat(d);y.y+=Xr;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=Yr(x.x-f.x,x.y-f.y,c),w=Math.abs(g.x)/Math.abs(b.y),T=e.identity([]);e.rotateZ(T,T,-c*(1-(o?0:i)));const E=e.identity([]);return e.scale(E,E,[1,1-(1-w)*i,1]),E[4]=-b.x/b.y*i,e.rotateZ(E,E,c),e.multiply(E,T,E),E}(t.projection,0,t.center,r,n),o=Zr(t);return e.scale(i,i,[o,o,1]),i}function Zr(t){const n=t.projection,r=Wr(t.projection,t.zoom,t.width,t.height),i=Hr(n,t.center),o=Hr(n,e.LngLat.convert(n.center));return Math.pow(2,i*r+(1-r)*o)}function Wr(t,n,r,i,o=1/0){const a=t.range;if(!a)return 0;const s=Math.min(o,Math.max(r,i)),l=Math.log(s/1024)/Math.LN2;return e.smoothstep(a[0]+l,a[1]+l,n)}const Xr=1/4e4;function Hr(t,n){const r=e.clamp(n.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=new e.LngLat(n.lng-180*Xr,r),o=new e.LngLat(n.lng+180*Xr,r),a=t.project(i.lng,r),s=t.project(o.lng,r),l=e.MercatorCoordinate.fromLngLat(i),u=e.MercatorCoordinate.fromLngLat(o),c=s.x-a.x,h=s.y-a.y,d=u.x-l.x,f=u.y-l.y,p=Math.sqrt((d*d+f*f)/(c*c+h*h));return Math.log(p)/Math.LN2}function Yr(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}class Kr{constructor(t,n,r,i,o,a,s){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new jr,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new qr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Kr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e){const t=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||t)&&this._updateCameraOnTerrain(),(e||t)&&this._constrainCameraAltitude(),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const i=!t(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.getProjection({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSize)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;var r;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(r=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.degToRad(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let i=0,o=0;for(let a=0;at.maxzoom&&(n=t.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const n=1/4e4,r=new e.MercatorCoordinate(t.x+n,t.y,t.z),i=new e.MercatorCoordinate(t.x,t.y+n,t.z),o=t.toLngLat(),a=r.toLngLat(),s=i.toLngLat(),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=this.locationCoordinate(s),h=Math.hypot(u.x-l.x,u.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);return Math.sqrt(h*d)*b/n},T=t=>{const n=v,r=x;return{aabb:e.tileAABB(this,l,0,0,0,t,r,n,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:n,wrap:t,fullyVisible:!1}},E=[];let S=[];const k=n,C=t.reparseOverscaled?r:n,M=e=>e*e,A=M((m-this._centerAltitude)*p),I=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=z(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},z=t=>{if(t.zoom=.9)return!0}else if(i&&(a=M(t.aabb.distanceZ(_)*p)),this.projection.isReprojectedInTileSpace&&r<=5){const n=Math.pow(2,t.zoom),r=w(new e.MercatorCoordinate((t.x+.5)/n,(t.y+.5)/n));l=r>.85?1:r}const u=n*n+o*o+a;return u{if(t*M(.707)0;){const r=E.pop(),a=r.x,s=r.y;let h=r.fullyVisible;if(!h){const e=r.aabb.intersects(d);if(0===e)continue;h=2===e}if(r.zoom!==k&&z(r))for(let t=0;t<4;t++){const n=(a<<1)+t%2,u=(s<<1)+(t>>1),d={aabb:o?r.aabb.quadrant(t):e.tileAABB(this,l,r.zoom+1,n,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:n,y:u,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};i&&!c&&(d.tileID=new e.OverscaledTileID(r.zoom+1===k?C:r.zoom+1,r.wrap,r.zoom+1,n,u),I(d)),E.push(d)}else{const i=r.zoom===k?C:r.zoom;if(t.minzoom&&t.minzoom>i)continue;const o=u[0]-(.5+a+(r.wrap<{const o=[0,0,0,1],a=[e.EXTENT,e.EXTENT,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.transformMat4$1(o,o,s),e.transformMat4$1(a,a,s);const l=e.getAABBPointSquareDist(o,a);if(0===l)return!0;let u=!1;const c=this._elevation;if(c&&l>n&&0!==r){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=c.getMinMaxForTile(i.tileID)),o||(o={min:x,max:v});const a=e.furthestTileCorner(this.rotation),s=[a[0]*e.EXTENT,a[1]*e.EXTENT,o.max];e.transformMat4(s,s,n),u=(1-s[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const n=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=this.projection.project(t.lng,n);return new e.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,n){let r,i;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(n.x-o.x)/e,i=(n.y-o.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(o);r=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(a.x-r,a.y-i))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,n){const r=n?e.mercatorZfromAltitude(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(i.x,i.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const r=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const a=o[3];e.scale$1(i,i,1/i[3]),e.scale$1(o,o,1/a);const s=i[2],l=o[2];return{p0:i,p1:o,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(r,r,this.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),e.scale$1(r,r,1/r[3]),n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,e.scale$1(n,n,1/this.worldSize),e.scale$1(r,r,1/this.worldSize),new e.Ray([n[0],n[1],n[2]],e.normalize([],e.sub([],r,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:r,t:i}=t,o=e.mercatorZfromAltitude(n[2],this._center.lat),a=e.mercatorZfromAltitude(r[2],this._center.lat);return new e.MercatorCoordinate(e.number(n[0],r[0],i)/this.worldSize,e.number(n[1],r[1],i)/this.worldSize,e.number(o,a,i))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.MercatorCoordinate(n[0],n[1],n[2]);let r=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const o=.02*i,a=t.clone();for(let t=0;t<10&&i-r>o;t++){a.y=e.number(r,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):r=a.y}return n?new e.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(t,n){const r=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.transformMat4$1(i,i,this.pixelMatrix),i[3]>0?new e.pointGeometry(i[0]/i[3],i[1]/i[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getGlobeBounds(){const{top:t,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,o=this.pointCoordinate3D(new e.pointGeometry(n,t)),a=this.pointCoordinate3D(new e.pointGeometry(i,t)),s=this.pointCoordinate3D(new e.pointGeometry(i,r)),l=this.pointCoordinate3D(new e.pointGeometry(n,r));let u=Math.min(o.x,l.x),c=Math.max(a.x,s.x),h=Math.min(o.y,a.y),d=Math.max(l.y,s.y);const f=Math.pow(2,-this.zoom)/16,p=(t,n,r,i)=>{const o=(t+r)/2,a=(n+i)/2,s=new e.pointGeometry(o,a),l=this.pointCoordinate3D(s),m=Math.max(0,u-l.x,h-l.y,l.x-c,l.y-d);u=Math.min(u,l.x),c=Math.max(c,l.x),h=Math.min(h,l.y),d=Math.max(d,l.y),m>f&&(p(t,n,o,a),p(o,a,r,i))};p(n,t,i,t),p(i,t,i,r),p(i,r,n,r),p(n,r,n,t);const m=new e.LngLat(e.lngFromMercatorX(c),e.latFromMercatorY(h)),_=new e.LngLat(e.lngFromMercatorX(u),e.latFromMercatorY(d));return new e.LngLatBounds(_,m)}_getBounds(t,n){if("globe"===this.projection.name)return this._getGlobeBounds();const r=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),i=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),a=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let s=this.pointCoordinate(r,t),l=this.pointCoordinate(i,t);const u=this.pointCoordinate(o,n),c=this.pointCoordinate(a,n),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return s.y>1&&l.y>=0?s=new e.MercatorCoordinate((1-c.y)/h(c,s)+c.x,1):s.y<0&&l.y<=1&&(s=new e.MercatorCoordinate(-c.y/h(c,s)+c.x,0)),l.y>1&&s.y>=0?l=new e.MercatorCoordinate((1-u.y)/h(u,l)+u.x,1):l.y<0&&s.y<=1&&(l=new e.MercatorCoordinate(-u.y/h(u,l)+u.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(s)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(u))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBounds(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(s=h-u),h-ct&&(a=t-l),t-e.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,a=e.create(),e.scale(a,a,[this.width/2,-this.height/2,1]),e.translate(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=e.create(),e.scale(a,a,[1,-1,1]),e.translate(a,a,[-1,-1,0]),e.scale(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},a=e.invert(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=a,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,i),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=a;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSize,n=this.cameraPixelsPerMeter,r=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,n];e.scale$2(o,o,i),e.scale$2(r,r,-1),e.multiply$2(r,r,o);const a=e.create();e.translate(a,a,r),e.scale(a,a,o),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),r=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-n[0]*i,r.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],i=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(o=Math.min((n-r)/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:r,bearing:i}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),s=Math.max((t[2]-o)/Math.cos(r),a),l=this._zoomFromMercatorZ(s);e.scaleAndAdd(t,t,n,s),this._pitch=e.clamp(r,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(i,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+2,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){const t=t=>{const n=this.getCameraToCenterDistance(this.projection,t);return this.scaleZoom(n/(e*this.tileSize))};let n,r=t(this.zoom),i=Math.abs(r-t(r));for(;n!==i;)r=t(r),n=i,i=Math.abs(r-t(r));return r}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,n){const r=Math.min(t.x,n.x),i=Math.max(t.x,n.x),o=Math.min(t.y,n.y),a=Math.max(t.y,n.y);if(ou||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,n){const r=e.length(e.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(r)+n;return r-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function(t,n){const r=[t[0],t[1],t[2],1];e.transformMat4$1(r,r,n);const i=Math.max(r[3],1e-6);return[r[0]/i,r[1]/i,r[2]/i,i]}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.pointGeometry(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,t))}}getCameraToCenterDistance(e,t=this.zoom){const n=Wr(e,t,this.width,this.height,1024),r=e.pixelSpaceConversion(this.center.lat,this.worldSize,n);return.5/Math.tan(.5*this._fov)*this.height*r}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.multiply(t,t,this.globeMatrix),t}}function Jr(e,t){let n=!1,r=null;const i=()=>{r=null,n&&(e(),r=setTimeout(i,t),n=!1)};return()=>(n=!0,r||i(),r)}class Qr{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Jr(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=ei(t);if(this._hashName){const t=this._hashName;let r=!1;const i=e.window.location.hash.slice(1).split("&").map(e=>{const i=e.split("=")[0];return i===t?(r=!0,`${i}=${n}`):e}).filter(e=>e);return r||i.push(`${t}=${n}`),"#"+i.join("&")}return"#"+n}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(e=>e.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(e))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}function ei(e,t){const n=e.getCenter(),r=Math.round(100*e.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=e.getBearing(),u=e.getPitch();let c=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+="/"+Math.round(u)),c}const ti={linearity:.3,easing:e.bezier(0,0,.3,1)},ni=e.extend({deceleration:2500,maxSpeed:1400},ti),ri=e.extend({deceleration:20,maxSpeed:1400},ti),ii=e.extend({deceleration:1e3,maxSpeed:360},ti),oi=e.extend({deceleration:1e3,maxSpeed:90},ti);class ai{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const o=li(n.pan.mag(),r,e.extend({},ni,t||{}));i.offset=n.pan.mult(o.amount/n.pan.mag()),i.center=this._map.transform.center,si(i,o)}if(n.zoom){const e=li(n.zoom,r,ri);i.zoom=this._map.transform.zoom+e.amount,si(i,e)}if(n.bearing){const t=li(n.bearing,r,ii);i.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),si(i,t)}if(n.pitch){const e=li(n.pitch,r,oi);i.pitch=this._map.transform.pitch+e.amount,si(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function si(e,t){(!e.duration||e.durationn.unproject(e)),s=o.reduce((e,t,n,r)=>e.add(t.div(r.length)),new e.pointGeometry(0,0));super(t,{points:o,point:s,lngLats:a,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class hi extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class di{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new hi(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new ui(e.type,this._map,e))}mouseup(e){this._map.fire(new ui(e.type,this._map,e))}preclick(t){const n=e.extend({},t);n.type="preclick",this._map.fire(new ui(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new ui(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new ui(e.type,this._map,e))}mouseover(e){this._map.fire(new ui(e.type,this._map,e))}mouseout(e){this._map.fire(new ui(e.type,this._map,e))}touchstart(e){return this._firePreventable(new ci(e.type,this._map,e))}touchmove(e){this._map.fire(new ci(e.type,this._map,e))}touchend(e){this._map.fire(new ci(e.type,this._map,e))}touchcancel(e){this._map.fire(new ci(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class fi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new ui(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new ui("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new ui(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class pi{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(c(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const n=t,r=this._startPos,i=this._lastPos;if(!r||!i||i.equals(n)||!this._box&&n.dist(r){this._box&&(this._box.style.transform=`translate(${a}px,${l}px)`,this._box.style.width=s-a+"px",this._box.style.height=u-l+"px")})}mouseupWindow(t,n){if(!this._active)return;const r=this._startPos,i=n;if(r&&0===t.button){if(this.reset(),f(),r.x!==i.x||r.y!==i.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new e.Event(t,{originalEvent:n}))}}function mi(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const n=new e.pointGeometry(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=mi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=mi(n,t);for(const e in this.touches){const t=this.touches[e],n=r[e];(!n||n.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class gi{constructor(e){this.singleTap=new _i(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const r=this.singleTap.touchend(e,t,n);if(r){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class yi{constructor(){this._zoomIn=new gi({numTouches:1,numTaps:2}),this._zoomOut=new gi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const vi={0:1,2:2};class xi{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const n=_(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=vi[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=mi(r,n),o=new e.pointGeometry(0,0),a=new e.pointGeometry(0,0);let s=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(o._add(t),a._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class Si{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[i,o]=r,a=ki(n,t,i),s=ki(n,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[r,i]=this._firstTwoTouches,o=ki(n,t,r),a=ki(n,t,i);o&&a||(this._active&&f(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function ki(e,t,n){for(let r=0;rMath.abs(e.x)}class Pi extends Si{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,zi(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,r){const i=this._lastPoints;if(!i)return;const o=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.isFullscreen()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,a,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return zi(e)&&zi(t)&&o}}const Oi={panStep:100,bearingStep:15,pitchStep:10};class Di{constructor(){const e=Oi;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Li,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-i*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Li(e){return e*(2-e)}const Ri=4.000244140625;class Bi{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.exported.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%Ri==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Ri?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const i=n(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,o=this._easing;let a,s=!1;if("wheel"===this._type&&i&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),n=o(t);a=e.number(i,r,n),t<1?this._frameId||(this._frameId=!0):s=!0}else a=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.ease;if(this._prevEase){const t=this._prevEase,r=(e.exported.now()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-o*o);n=e.bezier(o,a,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))+"px")}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Fi{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class ji{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ui{constructor(){this._tap=new gi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Vi{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ni{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Gi{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const qi=e=>e.zoom||e.drag||e.pitch||e.rotate;class $i extends e.Event{}class Zi{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const r=e.sub([],n,t);this.radius=e.length(r[2]<0?e.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const n=e.scale$2([],t,this.radius);if(n[2]>0){const t=e.scale$2([],[0,0,1],e.dot(n,[0,0,1])),r=e.scale$2([],e.normalize([],[n[0],n[1],0]),this.radius),i=e.add([],n,e.scale$2([],e.sub([],e.add([],r,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function Wi(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Xi{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ai(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new Zi,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,n,r]of this._listeners)t.addEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,n,r]of this._listeners)t.removeEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new di(t,e));const r=t.boxZoom=new pi(t,e);this._add("boxZoom",r);const i=new yi,o=new ji;t.doubleClickZoom=new Fi(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new Ui;this._add("tapDragZoom",a);const s=t.touchPitch=new Pi(t);this._add("touchPitch",s);const l=new wi(e),u=new Ti(e);t.dragRotate=new Ni(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new bi(e),h=new Ei(t,e);t.dragPan=new Vi(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Ii,f=new Mi;t.touchZoomRotate=new Gi(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new fi(t));const p=t.scrollZoom=new Bi(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new Di;this._add("keyboard",m);for(const n of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[n]&&t[n].enable(e[n])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!qi(this._eventsInProgress)||this.isZooming()}_blockedByActive(e,t,n){for(const r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,e.type+"Window")}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,r=n?void 0:e,i={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?m(this._el,s):n?void 0:p(this._el,e);for(const{handlerName:n,handler:u,allowed:c}of this._handlers){if(!u.isEnabled())continue;let h;this._blockedByActive(a,c,n)?u.reset():u[t||e.type]&&(h=u[t||e.type](e,l,s),this.mergeHandlerResult(i,o,h,n,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||u.isActive())&&(a[n]=u)}const u={};for(const e in this._previousActiveHandlers)a[e]||(u[e]=r);this._previousActiveHandlers=a,(Object.keys(u).length||Wi(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||Wi(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,n,r,i,o){if(!r)return;e.extend(t,r);const a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},r={};for(const[i,o,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.extend(n,o),e.extend(r,a);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){const i=this._map,o=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!Wi(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(!Wi(t))return void this._fireEvents(n,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:u,pitchDelta:c,around:h,aroundCoord:d,pinchAround:f}=t;void 0!==f&&(h=f),(e=>n.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=a(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,u&&(o.bearing+=u),c&&(o.pitch+=c),o._updateCameraState();const p=[0,0,0];if(s)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){s=s.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;p[0]=-s.x*e.mercatorScale(e.latFromMercatorY(t.y))*n,p[1]=-s.y*e.mercatorScale(o.center.lat)*n}else{const e=o.pointCoordinate(h.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=a(d||o.pointCoordinate3D(h)),n={dir:e.normalize([],e.sub([],t,o._camera.position))};if(n.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.scale$2(_,n.dir,r)}}const g=e.add(p,p,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_fireEvents(t,n,r){const i=qi(this._eventsInProgress),o=qi(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a[e+"start"]=n),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,s[e+"end"]=l)}for(const e in s)this._fireEvent(e,s[e]);const u=qi(this._eventsInProgress);if(r&&(i||o)&&!u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new $i("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Hi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Yi extends e.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,r){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},n),r)}panTo(t,n,r){return this.easeTo(e.extend({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,r){return this.easeTo(e.extend({zoom:t},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,n,r){return this.easeTo(e.extend({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,e.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,r,i,o){const a=t.clone(),s=this._extendCameraOptions(o);a.bearing=i;const l=e.LngLat.convert(n),u=e.LngLat.convert(r),c=.5*(l.lat+u.lat),h=.5*(l.lng+u.lng),d=e.latLngToECEF(c,h),f=e.normalize([],d),p=e.normalize([],e.cross([],f,[0,1,0])),m=e.cross([],p,f),_=[p[0],p[1],p[2],0,m[0],m[1],m[2],0,f[0],f[1],f[2],0,0,0,0,1],g=[d,e.latLngToECEF(l.lat,l.lng),e.latLngToECEF(u.lat,l.lng),e.latLngToECEF(u.lat,u.lng),e.latLngToECEF(l.lat,u.lng),e.latLngToECEF(c,l.lng),e.latLngToECEF(c,u.lng),e.latLngToECEF(l.lat,h),e.latLngToECEF(u.lat,h)];let y=e.Aabb.fromPoints(g.map(t=>[e.dot(p,t),e.dot(m,t),e.dot(f,t)]));const v=e.transformMat4([],y.center,_);0===e.squaredLength(v)&&e.set(v,0,0,1),e.normalize(v,v),e.scale$2(v,v,e.GLOBE_RADIUS),a.center=e.ecefToLatLng(v);const x=a.getWorldToCameraMatrix(),b=e.invert(new Float64Array(16),x);y=e.Aabb.applyTransform(y,e.multiply([],x,_)),e.transformMat4(v,v,x);const w=.5*(y.max[2]-y.min[2]),T=this._minimumAABBFrustumDistance(a,y),E=e.scale$2([],[0,0,1],w),S=e.add(E,v,E),k=T+(0===a.pitch?0:e.distance(v,S)),C=a.globeCenterInViewSpace,M=e.sub([],v,[C[0],C[1],C[2]]);e.normalize(M,M),e.scale$2(M,M,k);const A=e.add([],v,M);e.transformMat4(A,A,b);const I=e.earthRadius/e.GLOBE_RADIUS,z=e.length(A),P=e.mercatorZfromAltitude(z*I-e.earthRadius,0),O=Math.min(a.zoomFromMercatorZAdjusted(P),s.maxZoom);return O>.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"mercator"}),a.zoom=O,this._cameraForBounds(a,n,r,i,o)):{center:a.center,zoom:O,bearing:i}}queryTerrainElevation(t,n){const r=this.transform.elevation;return r?(n=e.extend({},{exaggerated:!0},n),r.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,r,i,o){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,r,i,o);const a=t.clone(),s=this._extendCameraOptions(o),l=a.padding;a.bearing=i;const u=e.LngLat.convert(n),c=e.LngLat.convert(r),h=new e.LngLat(u.lng,c.lat),d=new e.LngLat(c.lng,u.lat),f=a.project(u),p=a.project(c),m=this.queryTerrainElevation(u),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=[[f.x,f.y,Math.min(m||0,_||0,g||0,y||0)],[p.x,p.y,Math.max(m||0,_||0,g||0,y||0)]];let x=e.Aabb.fromPoints(v);const b=a.getWorldToCameraMatrix(),w=e.invert(new Float64Array(16),b);x=e.Aabb.applyTransform(x,b);const T=e.sub([],x.max,x.min),E=l.left||0,S=l.right||0,k=l.bottom||0,C=l.top||0,{left:M,right:A,top:I,bottom:z}=s.padding,P=.5*(E+S),O=.5*(C+k),D=Math.min(a.scaleZoom(a.scale*Math.min((a.width-(E+S+M+A))/T[0],(a.height-(k+C+z+I))/T[1])),s.maxZoom),L=a.scale/a.zoomScale(D);x=new e.Aabb([x.min[0]-(M+P)*L,x.min[1]-(z+O)*L,x.min[2]],[x.max[0]+(A+P)*L,x.max[1]+(I+O)*L,x.max[2]]);const R=.5*T[2],B=this._minimumAABBFrustumDistance(a,x),F=[0,0,1,0];e.transformMat4$1(F,F,b),e.normalize$2(F,F);const j=e.scale$2([],F,B+R),U=e.add([],x.center,j),V=("number"==typeof s.offset.x&&"number"==typeof s.offset.y?new e.pointGeometry(s.offset.x,s.offset.y):e.pointGeometry.convert(s.offset)).rotate(-e.degToRad(i));x.center[0]-=V.x*L,x.center[1]+=V.y*L,e.transformMat4(x.center,x.center,w),e.transformMat4(U,U,w);const N=[x.center[0],x.center[1],U[2]*a.pixelsPerMeter];e.scale$2(N,N,1/a.worldSize);const G=e.lngFromMercatorX(N[0]),q=e.latFromMercatorY(N[1]),$=Math.min(a._zoomFromMercatorZ(N[2]),s.maxZoom),Z=new e.LngLat(G,q);return a.mercatorFromTransition&&$<.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(a.setProjection({name:"globe"}),a.zoom=$,this._cameraForBounds(a,n,r,i,o)):{center:Z,zoom:$,bearing:i}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(t,n,r,i,o){const a=e.pointGeometry.convert(t),s=e.pointGeometry.convert(n),l=new e.pointGeometry(Math.min(a.x,s.x),Math.min(a.y,s.y)),u=new e.pointGeometry(Math.max(a.x,s.x),Math.max(a.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,s))return this;const c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),d=this.transform.pointLocation3D(new e.pointGeometry(l.x,u.y)),f=this.transform.pointLocation3D(new e.pointGeometry(u.x,l.y)),p=[Math.min(c.lng,h.lng,d.lng,f.lng),Math.min(c.lat,h.lat,d.lat,f.lat)],m=[Math.max(c.lng,h.lng,d.lng,f.lng),Math.max(c.lat,h.lat,d.lat,f.lat)],_=this._cameraForBounds(this.transform,p,m,r,i);return this._fitInternal(_,i,o)}_fitInternal(t,n,r){return t?(delete(n=e.extend(t,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(t,n){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let i=!1,o=!1,a=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(i=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.LngLat.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(a=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),i&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),o&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),a&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Hi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.warnOnce(Hi),this;this.stop();const i=r.zoom,o=r.pitch,a=r.bearing;r.setFreeCameraOptions(t);const s=i!==r.zoom,l=o!==r.pitch,u=a!==r.bearing;return this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),s&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),u&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),l&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||!t.essential&&e.exported.prefersReducedMotion)&&(t.duration=0);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?+t.zoom:i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=e.pointGeometry.convert(t.offset);let f,p,m;if("globe"===r.projection.name){const n=e.MercatorCoordinate.fromLngLat(r.center),i=d.rotate(-r.angle);n.x+=i.x/r.worldSize,n.y+=i.y/r.worldSize;const o=n.toLngLat(),a=e.LngLat.convert(t.center||o);this._normalizeCenter(a),f=r.centerPoint.add(i),p=new e.pointGeometry(n.x,n.y).mult(r.worldSize),m=new e.pointGeometry(e.mercatorXfromLng(a.lng),e.mercatorYfromLat(a.lat)).mult(r.worldSize).sub(p)}else{f=r.centerPoint.add(d);const n=r.pointLocation(f),i=e.LngLat.convert(t.center||n);this._normalizeCenter(i),p=r.project(n),m=r.project(i).sub(p)}const _=r.zoomScale(l-i);let g,y;t.around&&(g=e.LngLat.convert(t.around),y=r.locationPoint(g));const v=this._zooming||l!==i,x=this._rotating||o!==u,b=this._pitching||c!==a,w=!r.isPaddingEqual(h),T=r=>T=>{if(v&&(r.zoom=e.number(i,l,T)),x&&(r.bearing=e.number(o,u,T)),b&&(r.pitch=e.number(a,c,T)),w&&(r.interpolatePadding(s,h,T),f=r.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-i),t=l>i?Math.min(2,_):Math.max(.5,_),n=Math.pow(t,1-T),o=r.unproject(p.add(m.mult(T*n)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,f)}return t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(T,t.duration,r);return this._preloadTiles(e),this}const E={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,E),this._ease(T(r),e=>{r.recenterOnTerrain(),this._afterEase(n,e)},t),this}_prepareEase(t,n,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||r.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.Event("zoomend",t)),i&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,n){if(!t.essential&&e.exported.prefersReducedMotion){const r=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,n)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,r.minZoom,r.maxZoom):i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=r.zoomScale(l-i),f=e.pointGeometry.convert(t.offset);let p=r.centerPoint.add(f);const m=r.pointLocation(p),_=e.LngLat.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let v=t.curve;const x=Math.max(r.width,r.height),b=x/d,w=y.mag();if("minZoom"in t){const n=e.clamp(Math.min(t.minZoom,i,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(n-i);v=Math.sqrt(o/w*2)}const T=v*v;function E(e){const t=(b*b-x*x+(e?-1:1)*T*T*w*w)/(2*(e?b:x)*T*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function k(e){return(Math.exp(e)+Math.exp(-e))/2}const C=E(0);let M=function(e){return k(C)/k(C+v*e)},A=function(e){return x*((k(C)*(S(t=C+v*e)/k(t))-S(C))/T)/w;var t},I=(E(1)-C)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,n);const e=bt.maxDuration&&(t.duration=0);const z=o!==u,P=c!==a,O=!r.isPaddingEqual(h),D=r=>d=>{const m=d*I,v=1/M(m);r.zoom=1===d?l:i+r.scaleZoom(v),z&&(r.bearing=e.number(o,u,d)),P&&(r.pitch=e.number(a,c,d)),O&&(r.interpolatePadding(s,h,d),p=r.centerPoint.add(f));const x=1===d?_:r.unproject(g.add(y.mult(A(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,p),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(D,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=z,this._pitching=P,this._padding=O,this._prepareEase(n,!1),this._ease(D(r),()=>this._afterEase(n),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,n,r){!1===r.animate||0===r.duration?(t(1),n()):(this._easeStart=e.exported.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.wrap(t,-180,180);const r=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_emulate(e,t,n){const r=Math.ceil(15*t/1e3),i=[],o=e(n.clone());for(let e=0;e<=r;e++){const t=o(e/r);i.push(t.clone())}return i}}class Ki{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const n=this._map._getUIString("AttributionControl."+t);e.setAttribute("aria-label",n),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const r=n.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length),e=e.filter((t,n)=>{for(let r=n+1;r=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Ji{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Qi{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(const t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function eo(t,n,r){if(t=new e.LngLat(t.lng,t.lat),n){const i=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint(t).distSqr(n),l=n.x<0||n.y<0||n.x>r.width||n.y>r.height;r.locationPoint(i).distSqr(n)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const to={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class no extends e.Evented{constructor(t,n){if(super(),(t instanceof e.window.HTMLElement||n)&&(t=e.extend({element:t},n)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,r=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${n}`},this._element),s=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},s),a("stop",{offset:"100%","stop-opacity":.05},s),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},i),a("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.pointGeometry.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const r=this._element.classList;for(const e in to)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,n=13.5,r=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(n);let i;t._showingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=""+i,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${to[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,n=this._map,r=this.getPitchAlignment();if(!n||!t||"map"!==r)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?`rotateX(${e}deg)`:""}const i=e.radToDeg(e.globeTiltAtLngLat(n.transform,this._lngLat)),o=t.sub(e.globeCenterToScreenPoint(n.transform)),a=Math.abs(o.x)+Math.abs(o.y);if(0===a)return"";const s=i/a;return`rotateX(${-o.y*s}deg) rotateY(${o.x*s}deg)`}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let r=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.radToDeg(Math.atan2(i.y,i.x))-90}else r=-n.getBearing();else if("horizon"===i){const i=e.smoothstep(4,6,n.getZoom()),o=e.globeCenterToScreenPoint(n.transform);o.y+=i*n.transform.height;const a=t.sub(o),s=e.radToDeg(Math.atan2(a.y,a.x));r=(s>90?s-270:s+90)*(1-i)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),n._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){const n=this._map;if(!n)return;const r=this._pointerdownPos,i=this._positionDelta;if(r&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const n=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}const so={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},lo={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0};function uo(e){e.parentNode&&e.parentNode.removeChild(e)}const co={showCompass:!0,showZoom:!0,visualizePitch:!1};class ho{constructor(t,n,r=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new wi({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new Ti({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),c()}move(e,t){const n=this.map,r=this.mouseRotate.mousemoveWindow(e,t),i=r&&r.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),i=r&&r.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=e*i+"px",this._container.innerHTML=`${r} ${o}`})}function _o(e){const t=Math.pow(10,(""+Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}const go={version:e.version,supported:n,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends Yi{constructor(t){if(e.LivePerformanceUtils.mark(e.PerformanceMarkers.create),null!=(t=e.extend({},lo,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Kr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Qi,this._domRenderTaskQueue=new Qi,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.uniqueId(),this._locale=e.extend({},so,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new ao(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Xi(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Qr("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Ki({customAttribution:t.customAttribution})),this._logoControl=new Ji,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.Event(t.dataType+"data",t))}),this.on("dataloading",t=>{this.fire(new e.Event(t.dataType+"dataloading",t))})}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),n&&this.fire(new e.Event("moveend",t)),this}getBounds(){return"globe"===this.transform.projection.name&&e.warnOnce('Globe projection does not support getBounds API, this API may behave unexpectedly when viewing the poles."'),this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?e.window.navigator.language:Array.isArray(t)?0===t.length?void 0:t.map(t=>"auto"===t?e.window.navigator.language:t):t}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style._reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let r;"globe"===n&&t.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(t.setMercatorFromTransition(),r=!0):"mercator"===n&&t.zoom=e.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e)),a=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];a.length?r||(r=!0,n.call(this,new ui(e,this,i.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e));(o.length?this.queryRenderedFeatures(i.point,{layers:o}):[]).length?r=!0:r&&(r=!1,n.call(this,new ui(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new ui(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),i=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:r}}}}on(e,t,n){if(void 0===n)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{t?this.fire(new e.ErrorEvent(t)):r&&this._updateDiff(r,n)})}else"object"==typeof t&&this._updateDiff(t,n)}_updateDiff(t,n){try{this.style.setState(t)&&this._update(!0)}catch(r){e.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,n,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap){const{width:l,height:u,data:c}=e.exported.getImageData(n);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:u}=n,c=n;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,n){const r=this.style.getImage(t);if(!r)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?e.exported.getImageData(n):n,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),(t,r)=>{n(t,r instanceof e.window.HTMLImageElement?e.exported.getImageData(r):r)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const t=e.window.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=i?Math.abs(t/i):t,this._containerHeight=o?Math.abs(n/o):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=o("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const r=e.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(n),this._canvas.style.width=t+"px",this._canvas.style.height=n+"px"}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);r?(e.storeAuthState(r,!0),this.painter=new Fr(r,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.exported$1.testSupport(r)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;const r=this.painter.context.extTimerQuery,i=e.exported.now();if(this.listens("gpu-timing-frame")&&(n=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],e.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],e.window.performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();let o=!1;const a=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,r=e.exported.now();this.style.zoomHistory.update(t,r);const i=new e.EvaluationParameters(t,{now:r,fadeDuration:a,pitch:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),s=i.crossFadingFactor();1===s&&s===this._crossFadingFactor||(o=!0,this._crossFadingFactor=s),this.style.update(i)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let s=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),s=this._updateAverageElevation(i),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):s=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,a,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:a,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&(this.style.hasTransitions()||o)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.exported.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,n),setTimeout(()=>{const o=r.getQueryObjectEXT(n,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(n),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:o}})},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:n}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:n}))},50)}const l=this._sourcesDirty||this._styleDirty||this._placementDirty||s;if(l||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(s=this._updateAverageElevation(i,!0)),s)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||l||(this._fullyLoaded=!0,e.LivePerformanceUtils.mark(e.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&e.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.painter.transform.projection,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),i=!1;this.transform.elevation&&(i=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(r),n(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),n(r)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Ji&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){this.painter.updateTerrain(this.style,this.isMoving()||this.isRotating()||this.isZooming())}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,r=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,r),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let r=n[1]-n[0];const i=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const n=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(n,(e,n)=>e._preloadTiles(t,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===e.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,n){e.setCacheLimits(t,n)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},co,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),n=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new ho(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const n=o("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl."+t);e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},fo,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Jr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){const n=(e=!!this.options.geolocation)=>{this._supportsGeolocation=e,t(e)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then(e=>n("denied"!==e.state)).catch(()=>n()):n()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=this._map.getBearing(),o=e.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,n=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*n);this._circleElement.style.width=r+"px",this._circleElement.style.height=r+"px"}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new no({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new no({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))})}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Ki,ScaleControl:class{constructor(t){this.options=e.extend({},po,t),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(e){return!1}}()||(this._setScale=mo.bind(this)),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,r=t._containerWidth/2-e/2,i=t.unproject([r,n]),o=t.unproject([r+e,n]),a=i.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){const r=_o(t),i=r/t;this._map._requestDomTask(()=>{this._container.style.width=e*i+"px",this._container.innerHTML="nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:n}).format(r):r+" nm"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(ro),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const n=e.window.document.createDocumentFragment(),r=e.window.document.createElement("body");let i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,r=this._pos;if(!t||!n||!r)return"bottom";const i=n.offsetWidth,o=n.offsetHeight,a=r.xt.transform.width-i/2;if(r.y+et.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push("mapboxgl-popup-anchor-"+this._anchor),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,r=this._content;if(!n||!this._lngLat&&!this._trackPointer||!r)return;let i=this._container;if(i||(i=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",i),i.appendChild(r)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=eo(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),r=oo(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=oo(this.options.offset,i),a=e.add(o).round();n._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${to[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&n._showingGlobe()){const t=e.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(io);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=""+e),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:no,Style:en,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.pointGeometry,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Gr,Evented:e.Evented,config:e.config,prewarm:function(){Ve().acquire(Fe)},clearPrewarmedResources:function(){const e=Ue;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Fe),Ue=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return je.workerCount},set workerCount(e){je.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return go})),r}()}).call(this,n(26))},function(e,t,n){"use strict";n(47);var r=n(0),i=n(15),o=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,a=Object(i.a)((function(e){return o.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}));function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t96?d:f},m=function(e,t,n){var r;if(t){var i=t.shouldForwardProp;r=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},_=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;Object(u.c)(t,n,r);Object(h.a)((function(){return Object(u.b)(t,n,r)}));return null},g=function e(t,n){var i,o,a=t.__emotion_real===t,h=a&&t.__emotion_base||t;void 0!==n&&(i=n.label,o=n.target);var d=m(t,n,a),f=d||p(h),g=!f("as");return function(){var y=arguments,v=a&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==i&&v.push("label:"+i+";"),null==y[0]||void 0===y[0].raw)v.push.apply(v,y);else{0,v.push(y[0][0]);for(var x=y.length,b=1;b1?t-1:0),r=1;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var U=Symbol("mobx-stored-annotations");function V(e){return Object.assign((function(t,n){N(t,n,e)}),e)}function N(e,t,n){I(e,U)||w(e,U,D({},e[U])),function(e){return"override"===e.annotationType_}(n)||(e[U][t]=n)}var G=Symbol("mobx administration"),q=function(){function e(e){void 0===e&&(e="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ve.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return dt(this)},t.reportChanged=function(){ct(),ft(this),ht()},t.toString=function(){return this.name_},e}(),$=E("Atom",q);function Z(e,t,n){void 0===t&&(t=_),void 0===n&&(n=_);var r,i=new q(e);return t!==_&&zt("onBO",i,t,r),n!==_&&It(i,n),i}var W={identity:function(e,t){return e===t},structural:function(e,t){return qn(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?0!==e||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return qn(e,t,1)}};function X(e,t,n){return Vt(e)?e:Array.isArray(e)?Se.array(e,{name:n}):x(e)?Se.object(e,void 0,{name:n}):S(e)?Se.map(e,{name:n}):k(e)?Se.set(e,{name:n}):"function"!=typeof e||kt(e)||jt(e)?e:b(e)?Bt(e):St(n,e)}function H(e){return e}function Y(e,t){return{annotationType_:e,options_:t,make_:K,extend_:J}}function K(e,t,n,r){var i;if(null!=(i=this.options_)&&i.bound)return null===this.extend_(e,t,n,!1)?0:1;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(kt(n.value))return 1;var o=Q(e,this,t,n,!1);return l(r,t,o),2}function J(e,t,n,r){var i=Q(e,this,t,n);return e.defineProperty_(t,i,r)}function Q(e,t,n,r,i){var o,a,s,l,u,c,h,d;void 0===i&&(i=at.safeDescriptors),d=r,t.annotationType_,d.value;var f,p=r.value;null!=(o=t.options_)&&o.bound&&(p=p.bind(null!=(f=e.proxy_)?f:e.target_));return{value:De(null!=(a=null==(s=t.options_)?void 0:s.name)?a:n.toString(),p,null!=(l=null==(u=t.options_)?void 0:u.autoAction)&&l,null!=(c=t.options_)&&c.bound?null!=(h=e.proxy_)?h:e.target_:void 0),configurable:!i||e.isPlainObject_,enumerable:!1,writable:!i}}function ee(e,t){return{annotationType_:e,options_:t,make_:te,extend_:ne}}function te(e,t,n,r){var i;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(null!=(i=this.options_)&&i.bound&&(!I(e.target_,t)||!jt(e.target_[t]))&&null===this.extend_(e,t,n,!1))return 0;if(jt(n.value))return 1;var o=re(e,this,t,n,!1,!1);return l(r,t,o),2}function ne(e,t,n,r){var i,o=re(e,this,t,n,null==(i=this.options_)?void 0:i.bound);return e.defineProperty_(t,o,r)}function re(e,t,n,r,i,o){var a;void 0===o&&(o=at.safeDescriptors),a=r,t.annotationType_,a.value;var s,l=r.value;(jt(l)||(l=Bt(l)),i)&&((l=l.bind(null!=(s=e.proxy_)?s:e.target_)).isMobXFlow=!0);return{value:l,configurable:!o||e.isPlainObject_,enumerable:!1,writable:!o}}function ie(e,t){return{annotationType_:e,options_:t,make_:oe,extend_:ae}}function oe(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ae(e,t,n,r){return function(e,t,n,r){t.annotationType_,r.get;0}(0,this,0,n),e.defineComputedProperty_(t,D({},this.options_,{get:n.get,set:n.set}),r)}function se(e,t){return{annotationType_:e,options_:t,make_:le,extend_:ue}}function le(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ue(e,t,n,r){var i,o;return function(e,t,n,r){t.annotationType_;0}(0,this),e.defineObservableProperty_(t,n.value,null!=(i=null==(o=this.options_)?void 0:o.enhancer)?i:X,r)}var ce=he();function he(e){return{annotationType_:"true",options_:e,make_:de,extend_:fe}}function de(e,t,n,r){var i,o,a,s;if(n.get)return Me.make_(e,t,n,r);if(n.set){var u=De(t.toString(),n.set);return r===e.target_?null===e.defineProperty_(t,{configurable:!at.safeDescriptors||e.isPlainObject_,set:u})?0:2:(l(r,t,{configurable:!0,set:u}),2)}if(r!==e.target_&&"function"==typeof n.value)return b(n.value)?(null!=(s=this.options_)&&s.autoBind?Bt.bound:Bt).make_(e,t,n,r):(null!=(a=this.options_)&&a.autoBind?St.bound:St).make_(e,t,n,r);var c,h=!1===(null==(i=this.options_)?void 0:i.deep)?Se.ref:Se;"function"==typeof n.value&&null!=(o=this.options_)&&o.autoBind&&(n.value=n.value.bind(null!=(c=e.proxy_)?c:e.target_));return h.make_(e,t,n,r)}function fe(e,t,n,r){var i,o,a;if(n.get)return Me.extend_(e,t,n,r);if(n.set)return e.defineProperty_(t,{configurable:!at.safeDescriptors||e.isPlainObject_,set:De(t.toString(),n.set)},r);"function"==typeof n.value&&null!=(i=this.options_)&&i.autoBind&&(n.value=n.value.bind(null!=(a=e.proxy_)?a:e.target_));return(!1===(null==(o=this.options_)?void 0:o.deep)?Se.ref:Se).extend_(e,t,n,r)}var pe={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};function me(e){return e||pe}Object.freeze(pe);var _e=se("observable"),ge=se("observable.ref",{enhancer:H}),ye=se("observable.shallow",{enhancer:function(e,t,n){return null==e||Cn(e)||dn(e)||yn(e)||bn(e)?e:Array.isArray(e)?Se.array(e,{name:n,deep:!1}):x(e)?Se.object(e,void 0,{name:n,deep:!1}):S(e)?Se.map(e,{name:n,deep:!1}):k(e)?Se.set(e,{name:n,deep:!1}):void 0}}),ve=se("observable.struct",{enhancer:function(e,t){return qn(e,t)?t:e}}),xe=V(_e);function be(e){return!0===e.deep?X:!1===e.deep?H:(t=e.defaultDecorator)&&null!=(n=null==(r=t.options_)?void 0:r.enhancer)?n:X;var t,n,r}function we(e,t,n){if(!y(t))return Vt(e)?e:x(e)?Se.object(e,t,n):Array.isArray(e)?Se.array(e,t):S(e)?Se.map(e,t):k(e)?Se.set(e,t):"object"==typeof e&&null!==e?e:Se.box(e,t);N(e,t,_e)}Object.assign(we,xe);var Te,Ee,Se=a(we,{box:function(e,t){var n=me(t);return new Ue(e,be(n),n.name,!0,n.equals)},array:function(e,t){var n=me(t);return(!1===at.useProxies||!1===n.proxy?jn:nn)(e,be(n),n.name)},map:function(e,t){var n=me(t);return new gn(e,be(n),n.name)},set:function(e,t){var n=me(t);return new xn(e,be(n),n.name)},object:function(e,t,n){return Pt(!1===at.useProxies||!1===(null==n?void 0:n.proxy)?En({},n):function(e,t){var n,r;return p(),e=En(e,t),null!=(r=(n=e[G]).proxy_)?r:n.proxy_=new Proxy(e,$t)}({},n),e,t)},ref:V(ge),shallow:V(ye),deep:xe,struct:V(ve)}),ke=ie("computed"),Ce=ie("computed.struct",{equals:W.structural}),Me=function(e,t){if(y(t))return N(e,t,ke);if(x(e))return V(ie("computed",e));var n=x(t)?t:{};return n.get=e,n.name||(n.name=e.name||""),new Ge(n)};Object.assign(Me,ke),Me.struct=V(Ce);var Ae,Ie=0,ze=1,Pe=null!=(Te=null==(Ee=s((function(){}),"name"))?void 0:Ee.configurable)&&Te,Oe={value:"action",configurable:!0,writable:!1,enumerable:!1};function De(e,t,n,r){function i(){return Le(e,n,t,r||this,arguments)}return void 0===n&&(n=!1),i.isMobxAction=!0,Pe&&(Oe.value=e,Object.defineProperty(i,"name",Oe)),i}function Le(e,t,n,i,o){var a=function(e,t,n,r){0;var i=at.trackingDerivation,o=!t||!i;ct();var a=at.allowStateChanges;o&&(Je(),a=Be(!0));var s=et(!0),l={runAsAction_:o,prevDerivation_:i,prevAllowStateChanges_:a,prevAllowStateReads_:s,notifySpy_:!1,startTime_:0,actionId_:ze++,parentActionId_:Ie};return Ie=l.actionId_,l}(0,t);try{return n.apply(i,o)}catch(e){throw a.error_=e,e}finally{!function(e){Ie!==e.actionId_&&r(30);Ie=e.parentActionId_,void 0!==e.error_&&(at.suppressReactionErrors=!0);Fe(e.prevAllowStateChanges_),tt(e.prevAllowStateReads_),ht(),e.runAsAction_&&Qe(e.prevDerivation_);0;at.suppressReactionErrors=!1}(a)}}function Re(e,t){var n=Be(e);try{return t()}finally{Fe(n)}}function Be(e){var t=at.allowStateChanges;return at.allowStateChanges=e,t}function Fe(e){at.allowStateChanges=e}Ae=Symbol.toPrimitive;var je,Ue=function(e){function t(t,n,r,i,o){var a;return void 0===r&&(r="ObservableValue"),void 0===i&&(i=!0),void 0===o&&(o=W.default),(a=e.call(this,r)||this).enhancer=void 0,a.name_=void 0,a.equals=void 0,a.hasUnreportedChange_=!1,a.interceptors_=void 0,a.changeListeners_=void 0,a.value_=void 0,a.dehancer=void 0,a.enhancer=n,a.name_=r,a.equals=o,a.value_=n(t,void 0,r),a}L(t,e);var n=t.prototype;return n.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},n.set=function(e){this.value_;if((e=this.prepareNewValue_(e))!==at.UNCHANGED){0,this.setNewValue_(e)}},n.prepareNewValue_=function(e){if(Xe(this),Zt(this)){var t=Xt(this,{object:this,type:Qt,newValue:e});if(!t)return at.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?at.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),Ht(this)&&Kt(this,{type:Qt,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return Wt(this,e)},n.observe_=function(e,t){return t&&e({observableKind:"value",debugObjectName:this.name_,object:this,type:Qt,newValue:this.value_,oldValue:void 0}),Yt(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+"["+this.value_+"]"},n.valueOf=function(){return A(this.get())},n[Ae]=function(){return this.valueOf()},t}(q);je=Symbol.toPrimitive;var Ve,Ne,Ge=function(){function e(e){this.dependenciesState_=Ve.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ve.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new $e(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=Ne.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||r(31),this.derivation=e.get,this.name_=e.name||"ComputedValue",e.set&&(this.setter_=De("ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?W.structural:W.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){!function(e){if(e.lowestObserverState_!==Ve.UP_TO_DATE_)return;e.lowestObserverState_=Ve.POSSIBLY_STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ve.UP_TO_DATE_&&(e.dependenciesState_=Ve.POSSIBLY_STALE_,e.onBecomeStale_())}))}(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.get=function(){if(this.isComputing_&&r(32,this.name_,this.derivation),0!==at.inBatch||0!==this.observers_.size||this.keepAlive_){if(dt(this),We(this)){var e=at.trackingContext;this.keepAlive_&&!e&&(at.trackingContext=this),this.trackAndCompute()&&function(e){if(e.lowestObserverState_===Ve.STALE_)return;e.lowestObserverState_=Ve.STALE_,e.observers_.forEach((function(t){t.dependenciesState_===Ve.POSSIBLY_STALE_?t.dependenciesState_=Ve.STALE_:t.dependenciesState_===Ve.UP_TO_DATE_&&(e.lowestObserverState_=Ve.UP_TO_DATE_)}))}(this),at.trackingContext=e}}else We(this)&&(this.warnAboutUntrackedRead_(),ct(),this.value_=this.computeValue_(!1),ht());var t=this.value_;if(Ze(t))throw t.cause;return t},t.set=function(e){if(this.setter_){this.isRunningSetter_&&r(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter_=!1}}else r(34,this.name_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===Ve.NOT_TRACKING_,n=this.computeValue_(!0),r=t||Ze(e)||Ze(n)||!this.equals_(e,n);return r&&(this.value_=n),r},t.computeValue_=function(e){this.isComputing_=!0;var t,n=Be(!1);if(e)t=He(this,this.derivation,this.scope_);else if(!0===at.disableErrorBoundaries)t=this.derivation.call(this.scope_);else try{t=this.derivation.call(this.scope_)}catch(e){t=new $e(e)}return Fe(n),this.isComputing_=!1,t},t.suspend_=function(){this.keepAlive_||(Ye(this),this.value_=void 0)},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return Ct((function(){var o=n.get();if(!r||t){var a=Je();e({observableKind:"computed",debugObjectName:n.name_,type:Qt,object:n,newValue:o,oldValue:i}),Qe(a)}r=!1,i=o}))},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return A(this.get())},t[je]=function(){return this.valueOf()},e}(),qe=E("ComputedValue",Ge);!function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"}(Ve||(Ve={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(Ne||(Ne={}));var $e=function(e){this.cause=void 0,this.cause=e};function Ze(e){return e instanceof $e}function We(e){switch(e.dependenciesState_){case Ve.UP_TO_DATE_:return!1;case Ve.NOT_TRACKING_:case Ve.STALE_:return!0;case Ve.POSSIBLY_STALE_:for(var t=et(!0),n=Je(),r=e.observing_,i=r.length,o=0;or&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&<(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,st(u,e))}r!==Ve.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),tt(r),i}function Ye(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)lt(t[n],e);e.dependenciesState_=Ve.NOT_TRACKING_}function Ke(e){var t=Je();try{return e()}finally{Qe(t)}}function Je(){var e=at.trackingDerivation;return at.trackingDerivation=null,e}function Qe(e){at.trackingDerivation=e}function et(e){var t=at.allowStateReads;return at.allowStateReads=e,t}function tt(e){at.allowStateReads=e}function nt(e){if(e.dependenciesState_!==Ve.UP_TO_DATE_){e.dependenciesState_=Ve.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ve.UP_TO_DATE_}}var rt=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},it=!0,ot=!1,at=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(it=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new rt).version&&(it=!1),it?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new rt):(setTimeout((function(){ot||r(35)}),1),new rt)}();function st(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function lt(e,t){e.observers_.delete(t),0===e.observers_.size&&ut(e)}function ut(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,at.pendingUnobservations.push(e))}function ct(){at.inBatch++}function ht(){if(0==--at.inBatch){_t();for(var e=at.pendingUnobservations,t=0;t0&&ut(e),!1)}function ft(e){e.lowestObserverState_!==Ve.STALE_&&(e.lowestObserverState_=Ve.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ve.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ve.STALE_})))}var pt=function(){function e(e,t,n,r){void 0===e&&(e="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Ve.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Ne.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,at.pendingReactions.push(this),_t())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){ct(),this.isScheduled_=!1;var e=at.trackingContext;if(at.trackingContext=this,We(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}at.trackingContext=e,ht()}},t.track=function(e){if(!this.isDisposed_){ct();0,this.isRunning_=!0;var t=at.trackingContext;at.trackingContext=this;var n=He(this,e,void 0);at.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&Ye(this),Ze(n)&&this.reportExceptionInDerivation_(n.cause),ht()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(at.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";at.suppressReactionErrors||console.error(n,e),at.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(ct(),Ye(this),ht()))},t.getDisposer_=function(){var e=this.dispose.bind(this);return e[G]=this,e},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1),function(){r("trace() is not available in production builds");for(var e=!1,t=arguments.length,n=new Array(t),i=0;i0||at.isRunningReactions||mt(gt)}function gt(){at.isRunningReactions=!0;for(var e=at.pendingReactions,t=0;e.length>0;){100==++t&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r",t,e):g(n)?De(t,n,e):y(n)?N(t,n,e?bt:vt):y(t)?V(Y(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Et=Tt(!1);Object.assign(Et,vt);var St=Tt(!0);function kt(e){return g(e)&&!0===e.isMobxAction}function Ct(e,t){var n,r;void 0===t&&(t=h);var i,o=null!=(n=null==(r=t)?void 0:r.name)?n:"Autorun";if(!t.scheduler&&!t.delay)i=new pt(o,(function(){this.track(l)}),t.onError,t.requiresObservable);else{var a=At(t),s=!1;i=new pt(o,(function(){s||(s=!0,a((function(){s=!1,i.isDisposed_||i.track(l)})))}),t.onError,t.requiresObservable)}function l(){e(i)}return i.schedule_(),i.getDisposer_()}Object.assign(St,bt),Et.bound=V(xt),St.bound=V(wt);var Mt=function(e){return e()};function At(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Mt}function It(e,t,n){return zt("onBUO",e,t,n)}function zt(e,t,n,r){var i="function"==typeof r?Un(t,n):Un(t),o=g(r)?r:n,a=e+"L";return i[a]?i[a].add(o):i[a]=new Set([o]),function(){var e=i[a];e&&(e.delete(o),0===e.size&&delete i[a])}}function Pt(e,t,n,r){var i=z(t),o=En(e,r)[G];ct();try{M(i).forEach((function(e){o.extend_(e,i[e],!n||(!(e in n)||n[e]))}))}finally{ht()}return e}var Ot=0;function Dt(){this.message="FLOW_CANCELLED"}Dt.prototype=Object.create(Error.prototype);var Lt=ee("flow"),Rt=ee("flow.bound",{bound:!0}),Bt=Object.assign((function(e,t){if(y(t))return N(e,t,Lt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++Ot,a=Et(r+" - runid: "+o+" - init",n).apply(t,i),s=void 0,l=new Promise((function(t,n){var i=0;function l(e){var t;s=void 0;try{t=Et(r+" - runid: "+o+" - yield "+i++,a.next).call(a,e)}catch(e){return n(e)}c(t)}function u(e){var t;s=void 0;try{t=Et(r+" - runid: "+o+" - yield "+i++,a.throw).call(a,e)}catch(e){return n(e)}c(t)}function c(e){if(!g(null==e?void 0:e.then))return e.done?t(e.value):(s=Promise.resolve(e.value)).then(l,u);e.then(c,n)}e=n,l(void 0)}));return l.cancel=Et(r+" - runid: "+o+" - cancel",(function(){try{s&&Ft(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(_,_),Ft(n),e(new Dt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Lt);function Ft(e){g(e.cancel)&&e.cancel()}function jt(e){return!0===(null==e?void 0:e.isMobXFlow)}function Ut(e,t){return!!e&&(void 0!==t?!!Cn(e)&&e[G].values_.has(t):Cn(e)||!!e[G]||$(e)||yt(e)||qe(e))}function Vt(e){return Ut(e)}function Nt(e){switch(e.length){case 0:return at.trackingDerivation;case 1:return Un(e[0]);case 2:return Un(e[0],e[1])}}function Gt(e,t){void 0===t&&(t=void 0),ct();try{return e.apply(t)}finally{ht()}}function qt(e){return e[G]}Bt.bound=V(Rt);var $t={has:function(e,t){return qt(e).has_(t)},get:function(e,t){return qt(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=qt(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=qt(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=qt(e).defineProperty_(t,n))||r},ownKeys:function(e){return qt(e).ownKeys_()},preventExtensions:function(e){r(13)}};function Zt(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function Wt(e,t){var n=e.interceptors_||(e.interceptors_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Xt(e,t){var n=Je();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function Yt(e,t){var n=e.changeListeners_||(e.changeListeners_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Kt(e,t){var n=Je(),r=e.changeListeners_;if(r){for(var i=0,o=(r=r.slice()).length;i0?e.map(this.dehancer):e},t.intercept_=function(e){return Wt(this,e)},t.observe_=function(e,t){return void 0===t&&(t=!1),t&&e({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Yt(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){("number"!=typeof e||isNaN(e)||e<0)&&r("Out of range: "+e);var t=this.values_.length;if(e!==t)if(e>t){for(var n=new Array(e-t),i=0;i0&&Fn(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;this.atom_;var i=this.values_.length;if(void 0===e?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=1===arguments.length?i-e:null==t?0:Math.max(0,Math.min(t,i-e)),void 0===n&&(n=c),Zt(this)){var o=Xt(this,{object:this.proxy_,type:"splice",index:e,removedCount:t,added:n});if(!o)return c;t=o.removedCount,n=o.added}if(n=0===n.length?n:n.map((function(e){return r.enhancer_(e,void 0)})),this.legacyMode_){var a=n.length-t;this.updateArrayLength_(i,a)}var s=this.spliceItemsIntoValues_(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){var r;if(n.length<1e4)return(r=this.values_).splice.apply(r,[e,t].concat(n));var i=this.values_.slice(e,e+t),o=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var a=0;a=this.values_.length))return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e]);console.warn("[mobx] Out of bounds read: "+e)},t.set_=function(e,t){var n=this.values_;if(this.legacyMode_&&e>n.length&&r(17,e,n.length),e2?n-2:0),i=2;i-1&&(this.splice(n,1),!0)}};function on(e,t){"function"==typeof Array.prototype[e]&&(rn[e]=t(e))}function an(e){return function(){var t=this[G];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function sn(e){return function(t,n){var r=this,i=this[G];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function ln(e){return function(){var t=this,n=this[G];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}on("concat",an),on("flat",an),on("includes",an),on("indexOf",an),on("join",an),on("lastIndexOf",an),on("slice",an),on("toString",an),on("toLocaleString",an),on("every",sn),on("filter",sn),on("find",sn),on("findIndex",sn),on("flatMap",sn),on("forEach",sn),on("map",sn),on("some",sn),on("reduce",ln),on("reduceRight",ln);var un,cn,hn=E("ObservableArrayAdministration",tn);function dn(e){return v(e)&&hn(e[G])}var fn={},pn="add";un=Symbol.iterator,cn=Symbol.toStringTag;var mn,_n,gn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[G]=fn,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,g(Map)||r(18),this.keysAtom_=Z("ObservableMap.keys()"),this.data_=new Map,this.hasMap_=new Map,Re(!0,(function(){i.merge(e)}))}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!at.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new Ue(this.has_(e),H,"ObservableMap.key?",!1);this.hasMap_.set(e,r),It(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if(Zt(this)){var r=Xt(this,{type:n?Qt:pn,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if((this.keysAtom_,Zt(this))&&!Xt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Ht(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Gt((function(){var n;t.keysAtom_.reportChanged(),null==(n=t.hasMap_.get(e))||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)})),n&&Kt(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==at.UNCHANGED){var r=Ht(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:Qt,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&Kt(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Gt((function(){var r,i=new Ue(t,n.enhancer_,"ObservableMap.key",!1);n.data_.set(e,i),t=i.value_,null==(r=n.hasMap_.get(e))||r.setNewValue_(!0),n.keysAtom_.reportChanged()}));var r=Ht(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:pn,object:this,name:e,newValue:t}:null;r&&Kt(this,i)},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[un]=function(){return this.entries()},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value,o=i[0],a=i[1];e.call(t,a,o,this)}},t.merge=function(e){var t=this;return yn(e)&&(e=new Map(e)),Gt((function(){x(e)?function(e){var t=Object.keys(e);if(!C)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return u.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],r=e[1];return t.set(n,r)})):S(e)?(e.constructor!==Map&&r(19,e),e.forEach((function(e,n){return t.set(n,e)}))):null!=e&&r(20,e)})),this},t.clear=function(){var e=this;Gt((function(){Ke((function(){for(var t,n=j(e.keys());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.replace=function(e){var t=this;return Gt((function(){for(var n,i=function(e){if(S(e)||yn(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}return r(21,e)}(e),o=new Map,a=!1,s=j(t.data_.keys());!(n=s()).done;){var l=n.value;if(!i.has(l))if(t.delete(l))a=!0;else{var u=t.data_.get(l);o.set(l,u)}}for(var c,h=j(i.entries());!(c=h()).done;){var d=c.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var _=t.data_.get(f);o.set(f,_),m||(a=!0)}}if(!a)if(t.data_.size!==o.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),y=o.keys(),v=g.next(),b=y.next();!v.done;){if(v.value!==b.value){t.keysAtom_.reportChanged();break}v=g.next(),b=y.next()}t.data_=o})),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return Yt(this,e)},t.intercept_=function(e){return Wt(this,e)},O(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:cn,get:function(){return"Map"}}]),e}(),yn=E("ObservableMap",gn);var vn={};mn=Symbol.iterator,_n=Symbol.toStringTag;var xn=function(){function e(e,t,n){void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[G]=vn,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,g(Set)||r(22),this.atom_=Z(this.name_),this.enhancer_=function(e,r){return t(e,r,n)},e&&this.replace(e)}var t=e.prototype;return t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.clear=function(){var e=this;Gt((function(){Ke((function(){for(var t,n=j(e.data_.values());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if((this.atom_,Zt(this))&&!Xt(this,{type:pn,object:this,newValue:e}))return this;if(!this.has(e)){Gt((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Ht(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:pn,object:this,newValue:e}:null;0,n&&Kt(this,r)}return this},t.delete=function(e){var t=this;if(Zt(this)&&!Xt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Ht(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Gt((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&Kt(this,r),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=0,t=Array.from(this.keys()),n=Array.from(this.values());return Zn({next:function(){var r=e;return e+=1,rOn){for(var t=On;t=0&&r++}t=$n(t),n=$n(n);var l="[object Array]"===s;if(!l){if("object"!=typeof t||"object"!=typeof n)return!1;var u=t.constructor,c=n.constructor;if(u!==c&&!(g(u)&&u instanceof u&&g(c)&&c instanceof c)&&"constructor"in t&&"constructor"in n)return!1}if(0===r)return!1;r<0&&(r=-1);o=o||[];var h=(i=i||[]).length;for(;h--;)if(i[h]===t)return o[h]===n;if(i.push(t),o.push(n),l){if((h=t.length)!==n.length)return!1;for(;h--;)if(!e(t[h],n[h],r-1,i,o))return!1}else{var d,f=Object.keys(t);if(h=f.length,Object.keys(n).length!==h)return!1;for(;h--;)if(d=f[h],!I(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function $n(e){return dn(e)?e.slice():S(e)||yn(e)||k(e)||bn(e)?Array.from(e.entries()):e}function Zn(e){return e[Symbol.iterator]=Wn,e}function Wn(){return this}["Symbol","Map","Set"].forEach((function(e){void 0===o()[e]&&r("MobX requires global '"+e+"' to be available or polyfilled")})),"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:function(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}},extras:{getDebugName:Nn},$mobx:G})}).call(this,n(19))},function(e,t,n){"use strict";t.a=function(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}},function(e,t,n){"use strict";t.a=function(e){var t=new WeakMap;return function(n){if(t.has(n))return t.get(n);var r=e(n);return t.set(n,r),r}}},function(e,t,n){"use strict";var r=function(){function e(e){var t=this;this._insertTag=function(e){var n;n=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,n),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var n=function(e){if(e.sheet)return e.sheet;for(var t=0;t2||B(A)>3?"":" "}function N(e,t){for(;--t&&O()&&!(A<48||A>102||A>57&&A<65||A>70&&A<97););return R(e,L()+(t<6&&32==D()&&32==O()))}function G(e,t){for(;O()&&e+A!==57&&(e+A!==84||47!==D()););return"/*"+R(t,M-1)+"*"+d(47===e?e:O())}function q(e){for(;!B(D());)O();return R(e,M)}function $(e){return j(function e(t,n,r,i,o,a,s,l,u){var c=0,h=0,f=s,p=0,m=0,_=0,x=1,w=1,E=1,C=0,z="",P=o,R=a,B=i,F=z;for(;w;)switch(_=C,C=O()){case 40:if(108!=_&&58==v(F,f-1)){-1!=y(F+=g(U(C),"&","&\f"),"&\f")&&(E=-1);break}case 34:case 39:case 91:F+=U(C);break;case 9:case 10:case 13:case 32:F+=V(_);break;case 92:F+=N(L()-1,7);continue;case 47:switch(D()){case 42:case 47:T(W(G(O(),L()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*E;case 125*x:case 59:case 0:switch(C){case 0:case 125:w=0;case 59+h:m>0&&b(F)-f&&T(m>32?X(F+";",i,r,f-1):X(g(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(T(B=Z(F,n,r,c,h,o,l,z,P=[],R=[],f),a),123===C)if(0===h)e(F,n,B,B,P,a,f,l,R);else switch(99===p&&110===v(F,3)?100:p){case 100:case 109:case 115:e(t,B,B,i&&T(Z(t,B,B,0,0,o,l,z,o,P=[],f),R),o,R,f,l,i?P:R);break;default:e(F,B,B,B,[""],R,0,l,R)}}c=h=m=0,x=E=1,z=F="",f=s;break;case 58:f=1+b(F),m=_;default:if(x<1)if(123==C)--x;else if(125==C&&0==x++&&125==(A=M>0?v(I,--M):0,k--,10===A&&(k=1,S--),A))continue;switch(F+=d(C),C*x){case 38:E=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*E,E=1;break;case 64:45===D()&&(F+=U(O())),p=D(),h=f=b(z=F+=q(L())),C++;break;case 45:45===_&&2==b(F)&&(x=0)}}return a}("",null,null,null,[""],e=F(e),0,[0],e))}function Z(e,t,n,r,i,o,a,s,u,c,d){for(var f=i-1,p=0===i?o:[""],_=w(p),y=0,v=0,b=0;y0?p[T]+" "+E:g(E,/&\f/g,p[T])))&&(u[b++]=S);return z(e,t,n,0===i?l:s,u,c,d)}function W(e,t,n){return z(e,t,n,s,d(A),x(e,2,-2),0)}function X(e,t,n,r){return z(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function H(e,t){for(var n="",r=w(e),i=0;i-1&&!e.return)switch(e.type){case u:e.return=function e(t,n){switch(p(t,n)){case 5103:return a+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return a+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return a+t+o+t+i+t+t;case 6828:case 4268:return a+t+i+t+t;case 6165:return a+t+i+"flex-"+t+t;case 5187:return a+t+g(t,/(\w+).+(:[^]+)/,a+"box-$1$2"+i+"flex-$1$2")+t;case 5443:return a+t+i+"flex-item-"+g(t,/flex-|-self/,"")+t;case 4675:return a+t+i+"flex-line-pack"+g(t,/align-content|flex-|-self/,"")+t;case 5548:return a+t+i+g(t,"shrink","negative")+t;case 5292:return a+t+i+g(t,"basis","preferred-size")+t;case 6060:return a+"box-"+g(t,"-grow","")+a+t+i+g(t,"grow","positive")+t;case 4554:return a+g(t,/([^-])(transform)/g,"$1"+a+"$2")+t;case 6187:return g(g(g(t,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),t,"")+t;case 5495:case 3959:return g(t,/(image-set\([^]*)/,a+"$1$`$1");case 4968:return g(g(t,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+i+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+a+t+t;case 4095:case 3583:case 4068:case 2532:return g(t,/(.+)-inline(.+)/,a+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(b(t)-1-n>6)switch(v(t,n+1)){case 109:if(45!==v(t,n+4))break;case 102:return g(t,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3$1"+o+(108==v(t,n+3)?"$3":"$2-$3"))+t;case 115:return~y(t,"stretch")?e(g(t,"stretch","fill-available"),n)+t:t}break;case 4949:if(115!==v(t,n+1))break;case 6444:switch(v(t,b(t)-3-(~y(t,"!important")&&10))){case 107:return g(t,":",":"+a)+t;case 101:return g(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+a+(45===v(t,14)?"inline-":"")+"box$3$1"+a+"$2$3$1"+i+"$2box$3")+t}break;case 5936:switch(v(t,n+11)){case 114:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return a+t+i+t+t}return t}(e.value,e.length);break;case c:return H([P(e,{value:g(e.value,"@","@"+a)})],r);case l:if(e.length)return E(e.props,(function(t){switch(_(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return H([P(e,{props:[g(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return H([P(e,{props:[g(t,/:(plac\w+)/,":"+a+"input-$1")]}),P(e,{props:[g(t,/:(plac\w+)/,":-moz-$1")]}),P(e,{props:[g(t,/:(plac\w+)/,i+"input-$1")]})],r)}return""}))}}];t.a=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||re;var o,a,s={},l=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n=0||(i[n]=e[n]);return i}n.d(t,"a",(function(){return r}))},function(e,t,n){var r; +(window.webpackJsonp=window.webpackJsonp||[]).push([[2],[function(e,t,n){"use strict";e.exports=n(41)},function(e,t,n){"use strict";n.d(t,"a",(function(){return u})),n.d(t,"b",(function(){return c})),n.d(t,"c",(function(){return l})),n.d(t,"d",(function(){return h}));var r=n(0),i=(n(17),n(5)),o=(n(52),n(16),n(25),n(6)),a=n(9),s=n(8),l=function(e,t){var n=arguments;if(null==t||!i.e.call(t,"css"))return r.createElement.apply(void 0,n);var o=n.length,a=new Array(o);a[0]=i.b,a[1]=Object(i.d)(e,t);for(var s=2;s=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)},i={animationIterationCount:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},o=n(15),a=/[A-Z]|^ms/g,s=/_EMO_([^_]+?)_([^]*?)_EMO_/g,l=function(e){return 45===e.charCodeAt(1)},u=function(e){return null!=e&&"boolean"!=typeof e},c=Object(o.a)((function(e){return l(e)?e:e.replace(a,"-$&").toLowerCase()})),h=function(e,t){switch(e){case"animation":case"animationName":if("string"==typeof t)return t.replace(s,(function(e,t,n){return f={name:t,styles:n,next:f},t}))}return 1===i[e]||l(e)||"number"!=typeof t||0===t?t:t+"px"};function d(e,t,n){if(null==n)return"";if(void 0!==n.__emotion_styles)return n;switch(typeof n){case"boolean":return"";case"object":if(1===n.anim)return f={name:n.name,styles:n.styles,next:f},n.name;if(void 0!==n.styles){var r=n.next;if(void 0!==r)for(;void 0!==r;)f={name:r.name,styles:r.styles,next:f},r=r.next;return n.styles+";"}return function(e,t,n){var r="";if(Array.isArray(n))for(var i=0;i1)return 1;for(var n=e,r=0;r<8;r++){var i=this.sampleCurveX(n)-e;if(Math.abs(i)i?a=n:s=n,n=.5*(s-a)+a;return n},solve:function(e,t){return this.sampleCurveY(this.solveCurveX(e,t))}};var m=_;function _(e,t){this.x=e,this.y=t}_.prototype={clone:function(){return new _(this.x,this.y)},add:function(e){return this.clone()._add(e)},sub:function(e){return this.clone()._sub(e)},multByPoint:function(e){return this.clone()._multByPoint(e)},divByPoint:function(e){return this.clone()._divByPoint(e)},mult:function(e){return this.clone()._mult(e)},div:function(e){return this.clone()._div(e)},rotate:function(e){return this.clone()._rotate(e)},rotateAround:function(e,t){return this.clone()._rotateAround(e,t)},matMult:function(e){return this.clone()._matMult(e)},unit:function(){return this.clone()._unit()},perp:function(){return this.clone()._perp()},round:function(){return this.clone()._round()},mag:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},equals:function(e){return this.x===e.x&&this.y===e.y},dist:function(e){return Math.sqrt(this.distSqr(e))},distSqr:function(e){var t=e.x-this.x,n=e.y-this.y;return t*t+n*n},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(e){return Math.atan2(this.y-e.y,this.x-e.x)},angleWith:function(e){return this.angleWithSep(e.x,e.y)},angleWithSep:function(e,t){return Math.atan2(this.x*t-this.y*e,this.x*e+this.y*t)},_matMult:function(e){var t=e[2]*this.x+e[3]*this.y;return this.x=e[0]*this.x+e[1]*this.y,this.y=t,this},_add:function(e){return this.x+=e.x,this.y+=e.y,this},_sub:function(e){return this.x-=e.x,this.y-=e.y,this},_mult:function(e){return this.x*=e,this.y*=e,this},_div:function(e){return this.x/=e,this.y/=e,this},_multByPoint:function(e){return this.x*=e.x,this.y*=e.y,this},_divByPoint:function(e){return this.x/=e.x,this.y/=e.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var e=this.y;return this.y=this.x,this.x=-e,this},_rotate:function(e){var t=Math.cos(e),n=Math.sin(e),r=n*this.x+t*this.y;return this.x=t*this.x-n*this.y,this.y=r,this},_rotateAround:function(e,t){var n=Math.cos(e),r=Math.sin(e),i=t.y+r*(this.x-t.x)+n*(this.y-t.y);return this.x=t.x+n*(this.x-t.x)-r*(this.y-t.y),this.y=i,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},_.convert=function(e){return e instanceof _?e:Array.isArray(e)?new _(e[0],e[1]):e};const g=Math.PI/180,y=180/Math.PI;function v(e){return e*g}function x(e){return e*y}const b=[[0,0],[1,0],[1,1],[0,1]];function w(e){if(e<=0)return 0;if(e>=1)return 1;const t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function E(e,t,n,r){const i=new f(e,t,n,r);return function(e){return i.solve(e)}}const T=E(.25,.1,.25,1);function S(e,t,n){return Math.min(n,Math.max(t,e))}function k(e,t,n){return(n=S((n-e)/(t-e),0,1))*n*(3-2*n)}function C(e,t,n){const r=n-t,i=((e-t)%r+r)%r+t;return i===t?n:i}function M(e,t,n){if(!e.length)return n(null,[]);let r=e.length;const i=new Array(e.length);let o=null;e.forEach((e,a)=>{t(e,(e,t)=>{e&&(o=e),i[a]=t,0==--r&&n(o,i)})})}function A(e){const t=[];for(const n in e)t.push(e[n]);return t}function I(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}let P=1;function z(){return P++}function O(){return function e(t){return t?(t^Math.random()*(16>>t/4)).toString(16):([1e7]+-[1e3]+-4e3+-8e3+-1e11).replace(/[018]/g,e)}()}function D(e){return e<=1?1:Math.pow(2,Math.ceil(Math.log(e)/Math.LN2))}function L(e){return!!e&&/^[0-9a-f]{8}-[0-9a-f]{4}-[4][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(e)}function R(e,t){e.forEach(e=>{t[e]&&(t[e]=t[e].bind(t))})}function B(e,t){return-1!==e.indexOf(t,e.length-t.length)}function F(e,t,n){const r={};for(const i in e)r[i]=t.call(n||this,e[i],i,e);return r}function j(e,t,n){const r={};for(const i in e)t.call(n||this,e[i],i,e)&&(r[i]=e[i]);return r}function N(e){return Array.isArray(e)?e.map(N):"object"==typeof e&&e?F(e,N):e}const U={};function V(e){U[e]||("undefined"!=typeof console&&console.warn(e),U[e]=!0)}function G(e,t,n){return(n.y-e.y)*(t.x-e.x)>(t.y-e.y)*(n.x-e.x)}function q(e){let t=0;for(let n,r,i=0,o=e.length,a=o-1;i@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(e,n,r,i)=>{const o=r||i;return t[n]=!o||o.toLowerCase(),""}),t["max-age"]){const e=parseInt(t["max-age"],10);isNaN(e)?delete t["max-age"]:t["max-age"]=e}return t}let W=null;function X(e){if(null==W){const t=e.navigator?e.navigator.userAgent:null;W=!!e.safari||!(!t||!(/\b(iPad|iPhone|iPod)\b/.test(t)||t.match("Safari")&&!t.match("Chrome")))}return W}function H(e){try{const t=n[e];return t.setItem("_mapbox_test_",1),t.removeItem("_mapbox_test_"),!0}catch(e){return!1}}function Y(e,t){return[e[4*t],e[4*t+1],e[4*t+2],e[4*t+3]]}const K="mapbox-tiles";let J,Q,ee=500,te=50;function ne(){try{return n.caches}catch(e){}}function re(){ne()&&!J&&(J=n.caches.open(K))}function ie(e){const t=e.indexOf("?");if(t<0)return e;const n=function(e){const t=e.indexOf("?");return t>0?e.slice(t+1).split("&"):[]}(e).filter(e=>{const t=e.split("=");return"language"===t[0]||"worldview"===t[0]});return n.length?`${e.slice(0,t)}?${n.join("&")}`:e.slice(0,t)}let oe=1/0;const ae={Unknown:"Unknown",Style:"Style",Source:"Source",Tile:"Tile",Glyphs:"Glyphs",SpriteImage:"SpriteImage",SpriteJSON:"SpriteJSON",Image:"Image"};"function"==typeof Object.freeze&&Object.freeze(ae);class se extends Error{constructor(e,t,n){401===t&&ye(n)&&(e+=": you may have provided an invalid Mapbox access token. See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes"),super(e),this.status=t,this.url=n}toString(){return`${this.name}: ${this.message} (${this.status}): ${this.url}`}}const le=$()?()=>self.worker&&self.worker.referrer:()=>("blob:"===n.location.protocol?n.parent:n).location.href,ue=function(e,t){if(!(/^file:/.test(r=e.url)||/^file:/.test(le())&&!/^\w+:/.test(r))){if(n.fetch&&n.Request&&n.AbortController&&n.Request.prototype.hasOwnProperty("signal"))return function(e,t){const r=new n.AbortController,i=new n.Request(e.url,{method:e.method||"GET",body:e.body,credentials:e.credentials,headers:e.headers,referrer:le(),signal:r.signal});let o=!1,a=!1;const s=(l=i.url).indexOf("sku=")>0&&ye(l);var l;"json"===e.type&&i.headers.set("Accept","application/json");const u=(r,o,l)=>{if(a)return;if(r&&"SecurityError"!==r.message&&V(r),o&&l)return c(o);const u=Date.now();n.fetch(i).then(n=>{if(n.ok){const e=s?n.clone():null;return c(n,e,u)}return t(new se(n.statusText,n.status,e.url))}).catch(e=>{20!==e.code&&t(new Error(e.message))})},c=(r,s,l)=>{("arrayBuffer"===e.type?r.arrayBuffer():"json"===e.type?r.json():r.text()).then(e=>{a||(s&&l&&function(e,t,r){if(re(),!J)return;const i={status:t.status,statusText:t.statusText,headers:new n.Headers};t.headers.forEach((e,t)=>i.headers.set(t,e));const o=Z(t.headers.get("Cache-Control")||"");if(o["no-store"])return;o["max-age"]&&i.headers.set("Expires",new Date(r+1e3*o["max-age"]).toUTCString());const a=i.headers.get("Expires");a&&(new Date(a).getTime()-r<42e4||function(e,t){if(void 0===Q)try{new Response(new ReadableStream),Q=!0}catch(e){Q=!1}Q?t(e.body):e.blob().then(t)}(t,t=>{const r=new n.Response(t,i);re(),J&&J.then(t=>t.put(ie(e.url),r)).catch(e=>V(e.message))}))}(i,s,l),o=!0,t(null,e,r.headers.get("Cache-Control"),r.headers.get("Expires")))}).catch(e=>{a||t(new Error(e.message))})};return s?function(e,t){if(re(),!J)return t(null);const n=ie(e.url);J.then(e=>{e.match(n).then(r=>{const i=function(e){if(!e)return!1;const t=new Date(e.headers.get("Expires")||0),n=Z(e.headers.get("Cache-Control")||"");return t>Date.now()&&!n["no-cache"]}(r);e.delete(n),i&&e.put(n,r.clone()),t(null,r,i)}).catch(t)}).catch(t)}(i,u):u(null,null),{cancel:()=>{a=!0,o||r.abort()}}}(e,t);if($()&&self.worker&&self.worker.actor)return self.worker.actor.send("getResource",e,t,void 0,!0)}var r;return function(e,t){const r=new n.XMLHttpRequest;r.open(e.method||"GET",e.url,!0),"arrayBuffer"===e.type&&(r.responseType="arraybuffer");for(const t in e.headers)r.setRequestHeader(t,e.headers[t]);return"json"===e.type&&(r.responseType="text",r.setRequestHeader("Accept","application/json")),r.withCredentials="include"===e.credentials,r.onerror=()=>{t(new Error(r.statusText))},r.onload=()=>{if((r.status>=200&&r.status<300||0===r.status)&&null!==r.response){let n=r.response;if("json"===e.type)try{n=JSON.parse(r.response)}catch(e){return t(e)}t(null,n,r.getResponseHeader("Cache-Control"),r.getResponseHeader("Expires"))}else t(new se(r.statusText,r.status,e.url))},r.send(e.body),{cancel:()=>r.abort()}}(e,t)},ce=function(e,t){return ue(I(e,{type:"arrayBuffer"}),t)};function he(e){const t=n.document.createElement("a");return t.href=e,t.protocol===n.document.location.protocol&&t.host===n.document.location.host}const de="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=";let fe,pe;fe=[],pe=0;const me=function(e,t){if(a.supported&&(e.headers||(e.headers={}),e.headers.accept="image/webp,*/*"),pe>=o.MAX_PARALLEL_IMAGE_REQUESTS){const n={requestParameters:e,callback:t,cancelled:!1,cancel(){this.cancelled=!0}};return fe.push(n),n}pe++;let r=!1;const i=()=>{if(!r)for(r=!0,pe--;fe.length&&pe{i(),e?t(e):r&&(n.createImageBitmap?function(e,t){const r=new n.Blob([new Uint8Array(e)],{type:"image/png"});n.createImageBitmap(r).then(e=>{t(null,e)}).catch(e=>{t(new Error(`Could not load image because of ${e.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`))})}(r,(e,n)=>t(e,n,o,a)):function(e,t){const r=new n.Image,i=n.URL;r.onload=()=>{t(null,r),i.revokeObjectURL(r.src),r.onload=null,n.requestAnimationFrame(()=>{r.src=de})},r.onerror=()=>t(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const o=new n.Blob([new Uint8Array(e)],{type:"image/png"});r.src=e.byteLength?i.createObjectURL(o):de}(r,(e,n)=>t(e,n,o,a)))});return{cancel:()=>{s.cancel(),i()}}},_e="NO_ACCESS_TOKEN";function ge(e){return 0===e.indexOf("mapbox:")}function ye(e){return o.API_URL_REGEX.test(e)}function ve(e){return o.API_CDN_URL_REGEX.test(e)}function xe(e){return o.API_STYLE_REGEX.test(e)&&!be(e)}function be(e){return o.API_SPRITE_REGEX.test(e)}const we=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function Ee(e){const t=e.match(we);if(!t)throw new Error("Unable to parse URL object");return{protocol:t[1],authority:t[2],path:t[3]||"/",params:t[4]?t[4].split("&"):[]}}function Te(e){const t=e.params.length?"?"+e.params.join("&"):"";return`${e.protocol}://${e.authority}${e.path}${t}`}function Se(e){if(!e)return null;const t=e.split(".");if(!t||3!==t.length)return null;try{return JSON.parse(decodeURIComponent(n.atob(t[1]).split("").map(e=>"%"+("00"+e.charCodeAt(0).toString(16)).slice(-2)).join("")))}catch(e){return null}}class ke{constructor(e){this.type=e,this.anonId=null,this.eventData={},this.queue=[],this.pendingRequest=null}getStorageKey(e){const t=Se(o.ACCESS_TOKEN);let r="";return r=t&&t.u?n.btoa(encodeURIComponent(t.u).replace(/%([0-9A-F]{2})/g,(e,t)=>String.fromCharCode(Number("0x"+t)))):o.ACCESS_TOKEN||"",e?`mapbox.eventData.${e}:${r}`:"mapbox.eventData:"+r}fetchEventData(){const e=H("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{const e=n.localStorage.getItem(t);e&&(this.eventData=JSON.parse(e));const i=n.localStorage.getItem(r);i&&(this.anonId=i)}catch(e){V("Unable to read from LocalStorage")}}saveEventData(){const e=H("localStorage"),t=this.getStorageKey(),r=this.getStorageKey("uuid");if(e)try{n.localStorage.setItem(r,this.anonId),Object.keys(this.eventData).length>=1&&n.localStorage.setItem(t,JSON.stringify(this.eventData))}catch(e){V("Unable to write to LocalStorage")}}processRequests(e){}postEvent(e,t,n,r){if(!o.EVENTS_URL)return;const i=Ee(o.EVENTS_URL);i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={event:this.type,created:new Date(e).toISOString()},s=t?I(a,t):a,l={url:Te(i),headers:{"Content-Type":"text/plain"},body:JSON.stringify([s])};this.pendingRequest=function(e,t){return ue(I(e,{method:"POST"}),t)}(l,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}queueRequest(e,t){this.queue.push(e),this.processRequests(t)}}const Ce=new class extends ke{constructor(e){super("appUserTurnstile"),this._customAccessToken=e}postTurnstileEvent(e,t){o.EVENTS_URL&&o.ACCESS_TOKEN&&Array.isArray(e)&&e.some(e=>ge(e)||ye(e))&&this.queueRequest(Date.now(),t)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;this.anonId&&this.eventData.lastSuccess&&this.eventData.tokenU||this.fetchEventData();const t=Se(o.ACCESS_TOKEN),n=t?t.u:o.ACCESS_TOKEN;let i=n!==this.eventData.tokenU;L(this.anonId)||(this.anonId=O(),i=!0);const a=this.queue.shift();if(this.eventData.lastSuccess){const e=new Date(this.eventData.lastSuccess),t=new Date(a),n=(a-this.eventData.lastSuccess)/864e5;i=i||n>=1||n<-1||e.getDate()!==t.getDate()}else i=!0;i?this.postEvent(a,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,"enabled.telemetry":!1,userId:this.anonId},e=>{e||(this.eventData.lastSuccess=a,this.eventData.tokenU=n)},e):this.processRequests()}},Me=Ce.postTurnstileEvent.bind(Ce),Ae=new class extends ke{constructor(){super("map.load"),this.success={},this.skuToken=""}postMapLoadEvent(e,t,n,r){this.skuToken=t,this.errorCb=r,o.EVENTS_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(_e)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||(this.anonId||this.fetchEventData(),L(this.anonId)||(this.anonId=O()),this.postEvent(n,{sdkIdentifier:"mapbox-gl-js",sdkVersion:r,skuId:d,skuToken:this.skuToken,userId:this.anonId},e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e))}},Ie=Ae.postMapLoadEvent.bind(Ae),Pe=new class extends ke{constructor(){super("gljs.performance")}postPerformanceEvent(e,t){o.EVENTS_URL&&(e||o.ACCESS_TOKEN)&&this.queueRequest({timestamp:Date.now(),performanceData:t},e)}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{timestamp:t,performanceData:i}=this.queue.shift(),o=function(e){const t=n.performance.getEntriesByType("resource"),i=n.performance.getEntriesByType("mark"),o=function(e){const t={};if(e)for(const n in e)if("other"!==n)for(const r of e[n]){const e=n+"ResolveRangeMin",i=n+"ResolveRangeMax",o=n+"RequestCount",a=n+"RequestCachedCount";t[e]=Math.min(t[e]||1/0,r.startTime),t[i]=Math.max(t[i]||-1/0,r.responseEnd);const s=e=>{void 0===t[e]&&(t[e]=0),++t[e]};void 0!==r.transferSize&&0===r.transferSize&&s(a),s(o)}return t}(function(e,t){const n={};if(e)for(const r of e){const e=t(r);void 0===n[e]&&(n[e]=[]),n[e].push(r)}return n}(t,Fe)),a=n.devicePixelRatio,s=n.navigator.connection||n.navigator.mozConnection||n.navigator.webkitConnection,l={counters:[],metadata:[],attributes:[]},u=(e,t,n)=>{null!=n&&e.push({name:t,value:n.toString()})};for(const e in o)u(l.counters,e,o[e]);if(e.interactionRange[0]!==1/0&&e.interactionRange[1]!==-1/0&&(u(l.counters,"interactionRangeMin",e.interactionRange[0]),u(l.counters,"interactionRangeMax",e.interactionRange[1])),i)for(const e of Object.keys(Re)){const t=Re[e],n=i.find(e=>e.name===t);n&&u(l.counters,t,n.startTime)}return u(l.counters,"visibilityHidden",e.visibilityHidden),u(l.attributes,"style",function(e){if(e)for(const t of e){const e=t.name.split("?")[0];if(xe(e)){const t=e.split("/").slice(-2);if(2===t.length)return`mapbox://styles/${t[0]}/${t[1]}`}}}(t)),u(l.attributes,"terrainEnabled",e.terrainEnabled?"true":"false"),u(l.attributes,"fogEnabled",e.fogEnabled?"true":"false"),u(l.attributes,"projection",e.projection),u(l.attributes,"zoom",e.zoom),u(l.metadata,"devicePixelRatio",a),u(l.metadata,"connectionEffectiveType",s?s.effectiveType:void 0),u(l.metadata,"navigatorUserAgent",n.navigator.userAgent),u(l.metadata,"screenWidth",n.screen.width),u(l.metadata,"screenHeight",n.screen.height),u(l.metadata,"windowWidth",n.innerWidth),u(l.metadata,"windowHeight",n.innerHeight),u(l.metadata,"mapWidth",e.width/a),u(l.metadata,"mapHeight",e.height/a),u(l.metadata,"webglRenderer",e.renderer),u(l.metadata,"webglVendor",e.vendor),u(l.metadata,"sdkVersion",r),u(l.metadata,"sdkIdentifier","mapbox-gl-js"),l}(i);for(const e of o.metadata);for(const e of o.counters);for(const e of o.attributes);this.postEvent(t,o,()=>{},e)}},ze=Pe.postPerformanceEvent.bind(Pe),Oe=new class extends ke{constructor(){super("map.auth"),this.success={},this.skuToken=""}getSession(e,t,n,r){if(!o.API_URL||!o.SESSION_PATH)return;const i=Ee(o.API_URL+o.SESSION_PATH);i.params.push("sku="+(t||"")),i.params.push("access_token="+(r||o.ACCESS_TOKEN||""));const a={url:Te(i),headers:{"Content-Type":"text/plain"}};this.pendingRequest=function(e,t){return ue(I(e,{method:"GET"}),t)}(a,e=>{this.pendingRequest=null,n(e),this.saveEventData(),this.processRequests(r)})}getSessionAPI(e,t,n,r){this.skuToken=t,this.errorCb=r,o.SESSION_PATH&&o.API_URL&&(n||o.ACCESS_TOKEN?this.queueRequest({id:e,timestamp:Date.now()},n):this.errorCb(new Error(_e)))}processRequests(e){if(this.pendingRequest||0===this.queue.length)return;const{id:t,timestamp:n}=this.queue.shift();t&&this.success[t]||this.getSession(n,this.skuToken,e=>{e?this.errorCb(e):t&&(this.success[t]=!0)},e)}},De=Oe.getSessionAPI.bind(Oe),Le=new Set,Re={create:"create",load:"load",fullLoad:"fullLoad"},Be={mark(e){n.performance.mark(e)},measure(e,t,r){n.performance.measure(e,t,r)}};function Fe(e){const t=e.name.split("?")[0];return ve(t)&&t.includes("mapbox-gl.js")?"javascript":ve(t)&&t.includes("mapbox-gl.css")?"css":function(e){return o.API_FONTS_REGEX.test(e)}(t)?"fontRange":be(t)?"sprite":xe(t)?"style":function(e){return o.API_TILEJSON_REGEX.test(e)}(t)?"tilejson":"other"}const je=n.performance;function Ne(e){const t=e?e.url.toString():void 0;return je.getEntriesByName(t)}let Ue,Ve,Ge,qe;const $e={now:()=>void 0!==Ge?Ge:n.performance.now(),setNow(e){Ge=e},restoreNow(){Ge=void 0},frame(e){const t=n.requestAnimationFrame(e);return{cancel:()=>n.cancelAnimationFrame(t)}},getImageData(e,t=0){const{width:r,height:i}=e;qe||(qe=n.document.createElement("canvas"));const o=qe.getContext("2d",{willReadFrequently:!0});if(!o)throw new Error("failed to create canvas 2d context");return(r>qe.width||i>qe.height)&&(qe.width=r,qe.height=i),o.clearRect(-t,-t,r+2*t,i+2*t),o.drawImage(e,0,0,r,i),o.getImageData(-t,-t,r+2*t,i+2*t)},resolveURL:e=>(Ue||(Ue=n.document.createElement("a")),Ue.href=e,Ue.href),get devicePixelRatio(){return n.devicePixelRatio},get prefersReducedMotion(){return!!n.matchMedia&&(null==Ve&&(Ve=n.matchMedia("(prefers-reduced-motion: reduce)")),Ve.matches)}};function Ze(e,t,n){n[e]&&-1!==n[e].indexOf(t)||(n[e]=n[e]||[],n[e].push(t))}function We(e,t,n){if(n&&n[e]){const r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}class Xe{constructor(e,t={}){I(this,t),this.type=e}}class He extends Xe{constructor(e,t={}){super("error",I({error:e},t))}}class Ye{on(e,t){return this._listeners=this._listeners||{},Ze(e,t,this._listeners),this}off(e,t){return We(e,t,this._listeners),We(e,t,this._oneTimeListeners),this}once(e,t){return t?(this._oneTimeListeners=this._oneTimeListeners||{},Ze(e,t,this._oneTimeListeners),this):new Promise(t=>this.once(e,t))}fire(e,t){"string"==typeof e&&(e=new Xe(e,t||{}));const n=e.type;if(this.listens(n)){e.target=this;const t=this._listeners&&this._listeners[n]?this._listeners[n].slice():[];for(const n of t)n.call(this,e);const r=this._oneTimeListeners&&this._oneTimeListeners[n]?this._oneTimeListeners[n].slice():[];for(const t of r)We(n,t,this._oneTimeListeners),t.call(this,e);const i=this._eventedParent;i&&(I(e,"function"==typeof this._eventedParentData?this._eventedParentData():this._eventedParentData),i.fire(e))}else e instanceof He&&console.error(e.error);return this}listens(e){return!!(this._listeners&&this._listeners[e]&&this._listeners[e].length>0||this._oneTimeListeners&&this._oneTimeListeners[e]&&this._oneTimeListeners[e].length>0||this._eventedParent&&this._eventedParent.listens(e))}setEventedParent(e,t){return this._eventedParent=e,this._eventedParentData=t,this}}var Ke=JSON.parse('{"$version":8,"$root":{"version":{"required":true,"type":"enum","values":[8]},"name":{"type":"string"},"metadata":{"type":"*"},"center":{"type":"array","value":"number"},"zoom":{"type":"number"},"bearing":{"type":"number","default":0,"period":360,"units":"degrees"},"pitch":{"type":"number","default":0,"units":"degrees"},"light":{"type":"light"},"terrain":{"type":"terrain"},"fog":{"type":"fog"},"sources":{"required":true,"type":"sources"},"sprite":{"type":"string"},"glyphs":{"type":"string"},"transition":{"type":"transition"},"projection":{"type":"projection"},"layers":{"required":true,"type":"array","value":"layer"}},"sources":{"*":{"type":"source"}},"source":["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],"source_vector":{"type":{"required":true,"type":"enum","values":{"vector":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"attribution":{"type":"string"},"promoteId":{"type":"promoteId"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster":{"type":{"required":true,"type":"enum","values":{"raster":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"scheme":{"type":"enum","values":{"xyz":{},"tms":{}},"default":"xyz"},"attribution":{"type":"string"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_raster_dem":{"type":{"required":true,"type":"enum","values":{"raster-dem":{}}},"url":{"type":"string"},"tiles":{"type":"array","value":"string"},"bounds":{"type":"array","value":"number","length":4,"default":[-180,-85.051129,180,85.051129]},"minzoom":{"type":"number","default":0},"maxzoom":{"type":"number","default":22},"tileSize":{"type":"number","default":512,"units":"pixels"},"attribution":{"type":"string"},"encoding":{"type":"enum","values":{"terrarium":{},"mapbox":{}},"default":"mapbox"},"volatile":{"type":"boolean","default":false},"*":{"type":"*"}},"source_geojson":{"type":{"required":true,"type":"enum","values":{"geojson":{}}},"data":{"type":"*"},"maxzoom":{"type":"number","default":18},"attribution":{"type":"string"},"buffer":{"type":"number","default":128,"maximum":512,"minimum":0},"filter":{"type":"*"},"tolerance":{"type":"number","default":0.375},"cluster":{"type":"boolean","default":false},"clusterRadius":{"type":"number","default":50,"minimum":0},"clusterMaxZoom":{"type":"number"},"clusterMinPoints":{"type":"number"},"clusterProperties":{"type":"*"},"lineMetrics":{"type":"boolean","default":false},"generateId":{"type":"boolean","default":false},"promoteId":{"type":"promoteId"}},"source_video":{"type":{"required":true,"type":"enum","values":{"video":{}}},"urls":{"required":true,"type":"array","value":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"source_image":{"type":{"required":true,"type":"enum","values":{"image":{}}},"url":{"required":true,"type":"string"},"coordinates":{"required":true,"type":"array","length":4,"value":{"type":"array","length":2,"value":"number"}}},"layer":{"id":{"type":"string","required":true},"type":{"type":"enum","values":{"fill":{},"line":{},"symbol":{},"circle":{},"heatmap":{},"fill-extrusion":{},"raster":{},"hillshade":{},"background":{},"sky":{}},"required":true},"metadata":{"type":"*"},"source":{"type":"string"},"source-layer":{"type":"string"},"minzoom":{"type":"number","minimum":0,"maximum":24},"maxzoom":{"type":"number","minimum":0,"maximum":24},"filter":{"type":"filter"},"layout":{"type":"layout"},"paint":{"type":"paint"}},"layout":["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],"layout_background":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_sky":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill":{"fill-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_circle":{"circle-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_heatmap":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_fill-extrusion":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"},"fill-extrusion-edge-radius":{"type":"number","private":true,"default":0,"minimum":0,"maximum":1,"property-type":"constant"}},"layout_line":{"line-cap":{"type":"enum","values":{"butt":{},"round":{},"square":{}},"default":"butt","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-join":{"type":"enum","values":{"bevel":{},"round":{},"miter":{}},"default":"miter","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{"type":"number","default":2,"requires":[{"line-join":"miter"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-round-limit":{"type":"number","default":1.05,"requires":[{"line-join":"round"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_symbol":{"symbol-placement":{"type":"enum","values":{"point":{},"line":{},"line-center":{}},"default":"point","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-spacing":{"type":"number","default":250,"minimum":1,"units":"pixels","requires":[{"symbol-placement":"line"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{"type":"boolean","default":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{"type":"number","expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{"type":"enum","values":{"auto":{},"viewport-y":{},"source":{}},"default":"auto","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{"type":"boolean","default":false,"requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-optional":{"type":"boolean","default":false,"requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-size":{"type":"number","default":1,"minimum":0,"units":"factor of the original icon size","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{"type":"enum","values":{"none":{},"width":{},"height":{},"both":{}},"default":"none","requires":["icon-image","text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{"type":"array","value":"number","length":4,"default":[0,0,0,0],"units":"pixels","requires":["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-image":{"type":"resolvedImage","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{"type":"boolean","default":false,"requires":["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"icon-offset":{"type":"array","value":"number","length":2,"default":[0,0],"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{"type":"enum","values":{"map":{},"viewport":{},"auto":{}},"default":"auto","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-field":{"type":"formatted","default":"","tokens":true,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-font":{"type":"array","value":"string","default":["Open Sans Regular","Arial Unicode MS Regular"],"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-size":{"type":"number","default":16,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{"type":"number","default":10,"minimum":0,"units":"ems","requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{"type":"number","default":1.2,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{"type":"number","default":0,"units":"ems","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-justify":{"type":"enum","values":{"auto":{},"left":{},"center":{},"right":{}},"default":"center","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{"type":"number","units":"ems","default":0,"requires":["text-field"],"property-type":"data-driven","expression":{"interpolated":true,"parameters":["zoom","feature"]}},"text-variable-anchor":{"type":"array","value":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"requires":["text-field",{"symbol-placement":["point"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-anchor":{"type":"enum","values":{"center":{},"left":{},"right":{},"top":{},"bottom":{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},"default":"center","requires":["text-field",{"!":"text-variable-anchor"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{"type":"number","default":45,"units":"degrees","requires":["text-field",{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-writing-mode":{"type":"array","value":"enum","values":{"horizontal":{},"vertical":{}},"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-rotate":{"type":"number","default":0,"period":360,"units":"degrees","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-padding":{"type":"number","default":2,"minimum":0,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-keep-upright":{"type":"boolean","default":true,"requires":["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-transform":{"type":"enum","values":{"none":{},"uppercase":{},"lowercase":{}},"default":"none","requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-offset":{"type":"array","value":"number","units":"ems","length":2,"default":[0,0],"requires":["text-field",{"!":"text-radial-offset"}],"expression":{"interpolated":true,"parameters":["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{"type":"boolean","default":false,"requires":["text-field"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-optional":{"type":"boolean","default":false,"requires":["text-field","icon-image"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_raster":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"layout_hillshade":{"visibility":{"type":"enum","values":{"visible":{},"none":{}},"default":"visible","property-type":"constant"}},"filter":{"type":"array","value":"*"},"filter_symbol":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature","pitch","distance-from-center"]}},"filter_fill":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_line":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_circle":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_fill-extrusion":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_heatmap":{"type":"boolean","default":false,"transition":false,"property-type":"data-driven","expression":{"interpolated":false,"parameters":["zoom","feature"]}},"filter_operator":{"type":"enum","values":{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},"in":{},"!in":{},"all":{},"any":{},"none":{},"has":{},"!has":{},"within":{}}},"geometry_type":{"type":"enum","values":{"Point":{},"LineString":{},"Polygon":{}}},"function":{"expression":{"type":"expression"},"stops":{"type":"array","value":"function_stop"},"base":{"type":"number","default":1,"minimum":0},"property":{"type":"string","default":"$zoom"},"type":{"type":"enum","values":{"identity":{},"exponential":{},"interval":{},"categorical":{}},"default":"exponential"},"colorSpace":{"type":"enum","values":{"rgb":{},"lab":{},"hcl":{}},"default":"rgb"},"default":{"type":"*","required":false}},"function_stop":{"type":"array","minimum":0,"maximum":24,"value":["number","color"],"length":2},"expression":{"type":"array","value":"*","minimum":1},"fog":{"range":{"type":"array","default":[0.5,10],"minimum":-20,"maximum":20,"length":2,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"high-color":{"type":"color","property-type":"data-constant","default":"#245cdf","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"space-color":{"type":"color","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"horizon-blend":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],4,0.2,7,0.1],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"star-intensity":{"type":"number","property-type":"data-constant","default":["interpolate",["linear"],["zoom"],5,0.35,6,0],"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"light":{"anchor":{"type":"enum","default":"viewport","values":{"map":{},"viewport":{}},"property-type":"data-constant","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]}},"position":{"type":"array","default":[1.15,210,30],"length":3,"value":"number","property-type":"data-constant","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]}},"color":{"type":"color","property-type":"data-constant","default":"#ffffff","expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"intensity":{"type":"number","property-type":"data-constant","default":0.5,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true}},"projection":{"name":{"type":"enum","values":{"albers":{},"equalEarth":{},"equirectangular":{},"lambertConformalConic":{},"mercator":{},"naturalEarth":{},"winkelTripel":{},"globe":{}},"default":"mercator","required":true},"center":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-180,-90],"maximum":[180,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]},"parallels":{"type":"array","length":2,"value":"number","property-type":"data-constant","minimum":[-90,-90],"maximum":[90,90],"transition":false,"requires":[{"name":["albers","lambertConformalConic"]}]}},"terrain":{"source":{"type":"string","required":true},"exaggeration":{"type":"number","property-type":"data-constant","default":1,"minimum":0,"maximum":1000,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["source"]}},"paint":["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],"paint_fill":{"fill-antialias":{"type":"boolean","default":true,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{"type":"color","transition":true,"requires":[{"!":"fill-pattern"},{"fill-antialias":true}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"fill-extrusion-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["fill-extrusion-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{"type":"number","default":0,"minimum":0,"units":"meters","transition":true,"requires":["fill-extrusion-height"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{"type":"boolean","default":true,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant","type":"number","private":true,"default":0,"minimum":0,"maximum":1,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant","type":"number","private":true,"default":3,"minimum":0,"expression":{"interpolated":true,"parameters":["zoom"]},"transition":true,"requires":["fill-extrusion-edge-radius"]}},"paint_line":{"line-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"line-pattern"}],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["line-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"line-width":{"type":"number","default":1,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{"type":"number","default":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{"type":"array","value":"number","minimum":0,"transition":false,"units":"line widths","requires":[{"!":"line-pattern"}],"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{"type":"color","transition":false,"requires":[{"!":"line-pattern"},{"source":"geojson","has":{"lineMetrics":true}}],"expression":{"interpolated":true,"parameters":["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{"type":"array","value":"number","length":2,"default":[0,0],"minimum":[0,0],"maximum":[1,1],"transition":false,"requires":[{"source":"geojson","has":{"lineMetrics":true}}],"property-type":"constant"}},"paint_circle":{"circle-radius":{"type":"number","default":5,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{"type":"number","default":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["circle-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"}},"paint_heatmap":{"heatmap-radius":{"type":"number","default":30,"minimum":1,"transition":true,"units":"pixels","expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{"type":"number","default":1,"minimum":0,"transition":false,"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{"type":"number","default":1,"minimum":0,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"heatmap-color":{"type":"color","default":["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",0.1,"royalblue",0.3,"cyan",0.5,"lime",0.7,"yellow",1,"red"],"transition":false,"expression":{"interpolated":true,"parameters":["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_symbol":{"icon-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{"type":"color","default":"#000000","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["icon-image"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["icon-image","icon-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"text-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{"type":"color","default":"#000000","transition":true,"overridable":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{"type":"color","default":"rgba(0, 0, 0, 0)","transition":true,"requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{"type":"number","default":0,"minimum":0,"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{"type":"array","value":"number","length":2,"default":[0,0],"transition":true,"units":"pixels","requires":["text-field"],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"map","requires":["text-field","text-translate"],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_raster":{"raster-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{"type":"number","default":0,"period":360,"transition":true,"units":"degrees","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{"type":"number","default":0,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-saturation":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-contrast":{"type":"number","default":0,"minimum":-1,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"raster-resampling":{"type":"enum","values":{"linear":{},"nearest":{}},"default":"linear","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{"type":"number","default":300,"minimum":0,"transition":false,"units":"milliseconds","expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_hillshade":{"hillshade-illumination-direction":{"type":"number","default":335,"minimum":0,"maximum":359,"transition":false,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{"type":"enum","values":{"map":{},"viewport":{}},"default":"viewport","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{"type":"number","default":0.5,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{"type":"color","default":"#FFFFFF","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{"type":"color","default":"#000000","transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_background":{"background-color":{"type":"color","default":"#000000","transition":true,"requires":[{"!":"background-pattern"}],"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"},"background-pattern":{"type":"resolvedImage","transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"background-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"paint_sky":{"sky-type":{"type":"enum","values":{"gradient":{},"atmosphere":{}},"default":"atmosphere","expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{"type":"array","value":"number","length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"requires":[{"sky-type":"atmosphere"}],"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{"type":"number","requires":[{"sky-type":"atmosphere"}],"default":10,"minimum":0,"maximum":100,"transition":false,"property-type":"data-constant"},"sky-gradient-center":{"type":"array","requires":[{"sky-type":"gradient"}],"value":"number","default":[0,0],"length":2,"units":"degrees","minimum":[0,0],"maximum":[360,180],"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{"type":"number","requires":[{"sky-type":"gradient"}],"default":90,"minimum":0,"maximum":180,"transition":false,"expression":{"interpolated":false,"parameters":["zoom"]},"property-type":"data-constant"},"sky-gradient":{"type":"color","default":["interpolate",["linear"],["sky-radial-progress"],0.8,"#87ceeb",1,"white"],"transition":false,"requires":[{"sky-type":"gradient"}],"expression":{"interpolated":true,"parameters":["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{"type":"color","default":"white","transition":false,"requires":[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{"type":"number","default":1,"minimum":0,"maximum":1,"transition":true,"expression":{"interpolated":true,"parameters":["zoom"]},"property-type":"data-constant"}},"transition":{"duration":{"type":"number","default":300,"minimum":0,"units":"milliseconds"},"delay":{"type":"number","default":0,"minimum":0,"units":"milliseconds"}},"property-type":{"data-driven":{"type":"property-type"},"color-ramp":{"type":"property-type"},"data-constant":{"type":"property-type"},"constant":{"type":"property-type"}},"promoteId":{"*":{"type":"string"}}}');function Je(e,...t){for(const n of t)for(const t in n)e[t]=n[t];return e}function Qe(e){return e instanceof Number||e instanceof String||e instanceof Boolean?e.valueOf():e}function et(e){if(Array.isArray(e))return e.map(et);if(e instanceof Object&&!(e instanceof Number||e instanceof String||e instanceof Boolean)){const t={};for(const n in e)t[n]=et(e[n]);return t}return Qe(e)}class tt extends Error{constructor(e,t){super(t),this.message=t,this.key=e}}var nt=tt;class rt{constructor(e,t=[]){this.parent=e,this.bindings={};for(const[e,n]of t)this.bindings[e]=n}concat(e){return new rt(this,e)}get(e){if(this.bindings[e])return this.bindings[e];if(this.parent)return this.parent.get(e);throw new Error(e+" not found in scope.")}has(e){return!!this.bindings[e]||!!this.parent&&this.parent.has(e)}}var it=rt;const ot={kind:"null"},at={kind:"number"},st={kind:"string"},lt={kind:"boolean"},ut={kind:"color"},ct={kind:"object"},ht={kind:"value"},dt={kind:"collator"},ft={kind:"formatted"},pt={kind:"resolvedImage"};function mt(e,t){return{kind:"array",itemType:e,N:t}}function _t(e){if("array"===e.kind){const t=_t(e.itemType);return"number"==typeof e.N?`array<${t}, ${e.N}>`:"value"===e.itemType.kind?"array":`array<${t}>`}return e.kind}const gt=[ot,at,st,lt,ut,ft,ct,mt(ht),pt];function yt(e,t){if("error"===t.kind)return null;if("array"===e.kind){if("array"===t.kind&&(0===t.N&&"value"===t.itemType.kind||!yt(e.itemType,t.itemType))&&("number"!=typeof e.N||e.N===t.N))return null}else{if(e.kind===t.kind)return null;if("value"===e.kind)for(const e of gt)if(!yt(e,t))return null}return`Expected ${_t(e)} but found ${_t(t)} instead.`}function vt(e,t){return t.some(t=>t.kind===e.kind)}function xt(e,t){return t.some(t=>"null"===t?null===e:"array"===t?Array.isArray(e):"object"===t?e&&!Array.isArray(e)&&"object"==typeof e:t===typeof e)}var bt,wt={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Et(e){return(e=Math.round(e))<0?0:e>255?255:e}function Tt(e){return Et("%"===e[e.length-1]?parseFloat(e)/100*255:parseInt(e))}function St(e){return(t="%"===e[e.length-1]?parseFloat(e)/100:parseFloat(e))<0?0:t>1?1:t;var t}function kt(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}try{bt={}.parseCSSColor=function(e){var t,n=e.replace(/ /g,"").toLowerCase();if(n in wt)return wt[n].slice();if("#"===n[0])return 4===n.length?(t=parseInt(n.substr(1),16))>=0&&t<=4095?[(3840&t)>>4|(3840&t)>>8,240&t|(240&t)>>4,15&t|(15&t)<<4,1]:null:7===n.length&&(t=parseInt(n.substr(1),16))>=0&&t<=16777215?[(16711680&t)>>16,(65280&t)>>8,255&t,1]:null;var r=n.indexOf("("),i=n.indexOf(")");if(-1!==r&&i+1===n.length){var o=n.substr(0,r),a=n.substr(r+1,i-(r+1)).split(","),s=1;switch(o){case"rgba":if(4!==a.length)return null;s=St(a.pop());case"rgb":return 3!==a.length?null:[Tt(a[0]),Tt(a[1]),Tt(a[2]),s];case"hsla":if(4!==a.length)return null;s=St(a.pop());case"hsl":if(3!==a.length)return null;var l=(parseFloat(a[0])%360+360)%360/360,u=St(a[1]),c=St(a[2]),h=c<=.5?c*(u+1):c+u-c*u,d=2*c-h;return[Et(255*kt(d,h,l+1/3)),Et(255*kt(d,h,l)),Et(255*kt(d,h,l-1/3)),s];default:return null}}return null}}catch(e){}class Ct{constructor(e,t,n,r=1){this.r=e,this.g=t,this.b=n,this.a=r}static parse(e){if(!e)return;if(e instanceof Ct)return e;if("string"!=typeof e)return;const t=bt(e);return t?new Ct(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3]):void 0}toString(){const[e,t,n,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(n)},${r})`}toArray(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[255*e/r,255*t/r,255*n/r,r]}toArray01(){const{r:e,g:t,b:n,a:r}=this;return 0===r?[0,0,0,0]:[e/r,t/r,n/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:n,a:r}=this;return[e,t,n,r]}}Ct.black=new Ct(0,0,0,1),Ct.white=new Ct(1,1,1,1),Ct.transparent=new Ct(0,0,0,0),Ct.red=new Ct(1,0,0,1),Ct.blue=new Ct(0,0,1,1);var Mt=Ct;class At{constructor(e,t,n){this.sensitivity=e?t?"variant":"case":t?"accent":"base",this.locale=n,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class It{constructor(e,t,n,r,i){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=n,this.fontStack=r,this.textColor=i}}class Pt{constructor(e){this.sections=e}static fromString(e){return new Pt([new It(e,null,null,null,null)])}isEmpty(){return 0===this.sections.length||!this.sections.some(e=>0!==e.text.length||e.image&&0!==e.image.name.length)}static factory(e){return e instanceof Pt?e:Pt.fromString(e)}toString(){return 0===this.sections.length?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const n={};t.fontStack&&(n["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(n["font-scale"]=t.scale),t.textColor&&(n["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(n)}return e}}class zt{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new zt({name:e,available:!1}):null}serialize(){return["image",this.name]}}function Ot(e,t,n,r){return"number"==typeof e&&e>=0&&e<=255&&"number"==typeof t&&t>=0&&t<=255&&"number"==typeof n&&n>=0&&n<=255?void 0===r||"number"==typeof r&&r>=0&&r<=1?null:`Invalid rgba value [${[e,t,n,r].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${("number"==typeof r?[e,t,n,r]:[e,t,n]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Dt(e){if(null===e)return!0;if("string"==typeof e)return!0;if("boolean"==typeof e)return!0;if("number"==typeof e)return!0;if(e instanceof Mt)return!0;if(e instanceof At)return!0;if(e instanceof Pt)return!0;if(e instanceof zt)return!0;if(Array.isArray(e)){for(const t of e)if(!Dt(t))return!1;return!0}if("object"==typeof e){for(const t in e)if(!Dt(e[t]))return!1;return!0}return!1}function Lt(e){if(null===e)return ot;if("string"==typeof e)return st;if("boolean"==typeof e)return lt;if("number"==typeof e)return at;if(e instanceof Mt)return ut;if(e instanceof At)return dt;if(e instanceof Pt)return ft;if(e instanceof zt)return pt;if(Array.isArray(e)){const t=e.length;let n;for(const t of e){const e=Lt(t);if(n){if(n===e)continue;n=ht;break}n=e}return mt(n||ht,t)}return ct}function Rt(e){const t=typeof e;return null===e?"":"string"===t||"number"===t||"boolean"===t?String(e):e instanceof Mt||e instanceof Pt||e instanceof zt?e.toString():JSON.stringify(e)}class Bt{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(2!==e.length)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Dt(e[1]))return t.error("invalid value");const n=e[1];let r=Lt(n);const i=t.expectedType;return"array"!==r.kind||0!==r.N||!i||"array"!==i.kind||"number"==typeof i.N&&0!==i.N||(r=i),new Bt(r,n)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return"array"===this.type.kind||"object"===this.type.kind?["literal",this.value]:this.value instanceof Mt?["rgba"].concat(this.value.toArray()):this.value instanceof Pt?this.value.serialize():this.value}}var Ft=Bt,jt=class{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}};const Nt={string:st,number:at,boolean:lt,object:ct};class Ut{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let n,r=1;const i=e[0];if("array"===i){let i,o;if(e.length>2){const n=e[1];if("string"!=typeof n||!(n in Nt)||"object"===n)return t.error('The item type argument of "array" must be one of string, number, boolean',1);i=Nt[n],r++}else i=ht;if(e.length>3){if(null!==e[2]&&("number"!=typeof e[2]||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);o=e[2],r++}n=mt(i,o)}else n=Nt[i];const o=[];for(;re.outputDefined())}serialize(){const e=this.type,t=[e.kind];if("array"===e.kind){const n=e.itemType;if("string"===n.kind||"number"===n.kind||"boolean"===n.kind){t.push(n.kind);const r=e.N;("number"==typeof r||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(e=>e.serialize()))}}var Vt=Ut;class Gt{constructor(e){this.type=ft,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[1];if(!Array.isArray(n)&&"object"==typeof n)return t.error("First argument must be an image or text section.");const r=[];let i=!1;for(let n=1;n<=e.length-1;++n){const o=e[n];if(i&&"object"==typeof o&&!Array.isArray(o)){i=!1;let e=null;if(o["font-scale"]&&(e=t.parse(o["font-scale"],1,at),!e))return null;let n=null;if(o["text-font"]&&(n=t.parse(o["text-font"],1,mt(st)),!n))return null;let a=null;if(o["text-color"]&&(a=t.parse(o["text-color"],1,ut),!a))return null;const s=r[r.length-1];s.scale=e,s.font=n,s.textColor=a}else{const o=t.parse(e[n],1,ht);if(!o)return null;const a=o.type.kind;if("string"!==a&&"value"!==a&&"null"!==a&&"resolvedImage"!==a)return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");i=!0,r.push({content:o,scale:null,font:null,textColor:null})}}return new Gt(r)}evaluate(e){return new Pt(this.sections.map(t=>{const n=t.content.evaluate(e);return Lt(n)===pt?new It("",n,null,null,null):new It(Rt(n),null,t.scale?t.scale.evaluate(e):null,t.font?t.font.evaluate(e).join(","):null,t.textColor?t.textColor.evaluate(e):null)}))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const n={};t.scale&&(n["font-scale"]=t.scale.serialize()),t.font&&(n["text-font"]=t.font.serialize()),t.textColor&&(n["text-color"]=t.textColor.serialize()),e.push(n)}return e}}class qt{constructor(e){this.type=pt,this.input=e}static parse(e,t){if(2!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,st);return n?new qt(n):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),n=zt.fromString(t);return n&&e.availableImages&&(n.available=e.availableImages.indexOf(t)>-1),n}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const $t={"to-boolean":lt,"to-color":ut,"to-number":at,"to-string":st};class Zt{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const n=e[0];if(("to-boolean"===n||"to-string"===n)&&2!==e.length)return t.error("Expected one argument.");const r=$t[n],i=[];for(let n=1;n4?`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:Ot(t[0],t[1],t[2],t[3]),!n))return new Mt(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new jt(n||`Could not parse color from value '${"string"==typeof t?t:String(JSON.stringify(t))}'`)}if("number"===this.type.kind){let t=null;for(const n of this.args){if(t=n.evaluate(e),null===t)return 0;const r=Number(t);if(!isNaN(r))return r}throw new jt(`Could not convert ${JSON.stringify(t)} to number.`)}return"formatted"===this.type.kind?Pt.fromString(Rt(this.args[0].evaluate(e))):"resolvedImage"===this.type.kind?zt.fromString(Rt(this.args[0].evaluate(e))):Rt(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if("formatted"===this.type.kind)return new Gt([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if("resolvedImage"===this.type.kind)return new qt(this.args[0]).serialize();const e=["to-"+this.type.kind];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Wt=Zt;const Xt=["Unknown","Point","LineString","Polygon"];var Ht=class{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&void 0!==this.feature.id?this.feature.id:null}geometryType(){return this.feature?"number"==typeof this.feature.type?Xt[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:n,y:r}=this.featureTileCoord;return this.featureDistanceData.bearing[0]*(n*t-e[0])+this.featureDistanceData.bearing[1]*(r*t-e[1])}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=Mt.parse(e)),t}};class Yt{constructor(e,t,n,r){this.name=e,this.type=t,this._evaluate=n,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const n=e[0],r=Yt.definitions[n];if(!r)return t.error(`Unknown expression "${n}". If you wanted a literal array, use ["literal", [...]].`,0);const i=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([t])=>!Array.isArray(t)||t.length===e.length-1);let s=null;for(const[r,o]of a){s=new Tn(t.registry,t.path,null,t.scope);const a=[];let l=!1;for(let t=1;t{return t=e,Array.isArray(t)?`(${t.map(_t).join(", ")})`:`(${_t(t.type)}...)`;var t}).join(" | "),r=[];for(let n=1;n=t[2]||e[1]<=t[1]||e[3]>=t[3])}function nn(e,t){const n=(180+e[0])/360,r=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e[1]*Math.PI/360)))/360,i=Math.pow(2,t.z);return[Math.round(n*i*Qt),Math.round(r*i*Qt)]}function rn(e,t,n){const r=e[0]-t[0],i=e[1]-t[1],o=e[0]-n[0],a=e[1]-n[1];return r*a-o*i==0&&r*o<=0&&i*a<=0}function on(e,t){let n=!1;for(let a=0,s=t.length;a(r=e)[1]!=(o=s[t+1])[1]>r[1]&&r[0]<(o[0]-i[0])*(r[1]-i[1])/(o[1]-i[1])+i[0]&&(n=!n)}}var r,i,o;return n}function an(e,t){for(let n=0;n0&&s<0||a<0&&s>0}function ln(e,t,n){for(const u of n)for(let n=0;nn[2]){const t=.5*r;let i=e[0]-n[0]>t?-r:n[0]-e[0]>t?r:0;0===i&&(i=e[0]-n[2]>t?-r:n[2]-e[0]>t?r:0),e[0]+=i}en(t,e)}function pn(e,t,n,r){const i=Math.pow(2,r.z)*Qt,o=[r.x*Qt,r.y*Qt],a=[];if(!e)return a;for(const r of e)for(const e of r){const r=[e.x+o[0],e.y+o[1]];fn(r,t,n,i),a.push(r)}return a}function mn(e,t,n,r){const i=Math.pow(2,r.z)*Qt,o=[r.x*Qt,r.y*Qt],a=[];if(!e)return a;for(const n of e){const e=[];for(const r of n){const n=[r.x+o[0],r.y+o[1]];en(t,n),e.push(n)}a.push(e)}if(t[2]-t[0]<=i/2){(s=t)[0]=s[1]=1/0,s[2]=s[3]=-1/0;for(const e of a)for(const r of e)fn(r,t,n,i)}var s;return a}class _n{constructor(e,t){this.type=lt,this.geojson=e,this.geometries=t}static parse(e,t){if(2!==e.length)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Dt(e[1])){const t=e[1];if("FeatureCollection"===t.type)for(let e=0;e{t&&!yn(e)&&(t=!1)}),t}function vn(e){if(e instanceof Kt&&"feature-state"===e.name)return!1;let t=!0;return e.eachChild(e=>{t&&!vn(e)&&(t=!1)}),t}function xn(e,t){if(e instanceof Kt&&t.indexOf(e.name)>=0)return!1;let n=!0;return e.eachChild(e=>{n&&!xn(e,t)&&(n=!1)}),n}class bn{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(2!==e.length||"string"!=typeof e[1])return t.error("'var' expression requires exactly one string literal argument.");const n=e[1];return t.scope.has(n)?new bn(n,t.scope.get(n)):t.error(`Unknown variable "${n}". Make sure "${n}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var wn=bn;class En{constructor(e,t=[],n,r=new it,i=[]){this.registry=e,this.path=t,this.key=t.map(e=>`[${e}]`).join(""),this.scope=r,this.errors=i,this.expectedType=n}parse(e,t,n,r,i={}){return t?this.concat(t,n,r)._parse(e,i):this._parse(e,i)}_parse(e,t){function n(e,t,n){return"assert"===n?new Vt(t,[e]):"coerce"===n?new Wt(t,[e]):e}if(null!==e&&"string"!=typeof e&&"boolean"!=typeof e&&"number"!=typeof e||(e=["literal",e]),Array.isArray(e)){if(0===e.length)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if("string"!=typeof r)return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const i=this.registry[r];if(i){let r=i.parse(e,this);if(!r)return null;if(this.expectedType){const e=this.expectedType,i=r.type;if("string"!==e.kind&&"number"!==e.kind&&"boolean"!==e.kind&&"object"!==e.kind&&"array"!==e.kind||"value"!==i.kind)if("color"!==e.kind&&"formatted"!==e.kind&&"resolvedImage"!==e.kind||"value"!==i.kind&&"string"!==i.kind){if(this.checkSubtype(e,i))return null}else r=n(r,e,t.typeAnnotation||"coerce");else r=n(r,e,t.typeAnnotation||"assert")}if(!(r instanceof Ft)&&"resolvedImage"!==r.type.kind&&function e(t){if(t instanceof wn)return e(t.boundExpression);if(t instanceof Kt&&"error"===t.name)return!1;if(t instanceof Jt)return!1;if(t instanceof gn)return!1;const n=t instanceof Wt||t instanceof Vt;let r=!0;return t.eachChild(t=>{r=n?r&&e(t):r&&t instanceof Ft}),!!r&&yn(t)&&xn(t,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"])}(r)){const t=new Ht;try{r=new Ft(r.type,r.evaluate(t))}catch(e){return this.error(e.message),null}}return r}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(void 0===e?"'undefined' value invalid. Use null instead.":"object"==typeof e?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,t,n){const r="number"==typeof e?this.path.concat(e):this.path,i=n?this.scope.concat(n):this.scope;return new En(this.registry,r,t||null,i,this.errors)}error(e,...t){const n=`${this.key}${t.map(e=>`[${e}]`).join("")}`;this.errors.push(new nt(n,e))}checkSubtype(e,t){const n=yt(e,t);return n&&this.error(n),n}}var Tn=En;function Sn(e,t){const n=e.length-1;let r,i,o=0,a=n,s=0;for(;o<=a;)if(s=Math.floor((o+a)/2),r=e[s],i=e[s+1],r<=t){if(s===n||tt))throw new jt("Input is not a number.");a=s-1}return 0}class kn{constructor(e,t,n){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[e,t]of n)this.labels.push(e),this.outputs.push(t)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");const n=t.parse(e[1],1,at);if(!n)return null;const r=[];let i=null;t.expectedType&&"value"!==t.expectedType.kind&&(i=t.expectedType);for(let n=1;n=o)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',s);const u=t.parse(a,l,i);if(!u)return null;i=i||u.type,r.push([o,u])}return new kn(i,n,r)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;return r>=t[i-1]?n[i-1].evaluate(e):n[Sn(t,r)].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var Cn=kn;function Mn(e,t,n){return e*(1-n)+t*n}var An=Object.freeze({__proto__:null,number:Mn,color:function(e,t,n){return new Mt(Mn(e.r,t.r,n),Mn(e.g,t.g,n),Mn(e.b,t.b,n),Mn(e.a,t.a,n))},array:function(e,t,n){return e.map((e,r)=>Mn(e,t[r],n))}});const In=6/29*3*(6/29),Pn=Math.PI/180,zn=180/Math.PI;function On(e){return e>.008856451679035631?Math.pow(e,1/3):e/In+4/29}function Dn(e){return e>6/29?e*e*e:In*(e-4/29)}function Ln(e){return 255*(e<=.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055)}function Rn(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function Bn(e){const t=Rn(e.r),n=Rn(e.g),r=Rn(e.b),i=On((.4124564*t+.3575761*n+.1804375*r)/.95047),o=On((.2126729*t+.7151522*n+.072175*r)/1);return{l:116*o-16,a:500*(i-o),b:200*(o-On((.0193339*t+.119192*n+.9503041*r)/1.08883)),alpha:e.a}}function Fn(e){let t=(e.l+16)/116,n=isNaN(e.a)?t:t+e.a/500,r=isNaN(e.b)?t:t-e.b/200;return t=1*Dn(t),n=.95047*Dn(n),r=1.08883*Dn(r),new Mt(Ln(3.2404542*n-1.5371385*t-.4985314*r),Ln(-.969266*n+1.8760108*t+.041556*r),Ln(.0556434*n-.2040259*t+1.0572252*r),e.alpha)}function jn(e,t,n){const r=t-e;return e+n*(r>180||r<-180?r-360*Math.round(r/360):r)}const Nn={forward:Bn,reverse:Fn,interpolate:function(e,t,n){return{l:Mn(e.l,t.l,n),a:Mn(e.a,t.a,n),b:Mn(e.b,t.b,n),alpha:Mn(e.alpha,t.alpha,n)}}},Un={forward:function(e){const{l:t,a:n,b:r}=Bn(e),i=Math.atan2(r,n)*zn;return{h:i<0?i+360:i,c:Math.sqrt(n*n+r*r),l:t,alpha:e.a}},reverse:function(e){const t=e.h*Pn,n=e.c;return Fn({l:e.l,a:Math.cos(t)*n,b:Math.sin(t)*n,alpha:e.alpha})},interpolate:function(e,t,n){return{h:jn(e.h,t.h,n),c:Mn(e.c,t.c,n),l:Mn(e.l,t.l,n),alpha:Mn(e.alpha,t.alpha,n)}}};var Vn=Object.freeze({__proto__:null,lab:Nn,hcl:Un});class Gn{constructor(e,t,n,r,i){this.type=e,this.operator=t,this.interpolation=n,this.input=r,this.labels=[],this.outputs=[];for(const[e,t]of i)this.labels.push(e),this.outputs.push(t)}static interpolationFactor(e,t,n,r){let i=0;if("exponential"===e.name)i=qn(t,e.base,n,r);else if("linear"===e.name)i=qn(t,1,n,r);else if("cubic-bezier"===e.name){const o=e.controlPoints;i=new f(o[0],o[1],o[2],o[3]).solve(qn(t,1,n,r))}return i}static parse(e,t){let[n,r,i,...o]=e;if(!Array.isArray(r)||0===r.length)return t.error("Expected an interpolation type expression.",1);if("linear"===r[0])r={name:"linear"};else if("exponential"===r[0]){const e=r[1];if("number"!=typeof e)return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:e}}else{if("cubic-bezier"!==r[0])return t.error("Unknown interpolation type "+String(r[0]),1,0);{const e=r.slice(1);if(4!==e.length||e.some(e=>"number"!=typeof e||e<0||e>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:e}}}if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return t.error("Expected an even number of arguments.");if(i=t.parse(i,2,at),!i)return null;const a=[];let s=null;"interpolate-hcl"===n||"interpolate-lab"===n?s=ut:t.expectedType&&"value"!==t.expectedType.kind&&(s=t.expectedType);for(let e=0;e=n)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',i);const u=t.parse(r,l,s);if(!u)return null;s=s||u.type,a.push([n,u])}return"number"===s.kind||"color"===s.kind||"array"===s.kind&&"number"===s.itemType.kind&&"number"==typeof s.N?new Gn(s,n,r,i,a):t.error(`Type ${_t(s)} is not interpolatable.`)}evaluate(e){const t=this.labels,n=this.outputs;if(1===t.length)return n[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return n[0].evaluate(e);const i=t.length;if(r>=t[i-1])return n[i-1].evaluate(e);const o=Sn(t,r),a=Gn.interpolationFactor(this.interpolation,r,t[o],t[o+1]),s=n[o].evaluate(e),l=n[o+1].evaluate(e);return"interpolate"===this.operator?An[this.type.kind.toLowerCase()](s,l,a):"interpolate-hcl"===this.operator?Un.reverse(Un.interpolate(Un.forward(s),Un.forward(l),a)):Nn.reverse(Nn.interpolate(Nn.forward(s),Nn.forward(l),a))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;e="linear"===this.interpolation.name?["linear"]:"exponential"===this.interpolation.name?1===this.interpolation.base?["linear"]:["exponential",this.interpolation.base]:["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let e=0;eyt(r,e.type));return new Zn(o?ht:n,i)}evaluate(e){let t,n=null,r=0;for(const i of this.args){if(r++,n=i.evaluate(e),n&&n instanceof zt&&!n.available&&(t||(t=n),n=null,r===this.args.length))return t;if(null!==n)break}return n}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Wn=Zn;class Xn{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 n=[];for(let r=1;r=n.length)throw new jt(`Array index out of bounds: ${t} > ${n.length-1}.`);if(t!==Math.floor(t))throw new jt(`Array index must be an integer, but found ${t} instead.`);return n[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var Kn=Yn;class Jn{constructor(e,t){this.type=lt,this.needle=e,this.haystack=t}static parse(e,t){if(3!==e.length)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ht),r=t.parse(e[2],2,ht);return n&&r?vt(n.type,[lt,st,at,ot,ht])?new Jn(n,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${_t(n.type)} instead`):null}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(null==n)return!1;if(!xt(t,["boolean","string","number","null"]))throw new jt(`Expected first argument to be of type boolean, string, number or null, but found ${_t(Lt(t))} instead.`);if(!xt(n,["string","array"]))throw new jt(`Expected second argument to be of type array or string, but found ${_t(Lt(n))} instead.`);return n.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Qn=Jn;class er{constructor(e,t,n){this.type=at,this.needle=e,this.haystack=t,this.fromIndex=n}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ht),r=t.parse(e[2],2,ht);if(!n||!r)return null;if(!vt(n.type,[lt,st,at,ot,ht]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${_t(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,at);return i?new er(n,r,i):null}return new er(n,r)}evaluate(e){const t=this.needle.evaluate(e),n=this.haystack.evaluate(e);if(!xt(t,["boolean","string","number","null"]))throw new jt(`Expected first argument to be of type boolean, string, number or null, but found ${_t(Lt(t))} instead.`);if(!xt(n,["string","array"]))throw new jt(`Expected second argument to be of type array or string, but found ${_t(Lt(n))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return n.indexOf(t,r)}return n.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(null!=this.fromIndex&&void 0!==this.fromIndex){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var tr=er;class nr{constructor(e,t,n,r,i,o){this.inputType=e,this.type=t,this.input=n,this.cases=r,this.outputs=i,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return t.error("Expected an even number of arguments.");let n,r;t.expectedType&&"value"!==t.expectedType.kind&&(r=t.expectedType);const i={},o=[];for(let a=2;aNumber.MAX_SAFE_INTEGER)return u.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if("number"==typeof e&&Math.floor(e)!==e)return u.error("Numeric branch labels must be integer values.");if(n){if(u.checkSubtype(n,Lt(e)))return null}else n=Lt(e);if(void 0!==i[String(e)])return u.error("Branch labels must be unique.");i[String(e)]=o.length}const c=t.parse(l,a,r);if(!c)return null;r=r||c.type,o.push(c)}const a=t.parse(e[1],1,ht);if(!a)return null;const s=t.parse(e[e.length-1],e.length-1,r);return s?"value"!==a.type.kind&&t.concat(1).checkSubtype(n,a.type)?null:new nr(n,r,a,i,o,s):null}evaluate(e){const t=this.input.evaluate(e);return(Lt(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),n=[],r={};for(const e of t){const t=r[this.cases[e]];void 0===t?(r[this.cases[e]]=n.length,n.push([this.cases[e],[e]])):n[t][1].push(e)}const i=e=>"number"===this.inputType.kind?Number(e):e;for(const[t,r]of n)e.push(1===r.length?i(r[0]):r.map(i)),e.push(this.outputs[t].serialize());return e.push(this.otherwise.serialize()),e}}var rr=nr;class ir{constructor(e,t,n){this.type=e,this.branches=t,this.otherwise=n}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return t.error("Expected an odd number of arguments.");let n;t.expectedType&&"value"!==t.expectedType.kind&&(n=t.expectedType);const r=[];for(let i=1;it.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var or=ir;class ar{constructor(e,t,n,r){this.type=e,this.input=t,this.beginIndex=n,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const n=t.parse(e[1],1,ht),r=t.parse(e[2],2,at);if(!n||!r)return null;if(!vt(n.type,[mt(ht),st,ht]))return t.error(`Expected first argument to be of type array or string, but found ${_t(n.type)} instead`);if(4===e.length){const i=t.parse(e[3],3,at);return i?new ar(n.type,n,r,i):null}return new ar(n.type,n,r)}evaluate(e){const t=this.input.evaluate(e),n=this.beginIndex.evaluate(e);if(!xt(t,["string","array"]))throw new jt(`Expected first argument to be of type array or string, but found ${_t(Lt(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(n,r)}return t.slice(n)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(null!=this.endIndex&&void 0!==this.endIndex){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var sr=ar;function lr(e,t){return"=="===e||"!="===e?"boolean"===t.kind||"string"===t.kind||"number"===t.kind||"null"===t.kind||"value"===t.kind:"string"===t.kind||"number"===t.kind||"value"===t.kind}function ur(e,t,n,r){return 0===r.compare(t,n)}function cr(e,t,n){const r="=="!==e&&"!="!==e;return class i{constructor(e,t,n){this.type=lt,this.lhs=e,this.rhs=t,this.collator=n,this.hasUntypedArgument="value"===e.type.kind||"value"===t.type.kind}static parse(e,t){if(3!==e.length&&4!==e.length)return t.error("Expected two or three arguments.");const n=e[0];let o=t.parse(e[1],1,ht);if(!o)return null;if(!lr(n,o.type))return t.concat(1).error(`"${n}" comparisons are not supported for type '${_t(o.type)}'.`);let a=t.parse(e[2],2,ht);if(!a)return null;if(!lr(n,a.type))return t.concat(2).error(`"${n}" comparisons are not supported for type '${_t(a.type)}'.`);if(o.type.kind!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error(`Cannot compare types '${_t(o.type)}' and '${_t(a.type)}'.`);r&&("value"===o.type.kind&&"value"!==a.type.kind?o=new Vt(a.type,[o]):"value"!==o.type.kind&&"value"===a.type.kind&&(a=new Vt(o.type,[a])));let s=null;if(4===e.length){if("string"!==o.type.kind&&"string"!==a.type.kind&&"value"!==o.type.kind&&"value"!==a.type.kind)return t.error("Cannot use collator to compare non-string types.");if(s=t.parse(e[3],3,dt),!s)return null}return new i(o,a,s)}evaluate(i){const o=this.lhs.evaluate(i),a=this.rhs.evaluate(i);if(r&&this.hasUntypedArgument){const t=Lt(o),n=Lt(a);if(t.kind!==n.kind||"string"!==t.kind&&"number"!==t.kind)throw new jt(`Expected arguments for "${e}" to be (string, string) or (number, number), but found (${t.kind}, ${n.kind}) instead.`)}if(this.collator&&!r&&this.hasUntypedArgument){const e=Lt(o),n=Lt(a);if("string"!==e.kind||"string"!==n.kind)return t(i,o,a)}return this.collator?n(i,o,a,this.collator.evaluate(i)):t(i,o,a)}eachChild(e){e(this.lhs),e(this.rhs),this.collator&&e(this.collator)}outputDefined(){return!0}serialize(){const t=[e];return this.eachChild(e=>{t.push(e.serialize())}),t}}}const hr=cr("==",(function(e,t,n){return t===n}),ur),dr=cr("!=",(function(e,t,n){return t!==n}),(function(e,t,n,r){return!ur(0,t,n,r)})),fr=cr("<",(function(e,t,n){return t",(function(e,t,n){return t>n}),(function(e,t,n,r){return r.compare(t,n)>0})),mr=cr("<=",(function(e,t,n){return t<=n}),(function(e,t,n,r){return r.compare(t,n)<=0})),_r=cr(">=",(function(e,t,n){return t>=n}),(function(e,t,n,r){return r.compare(t,n)>=0}));class gr{constructor(e,t,n,r,i,o){this.type=st,this.number=e,this.locale=t,this.currency=n,this.unit=r,this.minFractionDigits=i,this.maxFractionDigits=o}static parse(e,t){if(3!==e.length)return t.error("Expected two arguments.");const n=t.parse(e[1],1,at);if(!n)return null;const r=e[2];if("object"!=typeof r||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let i=null;if(r.locale&&(i=t.parse(r.locale,1,st),!i))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,st),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,st),!a))return null;let s=null;if(r["min-fraction-digits"]&&(s=t.parse(r["min-fraction-digits"],1,at),!s))return null;let l=null;return r["max-fraction-digits"]&&(l=t.parse(r["max-fraction-digits"],1,at),!l)?null:new gr(n,i,o,a,s,l)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:(this.currency?"currency":this.unit&&"unit")||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class yr{constructor(e){this.type=at,this.input=e}static parse(e,t){if(2!==e.length)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const n=t.parse(e[1],1);return n?"array"!==n.type.kind&&"string"!==n.type.kind&&"value"!==n.type.kind?t.error(`Expected argument of type string or array, but found ${_t(n.type)} instead.`):new yr(n):null}evaluate(e){const t=this.input.evaluate(e);if("string"==typeof t)return t.length;if(Array.isArray(t))return t.length;throw new jt(`Expected value to be of type string or array, but found ${_t(Lt(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}const vr={"==":hr,"!=":dr,">":pr,"<":fr,">=":_r,"<=":mr,array:Vt,at:Kn,boolean:Vt,case:or,coalesce:Wn,collator:Jt,format:Gt,image:qt,in:Qn,"index-of":tr,interpolate:$n,"interpolate-hcl":$n,"interpolate-lab":$n,length:yr,let:Hn,literal:Ft,match:rr,number:Vt,"number-format":gr,object:Vt,slice:sr,step:Cn,string:Vt,"to-boolean":Wt,"to-color":Wt,"to-number":Wt,"to-string":Wt,var:wn,within:gn};function xr(e,[t,n,r,i]){t=t.evaluate(e),n=n.evaluate(e),r=r.evaluate(e);const o=i?i.evaluate(e):1,a=Ot(t,n,r,o);if(a)throw new jt(a);return new Mt(t/255*o,n/255*o,r/255*o,o)}function br(e,t){return e in t}function wr(e,t){const n=t[e];return void 0===n?null:n}function Er(e){return{type:e}}Kt.register(vr,{error:[{kind:"error"},[st],(e,[t])=>{throw new jt(t.evaluate(e))}],typeof:[st,[ht],(e,[t])=>_t(Lt(t.evaluate(e)))],"to-rgba":[mt(at,4),[ut],(e,[t])=>t.evaluate(e).toArray()],rgb:[ut,[at,at,at],xr],rgba:[ut,[at,at,at,at],xr],has:{type:lt,overloads:[[[st],(e,[t])=>br(t.evaluate(e),e.properties())],[[st,ct],(e,[t,n])=>br(t.evaluate(e),n.evaluate(e))]]},get:{type:ht,overloads:[[[st],(e,[t])=>wr(t.evaluate(e),e.properties())],[[st,ct],(e,[t,n])=>wr(t.evaluate(e),n.evaluate(e))]]},"feature-state":[ht,[st],(e,[t])=>wr(t.evaluate(e),e.featureState||{})],properties:[ct,[],e=>e.properties()],"geometry-type":[st,[],e=>e.geometryType()],id:[ht,[],e=>e.id()],zoom:[at,[],e=>e.globals.zoom],pitch:[at,[],e=>e.globals.pitch||0],"distance-from-center":[at,[],e=>e.distanceFromCenter()],"heatmap-density":[at,[],e=>e.globals.heatmapDensity||0],"line-progress":[at,[],e=>e.globals.lineProgress||0],"sky-radial-progress":[at,[],e=>e.globals.skyRadialProgress||0],accumulated:[ht,[],e=>void 0===e.globals.accumulated?null:e.globals.accumulated],"+":[at,Er(at),(e,t)=>{let n=0;for(const r of t)n+=r.evaluate(e);return n}],"*":[at,Er(at),(e,t)=>{let n=1;for(const r of t)n*=r.evaluate(e);return n}],"-":{type:at,overloads:[[[at,at],(e,[t,n])=>t.evaluate(e)-n.evaluate(e)],[[at],(e,[t])=>-t.evaluate(e)]]},"/":[at,[at,at],(e,[t,n])=>t.evaluate(e)/n.evaluate(e)],"%":[at,[at,at],(e,[t,n])=>t.evaluate(e)%n.evaluate(e)],ln2:[at,[],()=>Math.LN2],pi:[at,[],()=>Math.PI],e:[at,[],()=>Math.E],"^":[at,[at,at],(e,[t,n])=>Math.pow(t.evaluate(e),n.evaluate(e))],sqrt:[at,[at],(e,[t])=>Math.sqrt(t.evaluate(e))],log10:[at,[at],(e,[t])=>Math.log(t.evaluate(e))/Math.LN10],ln:[at,[at],(e,[t])=>Math.log(t.evaluate(e))],log2:[at,[at],(e,[t])=>Math.log(t.evaluate(e))/Math.LN2],sin:[at,[at],(e,[t])=>Math.sin(t.evaluate(e))],cos:[at,[at],(e,[t])=>Math.cos(t.evaluate(e))],tan:[at,[at],(e,[t])=>Math.tan(t.evaluate(e))],asin:[at,[at],(e,[t])=>Math.asin(t.evaluate(e))],acos:[at,[at],(e,[t])=>Math.acos(t.evaluate(e))],atan:[at,[at],(e,[t])=>Math.atan(t.evaluate(e))],min:[at,Er(at),(e,t)=>Math.min(...t.map(t=>t.evaluate(e)))],max:[at,Er(at),(e,t)=>Math.max(...t.map(t=>t.evaluate(e)))],abs:[at,[at],(e,[t])=>Math.abs(t.evaluate(e))],round:[at,[at],(e,[t])=>{const n=t.evaluate(e);return n<0?-Math.round(-n):Math.round(n)}],floor:[at,[at],(e,[t])=>Math.floor(t.evaluate(e))],ceil:[at,[at],(e,[t])=>Math.ceil(t.evaluate(e))],"filter-==":[lt,[st,ht],(e,[t,n])=>e.properties()[t.value]===n.value],"filter-id-==":[lt,[ht],(e,[t])=>e.id()===t.value],"filter-type-==":[lt,[st],(e,[t])=>e.geometryType()===t.value],"filter-<":[lt,[st,ht],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r{const n=e.id(),r=t.value;return typeof n==typeof r&&n":[lt,[st,ht],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>i}],"filter-id->":[lt,[ht],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>r}],"filter-<=":[lt,[st,ht],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r<=i}],"filter-id-<=":[lt,[ht],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n<=r}],"filter->=":[lt,[st,ht],(e,[t,n])=>{const r=e.properties()[t.value],i=n.value;return typeof r==typeof i&&r>=i}],"filter-id->=":[lt,[ht],(e,[t])=>{const n=e.id(),r=t.value;return typeof n==typeof r&&n>=r}],"filter-has":[lt,[ht],(e,[t])=>t.value in e.properties()],"filter-has-id":[lt,[],e=>null!==e.id()&&void 0!==e.id()],"filter-type-in":[lt,[mt(st)],(e,[t])=>t.value.indexOf(e.geometryType())>=0],"filter-id-in":[lt,[mt(ht)],(e,[t])=>t.value.indexOf(e.id())>=0],"filter-in-small":[lt,[st,mt(ht)],(e,[t,n])=>n.value.indexOf(e.properties()[t.value])>=0],"filter-in-large":[lt,[st,mt(ht)],(e,[t,n])=>function(e,t,n,r){for(;n<=r;){const i=n+r>>1;if(t[i]===e)return!0;t[i]>e?r=i-1:n=i+1}return!1}(e.properties()[t.value],n.value,0,n.value.length-1)],all:{type:lt,overloads:[[[lt,lt],(e,[t,n])=>t.evaluate(e)&&n.evaluate(e)],[Er(lt),(e,t)=>{for(const n of t)if(!n.evaluate(e))return!1;return!0}]]},any:{type:lt,overloads:[[[lt,lt],(e,[t,n])=>t.evaluate(e)||n.evaluate(e)],[Er(lt),(e,t)=>{for(const n of t)if(n.evaluate(e))return!0;return!1}]]},"!":[lt,[lt],(e,[t])=>!t.evaluate(e)],"is-supported-script":[lt,[st],(e,[t])=>{const n=e.globals&&e.globals.isSupportedScript;return!n||n(t.evaluate(e))}],upcase:[st,[st],(e,[t])=>t.evaluate(e).toUpperCase()],downcase:[st,[st],(e,[t])=>t.evaluate(e).toLowerCase()],concat:[st,Er(ht),(e,t)=>t.map(t=>Rt(t.evaluate(e))).join("")],"resolved-locale":[st,[dt],(e,[t])=>t.evaluate(e).resolvedLocale()]});var Tr=vr;function Sr(e){return{result:"success",value:e}}function kr(e){return{result:"error",value:e}}function Cr(e){return"data-driven"===e["property-type"]}function Mr(e){return!!e.expression&&e.expression.parameters.indexOf("zoom")>-1}function Ar(e){return!!e.expression&&e.expression.interpolated}function Ir(e){return e instanceof Number?"number":e instanceof String?"string":e instanceof Boolean?"boolean":Array.isArray(e)?"array":null===e?"null":typeof e}function Pr(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}function zr(e){return e}function Or(e,t,n){return void 0!==e?e:void 0!==t?t:void 0!==n?n:void 0}function Dr(e,t,n,r,i){return Or(typeof n===i?r[n]:void 0,e.default,t.default)}function Lr(e,t,n){if("number"!==Ir(n))return Or(e.default,t.default);const r=e.stops.length;if(1===r)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[r-1][0])return e.stops[r-1][1];const i=Sn(e.stops.map(e=>e[0]),n);return e.stops[i][1]}function Rr(e,t,n){const r=void 0!==e.base?e.base:1;if("number"!==Ir(n))return Or(e.default,t.default);const i=e.stops.length;if(1===i)return e.stops[0][1];if(n<=e.stops[0][0])return e.stops[0][1];if(n>=e.stops[i-1][0])return e.stops[i-1][1];const o=Sn(e.stops.map(e=>e[0]),n),a=function(e,t,n,r){const i=r-n,o=e-n;return 0===i?0:1===t?o/i:(Math.pow(t,o)-1)/(Math.pow(t,i)-1)}(n,r,e.stops[o][0],e.stops[o+1][0]),s=e.stops[o][1],l=e.stops[o+1][1];let u=An[t.type]||zr;if(e.colorSpace&&"rgb"!==e.colorSpace){const t=Vn[e.colorSpace];u=(e,n)=>t.reverse(t.interpolate(t.forward(e),t.forward(n),a))}return"function"==typeof s.evaluate?{evaluate(...e){const t=s.evaluate.apply(void 0,e),n=l.evaluate.apply(void 0,e);if(void 0!==t&&void 0!==n)return u(t,n,a)}}:u(s,l,a)}function Br(e,t,n){return"color"===t.type?n=Mt.parse(n):"formatted"===t.type?n=Pt.fromString(n.toString()):"resolvedImage"===t.type?n=zt.fromString(n.toString()):Ir(n)===t.type||"enum"===t.type&&t.values[n]||(n=void 0),Or(n,e.default,t.default)}class Fr{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new Ht,this._defaultValue=t?function(e){return"color"===e.type&&(Pr(e.default)||Array.isArray(e.default))?new Mt(0,0,0,0):"color"===e.type?Mt.parse(e.default)||null:void 0===e.default?null:e.default}(t):null,this._enumValues=t&&"enum"===t.type?t.values:null}evaluateWithoutErrorHandling(e,t,n,r,i,o,a,s){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=n,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,n,r,i,o,a,s){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=n||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=i||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=s||null;try{const e=this.expression.evaluate(this._evaluator);if(null==e||"number"==typeof e&&e!=e)return this._defaultValue;if(this._enumValues&&!(e in this._enumValues))throw new jt(`Expected value to be one of ${Object.keys(this._enumValues).map(e=>JSON.stringify(e)).join(", ")}, but found ${JSON.stringify(e)} instead.`);return e}catch(e){return this._warningHistory[e.message]||(this._warningHistory[e.message]=!0,"undefined"!=typeof console&&console.warn(e.message)),this._defaultValue}}}function jr(e){return Array.isArray(e)&&e.length>0&&"string"==typeof e[0]&&e[0]in Tr}function Nr(e,t){const n=new Tn(Tr,[],t?function(e){const t={color:ut,string:st,number:at,enum:st,boolean:lt,formatted:ft,resolvedImage:pt};return"array"===e.type?mt(t[e.value]||ht,e.length):t[e.type]}(t):void 0),r=n.parse(e,void 0,void 0,void 0,t&&"string"===t.type?{typeAnnotation:"coerce"}:void 0);return r?Sr(new Fr(r,t)):kr(n.errors)}class Ur{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent="constant"!==e&&!vn(t.expression)}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}}class Vr{constructor(e,t,n,r){this.kind=e,this.zoomStops=n,this._styleExpression=t,this.isStateDependent="camera"!==e&&!vn(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,n,r,i,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,n,r,i,o)}evaluate(e,t,n,r,i,o){return this._styleExpression.evaluate(e,t,n,r,i,o)}interpolationFactor(e,t,n){return this.interpolationType?$n.interpolationFactor(this.interpolationType,e,t,n):0}}function Gr(e,t){if("error"===(e=Nr(e,t)).result)return e;const n=e.value.expression,r=yn(n);if(!r&&!Cr(t))return kr([new nt("","data expressions not supported")]);const i=xn(n,["zoom","pitch","distance-from-center"]);if(!i&&!Mr(t))return kr([new nt("","zoom expressions not supported")]);const o=function e(t){let n=null;if(t instanceof Hn)n=e(t.result);else if(t instanceof Wn){for(const r of t.args)if(n=e(r),n)break}else(t instanceof Cn||t instanceof $n)&&t.input instanceof Kt&&"zoom"===t.input.name&&(n=t);return n instanceof nt||t.eachChild(t=>{const r=e(t);r instanceof nt?n=r:!n&&r?n=new nt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):n&&r&&n!==r&&(n=new nt("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),n}(n);return o||i?o instanceof nt?kr([o]):o instanceof $n&&!Ar(t)?kr([new nt("",'"interpolate" expressions cannot be used with this property')]):Sr(o?new Vr(r?"camera":"composite",e.value,o.labels,o instanceof $n?o.interpolation:void 0):new Ur(r?"constant":"source",e.value)):kr([new nt("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class qr{constructor(e,t){this._parameters=e,this._specification=t,Je(this,function e(t,n){const r="color"===n.type,i=t.stops&&"object"==typeof t.stops[0][0],o=i||!(i||void 0!==t.property),a=t.type||(Ar(n)?"exponential":"interval");if(r&&((t=Je({},t)).stops&&(t.stops=t.stops.map(e=>[e[0],Mt.parse(e[1])])),t.default=Mt.parse(t.default?t.default:n.default)),t.colorSpace&&"rgb"!==t.colorSpace&&!Vn[t.colorSpace])throw new Error("Unknown color space: "+t.colorSpace);let s,l,u;if("exponential"===a)s=Rr;else if("interval"===a)s=Lr;else if("categorical"===a){s=Dr,l=Object.create(null);for(const e of t.stops)l[e[0]]=e[1];u=typeof t.stops[0][0]}else{if("identity"!==a)throw new Error(`Unknown function type "${a}"`);s=Br}if(i){const r={},i=[];for(let e=0;ee[0]),evaluate:({zoom:e},r)=>Rr({stops:o,base:t.base},n,e).evaluate(e,r)}}if(o){const e="exponential"===a?{name:"exponential",base:void 0!==t.base?t.base:1}:null;return{kind:"camera",interpolationType:e,interpolationFactor:$n.interpolationFactor.bind(void 0,e),zoomStops:t.stops.map(e=>e[0]),evaluate:({zoom:e})=>s(t,n,e,l,u)}}return{kind:"source",evaluate(e,r){const i=r&&r.properties?r.properties[t.property]:void 0;return void 0===i?Or(t.default,n.default):s(t,n,i,l,u)}}}(this._parameters,this._specification))}static deserialize(e){return new qr(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}class $r{constructor(e,t,n,r){this.message=(e?e+": ":"")+n,r&&(this.identifier=r),null!=t&&t.__line__&&(this.line=t.__line__)}}function Zr(e){const t=e.key,n=e.value,r=e.valueSpec||{},i=e.objectElementValidators||{},o=e.style,a=e.styleSpec;let s=[];const l=Ir(n);if("object"!==l)return[new $r(t,n,`object expected, ${l} found`)];for(const e in n){const l=e.split(".")[0],u=r[l]||r["*"];let c;i[l]?c=i[l]:r[l]?c=wi:i["*"]?c=i["*"]:r["*"]&&(c=wi),c?s=s.concat(c({key:(t?t+".":t)+e,value:n[e],valueSpec:u,style:o,styleSpec:a,object:n,objectKey:e},n)):s.push(new $r(t,n[e],`unknown property "${e}"`))}for(const e in r)i[e]||r[e].required&&void 0===r[e].default&&void 0===n[e]&&s.push(new $r(t,n,`missing required property "${e}"`));return s}function Wr(e){const t=e.value,n=e.valueSpec,r=e.style,i=e.styleSpec,o=e.key,a=e.arrayElementValidator||wi;if("array"!==Ir(t))return[new $r(o,t,`array expected, ${Ir(t)} found`)];if(n.length&&t.length!==n.length)return[new $r(o,t,`array length ${n.length} expected, length ${t.length} found`)];if(n["min-length"]&&t.lengthi)return[new $r(t,n,`${n} is greater than the maximum value ${i}`)]}return[]}function Hr(e){const t=e.valueSpec,n=Qe(e.value.type);let r,i,o,a={};const s="categorical"!==n&&void 0===e.value.property,l=!s,u="array"===Ir(e.value.stops)&&"array"===Ir(e.value.stops[0])&&"object"===Ir(e.value.stops[0][0]),c=Zr({key:e.key,value:e.value,valueSpec:e.styleSpec.function,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{stops:function(e){if("identity"===n)return[new $r(e.key,e.value,'identity function may not have a "stops" property')];let t=[];const r=e.value;return t=t.concat(Wr({key:e.key,value:r,valueSpec:e.valueSpec,style:e.style,styleSpec:e.styleSpec,arrayElementValidator:h})),"array"===Ir(r)&&0===r.length&&t.push(new $r(e.key,r,"array must have at least one stop")),t},default:function(e){return wi({key:e.key,value:e.value,valueSpec:t,style:e.style,styleSpec:e.styleSpec})}}});return"identity"===n&&s&&c.push(new $r(e.key,e.value,'missing required property "property"')),"identity"===n||e.value.stops||c.push(new $r(e.key,e.value,'missing required property "stops"')),"exponential"===n&&e.valueSpec.expression&&!Ar(e.valueSpec)&&c.push(new $r(e.key,e.value,"exponential functions not supported")),e.styleSpec.$version>=8&&(l&&!Cr(e.valueSpec)?c.push(new $r(e.key,e.value,"property functions not supported")):s&&!Mr(e.valueSpec)&&c.push(new $r(e.key,e.value,"zoom functions not supported"))),"categorical"!==n&&!u||void 0!==e.value.property||c.push(new $r(e.key,e.value,'"property" property is required')),c;function h(e){let n=[];const r=e.value,s=e.key;if("array"!==Ir(r))return[new $r(s,r,`array expected, ${Ir(r)} found`)];if(2!==r.length)return[new $r(s,r,`array length 2 expected, length ${r.length} found`)];if(u){if("object"!==Ir(r[0]))return[new $r(s,r,`object expected, ${Ir(r[0])} found`)];if(void 0===r[0].zoom)return[new $r(s,r,"object stop key must have zoom")];if(void 0===r[0].value)return[new $r(s,r,"object stop key must have value")];const t=Qe(r[0].zoom);if("number"!=typeof t)return[new $r(s,r[0].zoom,"stop zoom values must be numbers")];if(o&&o>t)return[new $r(s,r[0].zoom,"stop zoom values must appear in ascending order")];t!==o&&(o=t,i=void 0,a={}),n=n.concat(Zr({key:s+"[0]",value:r[0],valueSpec:{zoom:{}},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{zoom:Xr,value:d}}))}else n=n.concat(d({key:s+"[0]",value:r[0],valueSpec:{},style:e.style,styleSpec:e.styleSpec},r));return jr(et(r[1]))?n.concat([new $r(s+"[1]",r[1],"expressions are not allowed in function stops.")]):n.concat(wi({key:s+"[1]",value:r[1],valueSpec:t,style:e.style,styleSpec:e.styleSpec}))}function d(e,o){const s=Ir(e.value),l=Qe(e.value),u=null!==e.value?e.value:o;if(r){if(s!==r)return[new $r(e.key,u,`${s} stop domain type must match previous stop domain type ${r}`)]}else r=s;if("number"!==s&&"string"!==s&&"boolean"!==s&&"number"!=typeof l&&"string"!=typeof l&&"boolean"!=typeof l)return[new $r(e.key,u,"stop domain value must be a number, string, or boolean")];if("number"!==s&&"categorical"!==n){let r=`number expected, ${s} found`;return Cr(t)&&void 0===n&&(r+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new $r(e.key,u,r)]}return"categorical"!==n||"number"!==s||"number"==typeof l&&isFinite(l)&&Math.floor(l)===l?"categorical"!==n&&"number"===s&&"number"==typeof l&&"number"==typeof i&&void 0!==i&&lnew $r(`${e.key}${t.key}`,e.value,t.message));const n=t.value.expression||t.value._styleExpression.expression;if("property"===e.expressionContext&&"text-font"===e.propertyKey&&!n.outputDefined())return[new $r(e.key,e.value,`Invalid data expression for "${e.propertyKey}". Output values must be contained as literals within the expression.`)];if("property"===e.expressionContext&&"layout"===e.propertyType&&!vn(n))return[new $r(e.key,e.value,'"feature-state" data expressions are not supported with layout properties.')];if("filter"===e.expressionContext)return function e(t,n){const r=new Set(["zoom","feature-state","pitch","distance-from-center"]);if(n.valueSpec&&n.valueSpec.expression)for(const e of n.valueSpec.expression.parameters)r.delete(e);if(0===r.size)return[];const i=[];return t instanceof Kt&&r.has(t.name)?[new $r(n.key,n.value,`["${t.name}"] expression is not supported in a filter for a ${n.object.type} layer with id: ${n.object.id}`)]:(t.eachChild(t=>{i.push(...e(t,n))}),i)}(n,e);if(e.expressionContext&&0===e.expressionContext.indexOf("cluster")){if(!xn(n,["zoom","feature-state"]))return[new $r(e.key,e.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if("cluster-initial"===e.expressionContext&&!yn(n))return[new $r(e.key,e.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function Kr(e){const t=e.key,n=e.value,r=e.valueSpec,i=[];return Array.isArray(r.values)?-1===r.values.indexOf(Qe(n))&&i.push(new $r(t,n,`expected one of [${r.values.join(", ")}], ${JSON.stringify(n)} found`)):-1===Object.keys(r.values).indexOf(Qe(n))&&i.push(new $r(t,n,`expected one of [${Object.keys(r.values).join(", ")}], ${JSON.stringify(n)} found`)),i}function Jr(e){if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!Jr(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}}function Qr(e,t="fill"){if(null==e)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Jr(e)||(e=ii(e));const n=e;let r=!0;try{r=function(e){if(!ei(e))return e;let t=et(e);return function e(t){let n=!1;const r=[];if("case"===t[0]){for(let e=1;ee(t))}(t),t}(n)}catch(e){console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate.\nThis is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md\nand paste the contents of this message in the report.\nThank you!\nFilter Expression:\n${JSON.stringify(n,null,2)}\n `)}const i=Ke["filter_"+t],o=Nr(r,i);let a=null;if("error"===o.result)throw new Error(o.value.map(e=>`${e.key}: ${e.message}`).join(", "));a=(e,t,n)=>o.value.evaluate(e,t,{},n);let s=null,l=null;if(r!==n){const e=Nr(n,i);if("error"===e.result)throw new Error(e.value.map(e=>`${e.key}: ${e.message}`).join(", "));s=(t,n,r,i,o)=>e.value.evaluate(t,n,{},r,void 0,void 0,i,o),l=!yn(e.value.expression)}return{filter:a,dynamicFilter:s||void 0,needGeometry:ri(r),needFeature:!!l}}function ei(e){if(!Array.isArray(e))return!1;if("pitch"===(t=e[0])||"distance-from-center"===t)return!0;var t;for(let t=1;t",">=","<","<=","to-boolean"]);function ni(e,t){return et?1:0}function ri(e){if(!Array.isArray(e))return!1;if("within"===e[0])return!0;for(let t=1;t"===t||"<="===t||">="===t?oi(e[1],e[2],t):"any"===t?(n=e.slice(1),["any"].concat(n.map(ii))):"all"===t?["all"].concat(e.slice(1).map(ii)):"none"===t?["all"].concat(e.slice(1).map(ii).map(li)):"in"===t?ai(e[1],e.slice(2)):"!in"===t?li(ai(e[1],e.slice(2))):"has"===t?si(e[1]):"!has"===t?li(si(e[1])):"within"!==t||e;var n}function oi(e,t,n){switch(e){case"$type":return["filter-type-"+n,t];case"$id":return["filter-id-"+n,t];default:return["filter-"+n,e,t]}}function ai(e,t){if(0===t.length)return!1;switch(e){case"$type":return["filter-type-in",["literal",t]];case"$id":return["filter-id-in",["literal",t]];default:return t.length>200&&!t.some(e=>typeof e!=typeof t[0])?["filter-in-large",e,["literal",t.sort(ni)]]:["filter-in-small",e,["literal",t]]}}function si(e){switch(e){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",e]}}function li(e){return["!",e]}function ui(e){return Jr(et(e.value))?Yr(Je({},e,{expressionContext:"filter",valueSpec:e.styleSpec["filter_"+(e.layerType||"fill")]})):function e(t){const n=t.value,r=t.key;if("array"!==Ir(n))return[new $r(r,n,`array expected, ${Ir(n)} found`)];const i=t.styleSpec;let o,a=[];if(n.length<1)return[new $r(r,n,"filter array must have at least 1 element")];switch(a=a.concat(Kr({key:r+"[0]",value:n[0],valueSpec:i.filter_operator,style:t.style,styleSpec:t.styleSpec})),Qe(n[0])){case"<":case"<=":case">":case">=":n.length>=2&&"$type"===Qe(n[1])&&a.push(new $r(r,n,`"$type" cannot be use with operator "${n[0]}"`));case"==":case"!=":3!==n.length&&a.push(new $r(r,n,`filter array for operator "${n[0]}" must have 3 elements`));case"in":case"!in":n.length>=2&&(o=Ir(n[1]),"string"!==o&&a.push(new $r(r+"[1]",n[1],`string expected, ${o} found`)));for(let e=2;e{e in n&&t.push(new $r(r,n[e],`"${e}" is prohibited for ref layers`))}),i.layers.forEach(t=>{Qe(t.id)===s&&(e=t)}),e?e.ref?t.push(new $r(r,n.ref,"ref cannot reference another ref layer")):a=Qe(e.type):"string"==typeof s&&t.push(new $r(r,n.ref,`ref layer "${s}" not found`))}else if("background"!==a&&"sky"!==a)if(n.source){const e=i.sources&&i.sources[n.source],o=e&&Qe(e.type);e?"vector"===o&&"raster"===a?t.push(new $r(r,n.source,`layer "${n.id}" requires a raster source`)):"raster"===o&&"raster"!==a?t.push(new $r(r,n.source,`layer "${n.id}" requires a vector source`)):"vector"!==o||n["source-layer"]?"raster-dem"===o&&"hillshade"!==a?t.push(new $r(r,n.source,"raster-dem source can only be used with layer type 'hillshade'.")):"line"!==a||!n.paint||!n.paint["line-gradient"]&&!n.paint["line-trim-offset"]||"geojson"===o&&e.lineMetrics||t.push(new $r(r,n,`layer "${n.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):t.push(new $r(r,n,`layer "${n.id}" must specify a "source-layer"`)):t.push(new $r(r,n.source,`source "${n.source}" not found`))}else t.push(new $r(r,n,'missing required property "source"'));return t=t.concat(Zr({key:r,value:n,valueSpec:o.layer,style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":()=>[],type:()=>wi({key:r+".type",value:n.type,valueSpec:o.layer.type,style:e.style,styleSpec:e.styleSpec,object:n,objectKey:"type"}),filter:e=>ui(Je({layerType:a},e)),layout:e=>Zr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>di(Je({layerType:a},e))}}),paint:e=>Zr({layer:n,key:e.key,value:e.value,valueSpec:{},style:e.style,styleSpec:e.styleSpec,objectElementValidators:{"*":e=>hi(Je({layerType:a},e))}})}})),t}function pi(e){const t=e.value,n=e.key,r=Ir(t);return"string"!==r?[new $r(n,t,`string expected, ${r} found`)]:[]}const mi={promoteId:function({key:e,value:t}){if("string"===Ir(t))return pi({key:e,value:t});{const n=[];for(const r in t)n.push(...pi({key:`${e}.${r}`,value:t[r]}));return n}}};function _i(e){const t=e.value,n=e.key,r=e.styleSpec,i=e.style;if(!t.type)return[new $r(n,t,'"type" is required')];const o=Qe(t.type);let a;switch(o){case"vector":case"raster":case"raster-dem":return a=Zr({key:n,value:t,valueSpec:r["source_"+o.replace("-","_")],style:e.style,styleSpec:r,objectElementValidators:mi}),a;case"geojson":if(a=Zr({key:n,value:t,valueSpec:r.source_geojson,style:i,styleSpec:r,objectElementValidators:mi}),t.cluster)for(const e in t.clusterProperties){const[r,i]=t.clusterProperties[e],o="string"==typeof r?[r,["accumulated"],["get",e]]:r;a.push(...Yr({key:`${n}.${e}.map`,value:i,expressionContext:"cluster-map"})),a.push(...Yr({key:`${n}.${e}.reduce`,value:o,expressionContext:"cluster-reduce"}))}return a;case"video":return Zr({key:n,value:t,valueSpec:r.source_video,style:i,styleSpec:r});case"image":return Zr({key:n,value:t,valueSpec:r.source_image,style:i,styleSpec:r});case"canvas":return[new $r(n,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return Kr({key:n+".type",value:t.type,valueSpec:{values:gi(r)},style:i,styleSpec:r})}}function gi(e){return e.source.reduce((t,n)=>{const r=e[n];return"enum"===r.type.type&&(t=t.concat(Object.keys(r.type.values))),t},[])}function yi(e){const t=e.value,n=e.styleSpec,r=n.light,i=e.style;let o=[];const a=Ir(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new $r("light",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&r[a[1]]&&r[a[1]].transition?wi({key:e,value:t[e],valueSpec:n.transition,style:i,styleSpec:n}):r[e]?wi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}):[new $r(e,t[e],`unknown property "${e}"`)])}return o}function vi(e){const t=e.value,n=e.key,r=e.style,i=e.styleSpec,o=i.terrain;let a=[];const s=Ir(t);if(void 0===t)return a;if("object"!==s)return a=a.concat([new $r("terrain",t,`object expected, ${s} found`)]),a;for(const e in t){const n=e.match(/^(.*)-transition$/);a=a.concat(n&&o[n[1]]&&o[n[1]].transition?wi({key:e,value:t[e],valueSpec:i.transition,style:r,styleSpec:i}):o[e]?wi({key:e,value:t[e],valueSpec:o[e],style:r,styleSpec:i}):[new $r(e,t[e],`unknown property "${e}"`)])}if(t.source){const e=r.sources&&r.sources[t.source],i=e&&Qe(e.type);e?"raster-dem"!==i&&a.push(new $r(n,t.source,`terrain cannot be used with a source of type ${String(i)}, it only be used with a "raster-dem" source type`)):a.push(new $r(n,t.source,`source "${t.source}" not found`))}else a.push(new $r(n,t,'terrain is missing required property "source"'));return a}function xi(e){const t=e.value,n=e.style,r=e.styleSpec,i=r.fog;let o=[];const a=Ir(t);if(void 0===t)return o;if("object"!==a)return o=o.concat([new $r("fog",t,`object expected, ${a} found`)]),o;for(const e in t){const a=e.match(/^(.*)-transition$/);o=o.concat(a&&i[a[1]]&&i[a[1]].transition?wi({key:e,value:t[e],valueSpec:r.transition,style:n,styleSpec:r}):i[e]?wi({key:e,value:t[e],valueSpec:i[e],style:n,styleSpec:r}):[new $r(e,t[e],`unknown property "${e}"`)])}return o}const bi={"*":()=>[],array:Wr,boolean:function(e){const t=e.value,n=e.key,r=Ir(t);return"boolean"!==r?[new $r(n,t,`boolean expected, ${r} found`)]:[]},number:Xr,color:function(e){const t=e.key,n=e.value,r=Ir(n);return"string"!==r?[new $r(t,n,`color expected, ${r} found`)]:null===bt(n)?[new $r(t,n,`color expected, "${n}" found`)]:[]},enum:Kr,filter:ui,function:Hr,layer:fi,object:Zr,source:_i,light:yi,terrain:vi,fog:xi,string:pi,formatted:function(e){return 0===pi(e).length?[]:Yr(e)},resolvedImage:function(e){return 0===pi(e).length?[]:Yr(e)},projection:function(e){const t=e.value,n=e.styleSpec,r=n.projection,i=e.style;let o=[];const a=Ir(t);if("object"===a)for(const e in t)o=o.concat(wi({key:e,value:t[e],valueSpec:r[e],style:i,styleSpec:n}));else"string"!==a&&(o=o.concat([new $r("projection",t,`object or string expected, ${a} found`)]));return o}};function wi(e){const t=e.value,n=e.valueSpec,r=e.styleSpec;return n.expression&&Pr(Qe(t))?Hr(e):n.expression&&jr(et(t))?Yr(e):n.type&&bi[n.type]?bi[n.type](e):Zr(Je({},e,{valueSpec:n.type?r[n.type]:n}))}function Ei(e){const t=e.value,n=e.key,r=pi(e);return r.length||(-1===t.indexOf("{fontstack}")&&r.push(new $r(n,t,'"glyphs" url must include a "{fontstack}" token')),-1===t.indexOf("{range}")&&r.push(new $r(n,t,'"glyphs" url must include a "{range}" token'))),r}function Ti(e,t=Ke){return Ci(wi({key:"",value:e,valueSpec:t.$root,styleSpec:t,style:e,objectElementValidators:{glyphs:Ei,"*":()=>[]}}))}const Si=e=>Ci(hi(e)),ki=e=>Ci(di(e));function Ci(e){return e.slice().sort((e,t)=>e.line&&t.line?e.line-t.line:0)}function Mi(e,t){let n=!1;if(t&&t.length)for(const r of t)e.fire(new He(new Error(r.message))),n=!0;return n}var Ai=Ii;function Ii(e,t,n){var r=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;var i=new Int32Array(this.arrayBuffer);e=i[0],this.d=(t=i[1])+2*(n=i[2]);for(var o=0;o=c[f+0]&&r>=c[f+1])?(a[d]=!0,o.push(u[d])):a[d]=!1}}},Ii.prototype._forEachCell=function(e,t,n,r,i,o,a,s){for(var l=this._convertToCellCoord(e),u=this._convertToCellCoord(t),c=this._convertToCellCoord(n),h=this._convertToCellCoord(r),d=l;d<=c;d++)for(var f=u;f<=h;f++){var p=this.d*f+d;if((!s||s(this._convertFromCellCoord(d),this._convertFromCellCoord(f),this._convertFromCellCoord(d+1),this._convertFromCellCoord(f+1)))&&i.call(this,e,t,n,r,p,o,a,s))return}},Ii.prototype._convertFromCellCoord=function(e){return(e-this.padding)/this.scale},Ii.prototype._convertToCellCoord=function(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))},Ii.prototype.toArrayBuffer=function(){if(this.arrayBuffer)return this.arrayBuffer;for(var e=this.cells,t=3+this.cells.length+1+1,n=0,r=0;r=0||(i[n]=Li(e[n],t)));e instanceof Error&&(i.message=e.message)}if(i.$name)throw new Error("$name property is reserved for worker serialization logic.");return"Object"!==r&&(i.$name=r),i}throw new Error("can't serialize object of type "+typeof e)}function Ri(e){if(null==e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||e instanceof Boolean||e instanceof Number||e instanceof String||e instanceof Date||e instanceof RegExp||Oi(e)||Di(e)||ArrayBuffer.isView(e)||e instanceof n.ImageData)return e;if(Array.isArray(e))return e.map(Ri);if("object"==typeof e){const t=e.$name||"Object",{klass:n}=Pi[t];if(!n)throw new Error("can't deserialize unregistered class "+t);if(n.deserialize)return n.deserialize(e);const r=Object.create(n.prototype);for(const t of Object.keys(e))"$name"!==t&&(r[t]=Ri(e[t]));return r}throw new Error("can't deserialize object of type "+typeof e)}const Bi=e=>e>=1536&&e<=1791,Fi=e=>e>=1872&&e<=1919,ji=e=>e>=2208&&e<=2303,Ni=e=>e>=11904&&e<=12031,Ui=e=>e>=12032&&e<=12255,Vi=e=>e>=12272&&e<=12287,Gi=e=>e>=12288&&e<=12351,qi=e=>e>=12352&&e<=12447,$i=e=>e>=12448&&e<=12543,Zi=e=>e>=12544&&e<=12591,Wi=e=>e>=12704&&e<=12735,Xi=e=>e>=12736&&e<=12783,Hi=e=>e>=12784&&e<=12799,Yi=e=>e>=12800&&e<=13055,Ki=e=>e>=13056&&e<=13311,Ji=e=>e>=13312&&e<=19903,Qi=e=>e>=19968&&e<=40959,eo=e=>e>=40960&&e<=42127,to=e=>e>=42128&&e<=42191,no=e=>e>=44032&&e<=55215,ro=e=>e>=63744&&e<=64255,io=e=>e>=64336&&e<=65023,oo=e=>e>=65040&&e<=65055,ao=e=>e>=65072&&e<=65103,so=e=>e>=65104&&e<=65135,lo=e=>e>=65136&&e<=65279,uo=e=>e>=65280&&e<=65519;function co(e){for(const t of e)if(po(t.charCodeAt(0)))return!0;return!1}function ho(e){for(const t of e)if(!fo(t.charCodeAt(0)))return!1;return!0}function fo(e){return!(Bi(e)||Fi(e)||ji(e)||io(e)||lo(e))}function po(e){return!(746!==e&&747!==e&&(e<4352||!(Wi(e)||Zi(e)||ao(e)&&!(e>=65097&&e<=65103)||ro(e)||Ki(e)||Ni(e)||Xi(e)||!(!Gi(e)||e>=12296&&e<=12305||e>=12308&&e<=12319||12336===e)||Ji(e)||Qi(e)||Yi(e)||(e=>e>=12592&&e<=12687)(e)||(e=>e>=43360&&e<=43391)(e)||(e=>e>=55216&&e<=55295)(e)||(e=>e>=4352&&e<=4607)(e)||no(e)||qi(e)||Vi(e)||(e=>e>=12688&&e<=12703)(e)||Ui(e)||Hi(e)||$i(e)&&12540!==e||!(!uo(e)||65288===e||65289===e||65293===e||e>=65306&&e<=65310||65339===e||65341===e||65343===e||e>=65371&&e<=65503||65507===e||e>=65512&&e<=65519)||!(!so(e)||e>=65112&&e<=65118||e>=65123&&e<=65126)||(e=>e>=5120&&e<=5759)(e)||(e=>e>=6320&&e<=6399)(e)||oo(e)||(e=>e>=19904&&e<=19967)(e)||eo(e)||to(e))))}function mo(e){return!(po(e)||function(e){return!!((e=>e>=128&&e<=255)(e)&&(167===e||169===e||174===e||177===e||188===e||189===e||190===e||215===e||247===e)||(e=>e>=8192&&e<=8303)(e)&&(8214===e||8224===e||8225===e||8240===e||8241===e||8251===e||8252===e||8258===e||8263===e||8264===e||8265===e||8273===e)||(e=>e>=8448&&e<=8527)(e)||(e=>e>=8528&&e<=8591)(e)||(e=>e>=8960&&e<=9215)(e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||9003===e||e>=9085&&e<=9114||e>=9150&&e<=9165||9167===e||e>=9169&&e<=9179||e>=9186&&e<=9215)||(e=>e>=9216&&e<=9279)(e)&&9251!==e||(e=>e>=9280&&e<=9311)(e)||(e=>e>=9312&&e<=9471)(e)||(e=>e>=9632&&e<=9727)(e)||(e=>e>=9728&&e<=9983)(e)&&!(e>=9754&&e<=9759)||(e=>e>=11008&&e<=11263)(e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Gi(e)||$i(e)||(e=>e>=57344&&e<=63743)(e)||ao(e)||so(e)||uo(e)||8734===e||8756===e||8757===e||e>=9984&&e<=10087||e>=10102&&e<=10131||65532===e||65533===e)}(e))}function _o(e){return e>=1424&&e<=2303||io(e)||lo(e)}function go(e,t){return!(!t&&_o(e)||e>=2304&&e<=3583||e>=3840&&e<=4255||(e=>e>=6016&&e<=6143)(e))}function yo(e){for(const t of e)if(_o(t.charCodeAt(0)))return!0;return!1}const vo="deferred",xo="loading",bo="loaded";let wo=null,Eo="unavailable",To=null;const So=function(e){e&&"string"==typeof e&&e.indexOf("NetworkError")>-1&&(Eo="error"),wo&&wo(e)};function ko(){Co.fire(new Xe("pluginStateChange",{pluginStatus:Eo,pluginURL:To}))}const Co=new Ye,Mo=function(){return Eo},Ao=function(){if(Eo!==vo||!To)throw new Error("rtl-text-plugin cannot be downloaded unless a pluginURL is specified");Eo=xo,ko(),To&&ce({url:To},e=>{e?So(e):(Eo=bo,ko())})},Io={applyArabicShaping:null,processBidirectionalText:null,processStyledBidirectionalText:null,isLoaded:()=>Eo===bo||null!=Io.applyArabicShaping,isLoading:()=>Eo===xo,setState(e){Eo=e.pluginStatus,To=e.pluginURL},isParsed:()=>null!=Io.applyArabicShaping&&null!=Io.processBidirectionalText&&null!=Io.processStyledBidirectionalText,getPluginURL:()=>To};class Po{constructor(e,t){this.zoom=e,t?(this.now=t.now,this.fadeDuration=t.fadeDuration,this.transition=t.transition,this.pitch=t.pitch):(this.now=0,this.fadeDuration=0,this.transition={},this.pitch=0)}isSupportedScript(e){return function(e,t){for(const n of e)if(!go(n.charCodeAt(0),t))return!1;return!0}(e,Io.isLoaded())}}class zo{constructor(e,t){this.property=e,this.value=t,this.expression=function(e,t){if(Pr(e))return new qr(e,t);if(jr(e)){const n=Gr(e,t);if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));return n.value}{let n=e;return"string"==typeof e&&"color"===t.type&&(n=Mt.parse(e)),{kind:"constant",evaluate:()=>n}}}(void 0===t?e.specification.default:t,e.specification)}isDataDriven(){return"source"===this.expression.kind||"composite"===this.expression.kind}possiblyEvaluate(e,t,n){return this.property.possiblyEvaluate(this,e,t,n)}}class Oo{constructor(e){this.property=e,this.value=new zo(e,void 0)}transitioned(e,t){return new Lo(this.property,this.value,t,I({},e.transition,this.transition),e.now)}untransitioned(){return new Lo(this.property,this.value,null,{},0)}}class Do{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return N(this._values[e].value.value)}setValue(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Oo(this._values[e].property)),this._values[e].value=new zo(this._values[e].property,null===t?void 0:N(t))}getTransition(e){return N(this._values[e].transition)}setTransition(e,t){this._values.hasOwnProperty(e)||(this._values[e]=new Oo(this._values[e].property)),this._values[e].transition=N(t)||void 0}serialize(){const e={};for(const t of Object.keys(this._values)){const n=this.getValue(t);void 0!==n&&(e[t]=n);const r=this.getTransition(t);void 0!==r&&(e[t+"-transition"]=r)}return e}transitioned(e,t){const n=new Ro(this._properties);for(const r of Object.keys(this._values))n._values[r]=this._values[r].transitioned(e,t._values[r]);return n}untransitioned(){const e=new Ro(this._properties);for(const t of Object.keys(this._values))e._values[t]=this._values[t].untransitioned();return e}}class Lo{constructor(e,t,n,r,i){const o=r.delay||0,a=r.duration||0;i=i||0,this.property=e,this.value=t,this.begin=i+o,this.end=this.begin+a,e.specification.transition&&(r.delay||r.duration)&&(this.prior=n)}possiblyEvaluate(e,t,n){const r=e.now||0,i=this.value.possiblyEvaluate(e,t,n),o=this.prior;if(o){if(r>this.end)return this.prior=null,i;if(this.value.isDataDriven())return this.prior=null,i;if(rthis.capacity){this.capacity=Math.max(e,Math.floor(5*this.capacity),128),this.arrayBuffer=new ArrayBuffer(this.capacity*this.bytesPerElement);const t=this.uint8;this._refreshViews(),t&&this.uint8.set(t)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}destroy(){this.int8=this.uint8=this.int16=this.uint16=this.int32=this.uint32=this.float32=null,this.arrayBuffer=null}}function Xo(e,t=1){let n=0,r=0;return{members:e.map(e=>{const i=$o[e.type].BYTES_PER_ELEMENT,o=n=Ho(n,Math.max(t,i)),a=e.components||1;return r=Math.max(r,i),n+=i*a,{name:e.name,type:e.type,components:a,offset:o}}),size:Ho(n,Math.max(r,t)),alignment:t}}function Ho(e,t){return Math.ceil(e/t)*t}class Yo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.int16[r+0]=t,this.int16[r+1]=n,e}}Yo.prototype.bytesPerElement=4,zi(Yo,"StructArrayLayout2i4");class Ko extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.int16[i+0]=t,this.int16[i+1]=n,this.int16[i+2]=r,e}}Ko.prototype.bytesPerElement=6,zi(Ko,"StructArrayLayout3i6");class Jo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.int16[o+0]=t,this.int16[o+1]=n,this.int16[o+2]=r,this.int16[o+3]=i,e}}Jo.prototype.bytesPerElement=8,zi(Jo,"StructArrayLayout4i8");class Qo extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=6*e,u=12*e,c=3*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.uint8[u+4]=r,this.uint8[u+5]=i,this.uint8[u+6]=o,this.uint8[u+7]=a,this.float32[c+2]=s,e}}Qo.prototype.bytesPerElement=12,zi(Qo,"StructArrayLayout2i4ub1f12");class ea extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.float32[o+0]=t,this.float32[o+1]=n,this.float32[o+2]=r,this.float32[o+3]=i,e}}ea.prototype.bytesPerElement=16,zi(ea,"StructArrayLayout4f16");class ta extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=6*e,s=3*e;return this.uint16[a+0]=t,this.uint16[a+1]=n,this.uint16[a+2]=r,this.uint16[a+3]=i,this.float32[s+2]=o,e}}ta.prototype.bytesPerElement=12,zi(ta,"StructArrayLayout4ui1f12");class na extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=4*e;return this.uint16[o+0]=t,this.uint16[o+1]=n,this.uint16[o+2]=r,this.uint16[o+3]=i,e}}na.prototype.bytesPerElement=8,zi(na,"StructArrayLayout4ui8");class ra extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=6*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.int16[s+3]=i,this.int16[s+4]=o,this.int16[s+5]=a,e}}ra.prototype.bytesPerElement=12,zi(ra,"StructArrayLayout6i12");class ia extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h){const d=this.length;return this.resize(d+1),this.emplace(d,e,t,n,r,i,o,a,s,l,u,c,h)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=12*e;return this.int16[f+0]=t,this.int16[f+1]=n,this.int16[f+2]=r,this.int16[f+3]=i,this.uint16[f+4]=o,this.uint16[f+5]=a,this.uint16[f+6]=s,this.uint16[f+7]=l,this.int16[f+8]=u,this.int16[f+9]=c,this.int16[f+10]=h,this.int16[f+11]=d,e}}ia.prototype.bytesPerElement=24,zi(ia,"StructArrayLayout4i4ui4i24");class oa extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o){const a=this.length;return this.resize(a+1),this.emplace(a,e,t,n,r,i,o)}emplace(e,t,n,r,i,o,a){const s=10*e,l=5*e;return this.int16[s+0]=t,this.int16[s+1]=n,this.int16[s+2]=r,this.float32[l+2]=i,this.float32[l+3]=o,this.float32[l+4]=a,e}}oa.prototype.bytesPerElement=20,zi(oa,"StructArrayLayout3i3f20");class aa extends Wo{_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}}aa.prototype.bytesPerElement=4,zi(aa,"StructArrayLayout1ul4");class sa extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=this.length;return this.resize(f+1),this.emplace(f,e,t,n,r,i,o,a,s,l,u,c,h,d)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=20*e,m=10*e;return this.int16[p+0]=t,this.int16[p+1]=n,this.int16[p+2]=r,this.int16[p+3]=i,this.int16[p+4]=o,this.float32[m+3]=a,this.float32[m+4]=s,this.float32[m+5]=l,this.float32[m+6]=u,this.int16[p+14]=c,this.uint32[m+8]=h,this.uint16[p+18]=d,this.uint16[p+19]=f,e}}sa.prototype.bytesPerElement=40,zi(sa,"StructArrayLayout5i4f1i1ul2ui40");class la extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a){const s=this.length;return this.resize(s+1),this.emplace(s,e,t,n,r,i,o,a)}emplace(e,t,n,r,i,o,a,s){const l=8*e;return this.int16[l+0]=t,this.int16[l+1]=n,this.int16[l+2]=r,this.int16[l+4]=i,this.int16[l+5]=o,this.int16[l+6]=a,this.int16[l+7]=s,e}}la.prototype.bytesPerElement=16,zi(la,"StructArrayLayout3i2i2i16");class ua extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=4*e,s=8*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.int16[s+6]=i,this.int16[s+7]=o,e}}ua.prototype.bytesPerElement=16,zi(ua,"StructArrayLayout2f1f2i16");class ca extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=12*e,a=3*e;return this.uint8[o+0]=t,this.uint8[o+1]=n,this.float32[a+1]=r,this.float32[a+2]=i,e}}ca.prototype.bytesPerElement=12,zi(ca,"StructArrayLayout2ub2f12");class ha extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.float32[i+0]=t,this.float32[i+1]=n,this.float32[i+2]=r,e}}ha.prototype.bytesPerElement=12,zi(ha,"StructArrayLayout3f12");class da extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n){const r=this.length;return this.resize(r+1),this.emplace(r,e,t,n)}emplace(e,t,n,r){const i=3*e;return this.uint16[i+0]=t,this.uint16[i+1]=n,this.uint16[i+2]=r,e}}da.prototype.bytesPerElement=6,zi(da,"StructArrayLayout3ui6");class fa extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x){const b=this.length;return this.resize(b+1),this.emplace(b,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b){const w=30*e,E=15*e,T=60*e;return this.int16[w+0]=t,this.int16[w+1]=n,this.int16[w+2]=r,this.float32[E+2]=i,this.float32[E+3]=o,this.uint16[w+8]=a,this.uint16[w+9]=s,this.uint32[E+5]=l,this.uint32[E+6]=u,this.uint32[E+7]=c,this.uint16[w+16]=h,this.uint16[w+17]=d,this.uint16[w+18]=f,this.float32[E+10]=p,this.float32[E+11]=m,this.uint8[T+48]=_,this.uint8[T+49]=g,this.uint8[T+50]=y,this.uint32[E+13]=v,this.int16[w+28]=x,this.uint8[T+58]=b,e}}fa.prototype.bytesPerElement=60,zi(fa,"StructArrayLayout3i2f2ui3ul3ui2f3ub1ul1i1ub60");class pa extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,C,M,A){const I=this.length;return this.resize(I+1),this.emplace(I,e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,C,M,A)}emplace(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T,S,k,C,M,A,I){const P=38*e,z=19*e;return this.int16[P+0]=t,this.int16[P+1]=n,this.int16[P+2]=r,this.float32[z+2]=i,this.float32[z+3]=o,this.int16[P+8]=a,this.int16[P+9]=s,this.int16[P+10]=l,this.int16[P+11]=u,this.int16[P+12]=c,this.int16[P+13]=h,this.uint16[P+14]=d,this.uint16[P+15]=f,this.uint16[P+16]=p,this.uint16[P+17]=m,this.uint16[P+18]=_,this.uint16[P+19]=g,this.uint16[P+20]=y,this.uint16[P+21]=v,this.uint16[P+22]=x,this.uint16[P+23]=b,this.uint16[P+24]=w,this.uint16[P+25]=E,this.uint16[P+26]=T,this.uint16[P+27]=S,this.uint16[P+28]=k,this.uint32[z+15]=C,this.float32[z+16]=M,this.float32[z+17]=A,this.float32[z+18]=I,e}}pa.prototype.bytesPerElement=76,zi(pa,"StructArrayLayout3i2f6i15ui1ul3f76");class ma extends Wo{_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}}ma.prototype.bytesPerElement=4,zi(ma,"StructArrayLayout1f4");class _a extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t,n,r,i){const o=this.length;return this.resize(o+1),this.emplace(o,e,t,n,r,i)}emplace(e,t,n,r,i,o){const a=5*e;return this.float32[a+0]=t,this.float32[a+1]=n,this.float32[a+2]=r,this.float32[a+3]=i,this.float32[a+4]=o,e}}_a.prototype.bytesPerElement=20,zi(_a,"StructArrayLayout5f20");class ga extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t,n,r){const i=this.length;return this.resize(i+1),this.emplace(i,e,t,n,r)}emplace(e,t,n,r,i){const o=6*e;return this.uint32[3*e+0]=t,this.uint16[o+2]=n,this.uint16[o+3]=r,this.uint16[o+4]=i,e}}ga.prototype.bytesPerElement=12,zi(ga,"StructArrayLayout1ul3ui12");class ya extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.uint16[r+0]=t,this.uint16[r+1]=n,e}}ya.prototype.bytesPerElement=4,zi(ya,"StructArrayLayout2ui4");class va extends Wo{_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}}va.prototype.bytesPerElement=2,zi(va,"StructArrayLayout1ui2");class xa extends Wo{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,t){const n=this.length;return this.resize(n+1),this.emplace(n,e,t)}emplace(e,t,n){const r=2*e;return this.float32[r+0]=t,this.float32[r+1]=n,e}}xa.prototype.bytesPerElement=8,zi(xa,"StructArrayLayout2f8");class ba extends Zo{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]}}ba.prototype.size=40;class wa extends sa{get(e){return new ba(this,e)}}zi(wa,"CollisionBoxArray");class Ea extends Zo{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}}Ea.prototype.size=60;class Ta extends fa{get(e){return new Ea(this,e)}}zi(Ta,"PlacedSymbolArray");class Sa extends Zo{get projectedAnchorX(){return this._structArray.int16[this._pos2+0]}get projectedAnchorY(){return this._structArray.int16[this._pos2+1]}get projectedAnchorZ(){return this._structArray.int16[this._pos2+2]}get tileAnchorX(){return this._structArray.float32[this._pos4+2]}get tileAnchorY(){return this._structArray.float32[this._pos4+3]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+8]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+9]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+10]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+11]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+12]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+13]}get key(){return this._structArray.uint16[this._pos2+14]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+17]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+18]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+19]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+20]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+21]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+22]}get featureIndex(){return this._structArray.uint16[this._pos2+23]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+24]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+25]}get numIconVertices(){return this._structArray.uint16[this._pos2+26]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+27]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+28]}get crossTileID(){return this._structArray.uint32[this._pos4+15]}set crossTileID(e){this._structArray.uint32[this._pos4+15]=e}get textOffset0(){return this._structArray.float32[this._pos4+16]}get textOffset1(){return this._structArray.float32[this._pos4+17]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+18]}}Sa.prototype.size=76;class ka extends pa{get(e){return new Sa(this,e)}}zi(ka,"SymbolInstanceArray");class Ca extends ma{getoffsetX(e){return this.float32[1*e+0]}}zi(Ca,"GlyphOffsetArray");class Ma extends Yo{getx(e){return this.int16[2*e+0]}gety(e){return this.int16[2*e+1]}}zi(Ma,"SymbolLineVertexArray");class Aa extends Zo{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]}}Aa.prototype.size=12;class Ia extends ga{get(e){return new Aa(this,e)}}zi(Ia,"FeatureIndexArray");class Pa extends ya{geta_centroid_pos0(e){return this.uint16[2*e+0]}geta_centroid_pos1(e){return this.uint16[2*e+1]}}zi(Pa,"FillExtrusionCentroidArray");const za=Xo([{name:"a_pattern",components:4,type:"Uint16"},{name:"a_pixel_ratio",components:1,type:"Float32"}]),Oa=Xo([{name:"a_dash",components:4,type:"Uint16"}]);var Da={exports:{}},La={exports:{}};La.exports=function(e,t){var n,r,i,o,a,s,l,u;for(r=e.length-(n=3&e.length),i=t,a=3432918353,s=461845907,u=0;u>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295)<<13|i>>>19))+((5*(i>>>16)&65535)<<16)&4294967295))+((58964+(o>>>16)&65535)<<16);switch(l=0,n){case 3:l^=(255&e.charCodeAt(u+2))<<16;case 2:l^=(255&e.charCodeAt(u+1))<<8;case 1:i^=l=(65535&(l=(l=(65535&(l^=255&e.charCodeAt(u)))*a+(((l>>>16)*a&65535)<<16)&4294967295)<<15|l>>>17))*s+(((l>>>16)*s&65535)<<16)&4294967295}return i^=e.length,i=2246822507*(65535&(i^=i>>>16))+((2246822507*(i>>>16)&65535)<<16)&4294967295,i=3266489909*(65535&(i^=i>>>13))+((3266489909*(i>>>16)&65535)<<16)&4294967295,(i^=i>>>16)>>>0};var Ra={exports:{}};Ra.exports=function(e,t){for(var n,r=e.length,i=t^r,o=0;r>=4;)n=1540483477*(65535&(n=255&e.charCodeAt(o)|(255&e.charCodeAt(++o))<<8|(255&e.charCodeAt(++o))<<16|(255&e.charCodeAt(++o))<<24))+((1540483477*(n>>>16)&65535)<<16),i=1540483477*(65535&i)+((1540483477*(i>>>16)&65535)<<16)^(n=1540483477*(65535&(n^=n>>>24))+((1540483477*(n>>>16)&65535)<<16)),r-=4,++o;switch(r){case 3:i^=(255&e.charCodeAt(o+2))<<16;case 2:i^=(255&e.charCodeAt(o+1))<<8;case 1:i=1540483477*(65535&(i^=255&e.charCodeAt(o)))+((1540483477*(i>>>16)&65535)<<16)}return i=1540483477*(65535&(i^=i>>>13))+((1540483477*(i>>>16)&65535)<<16),(i^=i>>>15)>>>0};var Ba=La.exports,Fa=Ra.exports;Da.exports=Ba,Da.exports.murmur3=Ba,Da.exports.murmur2=Fa;class ja{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,t,n,r){this.ids.push(Na(e)),this.positions.push(t,n,r)}getPositions(e){const t=Na(e);let n=0,r=this.ids.length-1;for(;n>1;this.ids[e]>=t?r=e:n=e+1}const i=[];for(;this.ids[n]===t;)i.push({index:this.positions[3*n],start:this.positions[3*n+1],end:this.positions[3*n+2]}),n++;return i}static serialize(e,t){const n=new Float64Array(e.ids),r=new Uint32Array(e.positions);return function e(t,n,r,i){for(;r>1];let a=r-1,s=i+1;for(;;){do{a++}while(t[a]o);if(a>=s)break;Ua(t,a,s),Ua(n,3*a,3*s),Ua(n,3*a+1,3*s+1),Ua(n,3*a+2,3*s+2)}s-r"u_"+e),this.type=n}setUniform(e,t,n,r,i){t.set(e,i,r.constantOr(this.value))}getBinding(e,t){return"color"===this.type?new $a(e):new Ga(e)}}class Ka{constructor(e,t){this.uniformNames=t.map(e=>"u_"+e),this.pattern=null,this.pixelRatio=1}setConstantPatternPositions(e){this.pixelRatio=e.pixelRatio||1,this.pattern=e.tl.concat(e.br)}setUniform(e,t,n,r,i){const o="u_pattern"===i||"u_dash"===i?this.pattern:"u_pixel_ratio"===i?this.pixelRatio:null;o&&t.set(e,i,o)}getBinding(e,t){return"u_pattern"===t||"u_dash"===t?new qa(e):new Ga(e)}}class Ja{constructor(e,t,n,r){this.expression=e,this.type=n,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?2:1,offset:0})),this.paintVertexArray=new r}populatePaintArray(e,t,n,r,i,o){const a=this.paintVertexArray.length,s=this.expression.evaluate(new Po(0),t,{},i,r,o);this.paintVertexArray.resize(e),this._setPaintValue(a,e,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:0},n,r,void 0,i);this._setPaintValue(e,t,o)}_setPaintValue(e,t,n){if("color"===this.type){const r=Ha(n);for(let n=e;n`u_${e}_t`),this.type=n,this.useIntegerZoom=r,this.zoom=i,this.maxValue=0,this.paintVertexAttributes=t.map(e=>({name:"a_"+e,type:"Float32",components:"color"===n?4:2,offset:0})),this.paintVertexArray=new o}populatePaintArray(e,t,n,r,i,o){const a=this.expression.evaluate(new Po(this.zoom),t,{},i,r,o),s=this.expression.evaluate(new Po(this.zoom+1),t,{},i,r,o),l=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(l,e,a,s)}updatePaintArray(e,t,n,r,i){const o=this.expression.evaluate({zoom:this.zoom},n,r,void 0,i),a=this.expression.evaluate({zoom:this.zoom+1},n,r,void 0,i);this._setPaintValue(e,t,o,a)}_setPaintValue(e,t,n,r){if("color"===this.type){const i=Ha(n),o=Ha(r);for(let n=e;n!0)){this.binders={},this._buffers=[];const r=[];for(const i in e.paint._values){if(!n(i))continue;const o=e.paint.get(i);if(!(o instanceof Fo&&Cr(o.property.specification)))continue;const a=is(i,e.type),s=o.value,l=o.property.specification.type,u=o.property.useIntegerZoom,c="line-dasharray"===i||i.endsWith("pattern"),h="line-dasharray"===i&&"constant"!==e.layout.get("line-cap").value.kind;if("constant"!==s.kind||h)if("source"===s.kind||h||c){const t=ss(i,l,"source");this.binders[i]=c?new es(s,a,l,t,e.id):new Ja(s,a,l,t),r.push("/a_"+i)}else{const e=ss(i,l,"composite");this.binders[i]=new Qa(s,a,l,u,t,e),r.push("/z_"+i)}else this.binders[i]=c?new Ka(s.value,a):new Ya(s.value,a,l),r.push("/u_"+i)}this.cacheKey=r.sort().join("")}getMaxValue(e){const t=this.binders[e];return t instanceof Ja||t instanceof Qa?t.maxValue:0}populatePaintArrays(e,t,n,r,i,o){for(const a in this.binders){const s=this.binders[a];(s instanceof Ja||s instanceof Qa||s instanceof es)&&s.populatePaintArray(e,t,n,r,i,o)}}setConstantPatternPositions(e){for(const t in this.binders){const n=this.binders[t];n instanceof Ka&&n.setConstantPatternPositions(e)}}updatePaintArrays(e,t,n,r,i,o){let a=!1;for(const s in e){const l=t.getPositions(s);for(const t of l){const l=n.feature(t.index);for(const n in this.binders){const u=this.binders[n];if((u instanceof Ja||u instanceof Qa||u instanceof es)&&!0===u.expression.isStateDependent){const c=r.paint.get(n);u.expression=c.value,u.updatePaintArray(t.start,t.end,l,e[s],i,o),a=!0}}}}return a}defines(){const e=[];for(const t in this.binders){const n=this.binders[t];(n instanceof Ya||n instanceof Ka)&&e.push(...n.uniformNames.map(e=>"#define HAS_UNIFORM_"+e))}return e}getBinderAttributes(){const e=[];for(const t in this.binders){const n=this.binders[t];if(n instanceof Ja||n instanceof Qa||n instanceof es)for(let t=0;t!0)){this.programConfigurations={};for(const r of e)this.programConfigurations[r.id]=new ts(r,t,n);this.needsUpload=!1,this._featureMap=new ja,this._bufferOffset=0}populatePaintArrays(e,t,n,r,i,o,a){for(const n in this.programConfigurations)this.programConfigurations[n].populatePaintArrays(e,t,r,i,o,a);void 0!==t.id&&this._featureMap.add(t.id,n,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,t,n,r,i){for(const o of n)this.needsUpload=this.programConfigurations[o.id].updatePaintArrays(e,this._featureMap,t,o,r,i)||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 rs={"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern","pixel_ratio"],"fill-pattern":["pattern","pixel_ratio"],"fill-extrusion-pattern":["pattern","pixel_ratio"],"line-dasharray":["dash"]};function is(e,t){return rs[e]||[e.replace(t+"-","").replace(/-/g,"_")]}const os={"line-pattern":{source:ta,composite:ta},"fill-pattern":{source:ta,composite:ta},"fill-extrusion-pattern":{source:ta,composite:ta},"line-dasharray":{source:na,composite:na}},as={color:{source:xa,composite:ea},number:{source:ma,composite:xa}};function ss(e,t,n){const r=os[e];return r&&r[n]||as[t][n]}zi(Ya,"ConstantBinder"),zi(Ka,"PatternConstantBinder"),zi(Ja,"SourceExpressionBinder"),zi(es,"PatternCompositeBinder"),zi(Qa,"CompositeExpressionBinder"),zi(ts,"ProgramConfiguration",{omit:["_buffers"]}),zi(ns,"ProgramConfigurationSet");const ls="-transition";class us extends Ye{constructor(e,t){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1,needFeature:!1},this._filterCompiled=!1,"custom"!==e.type&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,"background"!==e.type&&"sky"!==e.type&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),t.layout&&(this._unevaluatedLayout=new Bo(t.layout)),t.paint)){this._transitionablePaint=new Do(t.paint);for(const t in e.paint)this.setPaintProperty(t,e.paint[t],{validate:!1});for(const t in e.layout)this.setLayoutProperty(t,e.layout[t],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new jo(t.paint)}}getLayoutProperty(e){return"visibility"===e?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,t,n={}){null!=t&&this._validate(ki,`layers.${this.id}.layout.${e}`,e,t,n)||("visibility"!==e?this._unevaluatedLayout.setValue(e,t):this.visibility=t)}getPaintProperty(e){return B(e,ls)?this._transitionablePaint.getTransition(e.slice(0,-ls.length)):this._transitionablePaint.getValue(e)}setPaintProperty(e,t,n={}){if(null!=t&&this._validate(Si,`layers.${this.id}.paint.${e}`,e,t,n))return!1;if(B(e,ls))return this._transitionablePaint.setTransition(e.slice(0,-ls.length),t||void 0),!1;{const n=this._transitionablePaint._values[e],r=n.value.isDataDriven(),i=n.value;this._transitionablePaint.setValue(e,t),this._handleSpecialPaintPropertyUpdate(e);const o=this._transitionablePaint._values[e].value,a=o.isDataDriven(),s=B(e,"pattern")||"line-dasharray"===e;return a||r||s||this._handleOverridablePaintPropertyUpdate(e,i,o)}}_handleSpecialPaintPropertyUpdate(e){}getProgramIds(){return null}getProgramConfiguration(e){return null}_handleOverridablePaintPropertyUpdate(e,t,n){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||"none"===this.visibility}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,t){this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,t)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,t)}serialize(){const e={id:this.id,type:this.type,source:this.source,"source-layer":this.sourceLayer,metadata:this.metadata,minzoom:this.minzoom,maxzoom:this.maxzoom,filter:this.filter,layout:this._unevaluatedLayout&&this._unevaluatedLayout.serialize(),paint:this._transitionablePaint&&this._transitionablePaint.serialize()};return this.visibility&&(e.layout=e.layout||{},e.layout.visibility=this.visibility),j(e,(e,t)=>!(void 0===e||"layout"===t&&!Object.keys(e).length||"paint"===t&&!Object.keys(e).length))}_validate(e,t,n,r,i={}){return(!i||!1!==i.validate)&&Mi(this,e.call(Ti,{key:t,layerType:this.type,objectKey:n,value:r,styleSpec:Ke,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isSky(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const t=this.paint.get(e);if(t instanceof Fo&&Cr(t.property.specification)&&("source"===t.value.kind||"composite"===t.value.kind)&&t.value.isStateDependent)return!0}return!1}compileFilter(){this._filterCompiled||(this._featureFilter=Qr(this.filter),this._filterCompiled=!0)}invalidateCompiledFilter(){this._filterCompiled=!1}dynamicFilter(){return this._featureFilter.dynamicFilter}dynamicFilterNeedsFeature(){return this._featureFilter.needFeature}}const cs=Xo([{name:"a_pos",components:2,type:"Int16"}],4),hs=Xo([{name:"a_pos_3",components:3,type:"Int16"},{name:"a_pos_normal_3",components:3,type:"Int16"}]);class ds{constructor(e=[]){this.segments=e}prepareSegment(e,t,n,r){let i=this.segments[this.segments.length-1];return e>ds.MAX_VERTEX_ARRAY_LENGTH&&V(`Max vertices per segment is ${ds.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!i||i.vertexLength+e>ds.MAX_VERTEX_ARRAY_LENGTH||i.sortKey!==r)&&(i={vertexOffset:t.length,primitiveOffset:n.length,vertexLength:0,primitiveLength:0},void 0!==r&&(i.sortKey=r),this.segments.push(i)),i}get(){return this.segments}destroy(){for(const e of this.segments)for(const t in e.vaos)e.vaos[t].destroy()}static simpleSegment(e,t,n,r){return new ds([{vertexOffset:e,primitiveOffset:t,vertexLength:n,primitiveLength:r,vaos:{},sortKey:0}])}}ds.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,zi(ds,"SegmentVector");var fs=8192;class ps{constructor(e,t){e&&(t?this.setSouthWest(e).setNorthEast(t):4===e.length?this.setSouthWest([e[0],e[1]]).setNorthEast([e[2],e[3]]):this.setSouthWest(e[0]).setNorthEast(e[1]))}setNorthEast(e){return this._ne=e instanceof _s?new _s(e.lng,e.lat):_s.convert(e),this}setSouthWest(e){return this._sw=e instanceof _s?new _s(e.lng,e.lat):_s.convert(e),this}extend(e){const t=this._sw,n=this._ne;let r,i;if(e instanceof _s)r=e,i=e;else{if(!(e instanceof ps))return Array.isArray(e)?4===e.length||e.every(Array.isArray)?this.extend(ps.convert(e)):this.extend(_s.convert(e)):"object"==typeof e&&null!==e&&e.hasOwnProperty("lat")&&e.hasOwnProperty("lon")?this.extend(_s.convert(e)):this;if(r=e._sw,i=e._ne,!r||!i)return this}return t||n?(t.lng=Math.min(r.lng,t.lng),t.lat=Math.min(r.lat,t.lat),n.lng=Math.max(i.lng,n.lng),n.lat=Math.max(i.lat,n.lat)):(this._sw=new _s(r.lng,r.lat),this._ne=new _s(i.lng,i.lat)),this}getCenter(){return new _s((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 _s(this.getWest(),this.getNorth())}getSouthEast(){return new _s(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:n}=_s.convert(e);let r=this._sw.lng<=t&&t<=this._ne.lng;return this._sw.lng>this._ne.lng&&(r=this._sw.lng>=t&&t>=this._ne.lng),this._sw.lat<=n&&n<=this._ne.lat&&r}static convert(e){return!e||e instanceof ps?e:new ps(e)}}const ms=6371008.8;class _s{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 _s(C(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,n=this.lat*t,r=e.lat*t,i=Math.sin(n)*Math.sin(r)+Math.cos(n)*Math.cos(r)*Math.cos((e.lng-this.lng)*t);return ms*Math.acos(Math.min(i,1))}toBounds(e=0){const t=360*e/40075017,n=t/Math.cos(Math.PI/180*this.lat);return new ps(new _s(this.lng-n,this.lat-t),new _s(this.lng+n,this.lat+t))}static convert(e){if(e instanceof _s)return e;if(Array.isArray(e)&&(2===e.length||3===e.length))return new _s(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&"object"==typeof e&&null!==e)return new _s(Number("lng"in e?e.lng:e.lon),Number(e.lat));throw new Error("`LngLatLike` argument must be specified as a LngLat instance, an object {lng: , lat: }, an object {lon: , lat: }, or an array of [, ]")}}const gs=2*Math.PI*ms;function ys(e){return gs*Math.cos(e*Math.PI/180)}function vs(e){return(180+e)/360}function xs(e){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+e*Math.PI/360)))/360}function bs(e,t){return e/ys(t)}function ws(e){return 360*e-180}function Es(e){return 360/Math.PI*Math.atan(Math.exp((180-360*e)*Math.PI/180))-90}function Ts(e,t){return e*ys(Es(t))}const Ss=85.051129;function ks(e){return 1/Math.cos(e*Math.PI/180)}class Cs{constructor(e,t,n=0){this.x=+e,this.y=+t,this.z=+n}static fromLngLat(e,t=0){const n=_s.convert(e);return new Cs(vs(n.lng),xs(n.lat),bs(t,n.lat))}toLngLat(){return new _s(ws(this.x),Es(this.y))}toAltitude(){return Ts(this.z,this.y)}meterInMercatorCoordinateUnits(){return 1/gs*ks(Es(this.y))}}function Ms(e,t,n,r,i,o,a,s,l){const u=(t+r)/2,c=(n+i)/2,h=new m(u,c);s(h),function(e,t,n,r,i,o){const a=n-i,s=r-o;return Math.abs((r-t)*a-(n-e)*s)/Math.hypot(a,s)}(h.x,h.y,o.x,o.y,a.x,a.y)>=l?(Ms(e,t,n,u,c,o,h,s,l),Ms(e,u,c,r,i,h,a,s,l)):e.push(a)}function As(e,t,n){let r=e[0],i=r.x,o=r.y;t(r);const a=[r];for(let s=1;se.x+1||re.y+1)&&V("Geometry exceeds allowed extent, reduce your vector tile buffer size"),e}function Ls(e,t,n){const r=e.loadGeometry(),i=e.extent,o=fs/i;if(t&&n&&n.projection.isReprojectedInTileSpace){const o=1<{const n=ws((t.x+e.x/i)/o),r=Es((t.y+e.y/i)/o),c=u.project(n,r);e.x=(c.x*a-s)*i,e.y=(c.y*a-l)*i};for(let t=0;t=i||n.y<0||n.y>=i||(c(n),e.push(n));r[t]=e}}for(const e of r)for(const t of e)Ds(t,o);return r}function Rs(e,t){return{type:e.type,id:e.id,properties:e.properties,geometry:t?Ls(e):[]}}function Bs(e,t,n,r,i){e.emplaceBack(2*t+(r+1)/2,2*n+(i+1)/2)}function Fs(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class js{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.projection=e.projection,this.layoutVertexArray=new Yo,this.indexArray=new da,this.segments=new ds,this.programConfigurations=new ns(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){const i=this.layers[0],o=[];let a=null;"circle"===i.type&&(a=i.layout.get("circle-sort-key"));for(const{feature:t,id:i,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Rs(t,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),u,n))continue;const c=a?a.evaluate(u,{},n):void 0,h={id:i,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ls(t,n,r),patterns:{},sortKey:c};o.push(h)}a&&o.sort((e,t)=>e.sortKey-t.sortKey);let s=null;"globe"===r.projection.name&&(this.globeExtVertexArray=new ra,s=r.projection);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r,l=e[o].feature;this.addFeature(r,i,o,t.availableImages,n,s),t.featureIndex.insert(l,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,cs.members),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.globeExtVertexArray&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,hs.members))),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}addFeature(e,t,n,r,i,o){for(const n of t)for(const t of n){const n=t.x,r=t.y;if(n<0||n>=fs||r<0||r>=fs)continue;if(o){const e=o.projectTilePoint(n,r,i),t=o.upVector(i,n,r),a=this.globeExtVertexArray;Fs(a,e,t),Fs(a,e,t),Fs(a,e,t),Fs(a,e,t)}const a=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),s=a.vertexLength;Bs(this.layoutVertexArray,n,r,-1,-1),Bs(this.layoutVertexArray,n,r,1,-1),Bs(this.layoutVertexArray,n,r,1,1),Bs(this.layoutVertexArray,n,r,-1,1),this.indexArray.emplaceBack(s,s+1,s+2),this.indexArray.emplaceBack(s,s+2,s+3),a.vertexLength+=4,a.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,{},r,i)}}function Ns(e,t){for(let n=0;n1){if(qs(e,t))return!0;for(let r=0;r1?n:n.sub(t)._mult(i)._add(t))}function Xs(e,t){let n,r,i,o=!1;for(let a=0;at.y!=i.y>t.y&&t.x<(i.x-r.x)*(t.y-r.y)/(i.y-r.y)+r.x&&(o=!o)}return o}function Hs(e,t){let n=!1;for(let r=0,i=e.length-1;rt.y!=a.y>t.y&&t.x<(a.x-o.x)*(t.y-o.y)/(a.y-o.y)+o.x&&(n=!n)}return n}function Ys(e,t,n,r,i){for(const o of e)if(t<=o.x&&n<=o.y&&r>=o.x&&i>=o.y)return!0;const o=[new m(t,n),new m(t,i),new m(r,i),new m(r,n)];if(e.length>2)for(const t of o)if(Hs(e,t))return!0;for(let t=0;ti.x&&t.x>i.x||e.yi.y&&t.y>i.y)return!1;const o=G(e,t,n[0]);return o!==G(e,t,n[1])||o!==G(e,t,n[2])||o!==G(e,t,n[3])}function Js(e,t,n){const r=t.paint.get(e).value;return"constant"===r.kind?r.value:n.programConfigurations.get(t.id).getMaxValue(e)}function Qs(e){return Math.sqrt(e[0]*e[0]+e[1]*e[1])}function el(e,t,n,r,i){if(!t[0]&&!t[1])return e;const o=m.convert(t)._mult(i);"viewport"===n&&o._rotate(-r);const a=[];for(let t=0;t0&&(o=1/Math.sqrt(o)),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e}function Il(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function Pl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[0],s=n[1],l=n[2];return e[0]=i*l-o*s,e[1]=o*a-r*l,e[2]=r*s-i*a,e}function zl(e,t,n){var r=t[0],i=t[1],o=t[2],a=n[3]*r+n[7]*i+n[11]*o+n[15];return e[0]=(n[0]*r+n[4]*i+n[8]*o+n[12])/(a=a||1),e[1]=(n[1]*r+n[5]*i+n[9]*o+n[13])/a,e[2]=(n[2]*r+n[6]*i+n[10]*o+n[14])/a,e}function Ol(e,t,n){var r=n[0],i=n[1],o=n[2],a=t[0],s=t[1],l=t[2],u=i*l-o*s,c=o*a-r*l,h=r*s-i*a,d=i*h-o*c,f=o*u-r*h,p=r*c-i*u,m=2*n[3];return c*=m,h*=m,f*=2,p*=2,e[0]=a+(u*=m)+(d*=2),e[1]=s+c+f,e[2]=l+h+p,e}var Dl,Ll=El,Rl=Tl,Bl=xl;function Fl(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function jl(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*n+r*r+i*i+o*o;return a>0&&(a=1/Math.sqrt(a)),e[0]=n*a,e[1]=r*a,e[2]=i*a,e[3]=o*a,e}function Nl(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3];return e[0]=n[0]*r+n[4]*i+n[8]*o+n[12]*a,e[1]=n[1]*r+n[5]*i+n[9]*o+n[13]*a,e[2]=n[2]*r+n[6]*i+n[10]*o+n[14]*a,e[3]=n[3]*r+n[7]*i+n[11]*o+n[15]*a,e}function Ul(){var e=new ol(4);return ol!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e[3]=1,e}function Vl(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Gl(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+a*s,e[1]=i*l+o*s,e[2]=o*l-i*s,e[3]=a*l-r*s,e}function ql(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l-o*s,e[1]=i*l+a*s,e[2]=o*l+r*s,e[3]=a*l-i*s,e}yl(),Dl=new ol(4),ol!=Float32Array&&(Dl[0]=0,Dl[1]=0,Dl[2]=0,Dl[3]=0);var $l=jl;yl(),bl(1,0,0),bl(0,1,0),Ul(),Ul(),al();class Zl{constructor(e,t){this.pos=e,this.dir=t}intersectsPlane(e,t,n){const r=Il(t,this.dir);if(Math.abs(r)<1e-6)return!1;const i=((e[0]-this.pos[0])*t[0]+(e[1]-this.pos[1])*t[1]+(e[2]-this.pos[2])*t[2])/r;return n[0]=this.pos[0]+this.dir[0]*i,n[1]=this.pos[1]+this.dir[1]*i,n[2]=this.pos[2]+this.dir[2]*i,!0}closestPointOnSphere(e,t,n){if(function(e,t){var n=e[0],r=e[1],i=e[2],o=t[0],a=t[1],s=t[2];return Math.abs(n-o)<=il*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-a)<=il*Math.max(1,Math.abs(r),Math.abs(a))&&Math.abs(i-s)<=il*Math.max(1,Math.abs(i),Math.abs(s))}(this.pos,e)||0===t)return n[0]=n[1]=n[2]=0,!1;const[r,i,o]=this.dir,a=this.pos[0]-e[0],s=this.pos[1]-e[1],l=this.pos[2]-e[2],u=r*r+i*i+o*o,c=2*(a*r+s*i+l*o),h=c*c-4*u*(a*a+s*s+l*l-t*t);if(h<0){const e=Math.max(-c/2,0),u=a+r*e,h=s+i*e,d=l+o*e,f=Math.hypot(u,h,d);return n[0]=u*t/f,n[1]=h*t/f,n[2]=d*t/f,!1}{const e=(-c-Math.sqrt(h))/(2*u);if(e<0){const e=Math.hypot(a,s,l);return n[0]=a*t/e,n[1]=s*t/e,n[2]=l*t/e,!1}return n[0]=a+r*e,n[1]=s+i*e,n[2]=l+o*e,!0}}}class Wl{constructor(e,t,n,r,i){this.TL=e,this.TR=t,this.BR=n,this.BL=r,this.horizon=i}static fromInvProjectionMatrix(e,t,n){const r=[-1,1,1],i=[1,1,1],o=[1,-1,1],a=[-1,-1,1],s=zl(r,r,e),l=zl(i,i,e),u=zl(o,o,e),c=zl(a,a,e);return new Wl(s,l,u,c,t/n)}}class Xl{constructor(e,t){this.points=e,this.planes=t}static fromInvProjectionMatrix(e,t,n,r){const i=Math.pow(2,n),o=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(n=>{const o=Nl([],n,e),a=1/o[3]/t*i;return function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}(o,o,[a,a,r?1/o[3]:a,a])}),a=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(e=>{const t=Al([],Pl([],Ll([],o[e[0]],o[e[1]]),Ll([],o[e[2]],o[e[1]]))),n=-Il(t,o[e[1]]);return t.concat(n)});return new Xl(o,a)}}class Hl{static fromPoints(e){const t=[1/0,1/0,1/0],n=[-1/0,-1/0,-1/0];for(const r of e)Sl(t,t,r),kl(n,n,r);return new Hl(t,n)}static applyTransform(e,t){const n=e.getCorners();for(let e=0;e=0;if(0===o)return 0;o!==t.length&&(n=!1)}if(n)return 2;for(let t=0;t<3;t++){let n=Number.MAX_VALUE,r=-Number.MAX_VALUE;for(let i=0;ithis.max[t]-this.min[t])return 0}return 1}}function Yl(e,t,n,r,i,o,a,s,l){if(o&&e.queryGeometry.isAboveHorizon)return!1;o&&(l*=e.pixelToTileUnitsFactor);const u=e.tileID.canonical,c=n.projection.upVectorScale(u,n.center.lat,n.worldSize).metersToTile;for(const h of t)for(const t of h){const h=t.add(s),d=i&&n.elevation?n.elevation.exaggeration()*i.getElevationAt(h.x,h.y,!0):0,f=n.projection.projectTilePoint(h.x,h.y,u);if(d>0){const e=n.projection.upVector(u,h.x,h.y);f.x+=e[0]*c*d,f.y+=e[1]*c*d,f.z+=e[2]*c*d}const p=o?h:Kl(f.x,f.y,f.z,r),m=o?e.tilespaceRays.map(e=>eu(e,d)):e.queryGeometry.screenGeometry,_=Nl([],[f.x,f.y,f.z,1],r);if(!a&&o?l*=_[3]/n.cameraToCenterDistance:a&&!o&&(l*=n.cameraToCenterDistance/_[3]),o){const e=Es((t.y/fs+u.y)/(1<e.width||i.height>e.height||n.x>e.width-i.width||n.y>e.height-i.height)throw new RangeError("out of range source coordinates for image copy");if(i.width>t.width||i.height>t.height||r.x>t.width-i.width||r.y>t.height-i.height)throw new RangeError("out of range destination coordinates for image copy");const a=e.data,s=t.data;for(let l=0;l{t[e.evaluationKey]=o;const a=e.expression.evaluate(t);i.data[n+r+0]=Math.floor(255*a.r/a.a),i.data[n+r+1]=Math.floor(255*a.g/a.a),i.data[n+r+2]=Math.floor(255*a.b/a.a),i.data[n+r+3]=Math.floor(255*a.a)};if(e.clips)for(let t=0,i=0;t80*n){r=o=e[0],i=a=e[1];for(var p=n;po&&(o=s),l>a&&(a=l);u=0!==(u=Math.max(o-r,a-i))?32767/u:0}return _u(d,f,n,r,i,u,0),f}function pu(e,t,n,r,i){var o,a;if(i===Fu(e,t,n,r)>0)for(o=t;o=t;o-=r)a=Lu(o,e[o],e[o+1],a);return a&&Au(a,a.next)&&(Ru(a),a=a.next),a}function mu(e,t){if(!e)return e;t||(t=e);var n,r=e;do{if(n=!1,r.steiner||!Au(r,r.next)&&0!==Mu(r.prev,r,r.next))r=r.next;else{if(Ru(r),(r=t=r.prev)===r.next)break;n=!0}}while(n||r!==t);return t}function _u(e,t,n,r,i,o,a){if(e){!a&&o&&function(e,t,n,r){var i=e;do{0===i.z&&(i.z=Tu(i.x,i.y,t,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,n,r,i,o,a,s,l,u=1;do{for(n=e,e=null,o=null,a=0;n;){for(a++,r=n,s=0,t=0;t0||l>0&&r;)0!==s&&(0===l||!r||n.z<=r.z)?(i=n,n=n.nextZ,s--):(i=r,r=r.nextZ,l--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;n=r}o.nextZ=null,u*=2}while(a>1)}(i)}(e,r,i,o);for(var s,l,u=e;e.prev!==e.next;)if(s=e.prev,l=e.next,o?yu(e,r,i,o):gu(e))t.push(s.i/n|0),t.push(e.i/n|0),t.push(l.i/n|0),Ru(e),e=l.next,u=l.next;else if((e=l)===u){a?1===a?_u(e=vu(mu(e),t,n),t,n,r,i,o,2):2===a&&xu(e,t,n,r,i,o):_u(mu(e),t,n,r,i,o,1);break}}}function gu(e){var t=e.prev,n=e,r=e.next;if(Mu(t,n,r)>=0)return!1;for(var i=t.x,o=n.x,a=r.x,s=t.y,l=n.y,u=r.y,c=io?i>a?i:a:o>a?o:a,f=s>l?s>u?s:u:l>u?l:u,p=r.next;p!==t;){if(p.x>=c&&p.x<=d&&p.y>=h&&p.y<=f&&ku(i,s,o,l,a,u,p.x,p.y)&&Mu(p.prev,p,p.next)>=0)return!1;p=p.next}return!0}function yu(e,t,n,r){var i=e.prev,o=e,a=e.next;if(Mu(i,o,a)>=0)return!1;for(var s=i.x,l=o.x,u=a.x,c=i.y,h=o.y,d=a.y,f=sl?s>u?s:u:l>u?l:u,_=c>h?c>d?c:d:h>d?h:d,g=Tu(f,p,t,n,r),y=Tu(m,_,t,n,r),v=e.prevZ,x=e.nextZ;v&&v.z>=g&&x&&x.z<=y;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&ku(s,c,l,h,u,d,v.x,v.y)&&Mu(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&ku(s,c,l,h,u,d,x.x,x.y)&&Mu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}for(;v&&v.z>=g;){if(v.x>=f&&v.x<=m&&v.y>=p&&v.y<=_&&v!==i&&v!==a&&ku(s,c,l,h,u,d,v.x,v.y)&&Mu(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;x&&x.z<=y;){if(x.x>=f&&x.x<=m&&x.y>=p&&x.y<=_&&x!==i&&x!==a&&ku(s,c,l,h,u,d,x.x,x.y)&&Mu(x.prev,x,x.next)>=0)return!1;x=x.nextZ}return!0}function vu(e,t,n){var r=e;do{var i=r.prev,o=r.next.next;!Au(i,o)&&Iu(i,r,r.next,o)&&Ou(i,o)&&Ou(o,i)&&(t.push(i.i/n|0),t.push(r.i/n|0),t.push(o.i/n|0),Ru(r),Ru(r.next),r=e=o),r=r.next}while(r!==e);return mu(r)}function xu(e,t,n,r,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&Cu(a,s)){var l=Du(a,s);return a=mu(a,a.next),l=mu(l,l.next),_u(a,t,n,r,i,o,0),void _u(l,t,n,r,i,o,0)}s=s.next}a=a.next}while(a!==e)}function bu(e,t){return e.x-t.x}function wu(e,t){var n=function(e,t){var n,r=t,i=e.x,o=e.y,a=-1/0;do{if(o<=r.y&&o>=r.next.y&&r.next.y!==r.y){var s=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(s<=i&&s>a&&(a=s,n=r.x=r.x&&r.x>=c&&i!==r.x&&ku(on.x||r.x===n.x&&Eu(n,r)))&&(n=r,d=l)),r=r.next}while(r!==u);return n}(e,t);if(!n)return t;var r=Du(n,e);return mu(r,r.next),mu(n,n.next)}function Eu(e,t){return Mu(e.prev,e,t.prev)<0&&Mu(t.next,e,e.next)<0}function Tu(e,t,n,r,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-n)*i|0)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-r)*i|0)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function Su(e){var t=e,n=e;do{(t.x=(e-a)*(o-s)&&(e-a)*(r-s)>=(n-a)*(t-s)&&(n-a)*(o-s)>=(i-a)*(r-s)}function Cu(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var n=e;do{if(n.i!==e.i&&n.next.i!==e.i&&n.i!==t.i&&n.next.i!==t.i&&Iu(n,n.next,e,t))return!0;n=n.next}while(n!==e);return!1}(e,t)&&(Ou(e,t)&&Ou(t,e)&&function(e,t){var n=e,r=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==e);return r}(e,t)&&(Mu(e.prev,e,t.prev)||Mu(e,t.prev,t))||Au(e,t)&&Mu(e.prev,e,e.next)>0&&Mu(t.prev,t,t.next)>0)}function Mu(e,t,n){return(t.y-e.y)*(n.x-t.x)-(t.x-e.x)*(n.y-t.y)}function Au(e,t){return e.x===t.x&&e.y===t.y}function Iu(e,t,n,r){var i=zu(Mu(e,t,n)),o=zu(Mu(e,t,r)),a=zu(Mu(n,r,e)),s=zu(Mu(n,r,t));return i!==o&&a!==s||!(0!==i||!Pu(e,n,t))||!(0!==o||!Pu(e,r,t))||!(0!==a||!Pu(n,e,r))||!(0!==s||!Pu(n,t,r))}function Pu(e,t,n){return t.x<=Math.max(e.x,n.x)&&t.x>=Math.min(e.x,n.x)&&t.y<=Math.max(e.y,n.y)&&t.y>=Math.min(e.y,n.y)}function zu(e){return e>0?1:e<0?-1:0}function Ou(e,t){return Mu(e.prev,e,e.next)<0?Mu(e,t,e.next)>=0&&Mu(e,e.prev,t)>=0:Mu(e,t,e.prev)<0||Mu(e,e.next,t)<0}function Du(e,t){var n=new Bu(e.i,e.x,e.y),r=new Bu(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Lu(e,t,n,r){var i=new Bu(e,t,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function Ru(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function Bu(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Fu(e,t,n,r){for(var i=0,o=t,a=n-r;or;){if(i-r>600){var a=i-r+1,s=n-r+1,l=Math.log(a),u=.5*Math.exp(2*l/3),c=.5*Math.sqrt(l*u*(a-u)/a)*(s-a/2<0?-1:1);e(t,n,Math.max(r,Math.floor(n-s*u/a+c)),Math.min(i,Math.floor(n+(a-s)*u/a+c)),o)}var h=t[n],d=r,f=i;for(Nu(t,r,n),o(t[i],h)>0&&Nu(t,r,i);d0;)f--}0===o(t[r],h)?Nu(t,r,f):Nu(t,++f,i),f<=n&&(r=f+1),n<=f&&(i=f-1)}}(e,t,n||0,r||e.length-1,i||Uu)}function Nu(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function Uu(e,t){return et?1:0}function Vu(e,t){const n=e.length;if(n<=1)return[e];const r=[];let i,o;for(let t=0;t1)for(let e=0;e0&&n.holes.push(r+=e[i-1].length)}return n};class Zu{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Yo,this.indexArray=new da,this.indexArray2=new ya,this.programConfigurations=new ns(e.layers,e.zoom),this.segments=new ds,this.segments2=new ds,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.projection=e.projection}populate(e,t,n,r){this.hasPattern=qu("fill",this.layers,t);const i=this.layers[0].layout.get("fill-sort-key"),o=[];for(const{feature:a,id:s,index:l,sourceLayerIndex:u}of e){const e=this.layers[0]._featureFilter.needGeometry,c=Rs(a,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),c,n))continue;const h=i?i.evaluate(c,{},n,t.availableImages):void 0,d={id:s,properties:a.properties,type:a.type,sourceLayerIndex:u,index:l,geometry:e?c.geometry:Ls(a,n,r),patterns:{},sortKey:h};o.push(d)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:a}=r;if(this.hasPattern){const e=$u("fill",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,{},t.availableImages);t.featureIndex.insert(e[o].feature,i,o,a,this.index)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,hu),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.indexBuffer2=e.createIndexBuffer(this.indexArray2)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.indexBuffer2.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.segments2.destroy())}addFeature(e,t,n,r,i,o=[]){for(const e of Vu(t,500)){let t=0;for(const n of e)t+=n.length;const n=this.segments.prepareSegment(t,this.layoutVertexArray,this.indexArray),r=n.vertexLength,i=[],o=[];for(const t of e){if(0===t.length)continue;t!==e[0]&&o.push(i.length/2);const n=this.segments2.prepareSegment(t.length,this.layoutVertexArray,this.indexArray2),r=n.vertexLength;this.layoutVertexArray.emplaceBack(t[0].x,t[0].y),this.indexArray2.emplaceBack(r+t.length-1,r),i.push(t[0].x),i.push(t[0].y);for(let e=1;e>3}if(i--,1===r||2===r)o+=e.readSVarint(),a+=e.readSVarint(),1===r&&(t&&s.push(t),t=[]),t.push(new ec(o,a));else{if(7!==r)throw new Error("unknown command "+r);t&&t.push(t[0].clone())}}return t&&s.push(t),s},nc.prototype.bbox=function(){var e=this._pbf;e.pos=this._geometry;for(var t=e.readVarint()+e.pos,n=1,r=0,i=0,o=0,a=1/0,s=-1/0,l=1/0,u=-1/0;e.pos>3}if(r--,1===n||2===n)(i+=e.readSVarint())s&&(s=i),(o+=e.readSVarint())u&&(u=o);else if(7!==n)throw new Error("unknown command "+n)}return[a,l,s,u]},nc.prototype.toGeoJSON=function(e,t,n){var r,i,o=this.extent*Math.pow(2,n),a=this.extent*e,s=this.extent*t,l=this.loadGeometry(),u=nc.types[this.type];function c(e){for(var t=0;t>3;t=1===r?e.readString():2===r?e.readFloat():3===r?e.readDouble():4===r?e.readVarint64():5===r?e.readVarint():6===r?e.readSVarint():7===r?e.readBoolean():null}return t}(n))}sc.prototype.feature=function(e){if(e<0||e>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[e];var t=this._pbf.readVarint()+this._pbf.pos;return new oc(this._pbf,t,this.extent,this._keys,this._values)};var uc=ac;function cc(e,t,n){if(3===e){var r=new uc(n,n.readVarint()+n.pos);r.length&&(t[r.name]=r)}}var hc=Qu.VectorTile=function(e,t){this.layers=e.readFields(cc,{},t)},dc=Qu.VectorTileFeature=tc;function fc(e,t,n,r){const i=[],o=0===r?(e,t,n,r,i,o)=>{e.push(new m(o,n+(o-t)/(r-t)*(i-n)))}:(e,t,n,r,i,o)=>{e.push(new m(t+(o-n)/(i-n)*(r-t),o))};for(const a of e){const e=[];for(const i of a){if(i.length<=2)continue;const a=[];for(let e=0;et&&o(a,s,l,u,c,t):h>n?d=t&&o(a,s,l,u,c,t),d>n&&h<=n&&o(a,s,l,u,c,n)}let s=i[i.length-1];const l=0===r?s.x:s.y;l>=t&&l<=n&&a.push(s),a.length&&(s=a[a.length-1],a[0].x===s.x&&a[0].y===s.y||a.push(a[0]),e.push(a))}e.length&&i.push(e)}return i}Qu.VectorTileLayer=ac;const pc=dc.types,mc=Math.pow(2,13);function _c(e,t,n,r,i,o,a,s){e.emplaceBack((t<<1)+a,(n<<1)+o,(Math.floor(r*mc)<<1)+i,Math.round(s))}function gc(e,t,n){const r=16384;e.emplaceBack(t.x,t.y,t.z,n[0]*r,n[1]*r,n[2]*r)}class yc{constructor(){this.acc=new m(0,0),this.polyCount=[]}startRing(e){this.currentPolyCount={edges:0,top:0},this.polyCount.push(this.currentPolyCount),this.min||(this.min=new m(e.x,e.y),this.max=new m(e.x,e.y))}append(e,t){this.currentPolyCount.edges++,this.acc._add(e);const n=this.min,r=this.max;e.xr.x&&(r.x=e.x),e.yr.y&&(r.y=e.y),((0===e.x||e.x===fs)&&e.x===t.x)!=((0===e.y||e.y===fs)&&e.y===t.y)&&this.processBorderOverlap(e,t),t.x<0!=e.x<0&&this.addBorderIntersection(0,Mn(t.y,e.y,(0-t.x)/(e.x-t.x))),t.x>fs!=e.x>fs&&this.addBorderIntersection(1,Mn(t.y,e.y,(fs-t.x)/(e.x-t.x))),t.y<0!=e.y<0&&this.addBorderIntersection(2,Mn(t.x,e.x,(0-t.y)/(e.y-t.y))),t.y>fs!=e.y>fs&&this.addBorderIntersection(3,Mn(t.x,e.x,(fs-t.y)/(e.y-t.y)))}addBorderIntersection(e,t){this.borders||(this.borders=[[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE],[Number.MAX_VALUE,-Number.MAX_VALUE]]);const n=this.borders[e];tn[1]&&(n[1]=t)}processBorderOverlap(e,t){if(e.x===t.x){if(e.y===t.y)return;const n=0===e.x?0:1;this.addBorderIntersection(n,t.y),this.addBorderIntersection(n,e.y)}else{const n=0===e.y?2:3;this.addBorderIntersection(n,t.x),this.addBorderIntersection(n,e.x)}}centroid(){const e=this.polyCount.reduce((e,t)=>e+t.edges,0);return 0!==e?this.acc.div(e)._round():new m(0,0)}span(){return new m(this.max.x-this.min.x,this.max.y-this.min.y)}intersectsCount(){return this.borders.reduce((e,t)=>e+ +(t[0]!==Number.MAX_VALUE),0)}}class vc{constructor(e){this.zoom=e.zoom,this.canonical=e.canonical,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.hasPattern=!1,this.edgeRadius=0,this.projection=e.projection,this.layoutVertexArray=new Jo,this.centroidVertexArray=new Pa,this.indexArray=new da,this.programConfigurations=new ns(e.layers,e.zoom),this.segments=new ds,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.enableTerrain=e.enableTerrain}populate(e,t,n,r){this.features=[],this.hasPattern=qu("fill-extrusion",this.layers,t),this.featuresOnBorder=[],this.borders=[[],[],[],[]],this.borderDoneWithNeighborZ=[-1,-1,-1,-1],this.tileToMeter=function(e){const t=Math.exp(Math.PI*(1-e.y/(1<=0;e--){const t=d[e];(0===t.length||(f=t[0]).every(e=>e.x<=0)||f.every(e=>e.x>=fs)||f.every(e=>e.y<=0)||f.every(e=>e.y>=fs))&&d.splice(e,1)}var f;let p;if(u)p=Cc(d,s,r);else{p=[];for(const e of d)p.push({polygon:e,bounds:s})}const _=h?this.edgeRadius:0;for(const{polygon:e,bounds:t}of p){let n=0,i=0;for(const t of e)h&&!t[0].equals(t[t.length-1])&&t.push(t[0]),i+=h?t.length-1:t.length;const o=this.segments.prepareSegment((h?5:4)*i,this.layoutVertexArray,this.indexArray);if(h){const t=[],i=[];n=o.vertexLength;for(const n of e){let a,s;n.length&&n!==e[0]&&i.push(t.length/2),a=n[1].sub(n[0])._perp()._unit();for(let e=1;e4&&Tc(i[i.length-2],i[0],i[1]),f=_?bc(i[i.length-2],i[0],i[1],_):0;a=i[1].sub(i[0])._perp()._unit();let p=!0;for(let m=1,g=0;m0?1:0,T=y.dist(v);if(g+T>32768&&(g=0),_){s=x.sub(v)._perp()._unit();let e=wc(y,v,x,xc(a,s),_);isNaN(e)&&(e=0);const t=v.sub(y)._unit();y=y.add(t.mult(f))._round(),v=v.add(t.mult(-e))._round(),f=e,a=s}const S=o.vertexLength,k=i.length>4&&Tc(y,v,x);let C=Sc(g,d,p);if(_c(this.layoutVertexArray,y.x,y.y,w,E,0,0,C),_c(this.layoutVertexArray,y.x,y.y,w,E,0,1,C),g+=T,C=Sc(g,k,!p),d=k,_c(this.layoutVertexArray,v.x,v.y,w,E,0,0,C),_c(this.layoutVertexArray,v.x,v.y,w,E,0,1,C),o.vertexLength+=4,this.indexArray.emplaceBack(S+0,S+1,S+2),this.indexArray.emplaceBack(S+1,S+3,S+2),o.primitiveLength+=2,_){const r=n+(1===m?i.length-2:m-2),a=1===m?n:r+1;if(this.indexArray.emplaceBack(S+1,r,S+3),this.indexArray.emplaceBack(r,a,S+3),o.primitiveLength+=2,void 0===e&&(e=S),!Ec(x,i[m],t)){const t=m===i.length-1?e:o.vertexLength;this.indexArray.emplaceBack(S+2,S+3,t),this.indexArray.emplaceBack(S+3,t+1,t),this.indexArray.emplaceBack(S+3,a,t+1),o.primitiveLength+=3}p=!p}if(u){const e=this.layoutVertexExtArray,t=l.projectTilePoint(y.x,y.y,r),n=l.projectTilePoint(v.x,v.y,r),i=l.upVector(r,y.x,y.y),o=l.upVector(r,v.x,v.y);gc(e,t,i),gc(e,t,i),gc(e,n,o),gc(e,n,o)}}h&&(n+=i.length-1)}}if(c&&c.polyCount.length>0){if(c.borders){c.vertexArrayOffset=this.centroidVertexArray.length;const e=c.borders,t=this.featuresOnBorder.push(c)-1;for(let n=0;n<4;n++)e[n][0]!==Number.MAX_VALUE&&this.borders[n].push(t)}this.encodeCentroid(c.borders?void 0:c.centroid(),c)}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}sortBorders(){for(let e=0;e<4;e++)this.borders[e].sort((t,n)=>this.featuresOnBorder[t].borders[e][0]-this.featuresOnBorder[n].borders[e][0])}encodeCentroid(e,t,n=!0){let r,i;if(e)if(0!==e.y){const n=t.span()._mult(this.tileToMeter);r=(Math.max(e.x,1)<<3)+Math.min(7,Math.round(n.x/10)),i=(Math.max(e.y,1)<<3)+Math.min(7,Math.round(n.y/10))}else r=Math.ceil(7*(e.x+450)),i=0;else r=0,i=+n;let o=n?this.centroidVertexArray.length:t.vertexArrayOffset;for(const e of t.polyCount){n&&this.centroidVertexArray.resize(this.centroidVertexArray.length+4*e.edges+e.top);for(let t=0;tn[1].x&&t.x>n[1].x||e.yn[1].y&&t.y>n[1].y}function Tc(e,t,n){if(e.x<0||e.x>=fs||t.x<0||t.x>=fs||n.x<0||n.x>=fs)return!1;const r=n.sub(t),i=r.perp(),o=e.sub(t);return(r.x*o.x+r.y*o.y)/Math.sqrt((r.x*r.x+r.y*r.y)*(o.x*o.x+o.y*o.y))>-.866&&i.x*o.x+i.y*o.y<0}function Sc(e,t,n){const r=t?2|e:-3&e;return n?1|r:-2&r}function kc(){const e=Math.PI/32,t=Math.tan(e),n=ms;return n*Math.sqrt(1+2*t*t)-n}function Cc(e,t,n){const r=1<{for(const n of e)a.push({polygon:n,bounds:t})},l=Math.ceil(Math.log2(n)),u=Math.ceil(Math.log2(r)),c=l-u,h=[];for(let e=0;e0?0:1);for(let e=0;et+1?f.push({polygons:d,bounds:e,depth:t+1}):s(d,e)}if(p.length){const e=[new m(0===n?c:r.x,1===n?c:r.y),a];h.length>t+1?f.push({polygons:p,bounds:e,depth:t+1}):s(p,e)}}return a}(e,t,Math.ceil((o-i)/11.25),Math.ceil((a-s)/11.25),1,(e,t,i)=>{if(0===e)return.5*(t+i);{const e=Es((n.y+t/fs)/r);return(xs(.5*(Es((n.y+i/fs)/r)+e))*r-n.y)*fs}})}zi(vc,"FillExtrusionBucket",{omit:["layers","features"]}),zi(yc,"PartMetadata");const Mc=new Go({"fill-extrusion-edge-radius":new No(Ke["layout_fill-extrusion"]["fill-extrusion-edge-radius"])});var Ac={paint:new Go({"fill-extrusion-opacity":new No(Ke["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new Uo(Ke["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new No(Ke["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new No(Ke["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Uo(Ke["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new Uo(Ke["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new Uo(Ke["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new No(Ke["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"]),"fill-extrusion-ambient-occlusion-intensity":new No(Ke["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-intensity"]),"fill-extrusion-ambient-occlusion-radius":new No(Ke["paint_fill-extrusion"]["fill-extrusion-ambient-occlusion-radius"])}),layout:Mc};function Ic(e,t,n){var r=2*Math.PI*6378137/256/Math.pow(2,n);return[e*r-2*Math.PI*6378137/2,t*r-2*Math.PI*6378137/2]}class Pc{constructor(e,t,n){this.z=e,this.x=t,this.y=n,this.key=Dc(0,e,e,t,n)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,t){const n=function(e,t,n){var r=Ic(256*e,256*(t=Math.pow(2,n)-t-1),n),i=Ic(256*(e+1),256*(t+1),n);return r[0]+","+r[1]+","+i[0]+","+i[1]}(this.x,this.y,this.z),r=function(e,t,n){let r,i="";for(let o=e;o>0;o--)r=1<this.canonical.z?new Oc(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Oc(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 Dc(this.wrap*+t,e,this.canonical.z,this.canonical.x,this.canonical.y);{const n=this.canonical.z-e;return Dc(this.wrap*+t,e,e,this.canonical.x>>n,this.canonical.y>>n)}}isChildOf(e){if(e.wrap!==this.wrap)return!1;const t=this.canonical.z-e.canonical.z;return 0===e.overscaledZ||e.overscaledZ>t&&e.canonical.y===this.canonical.y>>t}children(e){if(this.overscaledZ>=e)return[new Oc(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const t=this.canonical.z+1,n=2*this.canonical.x,r=2*this.canonical.y;return[new Oc(t,this.wrap,t,n,r),new Oc(t,this.wrap,t,n+1,r),new Oc(t,this.wrap,t,n,r+1),new Oc(t,this.wrap,t,n+1,r+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ye.id),this.index=e.index,this.projection=e.projection,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(e=>{this.gradients[e.id]={}}),this.layoutVertexArray=new Qo,this.layoutVertexArray2=new ea,this.indexArray=new da,this.programConfigurations=new ns(e.layers,e.zoom),this.segments=new ds,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id)}populate(e,t,n,r){this.hasPattern=qu("line",this.layers,t);const i=this.layers[0].layout.get("line-sort-key"),o=[];for(const{feature:t,id:a,index:s,sourceLayerIndex:l}of e){const e=this.layers[0]._featureFilter.needGeometry,u=Rs(t,e);if(!this.layers[0]._featureFilter.filter(new Po(this.zoom),u,n))continue;const c=i?i.evaluate(u,{},n):void 0,h={id:a,properties:t.properties,type:t.type,sourceLayerIndex:l,index:s,geometry:e?u.geometry:Ls(t,n,r),patterns:{},sortKey:c};o.push(h)}i&&o.sort((e,t)=>e.sortKey-t.sortKey);const{lineAtlas:a,featureIndex:s}=t,l=this.addConstantDashes(a);for(const r of o){const{geometry:i,index:o,sourceLayerIndex:u}=r;if(l&&this.addFeatureDashes(r,a),this.hasPattern){const e=$u("line",this.layers,r,this.zoom,t);this.patternFeatures.push(e)}else this.addFeature(r,i,o,n,a.positions,t.availableImages);s.insert(e[o].feature,i,o,u,this.index)}}addConstantDashes(e){let t=!1;for(const n of this.layers){const r=n.paint.get("line-dasharray").value,i=n.layout.get("line-cap").value;if("constant"!==r.kind||"constant"!==i.kind)t=!0;else{const t=i.value,n=r.value;if(!n)continue;e.addDash(n,t)}}return t}addFeatureDashes(e,t){const n=this.zoom;for(const r of this.layers){const i=r.paint.get("line-dasharray").value,o=r.layout.get("line-cap").value;if("constant"===i.kind&&"constant"===o.kind)continue;let a,s;if("constant"===i.kind){if(a=i.value,!a)continue}else a=i.evaluate({zoom:n},e);s="constant"===o.kind?o.value:o.evaluate({zoom:n},e),t.addDash(a,s),e.patterns[r.id]=t.getKey(a,s)}}update(e,t,n,r){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,t,this.stateDependentLayers,n,r)}addFeatures(e,t,n,r,i){for(const e of this.patternFeatures)this.addFeature(e,e.geometry,e.index,t,n,r)}isEmpty(){return 0===this.layoutVertexArray.length}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(0!==this.layoutVertexArray2.length&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,Vc)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Nc),this.indexBuffer=e.createIndexBuffer(this.indexArray)),this.programConfigurations.upload(e),this.uploaded=!0}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy())}lineFeatureClips(e){if(e.properties&&e.properties.hasOwnProperty("mapbox_clip_start")&&e.properties.hasOwnProperty("mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,t,n,r,i,o){const a=this.layers[0].layout,s=a.get("line-join").evaluate(e,{}),l=a.get("line-cap").evaluate(e,{}),u=a.get("line-miter-limit"),c=a.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const n of t)this.addLine(n,e,s,l,u,c);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,n,i,o,r)}addLine(e,t,n,r,i,o){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineSoFar=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let t=0;t=2&&e[s-1].equals(e[s-2]);)s--;let l=0;for(;l0;if(b&&t>l){const e=h.dist(d);if(e>2*u){const t=h.sub(h.sub(d)._mult(u/e)._round());this.updateDistance(d,t),this.addCurrentVertex(t,p,0,0,c),d=t}}const E=d&&f;let T=E?n:a?"butt":r;if(E&&"round"===T&&(vi&&(T="bevel"),"bevel"===T&&(v>2&&(T="flipbevel"),v100)_=m.mult(-1);else{const e=v*p.add(m).mag()/p.sub(m).mag();_._perp()._mult(e*(w?-1:1))}this.addCurrentVertex(h,_,0,0,c),this.addCurrentVertex(h,_.mult(-1),0,0,c)}else if("bevel"===T||"fakeround"===T){const e=-Math.sqrt(v*v-1),t=w?e:0,n=w?0:e;if(d&&this.addCurrentVertex(h,p,t,n,c),"fakeround"===T){const e=Math.round(180*x/Math.PI/20);for(let t=1;t2*u){const t=h.add(f.sub(h)._mult(u/e)._round());this.updateDistance(h,t),this.addCurrentVertex(t,m,0,0,c),h=t}}}}addCurrentVertex(e,t,n,r,i,o=!1){const a=t.y*r-t.x,s=-t.y-t.x*r;this.addHalfVertex(e,t.x+t.y*n,t.y-t.x*n,o,!1,n,i),this.addHalfVertex(e,a,s,o,!0,-r,i)}addHalfVertex({x:e,y:t},n,r,i,o,a,s){this.layoutVertexArray.emplaceBack((e<<1)+(i?1:0),(t<<1)+(o?1:0),Math.round(63*n)+128,Math.round(63*r)+128,1+(0===a?0:a<0?-1:1),0,this.lineSoFar),this.lineClips&&this.layoutVertexArray2.emplaceBack(this.scaledDistance,this.lineClipsArray.length,this.lineClips.start,this.lineClips.end);const l=s.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,l),s.primitiveLength++),o?this.e2=l:this.e1=l}updateScaledDistance(){if(this.lineClips){const e=this.totalDistance/(this.lineClips.end-this.lineClips.start);this.scaledDistance=this.distance/this.totalDistance,this.lineSoFar=e*this.lineClips.start+this.distance}else this.lineSoFar=this.distance}updateDistance(e,t){this.distance+=e.dist(t),this.updateScaledDistance()}}zi($c,"LineBucket",{omit:["layers","patternFeatures"]});const Zc=new Go({"line-cap":new Uo(Ke.layout_line["line-cap"]),"line-join":new Uo(Ke.layout_line["line-join"]),"line-miter-limit":new No(Ke.layout_line["line-miter-limit"]),"line-round-limit":new No(Ke.layout_line["line-round-limit"]),"line-sort-key":new Uo(Ke.layout_line["line-sort-key"])});var Wc={paint:new Go({"line-opacity":new Uo(Ke.paint_line["line-opacity"]),"line-color":new Uo(Ke.paint_line["line-color"]),"line-translate":new No(Ke.paint_line["line-translate"]),"line-translate-anchor":new No(Ke.paint_line["line-translate-anchor"]),"line-width":new Uo(Ke.paint_line["line-width"]),"line-gap-width":new Uo(Ke.paint_line["line-gap-width"]),"line-offset":new Uo(Ke.paint_line["line-offset"]),"line-blur":new Uo(Ke.paint_line["line-blur"]),"line-dasharray":new Uo(Ke.paint_line["line-dasharray"]),"line-pattern":new Uo(Ke.paint_line["line-pattern"]),"line-gradient":new Vo(Ke.paint_line["line-gradient"]),"line-trim-offset":new No(Ke.paint_line["line-trim-offset"])}),layout:Zc};const Xc=new class extends Uo{possiblyEvaluate(e,t){return t=new Po(Math.floor(t.zoom),{now:t.now,fadeDuration:t.fadeDuration,transition:t.transition}),super.possiblyEvaluate(e,t)}evaluate(e,t,n,r){return t=I({},t,{zoom:Math.floor(t.zoom)}),super.evaluate(e,t,n,r)}}(Wc.paint.properties["line-width"].specification);function Hc(e,t){return t>0?t+2*e:e}Xc.useIntegerZoom=!0;const Yc=Xo([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_tex_size",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),Kc=Xo([{name:"a_globe_anchor",components:3,type:"Int16"},{name:"a_globe_normal",components:3,type:"Float32"}],4),Jc=Xo([{name:"a_projected_pos",components:4,type:"Float32"}],4);Xo([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const Qc=Xo([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]),eh=Xo([{name:"a_size_scale",components:1,type:"Float32"},{name:"a_padding",components:2,type:"Float32"}]);Xo([{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 th=Xo([{name:"a_pos",components:3,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),nh=Xo([{name:"a_pos_2f",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);Xo([{name:"triangle",components:3,type:"Uint16"}]),Xo([{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"}]),Xo([{type:"Int16",name:"projectedAnchorX"},{type:"Int16",name:"projectedAnchorY"},{type:"Int16",name:"projectedAnchorZ"},{type:"Float32",name:"tileAnchorX"},{type:"Float32",name:"tileAnchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",components:2,name:"textOffset"},{type:"Float32",name:"collisionCircleDiameter"}]),Xo([{type:"Float32",name:"offsetX"}]),Xo([{type:"Int16",name:"x"},{type:"Int16",name:"y"}]);const rh=128;function ih(e,t){const{expression:n}=t;if("constant"===n.kind)return{kind:"constant",layoutSize:n.evaluate(new Po(e+1))};if("source"===n.kind)return{kind:"source"};{const{zoomStops:t,interpolationType:r}=n;let i=0;for(;i{e.text=function(e,t,n){const r=t.layout.get("text-transform").evaluate(n,{});return"uppercase"===r?e=e.toLocaleUpperCase():"lowercase"===r&&(e=e.toLocaleLowerCase()),Io.applyArabicShaping&&(e=Io.applyArabicShaping(e)),e}(e.text,t,n)}),e}const uh={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};function ch(e){return"︶"===e||"﹈"===e||"︸"===e||"﹄"===e||"﹂"===e||"︾"===e||"︼"===e||"︺"===e||"︘"===e||"﹀"===e||"︐"===e||"︓"===e||"︔"===e||"`"===e||" ̄"===e||"︑"===e||"︒"===e}function hh(e){return"︵"===e||"﹇"===e||"︷"===e||"﹃"===e||"﹁"===e||"︽"===e||"︻"===e||"︹"===e||"︗"===e||"︿"===e}var dh=mh,fh=function(e,t,n,r,i){var o,a,s=8*i-r-1,l=(1<>1,c=-7,h=n?i-1:0,d=n?-1:1,f=e[t+h];for(h+=d,o=f&(1<<-c)-1,f>>=-c,c+=s;c>0;o=256*o+e[t+h],h+=d,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=r;c>0;a=256*a+e[t+h],h+=d,c-=8);if(0===o)o=1-u;else{if(o===l)return a?NaN:1/0*(f?-1:1);a+=Math.pow(2,r),o-=u}return(f?-1:1)*a*Math.pow(2,o-r)},ph=function(e,t,n,r,i,o){var a,s,l,u=8*o-i-1,c=(1<>1,d=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:o-1,p=r?1:-1,m=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-a))<1&&(a--,l*=2),(t+=a+h>=1?d/l:d*Math.pow(2,1-h))*l>=2&&(a++,l/=2),a+h>=c?(s=0,a=c):a+h>=1?(s=(t*l-1)*Math.pow(2,i),a+=h):(s=t*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;e[n+f]=255&s,f+=p,s/=256,i-=8);for(a=a<0;e[n+f]=255&a,f+=p,a/=256,u-=8);e[n+f-p]|=128*m}; +/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */function mh(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}mh.Varint=0,mh.Fixed64=1,mh.Bytes=2,mh.Fixed32=5;var _h=4294967296,gh=1/_h,yh="undefined"==typeof TextDecoder?null:new TextDecoder("utf8");function vh(e){return e.type===mh.Bytes?e.readVarint()+e.pos:e.pos+1}function xh(e,t,n){return n?4294967296*t+(e>>>0):4294967296*(t>>>0)+(e>>>0)}function bh(e,t,n){var r=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));n.realloc(r);for(var i=n.pos-1;i>=e;i--)n.buf[i+r]=n.buf[i]}function wh(e,t){for(var n=0;n>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function Oh(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function Dh(e,t,n){t.glyphs=[],1===e&&n.readMessage(Lh,t)}function Lh(e,t,n){if(3===e){const{id:e,bitmap:r,width:i,height:o,left:a,top:s,advance:l}=n.readMessage(Rh,{});t.glyphs.push({id:e,bitmap:new ou({width:i+6,height:o+6},r),metrics:{width:i,height:o,left:a,top:s,advance:l}})}else 4===e?t.ascender=n.readSVarint():5===e&&(t.descender=n.readSVarint())}function Rh(e,t,n){1===e?t.id=n.readVarint():2===e?t.bitmap=n.readBytes():3===e?t.width=n.readVarint():4===e?t.height=n.readVarint():5===e?t.left=n.readSVarint():6===e?t.top=n.readSVarint():7===e&&(t.advance=n.readVarint())}function Bh(e){let t=0,n=0;for(const r of e)t+=r.w*r.h,n=Math.max(n,r.w);e.sort((e,t)=>t.h-e.h);const r=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(t/.95)),n),h:1/0}];let i=0,o=0;for(const t of e)for(let e=r.length-1;e>=0;e--){const n=r[e];if(!(t.w>n.w||t.h>n.h)){if(t.x=n.x,t.y=n.y,o=Math.max(o,t.y+t.h),i=Math.max(i,t.x+t.w),t.w===n.w&&t.h===n.h){const t=r.pop();e>3,o=this.pos;this.type=7&r,e(i,t,this),this.pos===o&&this.skip(r)}return t},readMessage:function(e,t){return this.readFields(e,t,this.readVarint()+this.pos)},readFixed32:function(){var e=Ph(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=Oh(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=Ph(this.buf,this.pos)+Ph(this.buf,this.pos+4)*_h;return this.pos+=8,e},readSFixed64:function(){var e=Ph(this.buf,this.pos)+Oh(this.buf,this.pos+4)*_h;return this.pos+=8,e},readFloat:function(){var e=fh(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=fh(this.buf,this.pos,!0,52,8);return this.pos+=8,e},readVarint:function(e){var t,n,r=this.buf;return t=127&(n=r[this.pos++]),n<128?t:(t|=(127&(n=r[this.pos++]))<<7,n<128?t:(t|=(127&(n=r[this.pos++]))<<14,n<128?t:(t|=(127&(n=r[this.pos++]))<<21,n<128?t:function(e,t,n){var r,i,o=n.buf;if(r=(112&(i=o[n.pos++]))>>4,i<128)return xh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<3,i<128)return xh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<10,i<128)return xh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<17,i<128)return xh(e,r,t);if(r|=(127&(i=o[n.pos++]))<<24,i<128)return xh(e,r,t);if(r|=(1&(i=o[n.pos++]))<<31,i<128)return xh(e,r,t);throw new Error("Expected varint not more than 10 bytes")}(t|=(15&(n=r[this.pos]))<<28,e,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var e=this.readVarint();return e%2==1?(e+1)/-2:e/2},readBoolean:function(){return Boolean(this.readVarint())},readString:function(){var e=this.readVarint()+this.pos,t=this.pos;return this.pos=e,e-t>=12&&yh?function(e,t,n){return yh.decode(e.subarray(t,n))}(this.buf,t,e):function(e,t,n){for(var r="",i=t;i239?4:l>223?3:l>191?2:1;if(i+c>n)break;1===c?l<128&&(u=l):2===c?128==(192&(o=e[i+1]))&&(u=(31&l)<<6|63&o)<=127&&(u=null):3===c?(a=e[i+2],128==(192&(o=e[i+1]))&&128==(192&a)&&((u=(15&l)<<12|(63&o)<<6|63&a)<=2047||u>=55296&&u<=57343)&&(u=null)):4===c&&(a=e[i+2],s=e[i+3],128==(192&(o=e[i+1]))&&128==(192&a)&&128==(192&s)&&((u=(15&l)<<18|(63&o)<<12|(63&a)<<6|63&s)<=65535||u>=1114112)&&(u=null)),null===u?(u=65533,c=1):u>65535&&(u-=65536,r+=String.fromCharCode(u>>>10&1023|55296),u=56320|1023&u),r+=String.fromCharCode(u),i+=c}return r}(this.buf,t,e)},readBytes:function(){var e=this.readVarint()+this.pos,t=this.buf.subarray(this.pos,e);return this.pos=e,t},readPackedVarint:function(e,t){if(this.type!==mh.Bytes)return e.push(this.readVarint(t));var n=vh(this);for(e=e||[];this.pos127;);else if(t===mh.Bytes)this.pos=this.readVarint()+this.pos;else if(t===mh.Fixed32)this.pos+=4;else{if(t!==mh.Fixed64)throw new Error("Unimplemented type: "+t);this.pos+=8}},writeTag:function(e,t){this.writeVarint(e<<3|t)},realloc:function(e){for(var t=this.length||16;t268435455||e<0?function(e,t){var n,r;if(e>=0?(n=e%4294967296|0,r=e/4294967296|0):(r=~(-e/4294967296),4294967295^(n=~(-e%4294967296))?n=n+1|0:(n=0,r=r+1|0)),e>=0x10000000000000000||e<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");t.realloc(10),function(e,t,n){n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,e>>>=7,n.buf[n.pos++]=127&e|128,n.buf[n.pos]=127&(e>>>=7)}(n,0,t),function(e,t){var n=(7&e)<<4;t.buf[t.pos++]|=n|((e>>>=3)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e|((e>>>=7)?128:0),e&&(t.buf[t.pos++]=127&e)))))}(r,t)}(e,this):(this.realloc(4),this.buf[this.pos++]=127&e|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=127&(e>>>=7)|(e>127?128:0),e<=127||(this.buf[this.pos++]=e>>>7&127))))},writeSVarint:function(e){this.writeVarint(e<0?2*-e-1:2*e)},writeBoolean:function(e){this.writeVarint(Boolean(e))},writeString:function(e){e=String(e),this.realloc(4*e.length),this.pos++;var t=this.pos;this.pos=function(e,t,n){for(var r,i,o=0;o55295&&r<57344){if(!i){r>56319||o+1===t.length?(e[n++]=239,e[n++]=191,e[n++]=189):i=r;continue}if(r<56320){e[n++]=239,e[n++]=191,e[n++]=189,i=r;continue}r=i-55296<<10|r-56320|65536,i=null}else i&&(e[n++]=239,e[n++]=191,e[n++]=189,i=null);r<128?e[n++]=r:(r<2048?e[n++]=r>>6|192:(r<65536?e[n++]=r>>12|224:(e[n++]=r>>18|240,e[n++]=r>>12&63|128),e[n++]=r>>6&63|128),e[n++]=63&r|128)}return n}(this.buf,e,this.pos);var n=this.pos-t;n>=128&&bh(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),ph(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ph(this.buf,e,this.pos,!0,52,8),this.pos+=8},writeBytes:function(e){var t=e.length;this.writeVarint(t),this.realloc(t);for(var n=0;n=128&&bh(n,r,this),this.pos=n-1,this.writeVarint(r),this.pos+=r},writeMessage:function(e,t,n){this.writeTag(e,mh.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,wh,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,Eh,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,kh,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,Th,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,Sh,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,Ch,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,Mh,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,Ah,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,Ih,t)},writeBytesField:function(e,t){this.writeTag(e,mh.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,mh.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,mh.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,mh.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,mh.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,mh.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,mh.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,mh.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,mh.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,mh.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,Boolean(t))}};class Fh{constructor(e,{pixelRatio:t,version:n,stretchX:r,stretchY:i,content:o}){this.paddedRect=e,this.pixelRatio=t,this.stretchX=r,this.stretchY=i,this.content=o,this.version=n}get tl(){return[this.paddedRect.x+1,this.paddedRect.y+1]}get br(){return[this.paddedRect.x+this.paddedRect.w-1,this.paddedRect.y+this.paddedRect.h-1]}get displaySize(){return[(this.paddedRect.w-2)/this.pixelRatio,(this.paddedRect.h-2)/this.pixelRatio]}}class jh{constructor(e,t){const n={},r={};this.haveRenderCallbacks=[];const i=[];this.addImages(e,n,i),this.addImages(t,r,i);const{w:o,h:a}=Bh(i),s=new au({width:o||1,height:a||1});for(const t in e){const r=e[t],i=n[t].paddedRect;au.copy(r.data,s,{x:0,y:0},{x:i.x+1,y:i.y+1},r.data)}for(const e in t){const n=t[e],i=r[e].paddedRect,o=i.x+1,a=i.y+1,l=n.data.width,u=n.data.height;au.copy(n.data,s,{x:0,y:0},{x:o,y:a},n.data),au.copy(n.data,s,{x:0,y:u-1},{x:o,y:a-1},{width:l,height:1}),au.copy(n.data,s,{x:0,y:0},{x:o,y:a+u},{width:l,height:1}),au.copy(n.data,s,{x:l-1,y:0},{x:o-1,y:a},{width:1,height:u}),au.copy(n.data,s,{x:0,y:0},{x:o+l,y:a},{width:1,height:u})}this.image=s,this.iconPositions=n,this.patternPositions=r}addImages(e,t,n){for(const r in e){const i=e[r],o={x:0,y:0,w:i.data.width+2,h:i.data.height+2};n.push(o),t[r]=new Fh(o,i),i.hasRenderCallback&&this.haveRenderCallbacks.push(r)}}patchUpdatedImages(e,t){this.haveRenderCallbacks=this.haveRenderCallbacks.filter(t=>e.hasImage(t)),e.dispatchRenderCallbacks(this.haveRenderCallbacks);for(const n in e.updatedImages)this.patchUpdatedImage(this.iconPositions[n],e.getImage(n),t),this.patchUpdatedImage(this.patternPositions[n],e.getImage(n),t)}patchUpdatedImage(e,t,n){if(!e||!t)return;if(e.version===t.version)return;e.version=t.version;const[r,i]=e.tl;n.update(t.data,void 0,{x:r,y:i})}}zi(Fh,"ImagePosition"),zi(jh,"ImageAtlas");const Nh={horizontal:1,vertical:2,horizontalOnly:3};class Uh{constructor(){this.scale=1,this.fontStack="",this.imageName=null}static forText(e,t){const n=new Uh;return n.scale=e||1,n.fontStack=t,n}static forImage(e){const t=new Uh;return t.imageName=e,t}}class Vh{constructor(){this.text="",this.sectionIndex=[],this.sections=[],this.imageSectionID=null}static fromFeature(e,t){const n=new Vh;for(let r=0;r=0&&n>=e&&qh[this.text.charCodeAt(n)];n--)t--;this.text=this.text.substring(e,t),this.sectionIndex=this.sectionIndex.slice(e,t)}substring(e,t){const n=new Vh;return n.text=this.text.substring(e,t),n.sectionIndex=this.sectionIndex.slice(e,t),n.sections=this.sections,n}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,t)=>Math.max(e,this.sections[t].scale),0)}addTextSection(e,t){this.text+=e.text,this.sections.push(Uh.forText(e.scale,e.fontStack||t));const n=this.sections.length-1;for(let t=0;t=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Gh(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=Vh.fromFeature(e,i);h===Nh.vertical&&m.verticalizePunctuation(d);let _=[];const g=function(e,t,n,r,i,o){if(!e)return[];const a=[],s=function(e,t,n,r,i,o){let a=0;for(let n=0;n=0;let u=0;for(let n=0;n0&&o>b&&(b=o)}else{const e=n[s.fontStack];if(!e)continue;e[m]&&(T=e[m]);const r=t[s.fontStack];if(!r)continue;const o=r.glyphs[m];if(!o)continue;if(v=o.metrics,k=8203!==m?24:0,_){const e=void 0!==r.ascender?Math.abs(r.ascender):0,t=void 0!==r.descender?Math.abs(r.descender):0,n=(e+t)*g;w-n/2;){if(a--,a<0)return!1;s-=e[a].dist(o),o=e[a]}s+=e[a].dist(e[a+1]),a++;const l=[];let u=0;for(;sr;)u-=l.shift().angleDelta;if(u>i)return!1;a++,s+=t.dist(n)}return!0}function nd(e){let t=0;for(let n=0;nu){const c=(u-l)/o,h=Mn(r.x,i.x,c),d=Mn(r.y,i.y,c),f=new ed(h,d,0,i.angleTo(r),n);return!a||td(e,f,s,a,t)?f:void 0}l+=o}}function ad(e,t,n,r,i,o,a,s,l){const u=rd(r,o,a),c=id(r,i),h=c*a,d=0===e[0].x||e[0].x===l||0===e[0].y||e[0].y===l;return t-h=0&&g=0&&y=0&&f+c<=h){const n=new ed(g,y,0,m,e);n._round(),i&&!td(t,n,a,i,o)||p.push(n)}}d+=l}return l||p.length||s||(p=e(t,d/2,r,i,o,a,s,!0,u)),p}(e,d?t/2*s%t:(c/2+2*o)*a*s%t,t,u,n,h,d,!1,l)}function sd(e,t,n,r,i){const o=[];for(let a=0;a=r&&u.x>=r||(a.x>=r?a=new m(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round():u.x>=r&&(u=new m(r,a.y+(r-a.x)/(u.x-a.x)*(u.y-a.y))._round()),a.y>=i&&u.y>=i||(a.y>=i?a=new m(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round():u.y>=i&&(u=new m(a.x+(i-a.y)/(u.y-a.y)*(u.x-a.x),i)._round()),l&&a.equals(l[l.length-1])||(l=[a],o.push(l)),l.push(u)))))}}return o}zi(ed,"Anchor");const ld=1e20;function ud(e,t,n,r,i,o,a,s,l){for(let u=t;u-1);l++,o[l]=s,a[l]=u,a[l+1]=ld}for(let s=0,l=0;s{let r=this.entries[e];r||(r=this.entries[e]={glyphs:{},requests:{},ranges:{},ascender:void 0,descender:void 0});let i=r.glyphs[t];if(void 0!==i)return void n(null,{stack:e,id:t,glyph:i});if(i=this._tinySDF(r,e,t),i)return r.glyphs[t]=i,void n(null,{stack:e,id:t,glyph:i});const o=Math.floor(t/256);if(256*o>65535)return void n(new Error("glyphs > 65535 not supported"));if(r.ranges[o])return void n(null,{stack:e,id:t,glyph:i});let a=r.requests[o];a||(a=r.requests[o]=[],dd.loadGlyphRange(e,o,this.url,this.requestManager,(e,t)=>{if(t){r.ascender=t.ascender,r.descender=t.descender;for(const e in t.glyphs)this._doesCharSupportLocalGlyph(+e)||(r.glyphs[+e]=t.glyphs[+e]);r.ranges[o]=!0}for(const n of a)n(e,t);delete r.requests[o]})),a.push((r,i)=>{r?n(r):i&&n(null,{stack:e,id:t,glyph:i.glyphs[t]||null})})},(e,n)=>{if(e)t(e);else if(n){const e={};for(const{stack:t,id:r,glyph:i}of n)void 0===e[t]&&(e[t]={}),void 0===e[t].glyphs&&(e[t].glyphs={}),e[t].glyphs[r]=i&&{id:i.id,bitmap:i.bitmap.clone(),metrics:i.metrics},e[t].ascender=this.entries[t].ascender,e[t].descender=this.entries[t].descender;t(null,e)}})}_doesCharSupportLocalGlyph(e){return this.localGlyphMode!==hd.none&&(this.localGlyphMode===hd.all?!!this.localFontFamily:!!this.localFontFamily&&(Qi(e)||no(e)||qi(e)||$i(e)||Gi(e)))}_tinySDF(e,t,n){const r=this.localFontFamily;if(!r||!this._doesCharSupportLocalGlyph(n))return;let i=e.tinySDF;if(!i){let n="400";/bold/i.test(t)?n="900":/medium/i.test(t)?n="500":/light/i.test(t)&&(n="200"),i=e.tinySDF=new dd.TinySDF({fontFamily:r,fontWeight:n,fontSize:48,buffer:6,radius:16}),i.fontWeight=n}if(this.localGlyphs[i.fontWeight][n])return this.localGlyphs[i.fontWeight][n];const o=String.fromCharCode(n),{data:a,width:s,height:l,glyphWidth:u,glyphHeight:c,glyphLeft:h,glyphTop:d,glyphAdvance:f}=i.draw(o);return this.localGlyphs[i.fontWeight][n]={id:n,bitmap:new ou({width:s,height:l},a),metrics:{width:u/2,height:c/2,left:h/2,top:d/2-27,advance:f/2,localGlyph:!0}}}}function fd(e,t,n,r){const i=[],o=e.image,a=o.pixelRatio,s=o.paddedRect.w-2,l=o.paddedRect.h-2,u=e.right-e.left,c=e.bottom-e.top,h=o.stretchX||[[0,s]],d=o.stretchY||[[0,l]],f=(e,t)=>e+t[1]-t[0],p=h.reduce(f,0),_=d.reduce(f,0),g=s-p,y=l-_;let v=0,x=p,b=0,w=_,E=0,T=g,S=0,k=y;if(o.content&&r){const e=o.content;v=pd(h,0,e[0]),b=pd(d,0,e[1]),x=pd(h,e[0],e[2]),w=pd(d,e[1],e[3]),E=e[0]-v,S=e[1]-b,T=e[2]-e[0]-x,k=e[3]-e[1]-w}const C=(r,i,s,l)=>{const h=_d(r.stretch-v,x,u,e.left),d=gd(r.fixed-E,T,r.stretch,p),f=_d(i.stretch-b,w,c,e.top),g=gd(i.fixed-S,k,i.stretch,_),y=_d(s.stretch-v,x,u,e.left),C=gd(s.fixed-E,T,s.stretch,p),M=_d(l.stretch-b,w,c,e.top),A=gd(l.fixed-S,k,l.stretch,_),I=new m(h,f),P=new m(y,f),z=new m(y,M),O=new m(h,M),D=new m(d/a,g/a),L=new m(C/a,A/a),R=t*Math.PI/180;if(R){const e=Math.sin(R),t=Math.cos(R),n=[t,-e,e,t];I._matMult(n),P._matMult(n),O._matMult(n),z._matMult(n)}const B=r.stretch+r.fixed,F=i.stretch+i.fixed;return{tl:I,tr:P,bl:O,br:z,tex:{x:o.paddedRect.x+1+B,y:o.paddedRect.y+1+F,w:s.stretch+s.fixed-B,h:l.stretch+l.fixed-F},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:D,pixelOffsetBR:L,minFontScaleX:T/a/u,minFontScaleY:k/a/c,isSDF:n}};if(r&&(o.stretchX||o.stretchY)){const e=md(h,g,p),t=md(d,y,_);for(let n=0;n{if(e)i(e);else if(t){const e={},n=function(e){return new dh(e).readFields(Dh,{})}(t);for(const t of n.glyphs)e[t.id]=t;i(null,{glyphs:e,ascender:n.ascender,descender:n.descender})}})},dd.TinySDF=class{constructor({fontSize:e=24,buffer:t=3,radius:n=8,cutoff:r=.25,fontFamily:i="sans-serif",fontWeight:o="normal",fontStyle:a="normal"}={}){this.buffer=t,this.cutoff=r,this.radius=n;const s=this.size=e+4*t,l=this._createCanvas(s),u=this.ctx=l.getContext("2d",{willReadFrequently:!0});u.font=`${a} ${o} ${e}px ${i}`,u.textBaseline="alphabetic",u.textAlign="left",u.fillStyle="black",this.gridOuter=new Float64Array(s*s),this.gridInner=new Float64Array(s*s),this.f=new Float64Array(s),this.z=new Float64Array(s+1),this.v=new Uint16Array(s)}_createCanvas(e){const t=document.createElement("canvas");return t.width=t.height=e,t}draw(e){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:r,actualBoundingBoxLeft:i,actualBoundingBoxRight:o}=this.ctx.measureText(e),a=Math.ceil(n),s=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(o-i))),l=Math.min(this.size-this.buffer,a+Math.ceil(r)),u=s+2*this.buffer,c=l+2*this.buffer,h=Math.max(u*c,0),d=new Uint8ClampedArray(h),f={data:d,width:u,height:c,glyphWidth:s,glyphHeight:l,glyphTop:a,glyphLeft:0,glyphAdvance:t};if(0===s||0===l)return f;const{ctx:p,buffer:m,gridInner:_,gridOuter:g}=this;p.clearRect(m,m,s,l),p.fillText(e,m,m+a);const y=p.getImageData(m,m,s,l);g.fill(ld,0,h),_.fill(0,0,h);for(let e=0;e0?e*e:0,_[r]=e<0?e*e:0}}ud(g,0,0,u,c,u,this.f,this.v,this.z),ud(_,m,m,s,l,u,this.f,this.v,this.z);for(let e=0;e0)for(let e=(this.length>>1)-1;e>=0;e--)this._down(e)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(0===this.length)return;const e=this.data[0],t=this.data.pop();return this.length--,this.length>0&&(this.data[0]=t,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:t,compare:n}=this,r=t[e];for(;e>0;){const i=e-1>>1,o=t[i];if(n(r,o)>=0)break;t[e]=o,e=i}t[e]=r}_down(e){const{data:t,compare:n}=this,r=this.length>>1,i=t[e];for(;e=0)break;t[e]=o,e=r}t[e]=i}}function xd(e,t){return et?1:0}function bd(e,t=1,n=!1){let r=1/0,i=1/0,o=-1/0,a=-1/0;const s=e[0];for(let e=0;eo)&&(o=t.x),(!e||t.y>a)&&(a=t.y)}const l=Math.min(o-r,a-i);let u=l/2;const c=new vd([],wd);if(0===l)return new m(r,i);for(let t=r;th.d||!h.d)&&(h=r,n&&console.log("found best %d after %d probes",Math.round(1e4*r.d)/1e4,d)),r.max-h.d<=t||(u=r.h/2,c.push(new Ed(r.p.x-u,r.p.y-u,u,e)),c.push(new Ed(r.p.x+u,r.p.y-u,u,e)),c.push(new Ed(r.p.x-u,r.p.y+u,u,e)),c.push(new Ed(r.p.x+u,r.p.y+u,u,e)),d+=4)}return n&&(console.log("num probes: "+d),console.log("best distance: "+h.d)),h.p}function wd(e,t){return t.max-e.max}function Ed(e,t,n,r){this.p=new m(e,t),this.h=n,this.d=function(e,t){let n=!1,r=1/0;for(let i=0;ie.y!=s.y>e.y&&e.x<(s.x-i.x)*(e.y-i.y)/(s.y-i.y)+i.x&&(n=!n),r=Math.min(r,Ws(e,i,s))}}return(n?1:-1)*Math.sqrt(r)}(this.p,r),this.max=this.d+this.h*Math.SQRT2}const Td=Number.POSITIVE_INFINITY,Sd=Math.sqrt(2);function kd(e,[t,n]){let r=0,i=0;if(n===Td){t<0&&(t=0);const n=t/Sd;switch(e){case"top-right":case"top-left":i=n-7;break;case"bottom-right":case"bottom-left":i=7-n;break;case"bottom":i=7-t;break;case"top":i=t-7}switch(e){case"top-right":case"bottom-right":r=-n;break;case"top-left":case"bottom-left":r=n;break;case"left":r=t;break;case"right":r=-t}}else{switch(t=Math.abs(t),n=Math.abs(n),e){case"top-right":case"top-left":case"top":i=n-7;break;case"bottom-right":case"bottom-left":case"bottom":i=7-n}switch(e){case"top-right":case"bottom-right":case"right":r=-t;break;case"top-left":case"bottom-left":case"left":r=t}}return[r,i]}function Cd(e,t,n,r,i,o,a,s,l,u){e.createArrays(),e.tilePixelRatio=fs/(512*e.overscaling),e.compareText={},e.iconsNeedLinear=!1;const c=e.layers[0].layout,h=e.layers[0]._unevaluatedLayout._values,d={};if("composite"===e.textSizeData.kind){const{minZoom:t,maxZoom:n}=e.textSizeData;d.compositeTextSizes=[h["text-size"].possiblyEvaluate(new Po(t),s),h["text-size"].possiblyEvaluate(new Po(n),s)]}if("composite"===e.iconSizeData.kind){const{minZoom:t,maxZoom:n}=e.iconSizeData;d.compositeIconSizes=[h["icon-size"].possiblyEvaluate(new Po(t),s),h["icon-size"].possiblyEvaluate(new Po(n),s)]}d.layoutTextSize=h["text-size"].possiblyEvaluate(new Po(l+1),s),d.layoutIconSize=h["icon-size"].possiblyEvaluate(new Po(l+1),s),d.textMaxSize=h["text-size"].possiblyEvaluate(new Po(18),s);const f="map"===c.get("text-rotation-alignment")&&"point"!==c.get("symbol-placement"),p=c.get("text-size");for(const o of e.features){const l=c.get("text-font").evaluate(o,{},s).join(","),h=p.evaluate(o,{},s),m=d.layoutTextSize.evaluate(o,{},s),_=(d.layoutIconSize.evaluate(o,{},s),{horizontal:{},vertical:void 0}),g=o.text;let y,v=[0,0];if(g){const r=g.toString(),a=24*c.get("text-letter-spacing").evaluate(o,{},s),u=24*c.get("text-line-height").evaluate(o,{},s),d=ho(r)?a:0,p=c.get("text-anchor").evaluate(o,{},s),y=c.get("text-variable-anchor");if(!y){const e=c.get("text-radial-offset").evaluate(o,{},s);v=e?kd(p,[24*e,Td]):c.get("text-offset").evaluate(o,{},s).map(e=>24*e)}let x=f?"center":c.get("text-justify").evaluate(o,{},s);const b="point"===c.get("symbol-placement"),w=b?24*c.get("text-max-width").evaluate(o,{},s):1/0,E=o=>{e.allowVerticalPlacement&&co(r)&&(_.vertical=Gh(g,t,n,i,l,w,u,p,o,d,v,Nh.vertical,!0,m,h))};if(!f&&y){const e="auto"===x?y.map(e=>Md(e)):[x];let r=!1;for(let o=0;o=0||!co(r)){const e=Gh(g,t,n,i,l,w,u,p,x,d,v,Nh.horizontal,!1,m,h);e&&(_.horizontal[x]=e)}E(b?"left":x)}}let x=!1;if(o.icon&&o.icon.name){const t=r[o.icon.name];t&&(y=Jh(i[o.icon.name],c.get("icon-offset").evaluate(o,{},s),c.get("icon-anchor").evaluate(o,{},s)),x=t.sdf,void 0===e.sdfIcons?e.sdfIcons=t.sdf:e.sdfIcons!==t.sdf&&V("Style sheet warning: Cannot mix SDF and non-SDF icons in one buffer"),(t.pixelRatio!==e.pixelRatio||0!==c.get("icon-rotate").constantOr(1))&&(e.iconsNeedLinear=!0))}const b=zd(_.horizontal)||_.vertical;e.iconsInText||(e.iconsInText=!!b&&b.iconsInText),(b||y)&&Ad(e,o,_,y,r,d,m,0,v,x,a,s,u)}o&&e.generateCollisionDebugBuffers(l,e.collisionBoxArray)}function Md(e){switch(e){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Ad(e,t,n,r,i,o,a,s,l,u,c,h,d){let f=o.textMaxSize.evaluate(t,{},h);void 0===f&&(f=a);const p=e.layers[0].layout,m=p.get("icon-offset").evaluate(t,{},h),_=zd(n.horizontal)||n.vertical,g="globe"===d.name,y=a/24,x=e.tilePixelRatio*f/24,b=(A=e.overscaling,e.zoom>18&&A>2&&(A>>=1),Math.max(fs/(512*A),1)*p.get("symbol-spacing")),w=p.get("text-padding")*e.tilePixelRatio,E=p.get("icon-padding")*e.tilePixelRatio,T=v(p.get("text-max-angle")),S="map"===p.get("text-rotation-alignment")&&"point"!==p.get("symbol-placement"),k="map"===p.get("icon-rotation-alignment")&&"point"!==p.get("symbol-placement"),C=p.get("symbol-placement"),M=b/2;var A;const I=p.get("icon-text-fit");let P;r&&"none"!==I&&(e.allowVerticalPlacement&&n.vertical&&(P=Qh(r,n.vertical,I,p.get("icon-text-fit-padding"),m,y)),_&&(r=Qh(r,_,I,p.get("icon-text-fit-padding"),m,y)));const z=(a,s,f)=>{if(s.x<0||s.x>=fs||s.y<0||s.y>=fs)return;let p=null;if(g){const{x:e,y:t,z:n}=d.projectTilePoint(s.x,s.y,f);p={anchor:new ed(e,t,n,0,void 0),up:d.upVector(f,s.x,s.y)}}!function(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v,x,b,w,E,T){const S=e.addToLineVertexArray(t,r);let k,C,M,A,I,P,z,O=0,D=0,L=0,R=0,B=-1,F=-1;const j={};let N=Da.exports("");const U=n?n.anchor:t;let G=0,q=0;if(void 0===l._unevaluatedLayout.getValue("text-radial-offset")?[G,q]=l.layout.get("text-offset").evaluate(x,{},T).map(e=>24*e):(G=24*l.layout.get("text-radial-offset").evaluate(x,{},T),q=Td),e.allowVerticalPlacement&&i.vertical){const e=i.vertical;if(p)P=Dd(e),s&&(z=Dd(s));else{const n=l.layout.get("text-rotate").evaluate(x,{},T)+90;M=Od(u,U,t,c,h,d,e,f,n,m),s&&(A=Od(u,U,t,c,h,d,s,g,n))}}if(o){const r=l.layout.get("icon-rotate").evaluate(x,{},T),i="none"!==l.layout.get("icon-text-fit"),a=fd(o,r,w,i),f=s?fd(s,r,w,i):void 0;C=Od(u,U,t,c,h,d,o,g,r),O=4*a.length;const p=e.iconSizeData;let m=null;"source"===p.kind?(m=[rh*l.layout.get("icon-size").evaluate(x,{},T)],m[0]>Id&&V(e.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')):"composite"===p.kind&&(m=[rh*b.compositeIconSizes[0].evaluate(x,{},T),rh*b.compositeIconSizes[1].evaluate(x,{},T)],(m[0]>Id||m[1]>Id)&&V(e.layerIds[0]+': Value for "icon-size" is >= 255. Reduce your "icon-size".')),e.addSymbols(e.icon,a,m,v,y,x,!1,n,t,S.lineStartIndex,S.lineLength,-1,E,T),B=e.icon.placedSymbolArray.length-1,f&&(D=4*f.length,e.addSymbols(e.icon,f,m,v,y,x,Nh.vertical,n,t,S.lineStartIndex,S.lineLength,-1,E,T),F=e.icon.placedSymbolArray.length-1)}for(const r in i.horizontal){const o=i.horizontal[r];k||(N=Da.exports(o.text),p?I=Dd(o):k=Od(u,U,t,c,h,d,o,f,l.layout.get("text-rotate").evaluate(x,{},T),m));const s=1===o.positionedLines.length;if(L+=Pd(e,n,t,o,a,l,p,x,m,S,i.vertical?Nh.horizontal:Nh.horizontalOnly,s?Object.keys(i.horizontal):[r],j,B,b,E,T),s)break}i.vertical&&(R+=Pd(e,n,t,i.vertical,a,l,p,x,m,S,Nh.vertical,["vertical"],j,F,b,E,T));let $=-1;const Z=(e,t)=>e?Math.max(e,t):t;$=Z(I,$),$=Z(P,$),$=Z(z,$);const W=$>-1?1:0;e.glyphOffsetArray.length>=Wf.MAX_GLYPHS&&V("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),void 0!==x.sortKey&&e.addToSortKeyRanges(e.symbolInstances.length,x.sortKey),e.symbolInstances.emplaceBack(U.x,U.y,U.z,t.x,t.y,j.right>=0?j.right:-1,j.center>=0?j.center:-1,j.left>=0?j.left:-1,j.vertical>=0?j.vertical:-1,B,F,N,void 0!==k?k:e.collisionBoxArray.length,void 0!==k?k+1:e.collisionBoxArray.length,void 0!==M?M:e.collisionBoxArray.length,void 0!==M?M+1:e.collisionBoxArray.length,void 0!==C?C:e.collisionBoxArray.length,void 0!==C?C+1:e.collisionBoxArray.length,A||e.collisionBoxArray.length,A?A+1:e.collisionBoxArray.length,c,L,R,O,D,W,0,G,q,$)}(e,s,p,a,n,r,i,P,e.layers[0],e.collisionBoxArray,t.index,t.sourceLayerIndex,e.index,w,S,l,0,E,k,m,t,o,u,c,h)};if("line"===C)for(const i of sd(t.geometry,0,0,fs,fs)){const t=ad(i,b,T,n.vertical||_,r,24,x,e.overscaling,fs);for(const n of t){const t=_;t&&Ld(e,t.text,M,n)||z(i,n,h)}}else if("line-center"===C){for(const e of t.geometry)if(e.length>1){const t=od(e,T,n.vertical||_,r,24,x);t&&z(e,t,h)}}else if("Polygon"===t.type)for(const e of Vu(t.geometry,0)){const t=bd(e,16);z(e[0],new ed(t.x,t.y,0,0,void 0),h)}else if("LineString"===t.type)for(const e of t.geometry)z(e,new ed(e[0].x,e[0].y,0,0,void 0),h);else if("Point"===t.type)for(const e of t.geometry)for(const t of e)z([t],new ed(t.x,t.y,0,0,void 0),h)}const Id=32640;function Pd(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,_,g){const y=function(e,t,n,r,i,o,a,s){const l=[];if(0===t.positionedLines.length)return l;const u=r.layout.get("text-rotate").evaluate(o,{})*Math.PI/180,c=function(e){const t=e[0],n=e[1],r=t*n;return r>0?[t,-n]:r<0?[-t,n]:0===t?[n,t]:[n,-t]}(n);let h=Math.abs(t.top-t.bottom);for(const e of t.positionedLines)h-=e.lineOffset;const d=t.positionedLines.length,f=h/d;let p=t.top-n[1];for(let e=0;eId&&V(e.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')):"composite"===v.kind&&(x=[rh*p.compositeTextSizes[0].evaluate(s,{},g),rh*p.compositeTextSizes[1].evaluate(s,{},g)],(x[0]>Id||x[1]>Id)&&V(e.layerIds[0]+': Value for "text-size" is >= 255. Reduce your "text-size".')),e.addSymbols(e.text,y,x,l,a,s,c,t,n,u.lineStartIndex,u.lineLength,f,_,g);for(const t of h)d[t]=e.text.placedSymbolArray.length-1;return 4*y.length}function zd(e){for(const t in e)return e[t];return null}function Od(e,t,n,r,i,o,a,s,l,u){let c=a.top,h=a.bottom,d=a.left,f=a.right;const p=a.collisionPadding;if(p&&(d-=p[0],c-=p[1],f+=p[2],h+=p[3]),l){const e=new m(d,c),t=new m(f,c),n=new m(d,h),r=new m(f,h),i=v(l);let o=new m(0,0);u&&(o=new m(u[0],u[1])),e._rotateAround(i,o),t._rotateAround(i,o),n._rotateAround(i,o),r._rotateAround(i,o),d=Math.min(e.x,t.x,n.x,r.x),f=Math.max(e.x,t.x,n.x,r.x),c=Math.min(e.y,t.y,n.y,r.y),h=Math.max(e.y,t.y,n.y,r.y)}return e.emplaceBack(t.x,t.y,t.z,n.x,n.y,d,c,f,h,s,r,i,o),e.length-1}function Dd(e){e.collisionPadding&&(e.top-=e.collisionPadding[1],e.bottom+=e.collisionPadding[3]);const t=e.bottom-e.top;return t>0?Math.max(10,t):null}function Ld(e,t,n,r){const i=e.compareText;if(t in i){const e=i[t];for(let t=e.length-1;t>=0;t--)if(r.dist(e[t])1?null:function(e,t,n,r){const i=Math.sin(n);return e*(Math.sin((1-r)*n)/i)+t*(Math.sin(r*n)/i)}(e.a[t],e.b[t],e.angle,S(n,0,1))+e.center[t]}function Hd(e){if(e.z<=1)return $d[e.z+2*e.y+e.x];const t=ef(Qd(e));return Hl.fromPoints(t)}function Yd(e,t,n){return Cl(e,e,1-n),Ml(e,e,t,n)}function Kd(e,t){const n=cf(t.zoom);if(0===n)return Hd(e);const r=Qd(e),i=ef(r),o=vs(r.getWest())*t.worldSize,a=vs(r.getEast())*t.worldSize,s=xs(r.getNorth())*t.worldSize,l=xs(r.getSouth())*t.worldSize,u=[o,s,0],c=[a,s,0],h=[o,l,0],d=[a,l,0],f=ul([],t.globeMatrix);return zl(u,u,f),zl(c,c,f),zl(h,h,f),zl(d,d,f),i[0]=Yd(i[0],h,n),i[1]=Yd(i[1],d,n),i[2]=Yd(i[2],c,n),i[3]=Yd(i[3],u,n),Hl.fromPoints(i)}function Jd(e,t,n){for(const r of e)zl(r,r,t),Cl(r,r,n)}function Qd({x:e,y:t,z:n}){const r=1/(1<Math.PI/2*1.01}const ff=v(85),pf=Math.cos(ff),mf=Math.sin(ff);function _f(e,t){const n=e.fovAboveCenter,r=e.elevation?e.elevation.getMinElevationBelowMSL()*t:0,i=(e._camera.position[2]*e.worldSize-r)/Math.cos(e._pitch),o=Math.sin(n)*i/Math.sin(Math.max(Math.PI/2-e._pitch-n,.01)),a=Math.sin(e._pitch)*o+i;return Math.min(1.01*a,i*(1/e._horizonShift))}function gf(e,t){if(!t.isReprojectedInTileSpace)return{scale:1<v&&(x(e,u,r,i,s,l),x(u,n,s,l,o,a))}x(h,d,r,o,i,o),x(d,f,i,o,i,a),x(f,p,i,a,r,a),x(p,h,r,a,r,o),m-=v,_-=v,g+=v,y+=v;const b=1/Math.max(g-m,y-_);return{scale:b,x:m*b,y:_*b,x2:g*b,y2:y*b,projection:t}}const yf=ll(new Float32Array(16));class vf{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 _s(0,0)}projectTilePoint(e,t,n){return{x:e,y:t,z:0}}locationPoint(e,t,n=!0){return e._coordinatePoint(e.locationCoordinate(t),n)}pixelsPerMeter(e,t){return bs(1,e)*t}pixelSpaceConversion(e,t,n){return 1}farthestPixelDistance(e){return _f(e,e.pixelsPerMeter)}pointCoordinate(e,t,n,r){const i=e.horizonLineFromTop(!1),o=new m(t,Math.max(i,n));return e.rayIntersectionCoordinate(e.pointRayIntersection(o,r))}pointCoordinate3D(e,t,n){const r=new m(t,n);if(e.elevation)return e.elevation.pointCoordinate(r);{const t=this.pointCoordinate(e,r.x,r.y,0);return[t.x,t.y,t.z]}}isPointAboveHorizon(e,t){if(e.elevation)return!this.pointCoordinate3D(e,t.x,t.y);const n=e.horizonLineFromTop();return t.y0?t<-Mf+n&&(t=-Mf+n):t>Mf-n&&(t=Mf-n);const o=i/Math.pow(Af(t),r);let a=o*Math.sin(r*e),s=i-o*Math.cos(r*e);return a=.5*(a/Math.PI+.5),s=.5*(s/Math.PI+.5),{x:a,y:this.southernCenter?s:1-s,z:0}}unproject(e,t){e=(2*e-.5)*Math.PI,this.southernCenter&&(t=1-t),t=(2*(1-t)-.5)*Math.PI;const{n:n,f:r}=this,i=r-t,o=Math.sign(i),a=Math.sign(n)*Math.sqrt(e*e+i*i);let s=Math.atan2(e,Math.abs(i))*o;i*n<0&&(s-=Math.PI*Math.sign(e)*o);const l=S(x(s/n)+this.center[0],-180,180),u=S(x(2*Math.atan(Math.pow(r/a,1/n))-Mf),-85.051129,Ss);return new _s(l,this.southernCenter?-u:u)}}class Pf extends vf{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:vs(e),y:xs(t),z:0}}unproject(e,t){const n=ws(e),r=Es(t);return new _s(n,r)}}const zf=v(Ss);class Of extends vf{project(e,t){const n=(t=v(t))*t,r=n*n;return{x:.5*((e=v(e))*(.8707-.131979*n+r*(r*(.003971*n-.001529*r)-.013791))/Math.PI+.5),y:1-.5*(t*(1.007226+n*(.015085+r*(.028874*n-.044475-.005916*r)))/Math.PI+1),z:0}}unproject(e,t){e=(2*e-.5)*Math.PI;let n=t=(2*(1-t)-1)*Math.PI,r=25,i=0,o=n*n;do{o=n*n;const e=o*o;i=(n*(1.007226+o*(.015085+e*(.028874*o-.044475-.005916*e)))-t)/(1.007226+o*(.045255+e*(.259866*o-.311325-.005916*11*e))),n=S(n-i,-zf,zf)}while(Math.abs(i)>1e-6&&--r>0);o=n*n;const a=S(x(e/(.8707+o*(o*(o*o*o*(.003971-.001529*o)-.013791)-.131979))),-180,180),s=x(n);return new _s(a,s)}}const Df=v(Ss);class Lf extends vf{project(e,t){t=v(t),e=v(e);const n=Math.cos(t),r=2/Math.PI,i=Math.acos(n*Math.cos(e/2)),o=Math.sin(i)/i,a=.5*(e*r+2*n*Math.sin(e/2)/o)||0,s=.5*(t+Math.sin(t)/o)||0;return{x:.5*(a/Math.PI+.5),y:1-.5*(s/Math.PI+1),z:0}}unproject(e,t){let n=e=(2*e-.5)*Math.PI,r=t=(2*(1-t)-1)*Math.PI,i=25;const o=1e-6;let a=0,s=0;do{const i=Math.cos(r),o=Math.sin(r),l=2*o*i,u=o*o,c=i*i,h=Math.cos(n/2),d=Math.sin(n/2),f=2*h*d,p=d*d,m=1-c*h*h,_=m?1/m:0,g=m?Math.acos(i*h)*Math.sqrt(1/m):0,y=.5*(2*g*i*d+2*n/Math.PI)-e,v=.5*(g*o+r)-t,x=.5*_*(c*p+g*i*h*u)+1/Math.PI,b=_*(f*l/4-g*o*d),w=.125*_*(l*d-g*o*c*f),E=.5*_*(u*h+g*p*i)+.5,T=b*w-E*x;a=(v*b-y*E)/T,s=(y*w-v*x)/T,n=S(n-a,-Math.PI,Math.PI),r=S(r-s,-Df,Df)}while((Math.abs(a)>o||Math.abs(s)>o)&&--i>0);return new _s(x(n),x(r))}}class Rf extends vf{constructor(e){super(e),this.center=e.center||[0,0],this.parallels=e.parallels||[0,0],this.cosPhi=Math.max(.01,Math.cos(v(this.parallels[0]))),this.scale=1/(2*Math.max(Math.PI*this.cosPhi,1/this.cosPhi)),this.wrap=!0,this.supportsWorldCopies=!0}project(e,t){const{scale:n,cosPhi:r}=this;return{x:v(e)*r*n+.5,y:-Math.sin(v(t))/r*n+.5,z:0}}unproject(e,t){const{scale:n,cosPhi:r}=this,i=-(t-.5)/n,o=S(x((e-.5)/n)/r,-180,180),a=Math.asin(S(i*r,-1,1)),s=S(x(a),-85.051129,Ss);return new _s(o,s)}}class Bf extends Pf{constructor(e){super(e),this.requiresDraping=!0,this.supportsWorldCopies=!1,this.supportsFog=!0,this.zAxisUnit="pixels",this.unsupportedLayers=["debug","custom"],this.range=[3,5]}projectTilePoint(e,t,n){const r=rf(e,t,n);return zl(r,r,sf(Hd(n))),{x:r[0],y:r[1],z:r[2]}}locationPoint(e,t){const n=nf(t.lat,t.lng),r=Al([],n),i=e.elevation?e.elevation.getAtPointOrZero(e.locationCoordinate(t),e._centerAltitude):e._centerAltitude;Ml(n,n,r,bs(1,0)*fs*i);const o=ll(new Float64Array(16));return cl(o,e.pixelMatrix,e.globeMatrix),zl(n,n,o),new m(n[0],n[1])}pixelsPerMeter(e,t){return bs(1,0)*t}pixelSpaceConversion(e,t,n){const r=bs(1,e)*t,i=Mn(bs(1,45)*t,r,n);return this.pixelsPerMeter(e,t)/i}createTileMatrix(e,t,n){const r=lf(Hd(n.canonical));return cl(new Float64Array(16),e.globeMatrix,r)}createInversionMatrix(e,t){const{center:n}=e,r=sf(Hd(t));return pl(r,r,v(n.lng)),fl(r,r,v(n.lat)),dl(r,r,[e._pixelsPerMercatorPixel,e._pixelsPerMercatorPixel,1]),Float32Array.from(r)}pointCoordinate(e,t,n,r){return Zd(e,t,n,!0)||new Cs(0,0)}pointCoordinate3D(e,t,n){const r=this.pointCoordinate(e,t,n,0);return[r.x,r.y,r.z]}isPointAboveHorizon(e,t){return!Zd(e,t.x,t.y,!1)}farthestPixelDistance(e){const t=function(e,t){const n=e.cameraToCenterDistance,r=e._centerAltitude*t,i=e._camera,o=e._camera.forward(),a=wl([],Cl([],o,-n),[0,0,r]),s=e.worldSize/(2*Math.PI),l=[0,0,-s],u=e.width/e.height,c=Math.tan(e.fovAboveCenter),h=Cl([],i.up(),c),d=Cl([],i.right(),c*u),f=Al([],wl([],wl([],o,h),d)),p=[];let m;if(new Zl(a,f).closestPointOnSphere(l,s,p)){const t=wl([],p,l),n=Ll([],t,a);m=Math.cos(e.fovAboveCenter)*xl(n)}else{const e=Ll([],a,l),t=Ll([],l,a);Al(t,t);const n=xl(e)-s;m=Math.sqrt(n*(n+2*s));const r=Math.acos(m/(s+n))-Math.acos(Il(o,t));m*=Math.cos(r)}return 1.01*m}(e,this.pixelsPerMeter(e.center.lat,e.worldSize)),n=cf(e.zoom);if(n>0){const r=_f(e,bs(1,e.center.lat)*e.worldSize),i=e.worldSize/(2*Math.PI),o=Math.max(e.width,e.height)/e.worldSize*Math.PI;return Mn(t,r+i*(1-Math.cos(o)),Math.pow(n,10))}return t}upVector(e,t,n){return rf(t,n,e,1)}upVectorScale(e){return{metersToTile:Ud*of(Hd(e))}}}function Ff(e){const t=e.parallels,n=!!t&&Math.abs(t[0]+t[1])<.01;switch(e.name){case"mercator":return new Pf(e);case"equirectangular":return new Cf(e);case"naturalEarth":return new Of(e);case"equalEarth":return new kf(e);case"winkelTripel":return new Lf(e);case"albers":return n?new Rf(e):new xf(e);case"lambertConformalConic":return n?new Rf(e):new If(e);case"globe":return new Bf(e)}throw new Error("Invalid projection name: "+e.name)}const jf=dc.types,Nf=[{name:"a_fade_opacity",components:1,type:"Uint8",offset:0}];function Uf(e,t,n,r,i,o,a,s,l,u,c,h,d){const f=s?Math.min(Id,Math.round(s[0])):0,p=s?Math.min(Id,Math.round(s[1])):0;e.emplaceBack(t,n,Math.round(32*r),Math.round(32*i),o,a,(f<<1)+(l?1:0),p,16*u,16*c,256*h,256*d)}function Vf(e,t,n,r,i,o,a){e.emplaceBack(t,n,r,i,o,a)}function Gf(e,t,n,r,i){e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i),e.emplaceBack(t,n,r,i)}function qf(e){for(const t of e.sections)if(yo(t.text))return!0;return!1}class $f{constructor(e){this.layoutVertexArray=new ia,this.indexArray=new da,this.programConfigurations=e,this.segments=new ds,this.dynamicLayoutVertexArray=new ea,this.opacityVertexArray=new aa,this.placedSymbolArray=new Ta,this.globeExtVertexArray=new oa}isEmpty(){return 0===this.layoutVertexArray.length&&0===this.indexArray.length&&0===this.dynamicLayoutVertexArray.length&&0===this.opacityVertexArray.length}upload(e,t,n,r){this.isEmpty()||(n&&(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Yc.members),this.indexBuffer=e.createIndexBuffer(this.indexArray,t),this.dynamicLayoutVertexBuffer=e.createVertexBuffer(this.dynamicLayoutVertexArray,Jc.members,!0),this.opacityVertexBuffer=e.createVertexBuffer(this.opacityVertexArray,Nf,!0),this.globeExtVertexArray.length>0&&(this.globeExtVertexBuffer=e.createVertexBuffer(this.globeExtVertexArray,Kc.members,!0)),this.opacityVertexBuffer.itemSize=1),(n||r)&&this.programConfigurations.upload(e))}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.programConfigurations.destroy(),this.segments.destroy(),this.dynamicLayoutVertexBuffer.destroy(),this.opacityVertexBuffer.destroy(),this.globeExtVertexBuffer&&this.globeExtVertexBuffer.destroy())}}zi($f,"SymbolBuffers");class Zf{constructor(e,t,n){this.layoutVertexArray=new e,this.layoutAttributes=t,this.indexArray=new n,this.segments=new ds,this.collisionVertexArray=new ca,this.collisionVertexArrayExt=new ha}upload(e){this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,this.layoutAttributes),this.indexBuffer=e.createIndexBuffer(this.indexArray),this.collisionVertexBuffer=e.createVertexBuffer(this.collisionVertexArray,Qc.members,!0),this.collisionVertexBufferExt=e.createVertexBuffer(this.collisionVertexArrayExt,eh.members,!0)}destroy(){this.layoutVertexBuffer&&(this.layoutVertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.collisionVertexBuffer.destroy(),this.collisionVertexBufferExt.destroy())}}zi(Zf,"CollisionBuffers");class Wf{constructor(e){this.collisionBoxArray=e.collisionBoxArray,this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(e=>e.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.fullyClipped=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=ll([]),this.placementViewportMatrix=ll([]);const t=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ih(this.zoom,t["text-size"]),this.iconSizeData=ih(this.zoom,t["icon-size"]);const n=this.layers[0].layout,r=n.get("symbol-sort-key"),i=n.get("symbol-z-order");this.canOverlap=n.get("text-allow-overlap")||n.get("icon-allow-overlap")||n.get("text-ignore-placement")||n.get("icon-ignore-placement"),this.sortFeaturesByKey="viewport-y"!==i&&void 0!==r.constantOr(1),this.sortFeaturesByY=("viewport-y"===i||"auto"===i&&!this.sortFeaturesByKey)&&this.canOverlap,this.writingModes=n.get("text-writing-mode").map(e=>Nh[e]),this.stateDependentLayerIds=this.layers.filter(e=>e.isStateDependent()).map(e=>e.id),this.sourceID=e.sourceID,this.projection=e.projection}createArrays(){this.text=new $f(new ns(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new $f(new ns(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new Ca,this.lineVertexArray=new Ma,this.symbolInstances=new ka}calculateGlyphDependencies(e,t,n,r,i){for(let n=0;n0)&&("constant"!==s.value.kind||s.value.value.length>0),h="constant"!==u.value.kind||!!u.value.value||Object.keys(u.parameters).length>0,d=o.get("symbol-sort-key");if(this.features=[],!c&&!h)return;const f=t.iconDependencies,p=t.glyphDependencies,m=t.availableImages,_=new Po(this.zoom);for(const{feature:t,id:l,index:u,sourceLayerIndex:g}of e){const e=i._featureFilter.needGeometry,y=Rs(t,e);if(!i._featureFilter.filter(_,y,n))continue;if(e||(y.geometry=Ls(t,n,r)),a&&1!==t.type&&n.z<=5){const e=y.geometry,t=.98078528056,r=(e,r)=>Il(rf(e.x,e.y,n,1),rf(r.x,r.y,n,1))=0;for(const n of v.sections)if(n.image)f[n.image.name]=!0;else{const r=co(v.toString()),i=n.fontStack||e,o=p[i]=p[i]||{};this.calculateGlyphDependencies(n.text,o,t,this.allowVerticalPlacement,r)}}}"line"===o.get("symbol-placement")&&(this.features=function(e){const t={},n={},r=[];let i=0;function o(t){r.push(e[t]),i++}function a(e,t,i){const o=n[e];return delete n[e],n[t]=o,r[o].geometry[0].pop(),r[o].geometry[0]=r[o].geometry[0].concat(i[0]),o}function s(e,n,i){const o=t[n];return delete t[n],t[e]=o,r[o].geometry[0].shift(),r[o].geometry[0]=i[0].concat(r[o].geometry[0]),o}function l(e,t,n){const r=n?t[0][t[0].length-1]:t[0][0];return`${e}:${r.x}:${r.y}`}for(let u=0;ue.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((e,t)=>e.sortKey-t.sortKey)}update(e,t,n,r){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,t,this.layers,n,r),this.icon.programConfigurations.updatePaintArrays(e,t,this.layers,n,r))}isEmpty(){return 0===this.symbolInstances.length&&!this.hasRTLText}uploadPending(){return!this.uploaded||this.text.programConfigurations.needsUpload||this.icon.programConfigurations.needsUpload}upload(e){!this.uploaded&&this.hasDebugData()&&(this.textCollisionBox.upload(e),this.iconCollisionBox.upload(e)),this.text.upload(e,this.sortFeaturesByY,!this.uploaded,this.text.programConfigurations.needsUpload),this.icon.upload(e,this.sortFeaturesByY,!this.uploaded,this.icon.programConfigurations.needsUpload),this.uploaded=!0}destroyDebugData(){this.textCollisionBox.destroy(),this.iconCollisionBox.destroy()}getProjection(){return this.projectionInstance||(this.projectionInstance=Ff(this.projection)),this.projectionInstance}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,t){const n=this.lineVertexArray.length;if(void 0!==e.segment)for(const{x:e,y:n}of t)this.lineVertexArray.emplaceBack(e,n);return{lineStartIndex:n,lineLength:this.lineVertexArray.length-n}}addSymbols(e,t,n,r,i,o,a,s,l,u,c,h,d,f){const p=e.indexArray,m=e.layoutVertexArray,_=e.globeExtVertexArray,g=e.segments.prepareSegment(4*t.length,m,p,this.canOverlap?o.sortKey:void 0),y=this.glyphOffsetArray.length,v=g.vertexLength,x=this.allowVerticalPlacement&&a===Nh.vertical?Math.PI/2:0,b=o.text&&o.text.sections;for(let r=0;r=0?t.rightJustifiedTextSymbolIndex:t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.leftJustifiedTextSymbolIndex>=0?t.leftJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex>=0?t.verticalPlacedTextSymbolIndex:r),o=oh(this.textSizeData,e,i)/24;return this.tilePixelRatio*o}getSymbolInstanceIconSize(e,t,n){const r=this.icon.placedSymbolArray.get(n),i=oh(this.iconSizeData,e,r);return this.tilePixelRatio*i}_commitDebugCollisionVertexUpdate(e,t,n){e.emplaceBack(t,-n,-n),e.emplaceBack(t,n,-n),e.emplaceBack(t,n,n),e.emplaceBack(t,-n,n)}_updateTextDebugCollisionBoxes(e,t,n,r,i,o){for(let a=r;a0}hasIconData(){return this.icon.segments.get().length>0}hasDebugData(){return this.textCollisionBox&&this.iconCollisionBox}hasTextCollisionBoxData(){return this.hasDebugData()&&this.textCollisionBox.segments.get().length>0}hasIconCollisionBoxData(){return this.hasDebugData()&&this.iconCollisionBox.segments.get().length>0}addIndicesForPlacedSymbol(e,t){const n=e.placedSymbolArray.get(t),r=n.vertexStartIndex+4*n.numGlyphs;for(let t=n.vertexStartIndex;tr[e]-r[t]||i[t]-i[e]),o}addToSortKeyRanges(e,t){const n=this.sortKeyRanges[this.sortKeyRanges.length-1];n&&n.sortKey===t?n.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:t,symbolInstanceStart:e,symbolInstanceEnd:e+1})}sortFeatures(e){if(this.sortFeaturesByY&&this.sortedAngle!==e&&!(this.text.segments.get().length>1||this.icon.segments.get().length>1)){this.symbolInstanceIndexes=this.getSortedSymbolIndexes(e),this.sortedAngle=e,this.text.indexArray.clear(),this.icon.indexArray.clear(),this.featureSortOrder=[];for(const e of this.symbolInstanceIndexes){const t=this.symbolInstances.get(e);this.featureSortOrder.push(t.featureIndex);const{rightJustifiedTextSymbolIndex:n,centerJustifiedTextSymbolIndex:r,leftJustifiedTextSymbolIndex:i,verticalPlacedTextSymbolIndex:o,placedIconSymbolIndex:a,verticalPlacedIconSymbolIndex:s}=t;n>=0&&this.addIndicesForPlacedSymbol(this.text,n),r>=0&&r!==n&&this.addIndicesForPlacedSymbol(this.text,r),i>=0&&i!==r&&i!==n&&this.addIndicesForPlacedSymbol(this.text,i),o>=0&&this.addIndicesForPlacedSymbol(this.text,o),a>=0&&this.addIndicesForPlacedSymbol(this.icon,a),s>=0&&this.addIndicesForPlacedSymbol(this.icon,s)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}zi(Wf,"SymbolBucket",{omit:["layers","collisionBoxArray","features","compareText"]}),Wf.MAX_GLYPHS=65535,Wf.addDynamicAttributes=Gf;const Xf=new Go({"symbol-placement":new No(Ke.layout_symbol["symbol-placement"]),"symbol-spacing":new No(Ke.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new No(Ke.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new Uo(Ke.layout_symbol["symbol-sort-key"]),"symbol-z-order":new No(Ke.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new No(Ke.layout_symbol["icon-allow-overlap"]),"icon-ignore-placement":new No(Ke.layout_symbol["icon-ignore-placement"]),"icon-optional":new No(Ke.layout_symbol["icon-optional"]),"icon-rotation-alignment":new No(Ke.layout_symbol["icon-rotation-alignment"]),"icon-size":new Uo(Ke.layout_symbol["icon-size"]),"icon-text-fit":new No(Ke.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new No(Ke.layout_symbol["icon-text-fit-padding"]),"icon-image":new Uo(Ke.layout_symbol["icon-image"]),"icon-rotate":new Uo(Ke.layout_symbol["icon-rotate"]),"icon-padding":new No(Ke.layout_symbol["icon-padding"]),"icon-keep-upright":new No(Ke.layout_symbol["icon-keep-upright"]),"icon-offset":new Uo(Ke.layout_symbol["icon-offset"]),"icon-anchor":new Uo(Ke.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new No(Ke.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new No(Ke.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new No(Ke.layout_symbol["text-rotation-alignment"]),"text-field":new Uo(Ke.layout_symbol["text-field"]),"text-font":new Uo(Ke.layout_symbol["text-font"]),"text-size":new Uo(Ke.layout_symbol["text-size"]),"text-max-width":new Uo(Ke.layout_symbol["text-max-width"]),"text-line-height":new Uo(Ke.layout_symbol["text-line-height"]),"text-letter-spacing":new Uo(Ke.layout_symbol["text-letter-spacing"]),"text-justify":new Uo(Ke.layout_symbol["text-justify"]),"text-radial-offset":new Uo(Ke.layout_symbol["text-radial-offset"]),"text-variable-anchor":new No(Ke.layout_symbol["text-variable-anchor"]),"text-anchor":new Uo(Ke.layout_symbol["text-anchor"]),"text-max-angle":new No(Ke.layout_symbol["text-max-angle"]),"text-writing-mode":new No(Ke.layout_symbol["text-writing-mode"]),"text-rotate":new Uo(Ke.layout_symbol["text-rotate"]),"text-padding":new No(Ke.layout_symbol["text-padding"]),"text-keep-upright":new No(Ke.layout_symbol["text-keep-upright"]),"text-transform":new Uo(Ke.layout_symbol["text-transform"]),"text-offset":new Uo(Ke.layout_symbol["text-offset"]),"text-allow-overlap":new No(Ke.layout_symbol["text-allow-overlap"]),"text-ignore-placement":new No(Ke.layout_symbol["text-ignore-placement"]),"text-optional":new No(Ke.layout_symbol["text-optional"])});var Hf={paint:new Go({"icon-opacity":new Uo(Ke.paint_symbol["icon-opacity"]),"icon-color":new Uo(Ke.paint_symbol["icon-color"]),"icon-halo-color":new Uo(Ke.paint_symbol["icon-halo-color"]),"icon-halo-width":new Uo(Ke.paint_symbol["icon-halo-width"]),"icon-halo-blur":new Uo(Ke.paint_symbol["icon-halo-blur"]),"icon-translate":new No(Ke.paint_symbol["icon-translate"]),"icon-translate-anchor":new No(Ke.paint_symbol["icon-translate-anchor"]),"text-opacity":new Uo(Ke.paint_symbol["text-opacity"]),"text-color":new Uo(Ke.paint_symbol["text-color"],{runtimeType:ut,getOverride:e=>e.textColor,hasOverride:e=>!!e.textColor}),"text-halo-color":new Uo(Ke.paint_symbol["text-halo-color"]),"text-halo-width":new Uo(Ke.paint_symbol["text-halo-width"]),"text-halo-blur":new Uo(Ke.paint_symbol["text-halo-blur"]),"text-translate":new No(Ke.paint_symbol["text-translate"]),"text-translate-anchor":new No(Ke.paint_symbol["text-translate-anchor"])}),layout:Xf};class Yf{constructor(e){this.type=e.property.overrides?e.property.overrides.runtimeType:ot,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}}zi(Yf,"FormatSectionOverride",{omit:["defaultValue"]});class Kf extends us{constructor(e){super(e,Hf)}recalculate(e,t){super.recalculate(e,t),"auto"===this.layout.get("icon-rotation-alignment")&&(this.layout._values["icon-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-rotation-alignment")&&(this.layout._values["text-rotation-alignment"]="point"!==this.layout.get("symbol-placement")?"map":"viewport"),"auto"===this.layout.get("text-pitch-alignment")&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")),"auto"===this.layout.get("icon-pitch-alignment")&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment"));const n=this.layout.get("text-writing-mode");if(n){const e=[];for(const t of n)e.indexOf(t)<0&&e.push(t);this.layout._values["text-writing-mode"]=e}else this.layout._values["text-writing-mode"]="point"===this.layout.get("symbol-placement")?["horizontal"]:["horizontal","vertical"];this._setPaintOverrides()}getValueAndResolveTokens(e,t,n,r){const i=this.layout.get(e).evaluate(t,{},n,r),o=this._unevaluatedLayout._values[e];return o.isDataDriven()||jr(o.value)||!i?i:function(e,t){return t.replace(/{([^{}]+)}/g,(t,n)=>n in e?String(e[n]):"")}(t.properties,i)}createBucket(e){return new Wf(e)}queryRadius(){return 0}queryIntersectsFeature(){return!1}_setPaintOverrides(){for(const e of Hf.paint.overridableProperties){if(!Kf.hasPaintOverride(this.layout,e))continue;const t=this.paint.get(e),n=new Yf(t),r=new Fr(n,t.property.specification);let i=null;i="constant"===t.value.kind||"source"===t.value.kind?new Ur("source",r):new Vr("composite",r,t.value.zoomStops,t.value._interpolationType),this.paint._values[e]=new Fo(t.property,i,t.parameters)}}_handleOverridablePaintPropertyUpdate(e,t,n){return!(!this.layout||t.isDataDriven()||n.isDataDriven())&&Kf.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,t){const n=e.get("text-field"),r=Hf.paint.properties[t];let i=!1;const o=e=>{for(const t of e)if(r.overrides&&r.overrides.hasOverride(t))return void(i=!0)};if("constant"===n.value.kind&&n.value.value instanceof Pt)o(n.value.value.sections);else if("source"===n.value.kind){const e=t=>{i||(t instanceof Ft&&Lt(t.value)===ft?o(t.value.sections):t instanceof Gt?o(t.sections):t.eachChild(e))},t=n.value;t._styleExpression&&e(t._styleExpression.expression)}return i}getProgramConfiguration(e){return new ts(this,e)}}var Jf={paint:new Go({"background-color":new No(Ke.paint_background["background-color"]),"background-pattern":new No(Ke.paint_background["background-pattern"]),"background-opacity":new No(Ke.paint_background["background-opacity"])})},Qf={paint:new Go({"raster-opacity":new No(Ke.paint_raster["raster-opacity"]),"raster-hue-rotate":new No(Ke.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new No(Ke.paint_raster["raster-brightness-min"]),"raster-brightness-max":new No(Ke.paint_raster["raster-brightness-max"]),"raster-saturation":new No(Ke.paint_raster["raster-saturation"]),"raster-contrast":new No(Ke.paint_raster["raster-contrast"]),"raster-resampling":new No(Ke.paint_raster["raster-resampling"]),"raster-fade-duration":new No(Ke.paint_raster["raster-fade-duration"])})};class ep extends us{constructor(e){super(e,{}),this.implementation=e}is3D(){return"3d"===this.implementation.renderingMode}hasOffscreenPass(){return void 0!==this.implementation.prerender}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){}onAdd(e){this.implementation.onAdd&&this.implementation.onAdd(e,e.painter.context.gl)}onRemove(e){this.implementation.onRemove&&this.implementation.onRemove(e,e.painter.context.gl)}}var tp={paint:new Go({"sky-type":new No(Ke.paint_sky["sky-type"]),"sky-atmosphere-sun":new No(Ke.paint_sky["sky-atmosphere-sun"]),"sky-atmosphere-sun-intensity":new No(Ke.paint_sky["sky-atmosphere-sun-intensity"]),"sky-gradient-center":new No(Ke.paint_sky["sky-gradient-center"]),"sky-gradient-radius":new No(Ke.paint_sky["sky-gradient-radius"]),"sky-gradient":new Vo(Ke.paint_sky["sky-gradient"]),"sky-atmosphere-halo-color":new No(Ke.paint_sky["sky-atmosphere-halo-color"]),"sky-atmosphere-color":new No(Ke.paint_sky["sky-atmosphere-color"]),"sky-opacity":new No(Ke.paint_sky["sky-opacity"])})};function np(e,t,n){const r=[0,0,1],i=Vl([]);return ql(i,i,n?-v(e)+Math.PI:v(e)),Gl(i,i,-v(t)),Ol(r,r,i),Al(r,r)}const rp={circle:class extends us{constructor(e){super(e,rl)}createBucket(e){return new js(e)}queryRadius(e){const t=e;return Js("circle-radius",this,t)+Js("circle-stroke-width",this,t)+Qs(this.paint.get("circle-translate"))}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=tl(this.paint.get("circle-translate"),this.paint.get("circle-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),u=this.paint.get("circle-radius").evaluate(t,n)+this.paint.get("circle-stroke-width").evaluate(t,n);return Yl(e,r,o,a,s,"map"===this.paint.get("circle-pitch-alignment"),"map"===this.paint.get("circle-pitch-scale"),l,u)}getProgramIds(){return["circle"]}getProgramConfiguration(e){return new ts(this,e)}},heatmap:class extends us{createBucket(e){return new tu(e)}constructor(e){super(e,su),this._updateColorRamp()}_handleSpecialPaintPropertyUpdate(e){"heatmap-color"===e&&this._updateColorRamp()}_updateColorRamp(){this.colorRamp=lu({expression:this._transitionablePaint._values["heatmap-color"].value.expression,evaluationKey:"heatmapDensity",image:this.colorRamp}),this.colorRampTexture=null}resize(){this.heatmapFbo&&(this.heatmapFbo.destroy(),this.heatmapFbo=null)}queryRadius(e){return Js("heatmap-radius",this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s){const l=this.paint.get("heatmap-radius").evaluate(t,n);return Yl(e,r,o,a,s,!0,!0,new m(0,0),l)}hasOffscreenPass(){return 0!==this.paint.get("heatmap-opacity")&&"none"!==this.visibility}getProgramIds(){return["heatmap","heatmapTexture"]}getProgramConfiguration(e){return new ts(this,e)}},hillshade:class extends us{constructor(e){super(e,uu)}hasOffscreenPass(){return 0!==this.paint.get("hillshade-exaggeration")&&"none"!==this.visibility}getProgramIds(){return["hillshade","hillshadePrepare"]}},fill:class extends us{constructor(e){super(e,Xu)}getProgramIds(){const e=this.paint.get("fill-pattern"),t=e&&e.constantOr(1),n=[t?"fillPattern":"fill"];return this.paint.get("fill-antialias")&&n.push(t&&!this.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline"),n}getProgramConfiguration(e){return new ts(this,e)}recalculate(e,t){super.recalculate(e,t);const n=this.paint._values["fill-outline-color"];"constant"===n.value.kind&&void 0===n.value.value&&(this.paint._values["fill-outline-color"]=this.paint._values["fill-color"])}createBucket(e){return new Zu(e)}queryRadius(){return Qs(this.paint.get("fill-translate"))}queryIntersectsFeature(e,t,n,r,i,o){return!e.queryGeometry.isAboveHorizon&&Vs(el(e.tilespaceGeometry,this.paint.get("fill-translate"),this.paint.get("fill-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),r)}isTileClipped(){return!0}},"fill-extrusion":class extends us{constructor(e){super(e,Ac)}createBucket(e){return new vc(e)}queryRadius(){return Qs(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}getProgramIds(){return[this.paint.get("fill-extrusion-pattern").constantOr(1)?"fillExtrusionPattern":"fillExtrusion"]}getProgramConfiguration(e){return new ts(this,e)}queryIntersectsFeature(e,t,n,r,i,o,a,s,l){const u=tl(this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),o.angle,e.pixelToTileUnitsFactor),c=this.paint.get("fill-extrusion-height").evaluate(t,n),h=this.paint.get("fill-extrusion-base").evaluate(t,n),d=[0,0],f=s&&o.elevation,p=o.elevation?o.elevation.exaggeration():1,_=e.tile.getBucket(this);if(f&&_ instanceof vc){const e=_.centroidVertexArray,t=l+1;te.polygon).flat());const g=f?s:null,[y,v]=function(e,t,n,r,i,o,a,s,l,u,c){return"globe"===e.projection.name?function(e,t,n,r,i,o,a,s,l,u,c){const h=[],d=[],f=e.projection.upVectorScale(c,e.center.lat,e.worldSize).metersToTile,p=[0,0,0,1],m=[0,0,0,1],_=(e,t,n,r)=>{e[0]=t,e[1]=n,e[2]=r,e[3]=1},g=kc();n>0&&(n+=g),r+=g;for(const g of t){const t=[],y=[];for(const h of g){const d=h.x+i.x,g=h.y+i.y,v=e.projection.projectTilePoint(d,g,c),x=e.projection.upVector(c,h.x,h.y);let b=n,w=r;if(a){const e=Fc(d,g,n,r,a,s,l,u);b+=e.base,w+=e.top}0!==n?_(p,v.x+x[0]*f*b,v.y+x[1]*f*b,v.z+x[2]*f*b):_(p,v.x,v.y,v.z),_(m,v.x+x[0]*f*w,v.y+x[1]*f*w,v.z+x[2]*f*w),zl(p,p,o),zl(m,m,o),t.push(new Lc(p[0],p[1],p[2])),y.push(new Lc(m[0],m[1],m[2]))}h.push(t),d.push(y)}return[h,d]}(e,t,n,r,i,o,a,s,l,u,c):a?function(e,t,n,r,i,o,a,s,l){const u=[],c=[],h=[0,0,0,1];for(const d of e){const e=[],f=[];for(const u of d){const c=u.x+r.x,d=u.y+r.y,p=Fc(c,d,t,n,o,a,s,l);h[0]=c,h[1]=d,h[2]=p.base,h[3]=1,Nl(h,h,i),h[3]=Math.max(h[3],1e-5);const m=new Lc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);h[0]=c,h[1]=d,h[2]=p.top,h[3]=1,Nl(h,h,i),h[3]=Math.max(h[3],1e-5);const _=new Lc(h[0]/h[3],h[1]/h[3],h[2]/h[3]);e.push(m),f.push(_)}u.push(e),c.push(f)}return[u,c]}(t,n,r,i,o,a,s,l,u):function(e,t,n,r,i){const o=[],a=[],s=i[8]*t,l=i[9]*t,u=i[10]*t,c=i[11]*t,h=i[8]*n,d=i[9]*n,f=i[10]*n,p=i[11]*n;for(const t of e){const e=[],n=[];for(const o of t){const t=o.x+r.x,a=o.y+r.y,m=i[0]*t+i[4]*a+i[12],_=i[1]*t+i[5]*a+i[13],g=i[2]*t+i[6]*a+i[14],y=i[3]*t+i[7]*a+i[15],v=m+s,x=_+l,b=g+u,w=Math.max(y+c,1e-5),E=m+h,T=_+d,S=g+f,k=Math.max(y+p,1e-5);e.push(new Lc(v/w,x/w,b/w)),n.push(new Lc(E/k,T/k,S/k))}o.push(e),a.push(n)}return[o,a]}(t,n,r,i,o)}(o,r,h,c,u,a,g,d,p,o.center.lat,e.tileID.canonical),x=e.queryGeometry;return function(e,t,n){let r=1/0;Vs(n,t)&&(r=Bc(n,t[0]));for(let i=0;i=3)for(let t=0;t{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 ap{constructor(){this.tasks={},this.taskQueue=[],R(["process"],this),this.invoker=new op(this.process),this.nextId=0}add(e,t){const n=this.nextId++,r=function({type:e,isSymbolTile:t,zoom:n}){return n=n||0,"message"===e?0:"maybePrepare"!==e||t?"parseTile"!==e||t?"parseTile"===e&&t?300-n:"maybePrepare"===e&&t?400-n:500:200-n:100-n}(t);if(0===r){$();try{e()}finally{}return{cancel:()=>{}}}return this.tasks[n]={fn:e,metadata:t,priority:r,id:n},this.taskQueue.push(n),this.invoker.trigger(),{cancel:()=>{delete this.tasks[n]}}}process(){$();try{if(this.taskQueue=this.taskQueue.filter(e=>!!this.tasks[e]),!this.taskQueue.length)return;const e=this.pick();if(null===e)return;const t=this.tasks[e];if(delete this.tasks[e],this.taskQueue.length&&this.invoker.trigger(),!t)return;t.fn()}finally{}}pick(){let e=null,t=1/0;for(let n=0;n>=1)>1;){const e=n+i>>1,l=r+o>>1;1&t?(i=n,o=r,n=a,r=s):(n=i,r=o,i=a,o=s),a=e,s=l}const l=4*e;cp[l+0]=n,cp[l+1]=r,cp[l+2]=i,cp[l+3]=o}const hp=new Uint16Array(2178),dp=new Uint8Array(1089),fp=new Uint16Array(1089);function pp(e){return 0===e?-.03125:32===e?.03125:0}var mp=Xo([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);const _p={type:2,extent:fs,loadGeometry:()=>[[new m(0,0),new m(8193,0),new m(8193,8193),new m(0,8193),new m(0,0)]]};class gp{constructor(e,t,n,r,i){this.tileID=e,this.uid=z(),this.uses=0,this.tileSize=t,this.tileZoom=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.isRaster=i,this.expiredRequestCount=0,this.state="loading",r&&r.transform&&(this.projection=r.transform.projection)}registerFadeDuration(e){const t=e+this.timeAdded;t<$e.now()||this.fadeEndTime&&tt.getLayer(e)).filter(Boolean);if(0!==e.length){r.layers=e,r.stateDependentLayerIds&&(r.stateDependentLayers=r.stateDependentLayerIds.map(t=>e.filter(e=>e.id===t)[0]));for(const t of e)n[t.id]=r}}return n}(e.buckets,t.style),this.hasSymbolBuckets=!1;for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Wf){if(this.hasSymbolBuckets=!0,!n)break;t.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const e in this.buckets){const t=this.buckets[e];if(t instanceof Wf&&t.hasRTLText){this.hasRTLText=!0,Io.isLoading()||Io.isLoaded()||"deferred"!==Mo()||Ao();break}}this.queryPadding=0;for(const e in this.buckets){const n=this.buckets[e];this.queryPadding=Math.max(this.queryPadding,t.style.getLayer(e).queryRadius(n))}e.imageAtlas&&(this.imageAtlas=e.imageAtlas),e.glyphAtlasImage&&(this.glyphAtlasImage=e.glyphAtlasImage),e.lineAtlas&&(this.lineAtlas=e.lineAtlas)}else this.collisionBoxArray=new wa}unloadVectorData(){if(this.hasData()){for(const e in this.buckets)this.buckets[e].destroy();this.buckets={},this.imageAtlas&&(this.imageAtlas=null),this.lineAtlas&&(this.lineAtlas=null),this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.lineAtlasTexture&&this.lineAtlasTexture.destroy(),this._tileBoundsBuffer&&(this._tileBoundsBuffer.destroy(),this._tileBoundsIndexBuffer.destroy(),this._tileBoundsSegments.destroy(),this._tileBoundsBuffer=null),this._tileDebugBuffer&&(this._tileDebugBuffer.destroy(),this._tileDebugSegments.destroy(),this._tileDebugBuffer=null),this._tileDebugIndexBuffer&&(this._tileDebugIndexBuffer.destroy(),this._tileDebugIndexBuffer=null),this._globeTileDebugBorderBuffer&&(this._globeTileDebugBorderBuffer.destroy(),this._globeTileDebugBorderBuffer=null),this._tileDebugTextBuffer&&(this._tileDebugTextBuffer.destroy(),this._tileDebugTextSegments.destroy(),this._tileDebugTextIndexBuffer.destroy(),this._tileDebugTextBuffer=null),this._globeTileDebugTextBuffer&&(this._globeTileDebugTextBuffer.destroy(),this._globeTileDebugTextBuffer=null),this.latestFeatureIndex=null,this.state="unloaded"}}getBucket(e){return this.buckets[e.id]}upload(e){for(const t in this.buckets){const n=this.buckets[t];n.uploadPending()&&n.upload(e)}const t=e.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new ip(e,this.imageAtlas.image,t.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new ip(e,this.glyphAtlasImage,t.ALPHA),this.glyphAtlasImage=null),this.lineAtlas&&!this.lineAtlas.uploaded&&(this.lineAtlasTexture=new ip(e,this.lineAtlas.image,t.ALPHA),this.lineAtlas.uploaded=!0)}prepare(e){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(e,this.imageAtlasTexture)}queryRenderedFeatures(e,t,n,r,i,o,a,s){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({tileResult:r,pixelPosMatrix:a,transform:o,params:i,tileTransform:this.tileTransform},e,t,n):{}}querySourceFeatures(e,t){const n=this.latestFeatureIndex;if(!n||!n.rawTileData)return;const r=n.loadVTLayers(),i=t?t.sourceLayer:"",o=r._geojsonTileLayer||r[i];if(!o)return;const a=Qr(t&&t.filter),{z:s,x:l,y:u}=this.tileID.canonical,c={z:s,x:l,y:u};for(let t=0;te)n=!1;else if(t)if(this.expirationTime=0;e--){const t=4*e,n=cp[t+0],r=cp[t+1],i=cp[t+2],o=cp[t+3],a=n+i>>1,s=r+o>>1,l=a+s-r,u=s+n-a,c=33*r+n,h=33*o+i,d=33*s+a,f=Math.hypot((hp[2*c+0]+hp[2*h+0])/2-hp[2*d+0],(hp[2*c+1]+hp[2*h+1])/2-hp[2*d+1])>=16;if(dp[d]=dp[d]||(f?1:0),e<1022){const e=33*(r+u>>1)+(n+l>>1),t=33*(o+u>>1)+(i+l>>1);dp[d]=dp[d]||dp[e]||dp[t]}}const i=new Jo,o=new da;let a=0;function s(e,t){const n=33*t+e;return 0===fp[n]&&(i.emplaceBack(hp[2*n+0],hp[2*n+1],e*fs/32,t*fs/32),fp[n]=++a),fp[n]-1}function l(e,t,n,r,i,a){const u=e+n>>1,c=t+r>>1;if(Math.abs(e-i)+Math.abs(t-a)>1&&dp[33*c+u])l(i,a,e,t,u,c),l(n,r,i,a,u,c);else{const l=s(e,t),u=s(n,r),c=s(i,a);o.emplaceBack(l,u,c)}}return l(0,0,32,32,32,0),l(32,32,0,0,0,32),{vertices:i,indices:o}}(this.tileID.canonical,t);r=e.vertices,i=e.indices}else{r=new Jo,i=new da;for(const{x:e,y:t}of n)r.emplaceBack(e,t,0,0);const e=du.exports(r.int16,void 0,4);for(let t=0;t0&&(a=ul(new Float64Array(16),t.globeMatrix)),this._makeGlobeTileDebugBorderBuffer(e,r,t,i,a,o),this._makeGlobeTileDebugTextBuffer(e,r,t,i,a,o)}_globePoint(e,t,n,r,i,o,a){let s=rf(e,t,n);if(o){const i=1<.5?h=-1:c<-.5&&(h=1);let d=(e/fs+n.x)/i+h,f=(t/fs+n.y)/i;d=(d-l)*r._pixelsPerMercatorPixel+l,f=(f-u)*r._pixelsPerMercatorPixel+u;const p=[d*r.worldSize,f*r.worldSize,0];zl(p,p,o),s=Yd(s,p,a)}return zl(s,s,i)}_makeGlobeTileDebugBorderBuffer(e,t,n,r,i,o){const a=new Yo,s=new va,l=new Ko,u=(e,u,c,h,d)=>{const f=(c-e)/(d-1),p=(h-u)/(d-1),m=a.length;for(let c=0;cu*e+t;for(let e=0;et[a])return null}else{const s=1/r[a];let l=(e[a]-n[a])*s,u=(t[a]-n[a])*s;if(l>u){const e=l;l=u,u=e}if(l>i&&(i=l),uo)return null}return i}function bp(e,t,n,r,i,o,a,s,l,u,c){const h=r-e,d=i-t,f=o-n,p=a-e,m=s-t,_=l-n,g=c[1]*_-c[2]*m,y=c[2]*p-c[0]*_,v=c[0]*m-c[1]*p,x=h*g+d*y+f*v;if(Math.abs(x)<1e-15)return null;const b=1/x,w=u[0]-e,E=u[1]-t,T=u[2]-n,S=(w*g+E*y+T*v)*b;if(S<0||S>1)return null;const k=E*f-T*d,C=T*h-w*f,M=w*d-E*h,A=(c[0]*k+c[1]*C+c[2]*M)*b;return A<0||S+A>1?null:(p*k+m*C+_*M)*b}function wp(e,t,n){return(e-t)/(n-t)}function Ep(e,t,n,r,i,o,a,s,l){const u=1<{const o=r?1:0,a=(e+1)*n-o,s=t*n,l=(t+1)*n-o;i[0]=e*n,i[1]=s,i[2]=a,i[3]=l};let a=new vp(r);const s=[];for(let t=0;t=1;r/=2){const e=n[n.length-1];a=new vp(r);for(let t=0;t0;){const{idx:s,t:f,nodex:p,nodey:m,depth:_}=d.pop();if(this.leaves[s]){Ep(p,m,_,e,t,n,r,c,h);const s=1<<_,l=(p+0)/s,u=(p+1)/s,d=(m+0)/s,g=(m+1)/s,y=kp(l,d,this.dem)*a,v=kp(u,d,this.dem)*a,x=kp(u,g,this.dem)*a,b=kp(l,g,this.dem)*a,w=bp(c[0],c[1],y,h[0],c[1],v,h[0],h[1],x,i,o),E=bp(h[0],h[1],x,c[0],h[1],b,c[0],c[1],y,i,o),T=Math.min(null!==w?w:Number.MAX_VALUE,null!==E?E:Number.MAX_VALUE);if(T!==Number.MAX_VALUE)return T;{const e=Ml([],i,o,f);if(Sp(y,v,b,x,wp(e[0],c[0],h[0]),wp(e[1],c[1],h[1]))>=e[2])return f}continue}let g=0;for(let d=0;d=l[u[n]]&&(u.splice(n,0,d),t=!0);t||(u[g]=d),g++}}for(let e=0;e=this.dim+1||t<-1||t>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(t+1)*this.stride+(e+1)}_unpackMapbox(e,t,n){return(256*e*256+256*t+n)/10-1e4}_unpackTerrarium(e,t,n){return 256*e+t+n/256-32768}static pack(e,t){const n=[0,0,0,0],r=Mp.getUnpackVector(t);let i=Math.floor((e+r[3])/r[2]);return n[2]=i%256,i=Math.floor(i/256),n[1]=i%256,i=Math.floor(i/256),n[0]=i,n}getPixels(){return new au({width:this.stride,height:this.stride},this.pixels)}backfillBorder(e,t,n){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let r=t*this.dim,i=t*this.dim+this.dim,o=n*this.dim,a=n*this.dim+this.dim;switch(t){case-1:r=i-1;break;case 1:i=r+1}switch(n){case-1:o=a-1;break;case 1:a=o+1}const s=-t*this.dim,l=-n*this.dim;for(let t=o;t{this.remove(e,i)},n)),this.data[r].push(i),this.order.push(r),this.order.length>this.max){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}has(e){return e.wrapped().key in this.data}getAndRemove(e){return this.has(e)?this._getAndRemoveByKey(e.wrapped().key):null}_getAndRemoveByKey(e){const t=this.data[e].shift();return t.timeout&&clearTimeout(t.timeout),0===this.data[e].length&&delete this.data[e],this.order.splice(this.order.indexOf(e),1),t.value}getByKey(e){const t=this.data[e];return t?t[0].value:null}get(e){return this.has(e)?this.data[e.wrapped().key][0].value:null}remove(e,t){if(!this.has(e))return this;const n=e.wrapped().key,r=void 0===t?0:this.data[n].indexOf(t),i=this.data[n][r];return this.data[n].splice(r,1),i.timeout&&clearTimeout(i.timeout),0===this.data[n].length&&delete this.data[n],this.onRemove(i.value),this.order.splice(this.order.indexOf(n),1),this}setMaxSize(e){for(this.max=e;this.order.length>this.max;){const e=this._getAndRemoveByKey(this.order[0]);e&&this.onRemove(e)}return this}filter(e){const t=[];for(const n in this.data)for(const r of this.data[n])e(r.value)||t.push(r);for(const e of t)this.remove(e.value.tileID,e)}}class Ip{constructor(e,t,n){this.func=e,this.mask=t,this.range=n}}Ip.ReadOnly=!1,Ip.ReadWrite=!0,Ip.disabled=new Ip(519,Ip.ReadOnly,[0,1]);class Pp{constructor(e,t,n,r,i,o){this.test=e,this.ref=t,this.mask=n,this.fail=r,this.depthFail=i,this.pass=o}}Pp.disabled=new Pp({func:519,mask:0},0,0,7680,7680,7680);class zp{constructor(e,t,n){this.blendFunction=e,this.blendColor=t,this.mask=n}}zp.Replace=[1,0],zp.disabled=new zp(zp.Replace,Mt.transparent,[!1,!1,!1,!1]),zp.unblended=new zp(zp.Replace,Mt.transparent,[!0,!0,!0,!0]),zp.alphaBlended=new zp([1,771],Mt.transparent,[!0,!0,!0,!0]);class Op{constructor(e,t,n){this.enable=e,this.mode=t,this.frontFace=n}}Op.disabled=new Op(!1,1029,2305),Op.backCCW=new Op(!0,1029,2305),Op.backCW=new Op(!0,1029,2304),Op.frontCW=new Op(!0,1028,2304),Op.frontCCW=new Op(!0,1028,2305);class Dp extends Ye{constructor(e,t,n){super(),this.id=e,this._onlySymbols=n,t.on("data",e=>{"source"===e.dataType&&"metadata"===e.sourceDataType&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&"source"===e.dataType&&"content"===e.sourceDataType&&(this.reload(),this.transform&&this.update(this.transform))}),t.on("error",()=>{this._sourceErrored=!0}),this._source=t,this._tiles={},this._cache=new Ap(0,this._unloadTile.bind(this)),this._timers={},this._cacheTimers={},this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._loadedParentTiles={},this._coveredTiles={},this._state=new yp,this._isRaster="raster"===this._source.type||"raster-dem"===this._source.type||"custom"===this._source.type&&"raster"===this._source._dataType}onAdd(e){this.map=e,this._minTileCacheSize=void 0===this._minTileCacheSize&&e?e._minTileCacheSize:this._minTileCacheSize,this._maxTileCacheSize=void 0===this._maxTileCacheSize&&e?e._maxTileCacheSize:this._maxTileCacheSize}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded)return!1;if(!this._source.loaded())return!1;for(const e in this._tiles){const t=this._tiles[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const e=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,e&&this.reload(),this.transform&&this.update(this.transform)}_loadTile(e,t){return e.isSymbolTile=this._onlySymbols,this._source.loadTile(e,t)}_unloadTile(e){if(this._source.unloadTile)return this._source.unloadTile(e,()=>{})}_abortTile(e){if(this._source.abortTile)return this._source.abortTile(e,()=>{})}serialize(){return this._source.serialize()}prepare(e){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const t in this._tiles){const n=this._tiles[t];n.upload(e),n.prepare(this.map.style.imageManager)}}getIds(){return A(this._tiles).map(e=>e.tileID).sort(Lp).map(e=>e.key)}getRenderableIds(e){const t=[];for(const n in this._tiles)this._isIdRenderable(+n,e)&&t.push(this._tiles[n]);return e?t.sort((e,t)=>{const n=e.tileID,r=t.tileID,i=new m(n.canonical.x,n.canonical.y)._rotate(this.transform.angle),o=new m(r.canonical.x,r.canonical.y)._rotate(this.transform.angle);return n.overscaledZ-r.overscaledZ||o.y-i.y||o.x-i.x}).map(e=>e.tileID.key):t.map(e=>e.tileID).sort(Lp).map(e=>e.key)}hasRenderableParent(e){const t=this.findLoadedParent(e,0);return!!t&&this._isIdRenderable(t.tileID.key)}_isIdRenderable(e,t){return this._tiles[e]&&this._tiles[e].hasData()&&!this._coveredTiles[e]&&(t||!this._tiles[e].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const e in this._tiles)"errored"!==this._tiles[e].state&&this._reloadTile(+e,"reloading")}}_reloadTile(e,t){const n=this._tiles[e];n&&("loading"!==n.state&&(n.state=t),this._loadTile(n,this._tileLoaded.bind(this,n,e,t)))}_tileLoaded(e,t,n,r){if(r)if(e.state="errored",404!==r.status)this._source.fire(new He(r,{tile:e}));else if("raster-dem"===this._source.type&&this.usedForTerrain&&this.map.painter.terrain){const e=this.map.painter.terrain;this.update(this.transform,e.getScaledDemTileSize(),!0),e.resetTileLookupCache(this.id)}else this.update(this.transform);else e.timeAdded=$e.now(),"expired"===n&&(e.refreshedUponExpiration=!0),this._setTileReloadTimer(t,e),"raster-dem"===this._source.type&&e.dem&&this._backfillDEM(e),this._state.initializeTileState(e,this.map?this.map.painter:null),this._source.fire(new Xe("data",{dataType:"source",tile:e,coord:e.tileID,sourceCacheId:this.id}))}_backfillDEM(e){const t=this.getRenderableIds();for(let r=0;r1||(Math.abs(n)>1&&(1===Math.abs(n+i)?n+=i:1===Math.abs(n-i)&&(n-=i)),t.dem&&e.dem&&(e.dem.backfillBorder(t.dem,n,r),e.neighboringTiles&&e.neighboringTiles[o]&&(e.neighboringTiles[o].backfilled=!0)))}}getTile(e){return this.getTileByID(e.key)}getTileByID(e){return this._tiles[e]}_retainLoadedChildren(e,t,n,r){for(const i in this._tiles){let o=this._tiles[i];if(r[i]||!o.hasData()||o.tileID.overscaledZ<=t||o.tileID.overscaledZ>n)continue;let a=o.tileID;for(;o&&o.tileID.overscaledZ>t+1;){const e=o.tileID.scaledTo(o.tileID.overscaledZ-1);o=this._tiles[e.key],o&&o.hasData()&&(a=e)}let s=a;for(;s.overscaledZ>t;)if(s=s.scaledTo(s.overscaledZ-1),e[s.key]){r[a.key]=a;break}}}findLoadedParent(e,t){if(e.key in this._loadedParentTiles){const n=this._loadedParentTiles[e.key];return n&&n.tileID.overscaledZ>=t?n:null}for(let n=e.overscaledZ-1;n>=t;n--){const t=e.scaledTo(n),r=this._getLoadedTile(t);if(r)return r}}_getLoadedTile(e){const t=this._tiles[e.key];return t&&t.hasData()?t:this._cache.getByKey(this._source.reparseOverscaled?e.wrapped().key:e.canonical.key)}updateCacheSize(e,t){t=t||this._source.tileSize;const n=Math.ceil(e.width/t)+1,r=Math.ceil(e.height/t)+1,i=Math.floor(n*r*5),o="number"==typeof this._minTileCacheSize?Math.max(this._minTileCacheSize,i):i,a="number"==typeof this._maxTileCacheSize?Math.min(this._maxTileCacheSize,o):o;this._cache.setMaxSize(a)}handleWrapJump(e){const t=Math.round((e-(void 0===this._prevLng?e:this._prevLng))/360);if(this._prevLng=e,t){const e={};for(const n in this._tiles){const r=this._tiles[n];r.tileID=r.tileID.unwrapTo(r.tileID.wrap+t),e[r.tileID.key]=r}this._tiles=e;for(const e in this._timers)clearTimeout(this._timers[e]),delete this._timers[e];for(const e in this._tiles)this._setTileReloadTimer(+e,this._tiles[e])}}update(e,t,n){if(this.transform=e,!this._sourceLoaded||this._paused||this.transform.freezeTileCoverage)return;if(this.usedForTerrain&&!n)return;let r;this.updateCacheSize(e,t),"globe"!==this.transform.projection.name&&this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?r=e.getVisibleUnwrappedCoordinates(this._source.tileID).map(e=>new Oc(e.canonical.z,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y)):(r=e.coveringTiles({tileSize:t||this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!n,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain}),this._source.hasTile&&(r=r.filter(e=>this._source.hasTile(e)))):r=[];const i=this._updateRetainedTiles(r);if(Rp(this._source.type)&&0!==r.length){const e={},t={},n=Object.keys(i);for(const r of n){const n=i[r],o=this._tiles[r];if(!o||o.fadeEndTime&&o.fadeEndTime<=$e.now())continue;const a=this.findLoadedParent(n,Math.max(n.overscaledZ-Dp.maxOverzooming,this._source.minzoom));a&&(this._addTile(a.tileID),e[a.tileID.key]=a.tileID),t[r]=n}const o=r[r.length-1].overscaledZ;for(const e in this._tiles){const n=this._tiles[e];if(i[e]||!n.hasData())continue;let r=n.tileID;for(;r.overscaledZ>o;){r=r.scaledTo(r.overscaledZ-1);const o=this._tiles[r.key];if(o&&o.hasData()&&t[r.key]){i[e]=n.tileID;break}}}for(const t in e)i[t]||(this._coveredTiles[t]=!0,i[t]=e[t])}for(const e in i)this._tiles[e].clearFadeHold();const o=function(e,t){const n=[];for(const r in e)r in t||n.push(r);return n}(this._tiles,i);for(const e of o){const t=this._tiles[e];t.hasSymbolBuckets&&!t.holdingForFade()?t.setHoldDuration(this.map._fadeDuration):t.hasSymbolBuckets&&!t.symbolFadeFinished()||this._removeTile(+e)}this._updateLoadedParentTileCache(),this._onlySymbols&&this._source.afterUpdate&&this._source.afterUpdate()}releaseSymbolFadeTiles(){for(const e in this._tiles)this._tiles[e].holdingForFade()&&this._removeTile(+e)}_updateRetainedTiles(e){const t={};if(0===e.length)return t;const n={},r=e.reduce((e,t)=>Math.min(e,t.overscaledZ),1/0),i=e[0].overscaledZ,o=Math.max(i-Dp.maxOverzooming,this._source.minzoom),a=Math.max(i+Dp.maxUnderzooming,this._source.minzoom),s={};for(const n of e){const e=this._addTile(n);t[n.key]=n,e.hasData()||r=this._source.maxzoom){const e=r.children(this._source.maxzoom)[0],n=this.getTile(e);if(n&&n.hasData()){t[e.key]=e;continue}}else{const e=r.children(this._source.maxzoom);if(t[e[0].key]&&t[e[1].key]&&t[e[2].key]&&t[e[3].key])continue}let i=e.wasRequested();for(let a=r.overscaledZ-1;a>=o;--a){const o=r.scaledTo(a);if(n[o.key])break;if(n[o.key]=!0,e=this.getTile(o),!e&&i&&(e=this._addTile(o)),e&&(t[o.key]=o,i=e.wasRequested(),e.hasData()))break}}return t}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const e in this._tiles){const t=[];let n,r=this._tiles[e].tileID;for(;r.overscaledZ>0;){if(r.key in this._loadedParentTiles){n=this._loadedParentTiles[r.key];break}t.push(r.key);const e=r.scaledTo(r.overscaledZ-1);if(n=this._getLoadedTile(e),n)break;r=e}for(const e of t)this._loadedParentTiles[e]=n}}_addTile(e){let t=this._tiles[e.key];if(t)return t;t=this._cache.getAndRemove(e),t&&(this._setTileReloadTimer(e.key,t),t.tileID=e,this._state.initializeTileState(t,this.map?this.map.painter:null),this._cacheTimers[e.key]&&(clearTimeout(this._cacheTimers[e.key]),delete this._cacheTimers[e.key],this._setTileReloadTimer(e.key,t)));const n=Boolean(t);if(!n){const n=this.map?this.map.painter:null;t=new gp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,n,this._isRaster),this._loadTile(t,this._tileLoaded.bind(this,t,e.key,t.state))}return t?(t.uses++,this._tiles[e.key]=t,n||this._source.fire(new Xe("dataloading",{tile:t,coord:t.tileID,dataType:"source"})),t):null}_setTileReloadTimer(e,t){e in this._timers&&(clearTimeout(this._timers[e]),delete this._timers[e]);const n=t.getExpiryTimeout();n&&(this._timers[e]=setTimeout(()=>{this._reloadTile(e,"expired"),delete this._timers[e]},n))}_removeTile(e){const t=this._tiles[e];t&&(t.uses--,delete this._tiles[e],this._timers[e]&&(clearTimeout(this._timers[e]),delete this._timers[e]),t.uses>0||(t.hasData()&&"reloading"!==t.state?this._cache.add(t.tileID,t,t.getExpiryTimeout()):(t.aborted=!0,this._abortTile(t),this._unloadTile(t))))}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const e in this._tiles)this._removeTile(+e);this._source._clear&&this._source._clear(),this._cache.reset(),this.map&&this.usedForTerrain&&this.map.painter.terrain&&this.map.painter.terrain.resetTileLookupCache(this.id)}tilesIn(e,t,n){const r=[],i=this.transform;if(!i)return r;const o="globe"===i.projection.name,a=vs(i.center.lng);for(const s in this._tiles){const l=this._tiles[s];if(n&&l.clearQueryDebugViz(),l.holdingForFade())continue;let u;if(o){const e=l.tileID.canonical;if(0===e.z){const t=[Math.abs(S(a,...Bp(e,-1))-a),Math.abs(S(a,...Bp(e,1))-a)];u=[0,2*t.indexOf(Math.min(...t))-1]}else{const t=[Math.abs(S(a,...Bp(e,-1))-a),Math.abs(S(a,...Bp(e,0))-a),Math.abs(S(a,...Bp(e,1))-a)];u=[t.indexOf(Math.min(...t))-1]}}else u=[0];for(const n of u){const o=e.containsTile(l,i,t,n);o&&r.push(o)}}return r}getVisibleCoordinates(e){const t=this.getRenderableIds(e).map(e=>this._tiles[e].tileID);for(const e of t)e.projMatrix=this.transform.calculateProjMatrix(e.toUnwrapped());return t}hasTransition(){if(this._source.hasTransition())return!0;if(Rp(this._source.type))for(const e in this._tiles){const t=this._tiles[e];if(void 0!==t.fadeEndTime&&t.fadeEndTime>=$e.now())return!0}return!1}setFeatureState(e,t,n){this._state.updateState(e=e||"_geojsonTileLayer",t,n)}removeFeatureState(e,t,n){this._state.removeFeatureState(e=e||"_geojsonTileLayer",t,n)}getFeatureState(e,t){return this._state.getState(e=e||"_geojsonTileLayer",t)}setDependencies(e,t,n){const r=this._tiles[e];r&&r.setDependencies(t,n)}reloadTilesForDependencies(e,t){for(const n in this._tiles)this._tiles[n].hasDependency(e,t)&&this._reloadTile(+n,"reloading");this._cache.filter(n=>!n.hasDependency(e,t))}_preloadTiles(e,t){const n=new Map,r=Array.isArray(e)?e:[e],i=this.map.painter.terrain,o=this.usedForTerrain&&i?i.getScaledDemTileSize():this._source.tileSize;for(const e of r){const t=e.coveringTiles({tileSize:o,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom&&!this.usedForTerrain,reparseOverscaled:this._source.reparseOverscaled,isTerrainDEM:this.usedForTerrain});for(const e of t)n.set(e.key,e);this.usedForTerrain&&e.updateElevation(!1)}M(Array.from(n.values()),(e,t)=>{const n=new gp(e,this._source.tileSize*e.overscaleFactor(),this.transform.tileZoom,this.map.painter,this._isRaster);this._loadTile(n,e=>{"raster-dem"===this._source.type&&n.dem&&this._backfillDEM(n),t(e,n)})},t)}}function Lp(e,t){const n=Math.abs(2*e.wrap)-+(e.wrap<0),r=Math.abs(2*t.wrap)-+(t.wrap<0);return e.overscaledZ-t.overscaledZ||r-n||t.canonical.y-e.canonical.y||t.canonical.x-e.canonical.x}function Rp(e){return"raster"===e||"image"===e||"video"===e||"custom"===e}function Bp(e,t){const n=1<=0&&r[3]>=0&&s.insert(a,r[0],r[1],r[2],r[3])}}loadVTLayers(){if(!this.vtLayers){this.vtLayers=new hc(new dh(this.rawTileData)).layers,this.sourceLayerCoder=new sp(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"]),this.vtFeatures={};for(const e in this.vtLayers)this.vtFeatures[e]=[]}return this.vtLayers}query(e,t,n,r){this.loadVTLayers();const i=e.params||{},o=Qr(i.filter),a=e.tileResult,s=e.transform,l=a.bufferedTilespaceBounds,u=this.grid.query(l.min.x,l.min.y,l.max.x,l.max.y,(e,t,n,r)=>Ys(a.bufferedTilespaceGeometry,e,t,n,r));u.sort(Up);let c=null;s.elevation&&u.length>0&&(c=Fp.create(s.elevation,this.tileID));const h={};let d;for(let s=0;s(p||(p=Ls(t,this.tileID.canonical,e.tileTransform)),n.queryIntersectsFeature(a,t,r,p,this.z,e.transform,e.pixelPosMatrix,c,i)))}return h}loadMatchingFeature(e,t,n,r,i,o,a,s,l){const{featureIndex:u,bucketIndex:c,sourceLayerIndex:h,layoutVertexArrayOffset:d}=t,f=this.bucketLayerIDs[c];if(r&&!function(e,t){for(let n=0;n=0)return!0;return!1}(r,f))return;const p=this.sourceLayerCoder.decode(h),m=this.vtLayers[p].feature(u);if(n.needGeometry){const e=Rs(m,!0);if(!n.filter(new Po(this.tileID.overscaledZ),e,this.tileID.canonical))return}else if(!n.filter(new Po(this.tileID.overscaledZ),m))return;const _=this.getId(m,p);for(let t=0;t{const a=t instanceof jo?t.get(o):null;return a&&a.evaluate?a.evaluate(n,r,i):a})}function Up(e,t){return t-e}zi(jp,"FeatureIndex",{omit:["rawTileData","sourceLayerCoder"]});class Vp{constructor(e,t){this.width=e,this.height=t,this.nextRow=0,this.image=new ou({width:e,height:t}),this.positions={},this.uploaded=!1}getDash(e,t){const n=this.getKey(e,t);return this.positions[n]}trim(){const e=this.width,t=this.height=D(this.nextRow);this.image.resize({width:e,height:t})}getKey(e,t){return e.join(",")+t}getDashRanges(e,t,n){const r=[];let i=e.length%2==1?-e[e.length-1]*n:0,o=e[0]*n,a=!0;r.push({left:i,right:o,isDash:a,zeroLength:0===e[0]});let s=e[0];for(let t=1;t1&&(a=e[++o]);const l=Math.abs(s-a.left),u=Math.abs(s-a.right),c=Math.min(l,u);let h;const d=t/n*(r+1);if(a.isDash){const e=r-Math.abs(d);h=Math.sqrt(c*c+e*e)}else h=r-Math.sqrt(c*c+d*d);this.image.data[i+s]=Math.max(0,Math.min(255,h+128))}}}addRegularDash(e,t){for(let t=e.length-1;t>=0;--t){const n=e[t],r=e[t+1];n.zeroLength?e.splice(t,1):r&&r.isDash===n.isDash&&(r.left=n.left,e.splice(t,1))}const n=e[0],r=e[e.length-1];n.isDash===r.isDash&&(n.left=r.left-this.width,r.right=n.right+this.width);const i=this.width*this.nextRow;let o=0,a=e[o];for(let n=0;n1&&(a=e[++o]);const r=Math.abs(n-a.left),s=Math.abs(n-a.right),l=Math.min(r,s);this.image.data[i+n]=Math.max(0,Math.min(255,(a.isDash?l:-l)+t+128))}}addDash(e,t){const n=this.getKey(e,t);if(this.positions[n])return this.positions[n];const r="round"===t,i=r?7:0,o=2*i+1;if(this.nextRow+o>this.height)return V("LineAtlas out of space"),null;0===e.length&&e.push(1);let a=0;for(let t=0;t=t.maxzoom||"none"!==t.visibility&&($p(e,this.zoom,n),(s[t.id]=t.createBucket({index:a.bucketLayerIDs.length,layers:e,zoom:this.zoom,canonical:this.canonical,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:h,sourceID:this.source,enableTerrain:this.enableTerrain,projection:this.projection.spec,availableImages:n})).populate(d,u,this.tileID.canonical,this.tileTransform),a.bucketLayerIDs.push(e.map(e=>e.id)))}}let h,d,f,p;l.trim();const m={type:"maybePrepare",isSymbolTile:this.isSymbolTile,zoom:this.zoom},_=F(u.glyphDependencies,e=>Object.keys(e).map(Number));Object.keys(_).length?r.send("getGlyphs",{uid:this.uid,stacks:_},(e,t)=>{h||(h=e,d=t,v.call(this))},void 0,!1,m):d={};const g=Object.keys(u.iconDependencies);g.length?r.send("getImages",{icons:g,source:this.source,tileID:this.tileID,type:"icons"},(e,t)=>{h||(h=e,f=t,v.call(this))},void 0,!1,m):f={};const y=Object.keys(u.patternDependencies);function v(){if(h)return i(h);if(d&&f&&p){const e=new Gp(d),t=new jh(f,p);for(const r in s){const i=s[r];i instanceof Wf?($p(i.layers,this.zoom,n),Cd(i,d,e.positions,f,t.iconPositions,this.showCollisionBoxes,n,this.tileID.canonical,this.tileZoom,this.projection)):i.hasPattern&&(i instanceof $c||i instanceof Zu||i instanceof vc)&&($p(i.layers,this.zoom,n),i.addFeatures(u,this.tileID.canonical,t.patternPositions,n,this.tileTransform))}this.status="done",i(null,{buckets:A(s).filter(e=>!e.isEmpty()),featureIndex:a,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:e.image,lineAtlas:l,imageAtlas:t,glyphMap:this.returnDependencies?d:null,iconMap:this.returnDependencies?f:null,glyphPositions:this.returnDependencies?e.positions:null})}}y.length?r.send("getImages",{icons:y,source:this.source,tileID:this.tileID,type:"patterns"},(e,t)=>{h||(h=e,p=t,v.call(this))},void 0,!1,m):p={},v.call(this)}}function $p(e,t,n){const r=new Po(t);for(const t of e)t.recalculate(r,n)}class Zp{constructor(e){this.entries={},this.scheduler=e}request(e,t,n,r){const i=this.entries[e]=this.entries[e]||{callbacks:[]};if(i.result){const[e,n]=i.result;return this.scheduler?this.scheduler.add(()=>{r(e,n)},t):r(e,n),()=>{}}return i.callbacks.push(r),i.cancel||(i.cancel=n((n,r)=>{i.result=[n,r];for(const e of i.callbacks)this.scheduler?this.scheduler.add(()=>{e(n,r)},t):e(n,r);setTimeout(()=>delete this.entries[e],3e3)})),()=>{i.result||(i.callbacks=i.callbacks.filter(e=>e!==r),i.callbacks.length||(i.cancel(),delete this.entries[e]))}}}function Wp(e,t,n){const r=JSON.stringify(e.request);return e.data&&(this.deduped.entries[r]={result:[null,e.data]}),this.deduped.request(r,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom},t=>{const r=ce(e.request,(e,r,i,o)=>{e?t(e):r&&t(null,{vectorTile:n?void 0:new hc(new dh(r)),rawData:r,cacheControl:i,expires:o})});return()=>{r.cancel(),t()}},t)}e.ARRAY_TYPE=ol,e.AUTH_ERR_MSG=_e,e.Aabb=Hl,e.Actor=class{constructor(e,t,r){this.target=e,this.parent=t,this.mapId=r,this.callbacks={},this.cancelCallbacks={},R(["receive"],this),this.target.addEventListener("message",this.receive,!1),this.globalScope=$()?e:n,this.scheduler=new ap}send(e,t,n,r,i=!1,o){const a=Math.round(1e18*Math.random()).toString(36).substring(0,10);n&&(n.metadata=o,this.callbacks[a]=n);const s=X(this.globalScope)?void 0:[];return this.target.postMessage({id:a,type:e,hasCallback:!!n,targetMapId:r,mustQueue:i,sourceMapId:this.mapId,data:Li(t,s)},s),{cancel:()=>{n&&delete this.callbacks[a],this.target.postMessage({id:a,type:"",targetMapId:r,sourceMapId:this.mapId})}}}receive(e){const t=e.data,n=t.id;if(n&&(!t.targetMapId||this.mapId===t.targetMapId))if(""===t.type){const e=this.cancelCallbacks[n];delete this.cancelCallbacks[n],e&&e.cancel()}else if(t.mustQueue||$()){const e=this.callbacks[n];this.cancelCallbacks[n]=this.scheduler.add(()=>this.processTask(n,t),e&&e.metadata||{type:"message"})}else this.processTask(n,t)}processTask(e,t){if(""===t.type){const n=this.callbacks[e];delete this.callbacks[e],n&&(t.error?n(Ri(t.error)):n(null,Ri(t.data)))}else{const n=X(this.globalScope)?void 0:[],r=t.hasCallback?(t,r)=>{delete this.cancelCallbacks[e],this.target.postMessage({id:e,type:"",sourceMapId:this.mapId,error:t?Li(t):null,data:Li(r,n)},n)}:e=>{},i=Ri(t.data);if(this.parent[t.type])this.parent[t.type](t.sourceMapId,i,r);else if(this.parent.getWorkerSource){const e=t.type.split(".");this.parent.getWorkerSource(t.sourceMapId,e[0],i.source)[e[1]](i,r)}else r(new Error("Could not find function "+t.type))}}remove(){this.scheduler.remove(),this.target.removeEventListener("message",this.receive,!1)}},e.CanonicalTileID=Pc,e.Color=Mt,e.ColorMode=zp,e.CullFaceMode=Op,e.DEMData=Mp,e.DataConstantProperty=No,e.DedupedRequest=Zp,e.DepthMode=Ip,e.EXTENT=fs,e.Elevation=class{isDataAvailableAtPoint(e){const t=this._source();if(this.isUsingMockSource()||!t||e.y<0||e.y>1)return!1;const n=t.getSource().maxzoom,r=1<1)return t;const i=r.getSource().maxzoom,o=1<{const o=this.getAtTileOffset(e,i.x,i.y),a=r.upVector(e.canonical,i.x,i.y);return Cl(a,a,o*r.upVectorScale(e.canonical,t,n).metersToTile),a}}getForTilePoints(e,t,n,r){if(this.isUsingMockSource())return!1;const i=Fp.create(this,e,r);return!!i&&(t.forEach(e=>{e[2]=this.exaggeration()*i.getElevationAt(e[0],e[1],n)}),!0)}getMinMaxForTile(e){if(this.isUsingMockSource())return null;const t=this.findDEMTileFor(e);if(!t||!t.dem)return null;const n=t.dem.tree,r=t.tileID,i=1<this._skuTokenExpiresAt}transformRequest(e,t){return this._transformRequestFn&&this._transformRequestFn(e,t)||{url:e}}normalizeStyleURL(e,t){if(!ge(e))return e;const n=Ee(e);return n.path="/styles/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeGlyphsURL(e,t){if(!ge(e))return e;const n=Ee(e);return n.path="/fonts/v1"+n.path,this._makeAPIURL(n,this._customAccessToken||t)}normalizeSourceURL(e,t,n,r){if(!ge(e))return e;const i=Ee(e);return i.path=`/v4/${i.authority}.json`,i.params.push("secure"),n&&i.params.push("language="+n),r&&i.params.push("worldview="+r),this._makeAPIURL(i,this._customAccessToken||t)}normalizeSpriteURL(e,t,n,r){const i=Ee(e);return ge(e)?(i.path=`/styles/v1${i.path}/sprite${t}${n}`,this._makeAPIURL(i,this._customAccessToken||r)):(i.path+=`${t}${n}`,Te(i))}normalizeTileURL(e,t,n){if(this._isSkuTokenExpired()&&this._createSkuToken(),e&&!ge(e))return e;const r=Ee(e);r.path=r.path.replace(/(\.(png|jpg)\d*)(?=$)/,`${t||n&&"raster"!==r.authority&&512===n?"@2x":""}${a.supported?".webp":"$1"}`),"raster"===r.authority?r.path=`/${o.RASTER_URL_PREFIX}${r.path}`:(r.path=r.path.replace(/^.+\/v4\//,"/"),r.path=`/${o.TILE_URL_VERSION}${r.path}`);const i=this._customAccessToken||function(e){for(const t of e){const e=t.match(/^access_token=(.*)$/);if(e)return e[1]}return null}(r.params)||o.ACCESS_TOKEN;return o.REQUIRE_ACCESS_TOKEN&&i&&this._skuToken&&r.params.push("sku="+this._skuToken),this._makeAPIURL(r,i)}canonicalizeTileURL(e,t){const n=Ee(e);if(!n.path.match(/^(\/v4\/|\/raster\/v1\/)/)||!n.path.match(/\.[\w]+$/))return e;let r="mapbox://";n.path.match(/^\/raster\/v1\//)?r+="raster/"+n.path.replace(`/${o.RASTER_URL_PREFIX}/`,""):r+="tiles/"+n.path.replace(`/${o.TILE_URL_VERSION}/`,"");let i=n.params;return t&&(i=i.filter(e=>!e.match(/^access_token=/))),i.length&&(r+="?"+i.join("&")),r}canonicalizeTileset(e,t){const n=!!t&&ge(t),r=[];for(const t of e.tiles||[])ye(t)?r.push(this.canonicalizeTileURL(t,n)):r.push(t);return r}_makeAPIURL(e,t){const n="See https://docs.mapbox.com/api/overview/#access-tokens-and-token-scopes",r=Ee(o.API_URL);if(e.protocol=r.protocol,e.authority=r.authority,"http"===e.protocol){const t=e.params.indexOf("secure");t>=0&&e.params.splice(t,1)}if("/"!==r.path&&(e.path=`${r.path}${e.path}`),!o.REQUIRE_ACCESS_TOKEN)return Te(e);if(t=t||o.ACCESS_TOKEN,!this._silenceAuthErrors){if(!t)throw new Error("An API access token is required to use Mapbox GL. "+n);if("s"===t[0])throw new Error("Use a public access token (pk.*) with Mapbox GL, not a secret access token (sk.*). "+n)}return e.params=e.params.filter(e=>-1===e.indexOf("access_token")),e.params.push("access_token="+(t||"")),Te(e)}},e.ResourceType=ae,e.SegmentVector=ds,e.SourceCache=Dp,e.StencilMode=Pp,e.StructArrayLayout1ui2=va,e.StructArrayLayout2f1f2i16=ua,e.StructArrayLayout2i4=Yo,e.StructArrayLayout2ui4=ya,e.StructArrayLayout3f12=ha,e.StructArrayLayout3ui6=da,e.StructArrayLayout4i8=Jo,e.StructArrayLayout5f20=_a,e.Texture=ip,e.Tile=gp,e.Transitionable=Do,e.Uniform1f=Ga,e.Uniform1i=class extends Va{constructor(e){super(e),this.current=0}set(e,t,n){this.fetchUniformLocation(e,t)&&this.current!==n&&(this.current=n,this.gl.uniform1i(this.location,n))}},e.Uniform2f=class extends Va{constructor(e){super(e),this.current=[0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]||(this.current=n,this.gl.uniform2f(this.location,n[0],n[1])))}},e.Uniform3f=class extends Va{constructor(e){super(e),this.current=[0,0,0]}set(e,t,n){this.fetchUniformLocation(e,t)&&(n[0]===this.current[0]&&n[1]===this.current[1]&&n[2]===this.current[2]||(this.current=n,this.gl.uniform3f(this.location,n[0],n[1],n[2])))}},e.Uniform4f=qa,e.UniformColor=$a,e.UniformMatrix2f=class extends Va{constructor(e){super(e),this.current=Xa}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<4;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix2fv(this.location,!1,n);break}}},e.UniformMatrix3f=class extends Va{constructor(e){super(e),this.current=Wa}set(e,t,n){if(this.fetchUniformLocation(e,t))for(let e=0;e<9;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix3fv(this.location,!1,n);break}}},e.UniformMatrix4f=class extends Va{constructor(e){super(e),this.current=Za}set(e,t,n){if(this.fetchUniformLocation(e,t)){if(n[12]!==this.current[12]||n[0]!==this.current[0])return this.current=n,void this.gl.uniformMatrix4fv(this.location,!1,n);for(let e=1;e<16;e++)if(n[e]!==this.current[e]){this.current=n,this.gl.uniformMatrix4fv(this.location,!1,n);break}}}},e.UnwrappedTileID=zc,e.ValidationError=$r,e.VectorTileFeature=dc,e.VectorTileWorkerSource=class extends Ye{constructor(e,t,n,r,i){super(),this.actor=e,this.layerIndex=t,this.availableImages=n,this.loadVectorData=i||Wp,this.loading={},this.loaded={},this.deduped=new Zp(e.scheduler),this.isSpriteLoaded=r,this.scheduler=e.scheduler}loadTile(e,t){const n=e.uid,r=e&&e.request,i=r&&r.collectResourceTiming,o=this.loading[n]=new qp(e);o.abort=this.loadVectorData(e,(a,s)=>{const l=!this.loading[n];if(delete this.loading[n],l||a||!s)return o.status="done",l||(this.loaded[n]=o),t(a);const u=s.rawData,c={};s.expires&&(c.expires=s.expires),s.cacheControl&&(c.cacheControl=s.cacheControl),o.vectorTile=s.vectorTile||new hc(new dh(u));const h=()=>{o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,(e,n)=>{if(e||!n)return t(e);const o={};if(i){const e=Ne(r);e.length>0&&(o.resourceTiming=JSON.parse(JSON.stringify(e)))}t(null,I({rawTileData:u.slice(0)},n,c,o))})};this.isSpriteLoaded?h():this.once("isSpriteLoaded",()=>{this.scheduler?this.scheduler.add(h,{type:"parseTile",isSymbolTile:e.isSymbolTile,zoom:e.tileZoom}):h()}),this.loaded=this.loaded||{},this.loaded[n]=o})}reloadTile(e,t){const n=this.loaded,r=e.uid,i=this;if(n&&n[r]){const o=n[r];o.showCollisionBoxes=e.showCollisionBoxes,o.enableTerrain=!!e.enableTerrain,o.projection=e.projection,o.tileTransform=gf(e.tileID.canonical,e.projection);const a=(e,n)=>{const r=o.reloadCallback;r&&(delete o.reloadCallback,o.parse(o.vectorTile,i.layerIndex,this.availableImages,i.actor,r)),t(e,n)};"parsing"===o.status?o.reloadCallback=a:"done"===o.status&&(o.vectorTile?o.parse(o.vectorTile,this.layerIndex,this.availableImages,this.actor,a):a())}}abortTile(e,t){const n=e.uid,r=this.loading[n];r&&(r.abort&&r.abort(),delete this.loading[n]),t()}removeTile(e,t){const n=this.loaded,r=e.uid;n&&n[r]&&delete n[r],t()}},e.WritingMode=Nh,e.add=wl,e.addDynamicAttributes=Gf,e.adjoint=function(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=t[4],s=t[5],l=t[6],u=t[7],c=t[8];return e[0]=a*c-s*u,e[1]=i*u-r*c,e[2]=r*s-i*a,e[3]=s*l-o*c,e[4]=n*c-i*l,e[5]=i*o-n*s,e[6]=o*u-a*l,e[7]=r*l-n*u,e[8]=n*a-r*o,e},e.asyncAll=M,e.bezier=E,e.bindAll=R,e.boundsAttributes=mp,e.bufferConvexPolygon=function(e,t){const n=[];for(let r=0;rte&&(e.getActor().send("enforceCacheSizeLimit",ee),oe=0)},e.calculateGlobeLabelMatrix=function(e,t){const{x:n,y:r}=e.point,i=uf(n,r,e.worldSize/e._pixelsPerMercatorPixel,0,0);return cl(i,i,lf(Hd(t)))},e.calculateGlobeMatrix=function(e){const{x:t,y:n}=e.point,{lng:r,lat:i}=e._center;return uf(t,n,e.worldSize,r,i)},e.calculateGlobeMercatorMatrix=function(e){const t=e.pixelsPerMeter,n=t/bs(1,e.center.lat),r=ll(new Float64Array(16));return hl(r,r,[e.point.x,e.point.y,0]),dl(r,r,[n,n,t]),Float32Array.from(r)},e.circumferenceAtLatitude=ys,e.clamp=S,e.clearTileCache=function(e){if(!ne())return;const t=n.caches.delete(K);e&&t.catch(e).then(()=>e())},e.clipLine=sd,e.clone=function(e){var t=new ol(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.clone$1=N,e.collisionCircleLayout=nh,e.config=o,e.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},e.create=function(){var e=new ol(16);return ol!=Float32Array&&(e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=0,e[12]=0,e[13]=0,e[14]=0),e[0]=1,e[5]=1,e[10]=1,e[15]=1,e},e.create$1=al,e.createExpression=Nr,e.createLayout=Xo,e.createStyleLayer=function(e){return"custom"===e.type?new ep(e):new rp[e.type](e)},e.cross=Pl,e.degToRad=v,e.distance=function(e,t){return Math.hypot(t[0]-e[0],t[1]-e[1],t[2]-e[2])},e.div=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e},e.dot=Il,e.earthRadius=ms,e.ease=T,e.easeCubicInOut=w,e.ecefToLatLng=function([e,t,n]){const r=Math.hypot(e,t,n),i=Math.atan2(e,n),o=.5*Math.PI-Math.acos(-t/r);return new _s(x(i),x(o))},e.emitValidationErrors=Mi,e.endsWith=B,e.enforceCacheSizeLimit=function(e){re(),J&&J.then(t=>{t.keys().then(n=>{for(let r=0;ro&&(r+=(e[i]-o)*(e[i]-o)),t[i]0){const e=180/r;sl(f,f,[e/u+1,0,0,0,e/c+1,0,-.5*e/h,.5*e/d,1])}return f[2]=l,f[5]=e.x,f[8]=e.y,f},e.getImage=me,e.getJSON=function(e,t){return ue(I(e,{type:"json"}),t)},e.getLatitudinalLod=function(e){const t=80.051129;e=S(e,-80.051129,t)/t*90;const n=Math.pow(Math.abs(Math.sin(v(e))),3);return Math.round(n*(Vd.length-1))},e.getMapSessionAPI=De,e.getPerformanceMeasurement=Ne,e.getProjection=Ff,e.getRTLTextPluginStatus=Mo,e.getReferrer=le,e.getTilePoint=function(e,{x:t,y:n},r=0){return new m(((t-r)*e.scale-e.x)*fs,(n*e.scale-e.y)*fs)},e.getTileVec3=function(e,t,n=0){return bl(((t.x-n)*e.scale-e.x)*fs,(t.y*e.scale-e.y)*fs,Ts(t.z,t.y))},e.getVideo=function(e,t){const r=n.document.createElement("video");r.muted=!0,r.onloadstart=function(){t(null,r)};for(let t=0;t{}}},e.globeCenterToScreenPoint=function(e){const t=[0,0,0],n=ll(new Float64Array(16));return cl(n,e.pixelMatrix,e.globeMatrix),zl(t,t,n),new m(t[0],t[1])},e.globeDenormalizeECEF=lf,e.globeECEFOrigin=function(e,t){const n=[0,0,0];return zl(n,n,sf(Hd(t.canonical))),zl(n,n,e),n},e.globeNormalizeECEF=sf,e.globePixelsToTileUnits=function(e,t){return fs/(512*Math.pow(2,e))*of(Hd(t))},e.globePoleMatrixForTile=function(e,t,n){const r=ll(new Float64Array(16)),i=(t/(1<0;return 0===r&&!i&&!a&&o},e.identity=ll,e.identity$1=Vl,e.invert=ul,e.isFullscreen=function(){return!!n.document.fullscreenElement||!!n.document.webkitFullscreenElement},e.isLngLatBehindGlobe=df,e.isMapAuthenticated=function(e){return Le.has(e)},e.isMapboxURL=ge,e.isSafariWithAntialiasingBug=function(e){const t=e.navigator?e.navigator.userAgent:null;return!!X(e)&&t&&(t.match("Version/15.4")||t.match("Version/15.5")||t.match(/CPU (OS|iPhone OS) (15_4|15_5) like Mac OS X/))},e.latFromMercatorY=Es,e.latLngToECEF=nf,e.len=Bl,e.length=xl,e.length$1=function(e){return Math.hypot(e[0],e[1],e[2],e[3])},e.lngFromMercatorX=ws,e.loadVectorTile=Wp,e.makeRequest=ue,e.mapValue=function(e,t,n,r,i){return S((e-t)/(n-t)*(i-r)+r,r,i)},e.mercatorScale=ks,e.mercatorXfromLng=vs,e.mercatorYfromLat=xs,e.mercatorZfromAltitude=bs,e.mul=gl,e.mul$1=Rl,e.multiply=cl,e.multiply$1=sl,e.multiply$2=Tl,e.nextPowerOfTwo=D,e.normalize=Al,e.normalize$1=$l,e.normalize$2=jl,e.number=Mn,e.ortho=function(e,t,n,r,i,o,a){var s=1/(t-n),l=1/(r-i),u=1/(o-a);return e[0]=-2*s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*u,e[11]=0,e[12]=(t+n)*s,e[13]=(i+r)*l,e[14]=(a+o)*u,e[15]=1,e},e.pbf=dh,e.perspective=function(e,t,n,r,i){var o,a=1/Math.tan(t/2);return e[0]=a/n,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=-1,e[12]=0,e[13]=0,e[15]=0,null!=i&&i!==1/0?(e[10]=(i+r)*(o=1/(r-i)),e[14]=2*i*r*o):(e[10]=-1,e[14]=-2*r),e},e.pick=function(e,t){const n={};for(let r=0;r0&&n[0]<=e.width&&n[1]>0&&n[1]<=e.height&&!df(e,new _s(e.center.lat,90)),r[0]>0&&r[0]<=e.width&&r[1]>0&&r[1]<=e.height&&!df(e,new _s(e.center.lat,-90))]},e.polygonContainsPoint=Hs,e.polygonIntersectsBox=Ys,e.polygonIntersectsPolygon=Ns,e.polygonizeBounds=function(e,t,n=0,r=!0){const i=new m(n,n),o=e.sub(i),a=t.add(i),s=[o,new m(a.x,o.y),a,new m(o.x,a.y)];return r&&s.push(o.clone()),s},e.posAttributes=jd,e.postMapLoadEvent=Ie,e.postPerformanceEvent=ze,e.postTurnstileEvent=Me,e.potpack=Bh,e.prevPowerOfTwo=function(e){return e<=1?1:Math.pow(2,Math.floor(Math.log(e)/Math.LN2))},e.radToDeg=x,e.refProperties=["type","source","source-layer","minzoom","maxzoom","filter","layout"],e.registerForPluginStateChange=function(e){return e({pluginStatus:Eo,pluginURL:To}),Co.on("pluginStateChange",e),e},e.removeAuthState=function(e){Le.delete(e)},e.renderColorRamp=lu,e.resample=As,e.rotateX=fl,e.rotateX$1=Gl,e.rotateY=pl,e.rotateY$1=ql,e.rotateZ=function(e,t,n){var r=Math.sin(n),i=Math.cos(n),o=t[0],a=t[1],s=t[2],l=t[3],u=t[4],c=t[5],h=t[6],d=t[7];return t!==e&&(e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15]),e[0]=o*i+u*r,e[1]=a*i+c*r,e[2]=s*i+h*r,e[3]=l*i+d*r,e[4]=u*i-o*r,e[5]=c*i-a*r,e[6]=h*i-s*r,e[7]=d*i-l*r,e},e.rotateZ$1=function(e,t,n){n*=.5;var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);return e[0]=r*l+i*s,e[1]=i*l-r*s,e[2]=o*l+a*s,e[3]=a*l-o*s,e},e.scale=dl,e.scale$1=Fl,e.scale$2=Cl,e.scaleAndAdd=Ml,e.set=function(e,t,n,r){return e[0]=t,e[1]=n,e[2]=r,e},e.setCacheLimits=function(e,t){ee=e,te=t},e.setColumn=function(e,t,n){e[4*t+0]=n[0],e[4*t+1]=n[1],e[4*t+2]=n[2],e[4*t+3]=n[3]},e.setRTLTextPlugin=function(e,t,n=!1){if(Eo===vo||Eo===xo||Eo===bo)throw new Error("setRTLTextPlugin cannot be called multiple times.");To=$e.resolveURL(e),Eo=vo,wo=t,ko(),n||Ao()},e.smoothstep=k,e.spec=Ke,e.squaredLength=function(e){var t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r},e.storeAuthState=function(e,t){t?Le.add(e):Le.delete(e)},e.sub=Ll,e.subtract=El,e.symbolSize=sh,e.tileAABB=function(e,t,n,r,i,o,a,s,l){if("globe"===l.name)return function(e,t,n){const r=t/e.worldSize,i=e.globeMatrix;if(n.z<=1){const e=Hd(n).getCorners();return Jd(e,i,r),Hl.fromPoints(e)}const o=Qd(n),a=ef(o);Jd(a,i,r);const s=Number.MAX_VALUE,l=[-s,-s,-s],u=[s,s,s];if(o.contains(e.center)){for(const e of a)Sl(u,u,e),kl(l,l,e);l[2]=0;const t=e.point,n=[t.x*r,t.y*r,0];return Sl(u,u,n),kl(l,l,n),new Hl(u,l)}const c=[i[12]*r,i[13]*r,i[14]*r],h=o.getCenter(),d=S(e.center.lat,-85.051129,Ss),f=S(h.lat,-85.051129,Ss),p=vs(e.center.lng),m=xs(d);let _=p-vs(h.lng);const g=m-xs(f);_>.5?_-=1:_<-.5&&(_+=1);let y=0;Math.abs(_)>Math.abs(g)?y=_>=0?1:3:(y=g>=0?0:2,Ml(c,c,[i[4]*r,i[5]*r,i[6]*r],-Math.sin(v(g>=0?o.getSouth():o.getNorth()))*Nd));const x=a[y],b=a[(y+1)%4],w=new Wd(x,b,c),E=[Xd(w,0)||x[0],Xd(w,1)||x[1],Xd(w,2)||x[2]],T=cf(e.zoom);if(T>0){const r=function({x:e,y:t,z:n},r,i,o,a){const s=1/(1<.5?d=-1:f<-.5&&(d=1),l=((l+d)*r-(o*=r))*i+o,u=((u+d)*r-o)*i+o,c=(c*r-(a*=r))*i+a,h=(h*r-a)*i+a,[[l,h,0],[u,h,0],[u,c,0],[l,c,0]]}(n,t,e._pixelsPerMercatorPixel,p,m);for(let e=0;eCi(ui(e)),e.validateFog=e=>Ci(xi(e)),e.validateLayer=e=>Ci(fi(e)),e.validateLight=e=>Ci(yi(e)),e.validateSource=e=>Ci(_i(e)),e.validateStyle=Ti,e.validateTerrain=e=>Ci(vi(e)),e.values=A,e.vectorTile=Qu,e.version=r,e.warnOnce=V,e.window=n,e.wrap=C})),i(0,(function(e){function t(e){if("number"==typeof e||"boolean"==typeof e||"string"==typeof e||null==e)return JSON.stringify(e);if(Array.isArray(e)){let n="[";for(const r of e)n+=t(r)+",";return n+"]"}let n="{";for(const r of Object.keys(e).sort())n+=`${r}:${t(e[r])},`;return n+"}"}function n(n){let r="";for(const i of e.refProperties)r+="/"+t(n[i]);return r}class r{constructor(e){this.keyCache={},e&&this.replace(e)}replace(e){this._layerConfigs={},this._layers={},this.update(e,[])}update(t,r){for(const n of t)this._layerConfigs[n.id]=n,(this._layers[n.id]=e.createStyleLayer(n)).compileFilter(),this.keyCache[n.id]&&delete this.keyCache[n.id];for(const e of r)delete this.keyCache[e],delete this._layerConfigs[e],delete this._layers[e];this.familiesBySource={};const i=function(e,t){const r={};for(let i=0;ithis._layers[e.id]),n=t[0];if("none"===n.visibility)continue;const r=n.source||"";let i=this.familiesBySource[r];i||(i=this.familiesBySource[r]={});const o=n.sourceLayer||"_geojsonTileLayer";let a=i[o];a||(a=i[o]=[]),a.push(t)}}}class i{loadTile(t,n){const{uid:r,encoding:i,rawImageData:o,padding:a,buildQuadTree:s}=t,l=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap?this.getImageData(o,a):o;n(null,new e.DEMData(r,l,i,a<1,s))}getImageData(e,t){this.offscreenCanvas&&this.offscreenCanvasContext||(this.offscreenCanvas=new OffscreenCanvas(e.width,e.height),this.offscreenCanvasContext=this.offscreenCanvas.getContext("2d",{willReadFrequently:!0})),this.offscreenCanvas.width=e.width,this.offscreenCanvas.height=e.height,this.offscreenCanvasContext.drawImage(e,0,0,e.width,e.height);const n=this.offscreenCanvasContext.getImageData(-t,-t,e.width+2*t,e.height+2*t);return this.offscreenCanvasContext.clearRect(0,0,this.offscreenCanvas.width,this.offscreenCanvas.height),n}}var o=function e(t,n){var r,i=t&&t.type;if("FeatureCollection"===i)for(r=0;r=Math.abs(s)?n-l+s:s-l+n,n=l}n+r>=0!=!!t&&e.reverse()}const l=e.VectorTileFeature.prototype.toGeoJSON;class u{constructor(t){this._feature=t,this.extent=e.EXTENT,this.type=t.type,this.properties=t.tags,"id"in t&&!isNaN(t.id)&&(this.id=parseInt(t.id,10))}loadGeometry(){if(1===this._feature.type){const t=[];for(const n of this._feature.geometry)t.push([new e.pointGeometry(n[0],n[1])]);return t}{const t=[];for(const n of this._feature.geometry){const r=[];for(const t of n)r.push(new e.pointGeometry(t[0],t[1]));t.push(r)}return t}}toGeoJSON(e,t,n){return l.call(this,e,t,n)}}class c{constructor(t){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=e.EXTENT,this.length=t.length,this._features=t}feature(e){return new u(this._features[e])}}var h={exports:{}},d=e.pointGeometry,f=e.vectorTile.VectorTileFeature,p=m;function m(e,t){this.options=t||{},this.features=e,this.length=e.length}function _(e,t){this.id="number"==typeof e.id?e.id:void 0,this.type=e.type,this.rawGeometry=1===e.type?[e.geometry]:e.geometry,this.properties=e.tags,this.extent=t||4096}m.prototype.feature=function(e){return new _(this.features[e],this.options.extent)},_.prototype.loadGeometry=function(){var e=this.rawGeometry;this.geometry=[];for(var t=0;t>31}function S(e,t){for(var n=e.loadGeometry(),r=e.type,i=0,o=0,a=n.length,s=0;s>1;(function e(t,n,r,i,o,a){for(;o>i;){if(o-i>600){const s=o-i+1,l=r-i+1,u=Math.log(s),c=.5*Math.exp(2*u/3),h=.5*Math.sqrt(u*c*(s-c)/s)*(l-s/2<0?-1:1);e(t,n,r,Math.max(i,Math.floor(r-l*c/s+h)),Math.min(o,Math.floor(r+(s-l)*c/s+h)),a)}const s=n[2*r+a];let l=i,u=o;for(M(t,n,i,r),n[2*o+a]>s&&M(t,n,i,o);ls;)u--}n[2*i+a]===s?M(t,n,i,u):(u++,M(t,n,u,o)),u<=r&&(i=u+1),r<=u&&(o=u-1)}})(e,t,a,r,i,o%2),C(e,t,n,r,a-1,o+1),C(e,t,n,a+1,i,o+1)}function M(e,t,n,r){A(e,n,r),A(t,2*n,2*r),A(t,2*n+1,2*r+1)}function A(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function I(e,t,n,r){const i=e-n,o=t-r;return i*i+o*o}h.exports=v,h.exports.fromVectorTileJs=v,h.exports.fromGeojsonVt=function(e,t){t=t||{};var n={};for(var r in e)n[r]=new y(e[r].features,t),n[r].name=r,n[r].version=t.version,n[r].extent=t.extent;return v({layers:n})},h.exports.GeoJSONWrapper=y;const P=e=>e[0],z=e=>e[1];class O{constructor(e,t=P,n=z,r=64,i=Float64Array){this.nodeSize=r,this.points=e;const o=e.length<65536?Uint16Array:Uint32Array,a=this.ids=new o(e.length),s=this.coords=new i(2*e.length);for(let r=0;r=n&&u<=i&&c>=r&&c<=o&&l.push(e[a]);continue}const p=Math.floor((f+d)/2);u=t[2*p],c=t[2*p+1],u>=n&&u<=i&&c>=r&&c<=o&&l.push(e[p]);const m=(h+1)%2;(0===h?n<=u:r<=c)&&(s.push(f),s.push(p-1),s.push(m)),(0===h?i>=u:o>=c)&&(s.push(p+1),s.push(d),s.push(m))}return l}(this.ids,this.coords,e,t,n,r,this.nodeSize)}within(e,t,n){return function(e,t,n,r,i,o){const a=[0,e.length-1,0],s=[],l=i*i;for(;a.length;){const u=a.pop(),c=a.pop(),h=a.pop();if(c-h<=o){for(let i=h;i<=c;i++)I(t[2*i],t[2*i+1],n,r)<=l&&s.push(e[i]);continue}const d=Math.floor((h+c)/2),f=t[2*d],p=t[2*d+1];I(f,p,n,r)<=l&&s.push(e[d]);const m=(u+1)%2;(0===u?n-i<=f:r-i<=p)&&(a.push(h),a.push(d-1),a.push(m)),(0===u?n+i>=f:r+i>=p)&&(a.push(d+1),a.push(c),a.push(m))}return s}(this.ids,this.coords,e,t,n,this.nodeSize)}}const D={minZoom:0,maxZoom:16,minPoints:2,radius:40,extent:512,nodeSize:64,log:!1,generateId:!1,reduce:null,map:e=>e},L=Math.fround||(R=new Float32Array(1),e=>(R[0]=+e,R[0]));var R;class B{constructor(e){this.options=$(Object.create(D),e),this.trees=new Array(this.options.maxZoom+1)}load(e){const{log:t,minZoom:n,maxZoom:r,nodeSize:i}=this.options;t&&console.time("total time");const o=`prepare ${e.length} points`;t&&console.time(o),this.points=e;let a=[];for(let t=0;t=n;e--){const n=+Date.now();a=this._cluster(a,e),this.trees[e]=new O(a,Z,W,i,Float32Array),t&&console.log("z%d: %d clusters in %dms",e,a.length,+Date.now()-n)}return t&&console.timeEnd("total time"),this}getClusters(e,t){let n=((e[0]+180)%360+360)%360-180;const r=Math.max(-90,Math.min(90,e[1]));let i=180===e[2]?180:((e[2]+180)%360+360)%360-180;const o=Math.max(-90,Math.min(90,e[3]));if(e[2]-e[0]>=360)n=-180,i=180;else if(n>i){const e=this.getClusters([n,r,180,o],t),a=this.getClusters([-180,r,i,o],t);return e.concat(a)}const a=this.trees[this._limitZoom(t)],s=a.range(V(n),G(o),V(i),G(r)),l=[];for(const e of s){const t=a.points[e];l.push(t.numPoints?N(t):this.points[t.index])}return l}getChildren(e){const t=this._getOriginId(e),n=this._getOriginZoom(e),r="No cluster with the specified id.",i=this.trees[n];if(!i)throw new Error(r);const o=i.points[t];if(!o)throw new Error(r);const a=this.options.radius/(this.options.extent*Math.pow(2,n-1)),s=i.within(o.x,o.y,a),l=[];for(const t of s){const n=i.points[t];n.parentId===e&&l.push(n.numPoints?N(n):this.points[n.index])}if(0===l.length)throw new Error(r);return l}getLeaves(e,t,n){const r=[];return this._appendLeaves(r,e,t=t||10,n=n||0,0),r}getTile(e,t,n){const r=this.trees[this._limitZoom(e)],i=Math.pow(2,e),{extent:o,radius:a}=this.options,s=a/o,l=(n-s)/i,u=(n+1+s)/i,c={features:[]};return this._addTileFeatures(r.range((t-s)/i,l,(t+1+s)/i,u),r.points,t,n,i,c),0===t&&this._addTileFeatures(r.range(1-s/i,l,1,u),r.points,i,n,i,c),t===i-1&&this._addTileFeatures(r.range(0,l,s/i,u),r.points,-1,n,i,c),c.features.length?c:null}getClusterExpansionZoom(e){let t=this._getOriginZoom(e)-1;for(;t<=this.options.maxZoom;){const n=this.getChildren(e);if(t++,1!==n.length)break;e=n[0].properties.cluster_id}return t}_appendLeaves(e,t,n,r,i){const o=this.getChildren(t);for(const t of o){const o=t.properties;if(o&&o.cluster?i+o.point_count<=r?i+=o.point_count:i=this._appendLeaves(e,o.cluster_id,n,r,i):it&&(h+=n.numPoints||1)}if(h>c&&h>=a){let e=i.x*c,a=i.y*c,s=o&&c>1?this._map(i,!0):null;const d=(r<<5)+(t+1)+this.points.length;for(const n of u){const r=l.points[n];if(r.zoom<=t)continue;r.zoom=t;const u=r.numPoints||1;e+=r.x*u,a+=r.y*u,r.parentId=d,o&&(s||(s=this._map(i,!0)),o(s,this._map(r)))}i.parentId=d,n.push(F(e/h,a/h,d,h,s))}else if(n.push(i),h>1)for(const e of u){const r=l.points[e];r.zoom<=t||(r.zoom=t,n.push(r))}}return n}_getOriginId(e){return e-this.points.length>>5}_getOriginZoom(e){return(e-this.points.length)%32}_map(e,t){if(e.numPoints)return t?$({},e.properties):e.properties;const n=this.points[e.index].properties,r=this.options.map(n);return t&&r===n?$({},r):r}}function F(e,t,n,r,i){return{x:L(e),y:L(t),zoom:1/0,id:n,parentId:-1,numPoints:r,properties:i}}function j(e,t){const[n,r]=e.geometry.coordinates;return{x:L(V(n)),y:L(G(r)),zoom:1/0,index:t,parentId:-1}}function N(e){return{type:"Feature",id:e.id,properties:U(e),geometry:{type:"Point",coordinates:[(t=e.x,360*(t-.5)),q(e.y)]}};var t}function U(e){const t=e.numPoints,n=t>=1e4?Math.round(t/1e3)+"k":t>=1e3?Math.round(t/100)/10+"k":t;return $($({},e.properties),{cluster:!0,cluster_id:e.id,point_count:t,point_count_abbreviated:n})}function V(e){return e/360+.5}function G(e){const t=Math.sin(e*Math.PI/180),n=.5-.25*Math.log((1+t)/(1-t))/Math.PI;return n<0?0:n>1?1:n}function q(e){const t=(180-360*e)*Math.PI/180;return 360*Math.atan(Math.exp(t))/Math.PI-90}function $(e,t){for(const n in t)e[n]=t[n];return e}function Z(e){return e.x}function W(e){return e.y}function X(e,t,n,r,i,o){var a=i-n,s=o-r;if(0!==a||0!==s){var l=((e-n)*a+(t-r)*s)/(a*a+s*s);l>1?(n=i,r=o):l>0&&(n+=a*l,r+=s*l)}return(a=e-n)*a+(s=t-r)*s}function H(e,t,n,r){var i={id:void 0===e?null:e,type:t,geometry:n,tags:r,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(e){var t=e.geometry,n=e.type;if("Point"===n||"MultiPoint"===n||"LineString"===n)Y(e,t);else if("Polygon"===n||"MultiLineString"===n)for(var r=0;r0&&(a+=r?(i*u-l*o)/2:Math.sqrt(Math.pow(l-i,2)+Math.pow(u-o,2))),i=l,o=u}var c=t.length-3;t[2]=1,function e(t,n,r,i){for(var o,a=i,s=r-n>>1,l=r-n,u=t[n],c=t[n+1],h=t[r],d=t[r+1],f=n+3;fa)o=f,a=p;else if(p===a){var m=Math.abs(f-s);mi&&(o-n>3&&e(t,n,o,i),t[o+2]=a,r-o>3&&e(t,o,r,i))}(t,0,c,n),t[c+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function ee(e,t,n,r){for(var i=0;i1?1:n}function re(e,t,n,r,i,o,a,s){if(r/=t,o>=(n/=t)&&a=r)return null;for(var l=[],u=0;u=n&&p=r)){var m=[];if("Point"===d||"MultiPoint"===d)ie(h,m,n,r,i);else if("LineString"===d)oe(h,m,n,r,i,!1,s.lineMetrics);else if("MultiLineString"===d)se(h,m,n,r,i,!1);else if("Polygon"===d)se(h,m,n,r,i,!0);else if("MultiPolygon"===d)for(var _=0;_=n&&a<=r&&(t.push(e[o]),t.push(e[o+1]),t.push(e[o+2]))}}function oe(e,t,n,r,i,o,a){for(var s,l,u=ae(e),c=0===i?ue:ce,h=e.start,d=0;dn&&(l=c(u,f,p,_,g,n),a&&(u.start=h+s*l)):y>r?v=n&&(l=c(u,f,p,_,g,n),x=!0),v>r&&y<=r&&(l=c(u,f,p,_,g,r),x=!0),!o&&x&&(a&&(u.end=h+s*l),t.push(u),u=ae(e)),a&&(h+=s)}var b=e.length-3;f=e[b],p=e[b+1],m=e[b+2],(y=0===i?f:p)>=n&&y<=r&&le(u,f,p,m),b=u.length-3,o&&b>=3&&(u[b]!==u[0]||u[b+1]!==u[1])&&le(u,u[0],u[1],u[2]),u.length&&t.push(u)}function ae(e){var t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function se(e,t,n,r,i,o){for(var a=0;aa.maxX&&(a.maxX=c),h>a.maxY&&(a.maxY=h)}return a}function _e(e,t,n,r){var i=t.geometry,o=t.type,a=[];if("Point"===o||"MultiPoint"===o)for(var s=0;s0&&t.size<(i?a:r))n.numPoints+=t.length/3;else{for(var s=[],l=0;la)&&(n.numSimplified++,s.push(t[l]),s.push(t[l+1])),n.numPoints++;i&&function(e,t){for(var n=0,r=0,i=e.length,o=i-2;r0===t)for(r=0,i=e.length;r24)throw new Error("maxZoom should be in the 0-24 range");if(t.promoteId&&t.generateId)throw new Error("promoteId and generateId cannot be used together.");var r=function(e,t){var n=[];if("FeatureCollection"===e.type)for(var r=0;r1&&console.time("creation"),d=this.tiles[h]=me(e,t,n,r,l),this.tileCoords.push({z:t,x:n,y:r}),u)){u>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",t,n,r,d.numFeatures,d.numPoints,d.numSimplified),console.timeEnd("creation"));var f="z"+t;this.stats[f]=(this.stats[f]||0)+1,this.total++}if(d.source=e,i){if(t===l.maxZoom||t===i)continue;var p=1<1&&console.time("clipping");var m,_,g,y,v,x,b=.5*l.buffer/l.extent,w=.5-b,E=.5+b,T=1+b;m=_=g=y=null,v=re(e,c,n-b,n+E,0,d.minX,d.maxX,l),x=re(e,c,n+w,n+T,0,d.minX,d.maxX,l),e=null,v&&(m=re(v,c,r-b,r+E,1,d.minY,d.maxY,l),_=re(v,c,r+w,r+T,1,d.minY,d.maxY,l),v=null),x&&(g=re(x,c,r-b,r+E,1,d.minY,d.maxY,l),y=re(x,c,r+w,r+T,1,d.minY,d.maxY,l),x=null),u>1&&console.timeEnd("clipping"),s.push(m||[],t+1,2*n,2*r),s.push(_||[],t+1,2*n,2*r+1),s.push(g||[],t+1,2*n+1,2*r),s.push(y||[],t+1,2*n+1,2*r+1)}}},ye.prototype.getTile=function(e,t,n){var r=this.options,i=r.extent,o=r.debug;if(e<0||e>24)return null;var a=1<1&&console.log("drilling down to z%d-%d-%d",e,t,n);for(var l,u=e,c=t,h=n;!l&&u>0;)u--,c=Math.floor(c/2),h=Math.floor(h/2),l=this.tiles[ve(u,c,h)];return l&&l.source?(o>1&&console.log("found parent tile z%d-%d-%d",u,c,h),o>1&&console.time("drilling down"),this.splitTile(l.source,u,c,h,e,t,n),o>1&&console.timeEnd("drilling down"),this.tiles[s]?fe(this.tiles[s],i):null):null};class be extends e.VectorTileWorkerSource{constructor(e,t,n,r,i){super(e,t,n,r,xe),i&&(this.loadGeoJSON=i)}loadData(t,n){const r=t&&t.request,i=r&&r.collectResourceTiming;this.loadGeoJSON(t,(a,s)=>{if(a||!s)return n(a);if("object"!=typeof s)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));{o(s,!0);try{if(t.filter){const n=e.createExpression(t.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if("error"===n.result)throw new Error(n.value.map(e=>`${e.key}: ${e.message}`).join(", "));const r=s.features.filter(e=>n.value.evaluate({zoom:0},e));s={type:"FeatureCollection",features:r}}this._geoJSONIndex=t.cluster?new B(function({superclusterOptions:t,clusterProperties:n}){if(!n||!t)return t;const r={},i={},o={accumulated:null,zoom:0},a={properties:null},s=Object.keys(n);for(const t of s){const[o,a]=n[t],s=e.createExpression(a),l=e.createExpression("string"==typeof o?[o,["accumulated"],["get",t]]:o);r[t]=s.value,i[t]=l.value}return t.map=e=>{a.properties=e;const t={};for(const e of s)t[e]=r[e].evaluate(o,a);return t},t.reduce=(e,t)=>{a.properties=t;for(const t of s)o.accumulated=e[t],e[t]=i[t].evaluate(o,a)},t}(t)).load(s.features):function(e,t){return new ye(e,t)}(s,t.geojsonVtOptions)}catch(a){return n(a)}this.loaded={};const l={};if(i){const n=e.getPerformanceMeasurement(r);n&&(l.resourceTiming={},l.resourceTiming[t.source]=JSON.parse(JSON.stringify(n)))}n(null,l)}})}reloadTile(e,t){const n=this.loaded;return n&&n[e.uid]?super.reloadTile(e,t):this.loadTile(e,t)}loadGeoJSON(t,n){if(t.request)e.getJSON(t.request,n);else{if("string"!=typeof t.data)return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`));try{return n(null,JSON.parse(t.data))}catch(e){return n(new Error(`Input data given to '${t.source}' is not a valid GeoJSON object.`))}}}getClusterExpansionZoom(e,t){try{t(null,this._geoJSONIndex.getClusterExpansionZoom(e.clusterId))}catch(e){t(e)}}getClusterChildren(e,t){try{t(null,this._geoJSONIndex.getChildren(e.clusterId))}catch(e){t(e)}}getClusterLeaves(e,t){try{t(null,this._geoJSONIndex.getLeaves(e.clusterId,e.limit,e.offset))}catch(e){t(e)}}}class we{constructor(t){this.self=t,this.actor=new e.Actor(t,this),this.layerIndexes={},this.availableImages={},this.isSpriteLoaded={},this.projections={},this.defaultProjection=e.getProjection({name:"mercator"}),this.workerSourceTypes={vector:e.VectorTileWorkerSource,geojson:be},this.workerSources={},this.demWorkerSources={},this.self.registerWorkerSource=(e,t)=>{if(this.workerSourceTypes[e])throw new Error(`Worker source with name "${e}" already registered.`);this.workerSourceTypes[e]=t},this.self.registerRTLTextPlugin=t=>{if(e.plugin.isParsed())throw new Error("RTL text plugin already registered.");e.plugin.applyArabicShaping=t.applyArabicShaping,e.plugin.processBidirectionalText=t.processBidirectionalText,e.plugin.processStyledBidirectionalText=t.processStyledBidirectionalText}}clearCaches(e,t,n){delete this.layerIndexes[e],delete this.availableImages[e],delete this.workerSources[e],delete this.demWorkerSources[e],n()}checkIfReady(e,t,n){n()}setReferrer(e,t){this.referrer=t}spriteLoaded(t,n){this.isSpriteLoaded[t]=n;for(const r in this.workerSources[t]){const i=this.workerSources[t][r];for(const t in i)i[t]instanceof e.VectorTileWorkerSource&&(i[t].isSpriteLoaded=n,i[t].fire(new e.Event("isSpriteLoaded")))}}setImages(e,t,n){this.availableImages[e]=t;for(const n in this.workerSources[e]){const r=this.workerSources[e][n];for(const e in r)r[e].availableImages=t}n()}enableTerrain(e,t,n){this.terrain=t,n()}setProjection(t,n){this.projections[t]=e.getProjection(n)}setLayers(e,t,n){this.getLayerIndex(e).replace(t),n()}updateLayers(e,t,n){this.getLayerIndex(e).update(t.layers,t.removedIds),n()}loadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).loadTile(i,r)}loadDEMTile(t,n,r){const i=this.enableTerrain?e.extend({buildQuadTree:this.terrain},n):n;this.getDEMWorkerSource(t,n.source).loadTile(i,r)}reloadTile(t,n,r){const i=this.enableTerrain?e.extend({enableTerrain:this.terrain},n):n;i.projection=this.projections[t]||this.defaultProjection,this.getWorkerSource(t,n.type,n.source).reloadTile(i,r)}abortTile(e,t,n){this.getWorkerSource(e,t.type,t.source).abortTile(t,n)}removeTile(e,t,n){this.getWorkerSource(e,t.type,t.source).removeTile(t,n)}removeSource(e,t,n){if(!this.workerSources[e]||!this.workerSources[e][t.type]||!this.workerSources[e][t.type][t.source])return;const r=this.workerSources[e][t.type][t.source];delete this.workerSources[e][t.type][t.source],void 0!==r.removeSource?r.removeSource(t,n):n()}loadWorkerSource(e,t,n){try{this.self.importScripts(t.url),n()}catch(e){n(e.toString())}}syncRTLPluginState(t,n,r){try{e.plugin.setState(n);const t=e.plugin.getPluginURL();if(e.plugin.isLoaded()&&!e.plugin.isParsed()&&null!=t){this.self.importScripts(t);const n=e.plugin.isParsed();r(n?void 0:new Error("RTL Text Plugin failed to import scripts from "+t),n)}}catch(e){r(e.toString())}}getAvailableImages(e){let t=this.availableImages[e];return t||(t=[]),t}getLayerIndex(e){let t=this.layerIndexes[e];return t||(t=this.layerIndexes[e]=new r),t}getWorkerSource(e,t,n){if(this.workerSources[e]||(this.workerSources[e]={}),this.workerSources[e][t]||(this.workerSources[e][t]={}),!this.workerSources[e][t][n]){const r={send:(t,n,r,i,o,a)=>{this.actor.send(t,n,r,e,o,a)},scheduler:this.actor.scheduler};this.workerSources[e][t][n]=new this.workerSourceTypes[t](r,this.getLayerIndex(e),this.getAvailableImages(e),this.isSpriteLoaded[e])}return this.workerSources[e][t][n]}getDEMWorkerSource(e,t){return this.demWorkerSources[e]||(this.demWorkerSources[e]={}),this.demWorkerSources[e][t]||(this.demWorkerSources[e][t]=new i),this.demWorkerSources[e][t]}enforceCacheSizeLimit(t,n){e.enforceCacheSizeLimit(n)}getWorkerPerformanceMetrics(e,t,n){n(void 0,void 0)}}return"undefined"!=typeof WorkerGlobalScope&&"undefined"!=typeof self&&self instanceof WorkerGlobalScope&&(self.worker=new we(self)),we})),i(0,(function(e){function t(e,n){if(Array.isArray(e)){if(!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r{e.window.removeEventListener("click",d,!0)},0)}function p(e,t){const n=e.getBoundingClientRect();return g(e,n,t)}function m(e,t){const n=e.getBoundingClientRect(),r=[];for(let i=0;i=0?0:t.button}function g(t,n,r){const i=t.offsetWidth===n.width?1:t.offsetWidth/n.width;return new e.pointGeometry((r.clientX-n.left)*i,(r.clientY-n.top)*i)}function y(e,t){var n=t[0],r=t[1],i=t[2],o=t[3],a=n*o-i*r;return a?(e[0]=o*(a=1/a),e[1]=-r*a,e[2]=-i*a,e[3]=n*a,e):null}function v(e){const{userImage:t}=e;return!!(t&&t.render&&t.render())&&(e.data.replace(new Uint8Array(t.data.buffer)),!0)}class x extends e.Evented{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new e.RGBAImage({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(e){if(this.loaded!==e&&(this.loaded=e,e)){for(const{ids:e,callback:t}of this.requestors)this._notify(e,t);this.requestors=[]}}hasImage(e){return!!this.getImage(e)}getImage(e){return this.images[e]}addImage(e,t){this._validate(e,t)&&(this.images[e]=t)}_validate(t,n){let r=!0;return this._validateStretch(n.stretchX,n.data&&n.data.width)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchX" value`))),r=!1),this._validateStretch(n.stretchY,n.data&&n.data.height)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "stretchY" value`))),r=!1),this._validateContent(n.content,n)||(this.fire(new e.ErrorEvent(new Error(`Image "${t}" has invalid "content" value`))),r=!1),r}_validateStretch(e,t){if(!e)return!0;let n=0;for(const r of e){if(r[0]{this.ready=!0})}broadcast(t,n,r){e.asyncAll(this.actors,(e,r)=>{e.send(t,n,r)},r=r||function(){})}getActor(){return this.currentActor=(this.currentActor+1)%this.actors.length,this.actors[this.currentActor]}remove(){this.actors.forEach(e=>{e.remove()}),this.actors=[],this.workerPool.release(this.id)}}function O(t,n,r){return n*(e.EXTENT/(t.tileSize*Math.pow(2,r-t.tileID.overscaledZ)))}z.Actor=e.Actor;class D{constructor(e,t,n,r){this.screenBounds=e,this.cameraPoint=t,this._screenRaycastCache={},this._cameraRaycastCache={},this.isAboveHorizon=n,this.screenGeometry=this.bufferedScreenGeometry(0),this.screenGeometryMercator=this._bufferedScreenMercator(0,r)}static createFromScreenPoints(t,n){let r,i;if(t instanceof e.pointGeometry||"number"==typeof t[0]){const o=e.pointGeometry.convert(t);r=[o],i=n.isPointAboveHorizon(o)}else{const o=e.pointGeometry.convert(t[0]),a=e.pointGeometry.convert(t[1]);r=[o,a],i=e.polygonizeBounds(o,a).every(e=>n.isPointAboveHorizon(e))}return new D(r,n.getCameraPoint(),i,n)}isPointQuery(){return 1===this.screenBounds.length}bufferedScreenGeometry(t){return e.polygonizeBounds(this.screenBounds[0],1===this.screenBounds.length?this.screenBounds[0]:this.screenBounds[1],t)}bufferedCameraGeometry(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,0,!1);return this.cameraPoint.y>r.y&&(this.cameraPoint.x>n.x&&this.cameraPoint.x=r.x?i[2]=this.cameraPoint:this.cameraPoint.x<=n.x&&(i[3]=this.cameraPoint)),e.bufferConvexPolygon(i,t)}bufferedCameraGeometryGlobe(t){const n=this.screenBounds[0],r=1===this.screenBounds.length?this.screenBounds[0].add(new e.pointGeometry(1,1)):this.screenBounds[1],i=e.polygonizeBounds(n,r,t),o=this.cameraPoint.clone();switch(3*((o.y>n.y)+(o.y>r.y))+((o.x>n.x)+(o.x>r.x))){case 0:i[0]=o,i[4]=o.clone();break;case 1:i.splice(1,0,o);break;case 2:i[1]=o;break;case 3:i.splice(4,0,o);break;case 5:i.splice(2,0,o);break;case 6:i[3]=o;break;case 7:i.splice(3,0,o);break;case 8:i[2]=o}return i}containsTile(t,n,r,i=0){const o=t.queryPadding/n._pixelsPerMercatorPixel+1,a=r?this._bufferedCameraMercator(o,n):this._bufferedScreenMercator(o,n);let s=t.tileID.wrap+(a.unwrapped?i:0);const l=a.polygon.map(n=>e.getTilePoint(t.tileTransform,n,s));if(!e.polygonIntersectsBox(l,0,0,e.EXTENT,e.EXTENT))return;s=t.tileID.wrap+(this.screenGeometryMercator.unwrapped?i:0);const u=this.screenGeometryMercator.polygon.map(n=>e.getTileVec3(t.tileTransform,n,s)),c=u.map(t=>new e.pointGeometry(t[0],t[1])),h=n.getFreeCameraOptions().position||new e.MercatorCoordinate(0,0,0),d=e.getTileVec3(t.tileTransform,h,s),f=u.map(t=>{const n=e.sub(t,t,d);return e.normalize(n,n),new e.Ray(d,n)}),p=O(t,1,n.zoom)*n._pixelsPerMercatorPixel;return{queryGeometry:this,tilespaceGeometry:c,tilespaceRays:f,bufferedTilespaceGeometry:l,bufferedTilespaceBounds:(m=e.getBounds(l),m.min.x=e.clamp(m.min.x,0,e.EXTENT),m.min.y=e.clamp(m.min.y,0,e.EXTENT),m.max.x=e.clamp(m.max.x,0,e.EXTENT),m.max.y=e.clamp(m.max.y,0,e.EXTENT),m),tile:t,tileID:t.tileID,pixelToTileUnitsFactor:p};var m}_bufferedScreenMercator(e,t){const n=B(e);if(this._screenRaycastCache[n])return this._screenRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedScreenGeometry(e),t):{polygon:this.bufferedScreenGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._screenRaycastCache[n]=r,r}}_bufferedCameraMercator(e,t){const n=B(e);if(this._cameraRaycastCache[n])return this._cameraRaycastCache[n];{let r;return r="globe"===t.projection.name?this._projectAndResample(this.bufferedCameraGeometryGlobe(e),t):{polygon:this.bufferedCameraGeometry(e).map(e=>t.pointCoordinate3D(e)),unwrapped:!0},this._cameraRaycastCache[n]=r,r}}_projectAndResample(t,n){const r=function(t,n){const r=e.multiply([],n.pixelMatrix,n.globeMatrix),i=[0,-e.GLOBE_RADIUS,0,1],o=[0,e.GLOBE_RADIUS,0,1],a=[0,0,0,1];e.transformMat4$1(i,i,r),e.transformMat4$1(o,o,r),e.transformMat4$1(a,a,r);const s=new e.pointGeometry(i[0]/i[3],i[1]/i[3]),l=new e.pointGeometry(o[0]/o[3],o[1]/o[3]),u=e.polygonContainsPoint(t,s)&&i[3]1?L(t.slice(0,d),n):[],m=dnew e.pointGeometry(R(t.x),t.y)),m=m.map(t=>new e.pointGeometry(R(t.x),t.y));const _=[...p];0===_.length&&_.push(m[m.length-1]);const g=e.number(_[_.length-1].y,(0===m.length?p[0]:m[0]).y,f);let y;return y=u?[new e.pointGeometry(0,g),new e.pointGeometry(0,0),new e.pointGeometry(1,0),new e.pointGeometry(1,g)]:[new e.pointGeometry(1,g),new e.pointGeometry(1,1),new e.pointGeometry(0,1),new e.pointGeometry(0,g)],_.push(...y),0===m.length?_.push(p[0]):_.push(...m),{polygon:_.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:!1}}(t,n);if(r)return r;const i=function(t,n){let r=!1,i=-1/0,o=0;for(let e=0;ei&&(i=t[e].x,o=e);for(let e=0;e.5&&(i.x{e.x-=1}),{polygon:t,unwrapped:r}}(L(t,n).map(t=>new e.pointGeometry(R(t.x),t.y)),n);return{polygon:i.polygon.map(t=>new e.MercatorCoordinate(t.x,t.y)),unwrapped:i.unwrapped}}}function L(t,n){return e.resample(t,e=>{const t=n.pointCoordinate3D(e);e.x=t.x,e.y=t.y},1/256)}function R(e){return e<0?1+e%1:e%1}function B(e){return 100*e|0}function F(t,n,r,i,o){const a=function(r,i){if(r)return o(r);if(i){t.url&&i.tiles&&t.tiles&&delete t.tiles;const r=e.pick(e.extend(i,t),["tiles","minzoom","maxzoom","attribution","mapbox_logo","bounds","scheme","tileSize","encoding"]);i.vector_layers&&(r.vectorLayers=i.vector_layers,r.vectorLayerIds=r.vectorLayers.map(e=>e.id)),r.tiles=n.canonicalizeTileset(r,t.url),o(null,r)}};return t.url?e.getJSON(n.transformRequest(n.normalizeSourceURL(t.url,null,r,i),e.ResourceType.Source),a):e.exported.frame(()=>a(null,t))}class j{constructor(t,n,r){this.bounds=e.LngLatBounds.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=r||24}validateBounds(e){return Array.isArray(e)&&4===e.length?[Math.max(-180,e[0]),Math.max(-90,e[1]),Math.min(180,e[2]),Math.min(90,e[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),r=Math.floor(e.mercatorXfromLng(this.bounds.getWest())*n),i=Math.floor(e.mercatorYfromLat(this.bounds.getNorth())*n),o=Math.ceil(e.mercatorXfromLng(this.bounds.getEast())*n),a=Math.ceil(e.mercatorYfromLat(this.bounds.getSouth())*n);return t.x>=r&&t.x=i&&t.y{this._tileJSONRequest=null,this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(e.extend(this,n),n.bounds&&(this.tileBounds=new j(n.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(n.tiles),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(e){this.map=e,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}serialize(){return e.extend({},this._options)}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const r=e.exported.devicePixelRatio>=2,i=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),r,this.tileSize);t.request=e.getImage(this.map._requestManager.transformRequest(i,e.ResourceType.Tile),(r,i,o,a)=>(delete t.request,t.aborted?(t.state="unloaded",n(null)):r?(t.state="errored",n(r)):i?(this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:o,expires:a}),t.setTexture(i,this.map.painter),t.state="loaded",e.cacheEntryPossiblyAdded(this.dispatcher),void n(null)):n(null)))}static loadTileData(e,t,n){e.setTexture(t,n)}static unloadTileData(e,t){e.texture&&t.saveTileTexture(e.texture)}abortTile(e,t){e.request&&(e.request.cancel(),delete e.request),t()}unloadTile(e,t){e.texture&&this.map.painter.saveTileTexture(e.texture),t()}hasTransition(){return!1}}let Me;function Ae(t,n,r,i,o,a,s,l){const u=[t,r,o,n,i,a,1,1,1],c=[s,l,1],h=e.adjoint([],u),[d,f,p]=e.transformMat3(c,c,e.transpose(h,h));return e.multiply$1(u,[d,0,0,0,f,0,0,0,p],u)}class Ie extends e.Evented{constructor(e,t,n,r){super(),this.id=e,this.dispatcher=n,this.coordinates=t.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(r),this.options=t,this._dirty=!1}load(t,n){this._loaded=n||!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this.url=this.options.url,this._imageRequest=e.getImage(this.map._requestManager.transformRequest(this.url,e.ResourceType.Image),(n,r)=>{if(this._imageRequest=null,this._loaded=!0,n)this.fire(new e.ErrorEvent(n));else if(r){const{HTMLImageElement:n}=e.window;this.image=r instanceof n?e.exported.getImageData(r):r,this._dirty=!0,this.width=this.image.width,this.height=this.image.height,t&&(this.coordinates=t),this._finishLoading()}})}loaded(){return this._loaded}updateImage(e){return this.image&&e.url?(this._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}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(e){this.map=e,this.load()}onRemove(){this._imageRequest&&(this._imageRequest.cancel(),this._imageRequest=null),this.texture&&this.texture.destroy()}setCoordinates(t){this.coordinates=t,this._boundsArray=void 0;const n=t.map(e.MercatorCoordinate.fromLngLat);return this.tileID=function(t){let n=1/0,r=1/0,i=-1/0,o=-1/0;for(const e of t)n=Math.min(n,e.x),r=Math.min(r,e.y),i=Math.max(i,e.x),o=Math.max(o,e.y);const a=Math.max(i-n,o-r),s=Math.max(0,Math.floor(-Math.log(a)/Math.LN2)),l=Math.pow(2,s);return new e.CanonicalTileID(s,Math.floor((n+i)/2*l),Math.floor((r+o)/2*l))}(n),this.minzoom=this.maxzoom=this.tileID.z,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"})),this}_clear(){this._boundsArray=void 0}_prepareData(t){for(const e in this.tiles){const t=this.tiles[e];"loaded"!==t.state&&(t.state="loaded",t.texture=this.texture)}if(this._boundsArray)return;const n=e.tileTransform(this.tileID,this.map.transform.projection),[r,i,o,a]=this.coordinates.map(t=>{const r=n.projection.project(t[0],t[1]);return e.getTilePoint(n,r)._round()});this.perspectiveTransform=function(t,n,r,i,o,a,s,l,u,c){const h=Ae(0,0,t,0,0,n,t,n),d=Ae(r,i,o,a,s,l,u,c);return e.multiply$1(d,e.adjoint(h,h),d),[d[6]/d[8]*t/e.EXTENT,d[7]/d[8]*n/e.EXTENT]}(this.width,this.height,r.x,r.y,i.x,i.y,a.x,a.y,o.x,o.y);const s=this._boundsArray=new e.StructArrayLayout4i8;s.emplaceBack(r.x,r.y,0,0),s.emplaceBack(i.x,i.y,e.EXTENT,0),s.emplaceBack(a.x,a.y,0,e.EXTENT),s.emplaceBack(o.x,o.y,e.EXTENT,e.EXTENT),this.boundsBuffer&&this.boundsBuffer.destroy(),this.boundsBuffer=t.createVertexBuffer(s,e.boundsAttributes.members),this.boundsSegments=e.SegmentVector.simpleSegment(0,0,4,2)}prepare(){if(0===Object.keys(this.tiles).length||!this.image)return;const t=this.map.painter.context,n=t.gl;this._dirty&&(this.texture?this.texture.update(this.image):(this.texture=new e.Texture(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE)),this._dirty=!1),this._prepareData(t)}loadTile(e,t){this.tileID&&this.tileID.equals(e.tileID.canonical)?(this.tiles[String(e.tileID.wrap)]=e,e.buckets={},t(null)):(e.state="errored",t(null))}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}const Pe={vector:class extends e.Evented{constructor(t,n,r,i){if(super(),this.id=t,this.dispatcher=r,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,e.extend(this,e.pick(n,["url","scheme","tileSize","promoteId"])),this._options=e.extend({type:"vector"},n),this._collectResourceTiming=n.collectResourceTiming,512!==this.tileSize)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(i),this._tileWorkers={},this._deduped=new e.DedupedRequest}load(t){this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"}));const n=Array.isArray(this.map._language)?this.map._language.join():this.map._language,r=this.map._worldview;this._tileJSONRequest=F(this._options,this.map._requestManager,n,r,(i,o)=>{this._tileJSONRequest=null,this._loaded=!0,i?(n&&console.warn("Ensure that your requested language string is a valid BCP-47 code or list of codes. Found: "+n),r&&2!==r.length&&console.warn("Requested worldview strings must be a valid ISO alpha-2 code. Found: "+r),this.fire(new e.ErrorEvent(i))):o&&(e.extend(this,o),o.bounds&&(this.tileBounds=new j(o.bounds,this.minzoom,this.maxzoom)),e.postTurnstileEvent(o.tiles,this.map._requestManager._customAccessToken),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))),t&&t(i)})}loaded(){return this._loaded}hasTile(e){return!this.tileBounds||this.tileBounds.contains(e.canonical)}onAdd(e){this.map=e,this.load()}reload(){this.cancelTileJSONRequest(),this.load(()=>{const e=this.map.style._getSourceCaches(this.id);for(const t of e)t.clearTiles()})}setSourceProperty(e){e(),this.reload()}setTiles(e){return this._options.tiles=e,this.reload(),this}setUrl(e){return this.url=e,this._options.url=e,this.reload(),this}onRemove(){this.cancelTileJSONRequest()}serialize(){return e.extend({},this._options)}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme)),i={request:this.map._requestManager.transformRequest(r,e.ResourceType.Tile),data:void 0,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId,isSymbolTile:t.isSymbolTile};if(i.request.collectResourceTiming=this._collectResourceTiming,t.actor&&"expired"!==t.state)"loading"===t.state?t.reloadCallback=n:t.request=t.actor.send("reloadTile",i,o.bind(this));else if(t.actor=this._tileWorkers[r]=this._tileWorkers[r]||this.dispatcher.getActor(),this.dispatcher.ready)t.request=t.actor.send("loadTile",i,o.bind(this),void 0,!0);else{const n=e.loadVectorTile.call({deduped:this._deduped},i,(e,n)=>{e||!n?o.call(this,e):(i.data={cacheControl:n.cacheControl,expires:n.expires,rawData:n.rawData.slice(0)},t.actor&&t.actor.send("loadTile",i,o.bind(this),void 0,!0))},!0);t.request={cancel:n}}function o(r,i){return delete t.request,t.aborted?n(null):r&&404!==r.status?n(r):(i&&i.resourceTiming&&(t.resourceTiming=i.resourceTiming),this.map._refreshExpiredTiles&&i&&t.setExpiryData(i),t.loadVectorData(i,this.map.painter),e.cacheEntryPossiblyAdded(this.dispatcher),n(null),void(t.reloadCallback&&(this.loadTile(t,t.reloadCallback),t.reloadCallback=null)))}}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.actor&&e.actor.send("abortTile",{uid:e.uid,type:this.type,source:this.id})}unloadTile(e){e.unloadVectorData(),e.actor&&e.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}hasTransition(){return!1}afterUpdate(){this._tileWorkers={}}cancelTileJSONRequest(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}},raster:Ce,"raster-dem":class extends Ce{constructor(t,n,r,i){super(t,n,r,i),this.type="raster-dem",this.maxzoom=22,this._options=e.extend({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox"}loadTile(t,n){const r=this.map._requestManager.normalizeTileURL(t.tileID.canonical.url(this.tiles,this.scheme),!1,this.tileSize);function i(e,r){e&&(t.state="errored",n(e)),r&&(t.dem=r,t.dem.onDeserialize(),t.needsHillshadePrepare=!0,t.needsDEMTextureUpload=!0,t.state="loaded",n(null))}t.request=e.getImage(this.map._requestManager.transformRequest(r,e.ResourceType.Tile),function(r,o,a,s){if(delete t.request,t.aborted)t.state="unloaded",n(null);else if(r)t.state="errored",n(r);else if(o){this.map._refreshExpiredTiles&&t.setExpiryData({cacheControl:a,expires:s});const n=e.window.ImageBitmap&&o instanceof e.window.ImageBitmap&&(null==Me&&(Me=e.window.OffscreenCanvas&&new e.window.OffscreenCanvas(1,1).getContext("2d")&&"function"==typeof e.window.createImageBitmap),Me),r=1-(o.width-e.prevPowerOfTwo(o.width))/2;r<1||t.neighboringTiles||(t.neighboringTiles=this._getNeighboringTiles(t.tileID));const l=n?o:e.exported.getImageData(o,r),u={uid:t.uid,coord:t.tileID,source:this.id,rawImageData:l,encoding:this.encoding,padding:r};t.actor&&"expired"!==t.state||(t.actor=this.dispatcher.getActor(),t.actor.send("loadDEMTile",u,i.bind(this),void 0,!0))}}.bind(this))}_getNeighboringTiles(t){const n=t.canonical,r=Math.pow(2,n.z),i=(n.x-1+r)%r,o=0===n.x?t.wrap-1:t.wrap,a=(n.x+1+r)%r,s=n.x+1===r?t.wrap+1:t.wrap,l={};return l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y).key]={backfilled:!1},n.y>0&&(l[new e.OverscaledTileID(t.overscaledZ,o,n.z,i,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},l[new e.OverscaledTileID(t.overscaledZ,s,n.z,a,n.y-1).key]={backfilled:!1}),n.y+1{if(this._loaded=!0,this._pendingLoad=null,t)this.fire(new e.ErrorEvent(t));else{const t={dataType:"source",sourceDataType:this._metadataFired?"content":"metadata"};this._collectResourceTiming&&n&&n.resourceTiming&&n.resourceTiming[this.id]&&(t.resourceTiming=n.resourceTiming[this.id]),this.fire(new e.Event("data",t)),this._metadataFired=!0}this._coalesce&&(this._updateWorkerData(),this._coalesce=!1)})}loaded(){return this._loaded}loadTile(t,n){const r=t.actor?"reloadTile":"loadTile";t.actor=this.actor,t.request=this.actor.send(r,{type:this.type,uid:t.uid,tileID:t.tileID,tileZoom:t.tileZoom,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:e.exported.devicePixelRatio,showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId},(e,i)=>(delete t.request,t.unloadVectorData(),t.aborted?n(null):e?n(e):(t.loadVectorData(i,this.map.painter,"reloadTile"===r),n(null))),void 0,"loadTile"===r)}abortTile(e){e.request&&(e.request.cancel(),delete e.request),e.aborted=!0}unloadTile(e){e.unloadVectorData(),this.actor.send("removeTile",{uid:e.uid,type:this.type,source:this.id})}onRemove(){this._pendingLoad&&this._pendingLoad.cancel()}serialize(){return e.extend({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}},video:class extends Ie{constructor(e,t,n,r){super(e,t,n,r),this.roundZoom=!0,this.type="video",this.options=t}load(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,e.ResourceType.Source).url);e.getVideo(this.urls,(t,n)=>{this._loaded=!0,t?this.fire(new e.ErrorEvent(t)):n&&(this.video=n,this.video.loop=!0,this.video.setAttribute("playsinline",""),this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading())})}pause(){this.video&&this.video.pause()}play(){this.video&&this.video.play()}seek(t){if(this.video){const n=this.video.seekable;tn.end(0)?this.fire(new e.ErrorEvent(new e.ValidationError("sources."+this.id,null,`Playback for this video can be set only between the ${n.start(0)} and ${n.end(0)}-second mark.`))):this.video.currentTime=t}}getVideo(){return this.video}onAdd(e){this.map||(this.map=e,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(0===Object.keys(this.tiles).length||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.texture?this.video.paused||(this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),n.texSubImage2D(n.TEXTURE_2D,0,0,0,n.RGBA,n.UNSIGNED_BYTE,this.video)):(this.texture=new e.Texture(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE),this.width=this.video.videoWidth,this.height=this.video.videoHeight),this._prepareData(t)}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}},image:Ie,canvas:class extends Ie{constructor(t,n,r,i){super(t,n,r,i),n.coordinates?Array.isArray(n.coordinates)&&4===n.coordinates.length&&!n.coordinates.some(e=>!Array.isArray(e)||2!==e.length||e.some(e=>"number"!=typeof e))||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "coordinates"'))),n.animate&&"boolean"!=typeof n.animate&&this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'optional "animate" property must be a boolean value'))),n.canvas?"string"==typeof n.canvas||n.canvas instanceof e.window.HTMLCanvasElement||this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'"canvas" must be either a string representing the ID of the canvas element from which to read, or an HTMLCanvasElement instance'))):this.fire(new e.ErrorEvent(new e.ValidationError("sources."+t,null,'missing required property "canvas"'))),this.options=n,this.animate=void 0===n.animate||n.animate}load(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof e.window.HTMLCanvasElement?this.options.canvas:e.window.document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new e.ErrorEvent(new Error("Canvas dimensions cannot be less than or equal to zero."))):(this.play=function(){this._playing=!0,this.map.triggerRepaint()},this.pause=function(){this._playing&&(this.prepare(),this._playing=!1)},this._finishLoading())}getCanvas(){return this.canvas}onAdd(e){this.map=e,this.load(),this.canvas&&this.animate&&this.play()}onRemove(){this.pause()}prepare(){let t=!1;if(this.canvas.width!==this.width&&(this.width=this.canvas.width,t=!0),this.canvas.height!==this.height&&(this.height=this.canvas.height,t=!0),this._hasInvalidDimensions())return;if(0===Object.keys(this.tiles).length)return;const n=this.map.painter.context;this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new e.Texture(n,this.canvas,n.gl.RGBA,{premultiply:!0}),this._prepareData(n)}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const e of[this.canvas.width,this.canvas.height])if(isNaN(e)||e<=0)return!0;return!1}},custom:class extends e.Evented{constructor(t,n,r,i){super(),this.id=t,this.type="custom",this._dataType="raster",this._dispatcher=r,this._implementation=n,this.setEventedParent(i),this.scheme="xyz",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this._loaded=!1,this.roundZoom=!0,this._implementation||this.fire(new e.ErrorEvent(new Error(`Missing implementation for ${this.id} custom source`))),this._implementation.loadTile||this.fire(new e.ErrorEvent(new Error(`Missing loadTile implementation for ${this.id} custom source`))),this._implementation.bounds&&(this.tileBounds=new j(this._implementation.bounds,this.minzoom,this.maxzoom)),n.update=this._update.bind(this),n.clearTiles=this._clearTiles.bind(this),n.coveringTiles=this._coveringTiles.bind(this),e.extend(this,e.pick(n,["dataType","scheme","minzoom","maxzoom","tileSize","attribution","minTileCacheSize","maxTileCacheSize"]))}serialize(){return e.pick(this,["type","scheme","minzoom","maxzoom","tileSize","attribution"])}load(){this._loaded=!0,this.fire(new e.Event("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}loaded(){return this._loaded}onAdd(t){this._map=t,this._loaded=!1,this.fire(new e.Event("dataloading",{dataType:"source"})),this._implementation.onAdd&&this._implementation.onAdd(t),this.load()}onRemove(e){this._implementation.onRemove&&this._implementation.onRemove(e)}hasTile(e){if(this._implementation.hasTile){const{x:t,y:n,z:r}=e.canonical;return this._implementation.hasTile({x:t,y:n,z:r})}return!this.tileBounds||this.tileBounds.contains(e.canonical)}loadTile(t,n){const{x:r,y:i,z:o}=t.tileID.canonical,a=new e.window.AbortController;t.request=Promise.resolve(this._implementation.loadTile({x:r,y:i,z:o},{signal:a.signal})).then(function(r){return delete t.request,t.aborted?(t.state="unloaded",n(null)):void 0===r?(t.state="errored",n(null)):null===r?(this.loadTileData(t,{width:this.tileSize,height:this.tileSize,data:null}),t.state="loaded",n(null)):function(t){return t instanceof e.window.ImageData||t instanceof e.window.HTMLCanvasElement||t instanceof e.window.ImageBitmap||t instanceof e.window.HTMLImageElement}(r)?(this.loadTileData(t,r),t.state="loaded",void n(null)):(t.state="errored",n(new Error(`Can't infer data type for ${this.id}, only raster data supported at the moment`)))}.bind(this)).catch(e=>{20!==e.code&&(t.state="errored",n(e))}),t.request.cancel=()=>a.abort()}loadTileData(e,t){Ce.loadTileData(e,t,this._map.painter)}unloadTileData(e){Ce.unloadTileData(e,this._map.painter)}unloadTile(e,t){if(this.unloadTileData(e),this._implementation.unloadTile){const{x:t,y:n,z:r}=e.tileID.canonical;this._implementation.unloadTile({x:t,y:n,z:r})}t()}abortTile(e,t){e.request&&e.request.cancel&&(e.request.cancel(),delete e.request),t()}hasTransition(){return!1}_coveringTiles(){return this._map.transform.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,roundZoom:this.roundZoom}).map(e=>({x:e.canonical.x,y:e.canonical.y,z:e.canonical.z}))}_clearTiles(){this._map.style._clearSource(this.id)}_update(){this.fire(new e.Event("data",{dataType:"source",sourceDataType:"content"}))}}},ze=function(t,n,r,i){const o=new Pe[n.type](t,n,r,i);if(o.id!==t)throw new Error(`Expected Source id to be ${t} instead of ${o.id}`);return e.bindAll(["load","abort","unload","serialize","prepare"],o),o};function Oe(t,n){const r=e.identity([]);return e.scale(r,r,[.5*t.width,.5*-t.height,1]),e.translate(r,r,[1,-1,0]),e.multiply(r,r,t.calculateProjMatrix(n.toUnwrapped())),Float32Array.from(r)}function De(e,t,n,r,i,o,a,s=!1){const l=e.tilesIn(r,a,s);l.sort(Re);const u=[];for(const r of l)u.push({wrappedTileID:r.tile.tileID.wrapped().key,queryResults:r.tile.queryRenderedFeatures(t,n,e._state,r,i,o,Oe(e.transform,r.tile.tileID),s)});const c=function(e){const t={},n={};for(const r of e){const e=r.queryResults,i=r.wrappedTileID,o=n[i]=n[i]||{};for(const n in e){const r=e[n],i=o[n]=o[n]||{},a=t[n]=t[n]||[];for(const e of r)i[e.featureIndex]||(i[e.featureIndex]=!0,a.push(e))}}return t}(u);for(const t in c)c[t].forEach(t=>{const n=t.feature,r=n.layer;r&&"background"!==r.type&&"sky"!==r.type&&(n.source=r.source,r["source-layer"]&&(n.sourceLayer=r["source-layer"]),n.state=void 0!==n.id?e.getFeatureState(r["source-layer"],n.id):{})});return c}function Le(e,t){const n=e.getRenderableIds().map(t=>e.getTileByID(t)),r=[],i={};for(let e=0;e{e.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Fe]}numActive(){return Object.keys(this.active).length}}let Ne;function Ue(){return Ne||(Ne=new je),Ne}function Ve(t,n){const r={};for(const e in t)"ref"!==e&&(r[e]=t[e]);return e.refProperties.forEach(e=>{e in n&&(r[e]=n[e])}),r}function Ge(e){e=e.slice();const t=Object.create(null);for(let n=0;n0?(i-a)/s:0;return this.points[o].mult(1-l).add(this.points[n].mult(l))}}class Qe{constructor(e,t,n){const r=this.boxCells=[],i=this.circleCells=[];this.xCellCount=Math.ceil(e/n),this.yCellCount=Math.ceil(t/n);for(let e=0;ethis.width||r<0||t>this.height)return!i&&[];const a=[];if(e<=0&&t<=0&&this.width<=n&&this.height<=r){if(i)return!0;for(let e=0;e0:a}_queryCircle(e,t,n,r,i){const o=e-n,a=e+n,s=t-n,l=t+n;if(a<0||o>this.width||l<0||s>this.height)return!r&&[];const u=[];return this._forEachCell(o,s,a,l,this._queryCellCircle,u,{hitTest:r,circle:{x:e,y:t,radius:n},seenUids:{box:{},circle:{}}},i),r?u.length>0:u}query(e,t,n,r,i){return this._query(e,t,n,r,!1,i)}hitTest(e,t,n,r,i){return this._query(e,t,n,r,!0,i)}hitTestCircle(e,t,n,r){return this._queryCircle(e,t,n,!0,r)}_queryCell(e,t,n,r,i,o,a,s){const l=a.seenUids,u=this.boxCells[i];if(null!==u){const i=this.bboxes;for(const c of u)if(!l.box[c]){l.box[c]=!0;const u=4*c;if(e<=i[u+2]&&t<=i[u+3]&&n>=i[u+0]&&r>=i[u+1]&&(!s||s(this.boxKeys[c]))){if(a.hitTest)return o.push(!0),!0;o.push({key:this.boxKeys[c],x1:i[u],y1:i[u+1],x2:i[u+2],y2:i[u+3]})}}}const c=this.circleCells[i];if(null!==c){const i=this.circles;for(const u of c)if(!l.circle[u]){l.circle[u]=!0;const c=3*u;if(this._circleAndRectCollide(i[c],i[c+1],i[c+2],e,t,n,r)&&(!s||s(this.circleKeys[u]))){if(a.hitTest)return o.push(!0),!0;{const e=i[c],t=i[c+1],n=i[c+2];o.push({key:this.circleKeys[u],x1:e-n,y1:t-n,x2:e+n,y2:t+n})}}}}}_queryCellCircle(e,t,n,r,i,o,a,s){const l=a.circle,u=a.seenUids,c=this.boxCells[i];if(null!==c){const e=this.bboxes;for(const t of c)if(!u.box[t]){u.box[t]=!0;const n=4*t;if(this._circleAndRectCollide(l.x,l.y,l.radius,e[n+0],e[n+1],e[n+2],e[n+3])&&(!s||s(this.boxKeys[t])))return o.push(!0),!0}}const h=this.circleCells[i];if(null!==h){const e=this.circles;for(const t of h)if(!u.circle[t]){u.circle[t]=!0;const n=3*t;if(this._circlesCollide(e[n],e[n+1],e[n+2],l.x,l.y,l.radius)&&(!s||s(this.circleKeys[t])))return o.push(!0),!0}}}_forEachCell(e,t,n,r,i,o,a,s){const l=this._convertToXCellCoord(e),u=this._convertToYCellCoord(t),c=this._convertToXCellCoord(n),h=this._convertToYCellCoord(r);for(let d=l;d<=c;d++)for(let l=u;l<=h;l++)if(i.call(this,e,t,n,r,this.xCellCount*l+d,o,a,s))return}_convertToXCellCoord(e){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(e*this.xScale)))}_convertToYCellCoord(e){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(e*this.yScale)))}_circlesCollide(e,t,n,r,i,o){const a=r-e,s=i-t,l=n+o;return l*l>a*a+s*s}_circleAndRectCollide(e,t,n,r,i,o,a){const s=(o-r)/2,l=Math.abs(e-(r+s));if(l>s+n)return!1;const u=(a-i)/2,c=Math.abs(t-(i+u));if(c>u+n)return!1;if(l<=s||c<=u)return!0;const h=l-s,d=c-u;return h*h+d*d<=n*n}}const et=Math.tan(85*Math.PI/180);function tt(t,n,r,i,o,a,s){const l=e.create();if(r)if("globe"===a.name){const t=e.calculateGlobeLabelMatrix(o,n);e.multiply(l,l,t)}else{const t=y([],s);l[0]=t[0],l[1]=t[1],l[4]=t[2],l[5]=t[3],i||e.rotateZ(l,l,o.angle)}else e.multiply(l,o.labelPlaneMatrix,t);return l}function nt(e,t,n,r,i,o,a){const s=tt(e,t,n,r,i,o,a);return"globe"===o.name&&n||(s[2]=s[6]=s[10]=s[14]=0),s}function rt(t,n,r,i,o,a,s){if(r){if("globe"===a.name){const l=tt(t,n,r,i,o,a,s);return e.invert(l,l),e.multiply(l,t,l),l}{const n=e.clone(t),r=e.identity([]);return r[0]=s[0],r[1]=s[1],r[4]=s[2],r[5]=s[3],e.multiply(n,n,r),i||e.rotateZ(n,n,-o.angle),n}}return o.glCoordMatrix}function it(t,n,r,i){const o=[t,n,r,1];r?e.transformMat4$1(o,o,i):mt(o,o,i);const a=o[3];return o[0]/=a,o[1]/=a,o[2]/=a,o}function ot(e,t){return Math.min(.5+e/t*.5,1.5)}function at(e,t){const n=e[0]/e[3],r=e[1]/e[3];return n>=-t[0]&&n<=t[0]&&r>=-t[1]&&r<=t[1]}function st(t,n,r,i,o,a,s,l,u,c){const h=r.transform,d=i?t.textSizeData:t.iconSizeData,f=e.evaluateSizeForZoom(d,r.transform.zoom),p="globe"===h.projection.name,m=[256/r.width*2+1,256/r.height*2+1],_=i?t.text.dynamicLayoutVertexArray:t.icon.dynamicLayoutVertexArray;_.clear();let g=null;p&&(g=i?t.text.globeExtVertexArray:t.icon.globeExtVertexArray);const y=t.lineVertexArray,v=i?t.text.placedSymbolArray:t.icon.placedSymbolArray,x=r.transform.width/r.transform.height;let b,w=!1;for(let i=0;iMath.abs(r)?{useVertical:!0}:t===e.WritingMode.vertical?i>0?{needsFlipping:!0}:null:0!==n&&function(e,t){return 0===e||Math.abs(t/e)>et}(r,i)?1===n?{needsFlipping:!0}:null:r<0?{needsFlipping:!0}:null}function ct(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y,v){const x=n/24,b=t.lineOffsetX*x,w=t.lineOffsetY*x,{lineStartIndex:E,glyphStartIndex:T,numGlyphs:S,segment:k,writingMode:C,flipState:M}=t,A=E+t.lineLength,I=t=>{if(h){const[n,r,i]=t.up,o=c.length;e.updateGlobeVertexNormal(h,o+0,n,r,i),e.updateGlobeVertexNormal(h,o+1,n,r,i),e.updateGlobeVertexNormal(h,o+2,n,r,i),e.updateGlobeVertexNormal(h,o+3,n,r,i)}const[n,r,i]=t.point;e.addDynamicAttributes(c,n,r,i,t.angle)};if(S>1){const e=lt(x,l,b,w,r,d,f,t,u,a,p,_,!1,g,y,v);if(!e)return{notEnoughRoom:!0};if(i&&!r){let[n,r,i]=e.first.point,[o,a,l]=e.last.point;[n,r]=it(n,r,i,s),[o,a]=it(o,a,l,s);const u=ut(C,M,(o-n)*m,a-r);if(t.flipState=u&&u.needsFlipping?1:2,u)return u}I(e.first);for(let e=T+1;e0?a:dt(f,i,n,1,o,void 0,g,y.canonical),l=ut(C,M,(s[0]-n[0])*m,s[1]-n[1]);if(t.flipState=l&&l.needsFlipping?1:2,l)return l}const n=ft(x*l.getoffsetX(T),b,w,r,d,f,k,E,A,u,a,p,_,!1,!1,g,y,v);if(!n)return{notEnoughRoom:!0};I(n)}return{}}function ht(e,t,n,r,i){const{x:o,y:a,z:s}=r.projectTilePoint(e.x,e.y,t);if(!i)return it(o,a,s,n);const[l,u,c]=i(e);return it(o+l,a+u,s+c,n)}function dt(t,n,r,i,o,a,s,l){const u=ht(t.sub(n)._unit()._add(t),l,o,s,a);return e.sub(u,r,u),e.normalize(u,u),e.scaleAndAdd(u,r,u,i)}function ft(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g,y){const v=i?t-n:t+n;let x=v>0?1:-1,b=0;i&&(x*=-1,b=Math.PI),x<0&&(b+=Math.PI);let w=l+s+(x>0?0:1)|0,E=o,T=o,S=0,k=0;const C=Math.abs(v),M=[],A=[];let I=a,P=I;const z=()=>dt(P,I,T,C-S+1,h,f,_,g.canonical);for(;S+k<=C;){if(w+=x,w=u)return null;if(T=E,P=I,M.push(T),p&&A.push(P),I=new e.pointGeometry(c.getx(w),c.gety(w)),E=d[w],!E){const e=ht(I,g.canonical,h,_,f);E=e[3]>0?d[w]=e:z()}S+=k,k=e.distance(T,E)}m&&f&&(d[w]&&(E=z(),k=e.distance(T,E)),d[w]=E);const O=(C-S)/k,D=I.sub(P)._mult(O)._add(P),L=e.sub([],E,T),R=e.scaleAndAdd([],T,L,O);let B=[0,0,1],F=L[0],j=L[1];if(y&&(B=_.upVector(g.canonical,D.x,D.y),0!==B[0]||0!==B[1]||1!==B[2])){const t=[B[2],0,-B[0]],n=e.cross([],B,t);e.normalize(t,t),e.normalize(n,n),F=e.dot(L,t),j=e.dot(L,n)}if(r){const t=e.cross([],B,L);e.normalize(t,t),e.scaleAndAdd(R,R,t,r*x)}const N=b+Math.atan2(j,F);return M.push(R),p&&A.push(D),{point:R,angle:N,path:M,tilePath:A,up:B}}function pt(e,t){const n=t.length,r=n+4*e;t.resize(r),t.float32.fill(-1/0,4*n,4*r)}function mt(e,t,n){const r=t[0],i=t[1];return e[0]=n[0]*r+n[4]*i+n[12],e[1]=n[1]*r+n[5]*i+n[13],e[3]=n[3]*r+n[7]*i+n[15],e}const _t=100;class gt{constructor(e,t,n=new Qe(e.width+200,e.height+200,25),r=new Qe(e.width+200,e.height+200,25)){this.transform=e,this.grid=n,this.ignoredGrid=r,this.pitchfactor=Math.cos(e._pitch)*e.cameraToCenterDistance,this.screenRightBoundary=e.width+_t,this.screenBottomBoundary=e.height+_t,this.gridRightBoundary=e.width+200,this.gridBottomBoundary=e.height+200,this.fogState=t}placeCollisionBox(e,t,n,r,i,o,a,s){let l=n.projectedAnchorX,u=n.projectedAnchorY,c=n.projectedAnchorZ;const h=n.elevation,d=n.tileID,f=e.getProjection();if(h&&d){const[e,t,r]=f.upVector(d.canonical,n.tileAnchorX,n.tileAnchorY),i=f.upVectorScale(d.canonical,this.transform.center.lat,this.transform.worldSize).metersToTile;l+=e*h*i,u+=t*h*i,c+=r*h*i}const p=this.projectAndGetPerspectiveRatio(a,l,u,c,n.tileID,"globe"===f.name||!!h||this.transform.pitch>0,f),m=o*p.perspectiveRatio,_=(n.x1*t+r.x-n.padding)*m+p.point.x,g=(n.y1*t+r.y-n.padding)*m+p.point.y,y=(n.x2*t+r.x+n.padding)*m+p.point.x,v=(n.y2*t+r.y+n.padding)*m+p.point.y,x=p.perspectiveRatio<=.55||p.occluded;return!this.isInsideGrid(_,g,y,v)||!i&&this.grid.hitTest(_,g,y,v,s)||x?{box:[],offscreen:!1,occluded:p.occluded}:{box:[_,g,y,v],offscreen:this.isOffscreen(_,g,y,v),occluded:!1}}placeCollisionCircles(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m){const _=[],g=this.transform.elevation,y=t.getProjection(),v=g?g.getAtTileOffsetFunc(m,this.transform.center.lat,this.transform.worldSize,y):null,x=new e.pointGeometry(r.tileAnchorX,r.tileAnchorY);let{x:b,y:w,z:E}=y.projectTilePoint(x.x,x.y,m.canonical);if(v){const[e,t,n]=v(x);b+=e,w+=t,E+=n}const T="globe"===y.name,S=this.projectAndGetPerspectiveRatio(s,b,w,E,m,T||!!g||this.transform.pitch>0,y),{perspectiveRatio:k}=S,C=(h?a/k:a*k)/e.ONE_EM,M=it(b,w,E,l),A=S.signedDistanceFromCamera>0?lt(C,o,r.lineOffsetX*C,r.lineOffsetY*C,!1,M,x,r,i,l,{},g&&!h?v:null,h&&!!g,y,m,h):null;let I=!1,P=!1,z=!0;if(A&&!S.occluded){const t=.5*f*k+p,r=new e.pointGeometry(-100,-100),i=new e.pointGeometry(this.screenRightBoundary,this.screenBottomBoundary),o=new Je,{first:a,last:s}=A,l=a.path.length;let h=[];for(let e=l-1;e>=1;e--)h.push(a.path[e]);for(let e=1;e(v&&!T&&(n=v(re[3]<=0)&&(h=[]));let g=[];if(h.length>0){let t=1/0,n=-1/0,o=1/0,a=-1/0;for(const e of h)t=Math.min(t,e[0]),o=Math.min(o,e[1]),n=Math.max(n,e[0]),a=Math.max(a,e[1]);n>=r.x&&t<=i.x&&a>=r.y&&o<=i.y&&(g=[h.map(t=>new e.pointGeometry(t[0],t[1]))],(ti.x||oi.y)&&(g=e.clipLine(g,r.x,r.y,i.x,i.y)))}for(const e of g){o.reset(e,.25*t);let r=0;r=o.length<=.5*t?1:Math.ceil(o.paddedLength/m)+1;for(let e=0;e0){e.transformMat4$1(l,l,t);const a="globe"===s.name;this.fogState&&o&&!a&&(u=function(t,n,r,i,o,a){const s=a.calculateFogTileMatrix(o),l=[n,r,i];return e.transformMat4(l,l,s),C(t,l,a.pitch,a._fov)}(this.fogState,n,r,i,o.toUnwrapped(),this.transform)>.9)}else mt(l,l,t);const c=l[3];return{point:new e.pointGeometry((l[0]/c+1)/2*this.transform.width+_t,(-l[1]/c+1)/2*this.transform.height+_t),perspectiveRatio:Math.min(.5+this.transform.getCameraToCenterDistance(s)/c*.5,1.5),signedDistanceFromCamera:c,occluded:a&&l[2]>c||u}}isOffscreen(e,t,n,r){return n<_t||e>=this.screenRightBoundary||r<_t||t>this.screenBottomBoundary}isInsideGrid(e,t,n,r){return n>=0&&e=0&&te.collisionGroupID===t}}return this.collisionGroups[e]}}function Ct(t,n,r,i,o){const{horizontalAlign:a,verticalAlign:s}=e.getAnchorAlignment(t),l=-(a-.5)*n,u=-(s-.5)*r,c=e.evaluateVariableOffset(t,i);return new e.pointGeometry(l+c[0]*o,u+c[1]*o)}function Mt(t,n,r,i,o){const a=new e.pointGeometry(t,n);return r&&a._rotate(i?o:-o),a}class At{constructor(e,t,n,r,i){this.transform=e.clone(),this.projection=e.projection.name,this.collisionIndex=new gt(this.transform,i),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=t,this.retainedQueryData={},this.collisionGroups=new kt(n),this.collisionCircleArrays={},this.prevPlacement=r,r&&(r.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,r,i){const o=r.getBucket(n),a=r.latestFeatureIndex;if(!o||!a||n.id!==o.layerIds[0])return;const s=o.layers[0].layout,l=r.collisionBoxArray,u=Math.pow(2,this.transform.zoom-r.tileID.overscaledZ),c=r.tileSize/e.EXTENT,h=r.tileID.toUnwrapped();this.transform.setProjection(o.projection);const d=(f=r.tileID,p=o.getProjection(),m=this.transform,p.name===this.projection?m.calculateProjMatrix(f.toUnwrapped()):yt(m,p,f));var f,p,m;const _="map"===s.get("text-pitch-alignment"),g="map"===s.get("text-rotation-alignment");n.compileFilter();const y=n.dynamicFilter(),v=n.dynamicFilterNeedsFeature(),x=this.transform.calculatePixelsToTileUnitsMatrix(r),b=nt(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);let w=null;if(_){const t=rt(d,r.tileID.canonical,_,g,this.transform,o.getProjection(),x);w=e.multiply([],this.transform.labelPlaneMatrix,t)}let E=null;y&&r.latestFeatureIndex&&(E={unwrappedTileID:h,dynamicFilter:y,dynamicFilterNeedsFeature:v,featureIndex:r.latestFeatureIndex}),this.retainedQueryData[o.bucketInstanceId]=new St(o.bucketInstanceId,a,o.sourceLayerIndex,o.index,r.tileID);const T={bucket:o,layout:s,posMatrix:d,textLabelPlaneMatrix:b,labelToScreenMatrix:w,clippingData:E,scale:u,textPixelRatio:c,holdingForFade:r.holdingForFade(),collisionBoxArray:l,partiallyEvaluatedTextSize:e.evaluateSizeForZoom(o.textSizeData,this.transform.zoom),partiallyEvaluatedIconSize:e.evaluateSizeForZoom(o.iconSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(o.sourceID)};if(i)for(const e of o.sortKeyRanges){const{sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i}=e;t.push({sortKey:n,symbolInstanceStart:r,symbolInstanceEnd:i,parameters:T})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:o.symbolInstances.length,parameters:T})}attemptAnchorPlacement(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_,g){const{textOffset0:y,textOffset1:v,crossTileID:x}=h,b=[y,v],w=Ct(e,n,r,b,i),E=this.collisionIndex.placeCollisionBox(f,i,t,Mt(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate);if(m){const e=f.getSymbolInstanceIconSize(g,this.transform.zoom,h.placedIconSymbolIndex);if(0===this.collisionIndex.placeCollisionBox(f,e,m,Mt(w.x,w.y,o,a,this.transform.angle),c,s,l,u.predicate).box.length)return}if(E.box.length>0){let t;return this.prevPlacement&&this.prevPlacement.variableOffsets[x]&&this.prevPlacement.placements[x]&&this.prevPlacement.placements[x].text&&(t=this.prevPlacement.variableOffsets[x].anchor),this.variableOffsets[x]={textOffset:b,width:n,height:r,anchor:e,textScale:i,prevAnchor:t},this.markUsedJustification(f,e,h,p),f.allowVerticalPlacement&&(this.markUsedOrientation(f,p,h),this.placedOrientations[x]=p),{shift:w,placedGlyphBoxes:E}}}placeLayerBucketPart(t,n,r,i){const{bucket:o,layout:a,posMatrix:s,textLabelPlaneMatrix:l,labelToScreenMatrix:u,clippingData:c,textPixelRatio:h,holdingForFade:d,collisionBoxArray:f,partiallyEvaluatedTextSize:p,partiallyEvaluatedIconSize:m,collisionGroup:_}=t.parameters,g=a.get("text-optional"),y=a.get("icon-optional"),v=a.get("text-allow-overlap"),x=a.get("icon-allow-overlap"),b="map"===a.get("text-rotation-alignment"),w="map"===a.get("text-pitch-alignment"),E="none"!==a.get("icon-text-fit"),T="viewport-y"===a.get("symbol-z-order");this.transform.setProjection(o.projection);let S=v&&(x||!o.hasIconData()||y),k=x&&(v||!o.hasTextData()||g);!o.collisionArrays&&f&&o.deserializeCollisionBoxes(f),r&&i&&o.updateCollisionDebugBuffers(this.transform.zoom,f);const C=(t,i,f)=>{const{crossTileID:T,numVerticalGlyphVertices:C}=t;if(c){const r={zoom:this.transform.zoom,pitch:this.transform.pitch};let i=null;if(c.dynamicFilterNeedsFeature){const e=this.retainedQueryData[o.bucketInstanceId];i=c.featureIndex.loadFeature({featureIndex:t.featureIndex,bucketIndex:e.bucketIndex,sourceLayerIndex:e.sourceLayerIndex,layoutVertexArrayOffset:0})}if(!(0,c.dynamicFilter)(r,i,this.retainedQueryData[o.bucketInstanceId].tileID.canonical,new e.pointGeometry(t.tileAnchorX,t.tileAnchorY),this.transform.calculateDistanceTileData(c.unwrappedTileID)))return this.placements[T]=new Et(!1,!1,!1,!0),void(n[T]=!0)}if(n[T])return;if(d)return void(this.placements[T]=new Et(!1,!1,!1));let M=!1,A=!1,I=!0,P=!1,z=!1,O=null,D={box:null,offscreen:null,occluded:null},L={box:null,offscreen:null,occluded:null},R=null,B=null,F=null,j=0,N=0,U=0;f.textFeatureIndex?j=f.textFeatureIndex:t.useRuntimeCollisionCircles&&(j=t.featureIndex),f.verticalTextFeatureIndex&&(N=f.verticalTextFeatureIndex);const V=e=>{e.tileID=this.retainedQueryData[o.bucketInstanceId].tileID;const t=this.transform.elevation;(t||e.elevation)&&(e.elevation=t?t.getAtTileOffset(e.tileID,e.tileAnchorX,e.tileAnchorY):0)},G=f.textBox;if(G){V(G);const n=n=>{let r=e.WritingMode.horizontal;if(o.allowVerticalPlacement&&!n&&this.prevPlacement){const e=this.prevPlacement.placedOrientations[T];e&&(this.placedOrientations[T]=e,r=e,this.markUsedOrientation(o,r,t))}return r},r=(t,n)=>{if(o.allowVerticalPlacement&&C>0&&f.verticalTextBox){for(const r of o.writingModes)if(r===e.WritingMode.vertical?(D=n(),L=D):D=t(),D&&D.box&&D.box.length)break}else D=t()};if(a.get("text-variable-anchor")){let l=a.get("text-variable-anchor");if(this.prevPlacement&&this.prevPlacement.variableOffsets[T]){const e=this.prevPlacement.variableOffsets[T];l.indexOf(e.anchor)>0&&(l=l.filter(t=>t!==e.anchor),l.unshift(e.anchor))}const u=(e,n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),u=(e.x2-e.x1)*a+2*e.padding,c=(e.y2-e.y1)*a+2*e.padding,d=E&&!x?n:null;d&&V(d);let f={box:[],offscreen:!1,occluded:!1};const g=v?2*l.length:l.length;for(let n=0;n=l.length,t,i,o,r,d,p,m);if(g&&(f=g.placedGlyphBoxes,f&&f.box&&f.box.length)){M=!0,O=g.shift;break}}return f};r(()=>u(G,f.iconBox,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return t&&V(t),o.allowVerticalPlacement&&!(D&&D.box&&D.box.length)&&C>0&&t?u(t,f.verticalIconBox,e.WritingMode.vertical):{box:null,offscreen:null,occluded:null}}),D&&(M=D.box,I=D.offscreen,P=D.occluded);const c=n(D&&D.box);if(!M&&this.prevPlacement){const e=this.prevPlacement.variableOffsets[T];e&&(this.variableOffsets[T]=e,this.markUsedJustification(o,e.anchor,t,c))}}else{const a=(n,r)=>{const a=o.getSymbolInstanceTextSize(p,t,this.transform.zoom,i),l=this.collisionIndex.placeCollisionBox(o,a,n,new e.pointGeometry(0,0),v,h,s,_.predicate);return l&&l.box&&l.box.length&&(this.markUsedOrientation(o,r,t),this.placedOrientations[T]=r),l};r(()=>a(G,e.WritingMode.horizontal),()=>{const t=f.verticalTextBox;return o.allowVerticalPlacement&&C>0&&t?(V(t),a(t,e.WritingMode.vertical)):{box:null,offscreen:null,occluded:null}}),n(D&&D.box&&D.box.length)}}if(R=D,M=R&&R.box&&R.box.length>0,I=R&&R.offscreen,P=R&&R.occluded,t.useRuntimeCollisionCircles){const n=o.text.placedSymbolArray.get(t.centerJustifiedTextSymbolIndex>=0?t.centerJustifiedTextSymbolIndex:t.verticalPlacedTextSymbolIndex),i=e.evaluateSizeForFeature(o.textSizeData,p,n),c=a.get("text-padding");B=this.collisionIndex.placeCollisionCircles(o,v,n,o.lineVertexArray,o.glyphOffsetArray,i,s,l,u,r,w,_.predicate,t.collisionCircleDiameter*i/e.ONE_EM,c,this.retainedQueryData[o.bucketInstanceId].tileID),M=v||B.circles.length>0&&!B.collisionDetected,I=I&&B.offscreen,P=B.occluded}if(f.iconFeatureIndex&&(U=f.iconFeatureIndex),f.iconBox){const n=n=>{V(n);const r=E&&O?Mt(O.x,O.y,b,w,this.transform.angle):new e.pointGeometry(0,0),i=o.getSymbolInstanceIconSize(m,this.transform.zoom,t.placedIconSymbolIndex);return this.collisionIndex.placeCollisionBox(o,i,n,r,x,h,s,_.predicate)};L&&L.box&&L.box.length&&f.verticalIconBox?(F=n(f.verticalIconBox),A=F.box.length>0):(F=n(f.iconBox),A=F.box.length>0),I=I&&F.offscreen,z=F.occluded}const q=g||0===t.numHorizontalGlyphVertices&&0===C,$=y||0===t.numIconVertices;if(q||$?$?q||(A=A&&M):M=A&&M:A=M=A&&M,M&&R&&R.box&&this.collisionIndex.insertCollisionBox(R.box,a.get("text-ignore-placement"),o.bucketInstanceId,L&&L.box&&N?N:j,_.ID),A&&F&&this.collisionIndex.insertCollisionBox(F.box,a.get("icon-ignore-placement"),o.bucketInstanceId,U,_.ID),B&&(M&&this.collisionIndex.insertCollisionCircles(B.circles,a.get("text-ignore-placement"),o.bucketInstanceId,j,_.ID),r)){const e=o.bucketInstanceId;let t=this.collisionCircleArrays[e];void 0===t&&(t=this.collisionCircleArrays[e]=new Tt);for(let e=0;e=0;--t){const n=e[t];C(o.symbolInstances.get(n),n,o.collisionArrays[n])}}else for(let e=t.symbolInstanceStart;e=0&&(t.text.placedSymbolArray.get(o).crossTileID=h>=0&&o!==h?0:u),a>=0&&(t.text.placedSymbolArray.get(a).crossTileID=h>=0&&a!==h?0:u),s>=0&&(t.text.placedSymbolArray.get(s).crossTileID=h>=0&&s!==h?0:u),l>=0&&(t.text.placedSymbolArray.get(l).crossTileID=h>=0&&l!==h?0:u)}markUsedOrientation(t,n,r){const i=n===e.WritingMode.horizontal||n===e.WritingMode.horizontalOnly?n:0,o=n===e.WritingMode.vertical?n:0,{leftJustifiedTextSymbolIndex:a,centerJustifiedTextSymbolIndex:s,rightJustifiedTextSymbolIndex:l,verticalPlacedTextSymbolIndex:u}=r,c=t.text.placedSymbolArray;a>=0&&(c.get(a).placedOrientation=i),s>=0&&(c.get(s).placedOrientation=i),l>=0&&(c.get(l).placedOrientation=i),u>=0&&(c.get(u).placedOrientation=o)}commit(e){this.commitTime=e,this.zoomAtLastRecencyCheck=this.transform.zoom;const t=this.prevPlacement;let n=!1;this.prevZoomAdjustment=t?t.zoomAdjustment(this.transform.zoom):0;const r=t?t.symbolFadeChange(e):1,i=t?t.opacities:{},o=t?t.variableOffsets:{},a=t?t.placedOrientations:{};for(const e in this.placements){const t=this.placements[e],o=i[e];o?(this.opacities[e]=new wt(o,r,t.text,t.icon,null,t.clipped),n=n||t.text!==o.text.placed||t.icon!==o.icon.placed):(this.opacities[e]=new wt(null,r,t.text,t.icon,t.skipFade,t.clipped),n=n||t.text||t.icon)}for(const e in i){const t=i[e];if(!this.opacities[e]){const i=new wt(t,r,!1,!1);i.isHidden()||(this.opacities[e]=i,n=n||t.text.placed||t.icon.placed)}}for(const e in o)this.variableOffsets[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.variableOffsets[e]=o[e]);for(const e in a)this.placedOrientations[e]||!this.opacities[e]||this.opacities[e].isHidden()||(this.placedOrientations[e]=a[e]);n?this.lastPlacementChangeTime=e:"number"!=typeof this.lastPlacementChangeTime&&(this.lastPlacementChangeTime=t?t.lastPlacementChangeTime:e)}updateLayerOpacities(e,t){const n={};for(const r of t){const t=r.getBucket(e);t&&r.latestFeatureIndex&&e.id===t.layerIds[0]&&this.updateBucketOpacities(t,n,r.collisionBoxArray)}}updateBucketOpacities(t,n,r){t.hasTextData()&&t.text.opacityVertexArray.clear(),t.hasIconData()&&t.icon.opacityVertexArray.clear(),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const i=t.layers[0].layout,o=!!t.layers[0].dynamicFilter(),a=new wt(null,0,!1,!1,!0),s=i.get("text-allow-overlap"),l=i.get("icon-allow-overlap"),u=i.get("text-variable-anchor"),c="map"===i.get("text-rotation-alignment"),h="map"===i.get("text-pitch-alignment"),d="none"!==i.get("icon-text-fit"),f=new wt(null,0,s&&(l||!t.hasIconData()||i.get("icon-optional")),l&&(s||!t.hasTextData()||i.get("text-optional")),!0);!t.collisionArrays&&r&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(r);const p=(e,t,n)=>{for(let r=0;r0||l>0,x=g>0,b=this.placedOrientations[_],w=b===e.WritingMode.vertical,E=b===e.WritingMode.horizontal||b===e.WritingMode.horizontalOnly;if(!v&&!x||y.isHidden()||m++,v){const e=Ft(y.text);p(t.text,s,w?jt:e),p(t.text,l,E?jt:e);const n=y.text.isHidden(),{leftJustifiedTextSymbolIndex:r,centerJustifiedTextSymbolIndex:o,rightJustifiedTextSymbolIndex:a,verticalPlacedTextSymbolIndex:u}=i,c=t.text.placedSymbolArray,h=n||w?1:0;r>=0&&(c.get(r).hidden=h),o>=0&&(c.get(o).hidden=h),a>=0&&(c.get(a).hidden=h),u>=0&&(c.get(u).hidden=n||E?1:0);const d=this.variableOffsets[_];d&&this.markUsedJustification(t,d.anchor,i,b);const f=this.placedOrientations[_];f&&(this.markUsedJustification(t,"left",i,f),this.markUsedOrientation(t,f,i))}if(x){const e=Ft(y.icon),{placedIconSymbolIndex:n,verticalPlacedIconSymbolIndex:r}=i,o=t.icon.placedSymbolArray,a=y.icon.isHidden()?1:0;n>=0&&(p(t.icon,g,w?jt:e),o.get(n).hidden=a),r>=0&&(p(t.icon,i.numVerticalIconVertices,E?jt:e),o.get(r).hidden=a)}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const n=t.collisionArrays[r];if(n){let r=new e.pointGeometry(0,0),i=!0;if(n.textBox||n.verticalTextBox){if(u){const e=this.variableOffsets[_];e?(r=Ct(e.anchor,e.width,e.height,e.textOffset,e.textScale),c&&r._rotate(h?this.transform.angle:-this.transform.angle)):i=!1}o&&(i=!y.clipped),n.textBox&&It(t.textCollisionBox.collisionVertexArray,y.text.placed,!i||w,r.x,r.y),n.verticalTextBox&&It(t.textCollisionBox.collisionVertexArray,y.text.placed,!i||E,r.x,r.y)}const a=i&&Boolean(!E&&n.verticalIconBox);n.iconBox&&It(t.iconCollisionBox.collisionVertexArray,y.icon.placed,a,d?r.x:0,d?r.y:0),n.verticalIconBox&&It(t.iconCollisionBox.collisionVertexArray,y.icon.placed,!a,d?r.x:0,d?r.y:0)}}}if(t.fullyClipped=0===m,t.sortFeatures(this.transform.angle),this.retainedQueryData[t.bucketInstanceId]&&(this.retainedQueryData[t.bucketInstanceId].featureSortOrder=t.featureSortOrder),t.hasTextData()&&t.text.opacityVertexBuffer&&t.text.opacityVertexBuffer.updateData(t.text.opacityVertexArray),t.hasIconData()&&t.icon.opacityVertexBuffer&&t.icon.opacityVertexBuffer.updateData(t.icon.opacityVertexArray),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexBuffer&&t.iconCollisionBox.collisionVertexBuffer.updateData(t.iconCollisionBox.collisionVertexArray),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexBuffer&&t.textCollisionBox.collisionVertexBuffer.updateData(t.textCollisionBox.collisionVertexArray),t.bucketInstanceId in this.collisionCircleArrays){const e=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=e.invProjMatrix,t.placementViewportMatrix=e.viewportMatrix,t.collisionCircleArray=e.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(e){return 0===this.fadeDuration?1:(e-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(e){return Math.max(0,(this.transform.zoom-e)/1.5)}hasTransitions(e){return this.stale||e-this.lastPlacementChangeTimee}setStale(){this.stale=!0}}function It(e,t,n,r,i){e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0),e.emplaceBack(t?1:0,n?1:0,r||0,i||0)}const Pt=Math.pow(2,25),zt=Math.pow(2,24),Ot=Math.pow(2,17),Dt=Math.pow(2,16),Lt=Math.pow(2,9),Rt=Math.pow(2,8),Bt=Math.pow(2,1);function Ft(e){if(0===e.opacity&&!e.placed)return 0;if(1===e.opacity&&e.placed)return 4294967295;const t=e.placed?1:0,n=Math.floor(127*e.opacity);return n*Pt+t*zt+n*Ot+t*Dt+n*Lt+t*Rt+n*Bt+t}const jt=0;class Nt{constructor(e){this._sortAcrossTiles="viewport-y"!==e.layout.get("symbol-z-order")&&void 0!==e.layout.get("symbol-sort-key").constantOr(1),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(e,t,n,r,i){const o=this._bucketParts;for(;this._currentTileIndexe.sortKey-t.sortKey));this._currentPartIndex{const t=e.exported.now()-i;return!this._forceFullPlacement&&t>2};for(;this._currentPlacementIndex>=0;){const e=n[t[this._currentPlacementIndex]],i=this.placement.collisionIndex.transform.zoom;if("symbol"===e.type&&(!e.minzoom||e.minzoom<=i)&&(!e.maxzoom||e.maxzoom>i)){if(this._inProgressLayer||(this._inProgressLayer=new Nt(e)),this._inProgressLayer.continuePlacement(r[e.source],this.placement,this._showCollisionBoxes,e,o))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(e){return this.placement.commit(e),this.placement}}const Vt=512/e.EXTENT/2;class Gt{constructor(e,t,n){this.tileID=e,this.indexedSymbolInstances={},this.bucketInstanceId=n;for(let n=0;ne.overscaledZ)for(const n in i){const o=i[n];o.tileID.isChildOf(e)&&o.findMatches(t.symbolInstances,e,r)}else{const o=i[e.scaledTo(Number(n)).key];o&&o.findMatches(t.symbolInstances,e,r)}}for(let e=0;e{t[e]=!0});for(const e in this.layerIndexes)t[e]||delete this.layerIndexes[e]}}const Wt=(t,n)=>e.emitValidationErrors(t,n&&n.filter(e=>"source.canvas"!==e.identifier)),Xt=e.pick(qe,["addLayer","removeLayer","setPaintProperty","setLayoutProperty","setFilter","addSource","removeSource","setLayerZoomRange","setLight","setTransition","setGeoJSONSourceData","setTerrain","setFog","setProjection"]),Ht=e.pick(qe,["setCenter","setZoom","setBearing","setPitch"]),Yt={version:8,layers:[],sources:{}},Kt={fill:!0,line:!0,background:!0,hillshade:!0,raster:!0};class Jt extends e.Evented{constructor(t,n={}){super(),this.map=t,this.dispatcher=new z(Ue(),this),this.imageManager=new x,this.imageManager.setEventedParent(this),this.glyphManager=new e.GlyphManager(t._requestManager,n.localFontFamily?e.LocalGlyphMode.all:n.localIdeographFontFamily?e.LocalGlyphMode.ideographs:e.LocalGlyphMode.none,n.localFontFamily||n.localIdeographFontFamily),this.crossTileSymbolIndex=new Zt,this._layers={},this._num3DLayers=0,this._numSymbolLayers=0,this._numCircleLayers=0,this._serializedLayers={},this._sourceCaches={},this._otherSourceCaches={},this._symbolSourceCaches={},this._loaded=!1,this._availableImages=[],this._order=[],this._drapedFirstOrder=[],this._markersNeedUpdate=!1,this._resetUpdates(),this.dispatcher.broadcast("setReferrer",e.getReferrer());const r=this;this._rtlTextPluginCallback=Jt.registerForPluginStateChange(t=>{r.dispatcher.broadcast("syncRTLPluginState",{pluginStatus:t.pluginStatus,pluginURL:t.pluginURL},(t,n)=>{if(e.triggerPluginCompletionEvent(t),n&&n.every(e=>e))for(const e in r._sourceCaches){const t=r._sourceCaches[e],n=t.getSource().type;"vector"!==n&&"geojson"!==n||t.reload()}})}),this.on("data",e=>{if("source"!==e.dataType||"metadata"!==e.sourceDataType)return;const t=this.getSource(e.sourceId);if(t&&t.vectorLayerIds)for(const e in this._layers){const n=this._layers[e];n.source===t.id&&this._validateLayer(n)}})}loadURL(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"}));const r="boolean"==typeof n.validate?n.validate:!e.isMapboxURL(t);t=this.map._requestManager.normalizeStyleURL(t,n.accessToken);const i=this.map._requestManager.transformRequest(t,e.ResourceType.Style);this._request=e.getJSON(i,(t,n)=>{this._request=null,t?this.fire(new e.ErrorEvent(t)):n&&this._load(n,r)})}loadJSON(t,n={}){this.fire(new e.Event("dataloading",{dataType:"style"})),this._request=e.exported.frame(()=>{this._request=null,this._load(t,!1!==n.validate)})}loadEmpty(){this.fire(new e.Event("dataloading",{dataType:"style"})),this._load(Yt,!1)}_updateLayerCount(e,t){const n=t?1:-1;e.is3D()&&(this._num3DLayers+=n),"circle"===e.type&&(this._numCircleLayers+=n),"symbol"===e.type&&(this._numSymbolLayers+=n)}_load(t,n){if(n&&Wt(this,e.validateStyle(t)))return;this._loaded=!0,this.stylesheet=e.clone$1(t),this._updateMapProjection();for(const e in t.sources)this.addSource(e,t.sources[e],{validate:!1});this._changed=!1,t.sprite?this._loadSprite(t.sprite):(this.imageManager.setLoaded(!0),this.dispatcher.broadcast("spriteLoaded",!0)),this.glyphManager.setURL(t.glyphs);const r=Ge(this.stylesheet.layers);this._order=r.map(e=>e.id),this._layers={},this._serializedLayers={};for(let t of r)t=e.createStyleLayer(t),t.setEventedParent(this,{layer:{id:t.id}}),this._layers[t.id]=t,this._serializedLayers[t.id]=t.serialize(),this._updateLayerCount(t,!0);this.dispatcher.broadcast("setLayers",this._serializeLayers(this._order)),this.light=new E(this.stylesheet.light),this.stylesheet.terrain&&!this.terrainSetForDrapingOnly()&&this._createTerrain(this.stylesheet.terrain,1),this.stylesheet.fog&&this._createFog(this.stylesheet.fog),this._updateDrapeFirstLayers(),this.fire(new e.Event("data",{dataType:"style"})),this.fire(new e.Event("style.load"))}terrainSetForDrapingOnly(){return!!this.terrain&&0===this.terrain.drapeRenderMode}setProjection(e){e?this.stylesheet.projection=e:delete this.stylesheet.projection,this._updateMapProjection()}applyProjectionUpdate(){this._loaded&&(this.dispatcher.broadcast("setProjection",this.map.transform.projectionOptions),this.map.transform.projection.requiresDraping?this.getTerrain()||this.stylesheet.terrain||this.setTerrainForDraping():this.terrainSetForDrapingOnly()&&this.setTerrain(null))}_updateMapProjection(){this.map._useExplicitProjection?this.applyProjectionUpdate():this.map._prioritizeAndUpdateProjection(null,this.stylesheet.projection)}_loadSprite(t){this._spriteRequest=function(t,n,r){let i,o,a;const s=e.exported.devicePixelRatio>1?"@2x":"";let l=e.getJSON(n.transformRequest(n.normalizeSpriteURL(t,s,".json"),e.ResourceType.SpriteJSON),(e,t)=>{l=null,a||(a=e,i=t,c())}),u=e.getImage(n.transformRequest(n.normalizeSpriteURL(t,s,".png"),e.ResourceType.SpriteImage),(e,t)=>{u=null,a||(a=e,o=t,c())});function c(){if(a)r(a);else if(i&&o){const t=e.exported.getImageData(o),n={};for(const r in i){const{width:o,height:a,x:s,y:l,sdf:u,pixelRatio:c,stretchX:h,stretchY:d,content:f}=i[r],p=new e.RGBAImage({width:o,height:a});e.RGBAImage.copy(t,p,{x:s,y:l},{x:0,y:0},{width:o,height:a}),n[r]={data:p,pixelRatio:c,sdf:u,stretchX:h,stretchY:d,content:f}}r(null,n)}}return{cancel(){l&&(l.cancel(),l=null),u&&(u.cancel(),u=null)}}}(t,this.map._requestManager,(t,n)=>{if(this._spriteRequest=null,t)this.fire(new e.ErrorEvent(t));else if(n)for(const e in n)this.imageManager.addImage(e,n[e]);this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),this.dispatcher.broadcast("setImages",this._availableImages),this.dispatcher.broadcast("spriteLoaded",!0),this.fire(new e.Event("data",{dataType:"style"}))})}_validateLayer(t){const n=this.getSource(t.source);if(!n)return;const r=t.sourceLayer;r&&("geojson"===n.type||n.vectorLayerIds&&-1===n.vectorLayerIds.indexOf(r))&&this.fire(new e.ErrorEvent(new Error(`Source layer "${r}" does not exist on source "${n.id}" as specified by style layer "${t.id}"`)))}loaded(){if(!this._loaded)return!1;if(Object.keys(this._updatedSources).length)return!1;for(const e in this._sourceCaches)if(!this._sourceCaches[e].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeLayers(e){const t=[];for(const n of e){const e=this._layers[n];"custom"!==e.type&&t.push(e.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;if(this.fog&&this.fog.hasTransition())return!0;for(const e in this._sourceCaches)if(this._sourceCaches[e].hasTransition())return!0;for(const e in this._layers)if(this._layers[e].hasTransition())return!0;return!1}get order(){return this.map._optimizeForTerrain&&this.terrain?this._drapedFirstOrder:this._order}isLayerDraped(e){return!!this.terrain&&Kt[e.type]}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading")}update(t){if(!this._loaded)return;const n=this._changed;if(this._changed){const e=Object.keys(this._updatedLayers),n=Object.keys(this._removedLayers);(e.length||n.length)&&this._updateWorkerLayers(e,n);for(const e in this._updatedSources){const t=this._updatedSources[e];"reload"===t?this._reloadSource(e):"clear"===t&&this._clearSource(e)}this._updateTilesForChangedImages();for(const e in this._updatedPaintProps)this._layers[e].updateTransitions(t);this.light.updateTransitions(t),this.fog&&this.fog.updateTransitions(t),this._resetUpdates()}const r={};for(const e in this._sourceCaches){const t=this._sourceCaches[e];r[e]=t.used,t.used=!1}for(const e of this._order){const n=this._layers[e];if(n.recalculate(t,this._availableImages),!n.isHidden(t.zoom)){const e=this._getLayerSourceCache(n);e&&(e.used=!0)}const r=this.map.painter;if(r){const e=n.getProgramIds();if(!e)continue;const i=n.getProgramConfiguration(t.zoom);for(const t of e)r.useProgram(t,i)}}for(const t in r){const n=this._sourceCaches[t];r[t]!==n.used&&n.getSource().fire(new e.Event("data",{sourceDataType:"visibility",dataType:"source",sourceId:n.getSource().id}))}this.light.recalculate(t),this.terrain&&this.terrain.recalculate(t),this.fog&&this.fog.recalculate(t),this.z=t.zoom,this._markersNeedUpdate&&(this._updateMarkersOpacity(),this._markersNeedUpdate=!1),n&&this.fire(new e.Event("data",{dataType:"style"}))}_updateTilesForChangedImages(){const e=Object.keys(this._changedImages);if(e.length){for(const t in this._sourceCaches)this._sourceCaches[t].reloadTilesForDependencies(["icons","patterns"],e);this._changedImages={}}}_updateWorkerLayers(e,t){this.dispatcher.broadcast("updateLayers",{layers:this._serializeLayers(e),removedIds:t})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={}}setState(n){if(this._checkLoaded(),Wt(this,e.validateStyle(n)))return!1;(n=e.clone$1(n)).layers=Ge(n.layers);const r=function(e,n){if(!e)return[{command:qe.setStyle,args:[n]}];let r=[];try{if(!t(e.version,n.version))return[{command:qe.setStyle,args:[n]}];t(e.center,n.center)||r.push({command:qe.setCenter,args:[n.center]}),t(e.zoom,n.zoom)||r.push({command:qe.setZoom,args:[n.zoom]}),t(e.bearing,n.bearing)||r.push({command:qe.setBearing,args:[n.bearing]}),t(e.pitch,n.pitch)||r.push({command:qe.setPitch,args:[n.pitch]}),t(e.sprite,n.sprite)||r.push({command:qe.setSprite,args:[n.sprite]}),t(e.glyphs,n.glyphs)||r.push({command:qe.setGlyphs,args:[n.glyphs]}),t(e.transition,n.transition)||r.push({command:qe.setTransition,args:[n.transition]}),t(e.light,n.light)||r.push({command:qe.setLight,args:[n.light]}),t(e.fog,n.fog)||r.push({command:qe.setFog,args:[n.fog]}),t(e.projection,n.projection)||r.push({command:qe.setProjection,args:[n.projection]});const i={},o=[];!function(e,n,r,i){let o;for(o in n=n||{},e=e||{})e.hasOwnProperty(o)&&(n.hasOwnProperty(o)||Ze(o,r,i));for(o in n)n.hasOwnProperty(o)&&(e.hasOwnProperty(o)?t(e[o],n[o])||("geojson"===e[o].type&&"geojson"===n[o].type&&Xe(e,n,o)?r.push({command:qe.setGeoJSONSourceData,args:[o,n[o].data]}):We(o,n,r,i)):$e(o,n,r))}(e.sources,n.sources,o,i);const a=[];e.layers&&e.layers.forEach(e=>{e.source&&i[e.source]?r.push({command:qe.removeLayer,args:[e.id]}):a.push(e)});let s=e.terrain;s&&i[s.source]&&(r.push({command:qe.setTerrain,args:[void 0]}),s=void 0),r=r.concat(o),t(s,n.terrain)||r.push({command:qe.setTerrain,args:[n.terrain]}),function(e,n,r){n=n||[];const i=(e=e||[]).map(Ye),o=n.map(Ye),a=e.reduce(Ke,{}),s=n.reduce(Ke,{}),l=i.slice(),u=Object.create(null);let c,h,d,f,p,m,_;for(c=0,h=0;c!(e.command in Ht));if(0===r.length)return!1;const i=r.filter(e=>!(e.command in Xt));if(i.length>0)throw new Error(`Unimplemented: ${i.map(e=>e.command).join(", ")}.`);return r.forEach(e=>{"setTransition"!==e.command&&"setProjection"!==e.command&&this[e.command].apply(this,e.args)}),this.stylesheet=n,this._updateMapProjection(),!0}addImage(t,n){return this.getImage(t)?this.fire(new e.ErrorEvent(new Error("An image with this name already exists."))):(this.imageManager.addImage(t,n),this._afterImageUpdated(t),this)}updateImage(e,t){this.imageManager.updateImage(e,t)}getImage(e){return this.imageManager.getImage(e)}removeImage(t){return this.getImage(t)?(this.imageManager.removeImage(t),this._afterImageUpdated(t),this):this.fire(new e.ErrorEvent(new Error("No image with this name exists.")))}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("setImages",this._availableImages),this.fire(new e.Event("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this._availableImages.slice()}addSource(t,n,r={}){if(this._checkLoaded(),void 0!==this.getSource(t))throw new Error("There is already a source with this ID");if(!n.type)throw new Error(`The type property must be defined, but only the following properties were given: ${Object.keys(n).join(", ")}.`);if(["vector","raster","geojson","video","image"].indexOf(n.type)>=0&&this._validate(e.validateSource,"sources."+t,n,null,r))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const i=ze(t,n,this.dispatcher,this);i.setEventedParent(this,()=>({isSourceLoaded:this._isSourceCacheLoaded(t),source:i.serialize(),sourceId:t}));const o=n=>{const r=(n?"symbol:":"other:")+t,o=this._sourceCaches[r]=new e.SourceCache(r,i,n);(n?this._symbolSourceCaches:this._otherSourceCaches)[t]=o,o.style=this,o.onAdd(this.map)};o(!1),"vector"!==n.type&&"geojson"!==n.type||o(!0),i.onAdd&&i.onAdd(this.map),this._changed=!0}removeSource(t){this._checkLoaded();const n=this.getSource(t);if(!n)throw new Error("There is no source with this ID");for(const n in this._layers)if(this._layers[n].source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while layer "${n}" is using it.`)));if(this.terrain&&this.terrain.get().source===t)return this.fire(new e.ErrorEvent(new Error(`Source "${t}" cannot be removed while terrain is using it.`)));const r=this._getSourceCaches(t);for(const t of r)delete this._sourceCaches[t.id],delete this._updatedSources[t.id],t.fire(new e.Event("data",{sourceDataType:"metadata",dataType:"source",sourceId:t.getSource().id})),t.setEventedParent(null),t.clearTiles();return delete this._otherSourceCaches[t],delete this._symbolSourceCaches[t],n.setEventedParent(null),n.onRemove&&n.onRemove(this.map),this._changed=!0,this}setGeoJSONSourceData(e,t){this._checkLoaded(),this.getSource(e).setData(t),this._changed=!0}getSource(e){const t=this._getSourceCache(e);return t&&t.getSource()}_getSources(){const e=[];for(const t in this._otherSourceCaches){const n=this._getSourceCache(t);n&&e.push(n.getSource())}return e}addLayer(t,n,r={}){this._checkLoaded();const i=t.id;if(this.getLayer(i))return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${i}" already exists on this map`)));let o;if("custom"===t.type){if(Wt(this,e.validateCustomStyleLayer(t)))return;o=e.createStyleLayer(t)}else{if("object"==typeof t.source&&(this.addSource(i,t.source),t=e.clone$1(t),t=e.extend(t,{source:i})),this._validate(e.validateLayer,"layers."+i,t,{arrayIndex:-1},r))return;o=e.createStyleLayer(t),this._validateLayer(o),o.setEventedParent(this,{layer:{id:i}}),this._serializedLayers[o.id]=o.serialize(),this._updateLayerCount(o,!0)}const a=n?this._order.indexOf(n):this._order.length;if(n&&-1===a)return void this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`)));this._order.splice(a,0,i),this._layerOrderChanged=!0,this._layers[i]=o;const s=this._getLayerSourceCache(o);if(this._removedLayers[i]&&o.source&&s&&"custom"!==o.type){const e=this._removedLayers[i];delete this._removedLayers[i],e.type!==o.type?this._updatedSources[o.source]="clear":(this._updatedSources[o.source]="reload",s.pause())}this._updateLayer(o),o.onAdd&&o.onAdd(this.map),this._updateDrapeFirstLayers()}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const r=this._order.indexOf(t);this._order.splice(r,1);const i=n?this._order.indexOf(n):this._order.length;n&&-1===i?this.fire(new e.ErrorEvent(new Error(`Layer with id "${n}" does not exist on this map.`))):(this._order.splice(i,0,t),this._layerOrderChanged=!0,this._updateDrapeFirstLayers())}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot be removed.`)));n.setEventedParent(null),this._updateLayerCount(n,!1);const r=this._order.indexOf(t);this._order.splice(r,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map),this._updateDrapeFirstLayers()}getLayer(e){return this._layers[e]}hasLayer(e){return e in this._layers}hasLayerType(e){for(const t in this._layers)if(this._layers[t].type===e)return!0;return!1}setLayerZoomRange(t,n,r){this._checkLoaded();const i=this.getLayer(t);i?i.minzoom===n&&i.maxzoom===r||(null!=n&&(i.minzoom=n),null!=r&&(i.maxzoom=r),this._updateLayer(i)):this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style and cannot have zoom extent.`)))}setFilter(n,r,i={}){this._checkLoaded();const o=this.getLayer(n);if(o){if(!t(o.filter,r))return null==r?(o.filter=void 0,void this._updateLayer(o)):void(this._validate(e.validateFilter,`layers.${o.id}.filter`,r,{layerType:o.type},i)||(o.filter=e.clone$1(r),this._updateLayer(o)))}else this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be filtered.`)))}getFilter(t){const n=this.getLayer(t);return n&&e.clone$1(n.filter)}setLayoutProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getLayoutProperty(r),i)||(a.setLayoutProperty(r,i,o),this._updateLayer(a)):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getLayoutProperty(t,n){const r=this.getLayer(t);if(r)return r.getLayoutProperty(n);this.fire(new e.ErrorEvent(new Error(`The layer '${t}' does not exist in the map's style.`)))}setPaintProperty(n,r,i,o={}){this._checkLoaded();const a=this.getLayer(n);a?t(a.getPaintProperty(r),i)||(a.setPaintProperty(r,i,o)&&this._updateLayer(a),this._changed=!0,this._updatedPaintProps[n]=!0):this.fire(new e.ErrorEvent(new Error(`The layer '${n}' does not exist in the map's style and cannot be styled.`)))}getPaintProperty(e,t){const n=this.getLayer(e);return n&&n.getPaintProperty(t)}setFeatureState(t,n){this._checkLoaded();const r=t.source,i=t.sourceLayer,o=this.getSource(r);if(!o)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const a=o.type;if("geojson"===a&&i)return void this.fire(new e.ErrorEvent(new Error("GeoJSON sources cannot have a sourceLayer parameter.")));if("vector"===a&&!i)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided.")));const s=this._getSourceCaches(r);for(const e of s)e.setFeatureState(i,t.id,n)}removeFeatureState(t,n){this._checkLoaded();const r=t.source,i=this.getSource(r);if(!i)return void this.fire(new e.ErrorEvent(new Error(`The source '${r}' does not exist in the map's style.`)));const o=i.type,a="vector"===o?t.sourceLayer:void 0;if("vector"===o&&!a)return void this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")));if(n&&"string"!=typeof t.id&&"number"!=typeof t.id)return void this.fire(new e.ErrorEvent(new Error("A feature id is required to remove its specific state property.")));const s=this._getSourceCaches(r);for(const e of s)e.removeFeatureState(a,t.id,n)}getFeatureState(t){this._checkLoaded();const n=t.source,r=t.sourceLayer,i=this.getSource(n);if(i){if("vector"!==i.type||r)return void 0===t.id&&this.fire(new e.ErrorEvent(new Error("The feature id parameter must be provided."))),this._getSourceCaches(n)[0].getFeatureState(r,t.id);this.fire(new e.ErrorEvent(new Error("The sourceLayer parameter must be provided for vector source types.")))}else this.fire(new e.ErrorEvent(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return e.extend({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){const t={};for(const e in this._sourceCaches){const n=this._sourceCaches[e].getSource();t[n.id]||(t[n.id]=n.serialize())}return e.filterObject({version:this.stylesheet.version,name:this.stylesheet.name,metadata:this.stylesheet.metadata,light:this.stylesheet.light,terrain:this.getTerrain()||void 0,fog:this.stylesheet.fog,center:this.stylesheet.center,zoom:this.stylesheet.zoom,bearing:this.stylesheet.bearing,pitch:this.stylesheet.pitch,sprite:this.stylesheet.sprite,glyphs:this.stylesheet.glyphs,transition:this.stylesheet.transition,projection:this.stylesheet.projection,sources:t,layers:this._serializeLayers(this._order)},e=>void 0!==e)}_updateLayer(e){this._updatedLayers[e.id]=!0;const t=this._getLayerSourceCache(e);e.source&&!this._updatedSources[e.source]&&t&&"raster"!==t.getSource().type&&(this._updatedSources[e.source]="reload",t.pause()),this._changed=!0,e.invalidateCompiledFilter()}_flattenAndSortRenderedFeatures(e){const t=e=>"fill-extrusion"===this._layers[e].type,n={},r=[];for(let i=this._order.length-1;i>=0;i--){const o=this._order[i];if(t(o)){n[o]=i;for(const t of e){const e=t[o];if(e)for(const t of e)r.push(t)}}}r.sort((e,t)=>t.intersectionZ-e.intersectionZ);const i=[];for(let o=this._order.length-1;o>=0;o--){const a=this._order[o];if(t(a))for(let e=r.length-1;e>=0;e--){const t=r[e].feature;if(n[t.layer.id]{const t=this.getLayer(e);return t&&t.is3D()}):this.has3DLayers(),s=D.createFromScreenPoints(t,r);for(const e in this._sourceCaches){const t=this._sourceCaches[e].getSource().id;n.layers&&!i[t]||o.push(De(this._sourceCaches[e],this._layers,this._serializedLayers,s,n,r,a,!!this.map._showQueryGeometry))}return this.placement&&o.push(function(e,t,n,r,i,o,a){const s={},l=o.queryRenderedSymbols(r),u=[];for(const e of Object.keys(l).map(Number))u.push(a[e]);u.sort(Re);for(const n of u){const r=n.featureIndex.lookupSymbolFeatures(l[n.bucketInstanceId],t,n.bucketIndex,n.sourceLayerIndex,i.filter,i.layers,i.availableImages,e);for(const e in r){const t=s[e]=s[e]||[],i=r[e];i.sort((e,t)=>{const r=n.featureSortOrder;if(r){const n=r.indexOf(e.featureIndex);return r.indexOf(t.featureIndex)-n}return t.featureIndex-e.featureIndex});for(const e of i)t.push(e)}}for(const t in s)s[t].forEach(r=>{const i=r.feature,o=n(e[t]).getFeatureState(i.layer["source-layer"],i.id);i.source=i.layer.source,i.layer["source-layer"]&&(i.sourceLayer=i.layer["source-layer"]),i.state=o});return s}(this._layers,this._serializedLayers,this._getLayerSourceCache.bind(this),s.screenGeometry,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(o)}querySourceFeatures(t,n){n&&n.filter&&this._validate(e.validateFilter,"querySourceFeatures.filter",n.filter,null,n);const r=this._getSourceCaches(t);let i=[];for(const e of r)i=i.concat(Le(e,n));return i}addSourceType(e,t,n){return Jt.getSourceType(e)?n(new Error(`A source type called "${e}" already exists.`)):(Jt.setSourceType(e,t),t.workerSourceURL?void this.dispatcher.broadcast("loadWorkerSource",{name:e,url:t.workerSourceURL},n):n(null,null))}getLight(){return this.light.getLight()}setLight(e,n={}){this._checkLoaded();const r=this.light.getLight();let i=!1;for(const n in e)if(!t(e[n],r[n])){i=!0;break}if(!i)return;const o=this._setTransitionParameters({duration:300,delay:0});this.light.setLight(e,n),this.light.updateTransitions(o)}getTerrain(){return this.terrain&&1===this.terrain.drapeRenderMode?this.terrain.get():null}setTerrainForDraping(){this.setTerrain({source:"",exaggeration:0},0)}setTerrain(n,r=1){if(this._checkLoaded(),!n)return delete this.terrain,delete this.stylesheet.terrain,this.dispatcher.broadcast("enableTerrain",!1),this._force3DLayerUpdate(),void(this._markersNeedUpdate=!0);if(1===r){if("object"==typeof n.source){const t="terrain-dem-src";this.addSource(t,n.source),n=e.clone$1(n),n=e.extend(n,{source:t})}if(this._validate(e.validateTerrain,"terrain",n))return}if(!this.terrain||this.terrain&&r!==this.terrain.drapeRenderMode)this._createTerrain(n,r);else{const r=this.terrain,i=r.get();for(const t of Object.keys(e.spec.terrain))!n.hasOwnProperty(t)&&e.spec.terrain[t].default&&(n[t]=e.spec.terrain[t].default);for(const e in n)if(!t(n[e],i[e])){r.set(n),this.stylesheet.terrain=n;const e=this._setTransitionParameters({duration:0});r.updateTransitions(e);break}}this._updateDrapeFirstLayers(),this._markersNeedUpdate=!0}_createFog(e){const t=this.fog=new P(e,this.map.transform);this.stylesheet.fog=e;const n=this._setTransitionParameters({duration:0});t.updateTransitions(n)}_updateMarkersOpacity(){0!==this.map._markers.length&&this.map._requestDomTask(()=>{for(const e of this.map._markers)e._evaluateOpacity()})}getFog(){return this.fog?this.fog.get():null}setFog(e){if(this._checkLoaded(),!e)return delete this.fog,delete this.stylesheet.fog,void(this._markersNeedUpdate=!0);if(this.fog){const n=this.fog,r=n.get();0===Object.keys(e).length&&n.set(e);for(const i in e)if(!t(e[i],r[i])){n.set(e),this.stylesheet.fog=e;const t=this._setTransitionParameters({duration:0});n.updateTransitions(t);break}}else this._createFog(e);this._markersNeedUpdate=!0}_setTransitionParameters(t){return{now:e.exported.now(),transition:e.extend(t,this.stylesheet.transition)}}_updateDrapeFirstLayers(){if(!this.map._optimizeForTerrain||!this.terrain)return;const e=this._order.filter(e=>this.isLayerDraped(this._layers[e])),t=this._order.filter(e=>!this.isLayerDraped(this._layers[e]));this._drapedFirstOrder=[],this._drapedFirstOrder.push(...e),this._drapedFirstOrder.push(...t)}_createTerrain(e,t){const n=this.terrain=new k(e,t);this.stylesheet.terrain=e,this.dispatcher.broadcast("enableTerrain",!this.terrainSetForDrapingOnly()),this._force3DLayerUpdate();const r=this._setTransitionParameters({duration:0});n.updateTransitions(r)}_force3DLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"fill-extrusion"===t.type&&this._updateLayer(t)}}_forceSymbolLayerUpdate(){for(const e in this._layers){const t=this._layers[e];"symbol"===t.type&&this._updateLayer(t)}}_validate(t,n,r,i,o={}){return(!o||!1!==o.validate)&&Wt(this,t.call(e.validateStyle,e.extend({key:n,style:this.serialize(),value:r,styleSpec:e.spec},i)))}_remove(){this._request&&(this._request.cancel(),this._request=null),this._spriteRequest&&(this._spriteRequest.cancel(),this._spriteRequest=null),e.evented.off("pluginStateChange",this._rtlTextPluginCallback);for(const e in this._layers)this._layers[e].setEventedParent(null);for(const e in this._sourceCaches)this._sourceCaches[e].clearTiles(),this._sourceCaches[e].setEventedParent(null);this.imageManager.setEventedParent(null),this.setEventedParent(null),this.dispatcher.remove()}_clearSource(e){const t=this._getSourceCaches(e);for(const e of t)e.clearTiles()}_reloadSource(e){const t=this._getSourceCaches(e);for(const e of t)e.resume(),e.reload()}_reloadSources(){for(const e of this._getSources())e.reload&&e.reload()}_updateSources(e){for(const t in this._sourceCaches)this._sourceCaches[t].update(e)}_generateCollisionBoxes(){for(const e in this._sourceCaches){const t=this._sourceCaches[e];t.resume(),t.reload()}}_updatePlacement(t,n,r,i,o=!1){let a=!1,s=!1;const l={};for(const e of this._order){const n=this._layers[e];if("symbol"!==n.type)continue;if(!l[n.source]){const e=this._getLayerSourceCache(n);if(!e)continue;l[n.source]=e.getRenderableIds(!0).map(t=>e.getTileByID(t)).sort((e,t)=>t.tileID.overscaledZ-e.tileID.overscaledZ||(e.tileID.isLessThan(t.tileID)?-1:1))}const r=this.crossTileSymbolIndex.addLayer(n,l[n.source],t.center.lng,t.projection);a=a||r}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),o=o||this._layerOrderChanged||0===r,this._layerOrderChanged&&this.fire(new e.Event("neworder")),(o||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(e.exported.now(),t.zoom))&&(this.pauseablePlacement=new Ut(t,this._order,o,n,r,i,this.placement,this.fog&&t.projection.supportsFog?this.fog.state:null),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,l),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(e.exported.now()),s=!0),a&&this.pauseablePlacement.placement.setStale()),s||a)for(const e of this._order){const t=this._layers[e];"symbol"===t.type&&this.placement.updateLayerOpacities(t,l[t.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(e.exported.now())}_releaseSymbolFadeTiles(){for(const e in this._sourceCaches)this._sourceCaches[e].releaseSymbolFadeTiles()}getImages(e,t,n){this.imageManager.getImages(t.icons,n),this._updateTilesForChangedImages();const r=e=>{e&&e.setDependencies(t.tileID.key,t.type,t.icons)};r(this._otherSourceCaches[t.source]),r(this._symbolSourceCaches[t.source])}getGlyphs(e,t,n){this.glyphManager.getGlyphs(t.stacks,n)}getResource(t,n,r){return e.makeRequest(n,r)}_getSourceCache(e){return this._otherSourceCaches[e]}_getLayerSourceCache(e){return"symbol"===e.type?this._symbolSourceCaches[e.source]:this._otherSourceCaches[e.source]}_getSourceCaches(e){const t=[];return this._otherSourceCaches[e]&&t.push(this._otherSourceCaches[e]),this._symbolSourceCaches[e]&&t.push(this._symbolSourceCaches[e]),t}_isSourceCacheLoaded(t){const n=this._getSourceCaches(t);return 0===n.length?(this.fire(new e.ErrorEvent(new Error(`There is no source with ID '${t}'`))),!1):n.every(e=>e.loaded())}has3DLayers(){return this._num3DLayers>0}hasSymbolLayers(){return this._numSymbolLayers>0}hasCircleLayers(){return this._numCircleLayers>0}_clearWorkerCaches(){this.dispatcher.broadcast("clearCaches")}destroy(){this._clearWorkerCaches(),this.terrainSetForDrapingOnly()&&(delete this.terrain,delete this.stylesheet.terrain)}}Jt.getSourceType=function(e){return Pe[e]},Jt.setSourceType=function(e,t){Pe[e]=t},Jt.registerForPluginStateChange=e.registerForPluginStateChange;var Qt="\n#define EPSILON 0.0000001\n#define PI 3.141592653589793\n#define EXTENT 8192.0\n#define HALF_PI PI/2.0\n#define QUARTER_PI PI/4.0\n#define RAD_TO_DEG 180.0/PI\n#define DEG_TO_RAD PI/180.0\n#define GLOBE_RADIUS EXTENT/PI/2.0",en="attribute highp vec3 a_pos_3f;uniform lowp mat4 u_matrix;varying highp vec3 v_uv;void main() {const mat3 half_neg_pi_around_x=mat3(1.0,0.0, 0.0,0.0,0.0,-1.0,0.0,1.0, 0.0);v_uv=half_neg_pi_around_x*a_pos_3f;vec4 pos=u_matrix*vec4(a_pos_3f,1.0);gl_Position=pos.xyww;}",tn="\n#define ELEVATION_SCALE 7.0\n#define ELEVATION_OFFSET 450.0\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_tl_up;uniform vec3 u_tile_tr_up;uniform vec3 u_tile_br_up;uniform vec3 u_tile_bl_up;uniform float u_tile_up_scale;vec3 elevationVector(vec2 pos) {vec2 uv=pos/EXTENT;vec3 up=normalize(mix(\nmix(u_tile_tl_up,u_tile_tr_up,uv.xxx),mix(u_tile_bl_up,u_tile_br_up,uv.xxx),uv.yyy));return up*u_tile_up_scale;}\n#else\nvec3 elevationVector(vec2 pos) { return vec3(0,0,1); }\n#endif\n#ifdef TERRAIN\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nuniform highp sampler2D u_dem;uniform highp sampler2D u_dem_prev;\n#else\nuniform sampler2D u_dem;uniform sampler2D u_dem_prev;\n#endif\nuniform vec4 u_dem_unpack;uniform vec2 u_dem_tl;uniform vec2 u_dem_tl_prev;uniform float u_dem_scale;uniform float u_dem_scale_prev;uniform float u_dem_size;uniform float u_dem_lerp;uniform float u_exaggeration;uniform float u_meter_to_dem;uniform mat4 u_label_plane_matrix_inv;uniform sampler2D u_depth;uniform vec2 u_depth_size_inv;vec4 tileUvToDemSample(vec2 uv,float dem_size,float dem_scale,vec2 dem_tl) {vec2 pos=dem_size*(uv*dem_scale+dem_tl)+1.0;vec2 f=fract(pos);return vec4((pos-f+0.5)/(dem_size+2.0),f);}float decodeElevation(vec4 v) {return dot(vec4(v.xyz*255.0,-1.0),u_dem_unpack);}float currentElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale+u_dem_tl)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale,u_dem_tl);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem,pos));\n#ifdef TERRAIN_DEM_NEAREST_FILTER\nreturn u_exaggeration*tl;\n#endif\nfloat tr=decodeElevation(texture2D(u_dem,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}float prevElevation(vec2 apos) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nvec2 pos=(u_dem_size*(apos/8192.0*u_dem_scale_prev+u_dem_tl_prev)+1.5)/(u_dem_size+2.0);return u_exaggeration*texture2D(u_dem_prev,pos).a;\n#else\nfloat dd=1.0/(u_dem_size+2.0);vec4 r=tileUvToDemSample(apos/8192.0,u_dem_size,u_dem_scale_prev,u_dem_tl_prev);vec2 pos=r.xy;vec2 f=r.zw;float tl=decodeElevation(texture2D(u_dem_prev,pos));float tr=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,0.0)));float bl=decodeElevation(texture2D(u_dem_prev,pos+vec2(0.0,dd)));float br=decodeElevation(texture2D(u_dem_prev,pos+vec2(dd,dd)));return u_exaggeration*mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);\n#endif\n}\n#ifdef TERRAIN_VERTEX_MORPHING\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nfloat nextElevation=currentElevation(apos);float prevElevation=prevElevation(apos);return mix(prevElevation,nextElevation,u_dem_lerp);}\n#else\nfloat elevation(vec2 apos) {\n#ifdef ZERO_EXAGGERATION\nreturn 0.0;\n#endif\nreturn currentElevation(apos);}\n#endif\nhighp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}bool isOccluded(vec4 frag) {vec3 coord=frag.xyz/frag.w;float depth=unpack_depth(texture2D(u_depth,(coord.xy+1.0)*0.5));return coord.z > depth+0.0005;}float occlusionFade(vec4 frag) {vec3 coord=frag.xyz/frag.w;vec3 df=vec3(5.0*u_depth_size_inv,0.0);vec2 uv=0.5*coord.xy+0.5;vec4 depth=vec4(\nunpack_depth(texture2D(u_depth,uv-df.xz)),unpack_depth(texture2D(u_depth,uv+df.xz)),unpack_depth(texture2D(u_depth,uv-df.zy)),unpack_depth(texture2D(u_depth,uv+df.zy))\n);return dot(vec4(0.25),vec4(1.0)-clamp(300.0*(vec4(coord.z-0.001)-depth),0.0,1.0));}vec4 fourSample(vec2 pos,vec2 off) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nfloat tl=texture2D(u_dem,pos).a;float tr=texture2D(u_dem,pos+vec2(off.x,0.0)).a;float bl=texture2D(u_dem,pos+vec2(0.0,off.y)).a;float br=texture2D(u_dem,pos+off).a;\n#else\nvec4 demtl=vec4(texture2D(u_dem,pos).xyz*255.0,-1.0);float tl=dot(demtl,u_dem_unpack);vec4 demtr=vec4(texture2D(u_dem,pos+vec2(off.x,0.0)).xyz*255.0,-1.0);float tr=dot(demtr,u_dem_unpack);vec4 dembl=vec4(texture2D(u_dem,pos+vec2(0.0,off.y)).xyz*255.0,-1.0);float bl=dot(dembl,u_dem_unpack);vec4 dembr=vec4(texture2D(u_dem,pos+off).xyz*255.0,-1.0);float br=dot(dembr,u_dem_unpack);\n#endif\nreturn vec4(tl,tr,bl,br);}float flatElevation(vec2 pack) {vec2 apos=floor(pack/8.0);vec2 span=10.0*(pack-apos*8.0);vec2 uvTex=(apos-vec2(1.0,1.0))/8190.0;float size=u_dem_size+2.0;float dd=1.0/size;vec2 pos=u_dem_size*(uvTex*u_dem_scale+u_dem_tl)+1.0;vec2 f=fract(pos);pos=(pos-f+0.5)*dd;vec4 h=fourSample(pos,vec2(dd));float z=mix(mix(h.x,h.y,f.x),mix(h.z,h.w,f.x),f.y);vec2 w=floor(0.5*(span*u_meter_to_dem-1.0));vec2 d=dd*w;h=fourSample(pos-d,2.0*d+vec2(dd));vec4 diff=abs(h.xzxy-h.ywzw);vec2 slope=min(vec2(0.25),u_meter_to_dem*0.5*(diff.xz+diff.yw)/(2.0*w+vec2(1.0)));vec2 fix=slope*span;float base=z+max(fix.x,fix.y);return u_exaggeration*base;}float elevationFromUint16(float word) {return u_exaggeration*(word/ELEVATION_SCALE-ELEVATION_OFFSET);}\n#else\nfloat elevation(vec2 pos) { return 0.0; }bool isOccluded(vec4 frag) { return false; }float occlusionFade(vec4 frag) { return 1.0; }\n#endif",nn="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump mat4 u_fog_matrix;varying vec3 v_fog_pos;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}vec3 fog_position(vec3 pos) {return (u_fog_matrix*vec4(pos,1.0)).xyz;}vec3 fog_position(vec2 pos) {return fog_position(vec3(pos,0.0));}float fog(vec3 pos) {float depth=length(pos);float opacity=fog_opacity(fog_range(depth));return opacity*fog_horizon_blending(pos/depth);}\n#endif",rn="#ifdef FOG\nuniform mediump vec4 u_fog_color;uniform mediump vec2 u_fog_range;uniform mediump float u_fog_horizon_blend;uniform mediump float u_fog_temporal_offset;varying vec3 v_fog_pos;uniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform highp vec2 u_viewport;uniform float u_globe_transition;uniform int u_is_globe;float fog_range(float depth) {return (depth-u_fog_range[0])/(u_fog_range[1]-u_fog_range[0]);}float fog_horizon_blending(vec3 camera_dir) {float t=max(0.0,camera_dir.z/u_fog_horizon_blend);return u_fog_color.a*exp(-3.0*t*t);}float fog_opacity(float t) {const float decay=6.0;float falloff=1.0-min(1.0,exp(-decay*t));falloff*=falloff*falloff;return u_fog_color.a*min(1.0,1.00747*falloff);}float globe_glow_progress() {highp vec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);highp vec3 dir=normalize(ray_dir);highp vec3 closest_point=dot(u_globe_pos,dir)*dir;highp float sdf=length(closest_point-u_globe_pos)/u_globe_radius;return sdf+PI*0.5;}float fog_opacity(vec3 pos) {float depth=length(pos);return fog_opacity(fog_range(depth));}vec3 fog_apply(vec3 color,vec3 pos) {float depth=length(pos);float opacity;if (u_is_globe==1) {float glow_progress=globe_glow_progress();float t=mix(glow_progress,depth,u_globe_transition);opacity=fog_opacity(fog_range(t));} else {opacity=fog_opacity(fog_range(depth));opacity*=fog_horizon_blending(pos/depth);}return mix(color,u_fog_color.rgb,opacity);}vec4 fog_apply_from_vert(vec4 color,float fog_opac) {float alpha=EPSILON+color.a;color.rgb=mix(color.rgb/alpha,u_fog_color.rgb,fog_opac)*alpha;return color;}vec3 fog_apply_sky_gradient(vec3 camera_ray,vec3 sky_color) {float horizon_blend=fog_horizon_blending(normalize(camera_ray));return mix(sky_color,u_fog_color.rgb,horizon_blend);}vec4 fog_apply_premultiplied(vec4 color,vec3 pos) {float alpha=EPSILON+color.a;color.rgb=fog_apply(color.rgb/alpha,pos)*alpha;return color;}vec3 fog_dither(vec3 color) {vec2 dither_seed=gl_FragCoord.xy+u_fog_temporal_offset;return dither(color,dither_seed);}vec4 fog_dither(vec4 color) {return vec4(fog_dither(color.rgb),color.a);}\n#endif";let on={},an={};const sn=[];dn(Qt,sn),dn(tn,sn),dn(nn,sn),dn(rn,sn),on=fn("",tn),an=fn(rn,nn);const ln=fn("\nhighp vec3 hash(highp vec2 p) {highp vec3 p3=fract(p.xyx*vec3(443.8975,397.2973,491.1871));p3+=dot(p3,p3.yxz+19.19);return fract((p3.xxy+p3.yzz)*p3.zyx);}vec3 dither(vec3 color,highp vec2 seed) {vec3 rnd=hash(seed)+hash(seed+0.59374)-0.5;return color+rnd/255.0;}highp float unpack_depth(highp vec4 rgba_depth)\n{const highp vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);return dot(rgba_depth,bit_shift)*2.0-1.0;}highp vec4 pack_depth(highp float ndc_z) {highp float depth=ndc_z*0.5+0.5;const highp vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);const highp vec4 bit_mask =vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);highp vec4 res=fract(depth*bit_shift);res-=res.xxyz*bit_mask;return res;}","\nfloat wrap(float n,float min,float max) {float d=max-min;float w=mod(mod(n-min,d)+d,d)+min;return (w==min) ? max : w;}\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 mercator_tile_position(mat4 matrix,vec2 tile_anchor,vec3 tile_id,vec2 mercator_center) {\n#ifndef PROJECTED_POS_ON_VIEWPORT\nfloat tiles=tile_id.z;vec2 mercator=(tile_anchor/EXTENT+tile_id.xy)/tiles;mercator-=mercator_center;mercator.x=wrap(mercator.x,-0.5,0.5);vec4 mercator_tile=vec4(mercator.xy*EXTENT,EXTENT/(2.0*PI),1.0);mercator_tile=matrix*mercator_tile;return mercator_tile.xyz;\n#else\nreturn vec3(0.0);\n#endif\n}vec3 mix_globe_mercator(vec3 globe,vec3 mercator,float t) {return mix(globe,mercator,t);}mat3 globe_mercator_surface_vectors(vec3 pos_normal,vec3 up_dir,float zoom_transition) {vec3 normal=zoom_transition==0.0 ? pos_normal : normalize(mix(pos_normal,up_dir,zoom_transition));vec3 xAxis=normalize(vec3(normal.z,0.0,-normal.x));vec3 yAxis=normalize(cross(normal,xAxis));return mat3(xAxis,yAxis,normal);}\n#endif\nvec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(\nunpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0\n);}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;}const vec4 AWAY=vec4(-1000.0,-1000.0,-1000.0,1);//Normalized device coordinate that is not rendered."),un=Qt,cn="\n#ifdef GL_ES\nprecision mediump float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif";var hn={background:fn("uniform vec4 u_color;uniform float u_opacity;\n#ifdef LIGHTING_3D_MODE\nvarying vec4 v_color;\n#endif\nvoid main() {vec4 out_color;\n#ifdef LIGHTING_3D_MODE\nout_color=v_color;\n#else\nout_color=u_color;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#ifdef LIGHTING_3D_MODE\nuniform vec4 u_color;varying vec4 v_color;\n#endif\nvoid main() {gl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(u_color);\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),backgroundPattern:fn("uniform vec2 u_pattern_tl;uniform vec2 u_pattern_br;uniform vec2 u_texsize;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos;void main() {vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(u_pattern_tl/u_texsize,u_pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pattern_size;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_pattern_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),circle:fn("varying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(\nantialiased_blur,0.0,extrude_length-radius/(radius+stroke_width)\n);vec4 out_color=mix(color*opacity,stroke_color*stroke_opacity,color_t);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_apply_premultiplied(out_color,v_fog_pos);\n#endif\ngl_FragColor=out_color*(v_visibility*opacity_t);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","#define NUM_VISIBILITY_RINGS 2\n#define INV_SQRT2 0.70710678\n#define ELEVATION_BIAS 0.0001\n#define NUM_SAMPLES_PER_RING 16\nuniform mat4 u_matrix;uniform mat2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec3 v_data;varying float v_visibility;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define mediump float radius\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define highp vec4 stroke_color\n#pragma mapbox: define mediump float stroke_width\n#pragma mapbox: define lowp float stroke_opacity\nvec2 calc_offset(vec2 extrusion,float radius,float stroke_width, float view_scale) {return extrusion*(radius+stroke_width)*u_extrude_scale*view_scale;}float cantilevered_elevation(vec2 pos,float radius,float stroke_width,float view_scale) {vec2 c1=pos+calc_offset(vec2(-1,-1),radius,stroke_width,view_scale);vec2 c2=pos+calc_offset(vec2(1,-1),radius,stroke_width,view_scale);vec2 c3=pos+calc_offset(vec2(1,1),radius,stroke_width,view_scale);vec2 c4=pos+calc_offset(vec2(-1,1),radius,stroke_width,view_scale);float h1=elevation(c1)+ELEVATION_BIAS;float h2=elevation(c2)+ELEVATION_BIAS;float h3=elevation(c3)+ELEVATION_BIAS;float h4=elevation(c4)+ELEVATION_BIAS;return max(h4,max(h3,max(h1,h2)));}float circle_elevation(vec2 pos) {\n#if defined(TERRAIN)\nreturn elevation(pos)+ELEVATION_BIAS;\n#else\nreturn 0.0;\n#endif\n}vec4 project_vertex(vec2 extrusion,vec4 world_center,vec4 projected_center,float radius,float stroke_width, float view_scale,mat3 surface_vectors) {vec2 sample_offset=calc_offset(extrusion,radius,stroke_width,view_scale);\n#ifdef PITCH_WITH_MAP\n#ifdef PROJECTION_GLOBE_VIEW\nreturn u_matrix*( world_center+vec4(sample_offset.x*surface_vectors[0]+sample_offset.y*surface_vectors[1],0) );\n#else\nreturn u_matrix*( world_center+vec4(sample_offset,0,0) );\n#endif\n#else\nreturn projected_center+vec4(sample_offset,0,0);\n#endif\n}float get_sample_step() {\n#ifdef PITCH_WITH_MAP\nreturn 2.0*PI/float(NUM_SAMPLES_PER_RING);\n#else\nreturn PI/float(NUM_SAMPLES_PER_RING);\n#endif\n}void main(void) {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize mediump float radius\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize highp vec4 stroke_color\n#pragma mapbox: initialize mediump float stroke_width\n#pragma mapbox: initialize lowp float stroke_opacity\nvec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);vec4 world_center;mat3 surface_vectors;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(circle_center)*circle_elevation(circle_center);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*circle_elevation(circle_center);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,circle_center,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;vec3 pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);world_center=vec4(pos,1);\n#else \nsurface_vectors=mat3(1.0);float height=circle_elevation(circle_center);world_center=vec4(circle_center,height,1);\n#endif\nvec4 projected_center=u_matrix*world_center;float view_scale=0.0;\n#ifdef PITCH_WITH_MAP\n#ifdef SCALE_WITH_MAP\nview_scale=1.0;\n#else\nview_scale=projected_center.w/u_camera_to_center_distance;\n#endif\n#else\n#ifdef SCALE_WITH_MAP\nview_scale=u_camera_to_center_distance;\n#else\nview_scale=projected_center.w;\n#endif\n#endif\ngl_Position=project_vertex(extrude,world_center,projected_center,radius,stroke_width,view_scale,surface_vectors);float visibility=0.0;\n#ifdef TERRAIN\nfloat step=get_sample_step();vec4 occlusion_world_center;vec4 occlusion_projected_center;\n#ifdef PITCH_WITH_MAP\nfloat cantilevered_height=cantilevered_elevation(circle_center,radius,stroke_width,view_scale);occlusion_world_center=vec4(circle_center,cantilevered_height,1);occlusion_projected_center=u_matrix*occlusion_world_center;\n#else\nocclusion_world_center=world_center;occlusion_projected_center=projected_center;\n#endif\nfor(int ring=0; ring < NUM_VISIBILITY_RINGS; ring++) {float scale=(float(ring)+1.0)/float(NUM_VISIBILITY_RINGS);for(int i=0; i < NUM_SAMPLES_PER_RING; i++) {vec2 extrusion=vec2(cos(step*float(i)),-sin(step*float(i)))*scale;vec4 frag_pos=project_vertex(extrusion,occlusion_world_center,occlusion_projected_center,radius,stroke_width,view_scale,surface_vectors);visibility+=float(!isOccluded(frag_pos));}}visibility/=float(NUM_VISIBILITY_RINGS)*float(NUM_SAMPLES_PER_RING);\n#else\nvisibility=1.0;\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nvisibility=1.0;\n#endif\nv_visibility=visibility;lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);\n#ifdef FOG\nv_fog_pos=fog_position(world_center.xyz);\n#endif\n}"),clippingMask:fn("void main() {gl_FragColor=vec4(1.0);}","attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),heatmap:fn("uniform highp float u_intensity;varying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#define GAUSS_COEF 0.3989422804014327\nvoid main() {\n#pragma mapbox: initialize highp float weight\nfloat d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0);\n#ifdef FOG\nif (u_is_globe==0) {gl_FragColor.r*=pow(1.0-fog_opacity(v_fog_pos),2.0);}\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;\n#endif\nvarying vec2 v_extrude;\n#pragma mapbox: define highp float weight\n#pragma mapbox: define mediump float radius\nconst highp float ZERO=1.0/255.0/16.0;\n#define GAUSS_COEF 0.3989422804014327\nvoid main(void) {\n#pragma mapbox: initialize highp float weight\n#pragma mapbox: initialize mediump float radius\nvec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec2 tilePos=floor(a_pos*0.5);vec3 pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 pos_normal_3=a_pos_normal_3/16384.0;mat3 surface_vectors=globe_mercator_surface_vectors(pos_normal_3,u_up_dir,u_zoom_transition);vec3 surface_extrusion=extrude.x*surface_vectors[0]+extrude.y*surface_vectors[1];vec3 globe_elevation=elevationVector(tilePos)*elevation(tilePos);vec3 globe_pos=a_pos_3+surface_extrusion+globe_elevation;vec3 mercator_elevation=u_up_dir*u_tile_up_scale*elevation(tilePos);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,tilePos,u_tile_id,u_merc_center)+surface_extrusion+mercator_elevation;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#else\npos=vec3(tilePos+extrude,elevation(tilePos));\n#endif\ngl_Position=u_matrix*vec4(pos,1);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),heatmapTexture:fn("uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(0.0);\n#endif\n}","attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=vec4(a_pos,0,1);v_pos=a_pos*0.5+0.5;}"),collisionBox:fn("varying float v_placed;varying float v_notUsed;void main() {vec4 red =vec4(1.0,0.0,0.0,1.0);vec4 blue=vec4(0.0,0.0,1.0,0.5);gl_FragColor =mix(red,blue,step(0.5,v_placed))*0.5;gl_FragColor*=mix(1.0,0.1,step(0.5,v_notUsed));}","attribute vec3 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;attribute float a_size_scale;attribute vec2 a_padding;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_pos+elevationVector(a_anchor_pos)*elevation(a_anchor_pos),1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,1.5);gl_Position=projectedPoint;gl_Position.xy+=(a_extrude*a_size_scale+a_shift+a_padding)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:fn("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos_2f;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos_2f;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(\nmix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(\n0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:fn("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;\n#endif\nvarying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {float h=elevation(a_pos);v_uv=a_pos/8192.0;\n#ifdef PROJECTION_GLOBE_VIEW\ngl_Position=u_matrix*vec4(a_pos_3+elevationVector(a_pos)*h,1);\n#else\ngl_Position=u_matrix*vec4(a_pos*u_overlay_scale,h,1);\n#endif\n}"),fill:fn("#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\nvec4 out_color=color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutline:fn("varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=outline_color;\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos;\n#pragma mapbox: define highp vec4 outline_color\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize highp vec4 outline_color\n#pragma mapbox: initialize lowp float opacity\ngl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillOutlinePattern:fn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);float dist=length(v_pos_world-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;varying vec2 v_pos_world;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);v_pos_world=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillPattern:fn("uniform vec2 u_texsize;uniform sampler2D u_image;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color*opacity;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos;\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,a_pos);\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),fillExtrusion:fn("varying vec4 v_color;\n#ifdef RENDER_SHADOWS\nvarying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\nvoid main() {\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvec3 normal=v_normal;\n#endif\nfloat z;vec4 color;\n#ifdef ZERO_ROOF_RADIUS\nz=float(normal.z > 0.00001);color=mix(v_color,v_roof_color,z);\n#else\ncolor=v_color;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;\n#ifdef ZERO_ROOF_RADIUS\nconcave*=(1.0-z);\n#endif\nfloat x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);color.rgb=color.rgb*shade;\n#endif\n#ifdef RENDER_SHADOWS\n#ifdef ZERO_ROOF_RADIUS\nnormal=mix(normal,vec3(0.0,0.0,1.0),z);\n#endif\ncolor.xyz=shadowed_color_normal(color.xyz,normalize(normal),v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform float u_edge_radius;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec4 v_color;\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying highp vec4 v_pos_light_view_0;varying highp vec4 v_pos_light_view_1;varying float v_depth;\n#endif\n#ifdef ZERO_ROOF_RADIUS\nvarying vec4 v_roof_color;\n#endif\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nvarying highp vec3 v_normal;\n#endif\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#pragma mapbox: define highp float base\n#pragma mapbox: define highp float height\n#pragma mapbox: define highp vec4 color\nvoid main() {\n#pragma mapbox: initialize highp float base\n#pragma mapbox: initialize highp float height\n#pragma mapbox: initialize highp vec4 color\nvec4 pos_nx=floor(a_pos_normal_ed*0.5);vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));\n#if defined(ZERO_ROOF_RADIUS) || defined(RENDER_SHADOWS)\nv_normal=normal;\n#endif\nbase=max(0.0,base);height=max(0.0,top_up_ny.y==0.0 && top_up_ny.x==1.0 ? height-u_edge_radius : height);float t=top_up_ny.x;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=0.0;float c_ele;vec3 pos;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);pos=vec3(pos_nx.xy,h);\n#else\nh=t > 0.0 ? height : base;pos=vec3(pos_nx.xy,h);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*h);vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,pos.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*pos.z;pos=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(pos,1),AWAY,hidden);\n#ifdef RENDER_SHADOWS\nv_pos_light_view_0=u_light_matrix_0*vec4(pos,1);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1);v_depth=gl_Position.w;\n#endif\nfloat NdotL=0.0;float colorvalue=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\ncolorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;NdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}v_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_color=apply_lighting(color,NdotL);\n#else\nv_color.rgb+=clamp(color.rgb*NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_color*=u_opacity;\n#ifdef ZERO_ROOF_RADIUS\nv_roof_color=vec4(0.0,0.0,0.0,1.0);\n#ifdef LIGHTING_3D_MODE\nv_roof_color=apply_lighting(color,calculate_NdotL(vec3(0.0,0.0,1.0)));\n#else\nfloat roofNdotL=clamp(u_lightpos.z,0.0,1.0);roofNdotL=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),roofNdotL);v_roof_color.rgb+=clamp(color.rgb*roofNdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));\n#endif\nv_roof_color*=u_opacity;\n#endif\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),fillExtrusionPattern:fn("uniform vec2 u_texsize;uniform sampler2D u_image;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;uniform lowp float u_opacity;\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 imagecoord=mod(v_pos,1.0);vec2 pos=mix(pattern_tl/u_texsize,pattern_br/u_texsize,imagecoord);vec4 out_color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color,v_NdotL)*u_opacity;\n#else\nout_color=out_color*v_lighting;\n#endif\n#ifdef FAUX_AO\nfloat intensity=u_ao[0];float h=max(0.0,v_ao.z);float h_floors=h/u_ao[1];float y_shade=1.0-0.9*intensity*min(v_ao.y,1.0);float shade=(1.0-0.08*intensity)*(y_shade+(1.0-y_shade)*(1.0-pow(1.0-min(h_floors/16.0,1.0),16.0)))+0.08*intensity*min(h_floors/160.0,1.0);float concave=v_ao.x*v_ao.x;float x_shade=mix(1.0,mix(0.6,0.75,min(h_floors/30.0,1.0)),intensity)+0.1*intensity*min(h,1.0);shade*=mix(1.0,x_shade*x_shade*x_shade,concave);out_color.rgb=out_color.rgb*shade;\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\ngl_FragColor=out_color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform float u_tile_units_to_pixels;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec4 a_pos_normal_ed;attribute vec2 a_centroid_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_pos_3;attribute vec3 a_pos_normal_3;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_tile_id;uniform float u_zoom_transition;uniform vec3 u_up_dir;uniform float u_height_lift;\n#endif\nvarying vec2 v_pos;varying vec4 v_lighting;\n#ifdef FAUX_AO\nuniform lowp vec2 u_ao;varying vec3 v_ao;\n#endif\n#ifdef LIGHTING_3D_MODE\nvarying float v_NdotL;\n#endif\n#pragma mapbox: define lowp float base\n#pragma mapbox: define lowp float height\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float base\n#pragma mapbox: initialize lowp float height\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec4 pos_nx=floor(a_pos_normal_ed*0.5);mediump vec4 top_up_ny_start=a_pos_normal_ed-2.0*pos_nx;mediump vec3 top_up_ny=top_up_ny_start.xyz;float x_normal=pos_nx.z/8192.0;vec3 normal=top_up_ny.y==1.0 ? vec3(0.0,0.0,1.0) : normalize(vec3(x_normal,(2.0*top_up_ny.z-1.0)*(1.0-abs(x_normal)),0.0));float edgedistance=a_pos_normal_ed.w;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;base=max(0.0,base);height=max(0.0,height);float t=top_up_ny.x;float z=t > 0.0 ? height : base;vec2 centroid_pos=vec2(0.0);\n#if defined(HAS_CENTROID) || defined(TERRAIN)\ncentroid_pos=a_centroid_pos;\n#endif\nfloat ele=0.0;float h=z;vec3 p;float c_ele;\n#ifdef TERRAIN\nbool flat_roof=centroid_pos.x !=0.0 && t > 0.0;ele=elevation(pos_nx.xy);c_ele=flat_roof ? centroid_pos.y==0.0 ? elevationFromUint16(centroid_pos.x) : flatElevation(centroid_pos) : ele;h=flat_roof ? max(c_ele+height,ele+base+2.0) : ele+(t > 0.0 ? height : base==0.0 ?-5.0 : base);p=vec3(pos_nx.xy,h);\n#else\np=vec3(pos_nx.xy,z);\n#endif\n#ifdef PROJECTION_GLOBE_VIEW\nfloat lift=float((t+base) > 0.0)*u_height_lift;h+=lift;vec3 globe_normal=normalize(mix(a_pos_normal_3/16384.0,u_up_dir,u_zoom_transition));vec3 globe_pos=a_pos_3+globe_normal*(u_tile_up_scale*(p.z+lift));vec3 merc_pos=mercator_tile_position(u_inv_rot_matrix,p.xy,u_tile_id,u_merc_center)+u_up_dir*u_tile_up_scale*p.z;p=mix_globe_mercator(globe_pos,merc_pos,u_zoom_transition);\n#endif\nfloat hidden=float(centroid_pos.x==0.0 && centroid_pos.y==1.0);gl_Position=mix(u_matrix*vec4(p,1),AWAY,hidden);vec2 pos=normal.z==1.0\n? pos_nx.xy\n: vec2(edgedistance,z*u_height_factor);v_pos=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,display_size,u_tile_units_to_pixels,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float NdotL=0.0;\n#ifdef LIGHTING_3D_MODE\nNdotL=calculate_NdotL(normal);\n#else\nNdotL=clamp(dot(normal,u_lightpos),0.0,1.0);NdotL=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),NdotL);\n#endif\nif (normal.y !=0.0) {float r=0.84;\n#ifndef LIGHTING_3D_MODE\nr=mix(0.7,0.98,1.0-u_lightintensity);\n#endif\nNdotL*=(\n(1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),r,1.0)));}\n#ifdef FAUX_AO\nfloat concave=pos_nx.w-floor(pos_nx.w*0.5)*2.0;float start=top_up_ny_start.w;float y_ground=1.0-clamp(t+base,0.0,1.0);float top_height=height;\n#ifdef TERRAIN\ntop_height=mix(max(c_ele+height,ele+base+2.0),ele+height,float(centroid_pos.x==0.0))-ele;y_ground+=y_ground*5.0/max(3.0,top_height);\n#endif\nv_ao=vec3(mix(concave,-concave,start),y_ground,h-ele);NdotL*=(1.0+0.05*(1.0-top_up_ny.y)*u_ao[0]);\n#ifdef PROJECTION_GLOBE_VIEW\ntop_height+=u_height_lift;\n#endif\ngl_Position.z-=(0.0000006*(min(top_height,500.)+2.0*min(base,500.0)+60.0*concave+3.0*start))*gl_Position.w;\n#endif\n#ifdef LIGHTING_3D_MODE\nv_NdotL=NdotL;\n#else\nv_lighting.rgb+=clamp(NdotL*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;\n#endif \n#ifdef FOG\nv_fog_pos=fog_position(p);\n#endif\n}"),hillshadePrepare:fn("#ifdef GL_ES\nprecision highp float;\n#endif\nuniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord) {\n#ifdef TERRAIN_DEM_FLOAT_FORMAT\nreturn texture2D(u_image,coord).a/4.0;\n#else\nvec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;\n#endif\n}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y));float b=getElevation(v_pos+vec2(0,-epsilon.y));float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y));float d=getElevation(v_pos+vec2(-epsilon.x,0));float e=getElevation(v_pos+vec2(epsilon.x,0));float f=getElevation(v_pos+vec2(-epsilon.x,epsilon.y));float g=getElevation(v_pos+vec2(0,epsilon.y));float h=getElevation(v_pos+vec2(epsilon.x,epsilon.y));float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2(\n(c+e+e+h)-(a+d+d+f),(f+g+g+h)-(a+b+b+c)\n)/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(\nderiv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:fn("uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent;void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color;\n#ifdef LIGHTING_3D_MODE\ngl_FragColor=apply_lighting(gl_FragColor);\n#endif\n#ifdef FOG\ngl_FragColor=fog_dither(fog_apply_premultiplied(gl_FragColor,v_fog_pos));\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),line:fn("uniform lowp float u_device_pixel_ratio;uniform float u_alpha_discard_threshold;uniform highp vec2 u_trim_offset;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform sampler2D u_dash_image;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform sampler2D u_gradient_image;\n#endif\nuniform float u_border_width;uniform vec4 u_border_color;float luminance(vec3 c) {return (c.r+c.r+c.b+c.g+c.g+c.g)*0.1667;}\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nfloat linearstep(float edge0,float edge1,float x) {return clamp((x-edge0)/(edge1-edge0),0.0,1.0);}void main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nfloat dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);\n#ifdef RENDER_LINE_DASH\nfloat sdfdist=texture2D(u_dash_image,v_tex).a;float sdfgamma=1.0/(2.0*u_device_pixel_ratio)/dash.z;alpha*=linearstep(0.5-sdfgamma/floorwidth,0.5+sdfgamma/floorwidth,sdfdist);\n#endif\nhighp vec4 out_color;\n#ifdef RENDER_LINE_GRADIENT\nout_color=texture2D(u_gradient_image,v_uv.xy);\n#else\nout_color=color;\n#endif\n#ifdef RENDER_LINE_TRIM_OFFSET\nhighp float start=v_uv[2];highp float end=v_uv[3];highp float trim_start=u_trim_offset[0];highp float trim_end=u_trim_offset[1];highp float line_progress=(start+(v_uv.x)*(end-start));if (trim_end > trim_start) {if (line_progress <=trim_end && line_progress >=trim_start) {out_color=vec4(0,0,0,0);}}\n#endif\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply_premultiplied(out_color,v_fog_pos));\n#endif\n#ifdef RENDER_LINE_ALPHA_DISCARD\nif (alpha < u_alpha_discard_threshold) {discard;}\n#endif\n#ifdef RENDER_LINE_BORDER\nfloat edgeBlur=(u_border_width+1.0/u_device_pixel_ratio);float alpha2=clamp(min(dist-(v_width2.t-edgeBlur),v_width2.s-dist)/edgeBlur,0.0,1.0);if (alpha2 < 1.) {float smoothAlpha=smoothstep(0.6,1.0,alpha2);\n#ifdef RENDER_LINE_BORDER_AUTO\nfloat Y=(out_color.a > 0.01) ? luminance(out_color.rgb/out_color.a) : 1.;float adjustment=(Y > 0.) ? 0.5/Y : 0.45;if (out_color.a > 0.25 && Y < 0.25) {vec3 borderColor=(Y > 0.) ? out_color.rgb : vec3(1,1,1)*out_color.a;out_color.rgb=out_color.rgb+borderColor*(adjustment*(1.0-smoothAlpha));} else {out_color.rgb*=(0.6 +0.4*smoothAlpha);}\n#else\nout_color.rgb=mix(u_border_color.rgb,out_color.rgb,smoothAlpha);\n#endif\n}\n#endif\ngl_FragColor=out_color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define EXTRUDE_SCALE 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nattribute highp vec4 a_packed;\n#endif\n#ifdef RENDER_LINE_DASH\nattribute float a_linesofar;\n#endif\nuniform mat4 u_matrix;uniform mat2 u_pixels_to_tile_units;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec4 v_uv;\n#ifdef RENDER_LINE_DASH\nuniform vec2 u_texsize;uniform float u_tile_units_to_pixels;varying vec2 v_tex;\n#endif\n#ifdef RENDER_LINE_GRADIENT\nuniform float u_image_height;\n#endif\n#pragma mapbox: define highp vec4 color\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 dash\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float width\nvoid main() {\n#pragma mapbox: initialize highp vec4 color\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize lowp vec4 dash\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float width\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*EXTRUDE_SCALE;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*EXTRUDE_SCALE*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\n#if defined(RENDER_LINE_GRADIENT) || defined(RENDER_LINE_TRIM_OFFSET)\nfloat a_uv_x=a_packed[0];float a_split_index=a_packed[1];highp float a_clip_start=a_packed[2];highp float a_clip_end=a_packed[3];\n#ifdef RENDER_LINE_GRADIENT\nhighp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec4(a_uv_x,a_split_index*texel_height-half_texel_height,a_clip_start,a_clip_end);\n#else\nv_uv=vec4(a_uv_x,0.0,a_clip_start,a_clip_end);\n#endif\n#endif\n#ifdef RENDER_LINE_DASH\nfloat scale=dash.z==0.0 ? 0.0 : u_tile_units_to_pixels/dash.z;float height=dash.y;v_tex=vec2(a_linesofar*scale/floorwidth,(-normal.y*height+dash.x+0.5)/u_texsize.y);\n#endif\nv_width2=vec2(outset,inset);\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),linePattern:fn("uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_tile_units_to_pixels;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\nvec2 pattern_tl=pattern.xy;vec2 pattern_br=pattern.zw;vec2 display_size=(pattern_br-pattern_tl)/pixel_ratio;vec2 pattern_size=vec2(display_size.x/u_tile_units_to_pixels,display_size.y);float aspect=display_size.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x=mod(v_linesofar/pattern_size.x*aspect,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos=mix(pattern_tl*texel_size-texel_size,pattern_br*texel_size+texel_size,vec2(x,y));vec4 color=texture2D(u_image,pos);\n#ifdef LIGHTING_3D_MODE\ncolor=apply_lighting(color);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color*(alpha*opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","\n#define scale 0.015873016\nattribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_linesofar;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mat2 u_pixels_to_tile_units;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width;\n#pragma mapbox: define lowp float blur\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float offset\n#pragma mapbox: define mediump float gapwidth\n#pragma mapbox: define mediump float width\n#pragma mapbox: define lowp float floorwidth\n#pragma mapbox: define lowp vec4 pattern\n#pragma mapbox: define lowp float pixel_ratio\nvoid main() {\n#pragma mapbox: initialize lowp float blur\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float offset\n#pragma mapbox: initialize mediump float gapwidth\n#pragma mapbox: initialize mediump float width\n#pragma mapbox: initialize lowp float floorwidth\n#pragma mapbox: initialize mediump vec4 pattern\n#pragma mapbox: initialize lowp float pixel_ratio\nfloat ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist*u_pixels_to_tile_units,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2*u_pixels_to_tile_units,0.0,1.0)+projected_extrude;\n#ifndef RENDER_TO_TEXTURE\nfloat extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective;\n#else\nv_gamma_scale=1.0;\n#endif\nv_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;\n#ifdef FOG\nv_fog_pos=fog_position(pos);\n#endif\n}"),raster:fn("uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(\ndot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);vec3 out_color=mix(u_high_vec,u_low_vec,rgb);\n#ifdef LIGHTING_3D_MODE\nout_color=apply_lighting(out_color);\n#endif\n#ifdef FOG\nout_color=fog_dither(fog_apply(out_color,v_fog_pos));\n#endif\ngl_FragColor=vec4(out_color*color.a,color.a);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform vec2 u_perspective_transform;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {float w=1.0+dot(a_texture_pos,u_perspective_transform);gl_Position=u_matrix*vec4(a_pos*w,0,w);v_pos0=a_texture_pos/8192.0;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;\n#ifdef FOG\nv_fog_pos=fog_position(a_pos);\n#endif\n}"),symbolIcon:fn("uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nlowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_tex;varying float v_fade_opacity;\n#pragma mapbox: define lowp float opacity\nvoid main() {\n#pragma mapbox: initialize lowp float opacity\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_min_font_scale=a_pixeloffset.zw/256.0;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetProjected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetProjected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetProjected_point.xy/offsetProjected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*max(a_min_font_scale,font_scale)+a_pxoffset/16.0);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;v_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change))*projection_transition_fade;}"),symbolSDF:fn("#define SDF_PX 8.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_pixeloffset;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec2 v_data0;varying vec3 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetprojected_point;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 displacement=vec3(a_globe_normal.z,0,-a_globe_normal.x);offsetprojected_point=u_matrix*vec4(a_globe_anchor+displacement,1);\n#else\noffsetprojected_point=u_matrix*vec4(tile_anchor+vec2(1,0),0,1);\n#endif\nvec2 a=projected_point.xy/projected_point.w;vec2 b=offsetprojected_point.xy/offsetprojected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nvec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade);}"),symbolTextAndIcon:fn("#define SDF_PX 8.0\n#define SDF 1.0\n#define ICON 0.0\nuniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nfloat fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\nreturn;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","attribute vec4 a_pos_offset;attribute vec4 a_tex_size;attribute vec4 a_projected_pos;attribute float a_fade_opacity;\n#ifdef PROJECTION_GLOBE_VIEW\nattribute vec3 a_globe_anchor;attribute vec3 a_globe_normal;\n#endif\nuniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec3 u_up_vector;uniform vec2 u_texsize_icon;\n#ifdef PROJECTION_GLOBE_VIEW\nuniform vec3 u_tile_id;uniform mat4 u_inv_rot_matrix;uniform vec2 u_merc_center;uniform vec3 u_camera_forward;uniform float u_zoom_transition;uniform vec3 u_ecef_origin;uniform mat4 u_tile_matrix;\n#endif\nvarying vec4 v_data0;varying vec4 v_data1;\n#pragma mapbox: define highp vec4 fill_color\n#pragma mapbox: define highp vec4 halo_color\n#pragma mapbox: define lowp float opacity\n#pragma mapbox: define lowp float halo_width\n#pragma mapbox: define lowp float halo_blur\nvoid main() {\n#pragma mapbox: initialize highp vec4 fill_color\n#pragma mapbox: initialize highp vec4 halo_color\n#pragma mapbox: initialize lowp float opacity\n#pragma mapbox: initialize lowp float halo_width\n#pragma mapbox: initialize lowp float halo_blur\nvec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_tex_size.xy;vec2 a_size=a_tex_size.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;highp float segment_angle=-a_projected_pos[3];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec2 tile_anchor=a_pos;vec3 h=elevationVector(tile_anchor)*elevation(tile_anchor);float globe_occlusion_fade;vec3 world_pos;vec3 mercator_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nmercator_pos=mercator_tile_position(u_inv_rot_matrix,tile_anchor,u_tile_id,u_merc_center);world_pos=mix_globe_mercator(a_globe_anchor+h,mercator_pos,u_zoom_transition);vec4 ecef_point=u_tile_matrix*vec4(world_pos,1.0);vec3 origin_to_point=ecef_point.xyz-u_ecef_origin;globe_occlusion_fade=dot(origin_to_point,u_camera_forward) >=0.0 ? 0.0 : 1.0;\n#else\nworld_pos=vec3(tile_anchor,0)+h;globe_occlusion_fade=1.0;\n#endif\nvec4 projected_point=u_matrix*vec4(world_pos,1);highp float camera_to_anchor_distance=projected_point.w;highp float distance_ratio=u_pitch_with_map ?\ncamera_to_anchor_distance/u_camera_to_center_distance :\nu_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(\n0.5+0.5*distance_ratio,0.0,1.5);size*=perspective_ratio;float font_scale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offset_projected_point=u_matrix*vec4(a_pos+vec2(1,0),0,1);vec2 a=projected_point.xy/projected_point.w;vec2 b=offset_projected_point.xy/offset_projected_point.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}vec4 projected_pos;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 proj_pos=mix_globe_mercator(a_projected_pos.xyz+h,mercator_pos,u_zoom_transition);projected_pos=u_label_plane_matrix*vec4(proj_pos,1.0);\n#else\nprojected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,h.z,1.0);\n#endif\nhighp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);float z=0.0;vec2 offset=rotation_matrix*(a_offset/32.0*font_scale);\n#ifdef TERRAIN\n#ifdef PITCH_WITH_MAP_TERRAIN\nvec4 tile_pos=u_label_plane_matrix_inv*vec4(a_projected_pos.xy+offset,0.0,1.0);z=elevation(tile_pos.xy);\n#endif\n#endif\nfloat occlusion_fade=occlusionFade(projected_point)*globe_occlusion_fade;\n#ifdef PROJECTION_GLOBE_VIEW\nvec3 xAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,u_up_vector)) : vec3(1,0,0);vec3 yAxis=u_pitch_with_map ? normalize(cross(a_globe_normal,xAxis)) : vec3(0,1,0);gl_Position=mix(u_coord_matrix*vec4(projected_pos.xyz/projected_pos.w+xAxis*offset.x+yAxis*offset.y,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#else\ngl_Position=mix(u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+offset,z,1.0),AWAY,float(projected_point.w <=0.0 || occlusion_fade==0.0));\n#endif\nfloat gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(occlusion_fade,fade_opacity[0]+fade_change));float projection_transition_fade=1.0;\n#if defined(PROJECTED_POS_ON_VIEWPORT) && defined(PROJECTION_GLOBE_VIEW)\nprojection_transition_fade=1.0-step(EPSILON,u_zoom_transition);\n#endif\nv_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity*projection_transition_fade,is_sdf);}"),terrainRaster:fn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nvarying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nvoid main() {vec4 color=texture2D(u_image0,v_pos0);\n#ifdef RENDER_SHADOWS\ncolor.xyz=shadowed_color(color.xyz,v_pos_light_view_0,v_pos_light_view_1,v_depth);\n#endif\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#else\ncolor=fog_dither(fog_apply_from_vert(color,v_fog_opacity));\n#endif\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_matrix;uniform float u_skirt_height;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;\n#ifdef FOG\nvarying float v_fog_opacity;\n#endif\n#ifdef RENDER_SHADOWS\nuniform mat4 u_light_matrix_0;uniform mat4 u_light_matrix_1;varying vec4 v_pos_light_view_0;varying vec4 v_pos_light_view_1;varying float v_depth;\n#endif\nconst float skirtOffset=24575.0;const float wireframeOffset=0.00015;void main() {v_pos0=a_texture_pos/8192.0;float skirt=float(a_pos.x >=skirtOffset);float elevation=elevation(a_texture_pos)-skirt*u_skirt_height;\n#ifdef TERRAIN_WIREFRAME\nelevation+=u_skirt_height*u_skirt_height*wireframeOffset;\n#endif\nvec2 decodedPos=a_pos-vec2(skirt*skirtOffset,0.0);gl_Position=u_matrix*vec4(decodedPos,elevation,1.0);\n#ifdef FOG\n#ifdef ZERO_EXAGGERATION\nv_fog_pos=fog_position(decodedPos);\n#else\nv_fog_opacity=fog(fog_position(vec3(decodedPos,elevation)));\n#endif\n#endif\n#ifdef RENDER_SHADOWS\nvec3 pos=vec3(decodedPos,elevation);v_pos_light_view_0=u_light_matrix_0*vec4(pos,1.);v_pos_light_view_1=u_light_matrix_1*vec4(pos,1.);v_depth=gl_Position.w;\n#endif\n}"),terrainDepth:fn("#ifdef GL_ES\nprecision highp float;\n#endif\nvarying float v_depth;void main() {gl_FragColor=pack_depth(v_depth);}","uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying float v_depth;void main() {float elevation=elevation(a_texture_pos);gl_Position=u_matrix*vec4(a_pos,elevation,1.0);v_depth=gl_Position.z/gl_Position.w;}"),skybox:fn("\nvarying lowp vec3 v_uv;uniform lowp samplerCube u_cubemap;uniform lowp float u_opacity;uniform highp float u_temporal_offset;uniform highp vec3 u_sun_direction;float sun_disk(highp vec3 ray_direction,highp vec3 sun_direction) {highp float cos_angle=dot(normalize(ray_direction),sun_direction);const highp float cos_sun_angular_diameter=0.99996192306;const highp float smoothstep_delta=1e-5;return smoothstep(\ncos_sun_angular_diameter-smoothstep_delta,cos_sun_angular_diameter+smoothstep_delta,cos_angle);}float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec3 uv=v_uv;const float y_bias=0.015;uv.y+=y_bias;uv.y=pow(abs(uv.y),1.0/5.0);uv.y=map(uv.y,0.0,1.0,-1.0,1.0);vec3 sky_color=textureCube(u_cubemap,uv).rgb;\n#ifdef FOG\nsky_color=fog_apply_sky_gradient(v_uv.xzy,sky_color);\n#endif\nsky_color.rgb=dither(sky_color.rgb,gl_FragCoord.xy+u_temporal_offset);sky_color+=0.1*sun_disk(v_uv,u_sun_direction);gl_FragColor=vec4(sky_color*u_opacity,u_opacity);\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",en),skyboxGradient:fn("varying highp vec3 v_uv;uniform lowp sampler2D u_color_ramp;uniform highp vec3 u_center_direction;uniform lowp float u_radius;uniform lowp float u_opacity;uniform highp float u_temporal_offset;void main() {float progress=acos(dot(normalize(v_uv),u_center_direction))/u_radius;vec4 color=texture2D(u_color_ramp,vec2(progress,0.5));\n#ifdef FOG\ncolor.rgb=fog_apply_sky_gradient(v_uv.xzy,color.rgb/color.a)*color.a;\n#endif\ncolor*=u_opacity;color.rgb=dither(color.rgb,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=color;\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}",en),skyboxCapture:fn("\nvarying highp vec3 v_position;uniform highp float u_sun_intensity;uniform highp float u_luminance;uniform lowp vec3 u_sun_direction;uniform highp vec4 u_color_tint_r;uniform highp vec4 u_color_tint_m;\n#ifdef GL_ES\nprecision highp float;\n#endif\n#define BETA_R vec3(5.5e-6,13.0e-6,22.4e-6)\n#define BETA_M vec3(21e-6,21e-6,21e-6)\n#define MIE_G 0.76\n#define DENSITY_HEIGHT_SCALE_R 8000.0\n#define DENSITY_HEIGHT_SCALE_M 1200.0\n#define PLANET_RADIUS 6360e3\n#define ATMOSPHERE_RADIUS 6420e3\n#define SAMPLE_STEPS 10\n#define DENSITY_STEPS 4\nfloat ray_sphere_exit(vec3 orig,vec3 dir,float radius) {float a=dot(dir,dir);float b=2.0*dot(dir,orig);float c=dot(orig,orig)-radius*radius;float d=sqrt(b*b-4.0*a*c);return (-b+d)/(2.0*a);}vec3 extinction(vec2 density) {return exp(-vec3(BETA_R*u_color_tint_r.a*density.x+BETA_M*u_color_tint_m.a*density.y));}vec2 local_density(vec3 point) {float height=max(length(point)-PLANET_RADIUS,0.0);float exp_r=exp(-height/DENSITY_HEIGHT_SCALE_R);float exp_m=exp(-height/DENSITY_HEIGHT_SCALE_M);return vec2(exp_r,exp_m);}float phase_ray(float cos_angle) {return (3.0/(16.0*PI))*(1.0+cos_angle*cos_angle);}float phase_mie(float cos_angle) {return (3.0/(8.0*PI))*((1.0-MIE_G*MIE_G)*(1.0+cos_angle*cos_angle))/((2.0+MIE_G*MIE_G)*pow(1.0+MIE_G*MIE_G-2.0*MIE_G*cos_angle,1.5));}vec2 density_to_atmosphere(vec3 point,vec3 light_dir) {float ray_len=ray_sphere_exit(point,light_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(DENSITY_STEPS);vec2 density_point_to_atmosphere=vec2(0.0);for (int i=0; i < DENSITY_STEPS;++i) {vec3 point_on_ray=point+light_dir*((float(i)+0.5)*step_len);density_point_to_atmosphere+=local_density(point_on_ray)*step_len;;}return density_point_to_atmosphere;}vec3 atmosphere(vec3 ray_dir,vec3 sun_direction,float sun_intensity) {vec2 density_orig_to_point=vec2(0.0);vec3 scatter_r=vec3(0.0);vec3 scatter_m=vec3(0.0);vec3 origin=vec3(0.0,PLANET_RADIUS,0.0);float ray_len=ray_sphere_exit(origin,ray_dir,ATMOSPHERE_RADIUS);float step_len=ray_len/float(SAMPLE_STEPS);for (int i=0; i < SAMPLE_STEPS;++i) {vec3 point_on_ray=origin+ray_dir*((float(i)+0.5)*step_len);vec2 density=local_density(point_on_ray)*step_len;density_orig_to_point+=density;vec2 density_point_to_atmosphere=density_to_atmosphere(point_on_ray,sun_direction);vec2 density_orig_to_atmosphere=density_orig_to_point+density_point_to_atmosphere;vec3 extinction=extinction(density_orig_to_atmosphere);scatter_r+=density.x*extinction;scatter_m+=density.y*extinction;}float cos_angle=dot(ray_dir,sun_direction);float phase_r=phase_ray(cos_angle);float phase_m=phase_mie(cos_angle);vec3 beta_r=BETA_R*u_color_tint_r.rgb*u_color_tint_r.a;vec3 beta_m=BETA_M*u_color_tint_m.rgb*u_color_tint_m.a;return (scatter_r*phase_r*beta_r+scatter_m*phase_m*beta_m)*sun_intensity;}const float A=0.15;const float B=0.50;const float C=0.10;const float D=0.20;const float E=0.02;const float F=0.30;vec3 uncharted2_tonemap(vec3 x) {return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;}void main() {vec3 ray_direction=v_position;ray_direction.y=pow(ray_direction.y,5.0);const float y_bias=0.015;ray_direction.y+=y_bias;vec3 color=atmosphere(normalize(ray_direction),u_sun_direction,u_sun_intensity);float white_scale=1.0748724675633854;color=uncharted2_tonemap((log2(2.0/pow(u_luminance,4.0)))*color)*white_scale;gl_FragColor=vec4(color,1.0);}","attribute highp vec3 a_pos_3f;uniform mat3 u_matrix_3f;varying highp vec3 v_position;float map(float value,float start,float end,float new_start,float new_end) {return ((value-start)*(new_end-new_start))/(end-start)+new_start;}void main() {vec4 pos=vec4(u_matrix_3f*a_pos_3f,1.0);v_position=pos.xyz;v_position.y*=-1.0;v_position.y=map(v_position.y,-1.0,1.0,0.0,1.0);gl_Position=vec4(a_pos_3f.xy,0.0,1.0);}"),globeRaster:fn("uniform sampler2D u_image0;varying vec2 v_pos0;\n#ifndef FOG\nuniform highp vec3 u_frustum_tl;uniform highp vec3 u_frustum_tr;uniform highp vec3 u_frustum_br;uniform highp vec3 u_frustum_bl;uniform highp vec3 u_globe_pos;uniform highp float u_globe_radius;uniform vec2 u_viewport;\n#endif\nvoid main() {vec4 color;\n#ifdef CUSTOM_ANTIALIASING\nvec2 uv=gl_FragCoord.xy/u_viewport;highp vec3 ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,uv.x),mix(u_frustum_bl,u_frustum_br,uv.x),1.0-uv.y);vec3 dir=normalize(ray_dir);vec3 closest_point=dot(u_globe_pos,dir)*dir;float norm_dist_from_center=1.0-length(closest_point-u_globe_pos)/u_globe_radius;const float antialias_pixel=2.0;float antialias_factor=antialias_pixel*fwidth(norm_dist_from_center);float antialias=smoothstep(0.0,antialias_factor,norm_dist_from_center);vec4 raster=texture2D(u_image0,v_pos0);color=vec4(raster.rgb*antialias,raster.a*antialias);\n#else\ncolor=texture2D(u_image0,v_pos0);\n#endif\n#ifdef FOG\ncolor=fog_dither(fog_apply_premultiplied(color,v_fog_pos));\n#endif\ngl_FragColor=color;\n#ifdef TERRAIN_WIREFRAME\ngl_FragColor=vec4(1.0,0.0,0.0,0.8);\n#endif\n#ifdef OVERDRAW_INSPECTOR\ngl_FragColor=vec4(1.0);\n#endif\n}","uniform mat4 u_proj_matrix;uniform mat4 u_normalize_matrix;uniform mat4 u_globe_matrix;uniform mat4 u_merc_matrix;uniform float u_zoom_transition;uniform vec2 u_merc_center;uniform mat3 u_grid_matrix;\n#ifdef GLOBE_POLES\nattribute vec3 a_globe_pos;attribute vec2 a_uv;\n#else\nattribute vec2 a_pos;\n#endif\nvarying vec2 v_pos0;const float wireframeOffset=1e3;float mercatorXfromLng(float lng) {return (180.0+lng)/360.0;}float mercatorYfromLat(float lat) {return (180.0-(RAD_TO_DEG*log(tan(QUARTER_PI+lat/2.0*DEG_TO_RAD))))/360.0;}vec3 latLngToECEF(vec2 latLng) {latLng=DEG_TO_RAD*latLng;float cosLat=cos(latLng[0]);float sinLat=sin(latLng[0]);float cosLng=cos(latLng[1]);float sinLng=sin(latLng[1]);float sx=cosLat*sinLng*GLOBE_RADIUS;float sy=-sinLat*GLOBE_RADIUS;float sz=cosLat*cosLng*GLOBE_RADIUS;return vec3(sx,sy,sz);}void main() {\n#ifdef GLOBE_POLES\nvec3 globe_pos=a_globe_pos;vec2 uv=a_uv;\n#else\nfloat tiles=u_grid_matrix[0][2];float idx=u_grid_matrix[1][2];float idy=u_grid_matrix[2][2];vec3 latLng=u_grid_matrix*vec3(a_pos,1.0);float mercatorY=mercatorYfromLat(latLng[0]);float uvY=mercatorY*tiles-idy;float mercatorX=mercatorXfromLng(latLng[1]);float uvX=mercatorX*tiles-idx;vec3 globe_pos=latLngToECEF(latLng.xy);vec2 merc_pos=vec2(mercatorX,mercatorY);vec2 uv=vec2(uvX,uvY);\n#endif\nv_pos0=uv;vec2 tile_pos=uv*EXTENT;\n#ifdef GLOBE_POLES\nvec3 up_vector=normalize(globe_pos)*u_tile_up_scale;\n#else\nvec3 up_vector=elevationVector(tile_pos);\n#endif\nfloat height=elevation(tile_pos);\n#ifdef TERRAIN_WIREFRAME\nheight+=wireframeOffset;\n#endif\nglobe_pos+=up_vector*height;\n#ifdef GLOBE_POLES\nvec4 interpolated_pos=u_globe_matrix*vec4(globe_pos,1.0);\n#else\nvec4 globe_world_pos=u_globe_matrix*vec4(globe_pos,1.0);vec4 merc_world_pos=vec4(0.0);if (u_zoom_transition > 0.0) {merc_world_pos=vec4(merc_pos,height,1.0);merc_world_pos.xy-=u_merc_center;merc_world_pos.x=wrap(merc_world_pos.x,-0.5,0.5);merc_world_pos=u_merc_matrix*merc_world_pos;}vec4 interpolated_pos=vec4(mix(globe_world_pos.xyz,merc_world_pos.xyz,u_zoom_transition),1.0);\n#endif\ngl_Position=u_proj_matrix*interpolated_pos;\n#ifdef FOG\nv_fog_pos=fog_position((u_normalize_matrix*vec4(globe_pos,1.0)).xyz);\n#endif\n}"),globeAtmosphere:fn("uniform float u_transition;uniform highp float u_fadeout_range;uniform highp float u_temporal_offset;uniform vec3 u_start_color;uniform vec4 u_color;uniform vec4 u_space_color;uniform vec4 u_high_color;uniform float u_star_intensity;uniform float u_star_size;uniform float u_star_density;uniform float u_horizon_angle;uniform mat4 u_rotation_matrix;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;highp float random(highp vec3 p) {p=fract(p*vec3(23.2342,97.1231,91.2342));p+=dot(p.zxy,p.yxz+123.1234);return fract(p.x*p.y);}float stars(vec3 p,float scale,vec2 offset) {vec2 uv_scale=(u_viewport/u_star_size)*scale;vec3 position=vec3(p.xy*uv_scale+offset*u_viewport,p.z);vec3 q=fract(position)-0.5;vec3 id=floor(position);float random_visibility=step(random(id),u_star_density);float circle=smoothstep(0.5+u_star_intensity,0.5,length(q));return circle*random_visibility;}void main() {highp vec3 dir=normalize(v_ray_dir);float globe_pos_dot_dir;\n#ifdef PROJECTION_GLOBE_VIEW\nglobe_pos_dot_dir=dot(u_globe_pos,dir);highp vec3 closest_point_forward=abs(globe_pos_dot_dir)*dir;float norm_dist_from_center=length(closest_point_forward-u_globe_pos)/u_globe_radius;if (norm_dist_from_center < 0.98) {discard;return;}\n#endif\nhighp vec3 horizon_dir=normalize(v_horizon_dir);float horizon_angle_mercator=dir.y < horizon_dir.y ?\n0.0 : max(acos(dot(dir,horizon_dir)),0.0);float horizon_angle;\n#ifdef PROJECTION_GLOBE_VIEW\nhighp vec3 closest_point=globe_pos_dot_dir*dir;float closest_point_to_center=length(closest_point-u_globe_pos);float theta=asin(clamp(closest_point_to_center/length(u_globe_pos),-1.0,1.0));horizon_angle=globe_pos_dot_dir < 0.0 ?\nPI-theta-u_horizon_angle : theta-u_horizon_angle;float angle_t=pow(u_transition,10.0);horizon_angle=mix(horizon_angle,horizon_angle_mercator,angle_t);\n#else\nhorizon_angle=horizon_angle_mercator;\n#endif\nhorizon_angle/=PI;float t=exp(-horizon_angle/u_fadeout_range);float alpha_0=u_color.a;float alpha_1=u_high_color.a;float alpha_2=u_space_color.a;vec3 color_stop_0=u_color.rgb;vec3 color_stop_1=u_high_color.rgb;vec3 color_stop_2=u_space_color.rgb;vec3 c0=mix(color_stop_2,color_stop_1,alpha_1);vec3 c1=mix(c0,color_stop_0,alpha_0);vec3 c2=mix(c0,c1,t);vec3 c =mix(color_stop_2,c2,t);float a0=mix(alpha_2,1.0,alpha_1);float a1=mix(a0,1.0,alpha_0);float a2=mix(a0,a1,t);float a =mix(alpha_2,a2,t);vec2 uv=gl_FragCoord.xy/u_viewport-0.5;float aspect_ratio=u_viewport.x/u_viewport.y;vec4 uv_dir=vec4(normalize(vec3(uv.x*aspect_ratio,uv.y,1.0)),1.0);uv_dir=u_rotation_matrix*uv_dir;vec3 n=abs(uv_dir.xyz);vec2 uv_remap=(n.x > n.y && n.x > n.z) ? uv_dir.yz/uv_dir.x:\n(n.y > n.x && n.y > n.z) ? uv_dir.zx/uv_dir.y:\nuv_dir.xy/uv_dir.z;uv_remap.x/=aspect_ratio;vec3 D=vec3(uv_remap,1.0);highp float star_field=0.0;if (u_star_intensity > 0.0) {star_field+=stars(D,1.2,vec2(0.0,0.0));star_field+=stars(D,1.0,vec2(1.0,0.0));star_field+=stars(D,0.8,vec2(0.0,1.0));star_field+=stars(D,0.6,vec2(1.0,1.0));star_field*=(1.0-pow(t,0.25+(1.0-u_high_color.a)*0.75));c+=star_field*alpha_2;}c=dither(c,gl_FragCoord.xy+u_temporal_offset);gl_FragColor=vec4(c,a);}","attribute vec3 a_pos;attribute vec2 a_uv;uniform vec3 u_frustum_tl;uniform vec3 u_frustum_tr;uniform vec3 u_frustum_br;uniform vec3 u_frustum_bl;uniform float u_horizon;varying highp vec3 v_ray_dir;varying highp vec3 v_horizon_dir;void main() {v_ray_dir=mix(\nmix(u_frustum_tl,u_frustum_tr,a_uv.x),mix(u_frustum_bl,u_frustum_br,a_uv.x),a_uv.y);v_horizon_dir=mix(\nmix(u_frustum_tl,u_frustum_bl,u_horizon),mix(u_frustum_tr,u_frustum_br,u_horizon),a_uv.x);gl_Position=vec4(a_pos,1.0);}")};function dn(e,t){const n=e.replace(/\s*\/\/[^\n]*\n/g,"\n").split("\n");for(let e of n)if(e=e.trim(),"#"===e[0]&&e.includes("if")&&!e.includes("endif")){e=e.replace("#","").replace(/ifdef|ifndef|elif|if/g,"").replace(/!|defined|\(|\)|\|\||&&/g,"").replace(/\s+/g," ").trim();const n=e.split(" ");for(const e of n)t.includes(e)||t.push(e)}}function fn(e,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/attribute (highp |mediump |lowp )?([\w]+) ([\w]+)/g),i={},o=[...sn];return dn(e,o),dn(t,o),{fragmentSource:e=e.replace(n,(e,t,n,r,o)=>(i[o]=!0,"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:`\n#ifdef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = u_${o};\n#endif\n`)),vertexSource:t=t.replace(n,(e,t,n,r,o)=>{const a="float"===r?"vec2":"vec4",s=o.match(/color/)?"color":a;return i[o]?"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\nvarying ${n} ${r} ${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:"define"===t?`\n#ifndef HAS_UNIFORM_u_${o}\nuniform lowp float u_${o}_t;\nattribute ${n} ${a} a_${o};\n#else\nuniform ${n} ${r} u_${o};\n#endif\n`:"vec4"===s?`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = a_${o};\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`:`\n#ifndef HAS_UNIFORM_u_${o}\n ${n} ${r} ${o} = unpack_mix_${s}(a_${o}, u_${o}_t);\n#else\n ${n} ${r} ${o} = u_${o};\n#endif\n`}),staticAttributes:r,usedDefines:o}}class pn{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffers=[],this.vao=null}bind(e,t,n,r,i,o,a){this.context=e;let s=this.boundPaintVertexBuffers.length!==r.length;for(let e=0;!s&&e{const i=n.paint.get("hillshade-shadow-color"),o=n.paint.get("hillshade-highlight-color"),a=n.paint.get("hillshade-accent-color");let s=n.paint.get("hillshade-illumination-direction")*(Math.PI/180);"viewport"===n.paint.get("hillshade-illumination-anchor")&&(s-=e.transform.angle);const l=!e.options.moving;return{u_matrix:r||e.transform.calculateProjMatrix(t.tileID.toUnwrapped(),l),u_image:0,u_latrange:mn(0,t.tileID),u_light:[n.paint.get("hillshade-exaggeration"),s],u_shadow:i,u_highlight:o,u_accent:a}})(t,r,i,t.terrain?n.projMatrix:null);t.prepareDrawProgram(l,h,n.toUnwrapped());const{tileBoundsBuffer:f,tileBoundsIndexBuffer:p,tileBoundsSegments:m}=t.getTileBoundsBuffers(r);h.draw(l,u.TRIANGLES,o,a,s,e.CullFaceMode.disabled,d,i.id,f,p,m)}function gn(t,n,r){if(!n.needsDEMTextureUpload)return;const i=t.context,o=i.gl;i.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||t.getTileTexture(r.stride);const a=r.getPixels();n.demTexture?n.demTexture.update(a,{premultiply:!1}):n.demTexture=new e.Texture(i,a,o.RGBA,{premultiply:!1}),n.needsDEMTextureUpload=!1}function yn(t,n,r,i,o,a){const s=t.context,l=s.gl;if(!n.dem)return;const u=n.dem;if(s.activeTexture.set(l.TEXTURE1),gn(t,n,u),!n.demTexture)return;n.demTexture.bind(l.NEAREST,l.CLAMP_TO_EDGE);const c=u.dim;s.activeTexture.set(l.TEXTURE0);let h=n.fbo;if(!h){const t=new e.Texture(s,{width:c,height:c,data:null},l.RGBA);t.bind(l.LINEAR,l.CLAMP_TO_EDGE),h=n.fbo=s.createFramebuffer(c,c,!0),h.colorAttachment.set(t.texture)}s.bindFramebuffer.set(h.framebuffer),s.viewport.set([0,0,c,c]);const{tileBoundsBuffer:d,tileBoundsIndexBuffer:f,tileBoundsSegments:p}=t.getMercatorTileBoundsBuffers();t.useProgram("hillshadePrepare").draw(s,l.TRIANGLES,i,o,a,e.CullFaceMode.disabled,((t,n)=>{const r=n.stride,i=e.create();return e.ortho(i,0,e.EXTENT,-e.EXTENT,0,0,1),e.translate(i,i,[0,-e.EXTENT,0]),{u_matrix:i,u_image:1,u_dimension:[r,r],u_zoom:t.overscaledZ,u_unpack:n.unpackVector}})(n.tileID,u),r.id,d,f,p),n.needsHillshadePrepare=!1}const vn=t=>({u_matrix:new e.UniformMatrix4f(t),u_image0:new e.Uniform1i(t),u_skirt_height:new e.Uniform1f(t)}),xn=(e,t)=>({u_matrix:e,u_image0:0,u_skirt_height:t}),bn=(e,t,n,r,i,o,a,s,l,u,c,h,d,f)=>({u_proj_matrix:Float32Array.from(e),u_globe_matrix:t,u_normalize_matrix:Float32Array.from(r),u_merc_matrix:n,u_zoom_transition:i,u_merc_center:o,u_image0:0,u_frustum_tl:a,u_frustum_tr:s,u_frustum_br:l,u_frustum_bl:u,u_globe_pos:c,u_globe_radius:h,u_viewport:d,u_grid_matrix:f?Float32Array.from(f):new Float32Array(9)});function wn(e,t){return null!=e&&null!=t&&!(!e.hasData()||!t.hasData())&&null!=e.demTexture&&null!=t.demTexture&&e.tileID.key!==t.tileID.key}const En=new class{constructor(){this.operations={}}newMorphing(e,t,n,r,i){if(e in this.operations){const t=this.operations[e];t.to.tileID.key!==n.tileID.key&&(t.queued=n)}else this.operations[e]={startTime:r,phase:0,duration:i,from:t,to:n,queued:null}}getMorphValuesForProxy(e){if(!(e in this.operations))return null;const t=this.operations[e];return{from:t.from,to:t.to,phase:t.phase}}update(e){for(const t in this.operations){const n=this.operations[t];for(n.phase=(e-n.startTime)/n.duration;n.phase>=1||!this._validOp(n);)if(!this._nextOp(n,e)){delete this.operations[t];break}}}_nextOp(e,t){return!!e.queued&&(e.from=e.to,e.to=e.queued,e.queued=null,e.phase=0,e.startTime=t,!0)}_validOp(e){return e.from.hasData()&&e.to.hasData()}},Tn={0:null,1:"TERRAIN_VERTEX_MORPHING",2:"TERRAIN_WIREFRAME"};function Sn(e,t){const n=1<({u_matrix:e});function Cn(t,n,r,i,o){if(o>0){const a=e.exported.now(),s=(a-t.timeAdded)/o,l=n?(a-n.timeAdded)/o:-1,u=r.getSource(),c=i.coveringZoomLevel({tileSize:u.tileSize,roundZoom:u.roundZoom}),h=!n||Math.abs(n.tileID.overscaledZ-c)>Math.abs(t.tileID.overscaledZ-c),d=h&&t.refreshedUponExpiration?1:e.clamp(h?s:1-l,0,1);return t.refreshedUponExpiration&&s>=1&&(t.refreshedUponExpiration=!1),n?{opacity:1,mix:1-d}:{opacity:d,mix:0}}return{opacity:1,mix:0}}class Mn extends e.SourceCache{constructor(e){const t={type:"raster-dem",maxzoom:e.transform.maxZoom},n=new z(Ue(),null),r=ze("mock-dem",t,n,e.style);super("mock-dem",r,!1),r.setEventedParent(this),this._sourceLoaded=!0}_loadTile(e,t){e.state="loaded",t(null)}}class An extends e.SourceCache{constructor(e){const t=ze("proxy",{type:"geojson",maxzoom:e.transform.maxZoom},new z(Ue(),null),e.style);super("proxy",t,!1),t.setEventedParent(this),this.map=this.getSource().map=e,this.used=this._sourceLoaded=!0,this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}update(t,n,r){if(t.freezeTileCoverage)return;this.transform=t;const i=t.coveringTiles({tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled}).reduce((n,r)=>{if(n[r.key]="",!this._tiles[r.key]){const n=new e.Tile(r,this._source.tileSize*r.overscaleFactor(),t.tileZoom);n.state="loaded",this._tiles[r.key]=n}return n},{});for(const e in this._tiles)e in i||(this.freeFBO(e),this._tiles[e].unloadVectorData(),delete this._tiles[e])}freeFBO(e){const t=this.proxyCachedFBO[e];if(void 0!==t){const n=Object.values(t);this.renderCachePool.push(...n),delete this.proxyCachedFBO[e]}}deallocRenderCache(){this.renderCache.forEach(e=>e.fb.destroy()),this.renderCache=[],this.renderCachePool=[],this.proxyCachedFBO={}}}class In extends e.OverscaledTileID{constructor(e,t,n){super(e.overscaledZ,e.wrap,e.canonical.z,e.canonical.x,e.canonical.y),this.proxyTileKey=t,this.projMatrix=n}}class Pn extends e.Elevation{constructor(t,n){super(),this.painter=t,this.terrainTileForTile={},this.prevTerrainTileForTile={};const[r,i,o]=function(t){const n=new e.StructArrayLayout4i8,r=new e.StructArrayLayout3ui6,i=131;n.reserve(17161),r.reserve(33800);const o=e.EXTENT/128,a=e.EXTENT+o/2,s=a+o;for(let t=-o;ta||t<0||t>a?24575:0,o=e.clamp(Math.round(r),0,e.EXTENT),s=e.clamp(Math.round(t),0,e.EXTENT);n.emplaceBack(o+i,s,o,s)}const l=(e,t)=>{const n=t*i+e;r.emplaceBack(n+1,n,n+i),r.emplaceBack(n+i,n+i+1,n+1)};for(let e=1;e<129;e++)for(let t=1;t<129;t++)l(t,e);return[0,129].forEach(e=>{for(let t=0;t<130;t++)l(t,e),l(e,t)}),[n,r,32768]}(),a=t.context;this.gridBuffer=a.createVertexBuffer(r,e.boundsAttributes.members),this.gridIndexBuffer=a.createIndexBuffer(i),this.gridSegments=e.SegmentVector.simpleSegment(0,0,r.length,i.length),this.gridNoSkirtSegments=e.SegmentVector.simpleSegment(0,0,r.length,o),this.proxyCoords=[],this.proxiedCoords={},this._visibleDemTiles=[],this._drapedRenderBatches=[],this._sourceTilesOverlap={},this.proxySourceCache=new An(n.map),this.orthoMatrix=e.create(),e.ortho(this.orthoMatrix,"globe"===this.painter.transform.projection.name?.015:0,e.EXTENT,0,e.EXTENT,0,1);const s=a.gl;this._overlapStencilMode=new e.StencilMode({func:s.GEQUAL,mask:255},0,255,s.KEEP,s.KEEP,s.REPLACE),this._previousZoom=t.transform.zoom,this.pool=[],this._findCoveringTileCache={},this._tilesDirty={},this.style=n,this._useVertexMorphing=!0,this._exaggeration=1,this._mockSourceCache=new Mn(n.map)}set style(e){e.on("data",this._onStyleDataEvent.bind(this)),e.on("neworder",this._checkRenderCacheEfficiency.bind(this)),this._style=e,this._checkRenderCacheEfficiency()}update(t,n,r){if(t&&t.terrain){this._style!==t&&(this.style=t),this.enabled=!0;const i=t.terrain.properties;this.sourceCache=0===t.terrain.drapeRenderMode?this._mockSourceCache:t._getSourceCache(i.get("source")),this._exaggeration=i.get("exaggeration");const o=()=>{this.sourceCache.used&&e.warnOnce(`Raster DEM source '${this.sourceCache.id}' is used both for terrain and as layer source.\nThis leads to lower resolution of hillshade. For full hillshade resolution but higher memory consumption, define another raster DEM source.`);const t=this.getScaledDemTileSize();this.sourceCache.update(n,t,!0),this.resetTileLookupCache(this.sourceCache.id)};this.sourceCache.usedForTerrain||(this.resetTileLookupCache(this.sourceCache.id),this.sourceCache.usedForTerrain=!0,o(),this._initializing=!0),o(),n.updateElevation(!0,r),this.resetTileLookupCache(this.proxySourceCache.id),this.proxySourceCache.update(n),this._emptyDEMTextureDirty=!0}else this._disable()}resetTileLookupCache(e){this._findCoveringTileCache[e]={}}getScaledDemTileSize(){return this.sourceCache.getSource().tileSize/128*this.proxySourceCache.getSource().tileSize}_checkRenderCacheEfficiency(){const t=this.renderCacheEfficiency(this._style);this._style.map._optimizeForTerrain||100!==t.efficiency&&e.warnOnce(`Terrain render cache efficiency is not optimal (${t.efficiency}%) and performance\n may be affected negatively, consider placing all background, fill and line layers before layer\n with id '${t.firstUndrapedLayer}' or create a map using optimizeForTerrain: true option.`)}_onStyleDataEvent(e){e.coord&&"source"===e.dataType?this._clearRenderCacheForTile(e.sourceCacheId,e.coord):"style"===e.dataType&&(this._invalidateRenderCache=!0)}_disable(){if(this.enabled&&(this.enabled=!1,this._sharedDepthStencil=void 0,this.proxySourceCache.deallocRenderCache(),this._style))for(const e in this._style._sourceCaches)this._style._sourceCaches[e].usedForTerrain=!1}destroy(){this._disable(),this._emptyDEMTexture&&this._emptyDEMTexture.destroy(),this._emptyDepthBufferTexture&&this._emptyDepthBufferTexture.destroy(),this.pool.forEach(e=>e.fb.destroy()),this.pool=[],this._depthFBO&&(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0)}_source(){return this.enabled?this.sourceCache:null}isUsingMockSource(){return this.sourceCache===this._mockSourceCache}exaggeration(){return this._exaggeration}get visibleDemTiles(){return this._visibleDemTiles}get drapeBufferSize(){const e=2*this.proxySourceCache.getSource().tileSize;return[e,e]}set useVertexMorphing(e){this._useVertexMorphing=e}updateTileBinding(t){if(!this.enabled)return;this.prevTerrainTileForTile=this.terrainTileForTile;const n=this.proxySourceCache,r=this.painter.transform;this._initializing&&(this._initializing=0===r._centerAltitude&&-1===this.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(r.center),-1),this._emptyDEMTextureDirty=!this._initializing);const i=this.proxyCoords=n.getIds().map(e=>{const t=n.getTileByID(e).tileID;return t.projMatrix=r.calculateProjMatrix(t.toUnwrapped()),t});!function(t,n){const r=n.transform.pointCoordinate(n.transform.getCameraPoint()),i=new e.pointGeometry(r.x,r.y);t.sort((t,n)=>{if(n.overscaledZ-t.overscaledZ)return n.overscaledZ-t.overscaledZ;const r=new e.pointGeometry(t.canonical.x+(1<{this.proxyToSource[e.key]={}}),this.terrainTileForTile={};const a=this._style._sourceCaches;for(const e in a){const n=a[e];if(!n.used)continue;if(n!==this.sourceCache&&this.resetTileLookupCache(n.id),this._setupProxiedCoordsForOrtho(n,t[e],o),n.usedForTerrain)continue;const r=t[e];n.getSource().reparseOverscaled&&this._assignTerrainTiles(r)}this.proxiedCoords[n.id]=i.map(e=>new In(e,e.key,this.orthoMatrix)),this._assignTerrainTiles(i),this._prepareDEMTextures(),this._setupDrapedRenderBatches(),this._initFBOPool(),this._setupRenderCache(o),this.renderingToTexture=!1,this._updateTimestamp=e.exported.now();const s={};this._visibleDemTiles=[];for(const e of this.proxyCoords){const t=this.terrainTileForTile[e.key];if(!t)continue;const n=t.tileID.key;n in s||(this._visibleDemTiles.push(t),s[n]=n)}}_assignTerrainTiles(e){this._initializing||e.forEach(e=>{if(this.terrainTileForTile[e.key])return;const t=this._findTileCoveringTileID(e,this.sourceCache);t&&(this.terrainTileForTile[e.key]=t)})}_prepareDEMTextures(){const e=this.painter.context,t=e.gl;for(const n in this.terrainTileForTile){const r=this.terrainTileForTile[n],i=r.dem;!i||r.demTexture&&!r.needsDEMTextureUpload||(e.activeTexture.set(t.TEXTURE1),gn(this.painter,r,i))}}_prepareDemTileUniforms(e,t,n,r){if(!t||null==t.demTexture)return!1;const i=e.tileID.canonical,o=Math.pow(2,t.tileID.canonical.z-i.z),a=r||"";return n["u_dem_tl"+a]=[i.x*o%1,i.y*o%1],n["u_dem_scale"+a]=o,!0}get emptyDEMTexture(){return!this._emptyDEMTextureDirty&&this._emptyDEMTexture?this._emptyDEMTexture:this._updateEmptyDEMTexture()}get emptyDepthBufferTexture(){const t=this.painter.context,n=t.gl;if(!this._emptyDepthBufferTexture){const r=new e.RGBAImage({width:1,height:1},Uint8Array.of(255,255,255,255));this._emptyDepthBufferTexture=new e.Texture(t,r,n.RGBA,{premultiply:!1})}return this._emptyDepthBufferTexture}_getLoadedAreaMinimum(){let e=0;const t=this._visibleDemTiles.reduce((t,n)=>{if(!n.dem)return t;const r=n.dem.tree.minimums[0];return r>0&&e++,t+r},0);return e?t/e:0}_updateEmptyDEMTexture(){const t=this.painter.context,n=t.gl;t.activeTexture.set(n.TEXTURE2);const r=this._getLoadedAreaMinimum(),i=new e.RGBAImage({width:1,height:1},new Uint8Array(e.DEMData.pack(r,this.sourceCache.getSource().encoding)));this._emptyDEMTextureDirty=!1;let o=this._emptyDEMTexture;return o?o.update(i,{premultiply:!1}):o=this._emptyDEMTexture=new e.Texture(t,i,n.RGBA,{premultiply:!1}),o}setupElevationDraw(t,n,r){const i=this.painter.context,o=i.gl,a=(s=this.sourceCache.getSource().encoding,{u_dem:2,u_dem_prev:4,u_dem_unpack:e.DEMData.getUnpackVector(s),u_dem_tl:[0,0],u_dem_tl_prev:[0,0],u_dem_scale:0,u_dem_scale_prev:0,u_dem_size:0,u_dem_lerp:1,u_depth:3,u_depth_size_inv:[0,0],u_exaggeration:0});var s;a.u_dem_size=this.sourceCache.getSource().tileSize,a.u_exaggeration=this.exaggeration();let l=null,u=null,c=1;if(r&&r.morphing&&this._useVertexMorphing){const e=r.morphing.srcDemTile,n=r.morphing.dstDemTile;c=r.morphing.phase,e&&n&&(this._prepareDemTileUniforms(t,e,a,"_prev")&&(u=e),this._prepareDemTileUniforms(t,n,a)&&(l=n))}if(u&&l?(i.activeTexture.set(o.TEXTURE2),l.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),i.activeTexture.set(o.TEXTURE4),u.demTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE,o.NEAREST),a.u_dem_lerp=c):(l=this.terrainTileForTile[t.tileID.key],i.activeTexture.set(o.TEXTURE2),(this._prepareDemTileUniforms(t,l,a)?l.demTexture:this.emptyDEMTexture).bind(o.NEAREST,o.CLAMP_TO_EDGE)),i.activeTexture.set(o.TEXTURE3),r&&r.useDepthForOcclusion?(this._depthTexture&&this._depthTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),this._depthFBO&&(a.u_depth_size_inv=[1/this._depthFBO.width,1/this._depthFBO.height])):(this.emptyDepthBufferTexture.bind(o.NEAREST,o.CLAMP_TO_EDGE),a.u_depth_size_inv=[1,1]),r&&r.useMeterToDem&&l){const t=(1<{if(u===e)return;const r=[Tn[e],"PROJECTION_GLOBE_VIEW"];d&&r.push("CUSTOM_ANTIALIASING"),n&&r.push(Tn[c]),l=t.useProgram("globeRaster",null,r),u=e},p=t.colorModeForRenderPass(),m=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);En.update(o);const _=e.calculateGlobeMercatorMatrix(h),g=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],y=c?[!1,!0]:[!1],v=t.globeSharedBuffers,x=[h.width*e.exported.devicePixelRatio,h.height*e.exported.devicePixelRatio],b=Float32Array.from(h.globeMatrix),w={useDenormalizedUpVectorScale:!0};if(y.forEach(c=>{u=-1;const d=c?s.LINES:s.TRIANGLES;for(const u of i){const i=r.getTile(u),y=e.StencilMode.disabled,E=n.prevTerrainTileForTile[u.key],T=n.terrainTileForTile[u.key];wn(E,T)&&En.newMorphing(u.key,E,T,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE);const S=En.getMorphValuesForProxy(u.key),k=S?1:0;S&&e.extend$1(w,{morphing:{srcDemTile:S.from,dstDemTile:S.to,phase:e.easeCubicInOut(S.phase)}});const C=e.tileCornersToBounds(u.canonical),M=e.getLatitudinalLod(C.getCenter().lat),A=e.getGridMatrix(u.canonical,C,M,h.worldSize/h._pixelsPerMercatorPixel),I=e.globeNormalizeECEF(e.globeTileBounds(u.canonical)),P=bn(h.projMatrix,b,_,I,e.globeToMercatorTransition(h.zoom),g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x,A);if(f(k,c),n.setupElevationDraw(i,l,w),t.prepareDrawProgram(a,l,u.toUnwrapped()),v){const[n,r,i]=c?v.getWirefameBuffers(t.context,M):v.getGridBuffers(M);l.draw(a,d,m,y,p,e.CullFaceMode.backCCW,P,"globe_raster",n,r,i)}}}),v){const o=["GLOBE_POLES","PROJECTION_GLOBE_VIEW"];d&&o.push("CUSTOM_ANTIALIASING"),l=t.useProgram("globeRaster",null,o);for(const o of i){const{x:i,y:u,z:c}=o.canonical,d=0===u,f=u===(1<t.draw(a,s.TRIANGLES,m,e.StencilMode.disabled,p,e.CullFaceMode.disabled,bn(h.projMatrix,v,v,T,0,g,h.frustumCorners.TL,h.frustumCorners.TR,h.frustumCorners.BR,h.frustumCorners.BL,h.globeCenterInViewSpace,h.globeRadius,x),"globe_pole_raster",n,b,E);n.setupElevationDraw(u,l,w),t.prepareDrawProgram(a,l,o.toUnwrapped()),d&&S(l,_),f&&(v=e.scale(e.create(),v,[1,-1,1]),S(l,y))}}}}(t,n,r,i,o);else{const a=t.context,s=a.gl;let l,u;const c=t.options.showTerrainWireframe?2:0,h=(e,n)=>{if(u===e)return;const r=[Tn[e]];n&&r.push(Tn[c]),l=t.useProgram("terrainRaster",null,r),u=e},d=t.colorModeForRenderPass(),f=new e.DepthMode(s.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);En.update(o);const p=t.transform,m=6*Math.pow(1.5,22-p.zoom)*n.exaggeration();(c?[!1,!0]:[!1]).forEach(c=>{u=-1;const _=c?s.LINES:s.TRIANGLES,[g,y]=c?n.getWirefameBuffer():[n.gridIndexBuffer,n.gridSegments];for(const u of i){const i=r.getTile(u),v=e.StencilMode.disabled,x=n.prevTerrainTileForTile[u.key],b=n.terrainTileForTile[u.key];wn(x,b)&&En.newMorphing(u.key,x,b,o,250),a.activeTexture.set(s.TEXTURE0),i.texture.bind(s.LINEAR,s.CLAMP_TO_EDGE,s.LINEAR_MIPMAP_NEAREST);const w=En.getMorphValuesForProxy(u.key),E=w?1:0;let T;w&&(T={morphing:{srcDemTile:w.from,dstDemTile:w.to,phase:e.easeCubicInOut(w.phase)}});const S=xn(u.projMatrix,Sn(u.canonical,p.renderWorldCopies)?m/10:m);h(E,c),n.setupElevationDraw(i,l,T),t.prepareDrawProgram(a,l,u.toUnwrapped()),l.draw(a,_,f,v,d,e.CullFaceMode.backCCW,S,"terrain_raster",n.gridBuffer,g,y)}})}}(n,this,this.proxySourceCache,t,this._updateTimestamp),this.renderingToTexture=!0,n.gpuTimingDeferredRenderEnd(),t.splice(0,t.length))}renderBatch(t){if(0===this._drapedRenderBatches.length)return t+1;this.renderingToTexture=!0;const n=this.painter,r=this.painter.context,i=this.proxySourceCache,o=this.proxiedCoords[i.id],a=this._drapedRenderBatches.shift(),s=[],l=n.style.order;let u=0;for(const c of o){const o=i.getTileByID(c.proxyTileKey),h=i.proxyCachedFBO[c.key]?i.proxyCachedFBO[c.key][t]:void 0,d=void 0!==h?i.renderCache[h]:this.pool[u++],f=void 0!==h;if(o.texture=d.tex,f&&!d.dirty){s.push(o.tileID);continue}let p;r.bindFramebuffer.set(d.fb.framebuffer),this.renderedToTile=!1,d.dirty&&(r.clear({color:e.Color.transparent,stencil:0}),d.dirty=!1);for(let e=a.start;e<=a.end;++e){const t=n.style._layers[l[e]];if(t.isHidden(n.transform.zoom))continue;const i=n.style._getLayerSourceCache(t),o=i?this.proxyToSource[c.key][i.id]:[c];if(!o)continue;const a=o;r.viewport.set([0,0,d.fb.width,d.fb.height]),p!==(i?i.id:null)&&(this._setupStencil(d,o,t,i),p=i?i.id:null),n.renderLayer(n,i,t,a)}this.renderedToTile?(d.dirty=!0,s.push(o.tileID)):f||--u,5===u&&(u=0,this.renderToBackBuffer(s))}return this.renderToBackBuffer(s),this.renderingToTexture=!1,r.bindFramebuffer.set(null),r.viewport.set([0,0,n.width,n.height]),a.end+1}postRender(){}renderCacheEfficiency(e){const t=e.order.length;if(0===t)return{efficiency:100};let n,r=0,i=0,o=!1;for(let a=0;ae.dem).forEach(t=>{e=Math.min(e,t.dem.tree.minimums[0])}),0===e?e:(e-30)*this._exaggeration}raycast(e,t,n){if(!this._visibleDemTiles)return null;const r=this._visibleDemTiles.filter(e=>e.dem).map(r=>{const i=r.tileID,o=1<(null!==e.t?e.t:Number.MAX_VALUE)-(null!==t.t?t.t:Number.MAX_VALUE));for(const i of r){if(null==i.t)return null;const r=i.tile.dem.tree.raycast(i.minx,i.miny,i.maxx,i.maxy,e,t,n);if(null!=r)return r}return null}_createFBO(){const t=this.painter.context,n=t.gl,r=this.drapeBufferSize;t.activeTexture.set(n.TEXTURE0);const i=new e.Texture(t,{width:r[0],height:r[1],data:null},n.RGBA);i.bind(n.LINEAR,n.CLAMP_TO_EDGE);const o=t.createFramebuffer(r[0],r[1],!1);return o.colorAttachment.set(i.texture),o.depthAttachment=new Te(t,o.framebuffer),void 0===this._sharedDepthStencil?(this._sharedDepthStencil=t.createRenderbuffer(t.gl.DEPTH_STENCIL,r[0],r[1]),this._stencilRef=0,o.depthAttachment.set(this._sharedDepthStencil),t.clear({stencil:0})):o.depthAttachment.set(this._sharedDepthStencil),t.extTextureFilterAnisotropic&&!t.extTextureFilterAnisotropicForceOff&&n.texParameterf(n.TEXTURE_2D,t.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,t.extTextureFilterAnisotropicMax),{fb:o,tex:i,dirty:!1}}_initFBOPool(){for(;this.pool.length{const t=this._style._layers[e],n=t.isHidden(this.painter.transform.zoom);return"custom"!==t.type&&!n&&t.hasTransition()})}_clearRasterFadeFromRenderCache(){let e=!1;for(const t in this._style._sourceCaches)if(this._style._sourceCaches[t]._source instanceof Ce){e=!0;break}if(e)for(let e=0;et.renderCachePool.length){const e=Object.values(t.proxyCachedFBO);t.proxyCachedFBO={};for(let n=0;n=0;i--){const o=n[i];if(t.getTileByID(o.key),void 0!==t.proxyCachedFBO[o.key]){const n=e[o.key],i=this.proxyToSource[o.key];let a=0;for(const e in i){const t=i[e],o=n[e];if(!o||o.length!==t.length||t.some((t,n)=>t!==o[n]||r[e]&&r[e].hasOwnProperty(t.key))){a=-1;break}++a}for(const e in t.proxyCachedFBO[o.key])t.renderCache[t.proxyCachedFBO[o.key][e]].dirty=a<0||a!==Object.values(n).length}}const i=[...this._drapedRenderBatches];i.sort((e,t)=>t.end-t.start-(e.end-e.start));for(const e of i)for(const r of n){if(t.proxyCachedFBO[r.key])continue;let n=t.renderCachePool.pop();void 0===n&&t.renderCache.length<50&&(n=t.renderCache.length,t.renderCache.push(this._createFBO())),void 0!==n&&(t.proxyCachedFBO[r.key]={},t.proxyCachedFBO[r.key][e.start]=n,t.renderCache[n].dirty=!0)}this._tilesDirty={}}_setupStencil(e,t,n,r){if(!r||!this._sourceTilesOverlap[r.id])return void(this._overlapStencilType&&(this._overlapStencilType=!1));const i=this.painter.context,o=i.gl;if(t.length<=1)return void(this._overlapStencilType=!1);let a;if(n.isTileClipped())a=t.length,this._overlapStencilMode.test={func:o.EQUAL,mask:255},this._overlapStencilType="Clip";else{if(!(t[0].overscaledZ>t[t.length-1].overscaledZ))return void(this._overlapStencilType=!1);a=1,this._overlapStencilMode.test={func:o.GREATER,mask:255},this._overlapStencilType="Mask"}this._stencilRef+a>255&&(i.clear({stencil:0}),this._stencilRef=0),this._stencilRef+=a,this._overlapStencilMode.ref=this._stencilRef,n.isTileClipped()&&this._renderTileClippingMasks(t,this._overlapStencilMode.ref)}clipOrMaskOverlapStencilType(){return"Clip"===this._overlapStencilType||"Mask"===this._overlapStencilType}stencilModeForRTTOverlap(t){return this.renderingToTexture&&this._overlapStencilType?("Clip"===this._overlapStencilType&&(this._overlapStencilMode.ref=this.painter._tileClippingMaskIDs[t.key]),this._overlapStencilMode):e.StencilMode.disabled}_renderTileClippingMasks(t,n){const r=this.painter,i=this.painter.context,o=i.gl;r._tileClippingMaskIDs={},i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=r.useProgram("clippingMask");for(const s of t){const t=r._tileClippingMaskIDs[s.key]=--n;a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},t,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,kn(s.projMatrix),"$clipping",r.tileExtentBuffer,r.quadTriangleIndexBuffer,r.tileExtentSegments)}}pointCoordinate(t){const n=this.painter.transform;if(t.x<0||t.x>n.width||t.y<0||t.y>n.height)return null;const r=[t.x,t.y,1,1];e.transformMat4$1(r,r,n.pixelMatrixInverse),e.scale$1(r,r,1/r[3]),r[0]/=n.worldSize,r[1]/=n.worldSize;const i=n._camera.position,o=e.mercatorZfromAltitude(1,n.center.lat),a=[i[0],i[1],i[2]/o,0],s=e.subtract([],r.slice(0,3),a);e.normalize(s,s);const l=this.raycast(a,s,this._exaggeration);return null!==l&&l?(e.scaleAndAdd(a,a,s,l),a[3]=a[2],a[2]*=o,a):null}drawDepth(){const t=this.painter,n=t.context,r=this.proxySourceCache,i=Math.ceil(t.width),o=Math.ceil(t.height);if(!this._depthFBO||this._depthFBO.width===i&&this._depthFBO.height===o||(this._depthFBO.destroy(),this._depthFBO=void 0,this._depthTexture=void 0),!this._depthFBO){const t=n.gl,r=n.createFramebuffer(i,o,!0);n.activeTexture.set(t.TEXTURE0);const a=new e.Texture(n,{width:i,height:o,data:null},t.RGBA);a.bind(t.NEAREST,t.CLAMP_TO_EDGE),r.colorAttachment.set(a.texture);const s=n.createRenderbuffer(n.gl.DEPTH_COMPONENT16,i,o);r.depthAttachment.set(s),this._depthFBO=r,this._depthTexture=a}n.bindFramebuffer.set(this._depthFBO.framebuffer),n.viewport.set([0,0,i,o]),function(t,n,r,i){if("globe"===t.transform.projection.name)return;const o=t.context,a=o.gl;o.clear({depth:1});const s=t.useProgram("terrainDepth"),l=new e.DepthMode(a.LESS,e.DepthMode.ReadWrite,t.depthRangeFor3D);for(const t of i){const i=r.getTile(t),u=xn(t.projMatrix,0);n.setupElevationDraw(i,s),s.draw(o,a.TRIANGLES,l,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.backCCW,u,"terrain_depth",n.gridBuffer,n.gridIndexBuffer,n.gridNoSkirtSegments)}}(t,this,r,this.proxyCoords)}_setupProxiedCoordsForOrtho(e,t,n){if(e.getSource()instanceof Ie)return this._setupProxiedCoordsForImageSource(e,t,n);this._findCoveringTileCache[e.id]=this._findCoveringTileCache[e.id]||{};const r=this.proxiedCoords[e.id]=[],i=this.proxyCoords;for(let t=0;t(e.min.x=Math.min(e.min.x,t.x-s.x),e.min.y=Math.min(e.min.y,t.y-s.y),e.max.x=Math.max(e.max.x,t.x-s.x),e.max.y=Math.max(e.max.y,t.y-s.y),e),{min:new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE),max:new e.pointGeometry(-Number.MAX_VALUE,-Number.MAX_VALUE)}),u=(t,n)=>{const r=t.wrap+t.canonical.x/(1<a+l.max.x||i+os+l.max.y};for(let e=0;ee.key===n.tileID.key);if(e)return e}if(n.tileID.key!==t.key){const r=t.canonical.z-n.tileID.canonical.z;let o,a,s;i=e.create();const l=n.tileID.wrap-t.wrap<0?(o=e.EXTENT>>r,a=o*((n.tileID.canonical.x<=i){const r=t.canonical.z-i;n.getSource().reparseOverscaled?(s=Math.max(t.canonical.z+2,n.transform.tileZoom),a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r)):0!==r&&(s=i,a=new e.OverscaledTileID(s,t.wrap,i,t.canonical.x>>r,t.canonical.y>>r))}a.key!==t.key&&(u.push(a.key),r=n.getTile(a))}const c=e=>{u.forEach(t=>{i[t]=e}),u.length=0};for(s-=1;s>=l&&(!r||!r.hasData());s--){r&&c(r.tileID.key);const e=a.calculateScaledKey(s);if(r=n.getTileByID(e),r&&r.hasData())break;const t=i[e];if(null===t)break;void 0===t?u.push(e):r=n.getTileByID(t)}return c(r?r.tileID.key:null),r&&r.hasData()?r:null}findDEMTileFor(e){return this.enabled?this._findTileCoveringTileID(e,this.sourceCache):null}prepareDrawTile(){this.renderedToTile=!0}_clearRenderCacheForTile(e,t){let n=this._tilesDirty[e];n||(n=this._tilesDirty[e]={}),n[t.key]=!0}getWirefameBuffer(){if(!this.wireframeSegments){const t=function(t){let n=0;const r=new e.StructArrayLayout2ui4,i=131;for(let e=1;e<129;e++){for(let t=1;t<129;t++)n=e*i+t,r.emplaceBack(n,n+1),r.emplaceBack(n,n+i),r.emplaceBack(n+1,n+i),128===e&&r.emplaceBack(n+i,n+i+1);r.emplaceBack(n+1,n+1+i)}return r}();this.wireframeIndexBuffer=this.painter.context.createIndexBuffer(t),this.wireframeSegments=e.SegmentVector.simpleSegment(0,0,this.gridBuffer.length,t.length)}return[this.wireframeIndexBuffer,this.wireframeSegments]}}class zn{static cacheKey(e,t,n,r){let i=`${t}${r?r.cacheKey:""}`;for(const t of n)e.usedDefines.includes(t)&&(i+="/"+t);return i}constructor(t,n,r,i,o,a){const s=t.gl;this.program=s.createProgram();const l=function(e){const t=[];for(let n=0;n"#define "+e));const d=h.concat(t.extStandardDerivatives?"#extension GL_OES_standard_derivatives : enable\n".concat(cn):cn,cn,un,ln.fragmentSource,an.fragmentSource,r.fragmentSource).join("\n"),f=h.concat("\n#ifdef GL_ES\nprecision highp float;\n#else\n\n#if !defined(lowp)\n#define lowp\n#endif\n\n#if !defined(mediump)\n#define mediump\n#endif\n\n#if !defined(highp)\n#define highp\n#endif\n\n#endif",un,ln.vertexSource,an.vertexSource,on.vertexSource,r.vertexSource).join("\n"),p=s.createShader(s.FRAGMENT_SHADER);if(s.isContextLost())return void(this.failedToCreate=!0);s.shaderSource(p,d),s.compileShader(p),s.attachShader(this.program,p);const m=s.createShader(s.VERTEX_SHADER);if(s.isContextLost())this.failedToCreate=!0;else{s.shaderSource(m,f),s.compileShader(m),s.attachShader(this.program,m),this.attributes={},this.numAttributes=c.length;for(let e=0;e({u_dem:new e.Uniform1i(t),u_dem_prev:new e.Uniform1i(t),u_dem_unpack:new e.Uniform4f(t),u_dem_tl:new e.Uniform2f(t),u_dem_scale:new e.Uniform1f(t),u_dem_tl_prev:new e.Uniform2f(t),u_dem_scale_prev:new e.Uniform1f(t),u_dem_size:new e.Uniform1f(t),u_dem_lerp:new e.Uniform1f(t),u_exaggeration:new e.Uniform1f(t),u_depth:new e.Uniform1i(t),u_depth_size_inv:new e.Uniform2f(t),u_meter_to_dem:new e.Uniform1f(t),u_label_plane_matrix_inv:new e.UniformMatrix4f(t)}))(t)),a.includes("GLOBE")&&(this.globeUniforms=(t=>({u_tile_tl_up:new e.Uniform3f(t),u_tile_tr_up:new e.Uniform3f(t),u_tile_br_up:new e.Uniform3f(t),u_tile_bl_up:new e.Uniform3f(t),u_tile_up_scale:new e.Uniform1f(t)}))(t)),a.includes("FOG")&&(this.fogUniforms=(t=>({u_fog_matrix:new e.UniformMatrix4f(t),u_fog_range:new e.Uniform2f(t),u_fog_color:new e.Uniform4f(t),u_fog_horizon_blend:new e.Uniform1f(t),u_fog_temporal_offset:new e.Uniform1f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_globe_transition:new e.Uniform1f(t),u_is_globe:new e.Uniform1i(t),u_viewport:new e.Uniform2f(t)}))(t))}}setTerrainUniformValues(e,t){if(!this.terrainUniforms)return;const n=this.terrainUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setGlobeUniformValues(e,t){if(!this.globeUniforms)return;const n=this.globeUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e]&&n[e].set(this.program,e,t[e])}}setFogUniformValues(e,t){if(!this.fogUniforms)return;const n=this.fogUniforms;if(!this.failedToCreate){e.program.set(this.program);for(const e in t)n[e].set(this.program,e,t[e])}}draw(e,t,n,r,i,o,a,s,l,u,c,h,d,f,p){const m=e.gl;if(this.failedToCreate)return;e.program.set(this.program),e.setDepthMode(n),e.setStencilMode(r),e.setColorMode(i),e.setCullFace(o);for(const e of Object.keys(this.fixedUniforms))this.fixedUniforms[e].set(this.program,e,a[e]);f&&f.setUniforms(this.program,e,this.binderUniforms,h,{zoom:d});const _={[m.LINES]:2,[m.TRIANGLES]:3,[m.LINE_STRIP]:1}[t];for(const n of c.get()){const r=n.vaos||(n.vaos={});(r[s]||(r[s]=new pn)).bind(e,this,l,f?f.getPaintVertexBuffers():[],u,n.vertexOffset,p||[]),m.drawElements(t,n.primitiveLength*_,m.UNSIGNED_SHORT,n.primitiveOffset*_*2)}}}function On(e,t){const n=Math.pow(2,t.tileID.overscaledZ),r=t.tileSize*Math.pow(2,e.transform.tileZoom)/n,i=r*(t.tileID.canonical.x+t.tileID.wrap*n),o=r*t.tileID.canonical.y;return{u_image:0,u_texsize:t.imageAtlasTexture.size,u_tile_units_to_pixels:1/O(t,1,e.transform.tileZoom),u_pixel_coord_upper:[i>>16,o>>16],u_pixel_coord_lower:[65535&i,65535&o]}}const Dn=e.create(),Ln=(t,n,r,i,o,a,s,l,u,c,h)=>{const d=n.style.light,f=d.properties.get("position"),p=[f.x,f.y,f.z],m=e.create$1();"viewport"===d.properties.get("anchor")&&(e.fromRotation(m,-n.transform.angle),e.transformMat3(p,p,m));const _=d.properties.get("color"),g=n.transform,y={u_matrix:t,u_lightpos:p,u_lightintensity:d.properties.get("intensity"),u_lightcolor:[_.r,_.g,_.b],u_vertical_gradient:+r,u_opacity:i,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:Dn,u_merc_center:[0,0],u_up_dir:[0,0,0],u_height_lift:0,u_ao:o,u_edge_radius:a};return"globe"===g.projection.name&&(y.u_tile_id=[s.canonical.x,s.canonical.y,1<{const f=Ln(t,n,r,i,o,a,s,u,c,h,d),p={u_height_factor:-Math.pow(2,s.overscaledZ)/l.tileSize/8};return e.extend(f,On(n,l),p)},Bn=e=>({u_matrix:e}),Fn=(t,n,r)=>e.extend(Bn(t),On(n,r)),jn=(e,t)=>({u_matrix:e,u_world:t}),Nn=(t,n,r,i)=>e.extend(Fn(t,n,r),{u_world:i}),Un=e.create(),Vn=(t,n,r,i,o,a)=>{const s=t.transform,l="globe"===s.projection.name;let u;if("map"===a.paint.get("circle-pitch-alignment"))if(l){const t=e.globePixelsToTileUnits(s.zoom,n.canonical)*s._pixelsPerMercatorPixel;u=Float32Array.from([t,0,0,t])}else u=s.calculatePixelsToTileUnitsMatrix(r);else u=new Float32Array([s.pixelsToGLUnits[0],0,0,s.pixelsToGLUnits[1]]);const c={u_camera_to_center_distance:s.cameraToCenterDistance,u_matrix:t.translatePosMatrix(n.projMatrix,r,a.paint.get("circle-translate"),a.paint.get("circle-translate-anchor")),u_device_pixel_ratio:e.exported.devicePixelRatio,u_extrude_scale:u,u_inv_rot_matrix:Un,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(l){c.u_inv_rot_matrix=i,c.u_merc_center=o,c.u_tile_id=[n.canonical.x,n.canonical.y,1<{const t=[];return"map"===e.paint.get("circle-pitch-alignment")&&t.push("PITCH_WITH_MAP"),"map"===e.paint.get("circle-pitch-scale")&&t.push("SCALE_WITH_MAP"),t},qn=(t,n,r,i)=>{const o=e.EXTENT/r.tileSize;return{u_matrix:t,u_camera_to_center_distance:n.getCameraToCenterDistance(i),u_extrude_scale:[n.pixelsToGLUnits[0]/o,n.pixelsToGLUnits[1]/o]}},$n=(e,t,n=1)=>({u_matrix:e,u_color:t,u_overlay:0,u_overlay_scale:n}),Zn=e.create(),Wn=(t,n,r,i,o,a,s)=>{const l=t.transform,u="globe"===l.projection.name,c=u?e.globePixelsToTileUnits(l.zoom,n.canonical)*l._pixelsPerMercatorPixel:O(r,1,a),h={u_matrix:n.projMatrix,u_extrude_scale:c,u_intensity:s,u_inv_rot_matrix:Zn,u_merc_center:[0,0],u_tile_id:[0,0,0],u_zoom_transition:0,u_up_dir:[0,0,0]};if(u){h.u_inv_rot_matrix=i,h.u_merc_center=o,h.u_tile_id=[n.canonical.x,n.canonical.y,1<{const s=e.transform,l=s.calculatePixelsToTileUnitsMatrix(t);return{u_matrix:Kn(e,t,n,r),u_pixels_to_tile_units:l,u_device_pixel_ratio:o,u_units_to_pixels:[1/s.pixelsToGLUnits[0],1/s.pixelsToGLUnits[1]],u_dash_image:0,u_gradient_image:1,u_image_height:i,u_texsize:Jn(n)?t.lineAtlasTexture.size:[0,0],u_tile_units_to_pixels:Yn(t,e.transform),u_alpha_discard_threshold:0,u_trim_offset:a}},Hn=(e,t,n,r,i)=>{const o=e.transform;return{u_matrix:Kn(e,t,n,r),u_texsize:t.imageAtlasTexture.size,u_pixels_to_tile_units:o.calculatePixelsToTileUnitsMatrix(t),u_device_pixel_ratio:i,u_image:0,u_tile_units_to_pixels:Yn(t,o),u_units_to_pixels:[1/o.pixelsToGLUnits[0],1/o.pixelsToGLUnits[1]],u_alpha_discard_threshold:0}};function Yn(e,t){return 1/O(e,1,t.tileZoom)}function Kn(e,t,n,r){return e.translatePosMatrix(r||t.tileID.projMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}function Jn(e){const t=e.paint.get("line-dasharray").value;return t.value||"constant"!==t.kind}const Qn=(e,t,n,r,i,o)=>{return{u_matrix:e,u_tl_parent:t,u_scale_parent:n,u_fade_t:r.mix,u_opacity:r.opacity*i.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:i.paint.get("raster-brightness-min"),u_brightness_high:i.paint.get("raster-brightness-max"),u_saturation_factor:(s=i.paint.get("raster-saturation"),s>0?1-1/(1.001-s):-s),u_contrast_factor:(a=i.paint.get("raster-contrast"),a>0?1/(1-a):1+a),u_spin_weights:er(i.paint.get("raster-hue-rotate")),u_perspective_transform:o};var a,s};function er(e){e*=Math.PI/180;const t=Math.sin(e),n=Math.cos(e);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const tr=e.create(),nr=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>{const g=o.transform,y={u_is_size_zoom_constant:+("constant"===t||"source"===t),u_is_size_feature_constant:+("constant"===t||"camera"===t),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:g.cameraToCenterDistance,u_rotate_symbol:+r,u_aspect_ratio:g.width/g.height,u_fade_change:o.options.fadeDuration?o.symbolFadeChange:1,u_matrix:a,u_label_plane_matrix:s,u_coord_matrix:l,u_is_text:+u,u_pitch_with_map:+i,u_texsize:c,u_texture:0,u_tile_id:[0,0,0],u_zoom_transition:0,u_inv_rot_matrix:tr,u_merc_center:[0,0],u_camera_forward:[0,0,0],u_ecef_origin:[0,0,0],u_tile_matrix:tr,u_up_vector:[0,-1,0]};return"globe"===_.name&&(y.u_tile_id=[h.canonical.x,h.canonical.y,1<e.extend(nr(t,n,r,i,o,a,s,l,u,c,d,f,p,m,_,g),{u_gamma_scale:i?o.transform.cameraToCenterDistance*Math.cos(o.terrain?0:o.transform._pitch):1,u_device_pixel_ratio:e.exported.devicePixelRatio,u_is_halo:+h}),ir=(t,n,r,i,o,a,s,l,u,c,h,d,f,p,m,_)=>e.extend(rr(t,n,r,i,o,a,s,l,!0,u,!0,h,d,f,p,m,_),{u_texsize_icon:c,u_texture_icon:1}),or=(e,t,n)=>({u_matrix:e,u_opacity:t,u_color:n}),ar=(t,n,r,i,o)=>e.extend(function(e,t,n){const r=t.imageManager.getPattern(e.toString()),{width:i,height:o}=t.imageManager.getPixelSize(),a=Math.pow(2,n.tileID.overscaledZ),s=n.tileSize*Math.pow(2,t.transform.tileZoom)/a,l=s*(n.tileID.canonical.x+n.tileID.wrap*a),u=s*n.tileID.canonical.y;return{u_image:0,u_pattern_tl:r.tl,u_pattern_br:r.br,u_texsize:[i,o],u_pattern_size:r.displaySize,u_tile_units_to_pixels:1/O(n,1,t.transform.tileZoom),u_pixel_coord_upper:[l>>16,u>>16],u_pixel_coord_lower:[65535&l,65535&u]}}(i,r,o),{u_matrix:t,u_opacity:n}),sr={fillExtrusion:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t)}),fillExtrusionPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_lightpos:new e.Uniform3f(t),u_lightintensity:new e.Uniform1f(t),u_lightcolor:new e.Uniform3f(t),u_vertical_gradient:new e.Uniform1f(t),u_height_factor:new e.Uniform1f(t),u_edge_radius:new e.Uniform1f(t),u_ao:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_up_dir:new e.Uniform3f(t),u_height_lift:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t)}),fill:t=>({u_matrix:new e.UniformMatrix4f(t)}),fillPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),fillOutline:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t)}),fillOutlinePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_world:new e.Uniform2f(t),u_image:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),circle:t=>({u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),collisionBox:t=>({u_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_extrude_scale:new e.Uniform2f(t)}),collisionCircle:t=>({u_matrix:new e.UniformMatrix4f(t),u_inv_matrix:new e.UniformMatrix4f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_viewport_size:new e.Uniform2f(t)}),debug:t=>({u_color:new e.UniformColor(t),u_matrix:new e.UniformMatrix4f(t),u_overlay:new e.Uniform1i(t),u_overlay_scale:new e.Uniform1f(t)}),clippingMask:t=>({u_matrix:new e.UniformMatrix4f(t)}),heatmap:t=>({u_extrude_scale:new e.Uniform1f(t),u_intensity:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_up_dir:new e.Uniform3f(t)}),heatmapTexture:t=>({u_image:new e.Uniform1i(t),u_color_ramp:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t)}),hillshade:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_latrange:new e.Uniform2f(t),u_light:new e.Uniform2f(t),u_shadow:new e.UniformColor(t),u_highlight:new e.UniformColor(t),u_accent:new e.UniformColor(t)}),hillshadePrepare:t=>({u_matrix:new e.UniformMatrix4f(t),u_image:new e.Uniform1i(t),u_dimension:new e.Uniform2f(t),u_zoom:new e.Uniform1f(t),u_unpack:new e.Uniform4f(t)}),line:t=>({u_matrix:new e.UniformMatrix4f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_units_to_pixels:new e.Uniform2f(t),u_dash_image:new e.Uniform1i(t),u_gradient_image:new e.Uniform1i(t),u_image_height:new e.Uniform1f(t),u_texsize:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t),u_trim_offset:new e.Uniform2f(t)}),linePattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_texsize:new e.Uniform2f(t),u_pixels_to_tile_units:new e.UniformMatrix2f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_units_to_pixels:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t),u_alpha_discard_threshold:new e.Uniform1f(t)}),raster:t=>({u_matrix:new e.UniformMatrix4f(t),u_tl_parent:new e.Uniform2f(t),u_scale_parent:new e.Uniform1f(t),u_fade_t:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_image0:new e.Uniform1i(t),u_image1:new e.Uniform1i(t),u_brightness_low:new e.Uniform1f(t),u_brightness_high:new e.Uniform1f(t),u_saturation_factor:new e.Uniform1f(t),u_contrast_factor:new e.Uniform1f(t),u_spin_weights:new e.Uniform3f(t),u_perspective_transform:new e.Uniform2f(t)}),symbolIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_texture:new e.Uniform1i(t)}),symbolSDF:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_tile_id:new e.Uniform3f(t),u_zoom_transition:new e.Uniform1f(t),u_inv_rot_matrix:new e.UniformMatrix4f(t),u_merc_center:new e.Uniform2f(t),u_camera_forward:new e.Uniform3f(t),u_tile_matrix:new e.UniformMatrix4f(t),u_up_vector:new e.Uniform3f(t),u_ecef_origin:new e.Uniform3f(t),u_is_halo:new e.Uniform1i(t)}),symbolTextAndIcon:t=>({u_is_size_zoom_constant:new e.Uniform1i(t),u_is_size_feature_constant:new e.Uniform1i(t),u_size_t:new e.Uniform1f(t),u_size:new e.Uniform1f(t),u_camera_to_center_distance:new e.Uniform1f(t),u_rotate_symbol:new e.Uniform1i(t),u_aspect_ratio:new e.Uniform1f(t),u_fade_change:new e.Uniform1f(t),u_matrix:new e.UniformMatrix4f(t),u_label_plane_matrix:new e.UniformMatrix4f(t),u_coord_matrix:new e.UniformMatrix4f(t),u_is_text:new e.Uniform1i(t),u_pitch_with_map:new e.Uniform1i(t),u_texsize:new e.Uniform2f(t),u_texsize_icon:new e.Uniform2f(t),u_texture:new e.Uniform1i(t),u_texture_icon:new e.Uniform1i(t),u_gamma_scale:new e.Uniform1f(t),u_device_pixel_ratio:new e.Uniform1f(t),u_is_halo:new e.Uniform1i(t)}),background:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_color:new e.UniformColor(t)}),backgroundPattern:t=>({u_matrix:new e.UniformMatrix4f(t),u_opacity:new e.Uniform1f(t),u_image:new e.Uniform1i(t),u_pattern_tl:new e.Uniform2f(t),u_pattern_br:new e.Uniform2f(t),u_texsize:new e.Uniform2f(t),u_pattern_size:new e.Uniform2f(t),u_pixel_coord_upper:new e.Uniform2f(t),u_pixel_coord_lower:new e.Uniform2f(t),u_tile_units_to_pixels:new e.Uniform1f(t)}),terrainRaster:vn,terrainDepth:vn,skybox:t=>({u_matrix:new e.UniformMatrix4f(t),u_sun_direction:new e.Uniform3f(t),u_cubemap:new e.Uniform1i(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxGradient:t=>({u_matrix:new e.UniformMatrix4f(t),u_color_ramp:new e.Uniform1i(t),u_center_direction:new e.Uniform3f(t),u_radius:new e.Uniform1f(t),u_opacity:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t)}),skyboxCapture:t=>({u_matrix_3f:new e.UniformMatrix3f(t),u_sun_direction:new e.Uniform3f(t),u_sun_intensity:new e.Uniform1f(t),u_color_tint_r:new e.Uniform4f(t),u_color_tint_m:new e.Uniform4f(t),u_luminance:new e.Uniform1f(t)}),globeRaster:t=>({u_proj_matrix:new e.UniformMatrix4f(t),u_globe_matrix:new e.UniformMatrix4f(t),u_normalize_matrix:new e.UniformMatrix4f(t),u_merc_matrix:new e.UniformMatrix4f(t),u_zoom_transition:new e.Uniform1f(t),u_merc_center:new e.Uniform2f(t),u_image0:new e.Uniform1i(t),u_grid_matrix:new e.UniformMatrix3f(t),u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_globe_pos:new e.Uniform3f(t),u_globe_radius:new e.Uniform1f(t),u_viewport:new e.Uniform2f(t)}),globeAtmosphere:t=>({u_frustum_tl:new e.Uniform3f(t),u_frustum_tr:new e.Uniform3f(t),u_frustum_br:new e.Uniform3f(t),u_frustum_bl:new e.Uniform3f(t),u_horizon:new e.Uniform1f(t),u_transition:new e.Uniform1f(t),u_fadeout_range:new e.Uniform1f(t),u_color:new e.Uniform4f(t),u_high_color:new e.Uniform4f(t),u_space_color:new e.Uniform4f(t),u_star_intensity:new e.Uniform1f(t),u_star_density:new e.Uniform1f(t),u_star_size:new e.Uniform1f(t),u_temporal_offset:new e.Uniform1f(t),u_horizon_angle:new e.Uniform1f(t),u_rotation_matrix:new e.UniformMatrix4f(t)})};let lr;function ur(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=t.useProgram("collisionBox"),d=[];let f=0,p=0;for(let m=0;m0){const t=e.create(),n=x;e.mul(t,y.placementInvProjMatrix,c.glCoordMatrix),e.mul(t,t,y.placementViewportMatrix),d.push({circleArray:w,circleOffset:p,transform:n,invTransform:t,projection:y.getProjection()}),f+=w.length/4,p=f}b&&(t.terrain&&t.terrain.setupElevationDraw(g,h),h.draw(l,u.LINES,e.DepthMode.disabled,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.disabled,qn(x,c,g,y.getProjection()),r.id,b.layoutVertexBuffer,b.indexBuffer,b.segments,null,c.zoom,null,[b.collisionVertexBuffer,b.collisionVertexBufferExt]))}if(!s||!d.length)return;const m=t.useProgram("collisionCircle"),_=new e.StructArrayLayout2f1f2i16;_.resize(4*f),_._trim();let g=0;for(const e of d)for(let t=0;t=0&&(m[x.associatedIconIndex]={x:T,y:k,z:C,angle:z})}else pt(E,f)}if(h){p.clear();const n=t.icon.placedSymbolArray;for(let t=0;te.sortKey-t.sortKey);for(const e of k){const n=e.state;if(t.terrain&&t.terrain.setupElevationDraw(n.tile,n.program,{useDepthForOcclusion:!S,labelPlaneMatrixInv:n.labelPlaneMatrixInv}),f.activeTexture.set(p.TEXTURE0),n.atlasTexture.bind(n.atlasInterpolation,p.CLAMP_TO_EDGE),n.atlasTextureIcon&&(f.activeTexture.set(p.TEXTURE1),n.atlasTextureIcon&&n.atlasTextureIcon.bind(n.atlasInterpolationIcon,p.CLAMP_TO_EDGE)),n.isSDF){const i=n.uniformValues;n.hasHalo&&(i.u_is_halo=1,mr(n.buffers,e.segments,r,t,n.program,w,h,d,i)),i.u_is_halo=0}mr(n.buffers,e.segments,r,t,n.program,w,h,d,n.uniformValues)}}function mr(t,n,r,i,o,a,s,l,u){const c=i.context,h=[t.dynamicLayoutVertexBuffer,t.opacityVertexBuffer,t.globeExtVertexBuffer];o.draw(c,c.gl.TRIANGLES,a,s,l,e.CullFaceMode.disabled,u,r.id,t.layoutVertexBuffer,t.indexBuffer,n,r.paint,i.transform.zoom,t.programConfigurations.get(r.id),h)}function _r(t,n,r,i,o,a,s){const l=t.context.gl,u=r.paint.get("fill-pattern"),c=u&&u.constantOr(1);let h,d,f,p,m;s?(d=c&&!r.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",h=l.LINES):(d=c?"fillPattern":"fill",h=l.TRIANGLES);for(const _ of i){const i=n.getTile(_);if(c&&!i.patternsLoaded())continue;const g=i.getBucket(r);if(!g)continue;t.prepareDrawTile();const y=g.programConfigurations.get(r.id),v=t.useProgram(d,y);c&&(t.context.activeTexture.set(l.TEXTURE0),i.imageAtlasTexture.bind(l.LINEAR,l.CLAMP_TO_EDGE),y.updatePaintBuffers());const x=u.constantOr(null);if(x&&i.imageAtlas){const e=i.imageAtlas.patternPositions[x.toString()];e&&y.setConstantPatternPositions(e)}const b=t.translatePosMatrix(_.projMatrix,i,r.paint.get("fill-translate"),r.paint.get("fill-translate-anchor"));if(s){p=g.indexBuffer2,m=g.segments2;const e=t.terrain&&t.terrain.renderingToTexture?t.terrain.drapeBufferSize:[l.drawingBufferWidth,l.drawingBufferHeight];f="fillOutlinePattern"===d&&c?Nn(b,t,i,e):jn(b,e)}else p=g.indexBuffer,m=g.segments,f=c?Fn(b,t,i):Bn(b);t.prepareDrawProgram(t.context,v,_.toUnwrapped()),v.draw(t.context,h,o,t.stencilModeForClipping(_),a,e.CullFaceMode.disabled,f,r.id,g.layoutVertexBuffer,p,m,r.paint,t.transform.zoom,y)}}function gr(t,n,r,i,o,a,s){const l=t.context,u=l.gl,c=t.transform,h=r.paint.get("fill-extrusion-pattern"),d=h.constantOr(1),f=r.paint.get("fill-extrusion-opacity"),p=[r.paint.get("fill-extrusion-ambient-occlusion-intensity"),r.paint.get("fill-extrusion-ambient-occlusion-radius")],m=r.layout.get("fill-extrusion-edge-radius"),_="globe"===c.projection.name?e.fillExtrusionHeightLift():0,g="globe"===c.projection.name,y=g?e.globeToMercatorTransition(c.zoom):0,v=[e.mercatorXfromLng(c.center.lng),e.mercatorYfromLat(c.center.lat)],x=[];g&&(x.push("PROJECTION_GLOBE_VIEW"),t.style.terrainSetForDrapingOnly()&&x.push("TERRAIN")),p[0]>0&&x.push("FAUX_AO");for(const b of i){const i=n.getTile(b),w=i.getBucket(r);if(!w||w.projection.name!==c.projection.name)continue;const E=w.programConfigurations.get(r.id),T=t.useProgram(d?"fillExtrusionPattern":"fillExtrusion",E,x);if(t.terrain){const e=t.terrain;if(t.style.terrainSetForDrapingOnly())e.setupElevationDraw(i,T,{useMeterToDem:!0});else{if(!w.enableTerrain)continue;if(e.setupElevationDraw(i,T,{useMeterToDem:!0}),yr(l,n,b,w,r,e),!w.centroidVertexBuffer){const e=T.attributes.a_centroid_pos;void 0!==e&&u.vertexAttrib2f(e,0,0)}}}d&&(t.context.activeTexture.set(u.TEXTURE0),i.imageAtlasTexture.bind(u.LINEAR,u.CLAMP_TO_EDGE),E.updatePaintBuffers());const S=h.constantOr(null);if(S&&i.imageAtlas){const e=i.imageAtlas.patternPositions[S.toString()];e&&E.setConstantPatternPositions(e)}const k=t.translatePosMatrix(b.projMatrix,i,r.paint.get("fill-extrusion-translate"),r.paint.get("fill-extrusion-translate-anchor")),C=c.projection.createInversionMatrix(c,b.canonical),M=r.paint.get("fill-extrusion-vertical-gradient"),A=d?Rn(k,t,M,f,p,m,b,i,_,y,v,C):Ln(k,t,M,f,p,m,b,_,y,v,C);t.prepareDrawProgram(l,T,b.toUnwrapped());const I=[];t.terrain&&I.push(w.centroidVertexBuffer),g&&I.push(w.layoutVertexExtBuffer),T.draw(l,l.gl.TRIANGLES,o,a,s,e.CullFaceMode.backCCW,A,r.id,w.layoutVertexBuffer,w.indexBuffer,w.segments,r.paint,t.transform.zoom,E,I)}}function yr(t,n,r,i,o,a){const s=[t=>{let n=t.canonical.x-1,r=t.wrap;return n<0&&(n=(1<{let n=t.canonical.x+1,r=t.wrap;return n===1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,(0===t.canonical.y?1<new e.OverscaledTileID(t.overscaledZ,t.wrap,t.canonical.z,t.canonical.x,t.canonical.y===(1<{const t=n.getSource().minzoom,r=e=>{const t=n.getTileByID(e);if(t&&t.hasData())return t.getBucket(o)},i=[0,-1,1];for(const n of i){if(e.overscaledZ+n(u[0]=Math.min(t.min.y,n.min.y),u[1]=Math.max(t.max.y,n.max.y),u[2]=e.EXTENT-n.min.x>t.max.x?n.min.x-e.EXTENT:t.max.x,u),h=(t,n)=>(u[0]=Math.min(t.min.x,n.min.x),u[1]=Math.max(t.max.x,n.max.x),u[2]=e.EXTENT-n.min.y>t.max.y?n.min.y-e.EXTENT:t.max.y,u),d=[(e,t)=>c(e,t),(e,t)=>c(t,e),(e,t)=>h(e,t),(e,t)=>h(t,e)],f=new e.pointGeometry(0,0);let p,m,_;const g=(t,n,i,o,s)=>{const l=[[o?i:t,o?t:i,0],[o?i:n,o?n:i,0]],u=s<0?e.EXTENT+s:s,c=[o?u:(t+n)/2,o?(t+n)/2:u,0];return 0===i&&s<0||0!==i&&s>0?a.getForTilePoints(_,[c],!0,m):l.push(c),a.getForTilePoints(r,l,!0,p),Math.max(l[0][2],l[1][2],c[2])/a.exaggeration()};for(let t=0;t<4;t++){const n=(t<2?1:5)-t,o=i.borders[t];if(0===o.length)continue;const u=_=s[t](r),c=l(u);if(!(c&&c instanceof e.FillExtrusionBucket&&c.enableTerrain))continue;if(i.borderDoneWithNeighborZ[t]===c.canonical.z&&c.borderDoneWithNeighborZ[n]===i.canonical.z)continue;if(m=a.findDEMTileFor(u),!m||!m.dem)continue;if(!p){const e=a.findDEMTileFor(r);if(!e||!e.dem)return;p=e}const h=c.borders[n];let y=0;const v=c.borderDoneWithNeighborZ[n]!==i.canonical.z;if(i.canonical.z===c.canonical.z){for(let r=0;rs[0]+3));)v&&c.encodeCentroid(void 0,l,!1),y++;if(l&&ys[1]-3)&&(o++,++y!==h.length);)l=c.featuresOnBorder[h[y]];if(l=c.featuresOnBorder[h[r]],a.intersectsCount()>1||l.intersectsCount()>1||1!==o){1!==o&&(y=r),i.encodeCentroid(void 0,a,!1),v&&c.encodeCentroid(void 0,l,!1);continue}const u=d[t](a,l),p=t%2?e.EXTENT-1:0;f.x=g(u[0],Math.min(e.EXTENT-1,u[1]),p,t<2,u[2]),f.y=0,i.encodeCentroid(f,a,!1),v&&c.encodeCentroid(f,l,!1)}else i.encodeCentroid(void 0,a,!1)}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0,v&&(c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0)}else{for(const e of o)i.encodeCentroid(void 0,i.featuresOnBorder[e],!1);if(v){for(const e of h)c.encodeCentroid(void 0,c.featuresOnBorder[e],!1);c.borderDoneWithNeighborZ[n]=i.canonical.z,c.needsCentroidUpdate=!0}i.borderDoneWithNeighborZ[t]=c.canonical.z,i.needsCentroidUpdate=!0}}(i.needsCentroidUpdate||!i.centroidVertexBuffer&&0!==i.centroidVertexArray.length)&&i.uploadCentroid(t)}const vr=new e.Color(1,0,0,1),xr=new e.Color(0,1,0,1),br=new e.Color(0,0,1,1),wr=new e.Color(1,0,1,1),Er=new e.Color(0,1,1,1);function Tr(t,n,r){const i=t.context,o=t.transform,a=i.gl,s="globe"===o.projection.name,l=s?["PROJECTION_GLOBE_VIEW"]:null;let u=r.projMatrix;if(s&&e.globeToMercatorTransition(o.zoom)>0){const t=e.transitionTileAABBinECEF(r.canonical,o),n=e.globeDenormalizeECEF(t);u=e.multiply(new Float32Array(16),o.globeMatrix,n),e.multiply(u,o.projMatrix,u)}const c=t.useProgram("debug",null,l),h=n.getTileByID(r.key);t.terrain&&t.terrain.setupElevationDraw(h,c);const d=e.DepthMode.disabled,f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="$debug";i.activeTexture.set(a.TEXTURE0),t.emptyTexture.bind(a.LINEAR,a.CLAMP_TO_EDGE),s?h._makeGlobeTileDebugBuffers(t.context,o):h._makeDebugTileBoundsBuffers(t.context,o.projection);const _=h._tileDebugBuffer||t.debugBuffer,g=h._tileDebugIndexBuffer||t.debugIndexBuffer,y=h._tileDebugSegments||t.debugSegments;c.draw(i,a.LINE_STRIP,d,f,p,e.CullFaceMode.disabled,$n(u,e.Color.red),m,_,g,y,null,null,null,[h._globeTileDebugBorderBuffer]);const v=h.latestRawTileData,x=Math.floor((v&&v.byteLength||0)/1024),b=n.getTile(r).tileSize,w=512/Math.min(b,512)*(r.overscaledZ/o.zoom)*.5;let E=r.canonical.toString();r.overscaledZ!==r.canonical.z&&(E+=" => "+r.overscaledZ),E+=` ${x}kb`,function(e,t){e.initDebugOverlayCanvas();const n=e.debugOverlayCanvas,r=e.context.gl,i=e.debugOverlayCanvas.getContext("2d");i.clearRect(0,0,n.width,n.height),i.shadowColor="white",i.shadowBlur=2,i.lineWidth=1.5,i.strokeStyle="white",i.textBaseline="top",i.font="bold 36px Open Sans, sans-serif",i.fillText(t,5,5),i.strokeText(t,5,5),e.debugOverlayTexture.update(n),e.debugOverlayTexture.bind(r.LINEAR,r.CLAMP_TO_EDGE)}(t,E);const T=h._tileDebugTextBuffer||t.debugBuffer,S=h._tileDebugTextIndexBuffer||t.quadTriangleIndexBuffer,k=h._tileDebugTextSegments||t.debugSegments;c.draw(i,a.TRIANGLES,d,f,e.ColorMode.alphaBlended,e.CullFaceMode.disabled,$n(u,e.Color.transparent,w),m,T,S,k,null,null,null,[h._globeTileDebugTextBuffer])}function Sr(e,t,n,r){Cr(e,0,t+n/2,e.transform.width,n,r)}function kr(e,t,n,r){Cr(e,t-n/2,0,n,e.transform.height,r)}function Cr(t,n,r,i,o,a){const s=t.context,l=s.gl;l.enable(l.SCISSOR_TEST),l.scissor(n*e.exported.devicePixelRatio,r*e.exported.devicePixelRatio,i*e.exported.devicePixelRatio,o*e.exported.devicePixelRatio),s.clear({color:a}),l.disable(l.SCISSOR_TEST)}const Mr=e.createLayout([{name:"a_pos_3f",components:3,type:"Float32"}]),{members:Ar}=Mr;function Ir(e,t,n,r){e.emplaceBack(t,n,r)}class Pr{constructor(t){this.vertexArray=new e.StructArrayLayout3f12,this.indices=new e.StructArrayLayout3ui6,Ir(this.vertexArray,-1,-1,1),Ir(this.vertexArray,1,-1,1),Ir(this.vertexArray,-1,1,1),Ir(this.vertexArray,1,1,1),Ir(this.vertexArray,-1,-1,-1),Ir(this.vertexArray,1,-1,-1),Ir(this.vertexArray,-1,1,-1),Ir(this.vertexArray,1,1,-1),this.indices.emplaceBack(5,1,3),this.indices.emplaceBack(3,7,5),this.indices.emplaceBack(6,2,0),this.indices.emplaceBack(0,4,6),this.indices.emplaceBack(2,6,7),this.indices.emplaceBack(7,3,2),this.indices.emplaceBack(5,4,0),this.indices.emplaceBack(0,1,5),this.indices.emplaceBack(0,2,3),this.indices.emplaceBack(3,1,0),this.indices.emplaceBack(7,6,4),this.indices.emplaceBack(4,5,7),this.vertexBuffer=t.createVertexBuffer(this.vertexArray,Ar),this.indexBuffer=t.createIndexBuffer(this.indices),this.segment=e.SegmentVector.simpleSegment(0,0,36,12)}}function zr(t,n,r,i,o,a){const s=t.gl,l=n.paint.get("sky-atmosphere-color"),u=n.paint.get("sky-atmosphere-halo-color"),c=n.paint.get("sky-atmosphere-sun-intensity"),h=((e,t,n,r,i)=>({u_matrix_3f:e,u_sun_direction:t,u_sun_intensity:n,u_color_tint_r:[r.r,r.g,r.b,r.a],u_color_tint_m:[i.r,i.g,i.b,i.a],u_luminance:5e-5}))(e.fromMat4(e.create$1(),i),o,c,l,u);s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+a,n.skyboxTexture,0),r.draw(t,s.TRIANGLES,e.DepthMode.disabled,e.StencilMode.disabled,e.ColorMode.unblended,e.CullFaceMode.frontCW,h,"skyboxCapture",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}const Or=e.createLayout([{type:"Float32",name:"a_pos",components:3},{type:"Float32",name:"a_uv",components:2}]);class Dr{constructor(t){const n=new e.StructArrayLayout5f20;n.emplaceBack(-1,1,1,0,0),n.emplaceBack(1,1,1,1,0),n.emplaceBack(1,-1,1,1,1),n.emplaceBack(-1,-1,1,0,1);const r=new e.StructArrayLayout3ui6;r.emplaceBack(0,1,2),r.emplaceBack(2,3,0),this.vertexBuffer=t.createVertexBuffer(n,Or.members),this.indexBuffer=t.createIndexBuffer(r),this.segments=e.SegmentVector.simpleSegment(0,0,4,2)}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy()}}const Lr={symbol:function(t,n,r,i,o){if("translucent"!==t.renderPass)return;const a=e.StencilMode.disabled,s=t.colorModeForRenderPass();r.layout.get("text-variable-anchor")&&function(t,n,r,i,o,a,s){const l=n.transform,u="map"===o,c="map"===a;for(const n of t){const t=i.getTile(n),o=t.getBucket(r);if(!o||!o.text||!o.text.segments.get().length)continue;const a=e.evaluateSizeForZoom(o.textSizeData,l.zoom),h=xt(n,o.getProjection(),l),d=l.calculatePixelsToTileUnitsMatrix(t),f=tt(h,t.tileID.canonical,c,u,l,o.getProjection(),d),p="none"!==r.layout.get("icon-text-fit")&&o.hasIconData();if(a){const r=Math.pow(2,l.zoom-t.tileID.overscaledZ);dr(o,u,c,s,e.symbolSize,l,f,n,r,a,p)}}}(i,t,r,n,r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),o),0!==r.paint.get("icon-opacity").constantOr(1)&&pr(t,n,r,i,!1,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),r.layout.get("icon-rotation-alignment"),r.layout.get("icon-pitch-alignment"),r.layout.get("icon-keep-upright"),a,s),0!==r.paint.get("text-opacity").constantOr(1)&&pr(t,n,r,i,!0,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),r.layout.get("text-rotation-alignment"),r.layout.get("text-pitch-alignment"),r.layout.get("text-keep-upright"),a,s),n.map.showCollisionBoxes&&(ur(t,n,r,i,r.paint.get("text-translate"),r.paint.get("text-translate-anchor"),!0),ur(t,n,r,i,r.paint.get("icon-translate"),r.paint.get("icon-translate-anchor"),!1))},circle:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("circle-opacity"),a=r.paint.get("circle-stroke-width"),s=r.paint.get("circle-stroke-opacity"),l=void 0!==r.layout.get("circle-sort-key").constantOr(1);if(0===o.constantOr(1)&&(0===a.constantOr(1)||0===s.constantOr(1)))return;const u=t.context,c=u.gl,h=t.transform,d=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),f=e.StencilMode.disabled,p=t.colorModeForRenderPass(),m="globe"===h.projection.name,_=[e.mercatorXfromLng(h.center.lng),e.mercatorYfromLat(h.center.lat)],g=[];for(let o=0;oe.sortKey-t.sortKey);const y={useDepthForOcclusion:!m};for(const n of g){const{programConfiguration:i,program:o,layoutVertexBuffer:a,globeExtVertexBuffer:s,indexBuffer:l,uniformValues:m,tile:_}=n.state,g=n.segments;t.terrain&&t.terrain.setupElevationDraw(_,o,y),t.prepareDrawProgram(u,o,_.tileID.toUnwrapped()),o.draw(u,c.TRIANGLES,d,f,p,e.CullFaceMode.disabled,m,r.id,a,l,g,r.paint,h.zoom,i,[s])}},heatmap:function(t,n,r,i){if(0!==r.paint.get("heatmap-opacity"))if("offscreen"===t.renderPass){const o=t.context,a=o.gl,s=e.StencilMode.disabled,l=new e.ColorMode([a.ONE,a.ONE],e.Color.transparent,[!0,!0,!0,!0]);!function(e,t,n,r){const i=e.gl,o=t.width*r,a=t.height*r;e.activeTexture.set(i.TEXTURE1),e.viewport.set([0,0,o,a]);let s=n.heatmapFbo;if(!s||s&&(s.width!==o||s.height!==a)){s&&s.destroy();const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,i.LINEAR),s=n.heatmapFbo=e.createFramebuffer(o,a,!1),function(e,t,n,r,i,o){const a=e.gl;a.texImage2D(a.TEXTURE_2D,0,a.RGBA,i,o,0,a.RGBA,e.extRenderToTextureHalfFloat?e.extTextureHalfFloat.HALF_FLOAT_OES:a.UNSIGNED_BYTE,null),r.colorAttachment.set(n)}(e,0,t,s,o,a)}else i.bindTexture(i.TEXTURE_2D,s.colorAttachment.get()),e.bindFramebuffer.set(s.framebuffer)}(o,t,r,"globe"===t.transform.projection.name?.5:.25),o.clear({color:e.Color.transparent});const u=t.transform,c="globe"===u.projection.name,h=c?["PROJECTION_GLOBE_VIEW"]:null,d=c?e.CullFaceMode.frontCCW:e.CullFaceMode.disabled,f=[e.mercatorXfromLng(u.center.lng),e.mercatorYfromLat(u.center.lat)];for(let p=0;p({u_image:0,u_color_ramp:1,u_opacity:t.paint.get("heatmap-opacity")}))(0,n),n.id,t.viewportBuffer,t.quadTriangleIndexBuffer,t.viewportSegments,n.paint,t.transform.zoom)}(t,r))},line:function(t,n,r,i){if("translucent"!==t.renderPass)return;const o=r.paint.get("line-opacity"),a=r.paint.get("line-width");if(0===o.constantOr(1)||0===a.constantOr(1))return;const s=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),l=t.colorModeForRenderPass(),u=t.terrain&&t.terrain.renderingToTexture?1:e.exported.devicePixelRatio,c=r.paint.get("line-dasharray"),h=c.constantOr(1),d=r.layout.get("line-cap"),f=r.paint.get("line-pattern"),p=f.constantOr(1),m=r.paint.get("line-gradient"),_=p?"linePattern":"line",g=t.context,y=g.gl,v=(e=>{const t=[];Jn(e)&&t.push("RENDER_LINE_DASH"),e.paint.get("line-gradient")&&t.push("RENDER_LINE_GRADIENT");const n=e.paint.get("line-trim-offset");0===n[0]&&0===n[1]||t.push("RENDER_LINE_TRIM_OFFSET");const r=e.paint.get("line-pattern").constantOr(1),i=1!==e.paint.get("line-opacity").constantOr(1);return!r&&i&&t.push("RENDER_LINE_ALPHA_DISCARD"),t})(r);let x=v.includes("RENDER_LINE_ALPHA_DISCARD");t.terrain&&t.terrain.clipOrMaskOverlapStencilType()&&(x=!1);for(const o of i){const i=n.getTile(o);if(p&&!i.patternsLoaded())continue;const a=i.getBucket(r);if(!a)continue;t.prepareDrawTile();const b=a.programConfigurations.get(r.id),w=t.useProgram(_,b,v),E=f.constantOr(null);if(E&&i.imageAtlas){const e=i.imageAtlas.patternPositions[E.toString()];e&&b.setConstantPatternPositions(e)}const T=c.constantOr(null),S=d.constantOr(null);if(!p&&T&&S&&i.lineAtlas){const e=i.lineAtlas.getDash(T,S);e&&b.setConstantPatternPositions(e)}let[k,C]=r.paint.get("line-trim-offset");if("round"===S||"square"===S){const e=1;k!==C&&(0===k&&(k-=e),1===C&&(C+=e))}const M=t.terrain?o.projMatrix:null,A=p?Hn(t,i,r,M,u):Xn(t,i,r,M,a.lineClipsArray.length,u,[k,C]);if(m){const i=a.gradients[r.id];let s=i.texture;if(r.gradientVersion!==i.version){let l=256;if(r.stepInterpolant){const r=n.getSource().maxzoom,i=o.canonical.z===r?Math.ceil(1<{w.draw(g,y.TRIANGLES,s,n,l,e.CullFaceMode.disabled,A,r.id,a.layoutVertexBuffer,a.indexBuffer,a.segments,r.paint,t.transform.zoom,b,[a.layoutVertexBuffer2])};if(x){const n=t.stencilModeForClipping(o).ref;0===n&&t.terrain&&g.clear({stencil:0});const r={func:y.EQUAL,mask:255};A.u_alpha_discard_threshold=.8,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.INVERT)),A.u_alpha_discard_threshold=0,I(new e.StencilMode(r,n,255,y.KEEP,y.KEEP,y.KEEP))}else I(t.stencilModeForClipping(o))}x&&(t.resetStencilClippingMasks(),t.terrain&&g.clear({stencil:0}))},fill:function(t,n,r,i){const o=r.paint.get("fill-color"),a=r.paint.get("fill-opacity");if(0===a.constantOr(1))return;const s=t.colorModeForRenderPass(),l=r.paint.get("fill-pattern"),u=t.opaquePassEnabledForLayer()&&!l.constantOr(1)&&1===o.constantOr(e.Color.transparent).a&&1===a.constantOr(0)?"opaque":"translucent";if(t.renderPass===u){const o=t.depthModeForSublayer(1,"opaque"===t.renderPass?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly);_r(t,n,r,i,o,s,!1)}if("translucent"===t.renderPass&&r.paint.get("fill-antialias")){const o=t.depthModeForSublayer(r.getPaintProperty("fill-outline-color")?2:0,e.DepthMode.ReadOnly);_r(t,n,r,i,o,s,!0)}},"fill-extrusion":function(t,n,r,i){const o=r.paint.get("fill-extrusion-opacity");if(0!==o&&"translucent"===t.renderPass){const a=new e.DepthMode(t.context.gl.LEQUAL,e.DepthMode.ReadWrite,t.depthRangeFor3D);if(1!==o||r.paint.get("fill-extrusion-pattern").constantOr(1))gr(t,n,r,i,a,e.StencilMode.disabled,e.ColorMode.disabled),gr(t,n,r,i,a,t.stencilModeFor3D(),t.colorModeForRenderPass()),t.resetStencilClippingMasks();else{const o=t.colorModeForRenderPass();gr(t,n,r,i,a,e.StencilMode.disabled,o)}}},hillshade:function(t,n,r,i){if("offscreen"!==t.renderPass&&"translucent"!==t.renderPass)return;const o=t.context,a=t.depthModeForSublayer(0,e.DepthMode.ReadOnly),s=t.colorModeForRenderPass(),l=t.terrain&&t.terrain.renderingToTexture,[u,c]="translucent"!==t.renderPass||l?[{},i]:t.stencilConfigForOverlap(i);for(const i of c){const o=n.getTile(i);if(o.needsHillshadePrepare&&"offscreen"===t.renderPass)yn(t,o,r,a,e.StencilMode.disabled,s);else if("translucent"===t.renderPass){const e=l&&t.terrain?t.terrain.stencilModeForRTTOverlap(i):u[i.overscaledZ];_n(t,i,o,r,a,e,s)}}o.viewport.set([0,0,t.width,t.height]),t.resetStencilClippingMasks()},raster:function(t,n,r,i,o,a){if("translucent"!==t.renderPass)return;if(0===r.paint.get("raster-opacity"))return;if(!i.length)return;const s=t.context,l=s.gl,u=n.getSource(),c=t.useProgram("raster"),h=t.colorModeForRenderPass(),d=t.terrain&&t.terrain.renderingToTexture,[f,p]=u instanceof Ie||d?[{},i]:t.stencilConfigForOverlap(i),m=p[p.length-1].overscaledZ,_=!t.options.moving;for(const i of p){const o=d?e.DepthMode.disabled:t.depthModeForSublayer(i.overscaledZ-m,1===r.paint.get("raster-opacity")?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly,l.LESS),p=i.toUnwrapped(),g=n.getTile(i);if(d&&(!g||!g.hasData()))continue;const y=d?i.projMatrix:t.transform.calculateProjMatrix(p,_),v=t.terrain&&d?t.terrain.stencilModeForRTTOverlap(i):f[i.overscaledZ],x=a?0:r.paint.get("raster-fade-duration");g.registerFadeDuration(x);const b=n.findLoadedParent(i,0),w=Cn(g,b,n,t.transform,x);let E,T;t.terrain&&t.terrain.prepareDrawTile();const S="nearest"===r.paint.get("raster-resampling")?l.NEAREST:l.LINEAR;s.activeTexture.set(l.TEXTURE0),g.texture.bind(S,l.CLAMP_TO_EDGE),s.activeTexture.set(l.TEXTURE1),b?(b.texture.bind(S,l.CLAMP_TO_EDGE),E=Math.pow(2,b.tileID.overscaledZ-g.tileID.overscaledZ),T=[g.tileID.canonical.x*E%1,g.tileID.canonical.y*E%1]):g.texture.bind(S,l.CLAMP_TO_EDGE);const k=Qn(y,T||[0,0],E||1,w,r,u instanceof Ie?u.perspectiveTransform:[0,0]);if(t.prepareDrawProgram(s,c,p),u instanceof Ie)u.boundsBuffer&&u.boundsSegments&&c.draw(s,l.TRIANGLES,o,e.StencilMode.disabled,h,e.CullFaceMode.disabled,k,r.id,u.boundsBuffer,t.quadTriangleIndexBuffer,u.boundsSegments);else{const{tileBoundsBuffer:n,tileBoundsIndexBuffer:i,tileBoundsSegments:a}=t.getTileBoundsBuffers(g);c.draw(s,l.TRIANGLES,o,v,h,e.CullFaceMode.disabled,k,r.id,n,i,a)}}t.resetStencilClippingMasks()},background:function(t,n,r,i){const o=r.paint.get("background-color"),a=r.paint.get("background-opacity");if(0===a)return;const s=t.context,l=s.gl,u=t.transform,c=u.tileSize,h=r.paint.get("background-pattern");if(t.isPatternMissing(h))return;const d=!h&&1===o.a&&1===a&&t.opaquePassEnabledForLayer()?"opaque":"translucent";if(t.renderPass!==d)return;const f=e.StencilMode.disabled,p=t.depthModeForSublayer(0,"opaque"===d?e.DepthMode.ReadWrite:e.DepthMode.ReadOnly),m=t.colorModeForRenderPass(),_=t.useProgram(h?"backgroundPattern":"background");let g,y=i;y||(g=t.getBackgroundTiles(),y=Object.values(g).map(e=>e.tileID)),h&&(s.activeTexture.set(l.TEXTURE0),t.imageManager.bind(t.context));for(const d of y){const y=d.toUnwrapped(),v=i?d.projMatrix:t.transform.calculateProjMatrix(y);t.prepareDrawTile();const x=n?n.getTile(d):g?g[d.key]:new e.Tile(d,c,u.zoom,t),b=h?ar(v,a,t,h,{tileID:d,tileSize:c}):or(v,a,o);t.prepareDrawProgram(s,_,y);const{tileBoundsBuffer:w,tileBoundsIndexBuffer:E,tileBoundsSegments:T}=t.getTileBoundsBuffers(x);_.draw(s,l.TRIANGLES,p,f,m,e.CullFaceMode.disabled,b,r.id,w,E,T)}},sky:function(t,n,r){const i=t.transform,o="mercator"===i.projection.name||"globe"===i.projection.name?1:e.smoothstep(7,8,i.zoom),a=r.paint.get("sky-opacity")*o;if(0===a)return;const s=t.context,l=r.paint.get("sky-type"),u=new e.DepthMode(s.gl.LEQUAL,e.DepthMode.ReadOnly,[0,1]),c=t.frameCounter/1e3%1;"atmosphere"===l?"offscreen"===t.renderPass?r.needsSkyboxCapture(t)&&(function(t,n,r,i){const o=t.context,a=o.gl;let s=n.skyboxFbo;if(!s){s=n.skyboxFbo=o.createFramebuffer(32,32,!1),n.skyboxGeometry=new Pr(o),n.skyboxTexture=o.gl.createTexture(),a.bindTexture(a.TEXTURE_CUBE_MAP,n.skyboxTexture),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR);for(let e=0;e<6;++e)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+e,0,a.RGBA,32,32,0,a.RGBA,a.UNSIGNED_BYTE,null)}o.bindFramebuffer.set(s.framebuffer),o.viewport.set([0,0,32,32]);const l=n.getCenter(t,!0),u=t.useProgram("skyboxCapture"),c=new Float64Array(16);e.identity(c),e.rotateY(c,c,.5*-Math.PI),zr(o,n,u,c,l,0),e.identity(c),e.rotateY(c,c,.5*Math.PI),zr(o,n,u,c,l,1),e.identity(c),e.rotateX(c,c,.5*-Math.PI),zr(o,n,u,c,l,2),e.identity(c),e.rotateX(c,c,.5*Math.PI),zr(o,n,u,c,l,3),e.identity(c),zr(o,n,u,c,l,4),e.identity(c),e.rotateY(c,c,Math.PI),zr(o,n,u,c,l,5),o.viewport.set([0,0,t.width,t.height])}(t,r),r.markSkyboxValid(t)):"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skybox");a.activeTexture.set(s.TEXTURE0),s.bindTexture(s.TEXTURE_CUBE_MAP,n.skyboxTexture);const c=((e,t,n,r,i)=>({u_matrix:e,u_sun_direction:t,u_cubemap:0,u_opacity:r,u_temporal_offset:i}))(l.skyboxMatrix,n.getCenter(t,!1),0,i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,c,"skybox",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c):"gradient"===l&&"sky"===t.renderPass&&function(t,n,r,i,o){const a=t.context,s=a.gl,l=t.transform,u=t.useProgram("skyboxGradient");n.skyboxGeometry||(n.skyboxGeometry=new Pr(a)),a.activeTexture.set(s.TEXTURE0);let c=n.colorRampTexture;c||(c=n.colorRampTexture=new e.Texture(a,n.colorRamp,s.RGBA)),c.bind(s.LINEAR,s.CLAMP_TO_EDGE);const h=((t,n,r,i,o)=>({u_matrix:t,u_color_ramp:0,u_center_direction:n,u_radius:e.degToRad(r),u_opacity:i,u_temporal_offset:o}))(l.skyboxMatrix,n.getCenter(t,!1),n.paint.get("sky-gradient-radius"),i,o);t.prepareDrawProgram(a,u),u.draw(a,s.TRIANGLES,r,e.StencilMode.disabled,t.colorModeForRenderPass(),e.CullFaceMode.backCW,h,"skyboxGradient",n.skyboxGeometry.vertexBuffer,n.skyboxGeometry.indexBuffer,n.skyboxGeometry.segment)}(t,r,u,a,c)},debug:function(e,t,n){for(let r=0;rr)return void(this.transform.fogCullDistSq=null);const i=n+.78*(r-n);this.transform.fogCullDistSq=i*i}get terrain(){return this.transform._terrainEnabled()&&this._terrain&&this._terrain.enabled?this._terrain:null}resize(t,n){if(this.width=t*e.exported.devicePixelRatio,this.height=n*e.exported.devicePixelRatio,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const e of this.style.order)this.style._layers[e].resize()}setup(){const t=this.context,n=new e.StructArrayLayout2i4;n.emplaceBack(0,0),n.emplaceBack(e.EXTENT,0),n.emplaceBack(0,e.EXTENT),n.emplaceBack(e.EXTENT,e.EXTENT),this.tileExtentBuffer=t.createVertexBuffer(n,e.posAttributes.members),this.tileExtentSegments=e.SegmentVector.simpleSegment(0,0,4,2);const r=new e.StructArrayLayout2i4;r.emplaceBack(0,0),r.emplaceBack(e.EXTENT,0),r.emplaceBack(0,e.EXTENT),r.emplaceBack(e.EXTENT,e.EXTENT),this.debugBuffer=t.createVertexBuffer(r,e.posAttributes.members),this.debugSegments=e.SegmentVector.simpleSegment(0,0,4,5);const i=new e.StructArrayLayout2i4;i.emplaceBack(-1,-1),i.emplaceBack(1,-1),i.emplaceBack(-1,1),i.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(i,e.posAttributes.members),this.viewportSegments=e.SegmentVector.simpleSegment(0,0,4,2);const o=new e.StructArrayLayout4i8;o.emplaceBack(0,0,0,0),o.emplaceBack(e.EXTENT,0,e.EXTENT,0),o.emplaceBack(0,e.EXTENT,0,e.EXTENT),o.emplaceBack(e.EXTENT,e.EXTENT,e.EXTENT,e.EXTENT),this.mercatorBoundsBuffer=t.createVertexBuffer(o,e.boundsAttributes.members),this.mercatorBoundsSegments=e.SegmentVector.simpleSegment(0,0,4,2);const a=new e.StructArrayLayout3ui6;a.emplaceBack(0,1,2),a.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(a);const s=new e.StructArrayLayout1ui2;for(const e of[0,1,3,2,0])s.emplaceBack(e);this.debugIndexBuffer=t.createIndexBuffer(s),this.emptyTexture=new e.Texture(t,new e.RGBAImage({width:1,height:1},Uint8Array.of(0,0,0,0)),t.gl.RGBA),this.identityMat=e.create();const l=this.context.gl;this.stencilClearMode=new e.StencilMode({func:l.ALWAYS,mask:0},0,255,l.ZERO,l.ZERO,l.ZERO),this.loadTimeStamps.push(e.window.performance.now()),this.atmosphereBuffer=new Dr(this.context)}getMercatorTileBoundsBuffers(){return{tileBoundsBuffer:this.mercatorBoundsBuffer,tileBoundsIndexBuffer:this.quadTriangleIndexBuffer,tileBoundsSegments:this.mercatorBoundsSegments}}getTileBoundsBuffers(e){return e._makeTileBoundsBuffers(this.context,this.transform.projection),e._tileBoundsBuffer?{tileBoundsBuffer:e._tileBoundsBuffer,tileBoundsIndexBuffer:e._tileBoundsIndexBuffer,tileBoundsSegments:e._tileBoundsSegments}:this.getMercatorTileBoundsBuffers()}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0,this._tileClippingMaskIDs={},this.useProgram("clippingMask").draw(t,n.TRIANGLES,e.DepthMode.disabled,this.stencilClearMode,e.ColorMode.disabled,e.CullFaceMode.disabled,kn(this.identityMat),"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}resetStencilClippingMasks(){this.terrain||(this.currentStencilSource=void 0,this._tileClippingMaskIDs={})}_renderTileClippingMasks(t,n,r){if(!n||this.currentStencilSource===n.id||!t.isTileClipped()||!r||0===r.length)return;if(this._tileClippingMaskIDs&&!this.terrain){let e=!1;for(const t of r)if(void 0===this._tileClippingMaskIDs[t.key]){e=!0;break}if(!e)return}this.currentStencilSource=n.id;const i=this.context,o=i.gl;this.nextStencilID+r.length>256&&this.clearStencil(),i.setColorMode(e.ColorMode.disabled),i.setDepthMode(e.DepthMode.disabled);const a=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const t of r){const r=n.getTile(t),s=this._tileClippingMaskIDs[t.key]=this.nextStencilID++,{tileBoundsBuffer:l,tileBoundsIndexBuffer:u,tileBoundsSegments:c}=this.getTileBoundsBuffers(r);a.draw(i,o.TRIANGLES,e.DepthMode.disabled,new e.StencilMode({func:o.ALWAYS,mask:0},s,255,o.KEEP,o.KEEP,o.REPLACE),e.ColorMode.disabled,e.CullFaceMode.disabled,kn(t.projMatrix),"$clipping",l,u,c)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new e.StencilMode({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){if(this.terrain)return this.terrain.stencilModeForRTTOverlap(t);const n=this.context.gl;return new e.StencilMode({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,r=t.sort((e,t)=>t.overscaledZ-e.overscaledZ),i=r[r.length-1].overscaledZ,o=r[0].overscaledZ-i+1;if(o>1){this.currentStencilSource=void 0,this.nextStencilID+o>256&&this.clearStencil();const t={};for(let r=0;r=0;this.currentLayer--){const e=this.style._layers[r[this.currentLayer]],n=t._getLayerSourceCache(e);if(e.isSky())continue;const i=n?a[n.id]:void 0;this._renderTileClippingMasks(e,n,i),this.renderLayer(this,n,e,i)}if(this.style.fog&&this.transform.projection.supportsFog&&function(t,n){const r=t.context,i=r.gl,o=t.transform,a=new e.DepthMode(i.LEQUAL,e.DepthMode.ReadOnly,[0,1]),s=t.useProgram("globeAtmosphere",null,"globe"===o.projection.name?["PROJECTION_GLOBE_VIEW","FOG"]:["FOG"]),l=e.globeToMercatorTransition(o.zoom),u=n.properties.get("color").toArray01(),c=n.properties.get("high-color").toArray01(),h=n.properties.get("space-color").toArray01PremultipliedAlpha(),d=e.identity$1([]);e.rotateY$1(d,d,-e.degToRad(o._center.lng)),e.rotateX$1(d,d,e.degToRad(o._center.lat)),e.rotateZ$1(d,d,o.angle),e.rotateX$1(d,d,-o._pitch);const f=e.fromQuat(new Float32Array(16),d),p=e.mapValue(n.properties.get("star-intensity"),0,1,0,.25),m=5e-4,_=e.mapValue(n.properties.get("horizon-blend"),0,1,m,.25),g=e.globeUseCustomAntiAliasing(t,r,o)&&_===m?o.worldSize/(2*Math.PI*1.025)-1:o.globeRadius,y=t.frameCounter/1e3%1,v=e.length(o.globeCenterInViewSpace),x=Math.sqrt(Math.pow(v,2)-Math.pow(g,2)),b=Math.acos(x/v),w=((t,n,r,i,o,a,s,l,u,c,h,d,f,p)=>({u_frustum_tl:t,u_frustum_tr:n,u_frustum_br:r,u_frustum_bl:i,u_horizon:o,u_transition:a,u_fadeout_range:s,u_color:l,u_high_color:u,u_space_color:c,u_star_intensity:h,u_star_size:5*e.exported.devicePixelRatio,u_star_density:0,u_temporal_offset:d,u_horizon_angle:f,u_rotation_matrix:p}))(o.frustumCorners.TL,o.frustumCorners.TR,o.frustumCorners.BR,o.frustumCorners.BL,o.frustumCorners.horizon,l,_,u,c,h,p,y,b,f);t.prepareDrawProgram(r,s);const E=t.atmosphereBuffer;E&&s.draw(r,i.TRIANGLES,a,e.StencilMode.disabled,e.ColorMode.alphaBlended,e.CullFaceMode.backCW,w,"skybox",E.vertexBuffer,E.indexBuffer,E.segments)}(this,this.style.fog),this.renderPass="sky",(e.globeToMercatorTransition(this.transform.zoom)>0||"globe"!==this.transform.projection.name)&&this.transform.isHorizonVisible())for(this.currentLayer=0;this.currentLayer{const r=t._getLayerSourceCache(e);r&&!e.isHidden(this.transform.zoom)&&(!n||n.getSource().maxzoom0?t.pop():null}isPatternMissing(e){return null===e||void 0!==e&&!this.imageManager.getPattern(e.toString())}terrainRenderModeElevated(){return this.style&&!!this.style.getTerrain()&&!!this.terrain&&!this.terrain.renderingToTexture}currentGlobalDefines(){const e=this.terrain&&this.terrain.renderingToTexture,t=this.terrain&&0===this.terrain.exaggeration(),n=this.style&&this.style.fog,r=[];return this.terrainRenderModeElevated()&&r.push("TERRAIN"),"globe"===this.transform.projection.name&&r.push("GLOBE"),t&&r.push("ZERO_EXAGGERATION"),n&&!e&&0!==n.getOpacity(this.transform.pitch)&&r.push("FOG"),e&&r.push("RENDER_TO_TEXTURE"),this._showOverdrawInspector&&r.push("OVERDRAW_INSPECTOR"),r}useProgram(e,t,n){this.cache=this.cache||{};const r=n||[],i=this.currentGlobalDefines().concat(r),o=zn.cacheKey(hn[e],e,i,t);return this.cache[o]||(this.cache[o]=new zn(this.context,e,hn[e],t,sr[e],i)),this.cache[o]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.frontFace.setDefault(),this.context.cullFaceSide.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const e=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(e.FUNC_ADD)}initDebugOverlayCanvas(){null==this.debugOverlayCanvas&&(this.debugOverlayCanvas=e.window.document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new e.Texture(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this._terrain&&this._terrain.destroy(),this.globeSharedBuffers&&this.globeSharedBuffers.destroy(),this.emptyTexture.destroy(),this.debugOverlayTexture&&this.debugOverlayTexture.destroy(),this.atmosphereBuffer&&this.atmosphereBuffer.destroy()}prepareDrawTile(){this.terrain&&this.terrain.prepareDrawTile()}prepareDrawProgram(t,n,r){if(this.terrain&&this.terrain.renderingToTexture)return;const i=this.style.fog;if(i){const o=i.getOpacity(this.transform.pitch),a=((t,n,r,i,o,a,s,l,u,c,h)=>{const d=t.transform,f=n.properties.get("color").toArray01();f[3]=i;const p=t.frameCounter/1e3%1;return{u_fog_matrix:r?d.calculateFogTileMatrix(r):t.identityMat,u_fog_range:n.getFovAdjustedRange(d._fov),u_fog_color:f,u_fog_horizon_blend:n.properties.get("horizon-blend"),u_fog_temporal_offset:p,u_frustum_tl:o,u_frustum_tr:a,u_frustum_br:s,u_frustum_bl:l,u_globe_pos:u,u_globe_radius:c,u_viewport:h,u_globe_transition:e.globeToMercatorTransition(d.zoom),u_is_globe:+("globe"===d.projection.name)}})(this,i,r,o,this.transform.frustumCorners.TL,this.transform.frustumCorners.TR,this.transform.frustumCorners.BR,this.transform.frustumCorners.BL,this.transform.globeCenterInViewSpace,this.transform.globeRadius,[this.transform.width*e.exported.devicePixelRatio,this.transform.height*e.exported.devicePixelRatio]);n.setFogUniformValues(t,a)}}setTileLoadedFlag(e){this.tileLoaded=e}saveCanvasCopy(){this.frameCopies.push(this.canvasCopy()),this.tileLoaded=!1}canvasCopy(){const e=this.context.gl,t=e.createTexture();return e.bindTexture(e.TEXTURE_2D,t),e.copyTexImage2D(e.TEXTURE_2D,0,e.RGBA,0,0,e.drawingBufferWidth,e.drawingBufferHeight,0),t}getCanvasCopiesAndTimestamps(){return{canvasCopies:this.frameCopies,timeStamps:this.loadTimeStamps}}averageElevationNeedsEasing(){if(!this.transform._elevation)return!1;const e=this.style&&this.style.fog;return!!e&&0!==e.getOpacity(this.transform.pitch)}getBackgroundTiles(){const t=this._backgroundTiles,n=this._backgroundTiles={},r=this.transform.coveringTiles({tileSize:512});for(const i of r)n[i.key]=t[i.key]||new e.Tile(i,512,this.transform.tileZoom,this);return n}clearBackgroundTiles(){this._backgroundTiles={}}}class Br{constructor(e=0,t=0,n=0,r=0){if(isNaN(e)||e<0||isNaN(t)||t<0||isNaN(n)||n<0||isNaN(r)||r<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=e,this.bottom=t,this.left=n,this.right=r}interpolate(t,n,r){return null!=n.top&&null!=t.top&&(this.top=e.number(t.top,n.top,r)),null!=n.bottom&&null!=t.bottom&&(this.bottom=e.number(t.bottom,n.bottom,r)),null!=n.left&&null!=t.left&&(this.left=e.number(t.left,n.left,r)),null!=n.right&&null!=t.right&&(this.right=e.number(t.right,n.right,r)),this}getCenter(t,n){const r=e.clamp((this.left+t-this.right)/2,0,t),i=e.clamp((this.top+n-this.bottom)/2,0,n);return new e.pointGeometry(r,i)}equals(e){return this.top===e.top&&this.bottom===e.bottom&&this.left===e.left&&this.right===e.right}clone(){return new Br(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}function Fr(t,n){const r=e.getColumn(t,3);e.fromQuat(t,n),e.setColumn(t,3,r)}function jr(t,n){const r=e.identity$1([]);return e.rotateZ$1(r,r,-n),e.rotateX$1(r,r,-t),r}function Nr(t,n){const r=[t[0],t[1],0],i=[n[0],n[1],0];if(e.length(r)>=1e-15){const t=e.normalize([],r);e.scale$2(i,t,e.dot(i,t)),n[0]=i[0],n[1]=i[1]}const o=e.cross([],n,t);if(e.len(o)<1e-15)return null;const a=Math.atan2(-o[1],o[0]);return jr(Math.atan2(Math.sqrt(t[0]*t[0]+t[1]*t[1]),-t[2]),a)}class Ur{constructor(e,t){this.position=e,this.orientation=t}get position(){return this._position}set position(t){if(t){const n=t instanceof e.MercatorCoordinate?t:new e.MercatorCoordinate(t[0],t[1],t[2]);this._renderWorldCopies&&(n.x=e.wrap(n.x,0,1)),this._position=n}else this._position=null}lookAtPoint(t,n){if(this.orientation=null,!this.position)return;const r=this._elevation?this._elevation.getAtPointOrZero(e.MercatorCoordinate.fromLngLat(t)):0,i=this.position,o=e.MercatorCoordinate.fromLngLat(t,r),a=[o.x-i.x,o.y-i.y,o.z-i.z];n||(n=[0,0,1]),n[2]=Math.abs(n[2]),this.orientation=Nr(a,n)}setPitchBearing(t,n){this.orientation=jr(e.degToRad(t),e.degToRad(-n))}}class Vr{constructor(t,n){this._transform=e.identity([]),this.orientation=n,this.position=t}get mercatorPosition(){const t=this.position;return new e.MercatorCoordinate(t[0],t[1],t[2])}get position(){const t=e.getColumn(this._transform,3);return[t[0],t[1],t[2]]}set position(t){var n;t&&e.setColumn(this._transform,3,[(n=t)[0],n[1],n[2],1])}get orientation(){return this._orientation}set orientation(t){this._orientation=t||e.identity$1([]),t&&Fr(this._transform,this._orientation)}getPitchBearing(){const e=this.forward(),t=this.right();return{bearing:Math.atan2(-t[1],t[0]),pitch:Math.atan2(Math.sqrt(e[0]*e[0]+e[1]*e[1]),-e[2])}}setPitchBearing(e,t){this._orientation=jr(e,t),Fr(this._transform,this._orientation)}forward(){const t=e.getColumn(this._transform,2);return[-t[0],-t[1],-t[2]]}up(){const t=e.getColumn(this._transform,1);return[-t[0],-t[1],-t[2]]}right(){const t=e.getColumn(this._transform,0);return[t[0],t[1],t[2]]}getCameraToWorld(t,n){const r=new Float64Array(16);return e.invert(r,this.getWorldToCamera(t,n)),r}getWorldToCameraPosition(t,n,r){const i=this.position;e.scale$2(i,i,-t);const o=new Float64Array(16);return e.fromScaling(o,[r,r,r]),e.translate(o,o,i),o[10]*=n,o}getWorldToCamera(t,n){const r=new Float64Array(16),i=new Float64Array(4),o=this.position;return e.conjugate(i,this._orientation),e.scale$2(o,o,-t),e.fromQuat(r,i),e.translate(r,r,o),r[1]*=-1,r[5]*=-1,r[9]*=-1,r[13]*=-1,r[8]*=n,r[9]*=n,r[10]*=n,r[11]*=n,r}getCameraToClipPerspective(t,n,r,i){const o=new Float64Array(16);return e.perspective(o,t,n,r,i),o}getDistanceToElevation(t,n=!1){const r=0===t?0:e.mercatorZfromAltitude(t,n?e.latFromMercatorY(this.position[1]):this.position[1]),i=this.forward();return(r-this.position[2])/i[2]}clone(){return new Vr([...this.position],[...this.orientation])}}function Gr(t,n){const r=$r(t.projection,t.zoom,t.width,t.height),i=function(t,n,r,i,o){const a=new e.LngLat(r.lng-180*Zr,r.lat),s=new e.LngLat(r.lng+180*Zr,r.lat),l=t.project(a.lng,a.lat),u=t.project(s.lng,s.lat),c=-Math.atan2(u.y-l.y,u.x-l.x),h=e.MercatorCoordinate.fromLngLat(r);h.y=e.clamp(h.y,-.999975,.999975);const d=h.toLngLat(),f=t.project(d.lng,d.lat),p=e.MercatorCoordinate.fromLngLat(d);p.x+=Zr;const m=p.toLngLat(),_=t.project(m.lng,m.lat),g=Xr(_.x-f.x,_.y-f.y,c),y=e.MercatorCoordinate.fromLngLat(d);y.y+=Zr;const v=y.toLngLat(),x=t.project(v.lng,v.lat),b=Xr(x.x-f.x,x.y-f.y,c),w=Math.abs(g.x)/Math.abs(b.y),E=e.identity([]);e.rotateZ(E,E,-c*(1-(o?0:i)));const T=e.identity([]);return e.scale(T,T,[1,1-(1-w)*i,1]),T[4]=-b.x/b.y*i,e.rotateZ(T,T,c),e.multiply(T,E,T),T}(t.projection,0,t.center,r,n),o=qr(t);return e.scale(i,i,[o,o,1]),i}function qr(t){const n=t.projection,r=$r(t.projection,t.zoom,t.width,t.height),i=Wr(n,t.center),o=Wr(n,e.LngLat.convert(n.center));return Math.pow(2,i*r+(1-r)*o)}function $r(t,n,r,i,o=1/0){const a=t.range;if(!a)return 0;const s=Math.min(o,Math.max(r,i)),l=Math.log(s/1024)/Math.LN2;return e.smoothstep(a[0]+l,a[1]+l,n)}const Zr=1/4e4;function Wr(t,n){const r=e.clamp(n.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),i=new e.LngLat(n.lng-180*Zr,r),o=new e.LngLat(n.lng+180*Zr,r),a=t.project(i.lng,r),s=t.project(o.lng,r),l=e.MercatorCoordinate.fromLngLat(i),u=e.MercatorCoordinate.fromLngLat(o),c=s.x-a.x,h=s.y-a.y,d=u.x-l.x,f=u.y-l.y,p=Math.sqrt((d*d+f*f)/(c*c+h*h));return Math.log(p)/Math.LN2}function Xr(e,t,n){const r=Math.cos(n),i=Math.sin(n);return{x:e*r-t*i,y:e*i+t*r}}class Hr{constructor(t,n,r,i,o,a,s){this.tileSize=512,this._renderWorldCopies=void 0===o||o,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=null==r?0:r,this._maxPitch=null==i?60:i,this.setProjection(a),this.setMaxBounds(s),this.width=0,this.height=0,this._center=new e.LngLat(0,0),this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._nearZ=0,this._farZ=0,this._unmodified=!0,this._edgeInsets=new Br,this._projMatrixCache={},this._alignedProjMatrixCache={},this._fogTileMatrixCache={},this._distanceTileDataCache={},this._camera=new Vr,this._centerAltitude=0,this._averageElevation=0,this.cameraElevationReference="ground",this._pixelsPerMercatorPixel=1,this.globeRadius=0,this.globeCenterInViewSpace=[0,0,0],this._horizonShift=.1}clone(){const e=new Hr(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies,this.getProjection());return e._elevation=this._elevation,e._centerAltitude=this._centerAltitude,e._centerAltitudeValidForExaggeration=this._centerAltitudeValidForExaggeration,e.tileSize=this.tileSize,e.mercatorFromTransition=this.mercatorFromTransition,e.width=this.width,e.height=this.height,e.cameraElevationReference=this.cameraElevationReference,e._center=this._center,e._setZoom(this.zoom),e._seaLevelZoom=this._seaLevelZoom,e.angle=this.angle,e._fov=this._fov,e._pitch=this._pitch,e._nearZ=this._nearZ,e._farZ=this._farZ,e._averageElevation=this._averageElevation,e._unmodified=this._unmodified,e._edgeInsets=this._edgeInsets.clone(),e._camera=this._camera.clone(),e._calcMatrices(),e.freezeTileCoverage=this.freezeTileCoverage,e.frustumCorners=this.frustumCorners,e}get elevation(){return this._elevation}set elevation(e){this._elevation!==e&&(this._elevation=e,this._updateCameraOnTerrain(),this._calcMatrices())}updateElevation(e,t=!1){const n=this._elevation&&this._elevation.exaggeration()!==this._centerAltitudeValidForExaggeration;(null==this._seaLevelZoom||n)&&this._updateCameraOnTerrain(),(e||n)&&this._constrainCamera(t),this._calcMatrices()}getProjection(){return e.pick(this.projection,["name","center","parallels"])}setProjection(n){this.projectionOptions=n||{name:"mercator"};const r=this.projection?this.getProjection():void 0;this.projection=e.getProjection(this.projectionOptions);const i=!t(r,this.getProjection());return i&&this._calcMatrices(),this.mercatorFromTransition=!1,i}setMercatorFromTransition(){const t=this.projection.name;this.mercatorFromTransition=!0,this.projectionOptions={name:"mercator"},this.projection=e.getProjection({name:"mercator"});const n=t!==this.projection.name;return n&&this._calcMatrices(),n}get minZoom(){return this._minZoom}set minZoom(e){this._minZoom!==e&&(this._minZoom=e,this.zoom=Math.max(this.zoom,e))}get maxZoom(){return this._maxZoom}set maxZoom(e){this._maxZoom!==e&&(this._maxZoom=e,this.zoom=Math.min(this.zoom,e))}get minPitch(){return this._minPitch}set minPitch(e){this._minPitch!==e&&(this._minPitch=e,this.pitch=Math.max(this.pitch,e))}get maxPitch(){return this._maxPitch}set maxPitch(e){this._maxPitch!==e&&(this._maxPitch=e,this.pitch=Math.min(this.pitch,e))}get renderWorldCopies(){return this._renderWorldCopies&&!0===this.projection.supportsWorldCopies}set renderWorldCopies(e){void 0===e?e=!0:null===e&&(e=!1),this._renderWorldCopies=e}get worldSize(){return this.tileSize*this.scale}get cameraWorldSizeForFog(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get cameraWorldSize(){const e=Math.max(this._camera.getDistanceToElevation(this._averageElevation,!0),Number.EPSILON);return this._worldSizeFromZoom(this._zoomFromMercatorZ(e))}get pixelsPerMeter(){return this.projection.pixelsPerMeter(this.center.lat,this.worldSize)}get cameraPixelsPerMeter(){return e.mercatorZfromAltitude(this.center.lat,this.cameraWorldSizeForFog)}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new e.pointGeometry(this.width,this.height)}get bearing(){return e.wrap(this.rotation,-180,180)}set bearing(e){this.rotation=e}get rotation(){return-this.angle/Math.PI*180}set rotation(t){const n=-t*Math.PI/180;var r;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=(r=new e.ARRAY_TYPE(4),e.ARRAY_TYPE!=Float32Array&&(r[1]=0,r[2]=0),r[0]=1,r[3]=1,r),function(e,t,n){var r=t[0],i=t[1],o=t[2],a=t[3],s=Math.sin(n),l=Math.cos(n);e[0]=r*l+o*s,e[1]=i*l+a*s,e[2]=r*-s+o*l,e[3]=i*-s+a*l}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=e.clamp(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get aspect(){return this.width/this.height}get fovX(){return this._fov}get fovY(){const e=1/Math.tan(.5*this.fovX);return 2*Math.atan(1/this.aspect/e)}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=e.degToRad(t),this._calcMatrices())}get averageElevation(){return this._averageElevation}set averageElevation(e){this._averageElevation=e,this._calcFogMatrices(),this._distanceTileDataCache={}}get zoom(){return this._zoom}set zoom(e){const t=Math.min(Math.max(e,this.minZoom),this.maxZoom);this._zoom!==t&&(this._unmodified=!1,this._setZoom(t),this._updateSeaLevelZoom(),this._constrain(),this._calcMatrices())}_setZoom(e){this._zoom=e,this.scale=this.zoomScale(e),this.tileZoom=Math.floor(e),this.zoomFraction=e-this.tileZoom}_updateCameraOnTerrain(){if(!this._elevation||!this._elevation.isDataAvailableAtPoint(this.locationCoordinate(this.center)))return this._centerAltitude=0,this._seaLevelZoom=null,void(this._centerAltitudeValidForExaggeration=void 0);const e=this._elevation;this._centerAltitude=e.getAtPointOrZero(this.locationCoordinate(this.center)),this._centerAltitudeValidForExaggeration=e.exaggeration(),this._updateSeaLevelZoom()}_updateSeaLevelZoom(){void 0!==this._centerAltitudeValidForExaggeration&&(this._seaLevelZoom=this._zoomFromMercatorZ((this.pixelsPerMeter*this._centerAltitude+this.cameraToCenterDistance)/this.worldSize))}sampleAverageElevation(){if(!this._elevation)return 0;const t=this._elevation,n=[[.5,.2],[.3,.5],[.5,.5],[.7,.5],[.5,.8]],r=this.horizonLineFromTop();let i=0,o=0;for(let a=0;at.maxzoom&&(n=t.maxzoom);const a=this.locationCoordinate(this.center),s=this.center.lat,l=1<{const n=1/4e4,r=new e.MercatorCoordinate(t.x+n,t.y,t.z),i=new e.MercatorCoordinate(t.x,t.y+n,t.z),o=t.toLngLat(),a=r.toLngLat(),s=i.toLngLat(),l=this.locationCoordinate(o),u=this.locationCoordinate(a),c=this.locationCoordinate(s),h=Math.hypot(u.x-l.x,u.y-l.y),d=Math.hypot(c.x-l.x,c.y-l.y);return Math.sqrt(h*d)*b/n},E=t=>{const n=v,r=x;return{aabb:e.tileAABB(this,l,0,0,0,t,r,n,this.projection),zoom:0,x:0,y:0,minZ:r,maxZ:n,wrap:t,fullyVisible:!1}},T=[];let S=[];const k=n,C=t.reparseOverscaled?r:n,M=e=>e*e,A=M((m-this._centerAltitude)*p),I=e=>{if(!this._elevation||!e.tileID||!o)return;const t=this._elevation.getMinMaxForTile(e.tileID),n=e.aabb;t?(n.min[2]=t.min,n.max[2]=t.max,n.center[2]=(n.min[2]+n.max[2])/2):(e.shouldSplit=P(e),e.shouldSplit||(n.min[2]=n.max[2]=n.center[2]=this._centerAltitude))},P=t=>{if(t.zoom=.9)return!0}else if(i&&(a=M(t.aabb.distanceZ(_)*p)),this.projection.isReprojectedInTileSpace&&r<=5){const n=Math.pow(2,t.zoom),r=w(new e.MercatorCoordinate((t.x+.5)/n,(t.y+.5)/n));l=r>.85?1:r}const u=n*n+o*o+a;return u{if(t*M(.707)0;){const r=T.pop(),a=r.x,s=r.y;let h=r.fullyVisible;if(!h){const e=r.aabb.intersects(d);if(0===e)continue;h=2===e}if(r.zoom!==k&&P(r))for(let t=0;t<4;t++){const n=(a<<1)+t%2,u=(s<<1)+(t>>1),d={aabb:o?r.aabb.quadrant(t):e.tileAABB(this,l,r.zoom+1,n,u,r.wrap,r.minZ,r.maxZ,this.projection),zoom:r.zoom+1,x:n,y:u,wrap:r.wrap,fullyVisible:h,tileID:void 0,shouldSplit:void 0,minZ:r.minZ,maxZ:r.maxZ};i&&!c&&(d.tileID=new e.OverscaledTileID(r.zoom+1===k?C:r.zoom+1,r.wrap,r.zoom+1,n,u),I(d)),T.push(d)}else{const i=r.zoom===k?C:r.zoom;if(t.minzoom&&t.minzoom>i)continue;const o=u[0]-(.5+a+(r.wrap<{const o=[0,0,0,1],a=[e.EXTENT,e.EXTENT,0,1],s=this.calculateFogTileMatrix(i.tileID.toUnwrapped());e.transformMat4$1(o,o,s),e.transformMat4$1(a,a,s);const l=e.getAABBPointSquareDist(o,a);if(0===l)return!0;let u=!1;const c=this._elevation;if(c&&l>n&&0!==r){const n=this.calculateProjMatrix(i.tileID.toUnwrapped());let o;t.isTerrainDEM||(o=c.getMinMaxForTile(i.tileID)),o||(o={min:x,max:v});const a=e.furthestTileCorner(this.rotation),s=[a[0]*e.EXTENT,a[1]*e.EXTENT,o.max];e.transformMat4(s,s,n),u=(1-s[1])*this.height*.5e.distanceSq-t.distanceSq).map(e=>e.tileID)}resize(e,t){this.width=e,this.height=t,this.pixelsToGLUnits=[2/e,-2/t],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(e){return Math.pow(2,e)}scaleZoom(e){return Math.log(e)/Math.LN2}project(t){const n=e.clamp(t.lat,-e.MAX_MERCATOR_LATITUDE,e.MAX_MERCATOR_LATITUDE),r=this.projection.project(t.lng,n);return new e.pointGeometry(r.x*this.worldSize,r.y*this.worldSize)}unproject(e){return this.projection.unproject(e.x/this.worldSize,e.y/this.worldSize)}get point(){return this.project(this.center)}setLocationAtPoint(t,n){let r,i;const o=this.centerPoint;if("globe"===this.projection.name){const e=this.worldSize;r=(n.x-o.x)/e,i=(n.y-o.y)/e}else{const e=this.pointCoordinate(n),t=this.pointCoordinate(o);r=e.x-t.x,i=e.y-t.y}const a=this.locationCoordinate(t);this.setLocation(new e.MercatorCoordinate(a.x-r,a.y-i))}setLocation(e){this.center=this.coordinateLocation(e),this.projection.wrap&&(this.center=this.center.wrap())}locationPoint(e){return this.projection.locationPoint(this,e)}locationPoint3D(e){return this.projection.locationPoint(this,e,!0)}pointLocation(e){return this.coordinateLocation(this.pointCoordinate(e))}pointLocation3D(e){return this.coordinateLocation(this.pointCoordinate3D(e))}locationCoordinate(t,n){const r=n?e.mercatorZfromAltitude(n,t.lat):void 0,i=this.projection.project(t.lng,t.lat);return new e.MercatorCoordinate(i.x,i.y,r)}coordinateLocation(e){return this.projection.unproject(e.x,e.y)}pointRayIntersection(t,n){const r=null!=n?n:this._centerAltitude,i=[t.x,t.y,0,1],o=[t.x,t.y,1,1];e.transformMat4$1(i,i,this.pixelMatrixInverse),e.transformMat4$1(o,o,this.pixelMatrixInverse);const a=o[3];e.scale$1(i,i,1/i[3]),e.scale$1(o,o,1/a);const s=i[2],l=o[2];return{p0:i,p1:o,t:s===l?0:(r-s)/(l-s)}}screenPointToMercatorRay(t){const n=[t.x,t.y,0,1],r=[t.x,t.y,1,1];return e.transformMat4$1(n,n,this.pixelMatrixInverse),e.transformMat4$1(r,r,this.pixelMatrixInverse),e.scale$1(n,n,1/n[3]),e.scale$1(r,r,1/r[3]),n[2]=e.mercatorZfromAltitude(n[2],this._center.lat)*this.worldSize,r[2]=e.mercatorZfromAltitude(r[2],this._center.lat)*this.worldSize,e.scale$1(n,n,1/this.worldSize),e.scale$1(r,r,1/this.worldSize),new e.Ray([n[0],n[1],n[2]],e.normalize([],e.sub([],r,n)))}rayIntersectionCoordinate(t){const{p0:n,p1:r,t:i}=t,o=e.mercatorZfromAltitude(n[2],this._center.lat),a=e.mercatorZfromAltitude(r[2],this._center.lat);return new e.MercatorCoordinate(e.number(n[0],r[0],i)/this.worldSize,e.number(n[1],r[1],i)/this.worldSize,e.number(o,a,i))}pointCoordinate(e,t=this._centerAltitude){return this.projection.pointCoordinate(this,e.x,e.y,t)}pointCoordinate3D(t){if(!this.elevation)return this.pointCoordinate(t);let n=this.projection.pointCoordinate3D(this,t.x,t.y);if(n)return new e.MercatorCoordinate(n[0],n[1],n[2]);let r=0,i=this.horizonLineFromTop();if(t.y>i)return this.pointCoordinate(t);const o=.02*i,a=t.clone();for(let t=0;t<10&&i-r>o;t++){a.y=e.number(r,i,.66);const t=this.projection.pointCoordinate3D(this,a.x,a.y);t?(i=a.y,n=t):r=a.y}return n?new e.MercatorCoordinate(n[0],n[1],n[2]):this.pointCoordinate(t)}isPointAboveHorizon(e){return this.projection.isPointAboveHorizon(this,e)}_coordinatePoint(t,n){const r=n&&this.elevation?this.elevation.getAtPointOrZero(t,this._centerAltitude):this._centerAltitude,i=[t.x*this.worldSize,t.y*this.worldSize,r+t.toAltitude(),1];return e.transformMat4$1(i,i,this.pixelMatrix),i[3]>0?new e.pointGeometry(i[0]/i[3],i[1]/i[3]):new e.pointGeometry(Number.MAX_VALUE,Number.MAX_VALUE)}_getGlobeBounds(){const{top:t,left:n}=this._edgeInsets,r=this.height-this._edgeInsets.bottom,i=this.width-this._edgeInsets.right,o=this.pointCoordinate3D(new e.pointGeometry(n,t)),a=this.pointCoordinate3D(new e.pointGeometry(i,t)),s=this.pointCoordinate3D(new e.pointGeometry(i,r)),l=this.pointCoordinate3D(new e.pointGeometry(n,r));let u=Math.min(o.x,l.x),c=Math.max(a.x,s.x),h=Math.min(o.y,a.y),d=Math.max(l.y,s.y);const f=Math.pow(2,-this.zoom)/16,p=(t,n,r,i)=>{const o=(t+r)/2,a=(n+i)/2,s=new e.pointGeometry(o,a),l=this.pointCoordinate3D(s),m=Math.max(0,u-l.x,h-l.y,l.x-c,l.y-d);u=Math.min(u,l.x),c=Math.max(c,l.x),h=Math.min(h,l.y),d=Math.max(d,l.y),m>f&&(p(t,n,o,a),p(o,a,r,i))};p(n,t,i,t),p(i,t,i,r),p(i,r,n,r),p(n,r,n,t);const[m,_]=e.polesInViewport(this),g=m||_,y=m?90:e.latFromMercatorY(h),v=g?180:e.lngFromMercatorX(c),x=_?-90:e.latFromMercatorY(d),b=g?-180:e.lngFromMercatorX(u);return new e.LngLatBounds(new e.LngLat(b,x),new e.LngLat(v,y))}_getBounds(t,n){if("globe"===this.projection.name)return this._getGlobeBounds();const r=new e.pointGeometry(this._edgeInsets.left,this._edgeInsets.top),i=new e.pointGeometry(this.width-this._edgeInsets.right,this._edgeInsets.top),o=new e.pointGeometry(this.width-this._edgeInsets.right,this.height-this._edgeInsets.bottom),a=new e.pointGeometry(this._edgeInsets.left,this.height-this._edgeInsets.bottom);let s=this.pointCoordinate(r,t),l=this.pointCoordinate(i,t);const u=this.pointCoordinate(o,n),c=this.pointCoordinate(a,n),h=(e,t)=>(t.y-e.y)/(t.x-e.x);return s.y>1&&l.y>=0?s=new e.MercatorCoordinate((1-c.y)/h(c,s)+c.x,1):s.y<0&&l.y<=1&&(s=new e.MercatorCoordinate(-c.y/h(c,s)+c.x,0)),l.y>1&&s.y>=0?l=new e.MercatorCoordinate((1-u.y)/h(u,l)+u.x,1):l.y<0&&s.y<=1&&(l=new e.MercatorCoordinate(-u.y/h(u,l)+u.x,0)),(new e.LngLatBounds).extend(this.coordinateLocation(s)).extend(this.coordinateLocation(l)).extend(this.coordinateLocation(c)).extend(this.coordinateLocation(u))}_getBounds3D(){const e=this.elevation;if(!e.visibleDemTiles.length||e.isUsingMockSource())return this._getBounds(0,0);const t=e.visibleDemTiles.reduce((e,t)=>{if(t.dem){const n=t.dem.tree;e.min=Math.min(e.min,n.minimums[0]),e.max=Math.max(e.max,n.maximums[0])}return e},{min:Number.MAX_VALUE,max:0});return this._getBounds(t.min*e.exaggeration(),t.max*e.exaggeration())}getBounds(){return this._terrainEnabled()?this._getBounds3D():this._getBounds(0,0)}horizonLineFromTop(e=!0){const t=this.height/2/Math.tan(this._fov/2)/Math.tan(Math.max(this._pitch,.1))+this.centerOffset.y,n=this.height/2-t*(1-this._horizonShift);return e?Math.max(0,n):n}getMaxBounds(){return this.maxBounds}setMaxBounds(t){this.maxBounds=t,this.minLat=-e.MAX_MERCATOR_LATITUDE,this.maxLat=e.MAX_MERCATOR_LATITUDE,this.minLng=-180,this.maxLng=180,t&&(this.minLat=t.getSouth(),this.maxLat=t.getNorth(),this.minLng=t.getWest(),this.maxLng=t.getEast(),this.maxLngh&&(s=h-u),h-ct&&(a=t-l),t-e.5?v-1:v,x>.5?x-1:x,0]),this.alignedProjMatrix=b,a=e.create(),e.scale(a,a,[this.width/2,-this.height/2,1]),e.translate(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=e.create(),e.scale(a,a,[1,-1,1]),e.translate(a,a,[-1,-1,0]),e.scale(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a,this.pixelMatrix=e.multiply(new Float64Array(16),this.labelPlaneMatrix,this.projMatrix),this._calcFogMatrices(),this._distanceTileDataCache={},a=e.invert(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");if(this.pixelMatrixInverse=a,"globe"===this.projection.name||this.mercatorFromTransition){this.globeMatrix=e.calculateGlobeMatrix(this);const t=[this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]];this.globeCenterInViewSpace=e.transformMat4(t,t,i),this.globeRadius=this.worldSize/2/Math.PI-1}else this.globeMatrix=a;this._projMatrixCache={},this._alignedProjMatrixCache={},this._pixelsToTileUnitsCache={}}_calcFogMatrices(){this._fogTileMatrixCache={};const t=this.cameraWorldSizeForFog,n=this.cameraPixelsPerMeter,r=this._camera.position,i=1/this.height/this._pixelsPerMercatorPixel,o=[t,t,n];e.scale$2(o,o,i),e.scale$2(r,r,-1),e.multiply$2(r,r,o);const a=e.create();e.translate(a,a,r),e.scale(a,a,o),this.mercatorFogMatrix=a,this.worldToFogMatrix=this._camera.getWorldToCameraPosition(t,n,i)}_computeCameraPosition(e){const t=(e=e||this.pixelsPerMeter)/this.pixelsPerMeter,n=this._camera.forward(),r=this.point,i=this._mercatorZfromZoom(this._seaLevelZoom?this._seaLevelZoom:this._zoom)*t-e/this.worldSize*this._centerAltitude;return[r.x/this.worldSize-n[0]*i,r.y/this.worldSize-n[1]*i,e/this.worldSize*this._centerAltitude-n[2]*i]}_updateCameraState(){this.height&&(this._camera.setPitchBearing(this._pitch,this.angle),this._camera.position=this._computeCameraPosition())}_translateCameraConstrained(t){const n=this._maxCameraBoundsDistance()*Math.cos(this._pitch),r=this._camera.position[2],i=t[2];let o=1;this.projection.wrap&&(this.center=this.center.wrap()),i>0&&(o=Math.min((n-r)/i,1)),this._camera.position=e.scaleAndAdd([],this._camera.position,t,o),this._updateStateFromCamera()}_updateStateFromCamera(){const t=this._camera.position,n=this._camera.forward(),{pitch:r,bearing:i}=this._camera.getPitchBearing(),o=e.mercatorZfromAltitude(this._centerAltitude,this.center.lat)*this._pixelsPerMercatorPixel,a=this._mercatorZfromZoom(this._maxZoom)*Math.cos(e.degToRad(this._maxPitch)),s=Math.max((t[2]-o)/Math.cos(r),a),l=this._zoomFromMercatorZ(s);e.scaleAndAdd(t,t,n,s),this._pitch=e.clamp(r,e.degToRad(this.minPitch),e.degToRad(this.maxPitch)),this.angle=e.wrap(i,-Math.PI,Math.PI),this._setZoom(e.clamp(l,this._minZoom,this._maxZoom)),this._updateSeaLevelZoom(),this._center=this.coordinateLocation(new e.MercatorCoordinate(t[0],t[1],t[2])),this._unmodified=!1,this._constrain(),this._calcMatrices()}_worldSizeFromZoom(e){return Math.pow(2,e)*this.tileSize}_mercatorZfromZoom(e){return this.cameraToCenterDistance/this._worldSizeFromZoom(e)}_minimumHeightOverTerrain(){const e=Math.min((null!=this._seaLevelZoom?this._seaLevelZoom:this._zoom)+4,this._maxZoom);return this._mercatorZfromZoom(e)}_zoomFromMercatorZ(e){return this.scaleZoom(this.cameraToCenterDistance/(e*this.tileSize))}zoomFromMercatorZAdjusted(e){const t=t=>{const n=this.getCameraToCenterDistance(this.projection,t);return this.scaleZoom(n/(e*this.tileSize))};let n,r=t(this.zoom),i=Math.abs(r-t(r));for(;n!==i;)r=t(r),n=i,i=Math.abs(r-t(r));return r}_terrainEnabled(){return!(!this._elevation||!this.projection.supportsTerrain&&(e.warnOnce("Terrain is not yet supported with alternate projections. Use mercator or globe to enable terrain."),1))}anyCornerOffEdge(t,n){const r=Math.min(t.x,n.x),i=Math.max(t.x,n.x),o=Math.min(t.y,n.y),a=Math.max(t.y,n.y);if(ou||n.y>1)return!0}return!1}isHorizonVisible(){return this.pitch+e.radToDeg(this.fovAboveCenter)>88||this.anyCornerOffEdge(new e.pointGeometry(0,0),new e.pointGeometry(this.width,this.height))}zoomDeltaToMovement(t,n){const r=e.length(e.sub([],this._camera.position,t)),i=this._zoomFromMercatorZ(r)+n;return r-this._mercatorZfromZoom(i)}getCameraPoint(){if("globe"===this.projection.name){const t=function([t,n,r],i){const o=[t,n,r,1];e.transformMat4$1(o,o,i);const a=o[3]=Math.max(o[3],1e-6);return o[0]/=a,o[1]/=a,o[2]/=a,o}([this.globeMatrix[12],this.globeMatrix[13],this.globeMatrix[14]],this.pixelMatrix);return new e.pointGeometry(t[0],t[1])}{const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new e.pointGeometry(0,t))}}getCameraToCenterDistance(e,t=this.zoom){const n=$r(e,t,this.width,this.height,1024),r=e.pixelSpaceConversion(this.center.lat,this.worldSize,n);return.5/Math.tan(.5*this._fov)*this.height*r}getWorldToCameraMatrix(){const t=this._camera.getWorldToCamera(this.worldSize,"meters"===this.projection.zAxisUnit?this.pixelsPerMeter:1);return"globe"===this.projection.name&&e.multiply(t,t,this.globeMatrix),t}}function Yr(e,t){let n=!1,r=null;const i=()=>{r=null,n&&(e(),r=setTimeout(i,t),n=!1)};return()=>(n=!0,r||i(),r)}class Kr{constructor(t){this._hashName=t&&encodeURIComponent(t),e.bindAll(["_getCurrentHash","_onHashChange","_updateHash"],this),this._updateHash=Yr(this._updateHashUnthrottled.bind(this),300)}addTo(t){return this._map=t,e.window.addEventListener("hashchange",this._onHashChange,!1),t.on("moveend",this._updateHash),this}remove(){return this._map?(this._map.off("moveend",this._updateHash),e.window.removeEventListener("hashchange",this._onHashChange,!1),clearTimeout(this._updateHash()),this._map=void 0,this):this}getHashString(){const t=this._map;if(!t)return"";const n=Jr(t);if(this._hashName){const t=this._hashName;let r=!1;const i=e.window.location.hash.slice(1).split("&").map(e=>{const i=e.split("=")[0];return i===t?(r=!0,`${i}=${n}`):e}).filter(e=>e);return r||i.push(`${t}=${n}`),"#"+i.join("&")}return"#"+n}_getCurrentHash(){const t=e.window.location.hash.replace("#","");if(this._hashName){let e;return t.split("&").map(e=>e.split("=")).forEach(t=>{t[0]===this._hashName&&(e=t)}),(e&&e[1]||"").split("/")}return t.split("/")}_onHashChange(){const e=this._map;if(!e)return!1;const t=this._getCurrentHash();if(t.length>=3&&!t.some(e=>isNaN(e))){const n=e.dragRotate.isEnabled()&&e.touchZoomRotate.isEnabled()?+(t[3]||0):e.getBearing();return e.jumpTo({center:[+t[2],+t[1]],zoom:+t[0],bearing:n,pitch:+(t[4]||0)}),!0}return!1}_updateHashUnthrottled(){const t=e.window.location.href.replace(/(#.+)?$/,this.getHashString());e.window.history.replaceState(e.window.history.state,null,t)}}function Jr(e,t){const n=e.getCenter(),r=Math.round(100*e.getZoom())/100,i=Math.ceil((r*Math.LN2+Math.log(512/360/.5))/Math.LN10),o=Math.pow(10,i),a=Math.round(n.lng*o)/o,s=Math.round(n.lat*o)/o,l=e.getBearing(),u=e.getPitch();let c=t?`/${a}/${s}/${r}`:`${r}/${s}/${a}`;return(l||u)&&(c+="/"+Math.round(10*l)/10),u&&(c+="/"+Math.round(u)),c}const Qr={linearity:.3,easing:e.bezier(0,0,.3,1)},ei=e.extend({deceleration:2500,maxSpeed:1400},Qr),ti=e.extend({deceleration:20,maxSpeed:1400},Qr),ni=e.extend({deceleration:1e3,maxSpeed:360},Qr),ri=e.extend({deceleration:1e3,maxSpeed:90},Qr);class ii{constructor(e){this._map=e,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:e.exported.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=e.exported.now();for(;t.length>0&&n-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const n={zoom:0,bearing:0,pitch:0,pan:new e.pointGeometry(0,0),pinchAround:void 0,around:void 0};for(const{settings:e}of this._inertiaBuffer)n.zoom+=e.zoomDelta||0,n.bearing+=e.bearingDelta||0,n.pitch+=e.pitchDelta||0,e.panDelta&&n.pan._add(e.panDelta),e.around&&(n.around=e.around),e.pinchAround&&(n.pinchAround=e.pinchAround);const r=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,i={};if(n.pan.mag()){const o=ai(n.pan.mag(),r,e.extend({},ei,t||{}));i.offset=n.pan.mult(o.amount/n.pan.mag()),i.center=this._map.transform.center,oi(i,o)}if(n.zoom){const e=ai(n.zoom,r,ti);i.zoom=this._map.transform.zoom+e.amount,oi(i,e)}if(n.bearing){const t=ai(n.bearing,r,ni);i.bearing=this._map.transform.bearing+e.clamp(t.amount,-179,179),oi(i,t)}if(n.pitch){const e=ai(n.pitch,r,ri);i.pitch=this._map.transform.pitch+e.amount,oi(i,e)}if(i.zoom||i.bearing){const e=void 0===n.pinchAround?n.around:n.pinchAround;i.around=e?this._map.unproject(e):this._map.getCenter()}return this.clear(),i.noMoveStart=!0,i}}function oi(e,t){(!e.duration||e.durationn.unproject(e)),s=o.reduce((e,t,n,r)=>e.add(t.div(r.length)),new e.pointGeometry(0,0));super(t,{points:o,point:s,lngLats:a,lngLat:n.unproject(s),originalEvent:r}),this._defaultPrevented=!1}}class ui extends e.Event{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(e,t,n){super(e,{originalEvent:n}),this._defaultPrevented=!1}}class ci{constructor(e,t){this._map=e,this._clickTolerance=t.clickTolerance}reset(){this._mousedownPos=void 0}wheel(e){return this._firePreventable(new ui(e.type,this._map,e))}mousedown(e,t){return this._mousedownPos=t,this._firePreventable(new si(e.type,this._map,e))}mouseup(e){this._map.fire(new si(e.type,this._map,e))}preclick(t){const n=e.extend({},t);n.type="preclick",this._map.fire(new si(n.type,this._map,n))}click(e,t){this._mousedownPos&&this._mousedownPos.dist(t)>=this._clickTolerance||(this.preclick(e),this._map.fire(new si(e.type,this._map,e)))}dblclick(e){return this._firePreventable(new si(e.type,this._map,e))}mouseover(e){this._map.fire(new si(e.type,this._map,e))}mouseout(e){this._map.fire(new si(e.type,this._map,e))}touchstart(e){return this._firePreventable(new li(e.type,this._map,e))}touchmove(e){this._map.fire(new li(e.type,this._map,e))}touchend(e){this._map.fire(new li(e.type,this._map,e))}touchcancel(e){this._map.fire(new li(e.type,this._map,e))}_firePreventable(e){if(this._map.fire(e),e.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class hi{constructor(e){this._map=e}reset(){this._delayContextMenu=!1,this._contextMenuEvent=void 0}mousemove(e){this._map.fire(new si(e.type,this._map,e))}mousedown(){this._delayContextMenu=!0}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new si("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(e){this._delayContextMenu?this._contextMenuEvent=e:this._map.fire(new si(e.type,this._map,e)),this._map.listens("contextmenu")&&e.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class di{constructor(e,t){this._map=e,this._el=e.getCanvasContainer(),this._container=e.getContainer(),this._clickTolerance=t.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(e,t){this.isEnabled()&&e.shiftKey&&0===e.button&&(c(),this._startPos=this._lastPos=t,this._active=!0)}mousemoveWindow(e,t){if(!this._active)return;const n=t,r=this._startPos,i=this._lastPos;if(!r||!i||i.equals(n)||!this._box&&n.dist(r){this._box&&(this._box.style.transform=`translate(${a}px,${l}px)`,this._box.style.width=s-a+"px",this._box.style.height=u-l+"px")})}mouseupWindow(t,n){if(!this._active)return;const r=this._startPos,i=n;if(r&&0===t.button){if(this.reset(),f(),r.x!==i.x||r.y!==i.y)return this._map.fire(new e.Event("boxzoomend",{originalEvent:t})),{cameraAnimation:e=>e.fitScreenCoordinates(r,i,this._map.getBearing(),{linear:!1})};this._fireEvent("boxzoomcancel",t)}}keydown(e){this._active&&27===e.keyCode&&(this.reset(),this._fireEvent("boxzoomcancel",e))}blur(){this.reset()}reset(){this._active=!1,this._container.classList.remove("mapboxgl-crosshair"),this._box&&(this._box.remove(),this._box=null),h(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new e.Event(t,{originalEvent:n}))}}function fi(e,t){const n={};for(let r=0;rthis.numTouches)&&(this.aborted=!0),this.aborted||(0===this.startTime&&(this.startTime=t.timeStamp),r.length===this.numTouches&&(this.centroid=function(t){const n=new e.pointGeometry(0,0);for(const e of t)n._add(e);return n.div(t.length)}(n),this.touches=fi(r,n)))}touchmove(e,t,n){if(this.aborted||!this.centroid)return;const r=fi(n,t);for(const e in this.touches){const t=this.touches[e],n=r[e];(!n||n.dist(t)>30)&&(this.aborted=!0)}}touchend(e,t,n){if((!this.centroid||e.timeStamp-this.startTime>500)&&(this.aborted=!0),0===n.length){const e=!this.aborted&&this.centroid;if(this.reset(),e)return e}}}class mi{constructor(e){this.singleTap=new pi(e),this.numTaps=e.numTaps,this.reset()}reset(){this.lastTime=1/0,this.lastTap=void 0,this.count=0,this.singleTap.reset()}touchstart(e,t,n){this.singleTap.touchstart(e,t,n)}touchmove(e,t,n){this.singleTap.touchmove(e,t,n)}touchend(e,t,n){const r=this.singleTap.touchend(e,t,n);if(r){const t=e.timeStamp-this.lastTime<500,n=!this.lastTap||this.lastTap.dist(r)<30;if(t&&n||this.reset(),this.count++,this.lastTime=e.timeStamp,this.lastTap=r,this.count===this.numTaps)return this.reset(),r}}}class _i{constructor(){this._zoomIn=new mi({numTouches:1,numTaps:2}),this._zoomOut=new mi({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(e,t,n){this._zoomIn.touchstart(e,t,n),this._zoomOut.touchstart(e,t,n)}touchmove(e,t,n){this._zoomIn.touchmove(e,t,n),this._zoomOut.touchmove(e,t,n)}touchend(e,t,n){const r=this._zoomIn.touchend(e,t,n),i=this._zoomOut.touchend(e,t,n);return r?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()+1,around:t.unproject(r)},{originalEvent:e})}):i?(this._active=!0,e.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:t=>t.easeTo({duration:300,zoom:t.getZoom()-1,around:t.unproject(i)},{originalEvent:e})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}const gi={0:1,2:2};class yi{constructor(e){this.reset(),this._clickTolerance=e.clickTolerance||1}blur(){this.reset()}reset(){this._active=!1,this._moved=!1,this._lastPoint=void 0,this._eventButton=void 0}_correctButton(e,t){return!1}_move(e,t){return{}}mousedown(e,t){if(this._lastPoint)return;const n=_(e);this._correctButton(e,n)&&(this._lastPoint=t,this._eventButton=n)}mousemoveWindow(e,t){const n=this._lastPoint;if(n)if(e.preventDefault(),null!=this._eventButton&&function(e,t){const n=gi[t];return void 0===e.buttons||(e.buttons&n)!==n}(e,this._eventButton))this.reset();else if(this._moved||!(t.dist(n)0&&(this._active=!0);const i=fi(r,n),o=new e.pointGeometry(0,0),a=new e.pointGeometry(0,0);let s=0;for(const e in i){const t=i[e],n=this._touches[e];n&&(o._add(t),a._add(t.sub(n)),s++,i[e]=t)}if(this._touches=i,s{this._alertContainer.classList.remove("mapboxgl-touch-pan-blocker-show"),this._alertContainer.setAttribute("role","null")},500)}}class Ei{constructor(){this.reset()}reset(){this._active=!1,this._firstTwoTouches=void 0}_start(e){}_move(e,t,n){return{}}touchstart(e,t,n){this._firstTwoTouches||n.length<2||(this._firstTwoTouches=[n[0].identifier,n[1].identifier],this._start([t[0],t[1]]))}touchmove(e,t,n){const r=this._firstTwoTouches;if(!r)return;e.preventDefault();const[i,o]=r,a=Ti(n,t,i),s=Ti(n,t,o);if(!a||!s)return;const l=this._aroundCenter?null:a.add(s).div(2);return this._move([a,s],l,e)}touchend(e,t,n){if(!this._firstTwoTouches)return;const[r,i]=this._firstTwoTouches,o=Ti(n,t,r),a=Ti(n,t,i);o&&a||(this._active&&f(),this.reset())}touchcancel(){this.reset()}enable(e){this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}function Ti(e,t,n){for(let r=0;rMath.abs(e.x)}class Ii extends Ei{constructor(e){super(),this._map=e}reset(){super.reset(),this._valid=void 0,this._firstMove=void 0,this._lastPoints=void 0}_start(e){this._lastPoints=e,Ai(e[0].sub(e[1]))&&(this._valid=!1)}_move(t,n,r){const i=this._lastPoints;if(!i)return;const o=t[0].sub(i[0]),a=t[1].sub(i[1]);return this._map._cooperativeGestures&&!e.isFullscreen()&&r.touches.length<3||(this._valid=this.gestureBeginsVertically(o,a,r.timeStamp),!this._valid)?void 0:(this._lastPoints=t,this._active=!0,{pitchDelta:(o.y+a.y)/2*-.5})}gestureBeginsVertically(e,t,n){if(void 0!==this._valid)return this._valid;const r=e.mag()>=2,i=t.mag()>=2;if(!r&&!i)return;if(!r||!i)return null==this._firstMove&&(this._firstMove=n),n-this._firstMove<100&&void 0;const o=e.y>0==t.y>0;return Ai(e)&&Ai(t)&&o}}const Pi={panStep:100,bearingStep:15,pitchStep:10};class zi{constructor(){const e=Pi;this._panStep=e.panStep,this._bearingStep=e.bearingStep,this._pitchStep=e.pitchStep,this._rotationDisabled=!1}blur(){this.reset()}reset(){this._active=!1}keydown(e){if(e.altKey||e.ctrlKey||e.metaKey)return;let t=0,n=0,r=0,i=0,o=0;switch(e.keyCode){case 61:case 107:case 171:case 187:t=1;break;case 189:case 109:case 173:t=-1;break;case 37:e.shiftKey?n=-1:(e.preventDefault(),i=-1);break;case 39:e.shiftKey?n=1:(e.preventDefault(),i=1);break;case 38:e.shiftKey?r=1:(e.preventDefault(),o=-1);break;case 40:e.shiftKey?r=-1:(e.preventDefault(),o=1);break;default:return}return this._rotationDisabled&&(n=0,r=0),{cameraAnimation:a=>{const s=a.getZoom();a.easeTo({duration:300,easeId:"keyboardHandler",easing:Oi,zoom:t?Math.round(s)+t*(e.shiftKey?2:1):s,bearing:a.getBearing()+n*this._bearingStep,pitch:a.getPitch()+r*this._pitchStep,offset:[-i*this._panStep,-o*this._panStep],center:a.getCenter()},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}disableRotation(){this._rotationDisabled=!0}enableRotation(){this._rotationDisabled=!1}}function Oi(e){return e*(2-e)}const Di=4.000244140625;class Li{constructor(t,n){this._map=t,this._el=t.getCanvasContainer(),this._handler=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222,e.bindAll(["_onTimeout","_addScrollZoomBlocker","_showBlockerAlert"],this)}setZoomRate(e){this._defaultZoomRate=e}setWheelZoomRate(e){this._wheelZoomRate=e}isEnabled(){return!!this._enabled}isActive(){return this._active||void 0!==this._finishTimeout}isZooming(){return!!this._zooming}enable(e){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!e&&"center"===e.around,this._map._cooperativeGestures&&this._addScrollZoomBlocker())}disable(){this.isEnabled()&&(this._enabled=!1,this._map._cooperativeGestures&&(clearTimeout(this._alertTimer),this._alertContainer.remove()))}wheel(t){if(!this.isEnabled())return;if(this._map._cooperativeGestures){if(!(t.ctrlKey||t.metaKey||this.isZooming()||e.isFullscreen()))return void this._showBlockerAlert();"hidden"!==this._alertContainer.style.visibility&&(this._alertContainer.style.visibility="hidden",clearTimeout(this._alertTimer))}let n=t.deltaMode===e.window.WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const r=e.exported.now(),i=r-(this._lastWheelEventTime||0);this._lastWheelEventTime=r,0!==n&&n%Di==0?this._type="wheel":0!==n&&Math.abs(n)<4?this._type="trackpad":i>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(i*n)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,n+=this._lastValue)),t.shiftKey&&n&&(n/=4),this._type&&(this._lastWheelEvent=t,this._delta-=n,this._active||this._start(t)),t.preventDefault()}_onTimeout(e){this._type="wheel",this._delta-=this._lastValue,this._active||this._start(e)}_start(e){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const t=p(this._el,e);this._aroundPoint=this._aroundCenter?this._map.transform.centerPoint:t,this._aroundCoord=this._map.transform.pointCoordinate3D(this._aroundPoint),this._targetZoom=void 0,this._frameId||(this._frameId=!0,this._handler._triggerRenderFrame())}renderFrame(){if(!this._frameId)return;if(this._frameId=null,!this.isActive())return;const t=this._map.transform;"wheel"===this._type&&t.projection.wrap&&(t._center.lng>=180||t._center.lng<=-180)&&(this._prevEase=null,this._easing=null,this._lastWheelEvent=null,this._lastWheelEventTime=0);const n=()=>t._terrainEnabled()&&this._aroundCoord?t.computeZoomRelativeTo(this._aroundCoord):t.zoom;if(0!==this._delta){const e="wheel"===this._type&&Math.abs(this._delta)>Di?this._wheelZoomRate:this._defaultZoomRate;let r=2/(1+Math.exp(-Math.abs(this._delta*e)));this._delta<0&&0!==r&&(r=1/r);const i=n(),o=Math.pow(2,i),a="number"==typeof this._targetZoom?t.zoomScale(this._targetZoom):o;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(a*r))),"wheel"===this._type&&(this._startZoom=i,this._easing=this._smoothOutEasing(200)),this._delta=0}const r="number"==typeof this._targetZoom?this._targetZoom:n(),i=this._startZoom,o=this._easing;let a,s=!1;if("wheel"===this._type&&i&&o){const t=Math.min((e.exported.now()-this._lastWheelEventTime)/200,1),n=o(t);a=e.number(i,r,n),t<1?this._frameId||(this._frameId=!0):s=!0}else a=r,s=!0;return this._active=!0,s&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._handler._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!s,zoomDelta:a-n(),around:this._aroundPoint,aroundCoord:this._aroundCoord,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=e.ease;if(this._prevEase){const t=this._prevEase,r=(e.exported.now()-t.start)/t.duration,i=t.easing(r+.01)-t.easing(r),o=.27/Math.sqrt(i*i+1e-4)*.01,a=Math.sqrt(.0729-o*o);n=e.bezier(o,a,.25,1)}return this._prevEase={start:e.exported.now(),duration:t,easing:n},n}blur(){this.reset()}reset(){this._active=!1}_addScrollZoomBlocker(){this._map&&!this._alertContainer&&(this._alertContainer=o("div","mapboxgl-scroll-zoom-blocker",this._map._container),this._alertContainer.textContent=/(Mac|iPad)/i.test(e.window.navigator.userAgent)?this._map._getUIString("ScrollZoomBlocker.CmdMessage"):this._map._getUIString("ScrollZoomBlocker.CtrlMessage"),this._alertContainer.style.fontSize=Math.max(10,Math.min(24,Math.floor(.05*this._el.clientWidth)))+"px")}_showBlockerAlert(){this._alertContainer.style.visibility="visible",this._alertContainer.classList.add("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","alert"),clearTimeout(this._alertTimer),this._alertTimer=setTimeout(()=>{this._alertContainer.classList.remove("mapboxgl-scroll-zoom-blocker-show"),this._alertContainer.setAttribute("role","null")},200)}}class Ri{constructor(e,t){this._clickZoom=e,this._tapZoom=t}enable(){this._clickZoom.enable(),this._tapZoom.enable()}disable(){this._clickZoom.disable(),this._tapZoom.disable()}isEnabled(){return this._clickZoom.isEnabled()&&this._tapZoom.isEnabled()}isActive(){return this._clickZoom.isActive()||this._tapZoom.isActive()}}class Bi{constructor(){this.reset()}reset(){this._active=!1}blur(){this.reset()}dblclick(e,t){return e.preventDefault(),{cameraAnimation:n=>{n.easeTo({duration:300,zoom:n.getZoom()+(e.shiftKey?-1:1),around:n.unproject(t)},{originalEvent:e})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Fi{constructor(){this._tap=new mi({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,this._swipePoint=void 0,this._swipeTouch=0,this._tapTime=0,this._tap.reset()}touchstart(e,t,n){this._swipePoint||(this._tapTime&&e.timeStamp-this._tapTime>500&&this.reset(),this._tapTime?n.length>0&&(this._swipePoint=t[0],this._swipeTouch=n[0].identifier):this._tap.touchstart(e,t,n))}touchmove(e,t,n){if(this._tapTime){if(this._swipePoint){if(n[0].identifier!==this._swipeTouch)return;const r=t[0],i=r.y-this._swipePoint.y;return this._swipePoint=r,e.preventDefault(),this._active=!0,{zoomDelta:i/128}}}else this._tap.touchmove(e,t,n)}touchend(e,t,n){this._tapTime?this._swipePoint&&0===n.length&&this.reset():this._tap.touchend(e,t,n)&&(this._tapTime=e.timeStamp)}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ji{constructor(e,t,n){this._el=e,this._mousePan=t,this._touchPan=n}enable(e){this._inertiaOptions=e||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("mapboxgl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("mapboxgl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Ni{constructor(e,t,n){this._pitchWithRotate=e.pitchWithRotate,this._mouseRotate=t,this._mousePitch=n}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Ui{constructor(e,t,n,r){this._el=e,this._touchZoom=t,this._touchRotate=n,this._tapDragZoom=r,this._rotationDisabled=!1,this._enabled=!0}enable(e){this._touchZoom.enable(e),this._rotationDisabled||this._touchRotate.enable(e),this._tapDragZoom.enable(),this._el.classList.add("mapboxgl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("mapboxgl-touch-zoom-rotate")}isEnabled(){return this._touchZoom.isEnabled()&&(this._rotationDisabled||this._touchRotate.isEnabled())&&this._tapDragZoom.isEnabled()}isActive(){return this._touchZoom.isActive()||this._touchRotate.isActive()||this._tapDragZoom.isActive()}disableRotation(){this._rotationDisabled=!0,this._touchRotate.disable()}enableRotation(){this._rotationDisabled=!1,this._touchZoom.isEnabled()&&this._touchRotate.enable()}}const Vi=e=>e.zoom||e.drag||e.pitch||e.rotate;class Gi extends e.Event{}class qi{constructor(){this.constants=[1,1,.01],this.radius=0}setup(t,n){const r=e.sub([],n,t);this.radius=e.length(r[2]<0?e.div([],r,this.constants):[r[0],r[1],0])}projectRay(t){e.div(t,t,this.constants),e.normalize(t,t),e.mul$1(t,t,this.constants);const n=e.scale$2([],t,this.radius);if(n[2]>0){const t=e.scale$2([],[0,0,1],e.dot(n,[0,0,1])),r=e.scale$2([],e.normalize([],[n[0],n[1],0]),this.radius),i=e.add([],n,e.scale$2([],e.sub([],e.add([],r,t),n),2));n[0]=i[0],n[1]=i[1]}return n}}function $i(e){return e.panDelta&&e.panDelta.mag()||e.zoomDelta||e.bearingDelta||e.pitchDelta}class Zi{constructor(t,n){this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new ii(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._trackingEllipsoid=new qi,this._dragOrigin=null,this._eventsInProgress={},this._addDefaultHandlers(n),e.bindAll(["handleEvent","handleWindowEvent"],this);const r=this._el;this._listeners=[[r,"touchstart",{passive:!0}],[r,"touchmove",{passive:!1}],[r,"touchend",void 0],[r,"touchcancel",void 0],[r,"mousedown",void 0],[r,"mousemove",void 0],[r,"mouseup",void 0],[e.window.document,"mousemove",{capture:!0}],[e.window.document,"mouseup",void 0],[r,"mouseover",void 0],[r,"mouseout",void 0],[r,"dblclick",void 0],[r,"click",void 0],[r,"keydown",{capture:!1}],[r,"keyup",void 0],[r,"wheel",{passive:!1}],[r,"contextmenu",void 0],[e.window,"blur",void 0]];for(const[t,n,r]of this._listeners)t.addEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}destroy(){for(const[t,n,r]of this._listeners)t.removeEventListener(n,t===e.window.document?this.handleWindowEvent:this.handleEvent,r)}_addDefaultHandlers(e){const t=this._map,n=t.getCanvasContainer();this._add("mapEvent",new ci(t,e));const r=t.boxZoom=new di(t,e);this._add("boxZoom",r);const i=new _i,o=new Bi;t.doubleClickZoom=new Ri(o,i),this._add("tapZoom",i),this._add("clickZoom",o);const a=new Fi;this._add("tapDragZoom",a);const s=t.touchPitch=new Ii(t);this._add("touchPitch",s);const l=new xi(e),u=new bi(e);t.dragRotate=new Ni(e,l,u),this._add("mouseRotate",l,["mousePitch"]),this._add("mousePitch",u,["mouseRotate"]);const c=new vi(e),h=new wi(t,e);t.dragPan=new ji(n,c,h),this._add("mousePan",c),this._add("touchPan",h,["touchZoom","touchRotate"]);const d=new Mi,f=new ki;t.touchZoomRotate=new Ui(n,f,d,a),this._add("touchRotate",d,["touchPan","touchZoom"]),this._add("touchZoom",f,["touchPan","touchRotate"]),this._add("blockableMapEvent",new hi(t));const p=t.scrollZoom=new Li(t,this);this._add("scrollZoom",p,["mousePan"]);const m=t.keyboard=new zi;this._add("keyboard",m);for(const n of["boxZoom","doubleClickZoom","tapDragZoom","touchPitch","dragRotate","dragPan","touchZoomRotate","scrollZoom","keyboard"])e.interactive&&e[n]&&t[n].enable(e[n])}_add(e,t,n){this._handlers.push({handlerName:e,handler:t,allowed:n}),this._handlersById[e]=t}stop(e){if(!this._updatingCamera){for(const{handler:e}of this._handlers)e.reset();this._inertia.clear(),this._fireEvents({},{},e),this._changes=[]}}isActive(){for(const{handler:e}of this._handlers)if(e.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Vi(this._eventsInProgress)||this.isZooming()}_isDragging(){return!!this._eventsInProgress.drag}_blockedByActive(e,t,n){for(const r in e)if(r!==n&&(!t||t.indexOf(r)<0))return!0;return!1}handleWindowEvent(e){this.handleEvent(e,e.type+"Window")}_getMapTouches(e){const t=[];for(const n of e)this._el.contains(n.target)&&t.push(n);return t}handleEvent(e,t){this._updatingCamera=!0;const n="renderFrame"===e.type,r=n?void 0:e,i={needsRenderFrame:!1},o={},a={},s=e.touches?this._getMapTouches(e.touches):void 0,l=s?m(this._el,s):n?void 0:p(this._el,e);for(const{handlerName:n,handler:u,allowed:c}of this._handlers){if(!u.isEnabled())continue;let h;this._blockedByActive(a,c,n)?u.reset():u[t||e.type]&&(h=u[t||e.type](e,l,s),this.mergeHandlerResult(i,o,h,n,r),h&&h.needsRenderFrame&&this._triggerRenderFrame()),(h||u.isActive())&&(a[n]=u)}const u={};for(const e in this._previousActiveHandlers)a[e]||(u[e]=r);this._previousActiveHandlers=a,(Object.keys(u).length||$i(i))&&(this._changes.push([i,o,u]),this._triggerRenderFrame()),(Object.keys(a).length||$i(i))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:c}=i;c&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],c(this._map))}mergeHandlerResult(t,n,r,i,o){if(!r)return;e.extend(t,r);const a={handlerName:i,originalEvent:r.originalEvent||o};void 0!==r.zoomDelta&&(n.zoom=a),void 0!==r.panDelta&&(n.drag=a),void 0!==r.pitchDelta&&(n.pitch=a),void 0!==r.bearingDelta&&(n.rotate=a)}_applyChanges(){const t={},n={},r={};for(const[i,o,a]of this._changes)i.panDelta&&(t.panDelta=(t.panDelta||new e.pointGeometry(0,0))._add(i.panDelta)),i.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+i.zoomDelta),i.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+i.bearingDelta),i.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+i.pitchDelta),void 0!==i.around&&(t.around=i.around),void 0!==i.aroundCoord&&(t.aroundCoord=i.aroundCoord),void 0!==i.pinchAround&&(t.pinchAround=i.pinchAround),i.noInertia&&(t.noInertia=i.noInertia),e.extend(n,o),e.extend(r,a);this._updateMapTransform(t,n,r),this._changes=[]}_updateMapTransform(t,n,r){const i=this._map,o=i.transform,a=e=>[e.x,e.y,e.z];if((e=>{const t=this._eventsInProgress.drag;return t&&!this._handlersById[t.handlerName].isActive()})()&&!$i(t)){const e=o.zoom;o.cameraElevationReference="sea",o.recenterOnTerrain(),o.cameraElevationReference="ground",e!==o.zoom&&this._map._update(!0)}if(o._isCameraConstrained&&i._stop(!0),!$i(t))return void this._fireEvents(n,r,!0);let{panDelta:s,zoomDelta:l,bearingDelta:u,pitchDelta:c,around:h,aroundCoord:d,pinchAround:f}=t;o._isCameraConstrained&&(l>0&&(l=0),o._isCameraConstrained=!1),void 0!==f&&(h=f),(e=>n.drag&&!this._eventsInProgress.drag)()&&h&&(this._dragOrigin=a(o.pointCoordinate3D(h)),this._trackingEllipsoid.setup(o._camera.position,this._dragOrigin)),o.cameraElevationReference="sea",i._stop(!0),h=h||i.transform.centerPoint,u&&(o.bearing+=u),c&&(o.pitch+=c),o._updateCameraState();const p=[0,0,0];if(s)if("mercator"===o.projection.name){const e=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h).dir),t=this._trackingEllipsoid.projectRay(o.screenPointToMercatorRay(h.sub(s)).dir);p[0]=t[0]-e[0],p[1]=t[1]-e[1]}else{const t=o.pointCoordinate(h);if("globe"===o.projection.name){s=s.rotate(-o.angle);const n=o._pixelsPerMercatorPixel/o.worldSize;p[0]=-s.x*e.mercatorScale(e.latFromMercatorY(t.y))*n,p[1]=-s.y*e.mercatorScale(o.center.lat)*n}else{const e=o.pointCoordinate(h.sub(s));t&&e&&(p[0]=e.x-t.x,p[1]=e.y-t.y)}}const m=o.zoom,_=[0,0,0];if(l){const t=a(d||o.pointCoordinate3D(h)),n={dir:e.normalize([],e.sub([],t,o._camera.position))};if(n.dir[2]<0){const r=o.zoomDeltaToMovement(t,l);e.scale$2(_,n.dir,r)}}const g=e.add(p,p,_);o._translateCameraConstrained(g),l&&Math.abs(o.zoom-m)>1e-4&&o.recenterOnTerrain(),o.cameraElevationReference="ground",this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,r,!0)}_fireEvents(t,n,r){const i=Vi(this._eventsInProgress),o=Vi(t),a={};for(const e in t){const{originalEvent:n}=t[e];this._eventsInProgress[e]||(a[e+"start"]=n),this._eventsInProgress[e]=t[e]}!i&&o&&this._fireEvent("movestart",o.originalEvent);for(const e in a)this._fireEvent(e,a[e]);o&&this._fireEvent("move",o.originalEvent);for(const e in t){const{originalEvent:n}=t[e];this._fireEvent(e,n)}const s={};let l;for(const e in this._eventsInProgress){const{handlerName:t,originalEvent:r}=this._eventsInProgress[e];this._handlersById[t].isActive()||(delete this._eventsInProgress[e],l=n[t]||r,s[e+"end"]=l)}for(const e in s)this._fireEvent(e,s[e]);const u=Vi(this._eventsInProgress);if(r&&(i||o)&&!u){this._updatingCamera=!0;const t=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),n=e=>0!==e&&-this._bearingSnap{this._frameId=void 0,this.handleEvent(new Gi("renderFrame",{timeStamp:e})),this._applyChanges()})}_triggerRenderFrame(){void 0===this._frameId&&(this._frameId=this._requestFrame())}}const Wi="map.setFreeCameraOptions(...) and map.getFreeCameraOptions() are not yet supported for non-mercator projections.";class Xi extends e.Evented{constructor(t,n){super(),this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,e.bindAll(["_renderFrameCallback"],this)}getCenter(){return new e.LngLat(this.transform.center.lng,this.transform.center.lat)}setCenter(e,t){return this.jumpTo({center:e},t)}panBy(t,n,r){return t=e.pointGeometry.convert(t).mult(-1),this.panTo(this.transform.center,e.extend({offset:t},n),r)}panTo(t,n,r){return this.easeTo(e.extend({center:t},n),r)}getZoom(){return this.transform.zoom}setZoom(e,t){return this.jumpTo({zoom:e},t),this}zoomTo(t,n,r){return this.easeTo(e.extend({zoom:t},n),r)}zoomIn(e,t){return this.zoomTo(this.getZoom()+1,e,t),this}zoomOut(e,t){return this.zoomTo(this.getZoom()-1,e,t),this}getBearing(){return this.transform.bearing}setBearing(e,t){return this.jumpTo({bearing:e},t),this}getPadding(){return this.transform.padding}setPadding(e,t){return this.jumpTo({padding:e},t),this}rotateTo(t,n,r){return this.easeTo(e.extend({bearing:t},n),r)}resetNorth(t,n){return this.rotateTo(0,e.extend({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(e.extend({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(e,t){return Math.abs(this.getBearing())e.aspect?n/(2*Math.tan(.5*e.fovX)*e.aspect):r/(2*Math.tan(.5*e.fovY)*e.aspect)}_cameraForBoundsOnGlobe(t,n,r,i,o,a){const s=t.clone(),l=this._extendCameraOptions(a);s.bearing=i,s.pitch=o;const u=e.LngLat.convert(n),c=e.LngLat.convert(r),h=.5*(u.lat+c.lat),d=.5*(u.lng+c.lng),f=e.latLngToECEF(h,d),p=e.normalize([],f),m=e.normalize([],e.cross([],p,[0,1,0])),_=e.cross([],m,p),g=[m[0],m[1],m[2],0,_[0],_[1],_[2],0,p[0],p[1],p[2],0,0,0,0,1],y=[f,e.latLngToECEF(u.lat,u.lng),e.latLngToECEF(c.lat,u.lng),e.latLngToECEF(c.lat,c.lng),e.latLngToECEF(u.lat,c.lng),e.latLngToECEF(h,u.lng),e.latLngToECEF(h,c.lng),e.latLngToECEF(u.lat,d),e.latLngToECEF(c.lat,d)];let v=e.Aabb.fromPoints(y.map(t=>[e.dot(m,t),e.dot(_,t),e.dot(p,t)]));const x=e.transformMat4([],v.center,g);0===e.squaredLength(x)&&e.set(x,0,0,1),e.normalize(x,x),e.scale$2(x,x,e.GLOBE_RADIUS),s.center=e.ecefToLatLng(x);const b=s.getWorldToCameraMatrix(),w=e.invert(new Float64Array(16),b);v=e.Aabb.applyTransform(v,e.multiply([],b,g)),e.transformMat4(x,x,b);const E=.5*(v.max[2]-v.min[2]),T=this._minimumAABBFrustumDistance(s,v),S=e.scale$2([],[0,0,1],E),k=e.add(S,x,S),C=T+(0===s.pitch?0:e.distance(x,k)),M=s.globeCenterInViewSpace,A=e.sub([],x,[M[0],M[1],M[2]]);e.normalize(A,A),e.scale$2(A,A,C);const I=e.add([],x,A);e.transformMat4(I,I,w);const P=e.earthRadius/e.GLOBE_RADIUS,z=e.length(I),O=e.mercatorZfromAltitude(z*P-e.earthRadius,0),D=Math.min(s.zoomFromMercatorZAdjusted(O),l.maxZoom);return D>.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"mercator"}),s.zoom=D,this._cameraForBounds(s,n,r,i,o,a)):{center:s.center,zoom:D,bearing:i,pitch:o}}queryTerrainElevation(t,n){const r=this.transform.elevation;return r?(n=e.extend({},{exaggerated:!0},n),r.getAtPoint(e.MercatorCoordinate.fromLngLat(t),null,n.exaggerated)):null}_cameraForBounds(t,n,r,i,o,a){if("globe"===t.projection.name)return this._cameraForBoundsOnGlobe(t,n,r,i,o,a);const s=t.clone(),l=this._extendCameraOptions(a),u=s.padding;s.bearing=i,s.pitch=o;const c=e.LngLat.convert(n),h=e.LngLat.convert(r),d=new e.LngLat(c.lng,h.lat),f=new e.LngLat(h.lng,c.lat),p=s.project(c),m=s.project(h),_=this.queryTerrainElevation(c),g=this.queryTerrainElevation(h),y=this.queryTerrainElevation(d),v=this.queryTerrainElevation(f),x=[[p.x,p.y,Math.min(_||0,g||0,y||0,v||0)],[m.x,m.y,Math.max(_||0,g||0,y||0,v||0)]];let b=e.Aabb.fromPoints(x);const w=s.getWorldToCameraMatrix(),E=e.invert(new Float64Array(16),w);b=e.Aabb.applyTransform(b,w);const T=e.sub([],b.max,b.min),S=u.left||0,k=u.right||0,C=u.bottom||0,M=u.top||0,{left:A,right:I,top:P,bottom:z}=l.padding,O=.5*(S+k),D=.5*(M+C),L=Math.min(s.scaleZoom(s.scale*Math.min((s.width-(S+k+A+I))/T[0],(s.height-(C+M+z+P))/T[1])),l.maxZoom),R=s.scale/s.zoomScale(L);b=new e.Aabb([b.min[0]-(A+O)*R,b.min[1]-(z+D)*R,b.min[2]],[b.max[0]+(I+O)*R,b.max[1]+(P+D)*R,b.max[2]]);const B=.5*T[2],F=this._minimumAABBFrustumDistance(s,b),j=[0,0,1,0];e.transformMat4$1(j,j,w),e.normalize$2(j,j);const N=e.scale$2([],j,F+B),U=e.add([],b.center,N),V=("number"==typeof l.offset.x&&"number"==typeof l.offset.y?new e.pointGeometry(l.offset.x,l.offset.y):e.pointGeometry.convert(l.offset)).rotate(-e.degToRad(i));b.center[0]-=V.x*R,b.center[1]+=V.y*R,e.transformMat4(b.center,b.center,E),e.transformMat4(U,U,E);const G=[b.center[0],b.center[1],U[2]*s.pixelsPerMeter];e.scale$2(G,G,1/s.worldSize);const q=e.lngFromMercatorX(G[0]),$=e.latFromMercatorY(G[1]),Z=Math.min(s._zoomFromMercatorZ(G[2]),l.maxZoom),W=new e.LngLat(q,$);return s.mercatorFromTransition&&Z<.5*(e.GLOBE_ZOOM_THRESHOLD_MIN+e.GLOBE_ZOOM_THRESHOLD_MAX)?(s.setProjection({name:"globe"}),s.zoom=Z,this._cameraForBounds(s,n,r,i,o,a)):{center:W,zoom:Z,bearing:i,pitch:o}}fitBounds(e,t,n){const r=this.cameraForBounds(e,t);return this._fitInternal(r,t,n)}fitScreenCoordinates(t,n,r,i,o){const a=e.pointGeometry.convert(t),s=e.pointGeometry.convert(n),l=new e.pointGeometry(Math.min(a.x,s.x),Math.min(a.y,s.y)),u=new e.pointGeometry(Math.max(a.x,s.x),Math.max(a.y,s.y));if("mercator"===this.transform.projection.name&&this.transform.anyCornerOffEdge(a,s))return this;const c=this.transform.pointLocation3D(l),h=this.transform.pointLocation3D(u),d=this.transform.pointLocation3D(new e.pointGeometry(l.x,u.y)),f=this.transform.pointLocation3D(new e.pointGeometry(u.x,l.y)),p=[Math.min(c.lng,h.lng,d.lng,f.lng),Math.min(c.lat,h.lat,d.lat,f.lat)],m=[Math.max(c.lng,h.lng,d.lng,f.lng),Math.max(c.lat,h.lat,d.lat,f.lat)],_=i&&i.pitch?i.pitch:this.getPitch(),g=this._cameraForBounds(this.transform,p,m,r,_,i);return this._fitInternal(g,i,o)}_fitInternal(t,n,r){return t?(delete(n=e.extend(t,n)).padding,n.linear?this.easeTo(n,r):this.flyTo(n,r)):this}jumpTo(t,n){this.stop();const r=t.preloadOnly?this.transform.clone():this.transform;let i=!1,o=!1,a=!1;return"zoom"in t&&r.zoom!==+t.zoom&&(i=!0,r.zoom=+t.zoom),void 0!==t.center&&(r.center=e.LngLat.convert(t.center)),"bearing"in t&&r.bearing!==+t.bearing&&(o=!0,r.bearing=+t.bearing),"pitch"in t&&r.pitch!==+t.pitch&&(a=!0,r.pitch=+t.pitch),null==t.padding||r.isPaddingEqual(t.padding)||(r.padding=t.padding),t.preloadOnly?(this._preloadTiles(r),this):(this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),i&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),o&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),a&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)))}getFreeCameraOptions(){return this.transform.projection.supportsFreeCamera||e.warnOnce(Wi),this.transform.getFreeCameraOptions()}setFreeCameraOptions(t,n){const r=this.transform;if(!r.projection.supportsFreeCamera)return e.warnOnce(Wi),this;this.stop();const i=r.zoom,o=r.pitch,a=r.bearing;r.setFreeCameraOptions(t);const s=i!==r.zoom,l=o!==r.pitch,u=a!==r.bearing;return this.fire(new e.Event("movestart",n)).fire(new e.Event("move",n)),s&&this.fire(new e.Event("zoomstart",n)).fire(new e.Event("zoom",n)).fire(new e.Event("zoomend",n)),u&&this.fire(new e.Event("rotatestart",n)).fire(new e.Event("rotate",n)).fire(new e.Event("rotateend",n)),l&&this.fire(new e.Event("pitchstart",n)).fire(new e.Event("pitch",n)).fire(new e.Event("pitchend",n)),this.fire(new e.Event("moveend",n)),this}easeTo(t,n){this._stop(!1,t.easeId),(!1===(t=e.extend({offset:[0,0],duration:500,easing:e.ease},t)).animate||!t.essential&&e.exported.prefersReducedMotion)&&(t.duration=0);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?+t.zoom:i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=e.pointGeometry.convert(t.offset);let f,p,m;if("globe"===r.projection.name){const n=e.MercatorCoordinate.fromLngLat(r.center),i=d.rotate(-r.angle);n.x+=i.x/r.worldSize,n.y+=i.y/r.worldSize;const o=n.toLngLat(),a=e.LngLat.convert(t.center||o);this._normalizeCenter(a),f=r.centerPoint.add(i),p=new e.pointGeometry(n.x,n.y).mult(r.worldSize),m=new e.pointGeometry(e.mercatorXfromLng(a.lng),e.mercatorYfromLat(a.lat)).mult(r.worldSize).sub(p)}else{f=r.centerPoint.add(d);const n=r.pointLocation(f),i=e.LngLat.convert(t.center||n);this._normalizeCenter(i),p=r.project(n),m=r.project(i).sub(p)}const _=r.zoomScale(l-i);let g,y;t.around&&(g=e.LngLat.convert(t.around),y=r.locationPoint(g));const v=this._zooming||l!==i,x=this._rotating||o!==u,b=this._pitching||c!==a,w=!r.isPaddingEqual(h),E=r=>E=>{if(v&&(r.zoom=e.number(i,l,E)),x&&(r.bearing=e.number(o,u,E)),b&&(r.pitch=e.number(a,c,E)),w&&(r.interpolatePadding(s,h,E),f=r.centerPoint.add(d)),g)r.setLocationAtPoint(g,y);else{const e=r.zoomScale(r.zoom-i),t=l>i?Math.min(2,_):Math.max(.5,_),n=Math.pow(t,1-E),o=r.unproject(p.add(m.mult(E*n)).mult(e));r.setLocationAtPoint(r.renderWorldCopies?o.wrap():o,f)}return t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(E,t.duration,r);return this._preloadTiles(e),this}const T={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=v,this._rotating=x,this._pitching=b,this._padding=w,this._easeId=t.easeId,this._prepareEase(n,t.noMoveStart,T),this._ease(E(r),e=>{r.recenterOnTerrain(),this._afterEase(n,e)},t),this}_prepareEase(t,n,r={}){this._moving=!0,this.transform.cameraElevationReference="sea",n||r.moving||this.fire(new e.Event("movestart",t)),this._zooming&&!r.zooming&&this.fire(new e.Event("zoomstart",t)),this._rotating&&!r.rotating&&this.fire(new e.Event("rotatestart",t)),this._pitching&&!r.pitching&&this.fire(new e.Event("pitchstart",t))}_fireMoveEvents(t){this.fire(new e.Event("move",t)),this._zooming&&this.fire(new e.Event("zoom",t)),this._rotating&&this.fire(new e.Event("rotate",t)),this._pitching&&this.fire(new e.Event("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;this._easeId=void 0,this.transform.cameraElevationReference="ground";const r=this._zooming,i=this._rotating,o=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,r&&this.fire(new e.Event("zoomend",t)),i&&this.fire(new e.Event("rotateend",t)),o&&this.fire(new e.Event("pitchend",t)),this.fire(new e.Event("moveend",t))}flyTo(t,n){if(!t.essential&&e.exported.prefersReducedMotion){const r=e.pick(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(r,n)}this.stop(),t=e.extend({offset:[0,0],speed:1.2,curve:1.42,easing:e.ease},t);const r=this.transform,i=this.getZoom(),o=this.getBearing(),a=this.getPitch(),s=this.getPadding(),l="zoom"in t?e.clamp(+t.zoom,r.minZoom,r.maxZoom):i,u="bearing"in t?this._normalizeBearing(t.bearing,o):o,c="pitch"in t?+t.pitch:a,h="padding"in t?t.padding:r.padding,d=r.zoomScale(l-i),f=e.pointGeometry.convert(t.offset);let p=r.centerPoint.add(f);const m=r.pointLocation(p),_=e.LngLat.convert(t.center||m);this._normalizeCenter(_);const g=r.project(m),y=r.project(_).sub(g);let v=t.curve;const x=Math.max(r.width,r.height),b=x/d,w=y.mag();if("minZoom"in t){const n=e.clamp(Math.min(t.minZoom,i,l),r.minZoom,r.maxZoom),o=x/r.zoomScale(n-i);v=Math.sqrt(o/w*2)}const E=v*v;function T(e){const t=(b*b-x*x+(e?-1:1)*E*E*w*w)/(2*(e?b:x)*E*w);return Math.log(Math.sqrt(t*t+1)-t)}function S(e){return(Math.exp(e)-Math.exp(-e))/2}function k(e){return(Math.exp(e)+Math.exp(-e))/2}const C=T(0);let M=function(e){return k(C)/k(C+v*e)},A=function(e){return x*((k(C)*(S(t=C+v*e)/k(t))-S(C))/E)/w;var t},I=(T(1)-C)/v;if(Math.abs(w)<1e-6||!isFinite(I)){if(Math.abs(x-b)<1e-6)return this.easeTo(t,n);const e=bt.maxDuration&&(t.duration=0);const P=o!==u,z=c!==a,O=!r.isPaddingEqual(h),D=r=>d=>{const m=d*I,v=1/M(m);r.zoom=1===d?l:i+r.scaleZoom(v),P&&(r.bearing=e.number(o,u,d)),z&&(r.pitch=e.number(a,c,d)),O&&(r.interpolatePadding(s,h,d),p=r.centerPoint.add(f));const x=1===d?_:r.unproject(g.add(y.mult(A(m))).mult(v));return r.setLocationAtPoint(r.renderWorldCopies?x.wrap():x,p),r._updateCameraOnTerrain(),t.preloadOnly||this._fireMoveEvents(n),r};if(t.preloadOnly){const e=this._emulate(D,t.duration,r);return this._preloadTiles(e),this}return this._zooming=!0,this._rotating=P,this._pitching=z,this._padding=O,this._prepareEase(n,!1),this._ease(D(r),()=>this._afterEase(n),t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(e,t){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),this._easeFrameId=void 0,this._onEaseFrame=void 0),this._onEaseEnd){const e=this._onEaseEnd;this._onEaseEnd=void 0,e.call(this,t)}if(!e){const e=this.handlers;e&&e.stop(!1)}return this}_ease(t,n,r){!1===r.animate||0===r.duration?(t(1),n()):(this._easeStart=e.exported.now(),this._easeOptions=r,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_renderFrameCallback(){const t=Math.min((e.exported.now()-this._easeStart)/this._easeOptions.duration,1),n=this._onEaseFrame;n&&n(this._easeOptions.easing(t)),t<1?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()}_normalizeBearing(t,n){t=e.wrap(t,-180,180);const r=Math.abs(t-n);return Math.abs(t-360-n)180?-360:n<-180?360:0}_emulate(e,t,n){const r=Math.ceil(15*t/1e3),i=[],o=e(n.clone());for(let e=0;e<=r;e++){const t=o(e/r);i.push(t.clone())}return i}}class Hi{constructor(t={}){this.options=t,e.bindAll(["_toggleAttribution","_updateEditLink","_updateData","_updateCompact"],this)}getDefaultPosition(){return"bottom-right"}onAdd(e){const t=this.options&&this.options.compact;return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-attrib"),this._compactButton=o("button","mapboxgl-ctrl-attrib-button",this._container),o("span","mapboxgl-ctrl-icon",this._compactButton).setAttribute("aria-hidden","true"),this._compactButton.type="button",this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=o("div","mapboxgl-ctrl-attrib-inner",this._container),this._innerContainer.setAttribute("role","list"),t&&this._container.classList.add("mapboxgl-compact"),this._updateAttributions(),this._updateEditLink(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("moveend",this._updateEditLink),void 0===t&&(this._map.on("resize",this._updateCompact),this._updateCompact()),this._container}onRemove(){this._container.remove(),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("moveend",this._updateEditLink),this._map.off("resize",this._updateCompact),this._map=void 0,this._attribHTML=void 0}_setElementTitle(e,t){const n=this._map._getUIString("AttributionControl."+t);e.setAttribute("aria-label",n),e.removeAttribute("title"),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}_toggleAttribution(){this._container.classList.contains("mapboxgl-compact-show")?(this._container.classList.remove("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","false")):(this._container.classList.add("mapboxgl-compact-show"),this._compactButton.setAttribute("aria-expanded","true"))}_updateEditLink(){let t=this._editLink;t||(t=this._editLink=this._container.querySelector(".mapbox-improve-map"));const n=[{key:"owner",value:this.styleOwner},{key:"id",value:this.styleId},{key:"access_token",value:this._map._requestManager._customAccessToken||e.config.ACCESS_TOKEN}];if(t){const r=n.reduce((e,t,r)=>(t.value&&(e+=`${t.key}=${t.value}${re.length-t.length),e=e.filter((t,n)=>{for(let r=n+1;r=0)return!1;return!0}),this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?e=[...this.options.customAttribution,...e]:e.unshift(this.options.customAttribution));const n=e.join(" | ");n!==this._attribHTML&&(this._attribHTML=n,e.length?(this._innerContainer.innerHTML=n,this._container.classList.remove("mapboxgl-attrib-empty")):this._container.classList.add("mapboxgl-attrib-empty"),this._editLink=null)}_updateCompact(){this._map.getCanvasContainer().offsetWidth<=640?this._container.classList.add("mapboxgl-compact"):this._container.classList.remove("mapboxgl-compact","mapboxgl-compact-show")}}class Yi{constructor(){e.bindAll(["_updateLogo","_updateCompact"],this)}onAdd(e){this._map=e,this._container=o("div","mapboxgl-ctrl");const t=o("a","mapboxgl-ctrl-logo");return t.target="_blank",t.rel="noopener nofollow",t.href="https://www.mapbox.com/",t.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),t.setAttribute("rel","noopener nofollow"),this._container.appendChild(t),this._container.style.display="none",this._map.on("sourcedata",this._updateLogo),this._updateLogo(),this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){this._container.remove(),this._map.off("sourcedata",this._updateLogo),this._map.off("resize",this._updateCompact)}getDefaultPosition(){return"bottom-left"}_updateLogo(e){e&&"metadata"!==e.sourceDataType||(this._container.style.display=this._logoRequired()?"block":"none")}_logoRequired(){if(!this._map.style)return!0;const e=this._map.style._sourceCaches;if(0===Object.entries(e).length)return!0;for(const t in e){const n=e[t].getSource();if(n.hasOwnProperty("mapbox_logo")&&!n.mapbox_logo)return!1}return!0}_updateCompact(){const e=this._container.children;if(e.length){const t=e[0];this._map.getCanvasContainer().offsetWidth<250?t.classList.add("mapboxgl-compact"):t.classList.remove("mapboxgl-compact")}}}class Ki{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(e){const t=++this._id;return this._queue.push({callback:e,id:t,cancelled:!1}),t}remove(e){const t=this._currentlyRunning,n=t?this._queue.concat(t):this._queue;for(const t of n)if(t.id===e)return void(t.cancelled=!0)}run(e=0){const t=this._currentlyRunning=this._queue;this._queue=[];for(const n of t)if(!n.cancelled&&(n.callback(e),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}function Ji(t,n,r){if(t=new e.LngLat(t.lng,t.lat),n){const i=new e.LngLat(t.lng-360,t.lat),o=new e.LngLat(t.lng+360,t.lat),a=360*Math.ceil(Math.abs(t.lng-r.center.lng)/360),s=r.locationPoint(t).distSqr(n),l=n.x<0||n.y<0||n.x>r.width||n.y>r.height;r.locationPoint(i).distSqr(n)180;){const e=r.locationPoint(t);if(e.x>=0&&e.y>=0&&e.x<=r.width&&e.y<=r.height)break;t.lng>r.center.lng?t.lng-=360:t.lng+=360}return t}const Qi={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};class eo extends e.Evented{constructor(t,n){if(super(),(t instanceof e.window.HTMLElement||n)&&(t=e.extend({element:t},n)),e.bindAll(["_update","_onMove","_onUp","_addDragHandler","_onMapClick","_onKeyPress","_clearFadeTimer"],this),this._anchor=t&&t.anchor||"center",this._color=t&&t.color||"#3FB1CE",this._scale=t&&t.scale||1,this._draggable=t&&t.draggable||!1,this._clickTolerance=t&&t.clickTolerance||0,this._isDragging=!1,this._state="inactive",this._rotation=t&&t.rotation||0,this._rotationAlignment=t&&t.rotationAlignment||"auto",this._pitchAlignment=t&&t.pitchAlignment&&t.pitchAlignment||"auto",this._updateMoving=()=>this._update(!0),this._occludedOpacity=t&&t.occludedOpacity||.2,t&&t.element)this._element=t.element,this._offset=e.pointGeometry.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=o("div");const n=41,r=27,i=a("svg",{display:"block",height:n*this._scale+"px",width:r*this._scale+"px",viewBox:`0 0 ${r} ${n}`},this._element),s=a("radialGradient",{id:"shadowGradient"},a("defs",{},i));a("stop",{offset:"10%","stop-opacity":.4},s),a("stop",{offset:"100%","stop-opacity":.05},s),a("ellipse",{cx:13.5,cy:34.8,rx:10.5,ry:5.25,fill:"url(#shadowGradient)"},i),a("path",{fill:this._color,d:"M27,13.5C27,19.07 20.25,27 14.75,34.5C14.02,35.5 12.98,35.5 12.25,34.5C6.75,27 0,19.22 0,13.5C0,6.04 6.04,0 13.5,0C20.96,0 27,6.04 27,13.5Z"},i),a("path",{opacity:.25,d:"M13.5,0C6.04,0 0,6.04 0,13.5C0,19.22 6.75,27 12.25,34.5C13,35.52 14.02,35.5 14.75,34.5C20.25,27 27,19.07 27,13.5C27,6.04 20.96,0 13.5,0ZM13.5,1C20.42,1 26,6.58 26,13.5C26,15.9 24.5,19.18 22.22,22.74C19.95,26.3 16.71,30.14 13.94,33.91C13.74,34.18 13.61,34.32 13.5,34.44C13.39,34.32 13.26,34.18 13.06,33.91C10.28,30.13 7.41,26.31 5.02,22.77C2.62,19.23 1,15.95 1,13.5C1,6.58 6.58,1 13.5,1Z"},i),a("circle",{fill:"white",cx:13.5,cy:13.5,r:5.5},i),this._offset=e.pointGeometry.convert(t&&t.offset||[0,-14])}this._element.hasAttribute("aria-label")||this._element.setAttribute("aria-label","Map marker"),this._element.classList.add("mapboxgl-marker"),this._element.addEventListener("dragstart",e=>{e.preventDefault()}),this._element.addEventListener("mousedown",e=>{e.preventDefault()});const r=this._element.classList;for(const e in Qi)r.remove("mapboxgl-marker-anchor-"+e);r.add("mapboxgl-marker-anchor-"+this._anchor),this._popup=null}addTo(e){return e===this._map||(this.remove(),this._map=e,e.getCanvasContainer().appendChild(this._element),e.on("move",this._updateMoving),e.on("moveend",this._update),e.on("remove",this._clearFadeTimer),e._addMarker(this),this.setDraggable(this._draggable),this._update(),e.on("click",this._onMapClick)),this}remove(){const e=this._map;return e&&(e.off("click",this._onMapClick),e.off("move",this._updateMoving),e.off("moveend",this._update),e.off("mousedown",this._addDragHandler),e.off("touchstart",this._addDragHandler),e.off("mouseup",this._onUp),e.off("touchend",this._onUp),e.off("mousemove",this._onMove),e.off("touchmove",this._onMove),e.off("remove",this._clearFadeTimer),e._removeMarker(this),this._map=void 0),this._clearFadeTimer(),this._element.remove(),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=e.LngLat.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(!0),this}getElement(){return this._element}setPopup(e){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeAttribute("role"),this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),e){if(!("offset"in e.options)){const t=38.1,n=13.5,r=Math.sqrt(Math.pow(n,2)/2);e.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-t],"bottom-left":[r,-1*(t-n+r)],"bottom-right":[-r,-1*(t-n+r)],left:[n,-1*(t-n)],right:[-n,-1*(t-n)]}:this._offset}this._popup=e,e._marker=this,this._lngLat&&this._popup.setLngLat(this._lngLat),this._element.setAttribute("role","button"),this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress),this._element.setAttribute("aria-expanded","false")}return this}_onKeyPress(e){const t=e.code,n=e.charCode||e.keyCode;"Space"!==t&&"Enter"!==t&&32!==n&&13!==n||this.togglePopup()}_onMapClick(e){const t=e.originalEvent.target,n=this._element;this._popup&&(t===n||n.contains(t))&&this.togglePopup()}getPopup(){return this._popup}togglePopup(){const e=this._popup;return e?(e.isOpen()?(e.remove(),this._element.setAttribute("aria-expanded","false")):this._map&&(e.addTo(this._map),this._element.setAttribute("aria-expanded","true")),this):this}_behindTerrain(){const e=this._map,t=this._pos;if(!e||!t)return!1;const n=e.unproject(t),r=e.getFreeCameraOptions();if(!r.position)return!1;const i=r.position.toLngLat();return i.distanceTo(n)<.9*i.distanceTo(this._lngLat)}_evaluateOpacity(){const t=this._map;if(!t)return;const n=this._pos;if(!n||n.x<0||n.x>t.transform.width||n.y<0||n.y>t.transform.height)return void this._clearFadeTimer();const r=t.unproject(n);let i;t._showingGlobe()&&e.isLngLatBehindGlobe(t.transform,this._lngLat)?i=0:(i=1-t._queryFogOpacity(r),t.transform._terrainEnabled()&&t.getTerrain()&&this._behindTerrain()&&(i*=this._occludedOpacity)),this._element.style.opacity=""+i,this._element.style.pointerEvents=i>0?"auto":"none",this._popup&&this._popup._setOpacity(i),this._fadeTimer=null}_clearFadeTimer(){this._fadeTimer&&(clearTimeout(this._fadeTimer),this._fadeTimer=null)}_updateDOM(){const e=this._pos;if(!e||!this._map)return;const t=this._offset.mult(this._scale);this._element.style.transform=`\n translate(${e.x}px,${e.y}px)\n ${Qi[this._anchor]}\n ${this._calculateXYTransform()} ${this._calculateZTransform()}\n translate(${t.x}px,${t.y}px)\n `}_calculateXYTransform(){const t=this._pos,n=this._map,r=this.getPitchAlignment();if(!n||!t||"map"!==r)return"";if(!n._showingGlobe()){const e=n.getPitch();return e?`rotateX(${e}deg)`:""}const i=e.radToDeg(e.globeTiltAtLngLat(n.transform,this._lngLat)),o=t.sub(e.globeCenterToScreenPoint(n.transform)),a=Math.abs(o.x)+Math.abs(o.y);if(0===a)return"";const s=i/a;return`rotateX(${-o.y*s}deg) rotateY(${o.x*s}deg)`}_calculateZTransform(){const t=this._pos,n=this._map;if(!n||!t)return"";let r=0;const i=this.getRotationAlignment();if("map"===i)if(n._showingGlobe()){const t=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat+.001)),i=n.project(new e.LngLat(this._lngLat.lng,this._lngLat.lat-.001)).sub(t);r=e.radToDeg(Math.atan2(i.y,i.x))-90}else r=-n.getBearing();else if("horizon"===i){const i=e.smoothstep(4,6,n.getZoom()),o=e.globeCenterToScreenPoint(n.transform);o.y+=i*n.transform.height;const a=t.sub(o),s=e.radToDeg(Math.atan2(a.y,a.x));r=(s>90?s-270:s+90)*(1-i)}return r+=this._rotation,r?`rotateZ(${r}deg)`:""}_update(t){e.window.cancelAnimationFrame(this._updateFrameId);const n=this._map;n&&(n.transform.renderWorldCopies&&(this._lngLat=Ji(this._lngLat,this._pos,n.transform)),this._pos=n.project(this._lngLat),!0===t?this._updateFrameId=e.window.requestAnimationFrame(()=>{this._element&&this._pos&&this._anchor&&(this._pos=this._pos.round(),this._updateDOM())}):this._pos=this._pos.round(),n._requestDomTask(()=>{this._map&&(this._element&&this._pos&&this._anchor&&this._updateDOM(),(n._showingGlobe()||n.getTerrain()||n.getFog())&&!this._fadeTimer&&(this._fadeTimer=setTimeout(this._evaluateOpacity.bind(this),60)))}))}getOffset(){return this._offset}setOffset(t){return this._offset=e.pointGeometry.convert(t),this._update(),this}_onMove(t){const n=this._map;if(!n)return;const r=this._pointerdownPos,i=this._positionDelta;if(r&&i){if(!this._isDragging){const e=this._clickTolerance||n._clickTolerance;if(t.point.dist(r)=this._endTime)return this._end;const n=e.easeCubicInOut((t-this._startTime)/(this._endTime-this._startTime));return this._start*(1-n)+this._end*n}isEasing(e){return e>=this._startTime&&e<=this._endTime}jumpTo(e){this._startTime=-1/0,this._endTime=-1/0,this._start=e,this._end=e}easeTo(e,t,n){this._start=this.getValue(t),this._end=e,this._startTime=t,this._endTime=t+n}}const oo={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"Mapbox logo","Map.Title":"Map","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","ScrollZoomBlocker.CtrlMessage":"Use ctrl + scroll to zoom the map","ScrollZoomBlocker.CmdMessage":"Use ⌘ + scroll to zoom the map","TouchPanBlocker.Message":"Use two fingers to move the map"},ao={center:[0,0],zoom:0,bearing:0,pitch:0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:85,interactive:!0,scrollZoom:!0,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,performanceMetricsCollection:!0,bearingSnap:7,clickTolerance:3,pitchWithRotate:!0,hash:!1,attributionControl:!0,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,trackResize:!0,optimizeForTerrain:!0,renderWorldCopies:!0,refreshExpiredTiles:!0,minTileCacheSize:null,maxTileCacheSize:null,localIdeographFontFamily:"sans-serif",localFontFamily:null,transformRequest:null,accessToken:null,fadeDuration:300,crossSourceCollisions:!0},so={showCompass:!0,showZoom:!0,visualizePitch:!1};class lo{constructor(t,n,r=!1){this._clickTolerance=10,this.element=n,this.mouseRotate=new xi({clickTolerance:t.dragRotate._mouseRotate._clickTolerance}),this.map=t,r&&(this.mousePitch=new bi({clickTolerance:t.dragRotate._mousePitch._clickTolerance})),e.bindAll(["mousedown","mousemove","mouseup","touchstart","touchmove","touchend","reset"],this),n.addEventListener("mousedown",this.mousedown),n.addEventListener("touchstart",this.touchstart,{passive:!1}),n.addEventListener("touchmove",this.touchmove),n.addEventListener("touchend",this.touchend),n.addEventListener("touchcancel",this.reset)}down(e,t){this.mouseRotate.mousedown(e,t),this.mousePitch&&this.mousePitch.mousedown(e,t),c()}move(e,t){const n=this.map,r=this.mouseRotate.mousemoveWindow(e,t),i=r&&r.bearingDelta;if(i&&n.setBearing(n.getBearing()+i),this.mousePitch){const r=this.mousePitch.mousemoveWindow(e,t),i=r&&r.pitchDelta;i&&n.setPitch(n.getPitch()+i)}}off(){const e=this.element;e.removeEventListener("mousedown",this.mousedown),e.removeEventListener("touchstart",this.touchstart,{passive:!1}),e.removeEventListener("touchmove",this.touchmove),e.removeEventListener("touchend",this.touchend),e.removeEventListener("touchcancel",this.reset),this.offTemp()}offTemp(){h(),e.window.removeEventListener("mousemove",this.mousemove),e.window.removeEventListener("mouseup",this.mouseup)}mousedown(t){this.down(e.extend({},t,{ctrlKey:!0,preventDefault:()=>t.preventDefault()}),p(this.element,t)),e.window.addEventListener("mousemove",this.mousemove),e.window.addEventListener("mouseup",this.mouseup)}mousemove(e){this.move(e,p(this.element,e))}mouseup(e){this.mouseRotate.mouseupWindow(e),this.mousePitch&&this.mousePitch.mouseupWindow(e),this.offTemp()}touchstart(e){1!==e.targetTouches.length?this.reset():(this._startPos=this._lastPos=m(this.element,e.targetTouches)[0],this.down({type:"mousedown",button:0,ctrlKey:!0,preventDefault:()=>e.preventDefault()},this._startPos))}touchmove(e){1!==e.targetTouches.length?this.reset():(this._lastPos=m(this.element,e.targetTouches)[0],this.move({preventDefault:()=>e.preventDefault()},this._lastPos))}touchend(e){0===e.targetTouches.length&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this._container.style.width=e*i+"px",this._container.innerHTML=`${r} ${o}`})}function fo(e){const t=Math.pow(10,(""+Math.floor(e)).length-1);let n=e/t;return n=n>=10?10:n>=5?5:n>=3?3:n>=2?2:n>=1?1:function(e){const t=Math.pow(10,Math.ceil(-Math.log(e)/Math.LN10));return Math.round(e*t)/t}(n),t*n}const po={version:e.version,supported:n,setRTLTextPlugin:e.setRTLTextPlugin,getRTLTextPluginStatus:e.getRTLTextPluginStatus,Map:class extends Xi{constructor(t){if(e.LivePerformanceUtils.mark(e.PerformanceMarkers.create),null!=(t=e.extend({},ao,t)).minZoom&&null!=t.maxZoom&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(null!=t.minPitch&&null!=t.maxPitch&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(null!=t.minPitch&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(null!=t.maxPitch&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(t.antialias&&e.isSafariWithAntialiasingBug(e.window)&&(t.antialias=!1,e.warnOnce("Antialiasing is disabled for this WebGL context to avoid browser bug: https://github.com/mapbox/mapbox-gl-js/issues/11609")),super(new Hr(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),t),this._interactive=t.interactive,this._minTileCacheSize=t.minTileCacheSize,this._maxTileCacheSize=t.maxTileCacheSize,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=t.preserveDrawingBuffer,this._antialias=t.antialias,this._trackResize=t.trackResize,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles,this._fadeDuration=t.fadeDuration,this._isInitialLoad=!0,this._crossSourceCollisions=t.crossSourceCollisions,this._collectResourceTiming=t.collectResourceTiming,this._optimizeForTerrain=t.optimizeForTerrain,this._language=this._parseLanguage(t.language),this._worldview=t.worldview,this._renderTaskQueue=new Ki,this._domRenderTaskQueue=new Ki,this._controls=[],this._markers=[],this._popups=[],this._mapId=e.uniqueId(),this._locale=e.extend({},oo,t.locale),this._clickTolerance=t.clickTolerance,this._cooperativeGestures=t.cooperativeGestures,this._performanceMetricsCollection=t.performanceMetricsCollection,this._containerWidth=0,this._containerHeight=0,this._averageElevationLastSampledAt=-1/0,this._averageElevationExaggeration=0,this._averageElevation=new io(0),this._interactionRange=[1/0,-1/0],this._visibilityHidden=0,this._useExplicitProjection=!1,this._requestManager=new e.RequestManager(t.transformRequest,t.accessToken,t.testMode),this._silenceAuthErrors=!!t.testMode,"string"==typeof t.container){if(this._container=e.window.document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof e.window.HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(this._container.childNodes.length>0&&e.warnOnce("The map container element should be empty, otherwise the map's interactivity will be negatively impacted. If you want to display a message when WebGL is not supported, use the Mapbox GL Supported plugin instead."),t.maxBounds&&this.setMaxBounds(t.maxBounds),e.bindAll(["_onWindowOnline","_onWindowResize","_onVisibilityChange","_onMapScroll","_contextLost","_contextRestored"],this),this._setupContainer(),this._setupPainter(),void 0===this.painter)throw new Error("Failed to initialize WebGL.");this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),void 0!==e.window&&(e.window.addEventListener("online",this._onWindowOnline,!1),e.window.addEventListener("resize",this._onWindowResize,!1),e.window.addEventListener("orientationchange",this._onWindowResize,!1),e.window.addEventListener("webkitfullscreenchange",this._onWindowResize,!1),e.window.addEventListener("visibilitychange",this._onVisibilityChange,!1)),this.handlers=new Zi(this,t),this._localFontFamily=t.localFontFamily,this._localIdeographFontFamily=t.localIdeographFontFamily,t.style&&this.setStyle(t.style,{localFontFamily:this._localFontFamily,localIdeographFontFamily:this._localIdeographFontFamily}),t.projection&&this.setProjection(t.projection),this._hash=t.hash&&new Kr("string"==typeof t.hash&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,e.extend({},t.fitBoundsOptions,{duration:0})))),this.resize(),t.attributionControl&&this.addControl(new Hi({customAttribution:t.customAttribution})),this._logoControl=new Yi,this.addControl(this._logoControl,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update("style"===t.dataType),this.fire(new e.Event(t.dataType+"data",t))}),this.on("dataloading",t=>{this.fire(new e.Event(t.dataType+"dataloading",t))})}_getMapId(){return this._mapId}addControl(t,n){if(void 0===n&&(n=t.getDefaultPosition?t.getDefaultPosition():"top-right"),!t||!t.onAdd)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const r=t.onAdd(this);this._controls.push(t);const i=this._controlPositions[n];return-1!==n.indexOf("bottom")?i.insertBefore(r,i.firstChild):i.appendChild(r),this}removeControl(t){if(!t||!t.onRemove)return this.fire(new e.ErrorEvent(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(t);return n>-1&&this._controls.splice(n,1),t.onRemove(this),this}hasControl(e){return this._controls.indexOf(e)>-1}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}resize(t){if(this._updateContainerDimensions(),this._containerWidth===this.transform.width&&this._containerHeight===this.transform.height)return this;this._resizeCanvas(this._containerWidth,this._containerHeight),this.transform.resize(this._containerWidth,this._containerHeight),this.painter.resize(Math.ceil(this._containerWidth),Math.ceil(this._containerHeight));const n=!this._moving;return n&&this.fire(new e.Event("movestart",t)).fire(new e.Event("move",t)),this.fire(new e.Event("resize",t)),n&&this.fire(new e.Event("moveend",t)),this}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()||null}setMaxBounds(t){return this.transform.setMaxBounds(e.LngLatBounds.convert(t)),this._update()}setMinZoom(t){if((t=null==t?-2:t)>=-2&&t<=this.transform.maxZoom)return this.transform.minZoom=t,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=t,this._update(),this.getZoom()>t?this.setZoom(t):this.fire(new e.Event("zoomstart")).fire(new e.Event("zoom")).fire(new e.Event("zoomend")),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(t){if((t=null==t?0:t)<0)throw new Error("minPitch must be greater than or equal to 0");if(t>=0&&t<=this.transform.maxPitch)return this.transform.minPitch=t,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(t>=this.transform.minPitch)return this.transform.maxPitch=t,this._update(),this.getPitch()>t?this.setPitch(t):this.fire(new e.Event("pitchstart")).fire(new e.Event("pitch")).fire(new e.Event("pitchend")),this;throw new Error("maxPitch must be greater than or equal to minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(e){return this.transform.renderWorldCopies=e,this.transform.renderWorldCopies||this._forceMarkerAndPopupUpdate(!0),this._update()}getLanguage(){return this._language}_parseLanguage(t){return"auto"===t?e.window.navigator.language:Array.isArray(t)?0===t.length?void 0:t.map(t=>"auto"===t?e.window.navigator.language:t):t}setLanguage(e){const t=this._parseLanguage(e);if(!this.style||t===this._language)return this;this._language=t,this.style._reloadSources();for(const e of this._controls)e._setLanguage&&e._setLanguage(this._language);return this}getWorldview(){return this._worldview}setWorldview(e){return this.style&&e!==this._worldview?(this._worldview=e,this.style._reloadSources(),this):this}getProjection(){return this.transform.mercatorFromTransition?{name:"globe",center:[0,0]}:this.transform.getProjection()}_showingGlobe(){return"globe"===this.transform.projection.name}setProjection(e){return this._lazyInitEmptyStyle(),e?"string"==typeof e&&(e={name:e}):e=null,this._useExplicitProjection=!!e,this._prioritizeAndUpdateProjection(e,this.style.stylesheet?this.style.stylesheet.projection:null)}_updateProjectionTransition(){if("globe"!==this.getProjection().name)return;const t=this.transform,n=t.projection.name;let r;"globe"===n&&t.zoom>=e.GLOBE_ZOOM_THRESHOLD_MAX?(t.setMercatorFromTransition(),r=!0):"mercator"===n&&t.zoom=e.GLOBE_ZOOM_THRESHOLD_MAX?this.transform.setMercatorFromTransition():this.transform.setProjection(t),this.style.applyProjectionUpdate(),n){this.painter.clearBackgroundTiles();for(const e in this.style._sourceCaches)this.style._sourceCaches[e].clearTiles();this._update(!0),this._forceMarkerAndPopupUpdate(!0)}return this}project(t){return this.transform.locationPoint3D(e.LngLat.convert(t))}unproject(t){return this.transform.pointLocation3D(e.pointGeometry.convert(t))}isMoving(){return this._moving||this.handlers&&this.handlers.isMoving()||!1}isZooming(){return this._zooming||this.handlers&&this.handlers.isZooming()||!1}isRotating(){return this._rotating||this.handlers&&this.handlers.isRotating()||!1}_isDragging(){return this.handlers&&this.handlers._isDragging()||!1}_createDelegatedListener(e,t,n){if("mouseenter"===e||"mouseover"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e)),a=o.length?this.queryRenderedFeatures(i.point,{layers:o}):[];a.length?r||(r=!0,n.call(this,new si(e,this,i.originalEvent,{features:a}))):r=!1},o=()=>{r=!1};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}if("mouseleave"===e||"mouseout"===e){let r=!1;const i=i=>{const o=t.filter(e=>this.getLayer(e));(o.length?this.queryRenderedFeatures(i.point,{layers:o}):[]).length?r=!0:r&&(r=!1,n.call(this,new si(e,this,i.originalEvent)))},o=t=>{r&&(r=!1,n.call(this,new si(e,this,t.originalEvent)))};return{layers:new Set(t),listener:n,delegates:{mousemove:i,mouseout:o}}}{const r=e=>{const r=t.filter(e=>this.getLayer(e)),i=r.length?this.queryRenderedFeatures(e.point,{layers:r}):[];i.length&&(e.features=i,n.call(this,e),delete e.features)};return{layers:new Set(t),listener:n,delegates:{[e]:r}}}}on(e,t,n){if(void 0===n)return super.on(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[e]=this._delegatedListeners[e]||[],this._delegatedListeners[e].push(r);for(const e in r.delegates)this.on(e,r.delegates[e]);return this}once(e,t,n){if(void 0===n)return super.once(e,t);Array.isArray(t)||(t=[t]);const r=this._createDelegatedListener(e,t,n);for(const e in r.delegates)this.once(e,r.delegates[e]);return this}off(e,t,n){if(void 0===n)return super.off(e,t);t=new Set(Array.isArray(t)?t:[t]);const r=(e,t)=>{if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0},i=this._delegatedListeners?this._delegatedListeners[e]:void 0;return i&&(e=>{for(let i=0;i{t?this.fire(new e.ErrorEvent(t)):r&&this._updateDiff(r,n)})}else"object"==typeof t&&this._updateDiff(t,n)}_updateDiff(t,n){try{this.style.setState(t)&&this._update(!0)}catch(r){e.warnOnce(`Unable to perform style diff: ${r.message||r.error||r}. Rebuilding the style from scratch.`),this._updateStyle(t,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():(e.warnOnce("There is no style added to the map."),!1)}addSource(e,t){return this._lazyInitEmptyStyle(),this.style.addSource(e,t),this._update(!0)}isSourceLoaded(e){return!!this.style&&this.style._isSourceCacheLoaded(e)}areTilesLoaded(){const e=this.style&&this.style._sourceCaches;for(const t in e){const n=e[t]._tiles;for(const e in n){const t=n[e];if("loaded"!==t.state&&"errored"!==t.state)return!1}}return!0}addSourceType(e,t,n){this._lazyInitEmptyStyle(),this.style.addSourceType(e,t,n)}removeSource(e){return this.style.removeSource(e),this._updateTerrain(),this._update(!0)}getSource(e){return this.style.getSource(e)}addImage(t,n,{pixelRatio:r=1,sdf:i=!1,stretchX:o,stretchY:a,content:s}={}){if(this._lazyInitEmptyStyle(),n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap){const{width:l,height:u,data:c}=e.exported.getImageData(n);this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},c),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0})}else if(void 0===n.width||void 0===n.height)this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));else{const{width:l,height:u}=n,c=n;this.style.addImage(t,{data:new e.RGBAImage({width:l,height:u},new Uint8Array(c.data)),pixelRatio:r,stretchX:o,stretchY:a,content:s,sdf:i,version:0,userImage:c}),c.onAdd&&c.onAdd(this,t)}}updateImage(t,n){const r=this.style.getImage(t);if(!r)return void this.fire(new e.ErrorEvent(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const i=n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap?e.exported.getImageData(n):n,{width:o,height:a}=i;void 0!==o&&void 0!==a?o===r.data.width&&a===r.data.height?(r.data.replace(i.data,!(n instanceof e.window.HTMLImageElement||e.window.ImageBitmap&&n instanceof e.window.ImageBitmap)),this.style.updateImage(t,r)):this.fire(new e.ErrorEvent(new Error(`The width and height of the updated image (${o}, ${a})\n must be that same as the previous version of the image\n (${r.data.width}, ${r.data.height})`))):this.fire(new e.ErrorEvent(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")))}hasImage(t){return t?!!this.style.getImage(t):(this.fire(new e.ErrorEvent(new Error("Missing required image id"))),!1)}removeImage(e){this.style.removeImage(e)}loadImage(t,n){e.getImage(this._requestManager.transformRequest(t,e.ResourceType.Image),(t,r)=>{n(t,r instanceof e.window.HTMLImageElement?e.exported.getImageData(r):r)})}listImages(){return this.style.listImages()}addLayer(e,t){return this._lazyInitEmptyStyle(),this.style.addLayer(e,t),this._update(!0)}moveLayer(e,t){return this.style.moveLayer(e,t),this._update(!0)}removeLayer(e){return this.style.removeLayer(e),this._update(!0)}getLayer(e){return this.style.getLayer(e)}setLayerZoomRange(e,t,n){return this.style.setLayerZoomRange(e,t,n),this._update(!0)}setFilter(e,t,n={}){return this.style.setFilter(e,t,n),this._update(!0)}getFilter(e){return this.style.getFilter(e)}setPaintProperty(e,t,n,r={}){return this.style.setPaintProperty(e,t,n,r),this._update(!0)}getPaintProperty(e,t){return this.style.getPaintProperty(e,t)}setLayoutProperty(e,t,n,r={}){return this.style.setLayoutProperty(e,t,n,r),this._update(!0)}getLayoutProperty(e,t){return this.style.getLayoutProperty(e,t)}setLight(e,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(e,t),this._update(!0)}getLight(){return this.style.getLight()}setTerrain(e){return this._lazyInitEmptyStyle(),!e&&this.transform.projection.requiresDraping?this.style.setTerrainForDraping():this.style.setTerrain(e),this._averageElevationLastSampledAt=-1/0,this._update(!0)}getTerrain(){return this.style?this.style.getTerrain():null}setFog(e){return this._lazyInitEmptyStyle(),this.style.setFog(e),this._update(!0)}getFog(){return this.style?this.style.getFog():null}_queryFogOpacity(t){return this.style&&this.style.fog?this.style.fog.getOpacityAtLatLng(e.LngLat.convert(t),this.transform):0}setFeatureState(e,t){return this.style.setFeatureState(e,t),this._update()}removeFeatureState(e,t){return this.style.removeFeatureState(e,t),this._update()}getFeatureState(e){return this.style.getFeatureState(e)}_updateContainerDimensions(){if(!this._container)return;const t=this._container.getBoundingClientRect().width||400,n=this._container.getBoundingClientRect().height||300;let r,i,o,a=this._container;for(;a&&(!i||!o);){const t=e.window.getComputedStyle(a).transform;t&&"none"!==t&&(r=t.match(/matrix.*\((.+)\)/)[1].split(", "),r[0]&&"0"!==r[0]&&"1"!==r[0]&&(i=r[0]),r[3]&&"0"!==r[3]&&"1"!==r[3]&&(o=r[3])),a=a.parentElement}this._containerWidth=i?Math.abs(t/i):t,this._containerHeight=o?Math.abs(n/o):n}_detectMissingCSS(){"rgb(250, 128, 114)"!==e.window.getComputedStyle(this._missingCSSCanary).getPropertyValue("background-color")&&e.warnOnce("This page appears to be missing CSS declarations for Mapbox GL JS, which may cause the map to display incorrectly. Please ensure your page includes mapbox-gl.css, as described in https://www.mapbox.com/mapbox-gl-js/api/.")}_setupContainer(){const e=this._container;e.classList.add("mapboxgl-map"),(this._missingCSSCanary=o("div","mapboxgl-canary",e)).style.visibility="hidden",this._detectMissingCSS();const t=this._canvasContainer=o("div","mapboxgl-canvas-container",e);this._interactive&&t.classList.add("mapboxgl-interactive"),this._canvas=o("canvas","mapboxgl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex","0"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region"),this._updateContainerDimensions(),this._resizeCanvas(this._containerWidth,this._containerHeight);const n=this._controlContainer=o("div","mapboxgl-control-container",e),r=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(e=>{r[e]=o("div","mapboxgl-ctrl-"+e,n)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(t,n){const r=e.exported.devicePixelRatio||1;this._canvas.width=r*Math.ceil(t),this._canvas.height=r*Math.ceil(n),this._canvas.style.width=t+"px",this._canvas.style.height=n+"px"}_addMarker(e){this._markers.push(e)}_removeMarker(e){const t=this._markers.indexOf(e);-1!==t&&this._markers.splice(t,1)}_addPopup(e){this._popups.push(e)}_removePopup(e){const t=this._popups.indexOf(e);-1!==t&&this._popups.splice(t,1)}_setupPainter(){const t=e.extend({},n.webGLContextAttributes,{failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1}),r=this._canvas.getContext("webgl",t)||this._canvas.getContext("experimental-webgl",t);r?(e.storeAuthState(r,!0),this.painter=new Rr(r,this.transform),this.on("data",e=>{"source"===e.dataType&&this.painter.setTileLoadedFlag(!0)}),e.exported$1.testSupport(r)):this.fire(new e.ErrorEvent(new Error("Failed to initialize WebGL")))}_contextLost(t){t.preventDefault(),this._frame&&(this._frame.cancel(),this._frame=null),this.fire(new e.Event("webglcontextlost",{originalEvent:t}))}_contextRestored(t){this._setupPainter(),this.resize(),this._update(),this.fire(new e.Event("webglcontextrestored",{originalEvent:t}))}_onMapScroll(e){if(e.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(e){return this.style?(this._styleDirty=this._styleDirty||e,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(e){return this._update(),this._renderTaskQueue.add(e)}_cancelRenderFrame(e){this._renderTaskQueue.remove(e)}_requestDomTask(e){!this.loaded()||this.loaded()&&!this.isMoving()?e():this._domRenderTaskQueue.add(e)}_render(t){let n;const r=this.painter.context.extTimerQuery,i=e.exported.now();if(this.listens("gpu-timing-frame")&&(n=r.createQueryEXT(),r.beginQueryEXT(r.TIME_ELAPSED_EXT,n)),this.painter.context.setDirty(),this.painter.setBaseState(),(this.isMoving()||this.isRotating()||this.isZooming())&&(this._interactionRange[0]=Math.min(this._interactionRange[0],e.window.performance.now()),this._interactionRange[1]=Math.max(this._interactionRange[1],e.window.performance.now())),this._renderTaskQueue.run(t),this._domRenderTaskQueue.run(t),this._removed)return;this._updateProjectionTransition();const o=this._isInitialLoad?0:this._fadeDuration;if(this.style&&this._styleDirty){this._styleDirty=!1;const t=this.transform.zoom,n=this.transform.pitch,r=e.exported.now(),i=new e.EvaluationParameters(t,{now:r,fadeDuration:o,pitch:n,transition:this.style.getTransition()});this.style.update(i)}this.style&&this.style.fog&&this.style.fog.hasTransition()&&(this.style._markersNeedUpdate=!0,this._sourcesDirty=!0);let a=!1;if(this.style&&this._sourcesDirty?(this._sourcesDirty=!1,this.painter._updateFog(this.style),this._updateTerrain(),a=this._updateAverageElevation(i),this.style._updateSources(this.transform),this._forceMarkerAndPopupUpdate()):a=this._updateAverageElevation(i),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,o,this._crossSourceCollisions),this.style&&this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showTerrainWireframe:this.showTerrainWireframe,showOverdrawInspector:this._showOverdrawInspector,showQueryGeometry:!!this._showQueryGeometry,showTileAABBs:this.showTileAABBs,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:o,isInitialLoad:this._isInitialLoad,showPadding:this.showPadding,gpuTiming:!!this.listens("gpu-timing-layer"),gpuTimingDeferredRender:!!this.listens("gpu-timing-deferred-render"),speedIndexTiming:this.speedIndexTiming}),this.fire(new e.Event("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,this.fire(new e.Event("load"))),this.style&&this.style.hasTransitions()&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles(),n){const t=e.exported.now()-i;r.endQueryEXT(r.TIME_ELAPSED_EXT,n),setTimeout(()=>{const o=r.getQueryObjectEXT(n,r.QUERY_RESULT_EXT)/1e6;r.deleteQueryEXT(n),this.fire(new e.Event("gpu-timing-frame",{cpuTime:t,gpuTime:o})),e.window.performance.mark("frame-gpu",{startTime:i,detail:{gpuTime:o}})},50)}if(this.listens("gpu-timing-layer")){const t=this.painter.collectGpuTimers();setTimeout(()=>{const n=this.painter.queryGpuTimers(t);this.fire(new e.Event("gpu-timing-layer",{layerTimes:n}))},50)}if(this.listens("gpu-timing-deferred-render")){const t=this.painter.collectDeferredRenderGpuQueries();setTimeout(()=>{const n=this.painter.queryGpuTimeDeferredRender(t);this.fire(new e.Event("gpu-timing-deferred-render",{gpuTime:n}))},50)}const s=this._sourcesDirty||this._styleDirty||this._placementDirty||a;if(s||this._repaint)this.triggerRepaint();else{const t=!this.isMoving()&&this.loaded();if(t&&(a=this._updateAverageElevation(i,!0)),a)this.triggerRepaint();else if(this._triggerFrame(!1),t&&(this.fire(new e.Event("idle")),this._isInitialLoad=!1,this.speedIndexTiming)){const t=this._calculateSpeedIndex();this.fire(new e.Event("speedindexcompleted",{speedIndex:t})),this.speedIndexTiming=!1}}!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,e.LivePerformanceUtils.mark(e.PerformanceMarkers.fullLoad),this._performanceMetricsCollection&&e.postPerformanceEvent(this._requestManager._customAccessToken,{width:this.painter.width,height:this.painter.height,interactionRange:this._interactionRange,visibilityHidden:this._visibilityHidden,terrainEnabled:!!this.painter.style.getTerrain(),fogEnabled:!!this.painter.style.getFog(),projection:this.getProjection().name,zoom:this.transform.zoom,renderer:this.painter.context.renderer,vendor:this.painter.context.vendor}),this._authenticate())}_forceMarkerAndPopupUpdate(e){for(const t of this._markers)e&&!this.getRenderWorldCopies()&&(t._lngLat=t._lngLat.wrap()),t._update();for(const t of this._popups)!e||this.getRenderWorldCopies()||t._trackPointer||(t._lngLat=t._lngLat.wrap()),t._update()}_updateAverageElevation(e,t=!1){const n=e=>(this.transform.averageElevation=e,this._update(!1),!0);if(!this.painter.averageElevationNeedsEasing())return 0!==this.transform.averageElevation&&n(0);if((t||e-this._averageElevationLastSampledAt>500)&&!this._averageElevation.isEasing(e)){const t=this.transform.averageElevation;let r=this.transform.sampleAverageElevation(),i=!1;this.transform.elevation&&(i=this.transform.elevation.exaggeration()!==this._averageElevationExaggeration,this._averageElevationExaggeration=this.transform.elevation.exaggeration()),isNaN(r)?r=0:this._averageElevationLastSampledAt=e;const o=Math.abs(t-r);if(o>1){if(this._isInitialLoad||i)return this._averageElevation.jumpTo(r),n(r);this._averageElevation.easeTo(r,e,300)}else if(o>1e-4)return this._averageElevation.jumpTo(r),n(r)}return!!this._averageElevation.isEasing(e)&&n(this._averageElevation.getValue(e))}_authenticate(){e.getMapSessionAPI(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,t=>{if(t&&(t.message===e.AUTH_ERR_MSG||401===t.status)){const t=this.painter.context.gl;e.storeAuthState(t,!1),this._logoControl instanceof Yi&&this._logoControl._updateLogo(),t&&t.clear(t.DEPTH_BUFFER_BIT|t.COLOR_BUFFER_BIT|t.STENCIL_BUFFER_BIT),this._silenceAuthErrors||this.fire(new e.ErrorEvent(new Error("A valid Mapbox access token is required to use Mapbox GL JS. To create an account or a new access token, visit https://account.mapbox.com/")))}}),e.postMapLoadEvent(this._getMapId(),this._requestManager._skuToken,this._requestManager._customAccessToken,()=>{})}_updateTerrain(){const e=this._isDragging();this.painter.updateTerrain(this.style,e)}_calculateSpeedIndex(){const e=this.painter.canvasCopy(),t=this.painter.getCanvasCopiesAndTimestamps();t.timeStamps.push(performance.now());const n=this.painter.context.gl,r=n.createFramebuffer();function i(e){n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);const t=new Uint8Array(n.drawingBufferWidth*n.drawingBufferHeight*4);return n.readPixels(0,0,n.drawingBufferWidth,n.drawingBufferHeight,n.RGBA,n.UNSIGNED_BYTE,t),t}return n.bindFramebuffer(n.FRAMEBUFFER,r),this._canvasPixelComparison(i(e),t.canvasCopies.map(i),t.timeStamps)}_canvasPixelComparison(e,t,n){let r=n[1]-n[0];const i=e.length/4;for(let o=0;o{const t=!!this._renderNextFrame;this._frame=null,this._renderNextFrame=null,t&&this._render(e)}))}_preloadTiles(t){const n=this.style?Object.values(this.style._sourceCaches):[];return e.asyncAll(n,(e,n)=>e._preloadTiles(t,n),()=>{this.triggerRepaint()}),this}_onWindowOnline(){this._update()}_onWindowResize(e){this._trackResize&&this.resize({originalEvent:e})._update()}_onVisibilityChange(){"hidden"===e.window.document.visibilityState&&this._visibilityHidden++}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(e){this._showTileBoundaries!==e&&(this._showTileBoundaries=e,this._update())}get showTerrainWireframe(){return!!this._showTerrainWireframe}set showTerrainWireframe(e){this._showTerrainWireframe!==e&&(this._showTerrainWireframe=e,this._update())}get speedIndexTiming(){return!!this._speedIndexTiming}set speedIndexTiming(e){this._speedIndexTiming!==e&&(this._speedIndexTiming=e,this._update())}get showPadding(){return!!this._showPadding}set showPadding(e){this._showPadding!==e&&(this._showPadding=e,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(e){this._showCollisionBoxes!==e&&(this._showCollisionBoxes=e,e?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(e){this._showOverdrawInspector!==e&&(this._showOverdrawInspector=e,this._update())}get repaint(){return!!this._repaint}set repaint(e){this._repaint!==e&&(this._repaint=e,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(e){this._vertices=e,this._update()}get showTileAABBs(){return!!this._showTileAABBs}set showTileAABBs(e){this._showTileAABBs!==e&&(this._showTileAABBs=e,e&&this._update())}_setCacheLimits(t,n){e.setCacheLimits(t,n)}get version(){return e.version}},NavigationControl:class{constructor(t){this.options=e.extend({},so,t),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._container.addEventListener("contextmenu",e=>e.preventDefault()),this.options.showZoom&&(e.bindAll(["_setButtonTitle","_updateZoomButtons"],this),this._zoomInButton=this._createButton("mapboxgl-ctrl-zoom-in",e=>{this._map&&this._map.zoomIn({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("mapboxgl-ctrl-zoom-out",e=>{this._map&&this._map.zoomOut({},{originalEvent:e})}),o("span","mapboxgl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(e.bindAll(["_rotateCompassArrow"],this),this._compass=this._createButton("mapboxgl-ctrl-compass",e=>{const t=this._map;t&&(this.options.visualizePitch?t.resetNorthPitch({},{originalEvent:e}):t.resetNorth({},{originalEvent:e}))}),this._compassIcon=o("span","mapboxgl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}_updateZoomButtons(){const e=this._map;if(!e)return;const t=e.getZoom(),n=t===e.getMaxZoom(),r=t===e.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=r,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",r.toString())}_rotateCompassArrow(){const e=this._map;if(!e)return;const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(e.transform.pitch*(Math.PI/180)),.5)}) rotateX(${e.transform.pitch}deg) rotateZ(${e.transform.angle*(180/Math.PI)}deg)`:`rotate(${e.transform.angle*(180/Math.PI)}deg)`;e._requestDomTask(()=>{this._compassIcon&&(this._compassIcon.style.transform=t)})}onAdd(e){return this._map=e,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),e.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&e.on("pitch",this._rotateCompassArrow),e.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new lo(e,this._compass,this.options.visualizePitch)),this._container}onRemove(){const e=this._map;e&&(this._container.remove(),this.options.showZoom&&e.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&e.off("pitch",this._rotateCompassArrow),e.off("rotate",this._rotateCompassArrow),this._handler&&this._handler.off(),this._handler=void 0),this._map=void 0)}_createButton(e,t){const n=o("button",e,this._container);return n.type="button",n.addEventListener("click",t),n}_setButtonTitle(e,t){if(!this._map)return;const n=this._map._getUIString("NavigationControl."+t);e.setAttribute("aria-label",n),e.firstElementChild&&e.firstElementChild.setAttribute("title",n)}},GeolocateControl:class extends e.Evented{constructor(t){super(),this.options=e.extend({geolocation:e.window.navigator.geolocation},uo,t),e.bindAll(["_onSuccess","_onError","_onZoom","_finish","_setupUI","_updateCamera","_updateMarker","_updateMarkerRotation","_onDeviceOrientation"],this),this._updateMarkerRotationThrottled=Yr(this._updateMarkerRotation,20),this._numberOfWatches=0}onAdd(e){return this._map=e,this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkGeolocationSupport(this._setupUI),this._container}onRemove(){void 0!==this._geolocationWatchID&&(this.options.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),this._container.remove(),this._map.off("zoom",this._onZoom),this._map=void 0,this._numberOfWatches=0,this._noTimeout=!1}_checkGeolocationSupport(t){const n=(e=!!this.options.geolocation)=>{this._supportsGeolocation=e,t(e)};void 0!==this._supportsGeolocation?t(this._supportsGeolocation):void 0!==e.window.navigator.permissions?e.window.navigator.permissions.query({name:"geolocation"}).then(e=>n("denied"!==e.state)).catch(()=>n()):n()}_isOutOfMapMaxBounds(e){const t=this._map.getMaxBounds(),n=e.coords;return!!t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting")}}_onSuccess(t){if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new e.Event("outofmaxbounds",t)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=t,this._watchState){case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background")}this.options.showUserLocation&&"OFF"!==this._watchState&&this._updateMarker(t),this.options.trackUserLocation&&"ACTIVE_LOCK"!==this._watchState||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("geolocate",t)),this._finish()}}_updateCamera(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude),r=t.coords.accuracy,i=this._map.getBearing(),o=e.extend({bearing:i},this.options.fitBoundsOptions);this._map.fitBounds(n.toBounds(r),o,{geolocateSource:!0})}_updateMarker(t){if(t){const n=new e.LngLat(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(n).addTo(this._map),this._userLocationDotMarker.setLngLat(n).addTo(this._map),this._accuracy=t.coords.accuracy,this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}else this._userLocationDotMarker.remove(),this._accuracyCircleMarker.remove()}_updateCircleRadius(){const t=this._map.transform,n=e.mercatorZfromAltitude(1,t._center.lat)*t.worldSize,r=Math.ceil(2*this._accuracy*n);this._circleElement.style.width=r+"px",this._circleElement.style.height=r+"px"}_onZoom(){this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()}_updateMarkerRotation(){this._userLocationDotMarker&&"number"==typeof this._heading?(this._userLocationDotMarker.setRotation(this._heading),this._dotElement.classList.add("mapboxgl-user-location-show-heading")):(this._dotElement.classList.remove("mapboxgl-user-location-show-heading"),this._userLocationDotMarker.setRotation(0))}_onError(t){if(this._map){if(this.options.trackUserLocation)if(1===t.code){this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const e=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e),void 0!==this._geolocationWatchID&&this._clearWatch()}else{if(3===t.code&&this._noTimeout)return;this._setErrorState()}"OFF"!==this._watchState&&this.options.showUserLocation&&this._dotElement.classList.add("mapboxgl-user-location-dot-stale"),this.fire(new e.Event("error",t)),this._finish()}}_finish(){this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0}_setupUI(t){if(void 0!==this._map){if(this._container.addEventListener("contextmenu",e=>e.preventDefault()),this._geolocateButton=o("button","mapboxgl-ctrl-geolocate",this._container),o("span","mapboxgl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",!1===t){e.warnOnce("Geolocation support is not available so the GeolocateControl will be disabled.");const t=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.setAttribute("aria-label",t),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",t)}else{const e=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.setAttribute("aria-label",e),this._geolocateButton.firstElementChild&&this._geolocateButton.firstElementChild.setAttribute("title",e)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=o("div","mapboxgl-user-location"),this._dotElement.appendChild(o("div","mapboxgl-user-location-dot")),this._dotElement.appendChild(o("div","mapboxgl-user-location-heading")),this._userLocationDotMarker=new eo({element:this._dotElement,rotationAlignment:"map",pitchAlignment:"map"}),this._circleElement=o("div","mapboxgl-user-location-accuracy-circle"),this._accuracyCircleMarker=new eo({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",this.trigger.bind(this)),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",t=>{t.geolocateSource||"ACTIVE_LOCK"!==this._watchState||t.originalEvent&&"resize"===t.originalEvent.type||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this.fire(new e.Event("trackuserlocationend")))})}}_onDeviceOrientation(e){this._userLocationDotMarker&&(e.webkitCompassHeading?this._heading=e.webkitCompassHeading:!0===e.absolute&&(this._heading=-1*e.alpha),this._updateMarkerRotationThrottled())}trigger(){if(!this._setup)return e.warnOnce("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new e.Event("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":this._numberOfWatches--,this._noTimeout=!1,this._watchState="OFF",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background-error"),this.fire(new e.Event("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new e.Event("trackuserlocationstart"))}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active");break;case"ACTIVE_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-active-error");break;case"BACKGROUND":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background");break;case"BACKGROUND_ERROR":this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-background-error")}if("OFF"===this._watchState&&void 0!==this._geolocationWatchID)this._clearWatch();else if(void 0===this._geolocationWatchID){let e;this._geolocateButton.classList.add("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),this._numberOfWatches++,this._numberOfWatches>1?(e={maximumAge:6e5,timeout:0},this._noTimeout=!0):(e=this.options.positionOptions,this._noTimeout=!1),this._geolocationWatchID=this.options.geolocation.watchPosition(this._onSuccess,this._onError,e),this.options.showUserHeading&&this._addDeviceOrientationListener()}}else this.options.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_addDeviceOrientationListener(){const t=()=>{e.window.addEventListener("ondeviceorientationabsolute"in e.window?"deviceorientationabsolute":"deviceorientation",this._onDeviceOrientation)};void 0!==e.window.DeviceMotionEvent&&"function"==typeof e.window.DeviceMotionEvent.requestPermission?DeviceOrientationEvent.requestPermission().then(e=>{"granted"===e&&t()}).catch(console.error):t()}_clearWatch(){this.options.geolocation.clearWatch(this._geolocationWatchID),e.window.removeEventListener("deviceorientation",this._onDeviceOrientation),e.window.removeEventListener("deviceorientationabsolute",this._onDeviceOrientation),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("mapboxgl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},AttributionControl:Hi,ScaleControl:class{constructor(t){this.options=e.extend({},co,t),function(){try{return new Intl.NumberFormat("en",{style:"unit",unitDisplay:"narrow",unit:"meter"}),!0}catch(e){return!1}}()||(this._setScale=ho.bind(this)),e.bindAll(["_update","_setScale","setUnit"],this)}getDefaultPosition(){return"bottom-left"}_update(){const e=this.options.maxWidth||100,t=this._map,n=t._containerHeight/2,r=t._containerWidth/2-e/2,i=t.unproject([r,n]),o=t.unproject([r+e,n]),a=i.distanceTo(o);if("imperial"===this.options.unit){const t=3.2808*a;t>5280?this._setScale(e,t/5280,"mile"):this._setScale(e,t,"foot")}else"nautical"===this.options.unit?this._setScale(e,a/1852,"nautical-mile"):a>=1e3?this._setScale(e,a/1e3,"kilometer"):this._setScale(e,a,"meter")}_setScale(e,t,n){const r=fo(t),i=r/t;this._map._requestDomTask(()=>{this._container.style.width=e*i+"px",this._container.innerHTML="nautical-mile"!==n?new Intl.NumberFormat(this._language,{style:"unit",unitDisplay:"narrow",unit:n}).format(r):r+" nm"})}onAdd(e){return this._map=e,this._language=e.getLanguage(),this._container=o("div","mapboxgl-ctrl mapboxgl-ctrl-scale",e.getContainer()),this._container.dir="auto",this._map.on("move",this._update),this._update(),this._container}onRemove(){this._container.remove(),this._map.off("move",this._update),this._map=void 0}_setLanguage(e){this._language=e,this._update()}setUnit(e){this.options.unit=e,this._update()}},FullscreenControl:class{constructor(t){this._fullscreen=!1,t&&t.container&&(t.container instanceof e.window.HTMLElement?this._container=t.container:e.warnOnce("Full screen control 'container' must be a DOM element.")),e.bindAll(["_onClickFullscreen","_changeIcon"],this),"onfullscreenchange"in e.window.document?this._fullscreenchange="fullscreenchange":"onwebkitfullscreenchange"in e.window.document&&(this._fullscreenchange="webkitfullscreenchange")}onAdd(t){return this._map=t,this._container||(this._container=this._map.getContainer()),this._controlContainer=o("div","mapboxgl-ctrl mapboxgl-ctrl-group"),this._checkFullscreenSupport()?this._setupUI():(this._controlContainer.style.display="none",e.warnOnce("This device does not support fullscreen mode.")),this._controlContainer}onRemove(){this._controlContainer.remove(),this._map=null,e.window.document.removeEventListener(this._fullscreenchange,this._changeIcon)}_checkFullscreenSupport(){return!(!e.window.document.fullscreenEnabled&&!e.window.document.webkitFullscreenEnabled)}_setupUI(){const t=this._fullscreenButton=o("button","mapboxgl-ctrl-fullscreen",this._controlContainer);o("span","mapboxgl-ctrl-icon",t).setAttribute("aria-hidden","true"),t.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),e.window.document.addEventListener(this._fullscreenchange,this._changeIcon)}_updateTitle(){const e=this._getTitle();this._fullscreenButton.setAttribute("aria-label",e),this._fullscreenButton.firstElementChild&&this._fullscreenButton.firstElementChild.setAttribute("title",e)}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_changeIcon(){(e.window.document.fullscreenElement||e.window.document.webkitFullscreenElement)===this._container!==this._fullscreen&&(this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("mapboxgl-ctrl-shrink"),this._fullscreenButton.classList.toggle("mapboxgl-ctrl-fullscreen"),this._updateTitle())}_onClickFullscreen(){this._isFullscreen()?e.window.document.exitFullscreen?e.window.document.exitFullscreen():e.window.document.webkitCancelFullScreen&&e.window.document.webkitCancelFullScreen():this._container.requestFullscreen?this._container.requestFullscreen():this._container.webkitRequestFullscreen&&this._container.webkitRequestFullscreen()}},Popup:class extends e.Evented{constructor(t){super(),this.options=e.extend(Object.create(to),t),e.bindAll(["_update","_onClose","remove","_onMouseEvent"],this),this._classList=new Set(t&&t.className?t.className.trim().split(/\s+/):[])}addTo(t){return this._map&&this.remove(),this._map=t,this.options.closeOnClick&&t.on("preclick",this._onClose),this.options.closeOnMove&&t.on("move",this._onClose),t.on("remove",this.remove),this._update(),t._addPopup(this),this._focusFirstElement(),this._trackPointer?(t.on("mousemove",this._onMouseEvent),t.on("mouseup",this._onMouseEvent),t._canvasContainer.classList.add("mapboxgl-track-pointer")):t.on("move",this._update),this.fire(new e.Event("open")),this}isOpen(){return!!this._map}remove(){this._content&&this._content.remove(),this._container&&(this._container.remove(),this._container=void 0);const t=this._map;return t&&(t.off("move",this._update),t.off("move",this._onClose),t.off("preclick",this._onClose),t.off("click",this._onClose),t.off("remove",this.remove),t.off("mousemove",this._onMouseEvent),t.off("mouseup",this._onMouseEvent),t.off("drag",this._onMouseEvent),t._canvasContainer&&t._canvasContainer.classList.remove("mapboxgl-track-pointer"),t._removePopup(this),this._map=void 0),this.fire(new e.Event("close")),this}getLngLat(){return this._lngLat}setLngLat(t){this._lngLat=e.LngLat.convert(t),this._pos=null,this._trackPointer=!1,this._update();const n=this._map;return n&&(n.on("move",this._update),n.off("mousemove",this._onMouseEvent),n._canvasContainer.classList.remove("mapboxgl-track-pointer")),this}trackPointer(){this._trackPointer=!0,this._pos=null,this._update();const e=this._map;return e&&(e.off("move",this._update),e.on("mousemove",this._onMouseEvent),e.on("drag",this._onMouseEvent),e._canvasContainer.classList.add("mapboxgl-track-pointer")),this}getElement(){return this._container}setText(t){return this.setDOMContent(e.window.document.createTextNode(t))}setHTML(t){const n=e.window.document.createDocumentFragment(),r=e.window.document.createElement("body");let i;for(r.innerHTML=t;i=r.firstChild,i;)n.appendChild(i);return this.setDOMContent(n)}getMaxWidth(){return this._container&&this._container.style.maxWidth}setMaxWidth(e){return this.options.maxWidth=e,this._update(),this}setDOMContent(e){let t=this._content;if(t)for(;t.hasChildNodes();)t.firstChild&&t.removeChild(t.firstChild);else t=this._content=o("div","mapboxgl-popup-content",this._container||void 0);if(t.appendChild(e),this.options.closeButton){const e=this._closeButton=o("button","mapboxgl-popup-close-button",t);e.type="button",e.setAttribute("aria-label","Close popup"),e.setAttribute("aria-hidden","true"),e.innerHTML="×",e.addEventListener("click",this._onClose)}return this._update(),this._focusFirstElement(),this}addClassName(e){return this._classList.add(e),this._updateClassList(),this}removeClassName(e){return this._classList.delete(e),this._updateClassList(),this}setOffset(e){return this.options.offset=e,this._update(),this}toggleClassName(e){let t;return this._classList.delete(e)?t=!1:(this._classList.add(e),t=!0),this._updateClassList(),t}_onMouseEvent(e){this._update(e.point)}_getAnchor(e){if(this.options.anchor)return this.options.anchor;const t=this._map,n=this._container,r=this._pos;if(!t||!n||!r)return"bottom";const i=n.offsetWidth,o=n.offsetHeight,a=r.xt.transform.width-i/2;if(r.y+et.transform.height-o){if(a)return"bottom-left";if(s)return"bottom-right"}return a?"left":s?"right":"bottom"}_updateClassList(){const e=this._container;if(!e)return;const t=[...this._classList];t.push("mapboxgl-popup"),this._anchor&&t.push("mapboxgl-popup-anchor-"+this._anchor),this._trackPointer&&t.push("mapboxgl-popup-track-pointer"),e.className=t.join(" ")}_update(t){const n=this._map,r=this._content;if(!n||!this._lngLat&&!this._trackPointer||!r)return;let i=this._container;if(i||(i=this._container=o("div","mapboxgl-popup",n.getContainer()),this._tip=o("div","mapboxgl-popup-tip",i),i.appendChild(r)),this.options.maxWidth&&i.style.maxWidth!==this.options.maxWidth&&(i.style.maxWidth=this.options.maxWidth),n.transform.renderWorldCopies&&!this._trackPointer&&(this._lngLat=Ji(this._lngLat,this._pos,n.transform)),!this._trackPointer||t){const e=this._pos=this._trackPointer&&t?t:n.project(this._lngLat),r=ro(this.options.offset),i=this._anchor=this._getAnchor(r.y),o=ro(this.options.offset,i),a=e.add(o).round();n._requestDomTask(()=>{this._container&&i&&(this._container.style.transform=`${Qi[i]} translate(${a.x}px,${a.y}px)`)})}if(!this._marker&&n._showingGlobe()){const t=e.isLngLatBehindGlobe(n.transform,this._lngLat)?0:1;this._setOpacity(t)}this._updateClassList()}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const e=this._container.querySelector(no);e&&e.focus()}_onClose(){this.remove()}_setOpacity(e){this._container&&(this._container.style.opacity=""+e),this._content&&(this._content.style.pointerEvents=e?"auto":"none")}},Marker:eo,Style:Jt,LngLat:e.LngLat,LngLatBounds:e.LngLatBounds,Point:e.pointGeometry,MercatorCoordinate:e.MercatorCoordinate,FreeCameraOptions:Ur,Evented:e.Evented,config:e.config,prewarm:function(){Ue().acquire(Fe)},clearPrewarmedResources:function(){const e=Ne;e&&(e.isPreloaded()&&1===e.numActive()?(e.release(Fe),Ne=null):console.warn("Could not clear WebWorkers since there are active Map instances that still reference it. The pre-warmed WebWorker pool can only be cleared when all map instances have been removed with map.remove()"))},get accessToken(){return e.config.ACCESS_TOKEN},set accessToken(t){e.config.ACCESS_TOKEN=t},get baseApiUrl(){return e.config.API_URL},set baseApiUrl(t){e.config.API_URL=t},get workerCount(){return je.workerCount},set workerCount(e){je.workerCount=e},get maxParallelImageRequests(){return e.config.MAX_PARALLEL_IMAGE_REQUESTS},set maxParallelImageRequests(t){e.config.MAX_PARALLEL_IMAGE_REQUESTS=t},clearStorage(t){e.clearTileCache(t)},workerUrl:"",workerClass:null,setNow:e.exported.setNow,restoreNow:e.exported.restoreNow};return po})),r}()}).call(this,n(26))},function(e,t,n){"use strict";n(47);var r=n(0),i=n(15),o=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,a=Object(i.a)((function(e){return o.test(e)||111===e.charCodeAt(0)&&110===e.charCodeAt(1)&&e.charCodeAt(2)<91}));function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var t=1;t96?d:f},m=function(e,t,n){var r;if(t){var i=t.shouldForwardProp;r=e.__emotion_forwardProp&&i?function(t){return e.__emotion_forwardProp(t)&&i(t)}:i}return"function"!=typeof r&&n&&(r=e.__emotion_forwardProp),r},_=function(e){var t=e.cache,n=e.serialized,r=e.isStringTag;Object(u.c)(t,n,r);Object(h.a)((function(){return Object(u.b)(t,n,r)}));return null},g=function e(t,n){var i,o,a=t.__emotion_real===t,h=a&&t.__emotion_base||t;void 0!==n&&(i=n.label,o=n.target);var d=m(t,n,a),f=d||p(h),g=!f("as");return function(){var y=arguments,v=a&&void 0!==t.__emotion_styles?t.__emotion_styles.slice(0):[];if(void 0!==i&&v.push("label:"+i+";"),null==y[0]||void 0===y[0].raw)v.push.apply(v,y);else{0,v.push(y[0][0]);for(var x=y.length,b=1;b1?t-1:0),r=1;re.length)&&(t=e.length);for(var n=0,r=new Array(t);n=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var N=Symbol("mobx-stored-annotations");function U(e){return Object.assign((function(t,n){V(t,n,e)}),e)}function V(e,t,n){I(e,N)||w(e,N,D({},e[N])),function(e){return"override"===e.annotationType_}(n)||(e[N][t]=n)}var G=Symbol("mobx administration"),q=function(){function e(e){void 0===e&&(e="Atom"),this.name_=void 0,this.isPendingUnobservation_=!1,this.isBeingObserved_=!1,this.observers_=new Set,this.diffValue_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ue.NOT_TRACKING_,this.onBOL=void 0,this.onBUOL=void 0,this.name_=e}var t=e.prototype;return t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.reportObserved=function(){return dt(this)},t.reportChanged=function(){ct(),ft(this),ht()},t.toString=function(){return this.name_},e}(),$=T("Atom",q);function Z(e,t,n){void 0===t&&(t=_),void 0===n&&(n=_);var r,i=new q(e);return t!==_&&Pt("onBO",i,t,r),n!==_&&It(i,n),i}var W={identity:function(e,t){return e===t},structural:function(e,t){return qn(e,t)},default:function(e,t){return Object.is?Object.is(e,t):e===t?0!==e||1/e==1/t:e!=e&&t!=t},shallow:function(e,t){return qn(e,t,1)}};function X(e,t,n){return Ut(e)?e:Array.isArray(e)?Se.array(e,{name:n}):x(e)?Se.object(e,void 0,{name:n}):S(e)?Se.map(e,{name:n}):k(e)?Se.set(e,{name:n}):"function"!=typeof e||kt(e)||jt(e)?e:b(e)?Bt(e):St(n,e)}function H(e){return e}function Y(e,t){return{annotationType_:e,options_:t,make_:K,extend_:J}}function K(e,t,n,r){var i;if(null!=(i=this.options_)&&i.bound)return null===this.extend_(e,t,n,!1)?0:1;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(kt(n.value))return 1;var o=Q(e,this,t,n,!1);return l(r,t,o),2}function J(e,t,n,r){var i=Q(e,this,t,n);return e.defineProperty_(t,i,r)}function Q(e,t,n,r,i){var o,a,s,l,u,c,h,d;void 0===i&&(i=at.safeDescriptors),d=r,t.annotationType_,d.value;var f,p=r.value;null!=(o=t.options_)&&o.bound&&(p=p.bind(null!=(f=e.proxy_)?f:e.target_));return{value:De(null!=(a=null==(s=t.options_)?void 0:s.name)?a:n.toString(),p,null!=(l=null==(u=t.options_)?void 0:u.autoAction)&&l,null!=(c=t.options_)&&c.bound?null!=(h=e.proxy_)?h:e.target_:void 0),configurable:!i||e.isPlainObject_,enumerable:!1,writable:!i}}function ee(e,t){return{annotationType_:e,options_:t,make_:te,extend_:ne}}function te(e,t,n,r){var i;if(r===e.target_)return null===this.extend_(e,t,n,!1)?0:2;if(null!=(i=this.options_)&&i.bound&&(!I(e.target_,t)||!jt(e.target_[t]))&&null===this.extend_(e,t,n,!1))return 0;if(jt(n.value))return 1;var o=re(e,this,t,n,!1,!1);return l(r,t,o),2}function ne(e,t,n,r){var i,o=re(e,this,t,n,null==(i=this.options_)?void 0:i.bound);return e.defineProperty_(t,o,r)}function re(e,t,n,r,i,o){var a;void 0===o&&(o=at.safeDescriptors),a=r,t.annotationType_,a.value;var s,l=r.value;(jt(l)||(l=Bt(l)),i)&&((l=l.bind(null!=(s=e.proxy_)?s:e.target_)).isMobXFlow=!0);return{value:l,configurable:!o||e.isPlainObject_,enumerable:!1,writable:!o}}function ie(e,t){return{annotationType_:e,options_:t,make_:oe,extend_:ae}}function oe(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ae(e,t,n,r){return function(e,t,n,r){t.annotationType_,r.get;0}(0,this,0,n),e.defineComputedProperty_(t,D({},this.options_,{get:n.get,set:n.set}),r)}function se(e,t){return{annotationType_:e,options_:t,make_:le,extend_:ue}}function le(e,t,n){return null===this.extend_(e,t,n,!1)?0:1}function ue(e,t,n,r){var i,o;return function(e,t,n,r){t.annotationType_;0}(0,this),e.defineObservableProperty_(t,n.value,null!=(i=null==(o=this.options_)?void 0:o.enhancer)?i:X,r)}var ce=he();function he(e){return{annotationType_:"true",options_:e,make_:de,extend_:fe}}function de(e,t,n,r){var i,o,a,s;if(n.get)return Me.make_(e,t,n,r);if(n.set){var u=De(t.toString(),n.set);return r===e.target_?null===e.defineProperty_(t,{configurable:!at.safeDescriptors||e.isPlainObject_,set:u})?0:2:(l(r,t,{configurable:!0,set:u}),2)}if(r!==e.target_&&"function"==typeof n.value)return b(n.value)?(null!=(s=this.options_)&&s.autoBind?Bt.bound:Bt).make_(e,t,n,r):(null!=(a=this.options_)&&a.autoBind?St.bound:St).make_(e,t,n,r);var c,h=!1===(null==(i=this.options_)?void 0:i.deep)?Se.ref:Se;"function"==typeof n.value&&null!=(o=this.options_)&&o.autoBind&&(n.value=n.value.bind(null!=(c=e.proxy_)?c:e.target_));return h.make_(e,t,n,r)}function fe(e,t,n,r){var i,o,a;if(n.get)return Me.extend_(e,t,n,r);if(n.set)return e.defineProperty_(t,{configurable:!at.safeDescriptors||e.isPlainObject_,set:De(t.toString(),n.set)},r);"function"==typeof n.value&&null!=(i=this.options_)&&i.autoBind&&(n.value=n.value.bind(null!=(a=e.proxy_)?a:e.target_));return(!1===(null==(o=this.options_)?void 0:o.deep)?Se.ref:Se).extend_(e,t,n,r)}var pe={deep:!0,name:void 0,defaultDecorator:void 0,proxy:!0};function me(e){return e||pe}Object.freeze(pe);var _e=se("observable"),ge=se("observable.ref",{enhancer:H}),ye=se("observable.shallow",{enhancer:function(e,t,n){return null==e||Cn(e)||dn(e)||yn(e)||bn(e)?e:Array.isArray(e)?Se.array(e,{name:n,deep:!1}):x(e)?Se.object(e,void 0,{name:n,deep:!1}):S(e)?Se.map(e,{name:n,deep:!1}):k(e)?Se.set(e,{name:n,deep:!1}):void 0}}),ve=se("observable.struct",{enhancer:function(e,t){return qn(e,t)?t:e}}),xe=U(_e);function be(e){return!0===e.deep?X:!1===e.deep?H:(t=e.defaultDecorator)&&null!=(n=null==(r=t.options_)?void 0:r.enhancer)?n:X;var t,n,r}function we(e,t,n){if(!y(t))return Ut(e)?e:x(e)?Se.object(e,t,n):Array.isArray(e)?Se.array(e,t):S(e)?Se.map(e,t):k(e)?Se.set(e,t):"object"==typeof e&&null!==e?e:Se.box(e,t);V(e,t,_e)}a(we,xe);var Ee,Te,Se=a(we,{box:function(e,t){var n=me(t);return new Ne(e,be(n),n.name,!0,n.equals)},array:function(e,t){var n=me(t);return(!1===at.useProxies||!1===n.proxy?jn:nn)(e,be(n),n.name)},map:function(e,t){var n=me(t);return new gn(e,be(n),n.name)},set:function(e,t){var n=me(t);return new xn(e,be(n),n.name)},object:function(e,t,n){return zt(!1===at.useProxies||!1===(null==n?void 0:n.proxy)?Tn({},n):function(e,t){var n,r;return p(),e=Tn(e,t),null!=(r=(n=e[G]).proxy_)?r:n.proxy_=new Proxy(e,$t)}({},n),e,t)},ref:U(ge),shallow:U(ye),deep:xe,struct:U(ve)}),ke=ie("computed"),Ce=ie("computed.struct",{equals:W.structural}),Me=function(e,t){if(y(t))return V(e,t,ke);if(x(e))return U(ie("computed",e));var n=x(t)?t:{};return n.get=e,n.name||(n.name=e.name||""),new Ge(n)};Object.assign(Me,ke),Me.struct=U(Ce);var Ae,Ie=0,Pe=1,ze=null!=(Ee=null==(Te=s((function(){}),"name"))?void 0:Te.configurable)&&Ee,Oe={value:"action",configurable:!0,writable:!1,enumerable:!1};function De(e,t,n,r){function i(){return Le(e,n,t,r||this,arguments)}return void 0===n&&(n=!1),i.isMobxAction=!0,ze&&(Oe.value=e,l(i,"name",Oe)),i}function Le(e,t,n,i,o){var a=function(e,t,n,r){0;var i=at.trackingDerivation,o=!t||!i;ct();var a=at.allowStateChanges;o&&(Je(),a=Be(!0));var s=et(!0),l={runAsAction_:o,prevDerivation_:i,prevAllowStateChanges_:a,prevAllowStateReads_:s,notifySpy_:!1,startTime_:0,actionId_:Pe++,parentActionId_:Ie};return Ie=l.actionId_,l}(0,t);try{return n.apply(i,o)}catch(e){throw a.error_=e,e}finally{!function(e){Ie!==e.actionId_&&r(30);Ie=e.parentActionId_,void 0!==e.error_&&(at.suppressReactionErrors=!0);Fe(e.prevAllowStateChanges_),tt(e.prevAllowStateReads_),ht(),e.runAsAction_&&Qe(e.prevDerivation_);0;at.suppressReactionErrors=!1}(a)}}function Re(e,t){var n=Be(e);try{return t()}finally{Fe(n)}}function Be(e){var t=at.allowStateChanges;return at.allowStateChanges=e,t}function Fe(e){at.allowStateChanges=e}Ae=Symbol.toPrimitive;var je,Ne=function(e){function t(t,n,r,i,o){var a;return void 0===r&&(r="ObservableValue"),void 0===i&&(i=!0),void 0===o&&(o=W.default),(a=e.call(this,r)||this).enhancer=void 0,a.name_=void 0,a.equals=void 0,a.hasUnreportedChange_=!1,a.interceptors_=void 0,a.changeListeners_=void 0,a.value_=void 0,a.dehancer=void 0,a.enhancer=n,a.name_=r,a.equals=o,a.value_=n(t,void 0,r),a}L(t,e);var n=t.prototype;return n.dehanceValue=function(e){return void 0!==this.dehancer?this.dehancer(e):e},n.set=function(e){this.value_;if((e=this.prepareNewValue_(e))!==at.UNCHANGED){0,this.setNewValue_(e)}},n.prepareNewValue_=function(e){if(Xe(this),Zt(this)){var t=Xt(this,{object:this,type:Qt,newValue:e});if(!t)return at.UNCHANGED;e=t.newValue}return e=this.enhancer(e,this.value_,this.name_),this.equals(this.value_,e)?at.UNCHANGED:e},n.setNewValue_=function(e){var t=this.value_;this.value_=e,this.reportChanged(),Ht(this)&&Kt(this,{type:Qt,object:this,newValue:e,oldValue:t})},n.get=function(){return this.reportObserved(),this.dehanceValue(this.value_)},n.intercept_=function(e){return Wt(this,e)},n.observe_=function(e,t){return t&&e({observableKind:"value",debugObjectName:this.name_,object:this,type:Qt,newValue:this.value_,oldValue:void 0}),Yt(this,e)},n.raw=function(){return this.value_},n.toJSON=function(){return this.get()},n.toString=function(){return this.name_+"["+this.value_+"]"},n.valueOf=function(){return A(this.get())},n[Ae]=function(){return this.valueOf()},t}(q);je=Symbol.toPrimitive;var Ue,Ve,Ge=function(){function e(e){this.dependenciesState_=Ue.NOT_TRACKING_,this.observing_=[],this.newObserving_=null,this.isBeingObserved_=!1,this.isPendingUnobservation_=!1,this.observers_=new Set,this.diffValue_=0,this.runId_=0,this.lastAccessedBy_=0,this.lowestObserverState_=Ue.UP_TO_DATE_,this.unboundDepsCount_=0,this.value_=new $e(null),this.name_=void 0,this.triggeredBy_=void 0,this.isComputing_=!1,this.isRunningSetter_=!1,this.derivation=void 0,this.setter_=void 0,this.isTracing_=Ve.NONE,this.scope_=void 0,this.equals_=void 0,this.requiresReaction_=void 0,this.keepAlive_=void 0,this.onBOL=void 0,this.onBUOL=void 0,e.get||r(31),this.derivation=e.get,this.name_=e.name||"ComputedValue",e.set&&(this.setter_=De("ComputedValue-setter",e.set)),this.equals_=e.equals||(e.compareStructural||e.struct?W.structural:W.default),this.scope_=e.context,this.requiresReaction_=e.requiresReaction,this.keepAlive_=!!e.keepAlive}var t=e.prototype;return t.onBecomeStale_=function(){!function(e){if(e.lowestObserverState_!==Ue.UP_TO_DATE_)return;e.lowestObserverState_=Ue.POSSIBLY_STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ue.UP_TO_DATE_&&(e.dependenciesState_=Ue.POSSIBLY_STALE_,e.onBecomeStale_())}))}(this)},t.onBO=function(){this.onBOL&&this.onBOL.forEach((function(e){return e()}))},t.onBUO=function(){this.onBUOL&&this.onBUOL.forEach((function(e){return e()}))},t.get=function(){if(this.isComputing_&&r(32,this.name_,this.derivation),0!==at.inBatch||0!==this.observers_.size||this.keepAlive_){if(dt(this),We(this)){var e=at.trackingContext;this.keepAlive_&&!e&&(at.trackingContext=this),this.trackAndCompute()&&function(e){if(e.lowestObserverState_===Ue.STALE_)return;e.lowestObserverState_=Ue.STALE_,e.observers_.forEach((function(t){t.dependenciesState_===Ue.POSSIBLY_STALE_?t.dependenciesState_=Ue.STALE_:t.dependenciesState_===Ue.UP_TO_DATE_&&(e.lowestObserverState_=Ue.UP_TO_DATE_)}))}(this),at.trackingContext=e}}else We(this)&&(this.warnAboutUntrackedRead_(),ct(),this.value_=this.computeValue_(!1),ht());var t=this.value_;if(Ze(t))throw t.cause;return t},t.set=function(e){if(this.setter_){this.isRunningSetter_&&r(33,this.name_),this.isRunningSetter_=!0;try{this.setter_.call(this.scope_,e)}finally{this.isRunningSetter_=!1}}else r(34,this.name_)},t.trackAndCompute=function(){var e=this.value_,t=this.dependenciesState_===Ue.NOT_TRACKING_,n=this.computeValue_(!0),r=t||Ze(e)||Ze(n)||!this.equals_(e,n);return r&&(this.value_=n),r},t.computeValue_=function(e){this.isComputing_=!0;var t,n=Be(!1);if(e)t=He(this,this.derivation,this.scope_);else if(!0===at.disableErrorBoundaries)t=this.derivation.call(this.scope_);else try{t=this.derivation.call(this.scope_)}catch(e){t=new $e(e)}return Fe(n),this.isComputing_=!1,t},t.suspend_=function(){this.keepAlive_||(Ye(this),this.value_=void 0)},t.observe_=function(e,t){var n=this,r=!0,i=void 0;return Ct((function(){var o=n.get();if(!r||t){var a=Je();e({observableKind:"computed",debugObjectName:n.name_,type:Qt,object:n,newValue:o,oldValue:i}),Qe(a)}r=!1,i=o}))},t.warnAboutUntrackedRead_=function(){},t.toString=function(){return this.name_+"["+this.derivation.toString()+"]"},t.valueOf=function(){return A(this.get())},t[je]=function(){return this.valueOf()},e}(),qe=T("ComputedValue",Ge);!function(e){e[e.NOT_TRACKING_=-1]="NOT_TRACKING_",e[e.UP_TO_DATE_=0]="UP_TO_DATE_",e[e.POSSIBLY_STALE_=1]="POSSIBLY_STALE_",e[e.STALE_=2]="STALE_"}(Ue||(Ue={})),function(e){e[e.NONE=0]="NONE",e[e.LOG=1]="LOG",e[e.BREAK=2]="BREAK"}(Ve||(Ve={}));var $e=function(e){this.cause=void 0,this.cause=e};function Ze(e){return e instanceof $e}function We(e){switch(e.dependenciesState_){case Ue.UP_TO_DATE_:return!1;case Ue.NOT_TRACKING_:case Ue.STALE_:return!0;case Ue.POSSIBLY_STALE_:for(var t=et(!0),n=Je(),r=e.observing_,i=r.length,o=0;or&&(r=s.dependenciesState_)}n.length=i,e.newObserving_=null,o=t.length;for(;o--;){var l=t[o];0===l.diffValue_&<(l,e),l.diffValue_=0}for(;i--;){var u=n[i];1===u.diffValue_&&(u.diffValue_=0,st(u,e))}r!==Ue.UP_TO_DATE_&&(e.dependenciesState_=r,e.onBecomeStale_())}(e),tt(r),i}function Ye(e){var t=e.observing_;e.observing_=[];for(var n=t.length;n--;)lt(t[n],e);e.dependenciesState_=Ue.NOT_TRACKING_}function Ke(e){var t=Je();try{return e()}finally{Qe(t)}}function Je(){var e=at.trackingDerivation;return at.trackingDerivation=null,e}function Qe(e){at.trackingDerivation=e}function et(e){var t=at.allowStateReads;return at.allowStateReads=e,t}function tt(e){at.allowStateReads=e}function nt(e){if(e.dependenciesState_!==Ue.UP_TO_DATE_){e.dependenciesState_=Ue.UP_TO_DATE_;for(var t=e.observing_,n=t.length;n--;)t[n].lowestObserverState_=Ue.UP_TO_DATE_}}var rt=function(){this.version=6,this.UNCHANGED={},this.trackingDerivation=null,this.trackingContext=null,this.runId=0,this.mobxGuid=0,this.inBatch=0,this.pendingUnobservations=[],this.pendingReactions=[],this.isRunningReactions=!1,this.allowStateChanges=!1,this.allowStateReads=!0,this.enforceActions=!0,this.spyListeners=[],this.globalReactionErrorHandlers=[],this.computedRequiresReaction=!1,this.reactionRequiresObservable=!1,this.observableRequiresReaction=!1,this.disableErrorBoundaries=!1,this.suppressReactionErrors=!1,this.useProxies=!0,this.verifyProxies=!1,this.safeDescriptors=!0},it=!0,ot=!1,at=function(){var e=o();return e.__mobxInstanceCount>0&&!e.__mobxGlobals&&(it=!1),e.__mobxGlobals&&e.__mobxGlobals.version!==(new rt).version&&(it=!1),it?e.__mobxGlobals?(e.__mobxInstanceCount+=1,e.__mobxGlobals.UNCHANGED||(e.__mobxGlobals.UNCHANGED={}),e.__mobxGlobals):(e.__mobxInstanceCount=1,e.__mobxGlobals=new rt):(setTimeout((function(){ot||r(35)}),1),new rt)}();function st(e,t){e.observers_.add(t),e.lowestObserverState_>t.dependenciesState_&&(e.lowestObserverState_=t.dependenciesState_)}function lt(e,t){e.observers_.delete(t),0===e.observers_.size&&ut(e)}function ut(e){!1===e.isPendingUnobservation_&&(e.isPendingUnobservation_=!0,at.pendingUnobservations.push(e))}function ct(){at.inBatch++}function ht(){if(0==--at.inBatch){_t();for(var e=at.pendingUnobservations,t=0;t0&&ut(e),!1)}function ft(e){e.lowestObserverState_!==Ue.STALE_&&(e.lowestObserverState_=Ue.STALE_,e.observers_.forEach((function(e){e.dependenciesState_===Ue.UP_TO_DATE_&&e.onBecomeStale_(),e.dependenciesState_=Ue.STALE_})))}var pt=function(){function e(e,t,n,r){void 0===e&&(e="Reaction"),this.name_=void 0,this.onInvalidate_=void 0,this.errorHandler_=void 0,this.requiresObservable_=void 0,this.observing_=[],this.newObserving_=[],this.dependenciesState_=Ue.NOT_TRACKING_,this.diffValue_=0,this.runId_=0,this.unboundDepsCount_=0,this.isDisposed_=!1,this.isScheduled_=!1,this.isTrackPending_=!1,this.isRunning_=!1,this.isTracing_=Ve.NONE,this.name_=e,this.onInvalidate_=t,this.errorHandler_=n,this.requiresObservable_=r}var t=e.prototype;return t.onBecomeStale_=function(){this.schedule_()},t.schedule_=function(){this.isScheduled_||(this.isScheduled_=!0,at.pendingReactions.push(this),_t())},t.isScheduled=function(){return this.isScheduled_},t.runReaction_=function(){if(!this.isDisposed_){ct(),this.isScheduled_=!1;var e=at.trackingContext;if(at.trackingContext=this,We(this)){this.isTrackPending_=!0;try{this.onInvalidate_()}catch(e){this.reportExceptionInDerivation_(e)}}at.trackingContext=e,ht()}},t.track=function(e){if(!this.isDisposed_){ct();0,this.isRunning_=!0;var t=at.trackingContext;at.trackingContext=this;var n=He(this,e,void 0);at.trackingContext=t,this.isRunning_=!1,this.isTrackPending_=!1,this.isDisposed_&&Ye(this),Ze(n)&&this.reportExceptionInDerivation_(n.cause),ht()}},t.reportExceptionInDerivation_=function(e){var t=this;if(this.errorHandler_)this.errorHandler_(e,this);else{if(at.disableErrorBoundaries)throw e;var n="[mobx] uncaught error in '"+this+"'";at.suppressReactionErrors||console.error(n,e),at.globalReactionErrorHandlers.forEach((function(n){return n(e,t)}))}},t.dispose=function(){this.isDisposed_||(this.isDisposed_=!0,this.isRunning_||(ct(),Ye(this),ht()))},t.getDisposer_=function(){var e=this.dispose.bind(this);return e[G]=this,e},t.toString=function(){return"Reaction["+this.name_+"]"},t.trace=function(e){void 0===e&&(e=!1),function(){r("trace() is not available in production builds");for(var e=!1,t=arguments.length,n=new Array(t),i=0;i0||at.isRunningReactions||mt(gt)}function gt(){at.isRunningReactions=!0;for(var e=at.pendingReactions,t=0;e.length>0;){100==++t&&(console.error("[mobx] cycle in reaction: "+e[0]),e.splice(0));for(var n=e.splice(0),r=0,i=n.length;r",t,e):g(n)?De(t,n,e):y(n)?V(t,n,e?bt:vt):y(t)?U(Y(e?"autoAction":"action",{name:t,autoAction:e})):void 0}}var Tt=Et(!1);Object.assign(Tt,vt);var St=Et(!0);function kt(e){return g(e)&&!0===e.isMobxAction}function Ct(e,t){var n,r;void 0===t&&(t=h);var i,o=null!=(n=null==(r=t)?void 0:r.name)?n:"Autorun";if(!t.scheduler&&!t.delay)i=new pt(o,(function(){this.track(l)}),t.onError,t.requiresObservable);else{var a=At(t),s=!1;i=new pt(o,(function(){s||(s=!0,a((function(){s=!1,i.isDisposed_||i.track(l)})))}),t.onError,t.requiresObservable)}function l(){e(i)}return i.schedule_(),i.getDisposer_()}Object.assign(St,bt),Tt.bound=U(xt),St.bound=U(wt);var Mt=function(e){return e()};function At(e){return e.scheduler?e.scheduler:e.delay?function(t){return setTimeout(t,e.delay)}:Mt}function It(e,t,n){return Pt("onBUO",e,t,n)}function Pt(e,t,n,r){var i="function"==typeof r?Nn(t,n):Nn(t),o=g(r)?r:n,a=e+"L";return i[a]?i[a].add(o):i[a]=new Set([o]),function(){var e=i[a];e&&(e.delete(o),0===e.size&&delete i[a])}}function zt(e,t,n,r){var i=P(t),o=Tn(e,r)[G];ct();try{M(i).forEach((function(e){o.extend_(e,i[e],!n||(!(e in n)||n[e]))}))}finally{ht()}return e}var Ot=0;function Dt(){this.message="FLOW_CANCELLED"}Dt.prototype=Object.create(Error.prototype);var Lt=ee("flow"),Rt=ee("flow.bound",{bound:!0}),Bt=Object.assign((function(e,t){if(y(t))return V(e,t,Lt);var n=e,r=n.name||"",i=function(){var e,t=this,i=arguments,o=++Ot,a=Tt(r+" - runid: "+o+" - init",n).apply(t,i),s=void 0,l=new Promise((function(t,n){var i=0;function l(e){var t;s=void 0;try{t=Tt(r+" - runid: "+o+" - yield "+i++,a.next).call(a,e)}catch(e){return n(e)}c(t)}function u(e){var t;s=void 0;try{t=Tt(r+" - runid: "+o+" - yield "+i++,a.throw).call(a,e)}catch(e){return n(e)}c(t)}function c(e){if(!g(null==e?void 0:e.then))return e.done?t(e.value):(s=Promise.resolve(e.value)).then(l,u);e.then(c,n)}e=n,l(void 0)}));return l.cancel=Tt(r+" - runid: "+o+" - cancel",(function(){try{s&&Ft(s);var t=a.return(void 0),n=Promise.resolve(t.value);n.then(_,_),Ft(n),e(new Dt)}catch(t){e(t)}})),l};return i.isMobXFlow=!0,i}),Lt);function Ft(e){g(e.cancel)&&e.cancel()}function jt(e){return!0===(null==e?void 0:e.isMobXFlow)}function Nt(e,t){return!!e&&(void 0!==t?!!Cn(e)&&e[G].values_.has(t):Cn(e)||!!e[G]||$(e)||yt(e)||qe(e))}function Ut(e){return Nt(e)}function Vt(e){switch(e.length){case 0:return at.trackingDerivation;case 1:return Nn(e[0]);case 2:return Nn(e[0],e[1])}}function Gt(e,t){void 0===t&&(t=void 0),ct();try{return e.apply(t)}finally{ht()}}function qt(e){return e[G]}Bt.bound=U(Rt);var $t={has:function(e,t){return qt(e).has_(t)},get:function(e,t){return qt(e).get_(t)},set:function(e,t,n){var r;return!!y(t)&&(null==(r=qt(e).set_(t,n,!0))||r)},deleteProperty:function(e,t){var n;return!!y(t)&&(null==(n=qt(e).delete_(t,!0))||n)},defineProperty:function(e,t,n){var r;return null==(r=qt(e).defineProperty_(t,n))||r},ownKeys:function(e){return qt(e).ownKeys_()},preventExtensions:function(e){r(13)}};function Zt(e){return void 0!==e.interceptors_&&e.interceptors_.length>0}function Wt(e,t){var n=e.interceptors_||(e.interceptors_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Xt(e,t){var n=Je();try{for(var i=[].concat(e.interceptors_||[]),o=0,a=i.length;o0}function Yt(e,t){var n=e.changeListeners_||(e.changeListeners_=[]);return n.push(t),m((function(){var e=n.indexOf(t);-1!==e&&n.splice(e,1)}))}function Kt(e,t){var n=Je(),r=e.changeListeners_;if(r){for(var i=0,o=(r=r.slice()).length;i0?e.map(this.dehancer):e},t.intercept_=function(e){return Wt(this,e)},t.observe_=function(e,t){return void 0===t&&(t=!1),t&&e({observableKind:"array",object:this.proxy_,debugObjectName:this.atom_.name_,type:"splice",index:0,added:this.values_.slice(),addedCount:this.values_.length,removed:[],removedCount:0}),Yt(this,e)},t.getArrayLength_=function(){return this.atom_.reportObserved(),this.values_.length},t.setArrayLength_=function(e){("number"!=typeof e||isNaN(e)||e<0)&&r("Out of range: "+e);var t=this.values_.length;if(e!==t)if(e>t){for(var n=new Array(e-t),i=0;i0&&Fn(e+t+1)},t.spliceWithArray_=function(e,t,n){var r=this;this.atom_;var i=this.values_.length;if(void 0===e?e=0:e>i?e=i:e<0&&(e=Math.max(0,i+e)),t=1===arguments.length?i-e:null==t?0:Math.max(0,Math.min(t,i-e)),void 0===n&&(n=c),Zt(this)){var o=Xt(this,{object:this.proxy_,type:"splice",index:e,removedCount:t,added:n});if(!o)return c;t=o.removedCount,n=o.added}if(n=0===n.length?n:n.map((function(e){return r.enhancer_(e,void 0)})),this.legacyMode_){var a=n.length-t;this.updateArrayLength_(i,a)}var s=this.spliceItemsIntoValues_(e,t,n);return 0===t&&0===n.length||this.notifyArraySplice_(e,n,s),this.dehanceValues_(s)},t.spliceItemsIntoValues_=function(e,t,n){var r;if(n.length<1e4)return(r=this.values_).splice.apply(r,[e,t].concat(n));var i=this.values_.slice(e,e+t),o=this.values_.slice(e+t);this.values_.length+=n.length-t;for(var a=0;a=this.values_.length))return this.atom_.reportObserved(),this.dehanceValue_(this.values_[e]);console.warn("[mobx] Out of bounds read: "+e)},t.set_=function(e,t){var n=this.values_;if(this.legacyMode_&&e>n.length&&r(17,e,n.length),e2?n-2:0),i=2;i-1&&(this.splice(n,1),!0)}};function on(e,t){"function"==typeof Array.prototype[e]&&(rn[e]=t(e))}function an(e){return function(){var t=this[G];t.atom_.reportObserved();var n=t.dehanceValues_(t.values_);return n[e].apply(n,arguments)}}function sn(e){return function(t,n){var r=this,i=this[G];return i.atom_.reportObserved(),i.dehanceValues_(i.values_)[e]((function(e,i){return t.call(n,e,i,r)}))}}function ln(e){return function(){var t=this,n=this[G];n.atom_.reportObserved();var r=n.dehanceValues_(n.values_),i=arguments[0];return arguments[0]=function(e,n,r){return i(e,n,r,t)},r[e].apply(r,arguments)}}on("concat",an),on("flat",an),on("includes",an),on("indexOf",an),on("join",an),on("lastIndexOf",an),on("slice",an),on("toString",an),on("toLocaleString",an),on("every",sn),on("filter",sn),on("find",sn),on("findIndex",sn),on("flatMap",sn),on("forEach",sn),on("map",sn),on("some",sn),on("reduce",ln),on("reduceRight",ln);var un,cn,hn=T("ObservableArrayAdministration",tn);function dn(e){return v(e)&&hn(e[G])}var fn={},pn="add";un=Symbol.iterator,cn=Symbol.toStringTag;var mn,_n,gn=function(){function e(e,t,n){var i=this;void 0===t&&(t=X),void 0===n&&(n="ObservableMap"),this.enhancer_=void 0,this.name_=void 0,this[G]=fn,this.data_=void 0,this.hasMap_=void 0,this.keysAtom_=void 0,this.interceptors_=void 0,this.changeListeners_=void 0,this.dehancer=void 0,this.enhancer_=t,this.name_=n,g(Map)||r(18),this.keysAtom_=Z("ObservableMap.keys()"),this.data_=new Map,this.hasMap_=new Map,Re(!0,(function(){i.merge(e)}))}var t=e.prototype;return t.has_=function(e){return this.data_.has(e)},t.has=function(e){var t=this;if(!at.trackingDerivation)return this.has_(e);var n=this.hasMap_.get(e);if(!n){var r=n=new Ne(this.has_(e),H,"ObservableMap.key?",!1);this.hasMap_.set(e,r),It(r,(function(){return t.hasMap_.delete(e)}))}return n.get()},t.set=function(e,t){var n=this.has_(e);if(Zt(this)){var r=Xt(this,{type:n?Qt:pn,object:this,newValue:t,name:e});if(!r)return this;t=r.newValue}return n?this.updateValue_(e,t):this.addValue_(e,t),this},t.delete=function(e){var t=this;if((this.keysAtom_,Zt(this))&&!Xt(this,{type:"delete",object:this,name:e}))return!1;if(this.has_(e)){var n=Ht(this),r=n?{observableKind:"map",debugObjectName:this.name_,type:"delete",object:this,oldValue:this.data_.get(e).value_,name:e}:null;return Gt((function(){var n;t.keysAtom_.reportChanged(),null==(n=t.hasMap_.get(e))||n.setNewValue_(!1),t.data_.get(e).setNewValue_(void 0),t.data_.delete(e)})),n&&Kt(this,r),!0}return!1},t.updateValue_=function(e,t){var n=this.data_.get(e);if((t=n.prepareNewValue_(t))!==at.UNCHANGED){var r=Ht(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:Qt,object:this,oldValue:n.value_,name:e,newValue:t}:null;0,n.setNewValue_(t),r&&Kt(this,i)}},t.addValue_=function(e,t){var n=this;this.keysAtom_,Gt((function(){var r,i=new Ne(t,n.enhancer_,"ObservableMap.key",!1);n.data_.set(e,i),t=i.value_,null==(r=n.hasMap_.get(e))||r.setNewValue_(!0),n.keysAtom_.reportChanged()}));var r=Ht(this),i=r?{observableKind:"map",debugObjectName:this.name_,type:pn,object:this,name:e,newValue:t}:null;r&&Kt(this,i)},t.get=function(e){return this.has(e)?this.dehanceValue_(this.data_.get(e).get()):this.dehanceValue_(void 0)},t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.keys=function(){return this.keysAtom_.reportObserved(),this.data_.keys()},t.values=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:e.get(i)}}})},t.entries=function(){var e=this,t=this.keys();return Zn({next:function(){var n=t.next(),r=n.done,i=n.value;return{done:r,value:r?void 0:[i,e.get(i)]}}})},t[un]=function(){return this.entries()},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value,o=i[0],a=i[1];e.call(t,a,o,this)}},t.merge=function(e){var t=this;return yn(e)&&(e=new Map(e)),Gt((function(){x(e)?function(e){var t=Object.keys(e);if(!C)return t;var n=Object.getOwnPropertySymbols(e);return n.length?[].concat(t,n.filter((function(t){return u.propertyIsEnumerable.call(e,t)}))):t}(e).forEach((function(n){return t.set(n,e[n])})):Array.isArray(e)?e.forEach((function(e){var n=e[0],r=e[1];return t.set(n,r)})):S(e)?(e.constructor!==Map&&r(19,e),e.forEach((function(e,n){return t.set(n,e)}))):null!=e&&r(20,e)})),this},t.clear=function(){var e=this;Gt((function(){Ke((function(){for(var t,n=j(e.keys());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.replace=function(e){var t=this;return Gt((function(){for(var n,i=function(e){if(S(e)||yn(e))return e;if(Array.isArray(e))return new Map(e);if(x(e)){var t=new Map;for(var n in e)t.set(n,e[n]);return t}return r(21,e)}(e),o=new Map,a=!1,s=j(t.data_.keys());!(n=s()).done;){var l=n.value;if(!i.has(l))if(t.delete(l))a=!0;else{var u=t.data_.get(l);o.set(l,u)}}for(var c,h=j(i.entries());!(c=h()).done;){var d=c.value,f=d[0],p=d[1],m=t.data_.has(f);if(t.set(f,p),t.data_.has(f)){var _=t.data_.get(f);o.set(f,_),m||(a=!0)}}if(!a)if(t.data_.size!==o.size)t.keysAtom_.reportChanged();else for(var g=t.data_.keys(),y=o.keys(),v=g.next(),b=y.next();!v.done;){if(v.value!==b.value){t.keysAtom_.reportChanged();break}v=g.next(),b=y.next()}t.data_=o})),this},t.toString=function(){return"[object ObservableMap]"},t.toJSON=function(){return Array.from(this)},t.observe_=function(e,t){return Yt(this,e)},t.intercept_=function(e){return Wt(this,e)},O(e,[{key:"size",get:function(){return this.keysAtom_.reportObserved(),this.data_.size}},{key:cn,get:function(){return"Map"}}]),e}(),yn=T("ObservableMap",gn);var vn={};mn=Symbol.iterator,_n=Symbol.toStringTag;var xn=function(){function e(e,t,n){void 0===t&&(t=X),void 0===n&&(n="ObservableSet"),this.name_=void 0,this[G]=vn,this.data_=new Set,this.atom_=void 0,this.changeListeners_=void 0,this.interceptors_=void 0,this.dehancer=void 0,this.enhancer_=void 0,this.name_=n,g(Set)||r(22),this.atom_=Z(this.name_),this.enhancer_=function(e,r){return t(e,r,n)},e&&this.replace(e)}var t=e.prototype;return t.dehanceValue_=function(e){return void 0!==this.dehancer?this.dehancer(e):e},t.clear=function(){var e=this;Gt((function(){Ke((function(){for(var t,n=j(e.data_.values());!(t=n()).done;){var r=t.value;e.delete(r)}}))}))},t.forEach=function(e,t){for(var n,r=j(this);!(n=r()).done;){var i=n.value;e.call(t,i,i,this)}},t.add=function(e){var t=this;if((this.atom_,Zt(this))&&!Xt(this,{type:pn,object:this,newValue:e}))return this;if(!this.has(e)){Gt((function(){t.data_.add(t.enhancer_(e,void 0)),t.atom_.reportChanged()}));var n=Ht(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:pn,object:this,newValue:e}:null;0,n&&Kt(this,r)}return this},t.delete=function(e){var t=this;if(Zt(this)&&!Xt(this,{type:"delete",object:this,oldValue:e}))return!1;if(this.has(e)){var n=Ht(this),r=n?{observableKind:"set",debugObjectName:this.name_,type:"delete",object:this,oldValue:e}:null;return Gt((function(){t.atom_.reportChanged(),t.data_.delete(e)})),n&&Kt(this,r),!0}return!1},t.has=function(e){return this.atom_.reportObserved(),this.data_.has(this.dehanceValue_(e))},t.entries=function(){var e=0,t=Array.from(this.keys()),n=Array.from(this.values());return Zn({next:function(){var r=e;return e+=1,rOn){for(var t=On;t=0&&r++}t=$n(t),n=$n(n);var l="[object Array]"===s;if(!l){if("object"!=typeof t||"object"!=typeof n)return!1;var u=t.constructor,c=n.constructor;if(u!==c&&!(g(u)&&u instanceof u&&g(c)&&c instanceof c)&&"constructor"in t&&"constructor"in n)return!1}if(0===r)return!1;r<0&&(r=-1);o=o||[];var h=(i=i||[]).length;for(;h--;)if(i[h]===t)return o[h]===n;if(i.push(t),o.push(n),l){if((h=t.length)!==n.length)return!1;for(;h--;)if(!e(t[h],n[h],r-1,i,o))return!1}else{var d,f=Object.keys(t);if(h=f.length,Object.keys(n).length!==h)return!1;for(;h--;)if(d=f[h],!I(n,d)||!e(t[d],n[d],r-1,i,o))return!1}return i.pop(),o.pop(),!0}(e,t,n)}function $n(e){return dn(e)?e.slice():S(e)||yn(e)||k(e)||bn(e)?Array.from(e.entries()):e}function Zn(e){return e[Symbol.iterator]=Wn,e}function Wn(){return this}["Symbol","Map","Set"].forEach((function(e){void 0===o()[e]&&r("MobX requires global '"+e+"' to be available or polyfilled")})),"object"==typeof __MOBX_DEVTOOLS_GLOBAL_HOOK__&&__MOBX_DEVTOOLS_GLOBAL_HOOK__.injectMobx({spy:function(e){return console.warn("[mobx.spy] Is a no-op in production builds"),function(){}},extras:{getDebugName:Vn},$mobx:G})}).call(this,n(19))},function(e,t,n){"use strict";t.a=function(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}},function(e,t,n){"use strict";t.a=function(e){var t=new WeakMap;return function(n){if(t.has(n))return t.get(n);var r=e(n);return t.set(n,r),r}}},function(e,t,n){"use strict";var r=function(){function e(e){var t=this;this._insertTag=function(e){var n;n=0===t.tags.length?t.insertionPoint?t.insertionPoint.nextSibling:t.prepend?t.container.firstChild:t.before:t.tags[t.tags.length-1].nextSibling,t.container.insertBefore(e,n),t.tags.push(e)},this.isSpeedy=void 0===e.speedy||e.speedy,this.tags=[],this.ctr=0,this.nonce=e.nonce,this.key=e.key,this.container=e.container,this.prepend=e.prepend,this.insertionPoint=e.insertionPoint,this.before=null}var t=e.prototype;return t.hydrate=function(e){e.forEach(this._insertTag)},t.insert=function(e){this.ctr%(this.isSpeedy?65e3:1)==0&&this._insertTag(function(e){var t=document.createElement("style");return t.setAttribute("data-emotion",e.key),void 0!==e.nonce&&t.setAttribute("nonce",e.nonce),t.appendChild(document.createTextNode("")),t.setAttribute("data-s",""),t}(this));var t=this.tags[this.tags.length-1];if(this.isSpeedy){var n=function(e){if(e.sheet)return e.sheet;for(var t=0;t2||B(A)>3?"":" "}function V(e,t){for(;--t&&O()&&!(A<48||A>102||A>57&&A<65||A>70&&A<97););return R(e,L()+(t<6&&32==D()&&32==O()))}function G(e,t){for(;O()&&e+A!==57&&(e+A!==84||47!==D()););return"/*"+R(t,M-1)+"*"+d(47===e?e:O())}function q(e){for(;!B(D());)O();return R(e,M)}function $(e){return j(function e(t,n,r,i,o,a,s,l,u){var c=0,h=0,f=s,p=0,m=0,_=0,x=1,w=1,T=1,C=0,P="",z=o,R=a,B=i,F=P;for(;w;)switch(_=C,C=O()){case 40:if(108!=_&&58==v(F,f-1)){-1!=y(F+=g(N(C),"&","&\f"),"&\f")&&(T=-1);break}case 34:case 39:case 91:F+=N(C);break;case 9:case 10:case 13:case 32:F+=U(_);break;case 92:F+=V(L()-1,7);continue;case 47:switch(D()){case 42:case 47:E(W(G(O(),L()),n,r),u);break;default:F+="/"}break;case 123*x:l[c++]=b(F)*T;case 125*x:case 59:case 0:switch(C){case 0:case 125:w=0;case 59+h:m>0&&b(F)-f&&E(m>32?X(F+";",i,r,f-1):X(g(F," ","")+";",i,r,f-2),u);break;case 59:F+=";";default:if(E(B=Z(F,n,r,c,h,o,l,P,z=[],R=[],f),a),123===C)if(0===h)e(F,n,B,B,z,a,f,l,R);else switch(99===p&&110===v(F,3)?100:p){case 100:case 109:case 115:e(t,B,B,i&&E(Z(t,B,B,0,0,o,l,P,o,z=[],f),R),o,R,f,l,i?z:R);break;default:e(F,B,B,B,[""],R,0,l,R)}}c=h=m=0,x=T=1,P=F="",f=s;break;case 58:f=1+b(F),m=_;default:if(x<1)if(123==C)--x;else if(125==C&&0==x++&&125==(A=M>0?v(I,--M):0,k--,10===A&&(k=1,S--),A))continue;switch(F+=d(C),C*x){case 38:T=h>0?1:(F+="\f",-1);break;case 44:l[c++]=(b(F)-1)*T,T=1;break;case 64:45===D()&&(F+=N(O())),p=D(),h=f=b(P=F+=q(L())),C++;break;case 45:45===_&&2==b(F)&&(x=0)}}return a}("",null,null,null,[""],e=F(e),0,[0],e))}function Z(e,t,n,r,i,o,a,s,u,c,d){for(var f=i-1,p=0===i?o:[""],_=w(p),y=0,v=0,b=0;y0?p[E]+" "+T:g(T,/&\f/g,p[E])))&&(u[b++]=S);return P(e,t,n,0===i?l:s,u,c,d)}function W(e,t,n){return P(e,t,n,s,d(A),x(e,2,-2),0)}function X(e,t,n,r){return P(e,t,n,u,x(e,0,r),x(e,r+1,-1),r)}function H(e,t){for(var n="",r=w(e),i=0;i-1&&!e.return)switch(e.type){case u:e.return=function e(t,n){switch(p(t,n)){case 5103:return a+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return a+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return a+t+o+t+i+t+t;case 6828:case 4268:return a+t+i+t+t;case 6165:return a+t+i+"flex-"+t+t;case 5187:return a+t+g(t,/(\w+).+(:[^]+)/,a+"box-$1$2"+i+"flex-$1$2")+t;case 5443:return a+t+i+"flex-item-"+g(t,/flex-|-self/,"")+t;case 4675:return a+t+i+"flex-line-pack"+g(t,/align-content|flex-|-self/,"")+t;case 5548:return a+t+i+g(t,"shrink","negative")+t;case 5292:return a+t+i+g(t,"basis","preferred-size")+t;case 6060:return a+"box-"+g(t,"-grow","")+a+t+i+g(t,"grow","positive")+t;case 4554:return a+g(t,/([^-])(transform)/g,"$1"+a+"$2")+t;case 6187:return g(g(g(t,/(zoom-|grab)/,a+"$1"),/(image-set)/,a+"$1"),t,"")+t;case 5495:case 3959:return g(t,/(image-set\([^]*)/,a+"$1$`$1");case 4968:return g(g(t,/(.+:)(flex-)?(.*)/,a+"box-pack:$3"+i+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+a+t+t;case 4095:case 3583:case 4068:case 2532:return g(t,/(.+)-inline(.+)/,a+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(b(t)-1-n>6)switch(v(t,n+1)){case 109:if(45!==v(t,n+4))break;case 102:return g(t,/(.+:)(.+)-([^]+)/,"$1"+a+"$2-$3$1"+o+(108==v(t,n+3)?"$3":"$2-$3"))+t;case 115:return~y(t,"stretch")?e(g(t,"stretch","fill-available"),n)+t:t}break;case 4949:if(115!==v(t,n+1))break;case 6444:switch(v(t,b(t)-3-(~y(t,"!important")&&10))){case 107:return g(t,":",":"+a)+t;case 101:return g(t,/(.+:)([^;!]+)(;|!.+)?/,"$1"+a+(45===v(t,14)?"inline-":"")+"box$3$1"+a+"$2$3$1"+i+"$2box$3")+t}break;case 5936:switch(v(t,n+11)){case 114:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return a+t+i+g(t,/[svh]\w+-[tblr]{2}/,"lr")+t}return a+t+i+t+t}return t}(e.value,e.length);break;case c:return H([z(e,{value:g(e.value,"@","@"+a)})],r);case l:if(e.length)return T(e.props,(function(t){switch(_(t,/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":return H([z(e,{props:[g(t,/:(read-\w+)/,":-moz-$1")]})],r);case"::placeholder":return H([z(e,{props:[g(t,/:(plac\w+)/,":"+a+"input-$1")]}),z(e,{props:[g(t,/:(plac\w+)/,":-moz-$1")]}),z(e,{props:[g(t,/:(plac\w+)/,i+"input-$1")]})],r)}return""}))}}];t.a=function(e){var t=e.key;if("css"===t){var n=document.querySelectorAll("style[data-emotion]:not([data-s])");Array.prototype.forEach.call(n,(function(e){-1!==e.getAttribute("data-emotion").indexOf(" ")&&(document.head.appendChild(e),e.setAttribute("data-s",""))}))}var i=e.stylisPlugins||re;var o,a,s={},l=[];o=e.container||document.head,Array.prototype.forEach.call(document.querySelectorAll('style[data-emotion^="'+t+' "]'),(function(e){for(var t=e.getAttribute("data-emotion").split(" "),n=1;n=0||(i[n]=e[n]);return i}n.d(t,"a",(function(){return r}))},function(e,t,n){var r; /*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/!function(){"use strict";var n={}.hasOwnProperty;function i(){for(var e=[],t=0;t=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(t),n.properties);case"Polygon":var o=[];i(t,(function(e){o.push(e)}));var l,u,c,h,d,f,p,m,_=s(t,{properties:n.properties}),g=_.geometry.coordinates,y=0,v=0,x=0,b=o.map((function(e){return[e[0]-g[0],e[1]-g[1]]}));for(l=0;l3?Object(r.f)([o]):null}(t);return T?e(T,{properties:n.properties}):s(t,{properties:n.properties})}}},function(e,t,n){"use strict";var r=n(25),i=n.n(r);t.a=function(e,t){return i()(e,t)}},function(e,t,n){"use strict";var r=n(48),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var u=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(p){var i=f(n);i&&i!==p&&e(t,i,r)}var a=c(n);h&&(a=a.concat(h(n)));for(var s=l(t),m=l(n),_=0;_1)for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=2&&!Array.isArray(e[0])&&!Array.isArray(e[1]))return e;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(t),n.properties);case"Polygon":var o=[];i(t,(function(e){o.push(e)}));var l,u,c,h,d,f,p,m,_=s(t,{properties:n.properties}),g=_.geometry.coordinates,y=0,v=0,x=0,b=o.map((function(e){return[e[0]-g[0],e[1]-g[1]]}));for(l=0;l3?Object(r.f)([o]):null}(t);return E?e(E,{properties:n.properties}):s(t,{properties:n.properties})}}},function(e,t,n){"use strict";var r=n(25),i=n.n(r);t.a=function(e,t){return i()(e,t)}},function(e,t,n){"use strict";var r=n(48),i={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},o={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},a={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},s={};function l(e){return r.isMemo(e)?a:s[e.$$typeof]||i}s[r.ForwardRef]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},s[r.Memo]=a;var u=Object.defineProperty,c=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols,d=Object.getOwnPropertyDescriptor,f=Object.getPrototypeOf,p=Object.prototype;e.exports=function e(t,n,r){if("string"!=typeof n){if(p){var i=f(n);i&&i!==p&&e(t,i,r)}var a=c(n);h&&(a=a.concat(h(n)));for(var s=l(t),m=l(n),_=0;_1)for(var n=1;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=this._config.preview;if(r)t.postMessage({results:s,workerId:a.WORKER_ID,finished:u});else if(b(this._config.chunk)&&!n){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);s=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!u||!b(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){b(this._config.error)?this._config.error(e):r&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var n=t.statusText||e;this._sendError(new Error(n))}}function c(e){var t,n;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,n=this._config.chunkSize;return n?(e=t.substring(0,n),t=t.substring(n)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=x((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=x((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=x((function(){this._streamCleanUp(),r=!0,this._streamData("")}),this),this._streamCleanUp=x((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function f(e){var t,n,r,i=Math.pow(2,53),o=-i,s=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/,u=this,c=0,h=0,d=!1,f=!1,_=[],g={data:[],errors:[],meta:{}};if(b(e.step)){var y=e.step;e.step=function(t){if(g=t,T())w();else{if(w(),0===g.data.length)return;c+=t.data.length,e.preview&&c>e.preview?n.abort():(g.data=g.data[0],y(g,u))}}}function x(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){return g&&r&&(S("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(g.data=g.data.filter((function(e){return!x(e)}))),T()&&function(){if(g)if(Array.isArray(g.data[0])){for(var t=0;T()&&t=_.length?"__parsed_extra":_[r]),e.transform&&(a=e.transform(a,o)),a=E(o,a),"__parsed_extra"===o?(i[o]=i[o]||[],i[o].push(a)):i[o]=a}return e.header&&(r>_.length?S("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+r,h+n):r<_.length&&S("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+r,h+n)),i}var n=1;return!g.data.length||Array.isArray(g.data[0])?(g.data=g.data.map(t),n=g.data.length):g.data=t(g.data,0),e.header&&g.meta&&(g.meta.fields=_),h+=n,g}()}function T(){return e.header&&0===_.length}function E(t,n){return r=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[r]&&(e.dynamicTyping[r]=e.dynamicTypingFunction(r)),!0===(e.dynamicTyping[r]||e.dynamicTyping)?"true"===n||"TRUE"===n||"false"!==n&&"FALSE"!==n&&(function(e){if(s.test(e)){var t=parseFloat(e);if(o=r.length/2?"\r\n":"\r"}(i,l)),r=!1,e.delimiter)b(e.delimiter)&&(e.delimiter=e.delimiter(i),g.meta.delimiter=e.delimiter);else{var u=function(t,n,r,i,o){var s,l,u,c;o=o||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h=s)return R(!0)}else for(A=c,c++;;){if(-1===(A=e.indexOf(t,A+1)))return d||x.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),D();if(A===f-1)return D(e.substring(c,A).replace(M,t));if(t!==u||e[A+1]!==u){if(t===u||0===A||e[A-1]!==u){-1!==k&&k=s)return R(!0);break}x.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),A++}}else A++}return D();function P(e){v.push(e),T=c}function O(t){var n=0;if(-1!==t){var r=e.substring(A+1,t);r&&""===r.trim()&&(n=r.length)}return n}function D(t){return d||(void 0===t&&(t=e.substring(c)),w.push(t),c=f,P(w),y&&B()),R()}function L(t){c=t,P(w),w=[],C=e.indexOf(r,c)}function R(e){return{data:v,errors:x,meta:{delimiter:n,linebreak:r,aborted:h,truncated:!!e,cursor:T+(a||0)}}}function B(){o(R()),v=[],x=[]}},this.abort=function(){h=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,n=i[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var o={abort:function(){r=!0,g(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(b(n.userStep)){for(var a=0;ar[0]&&(r=s),s[1]i[1]&&(i=s)}var l=[t,n,r,i],u=l.slice();for(a=0;a=2&&f(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&f(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}(u)}(e),a=new r(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var s,u=[],c=0;ca||l.push({node:p,dist:m})}for(;l.length&&!l.peek().node.children;){var _=l.pop(),y=_.node,v=g(y,t,n),x=g(y,r,o);if(_.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function d(e,t,n){for(var r,i,o,a,s=Math.min(e[0],t[0]),l=Math.min(e[1],t[1]),u=Math.max(e[0],t[0]),c=Math.max(e[1],t[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),d=0;d0!=f(r,i,a)>0&&f(o,a,r)>0!=f(o,a,i)>0)return!1;return!0}function f(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function p(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function _(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function g(e,t,n){var r=t[0],i=t[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((e[0]-r)*o+(e[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=e[0]-r)*o+(a=e[1]-i)*a}function y(e,t,n,r,i,o,a,s){var l,u,c,h,d=n-e,f=r-t,p=a-i,m=s-o,_=e-i,g=t-o,y=d*d+f*f,v=d*p+f*m,x=p*p+m*m,b=d*_+f*g,w=p*_+m*g,T=y*x-v*v,E=T,S=T;0===T?(u=0,E=1,h=w,S=x):(h=y*w-v*b,(u=v*w-x*b)<0?(u=0,h=w,S=x):u>E&&(u=E,h=w+v,S=x)),h<0?(h=0,-b<0?u=0:-b>y?u=E:(u=-b,E=y)):h>S&&(h=S,-b+v<0?u=0:-b+v>y?u=E:(u=-b+v,E=y));var k=(1-(c=0===h?0:h/S))*i+c*a-((1-(l=0===u?0:u/E))*e+l*n),C=(1-c)*o+c*s-((1-l)*t+l*r);return k*k+C*C}function v(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),e.exports=s,e.exports.default=s},function(e,t,n){"use strict";function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}n.d(t,"a",(function(){return r}))},function(e,t,n){(function(e,r){var i; +*/i=[],void 0===(o="function"==typeof(r=function e(){"use strict";var t="undefined"!=typeof self?self:"undefined"!=typeof window?window:void 0!==t?t:{},n=!t.document&&!!t.postMessage,r=n&&/blob:/i.test((t.location||{}).protocol),i={},o=0,a={parse:function(n,r){var s=(r=r||{}).dynamicTyping||!1;if(b(s)&&(r.dynamicTypingFunction=s,s={}),r.dynamicTyping=s,r.transform=!!b(r.transform)&&r.transform,r.worker&&a.WORKERS_SUPPORTED){var l=function(){if(!a.WORKERS_SUPPORTED)return!1;var n,r,s=(n=t.URL||t.webkitURL||null,r=e.toString(),a.BLOB_URL||(a.BLOB_URL=n.createObjectURL(new Blob(["(",r,")();"],{type:"text/javascript"})))),l=new t.Worker(s);return l.onmessage=_,l.id=o++,i[l.id]=l}();return l.userStep=r.step,l.userChunk=r.chunk,l.userComplete=r.complete,l.userError=r.error,r.step=b(r.step),r.chunk=b(r.chunk),r.complete=b(r.complete),r.error=b(r.error),delete r.worker,void l.postMessage({input:n,config:r,workerId:l.id})}var f=null;return a.NODE_STREAM_INPUT,"string"==typeof n?f=r.download?new u(r):new h(r):!0===n.readable&&b(n.read)&&b(n.on)?f=new d(r):(t.File&&n instanceof File||n instanceof Object)&&(f=new c(r)),f.stream(n)},unparse:function(e,t){var n=!1,r=!0,i=",",o="\r\n",s='"',l=s+s,u=!1,c=null,h=!1;!function(){if("object"==typeof t){if("string"!=typeof t.delimiter||a.BAD_DELIMITERS.filter((function(e){return-1!==t.delimiter.indexOf(e)})).length||(i=t.delimiter),("boolean"==typeof t.quotes||"function"==typeof t.quotes||Array.isArray(t.quotes))&&(n=t.quotes),"boolean"!=typeof t.skipEmptyLines&&"string"!=typeof t.skipEmptyLines||(u=t.skipEmptyLines),"string"==typeof t.newline&&(o=t.newline),"string"==typeof t.quoteChar&&(s=t.quoteChar),"boolean"==typeof t.header&&(r=t.header),Array.isArray(t.columns)){if(0===t.columns.length)throw new Error("Option columns is empty");c=t.columns}void 0!==t.escapeChar&&(l=t.escapeChar+s),("boolean"==typeof t.escapeFormulae||t.escapeFormulae instanceof RegExp)&&(h=t.escapeFormulae instanceof RegExp?t.escapeFormulae:/^[=+\-@\t\r].*$/)}}();var d=new RegExp(p(s),"g");if("string"==typeof e&&(e=JSON.parse(e)),Array.isArray(e)){if(!e.length||Array.isArray(e[0]))return f(null,e,u);if("object"==typeof e[0])return f(c||Object.keys(e[0]),e,u)}else if("object"==typeof e)return"string"==typeof e.data&&(e.data=JSON.parse(e.data)),Array.isArray(e.data)&&(e.fields||(e.fields=e.meta&&e.meta.fields||c),e.fields||(e.fields=Array.isArray(e.data[0])?e.fields:"object"==typeof e.data[0]?Object.keys(e.data[0]):[]),Array.isArray(e.data[0])||"object"==typeof e.data[0]||(e.data=[e.data])),f(e.fields||[],e.data||[],u);throw new Error("Unable to serialize unrecognized input");function f(e,t,n){var a="";"string"==typeof e&&(e=JSON.parse(e)),"string"==typeof t&&(t=JSON.parse(t));var s=Array.isArray(e)&&0=this._config.preview;if(r)t.postMessage({results:s,workerId:a.WORKER_ID,finished:u});else if(b(this._config.chunk)&&!n){if(this._config.chunk(s,this._handle),this._handle.paused()||this._handle.aborted())return void(this._halted=!0);s=void 0,this._completeResults=void 0}return this._config.step||this._config.chunk||(this._completeResults.data=this._completeResults.data.concat(s.data),this._completeResults.errors=this._completeResults.errors.concat(s.errors),this._completeResults.meta=s.meta),this._completed||!u||!b(this._config.complete)||s&&s.meta.aborted||(this._config.complete(this._completeResults,this._input),this._completed=!0),u||s&&s.meta.paused||this._nextChunk(),s}this._halted=!0},this._sendError=function(e){b(this._config.error)?this._config.error(e):r&&this._config.error&&t.postMessage({workerId:a.WORKER_ID,error:e,finished:!1})}}function u(e){var t;(e=e||{}).chunkSize||(e.chunkSize=a.RemoteChunkSize),l.call(this,e),this._nextChunk=n?function(){this._readChunk(),this._chunkLoaded()}:function(){this._readChunk()},this.stream=function(e){this._input=e,this._nextChunk()},this._readChunk=function(){if(this._finished)this._chunkLoaded();else{if(t=new XMLHttpRequest,this._config.withCredentials&&(t.withCredentials=this._config.withCredentials),n||(t.onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)),t.open(this._config.downloadRequestBody?"POST":"GET",this._input,!n),this._config.downloadRequestHeaders){var e=this._config.downloadRequestHeaders;for(var r in e)t.setRequestHeader(r,e[r])}if(this._config.chunkSize){var i=this._start+this._config.chunkSize-1;t.setRequestHeader("Range","bytes="+this._start+"-"+i)}try{t.send(this._config.downloadRequestBody)}catch(e){this._chunkError(e.message)}n&&0===t.status&&this._chunkError()}},this._chunkLoaded=function(){4===t.readyState&&(t.status<200||400<=t.status?this._chunkError():(this._start+=this._config.chunkSize?this._config.chunkSize:t.responseText.length,this._finished=!this._config.chunkSize||this._start>=function(e){var t=e.getResponseHeader("Content-Range");return null===t?-1:parseInt(t.substring(t.lastIndexOf("/")+1))}(t),this.parseChunk(t.responseText)))},this._chunkError=function(e){var n=t.statusText||e;this._sendError(new Error(n))}}function c(e){var t,n;(e=e||{}).chunkSize||(e.chunkSize=a.LocalChunkSize),l.call(this,e);var r="undefined"!=typeof FileReader;this.stream=function(e){this._input=e,n=e.slice||e.webkitSlice||e.mozSlice,r?((t=new FileReader).onload=x(this._chunkLoaded,this),t.onerror=x(this._chunkError,this)):t=new FileReaderSync,this._nextChunk()},this._nextChunk=function(){this._finished||this._config.preview&&!(this._rowCount=this._input.size,this.parseChunk(e.target.result)},this._chunkError=function(){this._sendError(t.error)}}function h(e){var t;l.call(this,e=e||{}),this.stream=function(e){return t=e,this._nextChunk()},this._nextChunk=function(){if(!this._finished){var e,n=this._config.chunkSize;return n?(e=t.substring(0,n),t=t.substring(n)):(e=t,t=""),this._finished=!t,this.parseChunk(e)}}}function d(e){l.call(this,e=e||{});var t=[],n=!0,r=!1;this.pause=function(){l.prototype.pause.apply(this,arguments),this._input.pause()},this.resume=function(){l.prototype.resume.apply(this,arguments),this._input.resume()},this.stream=function(e){this._input=e,this._input.on("data",this._streamData),this._input.on("end",this._streamEnd),this._input.on("error",this._streamError)},this._checkIsFinished=function(){r&&1===t.length&&(this._finished=!0)},this._nextChunk=function(){this._checkIsFinished(),t.length?this.parseChunk(t.shift()):n=!0},this._streamData=x((function(e){try{t.push("string"==typeof e?e:e.toString(this._config.encoding)),n&&(n=!1,this._checkIsFinished(),this.parseChunk(t.shift()))}catch(e){this._streamError(e)}}),this),this._streamError=x((function(e){this._streamCleanUp(),this._sendError(e)}),this),this._streamEnd=x((function(){this._streamCleanUp(),r=!0,this._streamData("")}),this),this._streamCleanUp=x((function(){this._input.removeListener("data",this._streamData),this._input.removeListener("end",this._streamEnd),this._input.removeListener("error",this._streamError)}),this)}function f(e){var t,n,r,i=Math.pow(2,53),o=-i,s=/^\s*-?(\d+\.?|\.\d+|\d+\.\d+)([eE][-+]?\d+)?\s*$/,l=/^(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))|(\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d([+-][0-2]\d:[0-5]\d|Z))$/,u=this,c=0,h=0,d=!1,f=!1,_=[],g={data:[],errors:[],meta:{}};if(b(e.step)){var y=e.step;e.step=function(t){if(g=t,E())w();else{if(w(),0===g.data.length)return;c+=t.data.length,e.preview&&c>e.preview?n.abort():(g.data=g.data[0],y(g,u))}}}function x(t){return"greedy"===e.skipEmptyLines?""===t.join("").trim():1===t.length&&0===t[0].length}function w(){return g&&r&&(S("Delimiter","UndetectableDelimiter","Unable to auto-detect delimiting character; defaulted to '"+a.DefaultDelimiter+"'"),r=!1),e.skipEmptyLines&&(g.data=g.data.filter((function(e){return!x(e)}))),E()&&function(){if(g)if(Array.isArray(g.data[0])){for(var t=0;E()&&t=_.length?"__parsed_extra":_[r]),e.transform&&(a=e.transform(a,o)),a=T(o,a),"__parsed_extra"===o?(i[o]=i[o]||[],i[o].push(a)):i[o]=a}return e.header&&(r>_.length?S("FieldMismatch","TooManyFields","Too many fields: expected "+_.length+" fields but parsed "+r,h+n):r<_.length&&S("FieldMismatch","TooFewFields","Too few fields: expected "+_.length+" fields but parsed "+r,h+n)),i}var n=1;return!g.data.length||Array.isArray(g.data[0])?(g.data=g.data.map(t),n=g.data.length):g.data=t(g.data,0),e.header&&g.meta&&(g.meta.fields=_),h+=n,g}()}function E(){return e.header&&0===_.length}function T(t,n){return r=t,e.dynamicTypingFunction&&void 0===e.dynamicTyping[r]&&(e.dynamicTyping[r]=e.dynamicTypingFunction(r)),!0===(e.dynamicTyping[r]||e.dynamicTyping)?"true"===n||"TRUE"===n||"false"!==n&&"FALSE"!==n&&(function(e){if(s.test(e)){var t=parseFloat(e);if(o=r.length/2?"\r\n":"\r"}(i,l)),r=!1,e.delimiter)b(e.delimiter)&&(e.delimiter=e.delimiter(i),g.meta.delimiter=e.delimiter);else{var u=function(t,n,r,i,o){var s,l,u,c;o=o||[",","\t","|",";",a.RECORD_SEP,a.UNIT_SEP];for(var h=0;h=s)return R(!0)}else for(A=c,c++;;){if(-1===(A=e.indexOf(t,A+1)))return d||x.push({type:"Quotes",code:"MissingQuotes",message:"Quoted field unterminated",row:v.length,index:c}),D();if(A===f-1)return D(e.substring(c,A).replace(M,t));if(t!==u||e[A+1]!==u){if(t===u||0===A||e[A-1]!==u){-1!==k&&k=s)return R(!0);break}x.push({type:"Quotes",code:"InvalidQuotes",message:"Trailing quote on quoted field is malformed",row:v.length,index:c}),A++}}else A++}return D();function z(e){v.push(e),E=c}function O(t){var n=0;if(-1!==t){var r=e.substring(A+1,t);r&&""===r.trim()&&(n=r.length)}return n}function D(t){return d||(void 0===t&&(t=e.substring(c)),w.push(t),c=f,z(w),y&&B()),R()}function L(t){c=t,z(w),w=[],C=e.indexOf(r,c)}function R(e){return{data:v,errors:x,meta:{delimiter:n,linebreak:r,aborted:h,truncated:!!e,cursor:E+(a||0)}}}function B(){o(R()),v=[],x=[]}},this.abort=function(){h=!0},this.getCharIndex=function(){return c}}function _(e){var t=e.data,n=i[t.workerId],r=!1;if(t.error)n.userError(t.error,t.file);else if(t.results&&t.results.data){var o={abort:function(){r=!0,g(t.workerId,{data:[],errors:[],meta:{aborted:!0}})},pause:y,resume:y};if(b(n.userStep)){for(var a=0;ar[0]&&(r=s),s[1]i[1]&&(i=s)}var l=[t,n,r,i],u=l.slice();for(a=0;a=2&&f(t[t.length-2],t[t.length-1],e[n])<=0;)t.pop();t.push(e[n])}for(var r=[],i=e.length-1;i>=0;i--){for(;r.length>=2&&f(r[r.length-2],r[r.length-1],e[i])<=0;)r.pop();r.push(e[i])}return r.pop(),t.pop(),t.concat(r)}(u)}(e),a=new r(16);a.toBBox=function(e){return{minX:e[0],minY:e[1],maxX:e[0],maxY:e[1]}},a.compareMinX=function(e,t){return e[0]-t[0]},a.compareMinY=function(e,t){return e[1]-t[1]},a.load(e);for(var s,u=[],c=0;ca||l.push({node:p,dist:m})}for(;l.length&&!l.peek().node.children;){var _=l.pop(),y=_.node,v=g(y,t,n),x=g(y,r,o);if(_.dist=t.minX&&e[0]<=t.maxX&&e[1]>=t.minY&&e[1]<=t.maxY}function d(e,t,n){for(var r,i,o,a,s=Math.min(e[0],t[0]),l=Math.min(e[1],t[1]),u=Math.max(e[0],t[0]),c=Math.max(e[1],t[1]),h=n.search({minX:s,minY:l,maxX:u,maxY:c}),d=0;d0!=f(r,i,a)>0&&f(o,a,r)>0!=f(o,a,i)>0)return!1;return!0}function f(e,t,n){return a(e[0],e[1],t[0],t[1],n[0],n[1])}function p(e){var t=e.p,n=e.next.p;return e.minX=Math.min(t[0],n[0]),e.minY=Math.min(t[1],n[1]),e.maxX=Math.max(t[0],n[0]),e.maxY=Math.max(t[1],n[1]),e}function m(e,t){var n={p:e,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return t?(n.next=t.next,n.prev=t,t.next.prev=n,t.next=n):(n.prev=n,n.next=n),n}function _(e,t){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function g(e,t,n){var r=t[0],i=t[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((e[0]-r)*o+(e[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=e[0]-r)*o+(a=e[1]-i)*a}function y(e,t,n,r,i,o,a,s){var l,u,c,h,d=n-e,f=r-t,p=a-i,m=s-o,_=e-i,g=t-o,y=d*d+f*f,v=d*p+f*m,x=p*p+m*m,b=d*_+f*g,w=p*_+m*g,E=y*x-v*v,T=E,S=E;0===E?(u=0,T=1,h=w,S=x):(h=y*w-v*b,(u=v*w-x*b)<0?(u=0,h=w,S=x):u>T&&(u=T,h=w+v,S=x)),h<0?(h=0,-b<0?u=0:-b>y?u=T:(u=-b,T=y)):h>S&&(h=S,-b+v<0?u=0:-b+v>y?u=T:(u=-b+v,T=y));var k=(1-(c=0===h?0:h/S))*i+c*a-((1-(l=0===u?0:u/T))*e+l*n),C=(1-c)*o+c*s-((1-l)*t+l*r);return k*k+C*C}function v(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}i.default&&(i=i.default),e.exports=s,e.exports.default=s},function(e,t,n){"use strict";function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}n.d(t,"a",(function(){return r}))},function(e,t,n){(function(e,r){var i; /** * @license * Lodash @@ -18,7 +18,7 @@ License: MIT * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors - */(function(){var o="Expected a function",a="__lodash_placeholder__",s=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],l="[object Arguments]",u="[object Array]",c="[object Boolean]",h="[object Date]",d="[object Error]",f="[object Function]",p="[object GeneratorFunction]",m="[object Map]",_="[object Number]",g="[object Object]",y="[object RegExp]",v="[object Set]",x="[object String]",b="[object Symbol]",w="[object WeakMap]",T="[object ArrayBuffer]",E="[object DataView]",S="[object Float32Array]",k="[object Float64Array]",C="[object Int8Array]",M="[object Int16Array]",A="[object Int32Array]",I="[object Uint8Array]",z="[object Uint16Array]",P="[object Uint32Array]",O=/\b__p \+= '';/g,D=/\b(__p \+=) '' \+/g,L=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(R.source),j=RegExp(B.source),U=/<%-([\s\S]+?)%>/g,V=/<%([\s\S]+?)%>/g,N=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,W=RegExp(Z.source),X=/^\s+/,H=/\s/,Y=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,K=/\{\n\/\* \[wrapped with (.+)\] \*/,J=/,? & /,Q=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ee=/[()=,{}\[\]\/\s]/,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,oe=/^0b[01]+$/i,ae=/^\[object .+?Constructor\]$/,se=/^0o[0-7]+$/i,le=/^(?:0|[1-9]\d*)$/,ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ce=/($^)/,he=/['\n\r\u2028\u2029\\]/g,de="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",fe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="[\\ud800-\\udfff]",me="["+fe+"]",_e="["+de+"]",ge="\\d+",ye="[\\u2700-\\u27bf]",ve="[a-z\\xdf-\\xf6\\xf8-\\xff]",xe="[^\\ud800-\\udfff"+fe+ge+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",be="\\ud83c[\\udffb-\\udfff]",we="[^\\ud800-\\udfff]",Te="(?:\\ud83c[\\udde6-\\uddff]){2}",Ee="[\\ud800-\\udbff][\\udc00-\\udfff]",Se="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ke="(?:"+ve+"|"+xe+")",Ce="(?:"+Se+"|"+xe+")",Me="(?:"+_e+"|"+be+")"+"?",Ae="[\\ufe0e\\ufe0f]?"+Me+("(?:\\u200d(?:"+[we,Te,Ee].join("|")+")[\\ufe0e\\ufe0f]?"+Me+")*"),Ie="(?:"+[ye,Te,Ee].join("|")+")"+Ae,ze="(?:"+[we+_e+"?",_e,Te,Ee,pe].join("|")+")",Pe=RegExp("['’]","g"),Oe=RegExp(_e,"g"),De=RegExp(be+"(?="+be+")|"+ze+Ae,"g"),Le=RegExp([Se+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Se,"$"].join("|")+")",Ce+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Se+ke,"$"].join("|")+")",Se+"?"+ke+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Se+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ge,Ie].join("|"),"g"),Re=RegExp("[\\u200d\\ud800-\\udfff"+de+"\\ufe0e\\ufe0f]"),Be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],je=-1,Ue={};Ue[S]=Ue[k]=Ue[C]=Ue[M]=Ue[A]=Ue[I]=Ue["[object Uint8ClampedArray]"]=Ue[z]=Ue[P]=!0,Ue[l]=Ue[u]=Ue[T]=Ue[c]=Ue[E]=Ue[h]=Ue[d]=Ue[f]=Ue[m]=Ue[_]=Ue[g]=Ue[y]=Ue[v]=Ue[x]=Ue[w]=!1;var Ve={};Ve[l]=Ve[u]=Ve[T]=Ve[E]=Ve[c]=Ve[h]=Ve[S]=Ve[k]=Ve[C]=Ve[M]=Ve[A]=Ve[m]=Ve[_]=Ve[g]=Ve[y]=Ve[v]=Ve[x]=Ve[b]=Ve[I]=Ve["[object Uint8ClampedArray]"]=Ve[z]=Ve[P]=!0,Ve[d]=Ve[f]=Ve[w]=!1;var Ne={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,$e="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,We=$e||Ze||Function("return this")(),Xe=t&&!t.nodeType&&t,He=Xe&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=He&&He.exports===Xe,Ke=Ye&&$e.process,Je=function(){try{var e=He&&He.require&&He.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}(),Qe=Je&&Je.isArrayBuffer,et=Je&&Je.isDate,tt=Je&&Je.isMap,nt=Je&&Je.isRegExp,rt=Je&&Je.isSet,it=Je&&Je.isTypedArray;function ot(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function at(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function dt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Lt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function Rt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=kt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ft=kt({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ne[e]}function Ut(e){return Re.test(e)}function Vt(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Nt(e,t){return function(n){return e(t(n))}}function Gt(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"});var Yt=function e(t){var n,r=(t=null==t?We:Yt.defaults(We.Object(),t,Yt.pick(We,Fe))).Array,i=t.Date,H=t.Error,de=t.Function,fe=t.Math,pe=t.Object,me=t.RegExp,_e=t.String,ge=t.TypeError,ye=r.prototype,ve=de.prototype,xe=pe.prototype,be=t["__core-js_shared__"],we=ve.toString,Te=xe.hasOwnProperty,Ee=0,Se=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",ke=xe.toString,Ce=we.call(pe),Me=We._,Ae=me("^"+we.call(Te).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ie=Ye?t.Buffer:void 0,ze=t.Symbol,De=t.Uint8Array,Re=Ie?Ie.allocUnsafe:void 0,Ne=Nt(pe.getPrototypeOf,pe),$e=pe.create,Ze=xe.propertyIsEnumerable,Xe=ye.splice,He=ze?ze.isConcatSpreadable:void 0,Ke=ze?ze.iterator:void 0,Je=ze?ze.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),kt=t.clearTimeout!==We.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==We.Date.now&&i.now,Jt=t.setTimeout!==We.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=Ie?Ie.isBuffer:void 0,rn=t.isFinite,on=ye.join,an=Nt(pe.keys,pe),sn=fe.max,ln=fe.min,un=i.now,cn=t.parseInt,hn=fe.random,dn=ye.reverse,fn=eo(t,"DataView"),pn=eo(t,"Map"),mn=eo(t,"Promise"),_n=eo(t,"Set"),gn=eo(t,"WeakMap"),yn=eo(pe,"create"),vn=gn&&new gn,xn={},bn=Mo(fn),wn=Mo(pn),Tn=Mo(mn),En=Mo(_n),Sn=Mo(gn),kn=ze?ze.prototype:void 0,Cn=kn?kn.valueOf:void 0,Mn=kn?kn.toString:void 0;function An(e){if($a(e)&&!Da(e)&&!(e instanceof On)){if(e instanceof Pn)return e;if(Te.call(e,"__wrapped__"))return Ao(e)}return new Pn(e)}var In=function(){function e(){}return function(t){if(!qa(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function zn(){}function Pn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function On(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Dn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Kn(e,t,n,r,i,o){var a,s=1&t,u=2&t,d=4&t;if(n&&(a=i?n(e,r,i,o):n(e)),void 0!==a)return a;if(!qa(e))return e;var w=Da(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Te.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var O=ro(e),D=O==f||O==p;if(Fa(e))return di(e,s);if(O==g||O==l||D&&!i){if(a=u||D?{}:oo(e),!s)return u?function(e,t){return vi(e,no(e),t)}(e,function(e,t){return e&&vi(t,ws(t),e)}(a,e)):function(e,t){return vi(e,to(e),t)}(e,Wn(a,e))}else{if(!Ve[O])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case T:return fi(e);case c:case h:return new r(+e);case E:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case S:case k:case C:case M:case A:case I:case"[object Uint8ClampedArray]":case z:case P:return pi(e,n);case m:return new r;case _:case x:return new r(e);case y:return function(e){var t=new e.constructor(e.source,re.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return new r;case b:return i=e,Cn?pe(Cn.call(i)):{}}var i}(e,O,s)}}o||(o=new Fn);var L=o.get(e);if(L)return L;o.set(e,a),Ya(e)?e.forEach((function(r){a.add(Kn(r,t,n,r,e,o))})):Za(e)&&e.forEach((function(r,i){a.set(i,Kn(r,t,n,i,e,o))}));var R=w?void 0:(d?u?Wi:Zi:u?ws:bs)(e);return st(R||e,(function(r,i){R&&(r=e[i=r]),qn(a,i,Kn(r,t,n,i,e,o))})),a}function Jn(e,t,n){var r=n.length;if(null==e)return!r;for(e=pe(e);r--;){var i=n[r],o=t[i],a=e[i];if(void 0===a&&!(i in e)||!o(a))return!1}return!0}function Qn(e,t,n){if("function"!=typeof e)throw new ge(o);return bo((function(){e.apply(void 0,n)}),t)}function er(e,t,n,r){var i=-1,o=ht,a=!0,s=e.length,l=[],u=t.length;if(!s)return l;n&&(t=ft(t,zt(n))),r?(o=dt,a=!1):t.length>=200&&(o=Ot,a=!1,t=new Bn(t));e:for(;++i-1},Ln.prototype.set=function(e,t){var n=this.__data__,r=$n(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Rn.prototype.clear=function(){this.size=0,this.__data__={hash:new Dn,map:new(pn||Ln),string:new Dn}},Rn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},Rn.prototype.get=function(e){return Ji(this,e).get(e)},Rn.prototype.has=function(e){return Ji(this,e).has(e)},Rn.prototype.set=function(e,t){var n=Ji(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Bn.prototype.add=Bn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Bn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.clear=function(){this.__data__=new Ln,this.size=0},Fn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Fn.prototype.get=function(e){return this.__data__.get(e)},Fn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Ln){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Rn(r)}return n.set(e,t),this.size=n.size,this};var tr=wi(ur),nr=wi(cr,!0);function rr(e,t){var n=!0;return tr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ir(e,t,n){for(var r=-1,i=e.length;++r0&&n(s)?t>1?ar(s,t-1,n,r,i):pt(i,s):r||(i[i.length]=s)}return i}var sr=Ti(),lr=Ti(!0);function ur(e,t){return e&&sr(e,t,bs)}function cr(e,t){return e&&lr(e,t,bs)}function hr(e,t){return ct(t,(function(t){return Va(e[t])}))}function dr(e,t){for(var n=0,r=(t=li(t,e)).length;null!=e&&nt}function _r(e,t){return null!=e&&Te.call(e,t)}function gr(e,t){return null!=e&&t in pe(e)}function yr(e,t,n){for(var i=n?dt:ht,o=e[0].length,a=e.length,s=a,l=r(a),u=1/0,c=[];s--;){var h=e[s];s&&t&&(h=ft(h,zt(t))),u=ln(h.length,u),l[s]=!n&&(t||o>=120&&h.length>=120)?new Bn(s&&h):void 0}h=e[0];var d=-1,f=l[0];e:for(;++d=s)return l;var u=n[r];return l*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function Dr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&Xe.call(s,l,1),Xe.call(e,l,1);return e}function Rr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;so(i)?Xe.call(e,i,1):ei(e,i)}}return e}function Br(e,t){return e+en(hn()*(t-e+1))}function Fr(e,t){var n="";if(!e||t<1||t>9007199254740991)return n;do{t%2&&(n+=e),(t=en(t/2))&&(e+=e)}while(t);return n}function jr(e,t){return wo(_o(e,t,Ws),e+"")}function Ur(e){return Un(Is(e))}function Vr(e,t){var n=Is(e);return So(n,Yn(t,0,n.length))}function Nr(e,t,n,r){if(!qa(e))return e;for(var i=-1,o=(t=li(t,e)).length,a=o-1,s=e;null!=s&&++io?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=r(o);++i>>1,a=e[o];null!==a&&!Ja(a)&&(n?a<=t:a=200){var u=t?null:Fi(e);if(u)return qt(u);a=!1,i=Ot,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=kt||function(e){return We.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=Re?Re(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new De(t).set(new De(e)),t}function pi(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function mi(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e==e,o=Ja(e),a=void 0!==t,s=null===t,l=t==t,u=Ja(t);if(!s&&!u&&!o&&e>t||o&&a&&l&&!s&&!u||r&&a&&l||!n&&l||!i)return 1;if(!r&&!o&&!u&&e1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&lo(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=pe(t);++r-1?i[o?t[a]:a]:void 0}}function Mi(e){return $i((function(t){var n=t.length,r=n,i=Pn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new ge(o);if(i&&!s&&"wrapper"==Hi(a))var s=new Pn([],!0)}for(r=s?r:n;++r1&&v.reverse(),h&&us))return!1;var u=o.get(e),c=o.get(t);if(u&&c)return u==t&&c==e;var h=-1,d=!0,f=2&n?new Bn:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(Y,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return st(s,(function(n){var r="_."+n[0];t&n[1]&&!ht(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(K);return t?t[1].split(J):[]}(r),n)))}function Eo(e){var t=0,n=0;return function(){var r=un(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function So(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n1?e[t-1]:void 0;return n="function"==typeof n?(e.pop(),n):void 0,Ho(e,n)}));function na(e){var t=An(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=$i((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Hn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof On&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new Pn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(void 0),e}))):this.thru(i)}));var oa=xi((function(e,t,n){Te.call(e,n)?++e[n]:Xn(e,n,1)}));var aa=Ci(Oo),sa=Ci(Do);function la(e,t){return(Da(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(Da(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Te.call(e,n)?e[n].push(t):Xn(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=Ra(e)?r(e.length):[];return tr(e,(function(e){a[++i]=o?ot(t,e,n):vr(e,t,n)})),a})),da=xi((function(e,t,n){Xn(e,n,t)}));function fa(e,t){return(Da(e)?ft:Mr)(e,Ki(t,3))}var pa=xi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var ma=jr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&lo(e,t[0],t[1])?t=[]:n>2&&lo(t[0],t[1],t[2])&&(t=[t[0]]),Or(e,ar(t,1),[])})),_a=Kt||function(){return We.Date.now()};function ga(e,t,n){return t=n?void 0:t,Ui(e,128,void 0,void 0,void 0,void 0,t=e&&null==t?e.length:t)}function ya(e,t){var n;if("function"!=typeof t)throw new ge(o);return e=is(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}var va=jr((function(e,t,n){var r=1;if(n.length){var i=Gt(n,Yi(va));r|=32}return Ui(e,r,t,n,i)})),xa=jr((function(e,t,n){var r=3;if(n.length){var i=Gt(n,Yi(xa));r|=32}return Ui(t,r,e,n,i)}));function ba(e,t,n){var r,i,a,s,l,u,c=0,h=!1,d=!1,f=!0;if("function"!=typeof e)throw new ge(o);function p(t){var n=r,o=i;return r=i=void 0,c=t,s=e.apply(o,n)}function m(e){return c=e,l=bo(g,t),h?p(e):s}function _(e){var n=e-u;return void 0===u||n>=t||n<0||d&&e-c>=a}function g(){var e=_a();if(_(e))return y(e);l=bo(g,function(e){var n=t-(e-u);return d?ln(n,a-(e-c)):n}(e))}function y(e){return l=void 0,f&&r?p(e):(r=i=void 0,s)}function v(){var e=_a(),n=_(e);if(r=arguments,i=this,u=e,n){if(void 0===l)return m(u);if(d)return hi(l),l=bo(g,t),p(u)}return void 0===l&&(l=bo(g,t)),s}return t=as(t)||0,qa(n)&&(h=!!n.leading,a=(d="maxWait"in n)?sn(as(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){void 0!==l&&hi(l),c=0,r=u=i=l=void 0},v.flush=function(){return void 0===l?s:y(_a())},v}var wa=jr((function(e,t){return Qn(e,1,t)})),Ta=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Ea(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ge(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ea.Cache||Rn),n}function Sa(e){if("function"!=typeof e)throw new ge(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ea.Cache=Rn;var ka=ui((function(e,t){var n=(t=1==t.length&&Da(t[0])?ft(t[0],zt(Ki())):ft(ar(t,1),zt(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),Oa=xr(function(){return arguments}())?xr:function(e){return $a(e)&&Te.call(e,"callee")&&!Ze.call(e,"callee")},Da=r.isArray,La=Qe?zt(Qe):function(e){return $a(e)&&pr(e)==T};function Ra(e){return null!=e&&Ga(e.length)&&!Va(e)}function Ba(e){return $a(e)&&Ra(e)}var Fa=nn||al,ja=et?zt(et):function(e){return $a(e)&&pr(e)==h};function Ua(e){if(!$a(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Xa(e)}function Va(e){if(!qa(e))return!1;var t=pr(e);return t==f||t==p||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Na(e){return"number"==typeof e&&e==is(e)}function Ga(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $a(e){return null!=e&&"object"==typeof e}var Za=tt?zt(tt):function(e){return $a(e)&&ro(e)==m};function Wa(e){return"number"==typeof e||$a(e)&&pr(e)==_}function Xa(e){if(!$a(e)||pr(e)!=g)return!1;var t=Ne(e);if(null===t)return!0;var n=Te.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==Ce}var Ha=nt?zt(nt):function(e){return $a(e)&&pr(e)==y};var Ya=rt?zt(rt):function(e){return $a(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!Da(e)&&$a(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||$a(e)&&pr(e)==b}var Qa=it?zt(it):function(e){return $a(e)&&Ga(e.length)&&!!Ue[pr(e)]};var es=Li(Cr),ts=Li((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(Ra(e))return Ka(e)?Wt(e):yi(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=ro(e);return(t==m?Vt:t==v?qt:Is)(e)}function rs(e){return e?(e=as(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function is(e){var t=rs(e),n=t%1;return t==t?n?t-n:t:0}function os(e){return e?Yn(is(e),0,4294967295):0}function as(e){if("number"==typeof e)return e;if(Ja(e))return NaN;if(qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=It(e);var n=oe.test(e);return n||se.test(e)?qe(e.slice(2),n?2:8):ie.test(e)?NaN:+e}function ss(e){return vi(e,ws(e))}function ls(e){return null==e?"":Jr(e)}var us=bi((function(e,t){if(fo(t)||Ra(t))vi(t,bs(t),e);else for(var n in t)Te.call(t,n)&&qn(e,n,t[n])})),cs=bi((function(e,t){vi(t,ws(t),e)})),hs=bi((function(e,t,n,r){vi(t,ws(t),e,r)})),ds=bi((function(e,t,n,r){vi(t,bs(t),e,r)})),fs=$i(Hn);var ps=jr((function(e,t){e=pe(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&lo(t[0],t[1],i)&&(r=1);++n1),t})),vi(e,Wi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var ks=$i((function(e,t){return null==e?{}:function(e,t){return Dr(e,t,(function(t,n){return gs(e,n)}))}(e,t)}));function Cs(e,t){if(null==e)return{};var n=ft(Wi(e),(function(e){return[e]}));return t=Ki(t),Dr(e,n,(function(e,n){return t(e,n[0])}))}var Ms=ji(bs),As=ji(ws);function Is(e){return null==e?[]:Pt(e,bs(e))}var zs=Si((function(e,t,n){return t=t.toLowerCase(),e+(n?Ps(t):t)}));function Ps(e){return Us(ls(e).toLowerCase())}function Os(e){return(e=ls(e))&&e.replace(ue,Bt).replace(Oe,"")}var Ds=Si((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ls=Si((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Rs=Ei("toLowerCase");var Bs=Si((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Si((function(e,t,n){return e+(n?" ":"")+Us(t)}));var js=Si((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Us=Ei("toUpperCase");function Vs(e,t,n){return e=ls(e),void 0===(t=n?void 0:t)?function(e){return Be.test(e)}(e)?function(e){return e.match(Le)||[]}(e):function(e){return e.match(Q)||[]}(e):e.match(t)||[]}var Ns=jr((function(e,t){try{return ot(e,void 0,t)}catch(e){return Ua(e)?e:new H(e)}})),Gs=$i((function(e,t){return st(t,(function(t){t=Co(t),Xn(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var $s=Mi(),Zs=Mi(!0);function Ws(e){return e}function Xs(e){return Er("function"==typeof e?e:Kn(e,1))}var Hs=jr((function(e,t){return function(n){return vr(n,e,t)}})),Ys=jr((function(e,t){return function(n){return vr(e,n,t)}}));function Ks(e,t,n){var r=bs(t),i=hr(t,r);null!=n||qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=hr(t,bs(t)));var o=!(qa(n)&&"chain"in n&&!n.chain),a=Va(e);return st(i,(function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=yi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,pt([this.value()],arguments))})})),e}function Js(){}var Qs=Pi(ft),el=Pi(ut),tl=Pi(gt);function nl(e){return uo(e)?St(Co(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Di(),il=Di(!0);function ol(){return[]}function al(){return!1}var sl=zi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=zi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=zi((function(e,t){return e*t}),1),fl=Bi("round"),pl=zi((function(e,t){return e-t}),0);return An.after=function(e,t){if("function"!=typeof t)throw new ge(o);return e=is(e),function(){if(--e<1)return t.apply(this,arguments)}},An.ary=ga,An.assign=us,An.assignIn=cs,An.assignInWith=hs,An.assignWith=ds,An.at=fs,An.before=ya,An.bind=va,An.bindAll=Gs,An.bindKey=xa,An.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Da(e)?e:[e]},An.chain=na,An.chunk=function(e,t,n){t=(n?lo(e,t,n):void 0===t)?1:sn(is(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=r(Qt(i/t));oi?0:i+n),(r=void 0===r||r>i?i:is(r))<0&&(r+=i),r=n>r?0:os(r);n>>0)?(e=ls(e))&&("string"==typeof t||null!=t&&!Ha(t))&&!(t=Jr(t))&&Ut(e)?ci(Wt(e),0,n):e.split(t,n):[]},An.spread=function(e,t){if("function"!=typeof e)throw new ge(o);return t=null==t?0:sn(is(t),0),jr((function(n){var r=n[t],i=ci(n,0,t);return r&&pt(i,r),ot(e,this,i)}))},An.tail=function(e){var t=null==e?0:e.length;return t?Zr(e,1,t):[]},An.take=function(e,t,n){return e&&e.length?Zr(e,0,(t=n||void 0===t?1:is(t))<0?0:t):[]},An.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Zr(e,(t=r-(t=n||void 0===t?1:is(t)))<0?0:t,r):[]},An.takeRightWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3),!1,!0):[]},An.takeWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3)):[]},An.tap=function(e,t){return t(e),e},An.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new ge(o);return qa(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),ba(e,t,{leading:r,maxWait:t,trailing:i})},An.thru=ra,An.toArray=ns,An.toPairs=Ms,An.toPairsIn=As,An.toPath=function(e){return Da(e)?ft(e,Co):Ja(e)?[e]:yi(ko(ls(e)))},An.toPlainObject=ss,An.transform=function(e,t,n){var r=Da(e),i=r||Fa(e)||Qa(e);if(t=Ki(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:qa(e)&&Va(o)?In(Ne(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},An.unary=function(e){return ga(e,1)},An.union=$o,An.unionBy=Zo,An.unionWith=Wo,An.uniq=function(e){return e&&e.length?Qr(e):[]},An.uniqBy=function(e,t){return e&&e.length?Qr(e,Ki(t,2)):[]},An.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Qr(e,void 0,t):[]},An.unset=function(e,t){return null==e||ei(e,t)},An.unzip=Xo,An.unzipWith=Ho,An.update=function(e,t,n){return null==e?e:ti(e,t,si(n))},An.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:ti(e,t,si(n),r)},An.values=Is,An.valuesIn=function(e){return null==e?[]:Pt(e,ws(e))},An.without=Yo,An.words=Vs,An.wrap=function(e,t){return Ca(si(t),e)},An.xor=Ko,An.xorBy=Jo,An.xorWith=Qo,An.zip=ea,An.zipObject=function(e,t){return oi(e||[],t||[],qn)},An.zipObjectDeep=function(e,t){return oi(e||[],t||[],Nr)},An.zipWith=ta,An.entries=Ms,An.entriesIn=As,An.extend=cs,An.extendWith=hs,Ks(An,An),An.add=sl,An.attempt=Ns,An.camelCase=zs,An.capitalize=Ps,An.ceil=ll,An.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=as(n))==n?n:0),void 0!==t&&(t=(t=as(t))==t?t:0),Yn(as(e),t,n)},An.clone=function(e){return Kn(e,4)},An.cloneDeep=function(e){return Kn(e,5)},An.cloneDeepWith=function(e,t){return Kn(e,5,t="function"==typeof t?t:void 0)},An.cloneWith=function(e,t){return Kn(e,4,t="function"==typeof t?t:void 0)},An.conformsTo=function(e,t){return null==t||Jn(e,t,bs(t))},An.deburr=Os,An.defaultTo=function(e,t){return null==e||e!=e?t:e},An.divide=ul,An.endsWith=function(e,t,n){e=ls(e),t=Jr(t);var r=e.length,i=n=void 0===n?r:Yn(is(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},An.eq=Ia,An.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},An.escapeRegExp=function(e){return(e=ls(e))&&W.test(e)?e.replace(Z,"\\$&"):e},An.every=function(e,t,n){var r=Da(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},An.find=aa,An.findIndex=Oo,An.findKey=function(e,t){return vt(e,Ki(t,3),ur)},An.findLast=sa,An.findLastIndex=Do,An.findLastKey=function(e,t){return vt(e,Ki(t,3),cr)},An.floor=cl,An.forEach=la,An.forEachRight=ua,An.forIn=function(e,t){return null==e?e:sr(e,Ki(t,3),ws)},An.forInRight=function(e,t){return null==e?e:lr(e,Ki(t,3),ws)},An.forOwn=function(e,t){return e&&ur(e,Ki(t,3))},An.forOwnRight=function(e,t){return e&&cr(e,Ki(t,3))},An.get=_s,An.gt=za,An.gte=Pa,An.has=function(e,t){return null!=e&&io(e,t,_r)},An.hasIn=gs,An.head=Ro,An.identity=Ws,An.includes=function(e,t,n,r){e=Ra(e)?e:Is(e),n=n&&!r?is(n):0;var i=e.length;return n<0&&(n=sn(i+n,0)),Ka(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&bt(e,t,n)>-1},An.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:is(n);return i<0&&(i=sn(r+i,0)),bt(e,t,i)},An.inRange=function(e,t,n){return t=rs(t),void 0===n?(n=t,t=0):n=rs(n),function(e,t,n){return e>=ln(t,n)&&e=-9007199254740991&&e<=9007199254740991},An.isSet=Ya,An.isString=Ka,An.isSymbol=Ja,An.isTypedArray=Qa,An.isUndefined=function(e){return void 0===e},An.isWeakMap=function(e){return $a(e)&&ro(e)==w},An.isWeakSet=function(e){return $a(e)&&"[object WeakSet]"==pr(e)},An.join=function(e,t){return null==e?"":on.call(e,t)},An.kebabCase=Ds,An.last=Uo,An.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=is(n))<0?sn(r+i,0):ln(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):xt(e,Tt,i,!0)},An.lowerCase=Ls,An.lowerFirst=Rs,An.lt=es,An.lte=ts,An.max=function(e){return e&&e.length?ir(e,Ws,mr):void 0},An.maxBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),mr):void 0},An.mean=function(e){return Et(e,Ws)},An.meanBy=function(e,t){return Et(e,Ki(t,2))},An.min=function(e){return e&&e.length?ir(e,Ws,Cr):void 0},An.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),Cr):void 0},An.stubArray=ol,An.stubFalse=al,An.stubObject=function(){return{}},An.stubString=function(){return""},An.stubTrue=function(){return!0},An.multiply=dl,An.nth=function(e,t){return e&&e.length?Pr(e,is(t)):void 0},An.noConflict=function(){return We._===this&&(We._=Me),this},An.noop=Js,An.now=_a,An.pad=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Oi(en(i),n)+e+Oi(Qt(i),n)},An.padEnd=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var i=hn();return ln(e+i*(t-e+Ge("1e-"+((i+"").length-1))),t)}return Br(e,t)},An.reduce=function(e,t,n){var r=Da(e)?mt:Ct,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},An.reduceRight=function(e,t,n){var r=Da(e)?_t:Ct,i=arguments.length<3;return r(e,Ki(t,4),n,i,nr)},An.repeat=function(e,t,n){return t=(n?lo(e,t,n):void 0===t)?1:is(t),Fr(ls(e),t)},An.replace=function(){var e=arguments,t=ls(e[0]);return e.length<3?t:t.replace(e[1],e[2])},An.result=function(e,t,n){var r=-1,i=(t=li(t,e)).length;for(i||(i=1,e=void 0);++r9007199254740991)return[];var n=4294967295,r=ln(e,4294967295);e-=4294967295;for(var i=At(r,t=Ki(t));++n=o)return e;var s=n-Zt(r);if(s<1)return r;var l=a?ci(a,0,s).join(""):e.slice(0,s);if(void 0===i)return l+r;if(a&&(s+=l.length-s),Ha(i)){if(e.slice(s).search(i)){var u,c=l;for(i.global||(i=me(i.source,ls(re.exec(i))+"g")),i.lastIndex=0;u=i.exec(c);)var h=u.index;l=l.slice(0,void 0===h?s:h)}}else if(e.indexOf(Jr(i),s)!=s){var d=l.lastIndexOf(i);d>-1&&(l=l.slice(0,d))}return l+r},An.unescape=function(e){return(e=ls(e))&&F.test(e)?e.replace(R,Ht):e},An.uniqueId=function(e){var t=++Ee;return ls(e)+t},An.upperCase=js,An.upperFirst=Us,An.each=la,An.eachRight=ua,An.first=Ro,Ks(An,(hl={},ur(An,(function(e,t){Te.call(An.prototype,t)||(hl[t]=e)})),hl),{chain:!1}),An.VERSION="4.17.21",st(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){An[e].placeholder=An})),st(["drop","take"],(function(e,t){On.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new On(this):this.clone();return r.__filtered__?r.__takeCount__=ln(n,r.__takeCount__):r.__views__.push({size:ln(n,4294967295),type:e+(r.__dir__<0?"Right":"")}),r},On.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),st(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;On.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ki(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),st(["head","last"],(function(e,t){var n="take"+(t?"Right":"");On.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");On.prototype[e]=function(){return this.__filtered__?new On(this):this[n](1)}})),On.prototype.compact=function(){return this.filter(Ws)},On.prototype.find=function(e){return this.filter(e).head()},On.prototype.findLast=function(e){return this.reverse().find(e)},On.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new On(this):this.map((function(n){return vr(n,e,t)}))})),On.prototype.reject=function(e){return this.filter(Sa(Ki(e)))},On.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new On(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(n=(t=is(t))<0?n.dropRight(-t):n.take(t-e)),n)},On.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},On.prototype.toArray=function(){return this.take(4294967295)},ur(On.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=An[r?"take"+("last"==t?"Right":""):t],o=r||/^find/.test(t);i&&(An.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,s=t instanceof On,l=a[0],u=s||Da(t),c=function(e){var t=i.apply(An,pt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof l&&1!=l.length&&(s=u=!1);var h=this.__chain__,d=!!this.__actions__.length,f=o&&!h,p=s&&!d;if(!o&&u){t=p?t:new On(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new Pn(m,h)}return f&&p?e.apply(this,a):(m=this.thru(c),f?r?m.value()[0]:m.value():m)})})),st(["pop","push","shift","sort","splice","unshift"],(function(e){var t=ye[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);An.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Da(i)?i:[],e)}return this[n]((function(n){return t.apply(Da(n)?n:[],e)}))}})),ur(On.prototype,(function(e,t){var n=An[t];if(n){var r=n.name+"";Te.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ai(void 0,2).name]=[{name:"wrapper",func:void 0}],On.prototype.clone=function(){var e=new On(this.__wrapped__);return e.__actions__=yi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=yi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=yi(this.__views__),e},On.prototype.reverse=function(){if(this.__filtered__){var e=new On(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},On.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Da(e),r=t<0,i=n?e.length:0,o=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?void 0:this.__values__[this.__index__++]}},An.prototype.plant=function(e){for(var t,n=this;n instanceof zn;){var r=Ao(n);r.__index__=0,r.__values__=void 0,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},An.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof On){var t=e;return this.__actions__.length&&(t=new On(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new Pn(t,this.__chain__)}return this.thru(qo)},An.prototype.toJSON=An.prototype.valueOf=An.prototype.value=function(){return ri(this.__wrapped__,this.__actions__)},An.prototype.first=An.prototype.head,Ke&&(An.prototype[Ke]=function(){return this}),An}();We._=Yt,void 0===(i=function(){return Yt}.call(t,n,t,r))||(r.exports=i)}).call(this)}).call(this,n(19),n(80)(e))},function(e,t,n){"use strict";var r=n(0),i=n.n(r),o=n(7),a=n.n(o);function s(){return(s=Object.assign||function(e){for(var t=1;t=d.top+d.height||p.left+p.width>=d.left+d.width))break;u++}return l},f=0,p=Object(r.forwardRef)((function(e,t){var n=e.trigger,o=void 0===n?null:n,c=e.onOpen,h=void 0===c?function(){}:c,p=e.onClose,m=void 0===p?function(){}:p,_=e.defaultOpen,g=void 0!==_&&_,y=e.open,v=void 0===y?void 0:y,x=e.disabled,b=void 0!==x&&x,w=e.nested,T=void 0!==w&&w,E=e.closeOnDocumentClick,S=void 0===E||E,k=e.repositionOnResize,C=void 0===k||k,M=e.closeOnEscape,A=void 0===M||M,I=e.on,z=void 0===I?["click"]:I,P=e.contentStyle,O=void 0===P?{}:P,D=e.arrowStyle,L=void 0===D?{}:D,R=e.overlayStyle,B=void 0===R?{}:R,F=e.className,j=void 0===F?"":F,U=e.position,V=void 0===U?"bottom center":U,N=e.modal,G=void 0!==N&&N,q=e.lockScroll,$=void 0!==q&&q,Z=e.arrow,W=void 0===Z||Z,X=e.offsetX,H=void 0===X?0:X,Y=e.offsetY,K=void 0===Y?0:Y,J=e.mouseEnterDelay,Q=void 0===J?100:J,ee=e.mouseLeaveDelay,te=void 0===ee?100:ee,ne=e.keepTooltipInside,re=void 0!==ne&&ne,ie=e.children,oe=Object(r.useState)(v||g),ae=oe[0],se=oe[1],le=Object(r.useRef)(null),ue=Object(r.useRef)(null),ce=Object(r.useRef)(null),he=Object(r.useRef)(null),de=Object(r.useRef)("popup-"+ ++f),fe=!!G||!o,pe=Object(r.useRef)(0);l((function(){return ae?(he.current=document.activeElement,ke(),Te(),be()):we(),function(){clearTimeout(pe.current)}}),[ae]),Object(r.useEffect)((function(){"boolean"==typeof v&&(v?me():_e())}),[v,b]);var me=function(e){ae||b||(se(!0),setTimeout((function(){return h(e)}),0))},_e=function(e){var t;ae&&!b&&(se(!1),fe&&(null===(t=he.current)||void 0===t||t.focus()),setTimeout((function(){return m(e)}),0))},ge=function(e){null==e||e.stopPropagation(),ae?_e(e):me(e)},ye=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return me(e)}),Q)},ve=function(e){null==e||e.preventDefault(),ge()},xe=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return _e(e)}),te)},be=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Te=function(){var e,t=null==ue||null===(e=ue.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),n=Array.prototype.slice.call(t)[0];null==n||n.focus()};Object(r.useImperativeHandle)(t,(function(){return{open:function(){me()},close:function(){_e()},toggle:function(){ge()}}}));var Ee,Se,ke=function(){if(!fe&&ae&&(null==le?void 0:le.current)&&(null==le?void 0:le.current)&&(null==ue?void 0:ue.current)){var e,t,n=le.current.getBoundingClientRect(),r=ue.current.getBoundingClientRect(),i=d(n,r,V,W,{offsetX:H,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",W&&ce.current)ce.current.style.transform=i.transform,ce.current.style.setProperty("-ms-transform",i.transform),ce.current.style.setProperty("-webkit-transform",i.transform),ce.current.style.top=(null===(e=L.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=L.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Ee=_e,void 0===(Se=A)&&(Se=!0),Object(r.useEffect)((function(){if(Se){var e=function(e){"Escape"===e.key&&Ee(e)};return document.addEventListener("keyup",e),function(){Se&&document.removeEventListener("keyup",e)}}}),[Ee,Se]),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(t){if(9===t.keyCode){var n,r=null==e||null===(n=e.current)||void 0===n?void 0:n.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(r);if(1===i.length)return void t.preventDefault();var o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",n),function(){t&&document.removeEventListener("keydown",n)}}}),[e,t])}(ue,ae&&fe),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(){e()};return window.addEventListener("resize",n),function(){t&&window.removeEventListener("resize",n)}}}),[e,t])}(ke,C),function(e,t,n){void 0===n&&(n=!0),Object(r.useEffect)((function(){if(n){var r=function(n){var r=Array.isArray(e)?e:[e],i=!1;r.forEach((function(e){e.current&&!e.current.contains(n.target)||(i=!0)})),n.stopPropagation(),i||t(n)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),function(){n&&(document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r))}}}),[e,t,n])}(o?[ue,le]:[ue],_e,S&&!T);var Ce,Me=function(){return i.a.createElement("div",Object.assign({},(e=fe?u.popupContent.modal:u.popupContent.tooltip,t={className:"popup-content "+(""!==j?j.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:s({},e,O,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&z.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),W&&!fe&&i.a.createElement("div",{ref:ce,style:u.popupArrow},i.a.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==j?j.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:s({position:"absolute"},L)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(_e,ae):ie);var e,t},Ae=!(z.indexOf("hover")>=0),Ie=fe?u.overlay.modal:u.overlay.tooltip,ze=[Ae&&i.a.createElement("div",{key:"O","data-testid":"overlay","data-popup":fe?"modal":"tooltip",className:"popup-overlay "+(""!==j?j.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:s({},Ie,B,{pointerEvents:S&&T||fe?"auto":"none"}),onClick:S&&T?_e:void 0,tabIndex:-1},fe&&Me()),!fe&&Me()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(z)?z:[z],n=0,r=t.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var c=n(0),h=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;te.brand+"/"+e.version).join(" "):navigator.userAgent}function C(e){return e instanceof T(e).HTMLElement}function M(e){return e instanceof T(e).Element}function A(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof T(e).ShadowRoot||e instanceof ShadowRoot}function I(e){const{overflow:t,overflowX:n,overflowY:r}=E(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function z(){return!/^((?!chrome|android).)*safari/i.test(k())}Math.min,Math.max;const P=Math.round;function O(e,t,n){var r,i,o,a;void 0===t&&(t=!1),void 0===n&&(n=!1);const s=e.getBoundingClientRect();let l=1,u=1;t&&C(e)&&(l=e.offsetWidth>0&&P(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&P(s.height)/e.offsetHeight||1);const c=M(e)?T(e):window,h=!z()&&n,d=(s.left+(h&&null!=(r=null==(i=c.visualViewport)?void 0:i.offsetLeft)?r:0))/l,f=(s.top+(h&&null!=(o=null==(a=c.visualViewport)?void 0:a.offsetTop)?o:0))/u,p=s.width/l,m=s.height/u;return{width:p,height:m,top:f,right:d+p,bottom:f+m,left:d,x:d,y:f}}function D(e){return(t=e,(t instanceof T(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function L(e){return"html"===S(e)?e:e.assignedSlot||e.parentNode||(A(e)?e.host:null)||D(e)}function R(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=L(t);return["html","body","#document"].includes(S(n))?t.ownerDocument.body:C(n)&&I(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=T(r),a=i?[o].concat(o.visualViewport||[],I(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(R(a))}var B=c.useLayoutEffect,F=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],j=function(){};function U(e,t){return t?"-"===t[0]?e+t:e+"__"+t:e}function V(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i-1}function Z(e){return $(e)?window.pageYOffset:e.scrollTop}function W(e,t){$(e)?window.scrollTo(0,t):e.scrollTop=t}function X(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function H(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:j,i=Z(e),o=t-i,a=10,s=0;function l(){var t=X(s+=a,i,o,n);W(e,t),sn.bottom?W(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(E>=p&&!a)return o&&H(l,S,160),{placement:"bottom",maxHeight:t};if(!a&&E>=r||a&&w>=r)return o&&H(l,S,160),{placement:"bottom",maxHeight:a?w-v:E-v};if("auto"===i||a){var C=t,M=a?b:T;return M>=r&&(C=Math.min(M-v-s,t)),{placement:"top",maxHeight:C}}if("bottom"===i)return o&&W(l,S),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(T>=p&&!a)return o&&H(l,k,160),{placement:"top",maxHeight:t};if(!a&&T>=r||a&&b>=r){var A=t;return(!a&&T>=r||a&&b>=r)&&(A=a?b-x:T-x),o&&H(l,k,160),{placement:"top",maxHeight:A}}return{placement:"bottom",maxHeight:t};default:throw new Error('Invalid placement provided "'.concat(i,'".'))}return u}var oe=function(e){return"auto"===e?"bottom":e},ae=Object(c.createContext)(null),se=function(e){var t=e.children,n=e.minMenuHeight,r=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,s=e.menuShouldScrollIntoView,u=e.theme,h=(Object(c.useContext)(ae)||{}).setPortalPlacement,d=Object(c.useRef)(null),f=l(Object(c.useState)(r),2),p=f[0],m=f[1],_=l(Object(c.useState)(null),2),g=_[0],y=_[1],v=u.spacing.controlHeight;return B((function(){var e=d.current;if(e){var t="fixed"===a,o=ie({maxHeight:r,menuEl:e,minHeight:n,placement:i,shouldScroll:s&&!t,isFixedPosition:t,controlHeight:v});m(o.maxHeight),y(o.placement),null==h||h(o.placement)}}),[r,i,a,s,n,h,v]),t({ref:d,placerProps:o(o({},e),{},{placement:g||oe(i),maxHeight:p})})},le=function(e,t){var n=e.theme,r=n.spacing.baseUnit,i=n.colors;return o({textAlign:"center"},t?{}:{color:i.neutral40,padding:"".concat(2*r,"px ").concat(3*r,"px")})},ue=le,ce=le,he=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),n),t)};he.defaultProps={children:"No options"};var de=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),n),t)};de.defaultProps={children:"Loading..."};var fe,pe=["size"];var me,_e,ge={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},ye=function(e){var t=e.size,n=u(e,pe);return Object(x.c)("svg",d({height:t,width:t,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:ge},n))},ve=function(e){return Object(x.c)(ye,d({size:20},e),Object(x.c)("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},xe=function(e){return Object(x.c)(ye,d({size:20},e),Object(x.c)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},be=function(e,t){var n=e.isFocused,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorContainer",display:"flex",transition:"color 150ms"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*i,":hover":{color:n?a.neutral80:a.neutral40}})},we=be,Te=be,Ee=Object(x.d)(fe||(me=["\n 0%, 80%, 100% { opacity: 0; }\n 40% { opacity: 1; }\n"],_e||(_e=me.slice(0)),fe=Object.freeze(Object.defineProperties(me,{raw:{value:Object.freeze(_e)}})))),Se=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(Ee," 1s ease-in-out ").concat(t,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:n?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},ke=function(e){var t=e.innerProps,n=e.isRtl;return Object(x.c)("div",d({},q(e,"loadingIndicator",{indicator:!0,"loading-indicator":!0}),t),Object(x.c)(Se,{delay:0,offset:n}),Object(x.c)(Se,{delay:160,offset:!0}),Object(x.c)(Se,{delay:320,offset:!n}))};ke.defaultProps={size:4};var Ce=["data"],Me=["innerRef","isDisabled","isHidden","inputClassName"],Ae={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Ie={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":o({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Ae)},ze=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Ae)},Pe=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var Oe={ClearIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),n),t||Object(x.c)(ve,null))},Control:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.innerRef,o=e.innerProps,a=e.menuIsOpen;return Object(x.c)("div",d({ref:i},q(e,"control",{control:!0,"control--is-disabled":n,"control--is-focused":r,"control--menu-is-open":a}),o),t)},DropdownIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),n),t||Object(x.c)(xe,null))},DownChevron:xe,CrossIcon:ve,Group:function(e){var t=e.children,n=e.cx,r=e.getStyles,i=e.getClassNames,o=e.Heading,a=e.headingProps,s=e.innerProps,l=e.label,u=e.theme,c=e.selectProps;return Object(x.c)("div",d({},q(e,"group",{group:!0}),s),Object(x.c)(o,d({},a,{selectProps:c,theme:u,getStyles:r,getClassNames:i,cx:n}),l),Object(x.c)("div",null,t))},GroupHeading:function(e){var t=G(e);t.data;var n=u(t,Ce);return Object(x.c)("div",d({},q(e,"groupHeading",{"group-heading":!0}),n))},IndicatorsContainer:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"indicatorsContainer",{indicators:!0}),n),t)},IndicatorSeparator:function(e){var t=e.innerProps;return Object(x.c)("span",d({},t,q(e,"indicatorSeparator",{"indicator-separator":!0})))},Input:function(e){var t=e.cx,n=e.value,r=G(e),i=r.innerRef,o=r.isDisabled,a=r.isHidden,s=r.inputClassName,l=u(r,Me);return Object(x.c)("div",d({},q(e,"input",{"input-container":!0}),{"data-value":n||""}),Object(x.c)("input",d({className:t({input:!0},s),ref:i,style:ze(a),disabled:o},l)))},LoadingIndicator:ke,Menu:function(e){var t=e.children,n=e.innerRef,r=e.innerProps;return Object(x.c)("div",d({},q(e,"menu",{menu:!0}),{ref:n},r),t)},MenuList:function(e){var t=e.children,n=e.innerProps,r=e.innerRef,i=e.isMulti;return Object(x.c)("div",d({},q(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:r},n),t)},MenuPortal:function(e){var t=e.appendTo,n=e.children,r=e.controlElement,i=e.innerProps,a=e.menuPlacement,s=e.menuPosition,u=Object(c.useRef)(null),h=Object(c.useRef)(null),f=l(Object(c.useState)(oe(a)),2),p=f[0],m=f[1],_=Object(c.useMemo)((function(){return{setPortalPlacement:m}}),[]),g=l(Object(c.useState)(null),2),y=g[0],v=g[1],w=Object(c.useCallback)((function(){if(r){var e=function(e){var t=e.getBoundingClientRect();return{bottom:t.bottom,height:t.height,left:t.left,right:t.right,top:t.top,width:t.width}}(r),t="fixed"===s?0:window.pageYOffset,n=e[p]+t;n===(null==y?void 0:y.offset)&&e.left===(null==y?void 0:y.rect.left)&&e.width===(null==y?void 0:y.rect.width)||v({offset:n,rect:e})}}),[r,s,p,null==y?void 0:y.offset,null==y?void 0:y.rect.left,null==y?void 0:y.rect.width]);B((function(){w()}),[w]);var T=Object(c.useCallback)((function(){"function"==typeof h.current&&(h.current(),h.current=null),r&&u.current&&(h.current=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,l=i&&!s,u=o&&!s,c=l||u?[...M(e)?R(e):[],...R(t)]:[];c.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),u&&e.addEventListener("resize",n)});let h,d=null;if(a){let r=!0;d=new ResizeObserver(()=>{r||n(),r=!1}),M(e)&&!s&&d.observe(e),d.observe(t)}let f=s?O(e):null;return s&&function t(){const r=O(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n();f=r,h=requestAnimationFrame(t)}(),n(),()=>{var e;c.forEach(e=>{l&&e.removeEventListener("scroll",n),u&&e.removeEventListener("resize",n)}),null==(e=d)||e.disconnect(),d=null,s&&cancelAnimationFrame(h)}}(r,u.current,w,{elementResize:"ResizeObserver"in window}))}),[r,w]);B((function(){T()}),[T]);var E=Object(c.useCallback)((function(e){u.current=e,T()}),[T]);if(!t&&"fixed"!==s||!y)return null;var S=Object(x.c)("div",d({ref:E},q(o(o({},e),{},{offset:y.offset,position:s,rect:y.rect}),"menuPortal",{"menu-portal":!0}),i),n);return Object(x.c)(ae.Provider,{value:_},t?Object(b.createPortal)(S,t):S)},LoadingMessage:de,NoOptionsMessage:he,MultiValue:function(e){var t=e.children,n=e.components,r=e.data,i=e.innerProps,a=e.isDisabled,s=e.removeProps,l=e.selectProps,u=n.Container,c=n.Label,h=n.Remove;return Object(x.c)(u,{data:r,innerProps:o(o({},q(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:l},Object(x.c)(c,{data:r,innerProps:o({},q(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},t),Object(x.c)(h,{data:r,innerProps:o(o({},q(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(t||"option")},s),selectProps:l}))},MultiValueContainer:Pe,MultiValueLabel:Pe,MultiValueRemove:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({role:"button"},n),t||Object(x.c)(ve,{size:14}))},Option:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.isSelected,o=e.innerRef,a=e.innerProps;return Object(x.c)("div",d({},q(e,"option",{option:!0,"option--is-disabled":n,"option--is-focused":r,"option--is-selected":i}),{ref:o,"aria-disabled":n},a),t)},Placeholder:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"placeholder",{placeholder:!0}),n),t)},SelectContainer:function(e){var t=e.children,n=e.innerProps,r=e.isDisabled,i=e.isRtl;return Object(x.c)("div",d({},q(e,"container",{"--is-disabled":r,"--is-rtl":i}),n),t)},SingleValue:function(e){var t=e.children,n=e.isDisabled,r=e.innerProps;return Object(x.c)("div",d({},q(e,"singleValue",{"single-value":!0,"single-value--is-disabled":n}),r),t)},ValueContainer:function(e){var t=e.children,n=e.innerProps,r=e.isMulti,i=e.hasValue;return Object(x.c)("div",d({},q(e,"valueContainer",{"value-container":!0,"value-container--is-multi":r,"value-container--has-value":i}),n),t)}},De=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function Le(e,t){if(e.length!==t.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return"option ".concat(r,o?" is disabled. Select another option.":", selected.");default:return""}},onFocus:function(e){var t=e.context,n=e.focused,r=e.options,i=e.label,o=void 0===i?"":i,a=e.selectValue,s=e.isDisabled,l=e.isSelected,u=function(e,t){return e&&e.length?"".concat(e.indexOf(t)+1," of ").concat(e.length):""};if("value"===t&&a)return"value ".concat(o," focused, ").concat(u(a,n),".");if("menu"===t){var c=s?" disabled":"",h="".concat(l?"selected":"focused").concat(c);return"option ".concat(o," ").concat(h,", ").concat(u(r,n),".")}return""},onFilter:function(e){var t=e.inputValue,n=e.resultsMessage;return"".concat(n).concat(t?" for search term "+t:"",".")}},je=function(e){var t=e.ariaSelection,n=e.focusedOption,r=e.focusedValue,i=e.focusableOptions,a=e.isFocused,s=e.selectValue,l=e.selectProps,u=e.id,h=l.ariaLiveMessages,d=l.getOptionLabel,f=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,_=l.isSearchable,g=l.menuIsOpen,y=l.options,v=l.screenReaderStatus,b=l.tabSelectsValue,w=l["aria-label"],T=l["aria-live"],E=Object(c.useMemo)((function(){return o(o({},Fe),h||{})}),[h]),S=Object(c.useMemo)((function(){var e,n="";if(t&&E.onChange){var r=t.option,i=t.options,a=t.removedValue,l=t.removedValues,u=t.value,c=a||r||(e=u,Array.isArray(e)?null:e),h=c?d(c):"",f=i||l||void 0,p=f?f.map(d):[],_=o({isDisabled:c&&m(c,s),label:h,labels:p},t);n=E.onChange(_)}return n}),[t,E,m,s,d]),k=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&E.onFocus){var a={focused:t,label:d(t),isDisabled:m(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s};e=E.onFocus(a)}return e}),[n,r,d,m,E,i,s]),C=Object(c.useMemo)((function(){var e="";if(g&&y.length&&E.onFilter){var t=v({count:i.length});e=E.onFilter({inputValue:f,resultsMessage:t})}return e}),[i,f,g,E,y,v]),M=Object(c.useMemo)((function(){var e="";if(E.guidance){var t=r?"value":g?"menu":"input";e=E.guidance({"aria-label":w,context:t,isDisabled:n&&m(n,s),isMulti:p,isSearchable:_,tabSelectsValue:b})}return e}),[w,n,r,p,m,_,g,E,s,b]),A="".concat(k," ").concat(C," ").concat(M),I=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},S),Object(x.c)("span",{id:"aria-context"},A)),z="initial-input-focus"===(null==t?void 0:t.action);return Object(x.c)(c.Fragment,null,Object(x.c)(Be,{id:u},z&&I),Object(x.c)(Be,{"aria-live":T,"aria-atomic":"false","aria-relevant":"additions text"},a&&!z&&I))},Ue=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],Ve=new RegExp("["+Ue.map((function(e){return e.letters})).join("")+"]","g"),Ne={},Ge=0;Ge1?t-1:0),r=1;r0,m=h-d-c,_=!1;m>t&&a.current&&(r&&r(e),a.current=!1),p&&s.current&&(o&&o(e),s.current=!1),p&&t>m?(n&&!a.current&&n(e),f.scrollTop=h,_=!0,a.current=!0):!p&&-t>c&&(i&&!s.current&&i(e),f.scrollTop=0,_=!0,s.current=!0),_&&function(e){e.preventDefault(),e.stopPropagation()}(e)}}),[n,r,i,o]),d=Object(c.useCallback)((function(e){h(e,e.deltaY)}),[h]),f=Object(c.useCallback)((function(e){l.current=e.changedTouches[0].clientY}),[]),p=Object(c.useCallback)((function(e){var t=l.current-e.changedTouches[0].clientY;h(e,t)}),[h]),m=Object(c.useCallback)((function(e){if(e){var t=!!te&&{passive:!1};e.addEventListener("wheel",d,t),e.addEventListener("touchstart",f,t),e.addEventListener("touchmove",p,t)}}),[p,f,d]),_=Object(c.useCallback)((function(e){e&&(e.removeEventListener("wheel",d,!1),e.removeEventListener("touchstart",f,!1),e.removeEventListener("touchmove",p,!1))}),[p,f,d]);return Object(c.useEffect)((function(){if(t){var e=u.current;return m(e),function(){_(e)}}}),[t,m,_]),function(e){u.current=e}}({isEnabled:void 0===r||r,onBottomArrive:e.onBottomArrive,onBottomLeave:e.onBottomLeave,onTopArrive:e.onTopArrive,onTopLeave:e.onTopLeave}),o=function(e){var t=e.isEnabled,n=e.accountForScrollbars,r=void 0===n||n,i=Object(c.useRef)({}),o=Object(c.useRef)(null),a=Object(c.useCallback)((function(e){if(it){var t=document.body,n=t&&t.style;if(r&&Je.forEach((function(e){var t=n&&n[e];i.current[e]=t})),r&&ot<1){var o=parseInt(i.current.paddingRight,10)||0,a=document.body?document.body.clientWidth:0,s=window.innerWidth-a+o||0;Object.keys(Qe).forEach((function(e){var t=Qe[e];n&&(n[e]=t)})),n&&(n.paddingRight="".concat(s,"px"))}t&&rt()&&(t.addEventListener("touchmove",et,at),e&&(e.addEventListener("touchstart",nt,at),e.addEventListener("touchmove",tt,at))),ot+=1}}),[r]),s=Object(c.useCallback)((function(e){if(it){var t=document.body,n=t&&t.style;ot=Math.max(ot-1,0),r&&ot<1&&Je.forEach((function(e){var t=i.current[e];n&&(n[e]=t)})),t&&rt()&&(t.removeEventListener("touchmove",et,at),e&&(e.removeEventListener("touchstart",nt,at),e.removeEventListener("touchmove",tt,at)))}}),[r]);return Object(c.useEffect)((function(){if(t){var e=o.current;return a(e),function(){s(e)}}}),[t,a,s]),function(e){o.current=e}}({isEnabled:n});return Object(x.c)(c.Fragment,null,n&&Object(x.c)("div",{onClick:st,css:lt}),t((function(e){i(e),o(e)})))}var ct={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},ht=function(e){var t=e.name,n=e.onFocus;return Object(x.c)("input",{required:!0,name:t,tabIndex:-1,onFocus:n,css:ct,value:"",onChange:function(){}})},dt={clearIndicator:Te,container:function(e){var t=e.isDisabled;return{label:"container",direction:e.isRtl?"rtl":void 0,pointerEvents:t?"none":void 0,position:"relative"}},control:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.theme,a=i.colors,s=i.borderRadius;return o({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:i.spacing.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},t?{}:{backgroundColor:n?a.neutral5:a.neutral0,borderColor:n?a.neutral10:r?a.primary:a.neutral20,borderRadius:s,borderStyle:"solid",borderWidth:1,boxShadow:r?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:r?a.primary:a.neutral30}})},dropdownIndicator:we,group:function(e,t){var n=e.theme.spacing;return t?{}:{paddingBottom:2*n.baseUnit,paddingTop:2*n.baseUnit}},groupHeading:function(e,t){var n=e.theme,r=n.colors,i=n.spacing;return o({label:"group",cursor:"default",display:"block"},t?{}:{color:r.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:3*i.baseUnit,paddingRight:3*i.baseUnit,textTransform:"uppercase"})},indicatorsContainer:function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},indicatorSeparator:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorSeparator",alignSelf:"stretch",width:1},t?{}:{backgroundColor:n?a.neutral10:a.neutral20,marginBottom:2*i,marginTop:2*i})},input:function(e,t){var n=e.isDisabled,r=e.value,i=e.theme,a=i.spacing,s=i.colors;return o(o({visibility:n?"hidden":"visible",transform:r?"translateZ(0)":""},Ie),t?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:s.neutral80})},loadingIndicator:function(e,t){var n=e.isFocused,r=e.size,i=e.theme,a=i.colors,s=i.spacing.baseUnit;return o({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:r,lineHeight:1,marginRight:r,textAlign:"center",verticalAlign:"middle"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*s})},loadingMessage:ce,menu:function(e,t){var n,i=e.placement,a=e.theme,s=a.borderRadius,l=a.spacing,u=a.colors;return o((r(n={label:"menu"},function(e){return e?{bottom:"top",top:"bottom"}[e]:"bottom"}(i),"100%"),r(n,"position","absolute"),r(n,"width","100%"),r(n,"zIndex",1),n),t?{}:{backgroundColor:u.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:l.menuGutter,marginTop:l.menuGutter})},menuList:function(e,t){var n=e.maxHeight,r=e.theme.spacing.baseUnit;return o({maxHeight:n,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},t?{}:{paddingBottom:r,paddingTop:r})},menuPortal:function(e){var t=e.rect,n=e.offset,r=e.position;return{left:t.left,position:r,top:n,width:t.width,zIndex:1}},multiValue:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors;return o({label:"multiValue",display:"flex",minWidth:0},t?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:r.baseUnit/2})},multiValueLabel:function(e,t){var n=e.theme,r=n.borderRadius,i=n.colors,a=e.cropWithEllipsis;return o({overflow:"hidden",textOverflow:a||void 0===a?"ellipsis":void 0,whiteSpace:"nowrap"},t?{}:{borderRadius:r/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},multiValueRemove:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors,s=e.isFocused;return o({alignItems:"center",display:"flex"},t?{}:{borderRadius:i/2,backgroundColor:s?a.dangerLight:void 0,paddingLeft:r.baseUnit,paddingRight:r.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},noOptionsMessage:ue,option:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.isSelected,a=e.theme,s=a.spacing,l=a.colors;return o({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},t?{}:{backgroundColor:i?l.primary:r?l.primary25:"transparent",color:n?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(2*s.baseUnit,"px ").concat(3*s.baseUnit,"px"),":active":{backgroundColor:n?void 0:i?l.primary:l.primary50}})},placeholder:function(e,t){var n=e.theme,r=n.spacing,i=n.colors;return o({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},t?{}:{color:i.neutral50,marginLeft:r.baseUnit/2,marginRight:r.baseUnit/2})},singleValue:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing,a=r.colors;return o({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},t?{}:{color:n?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},valueContainer:function(e,t){var n=e.theme.spacing,r=e.isMulti,i=e.hasValue,a=e.selectProps.controlShouldRenderValue;return o({alignItems:"center",display:r&&i&&a?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},t?{}:{padding:"".concat(n.baseUnit/2,"px ").concat(2*n.baseUnit,"px")})}};var ft,pt={borderRadius:4,colors:{primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},spacing:{baseUnit:4,controlHeight:38,menuGutter:8}},mt={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:K(),captureMenuScroll:!K(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:function(e,t){if(e.data.__isNew__)return!0;var n=o({ignoreCase:!0,ignoreAccents:!0,stringify:He,trim:!0,matchFrom:"any"},ft),r=n.ignoreCase,i=n.ignoreAccents,a=n.stringify,s=n.trim,l=n.matchFrom,u=s?Xe(t):t,c=s?Xe(a(e)):a(e);return r&&(u=u.toLowerCase(),c=c.toLowerCase()),i&&(u=We(u),c=Ze(c)),"start"===l?c.substr(0,u.length)===u:c.indexOf(u)>-1},formatGroupLabel:function(e){return e.label},getOptionLabel:function(e){return e.label},getOptionValue:function(e){return e.value},isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:function(e){return!!e.isDisabled},loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!function(){try{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}catch(e){return!1}}(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var t=e.count;return"".concat(t," result").concat(1!==t?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function _t(e,t,n,r){return{type:"option",data:t,isDisabled:wt(e,t,n),isSelected:Tt(e,t,n),label:xt(e,t),value:bt(e,t),index:r}}function gt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return _t(e,n,t,r)})).filter((function(t){return vt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=_t(e,n,t,r);return vt(e,o)?o:void 0})).filter(ne)}function yt(e){return e.reduce((function(e,t){return"group"===t.type?e.push.apply(e,v(t.options.map((function(e){return e.data})))):e.push(t.data),e}),[])}function vt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!St(e)||!o)&&Et(e,{label:a,value:s,data:i},r)}var xt=function(e,t){return e.getOptionLabel(t)},bt=function(e,t){return e.getOptionValue(t)};function wt(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function Tt(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=bt(e,t);return n.some((function(t){return bt(e,t)===r}))}function Et(e,t,n){return!e.filterOption||e.filterOption(t,n)}var St=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},kt=1,Ct=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,n,r,i=y(a);function a(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this,e)).state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(e){t.controlRef=e},t.focusedOptionRef=null,t.getFocusedOptionRef=function(e){t.focusedOptionRef=e},t.menuListRef=null,t.getMenuListRef=function(e){t.menuListRef=e},t.inputRef=null,t.getInputRef=function(e){t.inputRef=e},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(e,n){var r=t.props,i=r.onChange,o=r.name;n.name=o,t.ariaOnChange(e,n),i(e,n)},t.setValue=function(e,n,r){var i=t.props,o=i.closeMenuOnSelect,a=i.isMulti,s=i.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:s}),o&&(t.setState({inputIsHiddenAfterUpdate:!a}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(e,{action:n,option:r})},t.selectOption=function(e){var n=t.props,r=n.blurInputOnSelect,i=n.isMulti,o=n.name,a=t.state.selectValue,s=i&&t.isOptionSelected(e,a),l=t.isOptionDisabled(e,a);if(s){var u=t.getOptionValue(e);t.setValue(a.filter((function(e){return t.getOptionValue(e)!==u})),"deselect-option",e)}else{if(l)return void t.ariaOnChange(e,{action:"select-option",option:e,name:o});i?t.setValue([].concat(v(a),[e]),"select-option",e):t.setValue(e,"select-option")}r&&t.blurInput()},t.removeValue=function(e){var n=t.props.isMulti,r=t.state.selectValue,i=t.getOptionValue(e),o=r.filter((function(e){return t.getOptionValue(e)!==i})),a=re(n,o,o[0]||null);t.onChange(a,{action:"remove-value",removedValue:e}),t.focusInput()},t.clearValue=function(){var e=t.state.selectValue;t.onChange(re(t.props.isMulti,[],null),{action:"clear",removedValues:e})},t.popValue=function(){var e=t.props.isMulti,n=t.state.selectValue,r=n[n.length-1],i=n.slice(0,n.length-1),o=re(e,i,i[0]||null);t.onChange(o,{action:"pop-value",removedValue:r})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var e=arguments.length,n=new Array(e),r=0;r5||o>5}},t.onTouchEnd=function(e){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(e.target)&&t.menuListRef&&!t.menuListRef.contains(e.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(e){t.userIsDragging||t.onControlMouseDown(e)},t.onClearIndicatorTouchEnd=function(e){t.userIsDragging||t.onClearIndicatorMouseDown(e)},t.onDropdownIndicatorTouchEnd=function(e){t.userIsDragging||t.onDropdownIndicatorMouseDown(e)},t.handleInputChange=function(e){var n=t.props.inputValue,r=e.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(r,{action:"input-change",prevInputValue:n}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(e){t.props.onFocus&&t.props.onFocus(e),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(e){var n=t.props.inputValue;t.menuListRef&&t.menuListRef.contains(document.activeElement)?t.inputRef.focus():(t.props.onBlur&&t.props.onBlur(e),t.onInputChange("",{action:"input-blur",prevInputValue:n}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1}))},t.onOptionHover=function(e){t.blockOptionHover||t.state.focusedOption===e||t.setState({focusedOption:e})},t.shouldHideSelectedOptions=function(){return St(t.props)},t.onValueInputFocus=function(e){e.preventDefault(),e.stopPropagation(),t.focus()},t.onKeyDown=function(e){var n=t.props,r=n.isMulti,i=n.backspaceRemovesValue,o=n.escapeClearsValue,a=n.inputValue,s=n.isClearable,l=n.isDisabled,u=n.menuIsOpen,c=n.onKeyDown,h=n.tabSelectsValue,d=n.openMenuOnFocus,f=t.state,p=f.focusedOption,m=f.focusedValue,_=f.selectValue;if(!(l||"function"==typeof c&&(c(e),e.defaultPrevented))){switch(t.blockOptionHover=!0,e.key){case"ArrowLeft":if(!r||a)return;t.focusValue("previous");break;case"ArrowRight":if(!r||a)return;t.focusValue("next");break;case"Delete":case"Backspace":if(a)return;if(m)t.removeValue(m);else{if(!i)return;r?t.popValue():s&&t.clearValue()}break;case"Tab":if(t.isComposing)return;if(e.shiftKey||!u||!h||!p||d&&t.isOptionSelected(p,_))return;t.selectOption(p);break;case"Enter":if(229===e.keyCode)break;if(u){if(!p)return;if(t.isComposing)return;t.selectOption(p);break}return;case"Escape":u?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:a}),t.onMenuClose()):s&&o&&t.clearValue();break;case" ":if(a)return;if(!u){t.openMenu("first");break}if(!p)return;t.selectOption(p);break;case"ArrowUp":u?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":u?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!u)return;t.focusOption("pageup");break;case"PageDown":if(!u)return;t.focusOption("pagedown");break;case"Home":if(!u)return;t.focusOption("first");break;case"End":if(!u)return;t.focusOption("last");break;default:return}e.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++kt),t.state.selectValue=N(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.buildFocusableOptions(),r=n.indexOf(t.state.selectValue[0]);t.state.focusedOption=n[r]}return t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=t.prevProps,r=t.clearFocusValueOnUpdate,i=t.inputIsHiddenAfterUpdate,a=t.ariaSelection,s=t.isFocused,l=t.prevWasFocused,u=e.options,c=e.value,h=e.menuIsOpen,d=e.inputValue,f=e.isMulti,p=N(c),m={};if(n&&(c!==n.value||u!==n.options||h!==n.menuIsOpen||d!==n.inputValue)){var _=h?function(e,t){return yt(gt(e,t))}(e,p):[],g=r?function(e,t){var n=e.focusedValue,r=e.selectValue.indexOf(n);if(r>-1){if(t.indexOf(n)>-1)return n;if(r-1?n:t[0]}(t,_),focusedValue:g,clearFocusValueOnUpdate:!1}}var y=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},v=a,x=s&&l;return s&&!x&&(v={value:re(f,p,p[0]||null),options:p,action:"initial-input-focus"},x=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(v=null),o(o(o({},m),y),{},{prevProps:e,ariaSelection:v,prevWasFocused:x})}}],(n=[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&Y(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.isDisabled,r=t.menuIsOpen,i=this.state.isFocused;(i&&!n&&e.isDisabled||i&&r&&!e.menuIsOpen)&&this.focusInput(),i&&n&&!e.isDisabled?this.setState({isFocused:!1},this.onMenuClose):i||n||!e.isDisabled||this.inputRef!==document.activeElement||this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Y(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(e,t){this.props.onInputChange(e,t)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(e){var t=this,n=this.state,r=n.selectValue,i=n.isFocused,o=this.buildFocusableOptions(),a="first"===e?0:o.length-1;if(!this.props.isMulti){var s=o.indexOf(r[0]);s>-1&&(a=s)}this.scrollToFocusedOptionOnUpdate=!(i&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:o[a]},(function(){return t.onMenuOpen()}))}},{key:"focusValue",value:function(e){var t=this.state,n=t.selectValue,r=t.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var i=n.indexOf(r);r||(i=-1);var o=n.length-1,a=-1;if(n.length){switch(e){case"previous":a=0===i?0:-1===i?o:i-1;break;case"next":i>-1&&i0&&void 0!==arguments[0]?arguments[0]:"first",t=this.props.pageSize,n=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var i=0,o=r.indexOf(n);n||(o=-1),"up"===e?i=o>0?o-1:r.length-1:"down"===e?i=(o+1)%r.length:"pageup"===e?(i=o-t)<0&&(i=0):"pagedown"===e?(i=o+t)>r.length-1&&(i=r.length-1):"last"===e&&(i=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[i],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(pt):o(o({},pt),this.props.theme):pt}},{key:"getCommonProps",value:function(){var e=this.clearValue,t=this.cx,n=this.getStyles,r=this.getClassNames,i=this.getValue,o=this.selectOption,a=this.setValue,s=this.props,l=s.isMulti,u=s.isRtl,c=s.options;return{clearValue:e,cx:t,getStyles:n,getClassNames:r,getValue:i,hasValue:this.hasValue(),isMulti:l,isRtl:u,options:c,selectOption:o,selectProps:s,setValue:a,theme:this.getTheme()}}},{key:"hasValue",value:function(){return this.state.selectValue.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var e=this.props,t=e.isClearable,n=e.isMulti;return void 0===t?n:t}},{key:"isOptionDisabled",value:function(e,t){return wt(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return Tt(this.props,e,t)}},{key:"filterOption",value:function(e,t){return Et(this.props,e,t)}},{key:"formatOptionLabel",value:function(e,t){if("function"==typeof this.props.formatOptionLabel){var n=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(e,{context:t,inputValue:n,selectValue:r})}return this.getOptionLabel(e)}},{key:"formatGroupLabel",value:function(e){return this.props.formatGroupLabel(e)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var e=this.props,t=e.isDisabled,n=e.isSearchable,r=e.inputId,i=e.inputValue,a=e.tabIndex,s=e.form,l=e.menuIsOpen,u=e.required,h=this.getComponents().Input,f=this.state,p=f.inputIsHidden,m=f.ariaSelection,_=this.commonProps,g=r||this.getElementId("input"),y=o(o(o({"aria-autocomplete":"list","aria-expanded":l,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":u,role:"combobox"},l&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!n&&{"aria-readonly":!0}),this.hasValue()?"initial-input-focus"===(null==m?void 0:m.action)&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return n?c.createElement(h,d({},_,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:g,innerRef:this.getInputRef,isDisabled:t,isHidden:p,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:a,form:s,type:"text",value:i},y)):c.createElement(Ke,d({id:g,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:j,onFocus:this.onInputFocus,disabled:t,tabIndex:a,inputMode:"none",form:s,value:""},y))}},{key:"renderPlaceholderOrValue",value:function(){var e=this,t=this.getComponents(),n=t.MultiValue,r=t.MultiValueContainer,i=t.MultiValueLabel,o=t.MultiValueRemove,a=t.SingleValue,s=t.Placeholder,l=this.commonProps,u=this.props,h=u.controlShouldRenderValue,f=u.isDisabled,p=u.isMulti,m=u.inputValue,_=u.placeholder,g=this.state,y=g.selectValue,v=g.focusedValue,x=g.isFocused;if(!this.hasValue()||!h)return m?null:c.createElement(s,d({},l,{key:"placeholder",isDisabled:f,isFocused:x,innerProps:{id:this.getElementId("placeholder")}}),_);if(p)return y.map((function(t,a){var s=t===v,u="".concat(e.getOptionLabel(t),"-").concat(e.getOptionValue(t));return c.createElement(n,d({},l,{components:{Container:r,Label:i,Remove:o},isFocused:s,isDisabled:f,key:u,index:a,removeProps:{onClick:function(){return e.removeValue(t)},onTouchEnd:function(){return e.removeValue(t)},onMouseDown:function(e){e.preventDefault()}},data:t}),e.formatOptionLabel(t,"value"))}));if(m)return null;var b=y[0];return c.createElement(a,d({},l,{data:b,isDisabled:f}),this.formatOptionLabel(b,"value"))}},{key:"renderClearIndicator",value:function(){var e=this.getComponents().ClearIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;if(!this.isClearable()||!e||r||!this.hasValue()||i)return null;var a={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:a,isFocused:o}))}},{key:"renderLoadingIndicator",value:function(){var e=this.getComponents().LoadingIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;return e&&i?c.createElement(e,d({},t,{innerProps:{"aria-hidden":"true"},isDisabled:r,isFocused:o})):null}},{key:"renderIndicatorSeparator",value:function(){var e=this.getComponents(),t=e.DropdownIndicator,n=e.IndicatorSeparator;if(!t||!n)return null;var r=this.commonProps,i=this.props.isDisabled,o=this.state.isFocused;return c.createElement(n,d({},r,{isDisabled:i,isFocused:o}))}},{key:"renderDropdownIndicator",value:function(){var e=this.getComponents().DropdownIndicator;if(!e)return null;var t=this.commonProps,n=this.props.isDisabled,r=this.state.isFocused,i={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:i,isDisabled:n,isFocused:r}))}},{key:"renderMenu",value:function(){var e=this,t=this.getComponents(),n=t.Group,r=t.GroupHeading,i=t.Menu,o=t.MenuList,a=t.MenuPortal,s=t.LoadingMessage,l=t.NoOptionsMessage,u=t.Option,h=this.commonProps,f=this.state.focusedOption,p=this.props,m=p.captureMenuScroll,_=p.inputValue,g=p.isLoading,y=p.loadingMessage,v=p.minMenuHeight,x=p.maxMenuHeight,b=p.menuIsOpen,w=p.menuPlacement,T=p.menuPosition,E=p.menuPortalTarget,S=p.menuShouldBlockScroll,k=p.menuShouldScrollIntoView,C=p.noOptionsMessage,M=p.onMenuScrollToTop,A=p.onMenuScrollToBottom;if(!b)return null;var I,z=function(t,n){var r=t.type,i=t.data,o=t.isDisabled,a=t.isSelected,s=t.label,l=t.value,p=f===i,m=o?void 0:function(){return e.onOptionHover(i)},_=o?void 0:function(){return e.selectOption(i)},g="".concat(e.getElementId("option"),"-").concat(n),y={id:g,onClick:_,onMouseMove:m,onMouseOver:m,tabIndex:-1};return c.createElement(u,d({},h,{innerProps:y,data:i,isDisabled:o,isSelected:a,key:g,label:s,type:r,value:l,isFocused:p,innerRef:p?e.getFocusedOptionRef:void 0}),e.formatOptionLabel(t.data,"menu"))};if(this.hasOptions())I=this.getCategorizedOptions().map((function(t){if("group"===t.type){var i=t.data,o=t.options,a=t.index,s="".concat(e.getElementId("group"),"-").concat(a),l="".concat(s,"-heading");return c.createElement(n,d({},h,{key:s,data:i,options:o,Heading:r,headingProps:{id:l,data:t.data},label:e.formatGroupLabel(t.data)}),t.options.map((function(e){return z(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return z(t,"".concat(t.index))}));else if(g){var P=y({inputValue:_});if(null===P)return null;I=c.createElement(s,h,P)}else{var O=C({inputValue:_});if(null===O)return null;I=c.createElement(l,h,O)}var D={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:T,menuShouldScrollIntoView:k},L=c.createElement(se,d({},h,D),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,D,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove,id:e.getElementId("listbox")},isLoading:g,placement:a}),c.createElement(ut,{captureEnabled:m,onTopArrive:M,onBottomArrive:A,lockEnabled:S},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},isLoading:g,maxHeight:s,focusedOption:f}),I)})))}));return E||"fixed"===T?c.createElement(a,d({},h,{appendTo:E,controlElement:this.controlRef,menuPlacement:w,menuPosition:T}),L):L}},{key:"renderFormField",value:function(){var e=this,t=this.props,n=t.delimiter,r=t.isDisabled,i=t.isMulti,o=t.name,a=t.required,s=this.state.selectValue;if(o&&!r){if(a&&!this.hasValue())return c.createElement(ht,{name:o,onFocus:this.onValueInputFocus});if(i){if(n){var l=s.map((function(t){return e.getOptionValue(t)})).join(n);return c.createElement("input",{name:o,type:"hidden",value:l})}var u=s.length>0?s.map((function(t,n){return c.createElement("input",{key:"i-".concat(n),name:o,type:"hidden",value:e.getOptionValue(t)})})):c.createElement("input",{name:o,type:"hidden",value:""});return c.createElement("div",null,u)}var h=s[0]?this.getOptionValue(s[0]):"";return c.createElement("input",{name:o,type:"hidden",value:h})}}},{key:"renderLiveRegion",value:function(){var e=this.commonProps,t=this.state,n=t.ariaSelection,r=t.focusedOption,i=t.focusedValue,o=t.isFocused,a=t.selectValue,s=this.getFocusableOptions();return c.createElement(je,d({},e,{id:this.getElementId("live-region"),ariaSelection:n,focusedOption:r,focusedValue:i,isFocused:o,selectValue:a,focusableOptions:s}))}},{key:"render",value:function(){var e=this.getComponents(),t=e.Control,n=e.IndicatorsContainer,r=e.SelectContainer,i=e.ValueContainer,o=this.props,a=o.className,s=o.id,l=o.isDisabled,u=o.menuIsOpen,h=this.state.isFocused,f=this.commonProps=this.getCommonProps();return c.createElement(r,d({},f,{className:a,innerProps:{id:s,onKeyDown:this.onKeyDown},isDisabled:l,isFocused:h}),this.renderLiveRegion(),c.createElement(t,d({},f,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:l,isFocused:h,menuIsOpen:u}),c.createElement(i,d({},f,{isDisabled:l}),this.renderPlaceholderOrValue(),this.renderInput()),c.createElement(n,d({},f,{isDisabled:l}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}])&&f(t.prototype,n),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(c.Component);Ct.defaultProps=mt;n(5),n(17),n(53),n(54),n(58),n(60),n(61),n(62),n(64),n(69),n(30),n(73),n(27);var Mt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,_,g,y,v,x,b,w,T,E,S,k,C,M,A,I,z,P,O,D,L,R,B,F,j=(r=(n=e).defaultInputValue,i=void 0===r?"":r,a=n.defaultMenuIsOpen,s=void 0!==a&&a,f=n.defaultValue,p=void 0===f?null:f,m=n.inputValue,_=n.menuIsOpen,g=n.onChange,y=n.onInputChange,v=n.onMenuClose,x=n.onMenuOpen,b=n.value,w=u(n,h),T=l(Object(c.useState)(void 0!==m?m:i),2),E=T[0],S=T[1],k=l(Object(c.useState)(void 0!==_?_:s),2),C=k[0],M=k[1],A=l(Object(c.useState)(void 0!==b?b:p),2),I=A[0],z=A[1],P=Object(c.useCallback)((function(e,t){"function"==typeof g&&g(e,t),z(e)}),[g]),O=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),S(void 0!==n?n:e)}),[y]),D=Object(c.useCallback)((function(){"function"==typeof x&&x(),M(!0)}),[x]),L=Object(c.useCallback)((function(){"function"==typeof v&&v(),M(!1)}),[v]),R=void 0!==m?m:E,B=void 0!==_?_:C,F=void 0!==b?b:I,o(o({},w),{},{inputValue:R,menuIsOpen:B,onChange:P,onInputChange:O,onMenuClose:L,onMenuOpen:D,value:F}));return c.createElement(Ct,d({ref:t},j))}));t.a=Mt},,function(e,t,n){"use strict"; + */(function(){var o="Expected a function",a="__lodash_placeholder__",s=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],l="[object Arguments]",u="[object Array]",c="[object Boolean]",h="[object Date]",d="[object Error]",f="[object Function]",p="[object GeneratorFunction]",m="[object Map]",_="[object Number]",g="[object Object]",y="[object RegExp]",v="[object Set]",x="[object String]",b="[object Symbol]",w="[object WeakMap]",E="[object ArrayBuffer]",T="[object DataView]",S="[object Float32Array]",k="[object Float64Array]",C="[object Int8Array]",M="[object Int16Array]",A="[object Int32Array]",I="[object Uint8Array]",P="[object Uint16Array]",z="[object Uint32Array]",O=/\b__p \+= '';/g,D=/\b(__p \+=) '' \+/g,L=/(__e\(.*?\)|\b__t\)) \+\n'';/g,R=/&(?:amp|lt|gt|quot|#39);/g,B=/[&<>"']/g,F=RegExp(R.source),j=RegExp(B.source),N=/<%-([\s\S]+?)%>/g,U=/<%([\s\S]+?)%>/g,V=/<%=([\s\S]+?)%>/g,G=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,q=/^\w*$/,$=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Z=/[\\^$.*+?()[\]{}|]/g,W=RegExp(Z.source),X=/^\s+/,H=/\s/,Y=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,K=/\{\n\/\* \[wrapped with (.+)\] \*/,J=/,? & /,Q=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ee=/[()=,{}\[\]\/\s]/,te=/\\(\\)?/g,ne=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,re=/\w*$/,ie=/^[-+]0x[0-9a-f]+$/i,oe=/^0b[01]+$/i,ae=/^\[object .+?Constructor\]$/,se=/^0o[0-7]+$/i,le=/^(?:0|[1-9]\d*)$/,ue=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,ce=/($^)/,he=/['\n\r\u2028\u2029\\]/g,de="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",fe="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",pe="[\\ud800-\\udfff]",me="["+fe+"]",_e="["+de+"]",ge="\\d+",ye="[\\u2700-\\u27bf]",ve="[a-z\\xdf-\\xf6\\xf8-\\xff]",xe="[^\\ud800-\\udfff"+fe+ge+"\\u2700-\\u27bfa-z\\xdf-\\xf6\\xf8-\\xffA-Z\\xc0-\\xd6\\xd8-\\xde]",be="\\ud83c[\\udffb-\\udfff]",we="[^\\ud800-\\udfff]",Ee="(?:\\ud83c[\\udde6-\\uddff]){2}",Te="[\\ud800-\\udbff][\\udc00-\\udfff]",Se="[A-Z\\xc0-\\xd6\\xd8-\\xde]",ke="(?:"+ve+"|"+xe+")",Ce="(?:"+Se+"|"+xe+")",Me="(?:"+_e+"|"+be+")"+"?",Ae="[\\ufe0e\\ufe0f]?"+Me+("(?:\\u200d(?:"+[we,Ee,Te].join("|")+")[\\ufe0e\\ufe0f]?"+Me+")*"),Ie="(?:"+[ye,Ee,Te].join("|")+")"+Ae,Pe="(?:"+[we+_e+"?",_e,Ee,Te,pe].join("|")+")",ze=RegExp("['’]","g"),Oe=RegExp(_e,"g"),De=RegExp(be+"(?="+be+")|"+Pe+Ae,"g"),Le=RegExp([Se+"?"+ve+"+(?:['’](?:d|ll|m|re|s|t|ve))?(?="+[me,Se,"$"].join("|")+")",Ce+"+(?:['’](?:D|LL|M|RE|S|T|VE))?(?="+[me,Se+ke,"$"].join("|")+")",Se+"?"+ke+"+(?:['’](?:d|ll|m|re|s|t|ve))?",Se+"+(?:['’](?:D|LL|M|RE|S|T|VE))?","\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",ge,Ie].join("|"),"g"),Re=RegExp("[\\u200d\\ud800-\\udfff"+de+"\\ufe0e\\ufe0f]"),Be=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Fe=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],je=-1,Ne={};Ne[S]=Ne[k]=Ne[C]=Ne[M]=Ne[A]=Ne[I]=Ne["[object Uint8ClampedArray]"]=Ne[P]=Ne[z]=!0,Ne[l]=Ne[u]=Ne[E]=Ne[c]=Ne[T]=Ne[h]=Ne[d]=Ne[f]=Ne[m]=Ne[_]=Ne[g]=Ne[y]=Ne[v]=Ne[x]=Ne[w]=!1;var Ue={};Ue[l]=Ue[u]=Ue[E]=Ue[T]=Ue[c]=Ue[h]=Ue[S]=Ue[k]=Ue[C]=Ue[M]=Ue[A]=Ue[m]=Ue[_]=Ue[g]=Ue[y]=Ue[v]=Ue[x]=Ue[b]=Ue[I]=Ue["[object Uint8ClampedArray]"]=Ue[P]=Ue[z]=!0,Ue[d]=Ue[f]=Ue[w]=!1;var Ve={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Ge=parseFloat,qe=parseInt,$e="object"==typeof e&&e&&e.Object===Object&&e,Ze="object"==typeof self&&self&&self.Object===Object&&self,We=$e||Ze||Function("return this")(),Xe=t&&!t.nodeType&&t,He=Xe&&"object"==typeof r&&r&&!r.nodeType&&r,Ye=He&&He.exports===Xe,Ke=Ye&&$e.process,Je=function(){try{var e=He&&He.require&&He.require("util").types;return e||Ke&&Ke.binding&&Ke.binding("util")}catch(e){}}(),Qe=Je&&Je.isArrayBuffer,et=Je&&Je.isDate,tt=Je&&Je.isMap,nt=Je&&Je.isRegExp,rt=Je&&Je.isSet,it=Je&&Je.isTypedArray;function ot(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function at(e,t,n,r){for(var i=-1,o=null==e?0:e.length;++i-1}function dt(e,t,n){for(var r=-1,i=null==e?0:e.length;++r-1;);return n}function Lt(e,t){for(var n=e.length;n--&&bt(t,e[n],0)>-1;);return n}function Rt(e,t){for(var n=e.length,r=0;n--;)e[n]===t&&++r;return r}var Bt=kt({"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","Ā":"A","Ă":"A","Ą":"A","ā":"a","ă":"a","ą":"a","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","ć":"c","ĉ":"c","ċ":"c","č":"c","Ď":"D","Đ":"D","ď":"d","đ":"d","Ē":"E","Ĕ":"E","Ė":"E","Ę":"E","Ě":"E","ē":"e","ĕ":"e","ė":"e","ę":"e","ě":"e","Ĝ":"G","Ğ":"G","Ġ":"G","Ģ":"G","ĝ":"g","ğ":"g","ġ":"g","ģ":"g","Ĥ":"H","Ħ":"H","ĥ":"h","ħ":"h","Ĩ":"I","Ī":"I","Ĭ":"I","Į":"I","İ":"I","ĩ":"i","ī":"i","ĭ":"i","į":"i","ı":"i","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","ĸ":"k","Ĺ":"L","Ļ":"L","Ľ":"L","Ŀ":"L","Ł":"L","ĺ":"l","ļ":"l","ľ":"l","ŀ":"l","ł":"l","Ń":"N","Ņ":"N","Ň":"N","Ŋ":"N","ń":"n","ņ":"n","ň":"n","ŋ":"n","Ō":"O","Ŏ":"O","Ő":"O","ō":"o","ŏ":"o","ő":"o","Ŕ":"R","Ŗ":"R","Ř":"R","ŕ":"r","ŗ":"r","ř":"r","Ś":"S","Ŝ":"S","Ş":"S","Š":"S","ś":"s","ŝ":"s","ş":"s","š":"s","Ţ":"T","Ť":"T","Ŧ":"T","ţ":"t","ť":"t","ŧ":"t","Ũ":"U","Ū":"U","Ŭ":"U","Ů":"U","Ű":"U","Ų":"U","ũ":"u","ū":"u","ŭ":"u","ů":"u","ű":"u","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","Ż":"Z","Ž":"Z","ź":"z","ż":"z","ž":"z","IJ":"IJ","ij":"ij","Œ":"Oe","œ":"oe","ʼn":"'n","ſ":"s"}),Ft=kt({"&":"&","<":"<",">":">",'"':""","'":"'"});function jt(e){return"\\"+Ve[e]}function Nt(e){return Re.test(e)}function Ut(e){var t=-1,n=Array(e.size);return e.forEach((function(e,r){n[++t]=[r,e]})),n}function Vt(e,t){return function(n){return e(t(n))}}function Gt(e,t){for(var n=-1,r=e.length,i=0,o=[];++n",""":'"',"'":"'"});var Yt=function e(t){var n,r=(t=null==t?We:Yt.defaults(We.Object(),t,Yt.pick(We,Fe))).Array,i=t.Date,H=t.Error,de=t.Function,fe=t.Math,pe=t.Object,me=t.RegExp,_e=t.String,ge=t.TypeError,ye=r.prototype,ve=de.prototype,xe=pe.prototype,be=t["__core-js_shared__"],we=ve.toString,Ee=xe.hasOwnProperty,Te=0,Se=(n=/[^.]+$/.exec(be&&be.keys&&be.keys.IE_PROTO||""))?"Symbol(src)_1."+n:"",ke=xe.toString,Ce=we.call(pe),Me=We._,Ae=me("^"+we.call(Ee).replace(Z,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ie=Ye?t.Buffer:void 0,Pe=t.Symbol,De=t.Uint8Array,Re=Ie?Ie.allocUnsafe:void 0,Ve=Vt(pe.getPrototypeOf,pe),$e=pe.create,Ze=xe.propertyIsEnumerable,Xe=ye.splice,He=Pe?Pe.isConcatSpreadable:void 0,Ke=Pe?Pe.iterator:void 0,Je=Pe?Pe.toStringTag:void 0,yt=function(){try{var e=eo(pe,"defineProperty");return e({},"",{}),e}catch(e){}}(),kt=t.clearTimeout!==We.clearTimeout&&t.clearTimeout,Kt=i&&i.now!==We.Date.now&&i.now,Jt=t.setTimeout!==We.setTimeout&&t.setTimeout,Qt=fe.ceil,en=fe.floor,tn=pe.getOwnPropertySymbols,nn=Ie?Ie.isBuffer:void 0,rn=t.isFinite,on=ye.join,an=Vt(pe.keys,pe),sn=fe.max,ln=fe.min,un=i.now,cn=t.parseInt,hn=fe.random,dn=ye.reverse,fn=eo(t,"DataView"),pn=eo(t,"Map"),mn=eo(t,"Promise"),_n=eo(t,"Set"),gn=eo(t,"WeakMap"),yn=eo(pe,"create"),vn=gn&&new gn,xn={},bn=Mo(fn),wn=Mo(pn),En=Mo(mn),Tn=Mo(_n),Sn=Mo(gn),kn=Pe?Pe.prototype:void 0,Cn=kn?kn.valueOf:void 0,Mn=kn?kn.toString:void 0;function An(e){if($a(e)&&!Da(e)&&!(e instanceof On)){if(e instanceof zn)return e;if(Ee.call(e,"__wrapped__"))return Ao(e)}return new zn(e)}var In=function(){function e(){}return function(t){if(!qa(t))return{};if($e)return $e(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}();function Pn(){}function zn(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=void 0}function On(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=4294967295,this.__views__=[]}function Dn(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t=t?e:t)),e}function Kn(e,t,n,r,i,o){var a,s=1&t,u=2&t,d=4&t;if(n&&(a=i?n(e,r,i,o):n(e)),void 0!==a)return a;if(!qa(e))return e;var w=Da(e);if(w){if(a=function(e){var t=e.length,n=new e.constructor(t);t&&"string"==typeof e[0]&&Ee.call(e,"index")&&(n.index=e.index,n.input=e.input);return n}(e),!s)return yi(e,a)}else{var O=ro(e),D=O==f||O==p;if(Fa(e))return di(e,s);if(O==g||O==l||D&&!i){if(a=u||D?{}:oo(e),!s)return u?function(e,t){return vi(e,no(e),t)}(e,function(e,t){return e&&vi(t,ws(t),e)}(a,e)):function(e,t){return vi(e,to(e),t)}(e,Wn(a,e))}else{if(!Ue[O])return i?e:{};a=function(e,t,n){var r=e.constructor;switch(t){case E:return fi(e);case c:case h:return new r(+e);case T:return function(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.byteLength)}(e,n);case S:case k:case C:case M:case A:case I:case"[object Uint8ClampedArray]":case P:case z:return pi(e,n);case m:return new r;case _:case x:return new r(e);case y:return function(e){var t=new e.constructor(e.source,re.exec(e));return t.lastIndex=e.lastIndex,t}(e);case v:return new r;case b:return i=e,Cn?pe(Cn.call(i)):{}}var i}(e,O,s)}}o||(o=new Fn);var L=o.get(e);if(L)return L;o.set(e,a),Ya(e)?e.forEach((function(r){a.add(Kn(r,t,n,r,e,o))})):Za(e)&&e.forEach((function(r,i){a.set(i,Kn(r,t,n,i,e,o))}));var R=w?void 0:(d?u?Wi:Zi:u?ws:bs)(e);return st(R||e,(function(r,i){R&&(r=e[i=r]),qn(a,i,Kn(r,t,n,i,e,o))})),a}function Jn(e,t,n){var r=n.length;if(null==e)return!r;for(e=pe(e);r--;){var i=n[r],o=t[i],a=e[i];if(void 0===a&&!(i in e)||!o(a))return!1}return!0}function Qn(e,t,n){if("function"!=typeof e)throw new ge(o);return bo((function(){e.apply(void 0,n)}),t)}function er(e,t,n,r){var i=-1,o=ht,a=!0,s=e.length,l=[],u=t.length;if(!s)return l;n&&(t=ft(t,Pt(n))),r?(o=dt,a=!1):t.length>=200&&(o=Ot,a=!1,t=new Bn(t));e:for(;++i-1},Ln.prototype.set=function(e,t){var n=this.__data__,r=$n(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this},Rn.prototype.clear=function(){this.size=0,this.__data__={hash:new Dn,map:new(pn||Ln),string:new Dn}},Rn.prototype.delete=function(e){var t=Ji(this,e).delete(e);return this.size-=t?1:0,t},Rn.prototype.get=function(e){return Ji(this,e).get(e)},Rn.prototype.has=function(e){return Ji(this,e).has(e)},Rn.prototype.set=function(e,t){var n=Ji(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this},Bn.prototype.add=Bn.prototype.push=function(e){return this.__data__.set(e,"__lodash_hash_undefined__"),this},Bn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.clear=function(){this.__data__=new Ln,this.size=0},Fn.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Fn.prototype.get=function(e){return this.__data__.get(e)},Fn.prototype.has=function(e){return this.__data__.has(e)},Fn.prototype.set=function(e,t){var n=this.__data__;if(n instanceof Ln){var r=n.__data__;if(!pn||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new Rn(r)}return n.set(e,t),this.size=n.size,this};var tr=wi(ur),nr=wi(cr,!0);function rr(e,t){var n=!0;return tr(e,(function(e,r,i){return n=!!t(e,r,i)})),n}function ir(e,t,n){for(var r=-1,i=e.length;++r0&&n(s)?t>1?ar(s,t-1,n,r,i):pt(i,s):r||(i[i.length]=s)}return i}var sr=Ei(),lr=Ei(!0);function ur(e,t){return e&&sr(e,t,bs)}function cr(e,t){return e&&lr(e,t,bs)}function hr(e,t){return ct(t,(function(t){return Ua(e[t])}))}function dr(e,t){for(var n=0,r=(t=li(t,e)).length;null!=e&&nt}function _r(e,t){return null!=e&&Ee.call(e,t)}function gr(e,t){return null!=e&&t in pe(e)}function yr(e,t,n){for(var i=n?dt:ht,o=e[0].length,a=e.length,s=a,l=r(a),u=1/0,c=[];s--;){var h=e[s];s&&t&&(h=ft(h,Pt(t))),u=ln(h.length,u),l[s]=!n&&(t||o>=120&&h.length>=120)?new Bn(s&&h):void 0}h=e[0];var d=-1,f=l[0];e:for(;++d=s)return l;var u=n[r];return l*("desc"==u?-1:1)}}return e.index-t.index}(e,t,n)}))}function Dr(e,t,n){for(var r=-1,i=t.length,o={};++r-1;)s!==e&&Xe.call(s,l,1),Xe.call(e,l,1);return e}function Rr(e,t){for(var n=e?t.length:0,r=n-1;n--;){var i=t[n];if(n==r||i!==o){var o=i;so(i)?Xe.call(e,i,1):ei(e,i)}}return e}function Br(e,t){return e+en(hn()*(t-e+1))}function Fr(e,t){var n="";if(!e||t<1||t>9007199254740991)return n;do{t%2&&(n+=e),(t=en(t/2))&&(e+=e)}while(t);return n}function jr(e,t){return wo(_o(e,t,Ws),e+"")}function Nr(e){return Nn(Is(e))}function Ur(e,t){var n=Is(e);return So(n,Yn(t,0,n.length))}function Vr(e,t,n,r){if(!qa(e))return e;for(var i=-1,o=(t=li(t,e)).length,a=o-1,s=e;null!=s&&++io?0:o+t),(n=n>o?o:n)<0&&(n+=o),o=t>n?0:n-t>>>0,t>>>=0;for(var a=r(o);++i>>1,a=e[o];null!==a&&!Ja(a)&&(n?a<=t:a=200){var u=t?null:Fi(e);if(u)return qt(u);a=!1,i=Ot,l=new Bn}else l=t?[]:s;e:for(;++r=r?e:Zr(e,t,n)}var hi=kt||function(e){return We.clearTimeout(e)};function di(e,t){if(t)return e.slice();var n=e.length,r=Re?Re(n):new e.constructor(n);return e.copy(r),r}function fi(e){var t=new e.constructor(e.byteLength);return new De(t).set(new De(e)),t}function pi(e,t){var n=t?fi(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}function mi(e,t){if(e!==t){var n=void 0!==e,r=null===e,i=e==e,o=Ja(e),a=void 0!==t,s=null===t,l=t==t,u=Ja(t);if(!s&&!u&&!o&&e>t||o&&a&&l&&!s&&!u||r&&a&&l||!n&&l||!i)return 1;if(!r&&!o&&!u&&e1?n[i-1]:void 0,a=i>2?n[2]:void 0;for(o=e.length>3&&"function"==typeof o?(i--,o):void 0,a&&lo(n[0],n[1],a)&&(o=i<3?void 0:o,i=1),t=pe(t);++r-1?i[o?t[a]:a]:void 0}}function Mi(e){return $i((function(t){var n=t.length,r=n,i=zn.prototype.thru;for(e&&t.reverse();r--;){var a=t[r];if("function"!=typeof a)throw new ge(o);if(i&&!s&&"wrapper"==Hi(a))var s=new zn([],!0)}for(r=s?r:n;++r1&&v.reverse(),h&&us))return!1;var u=o.get(e),c=o.get(t);if(u&&c)return u==t&&c==e;var h=-1,d=!0,f=2&n?new Bn:void 0;for(o.set(e,t),o.set(t,e);++h-1&&e%1==0&&e1?"& ":"")+t[r],t=t.join(n>2?", ":" "),e.replace(Y,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return st(s,(function(n){var r="_."+n[0];t&n[1]&&!ht(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(K);return t?t[1].split(J):[]}(r),n)))}function To(e){var t=0,n=0;return function(){var r=un(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function So(e,t){var n=-1,r=e.length,i=r-1;for(t=void 0===t?r:t;++n1?e[t-1]:void 0;return n="function"==typeof n?(e.pop(),n):void 0,Ho(e,n)}));function na(e){var t=An(e);return t.__chain__=!0,t}function ra(e,t){return t(e)}var ia=$i((function(e){var t=e.length,n=t?e[0]:0,r=this.__wrapped__,i=function(t){return Hn(t,e)};return!(t>1||this.__actions__.length)&&r instanceof On&&so(n)?((r=r.slice(n,+n+(t?1:0))).__actions__.push({func:ra,args:[i],thisArg:void 0}),new zn(r,this.__chain__).thru((function(e){return t&&!e.length&&e.push(void 0),e}))):this.thru(i)}));var oa=xi((function(e,t,n){Ee.call(e,n)?++e[n]:Xn(e,n,1)}));var aa=Ci(Oo),sa=Ci(Do);function la(e,t){return(Da(e)?st:tr)(e,Ki(t,3))}function ua(e,t){return(Da(e)?lt:nr)(e,Ki(t,3))}var ca=xi((function(e,t,n){Ee.call(e,n)?e[n].push(t):Xn(e,n,[t])}));var ha=jr((function(e,t,n){var i=-1,o="function"==typeof t,a=Ra(e)?r(e.length):[];return tr(e,(function(e){a[++i]=o?ot(t,e,n):vr(e,t,n)})),a})),da=xi((function(e,t,n){Xn(e,n,t)}));function fa(e,t){return(Da(e)?ft:Mr)(e,Ki(t,3))}var pa=xi((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));var ma=jr((function(e,t){if(null==e)return[];var n=t.length;return n>1&&lo(e,t[0],t[1])?t=[]:n>2&&lo(t[0],t[1],t[2])&&(t=[t[0]]),Or(e,ar(t,1),[])})),_a=Kt||function(){return We.Date.now()};function ga(e,t,n){return t=n?void 0:t,Ni(e,128,void 0,void 0,void 0,void 0,t=e&&null==t?e.length:t)}function ya(e,t){var n;if("function"!=typeof t)throw new ge(o);return e=is(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=void 0),n}}var va=jr((function(e,t,n){var r=1;if(n.length){var i=Gt(n,Yi(va));r|=32}return Ni(e,r,t,n,i)})),xa=jr((function(e,t,n){var r=3;if(n.length){var i=Gt(n,Yi(xa));r|=32}return Ni(t,r,e,n,i)}));function ba(e,t,n){var r,i,a,s,l,u,c=0,h=!1,d=!1,f=!0;if("function"!=typeof e)throw new ge(o);function p(t){var n=r,o=i;return r=i=void 0,c=t,s=e.apply(o,n)}function m(e){return c=e,l=bo(g,t),h?p(e):s}function _(e){var n=e-u;return void 0===u||n>=t||n<0||d&&e-c>=a}function g(){var e=_a();if(_(e))return y(e);l=bo(g,function(e){var n=t-(e-u);return d?ln(n,a-(e-c)):n}(e))}function y(e){return l=void 0,f&&r?p(e):(r=i=void 0,s)}function v(){var e=_a(),n=_(e);if(r=arguments,i=this,u=e,n){if(void 0===l)return m(u);if(d)return hi(l),l=bo(g,t),p(u)}return void 0===l&&(l=bo(g,t)),s}return t=as(t)||0,qa(n)&&(h=!!n.leading,a=(d="maxWait"in n)?sn(as(n.maxWait)||0,t):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){void 0!==l&&hi(l),c=0,r=u=i=l=void 0},v.flush=function(){return void 0===l?s:y(_a())},v}var wa=jr((function(e,t){return Qn(e,1,t)})),Ea=jr((function(e,t,n){return Qn(e,as(t)||0,n)}));function Ta(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new ge(o);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=n.cache;if(o.has(i))return o.get(i);var a=e.apply(this,r);return n.cache=o.set(i,a)||o,a};return n.cache=new(Ta.Cache||Rn),n}function Sa(e){if("function"!=typeof e)throw new ge(o);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}Ta.Cache=Rn;var ka=ui((function(e,t){var n=(t=1==t.length&&Da(t[0])?ft(t[0],Pt(Ki())):ft(ar(t,1),Pt(Ki()))).length;return jr((function(r){for(var i=-1,o=ln(r.length,n);++i=t})),Oa=xr(function(){return arguments}())?xr:function(e){return $a(e)&&Ee.call(e,"callee")&&!Ze.call(e,"callee")},Da=r.isArray,La=Qe?Pt(Qe):function(e){return $a(e)&&pr(e)==E};function Ra(e){return null!=e&&Ga(e.length)&&!Ua(e)}function Ba(e){return $a(e)&&Ra(e)}var Fa=nn||al,ja=et?Pt(et):function(e){return $a(e)&&pr(e)==h};function Na(e){if(!$a(e))return!1;var t=pr(e);return t==d||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!Xa(e)}function Ua(e){if(!qa(e))return!1;var t=pr(e);return t==f||t==p||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Va(e){return"number"==typeof e&&e==is(e)}function Ga(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}function qa(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $a(e){return null!=e&&"object"==typeof e}var Za=tt?Pt(tt):function(e){return $a(e)&&ro(e)==m};function Wa(e){return"number"==typeof e||$a(e)&&pr(e)==_}function Xa(e){if(!$a(e)||pr(e)!=g)return!1;var t=Ve(e);if(null===t)return!0;var n=Ee.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&we.call(n)==Ce}var Ha=nt?Pt(nt):function(e){return $a(e)&&pr(e)==y};var Ya=rt?Pt(rt):function(e){return $a(e)&&ro(e)==v};function Ka(e){return"string"==typeof e||!Da(e)&&$a(e)&&pr(e)==x}function Ja(e){return"symbol"==typeof e||$a(e)&&pr(e)==b}var Qa=it?Pt(it):function(e){return $a(e)&&Ga(e.length)&&!!Ne[pr(e)]};var es=Li(Cr),ts=Li((function(e,t){return e<=t}));function ns(e){if(!e)return[];if(Ra(e))return Ka(e)?Wt(e):yi(e);if(Ke&&e[Ke])return function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}(e[Ke]());var t=ro(e);return(t==m?Ut:t==v?qt:Is)(e)}function rs(e){return e?(e=as(e))===1/0||e===-1/0?17976931348623157e292*(e<0?-1:1):e==e?e:0:0===e?e:0}function is(e){var t=rs(e),n=t%1;return t==t?n?t-n:t:0}function os(e){return e?Yn(is(e),0,4294967295):0}function as(e){if("number"==typeof e)return e;if(Ja(e))return NaN;if(qa(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=qa(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=It(e);var n=oe.test(e);return n||se.test(e)?qe(e.slice(2),n?2:8):ie.test(e)?NaN:+e}function ss(e){return vi(e,ws(e))}function ls(e){return null==e?"":Jr(e)}var us=bi((function(e,t){if(fo(t)||Ra(t))vi(t,bs(t),e);else for(var n in t)Ee.call(t,n)&&qn(e,n,t[n])})),cs=bi((function(e,t){vi(t,ws(t),e)})),hs=bi((function(e,t,n,r){vi(t,ws(t),e,r)})),ds=bi((function(e,t,n,r){vi(t,bs(t),e,r)})),fs=$i(Hn);var ps=jr((function(e,t){e=pe(e);var n=-1,r=t.length,i=r>2?t[2]:void 0;for(i&&lo(t[0],t[1],i)&&(r=1);++n1),t})),vi(e,Wi(e),n),r&&(n=Kn(n,7,Gi));for(var i=t.length;i--;)ei(n,t[i]);return n}));var ks=$i((function(e,t){return null==e?{}:function(e,t){return Dr(e,t,(function(t,n){return gs(e,n)}))}(e,t)}));function Cs(e,t){if(null==e)return{};var n=ft(Wi(e),(function(e){return[e]}));return t=Ki(t),Dr(e,n,(function(e,n){return t(e,n[0])}))}var Ms=ji(bs),As=ji(ws);function Is(e){return null==e?[]:zt(e,bs(e))}var Ps=Si((function(e,t,n){return t=t.toLowerCase(),e+(n?zs(t):t)}));function zs(e){return Ns(ls(e).toLowerCase())}function Os(e){return(e=ls(e))&&e.replace(ue,Bt).replace(Oe,"")}var Ds=Si((function(e,t,n){return e+(n?"-":"")+t.toLowerCase()})),Ls=Si((function(e,t,n){return e+(n?" ":"")+t.toLowerCase()})),Rs=Ti("toLowerCase");var Bs=Si((function(e,t,n){return e+(n?"_":"")+t.toLowerCase()}));var Fs=Si((function(e,t,n){return e+(n?" ":"")+Ns(t)}));var js=Si((function(e,t,n){return e+(n?" ":"")+t.toUpperCase()})),Ns=Ti("toUpperCase");function Us(e,t,n){return e=ls(e),void 0===(t=n?void 0:t)?function(e){return Be.test(e)}(e)?function(e){return e.match(Le)||[]}(e):function(e){return e.match(Q)||[]}(e):e.match(t)||[]}var Vs=jr((function(e,t){try{return ot(e,void 0,t)}catch(e){return Na(e)?e:new H(e)}})),Gs=$i((function(e,t){return st(t,(function(t){t=Co(t),Xn(e,t,va(e[t],e))})),e}));function qs(e){return function(){return e}}var $s=Mi(),Zs=Mi(!0);function Ws(e){return e}function Xs(e){return Tr("function"==typeof e?e:Kn(e,1))}var Hs=jr((function(e,t){return function(n){return vr(n,e,t)}})),Ys=jr((function(e,t){return function(n){return vr(e,n,t)}}));function Ks(e,t,n){var r=bs(t),i=hr(t,r);null!=n||qa(t)&&(i.length||!r.length)||(n=t,t=e,e=this,i=hr(t,bs(t)));var o=!(qa(n)&&"chain"in n&&!n.chain),a=Ua(e);return st(i,(function(n){var r=t[n];e[n]=r,a&&(e.prototype[n]=function(){var t=this.__chain__;if(o||t){var n=e(this.__wrapped__),i=n.__actions__=yi(this.__actions__);return i.push({func:r,args:arguments,thisArg:e}),n.__chain__=t,n}return r.apply(e,pt([this.value()],arguments))})})),e}function Js(){}var Qs=zi(ft),el=zi(ut),tl=zi(gt);function nl(e){return uo(e)?St(Co(e)):function(e){return function(t){return dr(t,e)}}(e)}var rl=Di(),il=Di(!0);function ol(){return[]}function al(){return!1}var sl=Pi((function(e,t){return e+t}),0),ll=Bi("ceil"),ul=Pi((function(e,t){return e/t}),1),cl=Bi("floor");var hl,dl=Pi((function(e,t){return e*t}),1),fl=Bi("round"),pl=Pi((function(e,t){return e-t}),0);return An.after=function(e,t){if("function"!=typeof t)throw new ge(o);return e=is(e),function(){if(--e<1)return t.apply(this,arguments)}},An.ary=ga,An.assign=us,An.assignIn=cs,An.assignInWith=hs,An.assignWith=ds,An.at=fs,An.before=ya,An.bind=va,An.bindAll=Gs,An.bindKey=xa,An.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Da(e)?e:[e]},An.chain=na,An.chunk=function(e,t,n){t=(n?lo(e,t,n):void 0===t)?1:sn(is(t),0);var i=null==e?0:e.length;if(!i||t<1)return[];for(var o=0,a=0,s=r(Qt(i/t));oi?0:i+n),(r=void 0===r||r>i?i:is(r))<0&&(r+=i),r=n>r?0:os(r);n>>0)?(e=ls(e))&&("string"==typeof t||null!=t&&!Ha(t))&&!(t=Jr(t))&&Nt(e)?ci(Wt(e),0,n):e.split(t,n):[]},An.spread=function(e,t){if("function"!=typeof e)throw new ge(o);return t=null==t?0:sn(is(t),0),jr((function(n){var r=n[t],i=ci(n,0,t);return r&&pt(i,r),ot(e,this,i)}))},An.tail=function(e){var t=null==e?0:e.length;return t?Zr(e,1,t):[]},An.take=function(e,t,n){return e&&e.length?Zr(e,0,(t=n||void 0===t?1:is(t))<0?0:t):[]},An.takeRight=function(e,t,n){var r=null==e?0:e.length;return r?Zr(e,(t=r-(t=n||void 0===t?1:is(t)))<0?0:t,r):[]},An.takeRightWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3),!1,!0):[]},An.takeWhile=function(e,t){return e&&e.length?ni(e,Ki(t,3)):[]},An.tap=function(e,t){return t(e),e},An.throttle=function(e,t,n){var r=!0,i=!0;if("function"!=typeof e)throw new ge(o);return qa(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),ba(e,t,{leading:r,maxWait:t,trailing:i})},An.thru=ra,An.toArray=ns,An.toPairs=Ms,An.toPairsIn=As,An.toPath=function(e){return Da(e)?ft(e,Co):Ja(e)?[e]:yi(ko(ls(e)))},An.toPlainObject=ss,An.transform=function(e,t,n){var r=Da(e),i=r||Fa(e)||Qa(e);if(t=Ki(t,4),null==n){var o=e&&e.constructor;n=i?r?new o:[]:qa(e)&&Ua(o)?In(Ve(e)):{}}return(i?st:ur)(e,(function(e,r,i){return t(n,e,r,i)})),n},An.unary=function(e){return ga(e,1)},An.union=$o,An.unionBy=Zo,An.unionWith=Wo,An.uniq=function(e){return e&&e.length?Qr(e):[]},An.uniqBy=function(e,t){return e&&e.length?Qr(e,Ki(t,2)):[]},An.uniqWith=function(e,t){return t="function"==typeof t?t:void 0,e&&e.length?Qr(e,void 0,t):[]},An.unset=function(e,t){return null==e||ei(e,t)},An.unzip=Xo,An.unzipWith=Ho,An.update=function(e,t,n){return null==e?e:ti(e,t,si(n))},An.updateWith=function(e,t,n,r){return r="function"==typeof r?r:void 0,null==e?e:ti(e,t,si(n),r)},An.values=Is,An.valuesIn=function(e){return null==e?[]:zt(e,ws(e))},An.without=Yo,An.words=Us,An.wrap=function(e,t){return Ca(si(t),e)},An.xor=Ko,An.xorBy=Jo,An.xorWith=Qo,An.zip=ea,An.zipObject=function(e,t){return oi(e||[],t||[],qn)},An.zipObjectDeep=function(e,t){return oi(e||[],t||[],Vr)},An.zipWith=ta,An.entries=Ms,An.entriesIn=As,An.extend=cs,An.extendWith=hs,Ks(An,An),An.add=sl,An.attempt=Vs,An.camelCase=Ps,An.capitalize=zs,An.ceil=ll,An.clamp=function(e,t,n){return void 0===n&&(n=t,t=void 0),void 0!==n&&(n=(n=as(n))==n?n:0),void 0!==t&&(t=(t=as(t))==t?t:0),Yn(as(e),t,n)},An.clone=function(e){return Kn(e,4)},An.cloneDeep=function(e){return Kn(e,5)},An.cloneDeepWith=function(e,t){return Kn(e,5,t="function"==typeof t?t:void 0)},An.cloneWith=function(e,t){return Kn(e,4,t="function"==typeof t?t:void 0)},An.conformsTo=function(e,t){return null==t||Jn(e,t,bs(t))},An.deburr=Os,An.defaultTo=function(e,t){return null==e||e!=e?t:e},An.divide=ul,An.endsWith=function(e,t,n){e=ls(e),t=Jr(t);var r=e.length,i=n=void 0===n?r:Yn(is(n),0,r);return(n-=t.length)>=0&&e.slice(n,i)==t},An.eq=Ia,An.escape=function(e){return(e=ls(e))&&j.test(e)?e.replace(B,Ft):e},An.escapeRegExp=function(e){return(e=ls(e))&&W.test(e)?e.replace(Z,"\\$&"):e},An.every=function(e,t,n){var r=Da(e)?ut:rr;return n&&lo(e,t,n)&&(t=void 0),r(e,Ki(t,3))},An.find=aa,An.findIndex=Oo,An.findKey=function(e,t){return vt(e,Ki(t,3),ur)},An.findLast=sa,An.findLastIndex=Do,An.findLastKey=function(e,t){return vt(e,Ki(t,3),cr)},An.floor=cl,An.forEach=la,An.forEachRight=ua,An.forIn=function(e,t){return null==e?e:sr(e,Ki(t,3),ws)},An.forInRight=function(e,t){return null==e?e:lr(e,Ki(t,3),ws)},An.forOwn=function(e,t){return e&&ur(e,Ki(t,3))},An.forOwnRight=function(e,t){return e&&cr(e,Ki(t,3))},An.get=_s,An.gt=Pa,An.gte=za,An.has=function(e,t){return null!=e&&io(e,t,_r)},An.hasIn=gs,An.head=Ro,An.identity=Ws,An.includes=function(e,t,n,r){e=Ra(e)?e:Is(e),n=n&&!r?is(n):0;var i=e.length;return n<0&&(n=sn(i+n,0)),Ka(e)?n<=i&&e.indexOf(t,n)>-1:!!i&&bt(e,t,n)>-1},An.indexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=null==n?0:is(n);return i<0&&(i=sn(r+i,0)),bt(e,t,i)},An.inRange=function(e,t,n){return t=rs(t),void 0===n?(n=t,t=0):n=rs(n),function(e,t,n){return e>=ln(t,n)&&e=-9007199254740991&&e<=9007199254740991},An.isSet=Ya,An.isString=Ka,An.isSymbol=Ja,An.isTypedArray=Qa,An.isUndefined=function(e){return void 0===e},An.isWeakMap=function(e){return $a(e)&&ro(e)==w},An.isWeakSet=function(e){return $a(e)&&"[object WeakSet]"==pr(e)},An.join=function(e,t){return null==e?"":on.call(e,t)},An.kebabCase=Ds,An.last=No,An.lastIndexOf=function(e,t,n){var r=null==e?0:e.length;if(!r)return-1;var i=r;return void 0!==n&&(i=(i=is(n))<0?sn(r+i,0):ln(i,r-1)),t==t?function(e,t,n){for(var r=n+1;r--;)if(e[r]===t)return r;return r}(e,t,i):xt(e,Et,i,!0)},An.lowerCase=Ls,An.lowerFirst=Rs,An.lt=es,An.lte=ts,An.max=function(e){return e&&e.length?ir(e,Ws,mr):void 0},An.maxBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),mr):void 0},An.mean=function(e){return Tt(e,Ws)},An.meanBy=function(e,t){return Tt(e,Ki(t,2))},An.min=function(e){return e&&e.length?ir(e,Ws,Cr):void 0},An.minBy=function(e,t){return e&&e.length?ir(e,Ki(t,2),Cr):void 0},An.stubArray=ol,An.stubFalse=al,An.stubObject=function(){return{}},An.stubString=function(){return""},An.stubTrue=function(){return!0},An.multiply=dl,An.nth=function(e,t){return e&&e.length?zr(e,is(t)):void 0},An.noConflict=function(){return We._===this&&(We._=Me),this},An.noop=Js,An.now=_a,An.pad=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;if(!t||r>=t)return e;var i=(t-r)/2;return Oi(en(i),n)+e+Oi(Qt(i),n)},An.padEnd=function(e,t,n){e=ls(e);var r=(t=is(t))?Zt(e):0;return t&&rt){var r=e;e=t,t=r}if(n||e%1||t%1){var i=hn();return ln(e+i*(t-e+Ge("1e-"+((i+"").length-1))),t)}return Br(e,t)},An.reduce=function(e,t,n){var r=Da(e)?mt:Ct,i=arguments.length<3;return r(e,Ki(t,4),n,i,tr)},An.reduceRight=function(e,t,n){var r=Da(e)?_t:Ct,i=arguments.length<3;return r(e,Ki(t,4),n,i,nr)},An.repeat=function(e,t,n){return t=(n?lo(e,t,n):void 0===t)?1:is(t),Fr(ls(e),t)},An.replace=function(){var e=arguments,t=ls(e[0]);return e.length<3?t:t.replace(e[1],e[2])},An.result=function(e,t,n){var r=-1,i=(t=li(t,e)).length;for(i||(i=1,e=void 0);++r9007199254740991)return[];var n=4294967295,r=ln(e,4294967295);e-=4294967295;for(var i=At(r,t=Ki(t));++n=o)return e;var s=n-Zt(r);if(s<1)return r;var l=a?ci(a,0,s).join(""):e.slice(0,s);if(void 0===i)return l+r;if(a&&(s+=l.length-s),Ha(i)){if(e.slice(s).search(i)){var u,c=l;for(i.global||(i=me(i.source,ls(re.exec(i))+"g")),i.lastIndex=0;u=i.exec(c);)var h=u.index;l=l.slice(0,void 0===h?s:h)}}else if(e.indexOf(Jr(i),s)!=s){var d=l.lastIndexOf(i);d>-1&&(l=l.slice(0,d))}return l+r},An.unescape=function(e){return(e=ls(e))&&F.test(e)?e.replace(R,Ht):e},An.uniqueId=function(e){var t=++Te;return ls(e)+t},An.upperCase=js,An.upperFirst=Ns,An.each=la,An.eachRight=ua,An.first=Ro,Ks(An,(hl={},ur(An,(function(e,t){Ee.call(An.prototype,t)||(hl[t]=e)})),hl),{chain:!1}),An.VERSION="4.17.21",st(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){An[e].placeholder=An})),st(["drop","take"],(function(e,t){On.prototype[e]=function(n){n=void 0===n?1:sn(is(n),0);var r=this.__filtered__&&!t?new On(this):this.clone();return r.__filtered__?r.__takeCount__=ln(n,r.__takeCount__):r.__views__.push({size:ln(n,4294967295),type:e+(r.__dir__<0?"Right":"")}),r},On.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),st(["filter","map","takeWhile"],(function(e,t){var n=t+1,r=1==n||3==n;On.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:Ki(e,3),type:n}),t.__filtered__=t.__filtered__||r,t}})),st(["head","last"],(function(e,t){var n="take"+(t?"Right":"");On.prototype[e]=function(){return this[n](1).value()[0]}})),st(["initial","tail"],(function(e,t){var n="drop"+(t?"":"Right");On.prototype[e]=function(){return this.__filtered__?new On(this):this[n](1)}})),On.prototype.compact=function(){return this.filter(Ws)},On.prototype.find=function(e){return this.filter(e).head()},On.prototype.findLast=function(e){return this.reverse().find(e)},On.prototype.invokeMap=jr((function(e,t){return"function"==typeof e?new On(this):this.map((function(n){return vr(n,e,t)}))})),On.prototype.reject=function(e){return this.filter(Sa(Ki(e)))},On.prototype.slice=function(e,t){e=is(e);var n=this;return n.__filtered__&&(e>0||t<0)?new On(n):(e<0?n=n.takeRight(-e):e&&(n=n.drop(e)),void 0!==t&&(n=(t=is(t))<0?n.dropRight(-t):n.take(t-e)),n)},On.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},On.prototype.toArray=function(){return this.take(4294967295)},ur(On.prototype,(function(e,t){var n=/^(?:filter|find|map|reject)|While$/.test(t),r=/^(?:head|last)$/.test(t),i=An[r?"take"+("last"==t?"Right":""):t],o=r||/^find/.test(t);i&&(An.prototype[t]=function(){var t=this.__wrapped__,a=r?[1]:arguments,s=t instanceof On,l=a[0],u=s||Da(t),c=function(e){var t=i.apply(An,pt([e],a));return r&&h?t[0]:t};u&&n&&"function"==typeof l&&1!=l.length&&(s=u=!1);var h=this.__chain__,d=!!this.__actions__.length,f=o&&!h,p=s&&!d;if(!o&&u){t=p?t:new On(this);var m=e.apply(t,a);return m.__actions__.push({func:ra,args:[c],thisArg:void 0}),new zn(m,h)}return f&&p?e.apply(this,a):(m=this.thru(c),f?r?m.value()[0]:m.value():m)})})),st(["pop","push","shift","sort","splice","unshift"],(function(e){var t=ye[e],n=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);An.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var i=this.value();return t.apply(Da(i)?i:[],e)}return this[n]((function(n){return t.apply(Da(n)?n:[],e)}))}})),ur(On.prototype,(function(e,t){var n=An[t];if(n){var r=n.name+"";Ee.call(xn,r)||(xn[r]=[]),xn[r].push({name:t,func:n})}})),xn[Ai(void 0,2).name]=[{name:"wrapper",func:void 0}],On.prototype.clone=function(){var e=new On(this.__wrapped__);return e.__actions__=yi(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=yi(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=yi(this.__views__),e},On.prototype.reverse=function(){if(this.__filtered__){var e=new On(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},On.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,n=Da(e),r=t<0,i=n?e.length:0,o=function(e,t,n){var r=-1,i=n.length;for(;++r=this.__values__.length;return{done:e,value:e?void 0:this.__values__[this.__index__++]}},An.prototype.plant=function(e){for(var t,n=this;n instanceof Pn;){var r=Ao(n);r.__index__=0,r.__values__=void 0,t?i.__wrapped__=r:t=r;var i=r;n=n.__wrapped__}return i.__wrapped__=e,t},An.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof On){var t=e;return this.__actions__.length&&(t=new On(this)),(t=t.reverse()).__actions__.push({func:ra,args:[qo],thisArg:void 0}),new zn(t,this.__chain__)}return this.thru(qo)},An.prototype.toJSON=An.prototype.valueOf=An.prototype.value=function(){return ri(this.__wrapped__,this.__actions__)},An.prototype.first=An.prototype.head,Ke&&(An.prototype[Ke]=function(){return this}),An}();We._=Yt,void 0===(i=function(){return Yt}.call(t,n,t,r))||(r.exports=i)}).call(this)}).call(this,n(19),n(80)(e))},function(e,t,n){"use strict";var r=n(0),i=n.n(r),o=n(7),a=n.n(o);function s(){return(s=Object.assign||function(e){for(var t=1;t=d.top+d.height||p.left+p.width>=d.left+d.width))break;u++}return l},f=0,p=Object(r.forwardRef)((function(e,t){var n=e.trigger,o=void 0===n?null:n,c=e.onOpen,h=void 0===c?function(){}:c,p=e.onClose,m=void 0===p?function(){}:p,_=e.defaultOpen,g=void 0!==_&&_,y=e.open,v=void 0===y?void 0:y,x=e.disabled,b=void 0!==x&&x,w=e.nested,E=void 0!==w&&w,T=e.closeOnDocumentClick,S=void 0===T||T,k=e.repositionOnResize,C=void 0===k||k,M=e.closeOnEscape,A=void 0===M||M,I=e.on,P=void 0===I?["click"]:I,z=e.contentStyle,O=void 0===z?{}:z,D=e.arrowStyle,L=void 0===D?{}:D,R=e.overlayStyle,B=void 0===R?{}:R,F=e.className,j=void 0===F?"":F,N=e.position,U=void 0===N?"bottom center":N,V=e.modal,G=void 0!==V&&V,q=e.lockScroll,$=void 0!==q&&q,Z=e.arrow,W=void 0===Z||Z,X=e.offsetX,H=void 0===X?0:X,Y=e.offsetY,K=void 0===Y?0:Y,J=e.mouseEnterDelay,Q=void 0===J?100:J,ee=e.mouseLeaveDelay,te=void 0===ee?100:ee,ne=e.keepTooltipInside,re=void 0!==ne&&ne,ie=e.children,oe=Object(r.useState)(v||g),ae=oe[0],se=oe[1],le=Object(r.useRef)(null),ue=Object(r.useRef)(null),ce=Object(r.useRef)(null),he=Object(r.useRef)(null),de=Object(r.useRef)("popup-"+ ++f),fe=!!G||!o,pe=Object(r.useRef)(0);l((function(){return ae?(he.current=document.activeElement,ke(),Ee(),be()):we(),function(){clearTimeout(pe.current)}}),[ae]),Object(r.useEffect)((function(){"boolean"==typeof v&&(v?me():_e())}),[v,b]);var me=function(e){ae||b||(se(!0),setTimeout((function(){return h(e)}),0))},_e=function(e){var t;ae&&!b&&(se(!1),fe&&(null===(t=he.current)||void 0===t||t.focus()),setTimeout((function(){return m(e)}),0))},ge=function(e){null==e||e.stopPropagation(),ae?_e(e):me(e)},ye=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return me(e)}),Q)},ve=function(e){null==e||e.preventDefault(),ge()},xe=function(e){clearTimeout(pe.current),pe.current=setTimeout((function(){return _e(e)}),te)},be=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="hidden")},we=function(){fe&&$&&(document.getElementsByTagName("body")[0].style.overflow="auto")},Ee=function(){var e,t=null==ue||null===(e=ue.current)||void 0===e?void 0:e.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),n=Array.prototype.slice.call(t)[0];null==n||n.focus()};Object(r.useImperativeHandle)(t,(function(){return{open:function(){me()},close:function(){_e()},toggle:function(){ge()}}}));var Te,Se,ke=function(){if(!fe&&ae&&(null==le?void 0:le.current)&&(null==le?void 0:le.current)&&(null==ue?void 0:ue.current)){var e,t,n=le.current.getBoundingClientRect(),r=ue.current.getBoundingClientRect(),i=d(n,r,U,W,{offsetX:H,offsetY:K},re);if(ue.current.style.top=i.top+window.scrollY+"px",ue.current.style.left=i.left+window.scrollX+"px",W&&ce.current)ce.current.style.transform=i.transform,ce.current.style.setProperty("-ms-transform",i.transform),ce.current.style.setProperty("-webkit-transform",i.transform),ce.current.style.top=(null===(e=L.top)||void 0===e?void 0:e.toString())||i.arrowTop,ce.current.style.left=(null===(t=L.left)||void 0===t?void 0:t.toString())||i.arrowLeft}};Te=_e,void 0===(Se=A)&&(Se=!0),Object(r.useEffect)((function(){if(Se){var e=function(e){"Escape"===e.key&&Te(e)};return document.addEventListener("keyup",e),function(){Se&&document.removeEventListener("keyup",e)}}}),[Te,Se]),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(t){if(9===t.keyCode){var n,r=null==e||null===(n=e.current)||void 0===n?void 0:n.querySelectorAll('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), [tabindex="0"]'),i=Array.prototype.slice.call(r);if(1===i.length)return void t.preventDefault();var o=i[0],a=i[i.length-1];t.shiftKey&&document.activeElement===o?(t.preventDefault(),a.focus()):document.activeElement===a&&(t.preventDefault(),o.focus())}};return document.addEventListener("keydown",n),function(){t&&document.removeEventListener("keydown",n)}}}),[e,t])}(ue,ae&&fe),function(e,t){void 0===t&&(t=!0),Object(r.useEffect)((function(){if(t){var n=function(){e()};return window.addEventListener("resize",n),function(){t&&window.removeEventListener("resize",n)}}}),[e,t])}(ke,C),function(e,t,n){void 0===n&&(n=!0),Object(r.useEffect)((function(){if(n){var r=function(n){var r=Array.isArray(e)?e:[e],i=!1;r.forEach((function(e){e.current&&!e.current.contains(n.target)||(i=!0)})),n.stopPropagation(),i||t(n)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),function(){n&&(document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r))}}}),[e,t,n])}(o?[ue,le]:[ue],_e,S&&!E);var Ce,Me=function(){return i.a.createElement("div",Object.assign({},(e=fe?u.popupContent.modal:u.popupContent.tooltip,t={className:"popup-content "+(""!==j?j.split(" ").map((function(e){return e+"-content"})).join(" "):""),style:s({},e,O,{pointerEvents:"auto"}),ref:ue,onClick:function(e){e.stopPropagation()}},!G&&P.indexOf("hover")>=0&&(t.onMouseEnter=ye,t.onMouseLeave=xe),t),{key:"C",role:fe?"dialog":"tooltip",id:de.current}),W&&!fe&&i.a.createElement("div",{ref:ce,style:u.popupArrow},i.a.createElement("svg",{"data-testid":"arrow",className:"popup-arrow "+(""!==j?j.split(" ").map((function(e){return e+"-arrow"})).join(" "):""),viewBox:"0 0 32 16",style:s({position:"absolute"},L)},i.a.createElement("path",{d:"M16 0l16 16H0z",fill:"currentcolor"}))),ie&&"function"==typeof ie?ie(_e,ae):ie);var e,t},Ae=!(P.indexOf("hover")>=0),Ie=fe?u.overlay.modal:u.overlay.tooltip,Pe=[Ae&&i.a.createElement("div",{key:"O","data-testid":"overlay","data-popup":fe?"modal":"tooltip",className:"popup-overlay "+(""!==j?j.split(" ").map((function(e){return e+"-overlay"})).join(" "):""),style:s({},Ie,B,{pointerEvents:S&&E||fe?"auto":"none"}),onClick:S&&E?_e:void 0,tabIndex:-1},fe&&Me()),!fe&&Me()];return i.a.createElement(i.a.Fragment,null,function(){for(var e={key:"T",ref:le,"aria-describedby":de.current},t=Array.isArray(P)?P:[P],n=0,r=t.length;ne.length)&&(t=e.length);for(var n=0,r=new Array(t);n=0||(i[n]=e[n]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var c=n(0),h=["defaultInputValue","defaultMenuIsOpen","defaultValue","inputValue","menuIsOpen","onChange","onInputChange","onMenuClose","onMenuOpen","value"];function d(){return(d=Object.assign?Object.assign.bind():function(e){for(var t=1;te.brand+"/"+e.version).join(" "):navigator.userAgent}function C(e){return e instanceof E(e).HTMLElement}function M(e){return e instanceof E(e).Element}function A(e){if("undefined"==typeof ShadowRoot)return!1;return e instanceof E(e).ShadowRoot||e instanceof ShadowRoot}function I(e){const{overflow:t,overflowX:n,overflowY:r}=T(e);return/auto|scroll|overlay|hidden/.test(t+r+n)}function P(){return!/^((?!chrome|android).)*safari/i.test(k())}Math.min,Math.max;const z=Math.round;function O(e,t,n){var r,i,o,a;void 0===t&&(t=!1),void 0===n&&(n=!1);const s=e.getBoundingClientRect();let l=1,u=1;t&&C(e)&&(l=e.offsetWidth>0&&z(s.width)/e.offsetWidth||1,u=e.offsetHeight>0&&z(s.height)/e.offsetHeight||1);const c=M(e)?E(e):window,h=!P()&&n,d=(s.left+(h&&null!=(r=null==(i=c.visualViewport)?void 0:i.offsetLeft)?r:0))/l,f=(s.top+(h&&null!=(o=null==(a=c.visualViewport)?void 0:a.offsetTop)?o:0))/u,p=s.width/l,m=s.height/u;return{width:p,height:m,top:f,right:d+p,bottom:f+m,left:d,x:d,y:f}}function D(e){return(t=e,(t instanceof E(t).Node?e.ownerDocument:e.document)||window.document).documentElement;var t}function L(e){return"html"===S(e)?e:e.assignedSlot||e.parentNode||(A(e)?e.host:null)||D(e)}function R(e,t){var n;void 0===t&&(t=[]);const r=function e(t){const n=L(t);return["html","body","#document"].includes(S(n))?t.ownerDocument.body:C(n)&&I(n)?n:e(n)}(e),i=r===(null==(n=e.ownerDocument)?void 0:n.body),o=E(r),a=i?[o].concat(o.visualViewport||[],I(r)?r:[]):r,s=t.concat(a);return i?s:s.concat(R(a))}var B=c.useLayoutEffect,F=["className","clearValue","cx","getStyles","getClassNames","getValue","hasValue","isMulti","isRtl","options","selectOption","selectProps","setValue","theme"],j=function(){};function N(e,t){return t?"-"===t[0]?e+t:e+"__"+t:e}function U(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i-1}function Z(e){return $(e)?window.pageYOffset:e.scrollTop}function W(e,t){$(e)?window.scrollTo(0,t):e.scrollTop=t}function X(e,t,n,r){return n*((e=e/r-1)*e*e+1)+t}function H(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:200,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:j,i=Z(e),o=t-i,a=10,s=0;function l(){var t=X(s+=a,i,o,n);W(e,t),sn.bottom?W(e,Math.min(t.offsetTop+t.clientHeight-e.offsetHeight+i,e.scrollHeight)):r.top-i=p)return{placement:"bottom",maxHeight:t};if(T>=p&&!a)return o&&H(l,S,160),{placement:"bottom",maxHeight:t};if(!a&&T>=r||a&&w>=r)return o&&H(l,S,160),{placement:"bottom",maxHeight:a?w-v:T-v};if("auto"===i||a){var C=t,M=a?b:E;return M>=r&&(C=Math.min(M-v-s,t)),{placement:"top",maxHeight:C}}if("bottom"===i)return o&&W(l,S),{placement:"bottom",maxHeight:t};break;case"top":if(b>=p)return{placement:"top",maxHeight:t};if(E>=p&&!a)return o&&H(l,k,160),{placement:"top",maxHeight:t};if(!a&&E>=r||a&&b>=r){var A=t;return(!a&&E>=r||a&&b>=r)&&(A=a?b-x:E-x),o&&H(l,k,160),{placement:"top",maxHeight:A}}return{placement:"bottom",maxHeight:t};default:throw new Error('Invalid placement provided "'.concat(i,'".'))}return u}var oe=function(e){return"auto"===e?"bottom":e},ae=Object(c.createContext)(null),se=function(e){var t=e.children,n=e.minMenuHeight,r=e.maxMenuHeight,i=e.menuPlacement,a=e.menuPosition,s=e.menuShouldScrollIntoView,u=e.theme,h=(Object(c.useContext)(ae)||{}).setPortalPlacement,d=Object(c.useRef)(null),f=l(Object(c.useState)(r),2),p=f[0],m=f[1],_=l(Object(c.useState)(null),2),g=_[0],y=_[1],v=u.spacing.controlHeight;return B((function(){var e=d.current;if(e){var t="fixed"===a,o=ie({maxHeight:r,menuEl:e,minHeight:n,placement:i,shouldScroll:s&&!t,isFixedPosition:t,controlHeight:v});m(o.maxHeight),y(o.placement),null==h||h(o.placement)}}),[r,i,a,s,n,h,v]),t({ref:d,placerProps:o(o({},e),{},{placement:g||oe(i),maxHeight:p})})},le=function(e,t){var n=e.theme,r=n.spacing.baseUnit,i=n.colors;return o({textAlign:"center"},t?{}:{color:i.neutral40,padding:"".concat(2*r,"px ").concat(3*r,"px")})},ue=le,ce=le,he=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"noOptionsMessage",{"menu-notice":!0,"menu-notice--no-options":!0}),n),t)};he.defaultProps={children:"No options"};var de=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"loadingMessage",{"menu-notice":!0,"menu-notice--loading":!0}),n),t)};de.defaultProps={children:"Loading..."};var fe,pe=["size"];var me,_e,ge={name:"8mmkcg",styles:"display:inline-block;fill:currentColor;line-height:1;stroke:currentColor;stroke-width:0"},ye=function(e){var t=e.size,n=u(e,pe);return Object(x.c)("svg",d({height:t,width:t,viewBox:"0 0 20 20","aria-hidden":"true",focusable:"false",css:ge},n))},ve=function(e){return Object(x.c)(ye,d({size:20},e),Object(x.c)("path",{d:"M14.348 14.849c-0.469 0.469-1.229 0.469-1.697 0l-2.651-3.030-2.651 3.029c-0.469 0.469-1.229 0.469-1.697 0-0.469-0.469-0.469-1.229 0-1.697l2.758-3.15-2.759-3.152c-0.469-0.469-0.469-1.228 0-1.697s1.228-0.469 1.697 0l2.652 3.031 2.651-3.031c0.469-0.469 1.228-0.469 1.697 0s0.469 1.229 0 1.697l-2.758 3.152 2.758 3.15c0.469 0.469 0.469 1.229 0 1.698z"}))},xe=function(e){return Object(x.c)(ye,d({size:20},e),Object(x.c)("path",{d:"M4.516 7.548c0.436-0.446 1.043-0.481 1.576 0l3.908 3.747 3.908-3.747c0.533-0.481 1.141-0.446 1.574 0 0.436 0.445 0.408 1.197 0 1.615-0.406 0.418-4.695 4.502-4.695 4.502-0.217 0.223-0.502 0.335-0.787 0.335s-0.57-0.112-0.789-0.335c0 0-4.287-4.084-4.695-4.502s-0.436-1.17 0-1.615z"}))},be=function(e,t){var n=e.isFocused,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorContainer",display:"flex",transition:"color 150ms"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*i,":hover":{color:n?a.neutral80:a.neutral40}})},we=be,Ee=be,Te=Object(x.d)(fe||(me=["\n 0%, 80%, 100% { opacity: 0; }\n 40% { opacity: 1; }\n"],_e||(_e=me.slice(0)),fe=Object.freeze(Object.defineProperties(me,{raw:{value:Object.freeze(_e)}})))),Se=function(e){var t=e.delay,n=e.offset;return Object(x.c)("span",{css:Object(x.b)({animation:"".concat(Te," 1s ease-in-out ").concat(t,"ms infinite;"),backgroundColor:"currentColor",borderRadius:"1em",display:"inline-block",marginLeft:n?"1em":void 0,height:"1em",verticalAlign:"top",width:"1em"},"","")})},ke=function(e){var t=e.innerProps,n=e.isRtl;return Object(x.c)("div",d({},q(e,"loadingIndicator",{indicator:!0,"loading-indicator":!0}),t),Object(x.c)(Se,{delay:0,offset:n}),Object(x.c)(Se,{delay:160,offset:!0}),Object(x.c)(Se,{delay:320,offset:!n}))};ke.defaultProps={size:4};var Ce=["data"],Me=["innerRef","isDisabled","isHidden","inputClassName"],Ae={gridArea:"1 / 2",font:"inherit",minWidth:"2px",border:0,margin:0,outline:0,padding:0},Ie={flex:"1 1 auto",display:"inline-grid",gridArea:"1 / 1 / 2 / 3",gridTemplateColumns:"0 min-content","&:after":o({content:'attr(data-value) " "',visibility:"hidden",whiteSpace:"pre"},Ae)},Pe=function(e){return o({label:"input",color:"inherit",background:0,opacity:e?0:1,width:"100%"},Ae)},ze=function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",n,t)};var Oe={ClearIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"clearIndicator",{indicator:!0,"clear-indicator":!0}),n),t||Object(x.c)(ve,null))},Control:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.innerRef,o=e.innerProps,a=e.menuIsOpen;return Object(x.c)("div",d({ref:i},q(e,"control",{control:!0,"control--is-disabled":n,"control--is-focused":r,"control--menu-is-open":a}),o),t)},DropdownIndicator:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"dropdownIndicator",{indicator:!0,"dropdown-indicator":!0}),n),t||Object(x.c)(xe,null))},DownChevron:xe,CrossIcon:ve,Group:function(e){var t=e.children,n=e.cx,r=e.getStyles,i=e.getClassNames,o=e.Heading,a=e.headingProps,s=e.innerProps,l=e.label,u=e.theme,c=e.selectProps;return Object(x.c)("div",d({},q(e,"group",{group:!0}),s),Object(x.c)(o,d({},a,{selectProps:c,theme:u,getStyles:r,getClassNames:i,cx:n}),l),Object(x.c)("div",null,t))},GroupHeading:function(e){var t=G(e);t.data;var n=u(t,Ce);return Object(x.c)("div",d({},q(e,"groupHeading",{"group-heading":!0}),n))},IndicatorsContainer:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"indicatorsContainer",{indicators:!0}),n),t)},IndicatorSeparator:function(e){var t=e.innerProps;return Object(x.c)("span",d({},t,q(e,"indicatorSeparator",{"indicator-separator":!0})))},Input:function(e){var t=e.cx,n=e.value,r=G(e),i=r.innerRef,o=r.isDisabled,a=r.isHidden,s=r.inputClassName,l=u(r,Me);return Object(x.c)("div",d({},q(e,"input",{"input-container":!0}),{"data-value":n||""}),Object(x.c)("input",d({className:t({input:!0},s),ref:i,style:Pe(a),disabled:o},l)))},LoadingIndicator:ke,Menu:function(e){var t=e.children,n=e.innerRef,r=e.innerProps;return Object(x.c)("div",d({},q(e,"menu",{menu:!0}),{ref:n},r),t)},MenuList:function(e){var t=e.children,n=e.innerProps,r=e.innerRef,i=e.isMulti;return Object(x.c)("div",d({},q(e,"menuList",{"menu-list":!0,"menu-list--is-multi":i}),{ref:r},n),t)},MenuPortal:function(e){var t=e.appendTo,n=e.children,r=e.controlElement,i=e.innerProps,a=e.menuPlacement,s=e.menuPosition,u=Object(c.useRef)(null),h=Object(c.useRef)(null),f=l(Object(c.useState)(oe(a)),2),p=f[0],m=f[1],_=Object(c.useMemo)((function(){return{setPortalPlacement:m}}),[]),g=l(Object(c.useState)(null),2),y=g[0],v=g[1],w=Object(c.useCallback)((function(){if(r){var e=function(e){var t=e.getBoundingClientRect();return{bottom:t.bottom,height:t.height,left:t.left,right:t.right,top:t.top,width:t.width}}(r),t="fixed"===s?0:window.pageYOffset,n=e[p]+t;n===(null==y?void 0:y.offset)&&e.left===(null==y?void 0:y.rect.left)&&e.width===(null==y?void 0:y.rect.width)||v({offset:n,rect:e})}}),[r,s,p,null==y?void 0:y.offset,null==y?void 0:y.rect.left,null==y?void 0:y.rect.width]);B((function(){w()}),[w]);var E=Object(c.useCallback)((function(){"function"==typeof h.current&&(h.current(),h.current=null),r&&u.current&&(h.current=function(e,t,n,r){void 0===r&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=!0,animationFrame:s=!1}=r,l=i&&!s,u=o&&!s,c=l||u?[...M(e)?R(e):[],...R(t)]:[];c.forEach(e=>{l&&e.addEventListener("scroll",n,{passive:!0}),u&&e.addEventListener("resize",n)});let h,d=null;if(a){let r=!0;d=new ResizeObserver(()=>{r||n(),r=!1}),M(e)&&!s&&d.observe(e),d.observe(t)}let f=s?O(e):null;return s&&function t(){const r=O(e);!f||r.x===f.x&&r.y===f.y&&r.width===f.width&&r.height===f.height||n();f=r,h=requestAnimationFrame(t)}(),n(),()=>{var e;c.forEach(e=>{l&&e.removeEventListener("scroll",n),u&&e.removeEventListener("resize",n)}),null==(e=d)||e.disconnect(),d=null,s&&cancelAnimationFrame(h)}}(r,u.current,w,{elementResize:"ResizeObserver"in window}))}),[r,w]);B((function(){E()}),[E]);var T=Object(c.useCallback)((function(e){u.current=e,E()}),[E]);if(!t&&"fixed"!==s||!y)return null;var S=Object(x.c)("div",d({ref:T},q(o(o({},e),{},{offset:y.offset,position:s,rect:y.rect}),"menuPortal",{"menu-portal":!0}),i),n);return Object(x.c)(ae.Provider,{value:_},t?Object(b.createPortal)(S,t):S)},LoadingMessage:de,NoOptionsMessage:he,MultiValue:function(e){var t=e.children,n=e.components,r=e.data,i=e.innerProps,a=e.isDisabled,s=e.removeProps,l=e.selectProps,u=n.Container,c=n.Label,h=n.Remove;return Object(x.c)(u,{data:r,innerProps:o(o({},q(e,"multiValue",{"multi-value":!0,"multi-value--is-disabled":a})),i),selectProps:l},Object(x.c)(c,{data:r,innerProps:o({},q(e,"multiValueLabel",{"multi-value__label":!0})),selectProps:l},t),Object(x.c)(h,{data:r,innerProps:o(o({},q(e,"multiValueRemove",{"multi-value__remove":!0})),{},{"aria-label":"Remove ".concat(t||"option")},s),selectProps:l}))},MultiValueContainer:ze,MultiValueLabel:ze,MultiValueRemove:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({role:"button"},n),t||Object(x.c)(ve,{size:14}))},Option:function(e){var t=e.children,n=e.isDisabled,r=e.isFocused,i=e.isSelected,o=e.innerRef,a=e.innerProps;return Object(x.c)("div",d({},q(e,"option",{option:!0,"option--is-disabled":n,"option--is-focused":r,"option--is-selected":i}),{ref:o,"aria-disabled":n},a),t)},Placeholder:function(e){var t=e.children,n=e.innerProps;return Object(x.c)("div",d({},q(e,"placeholder",{placeholder:!0}),n),t)},SelectContainer:function(e){var t=e.children,n=e.innerProps,r=e.isDisabled,i=e.isRtl;return Object(x.c)("div",d({},q(e,"container",{"--is-disabled":r,"--is-rtl":i}),n),t)},SingleValue:function(e){var t=e.children,n=e.isDisabled,r=e.innerProps;return Object(x.c)("div",d({},q(e,"singleValue",{"single-value":!0,"single-value--is-disabled":n}),r),t)},ValueContainer:function(e){var t=e.children,n=e.innerProps,r=e.isMulti,i=e.hasValue;return Object(x.c)("div",d({},q(e,"valueContainer",{"value-container":!0,"value-container--is-multi":r,"value-container--has-value":i}),n),t)}},De=Number.isNaN||function(e){return"number"==typeof e&&e!=e};function Le(e,t){if(e.length!==t.length)return!1;for(var n=0;n1?"s":""," ").concat(i.join(","),", selected.");case"select-option":return"option ".concat(r,o?" is disabled. Select another option.":", selected.");default:return""}},onFocus:function(e){var t=e.context,n=e.focused,r=e.options,i=e.label,o=void 0===i?"":i,a=e.selectValue,s=e.isDisabled,l=e.isSelected,u=function(e,t){return e&&e.length?"".concat(e.indexOf(t)+1," of ").concat(e.length):""};if("value"===t&&a)return"value ".concat(o," focused, ").concat(u(a,n),".");if("menu"===t){var c=s?" disabled":"",h="".concat(l?"selected":"focused").concat(c);return"option ".concat(o," ").concat(h,", ").concat(u(r,n),".")}return""},onFilter:function(e){var t=e.inputValue,n=e.resultsMessage;return"".concat(n).concat(t?" for search term "+t:"",".")}},je=function(e){var t=e.ariaSelection,n=e.focusedOption,r=e.focusedValue,i=e.focusableOptions,a=e.isFocused,s=e.selectValue,l=e.selectProps,u=e.id,h=l.ariaLiveMessages,d=l.getOptionLabel,f=l.inputValue,p=l.isMulti,m=l.isOptionDisabled,_=l.isSearchable,g=l.menuIsOpen,y=l.options,v=l.screenReaderStatus,b=l.tabSelectsValue,w=l["aria-label"],E=l["aria-live"],T=Object(c.useMemo)((function(){return o(o({},Fe),h||{})}),[h]),S=Object(c.useMemo)((function(){var e,n="";if(t&&T.onChange){var r=t.option,i=t.options,a=t.removedValue,l=t.removedValues,u=t.value,c=a||r||(e=u,Array.isArray(e)?null:e),h=c?d(c):"",f=i||l||void 0,p=f?f.map(d):[],_=o({isDisabled:c&&m(c,s),label:h,labels:p},t);n=T.onChange(_)}return n}),[t,T,m,s,d]),k=Object(c.useMemo)((function(){var e="",t=n||r,o=!!(n&&s&&s.includes(n));if(t&&T.onFocus){var a={focused:t,label:d(t),isDisabled:m(t,s),isSelected:o,options:i,context:t===n?"menu":"value",selectValue:s};e=T.onFocus(a)}return e}),[n,r,d,m,T,i,s]),C=Object(c.useMemo)((function(){var e="";if(g&&y.length&&T.onFilter){var t=v({count:i.length});e=T.onFilter({inputValue:f,resultsMessage:t})}return e}),[i,f,g,T,y,v]),M=Object(c.useMemo)((function(){var e="";if(T.guidance){var t=r?"value":g?"menu":"input";e=T.guidance({"aria-label":w,context:t,isDisabled:n&&m(n,s),isMulti:p,isSearchable:_,tabSelectsValue:b})}return e}),[w,n,r,p,m,_,g,T,s,b]),A="".concat(k," ").concat(C," ").concat(M),I=Object(x.c)(c.Fragment,null,Object(x.c)("span",{id:"aria-selection"},S),Object(x.c)("span",{id:"aria-context"},A)),P="initial-input-focus"===(null==t?void 0:t.action);return Object(x.c)(c.Fragment,null,Object(x.c)(Be,{id:u},P&&I),Object(x.c)(Be,{"aria-live":E,"aria-atomic":"false","aria-relevant":"additions text"},a&&!P&&I))},Ne=[{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥ"},{base:"nj",letters:"nj"},{base:"o",letters:"oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],Ue=new RegExp("["+Ne.map((function(e){return e.letters})).join("")+"]","g"),Ve={},Ge=0;Ge1?t-1:0),r=1;r0,m=h-d-c,_=!1;m>t&&a.current&&(r&&r(e),a.current=!1),p&&s.current&&(o&&o(e),s.current=!1),p&&t>m?(n&&!a.current&&n(e),f.scrollTop=h,_=!0,a.current=!0):!p&&-t>c&&(i&&!s.current&&i(e),f.scrollTop=0,_=!0,s.current=!0),_&&function(e){e.preventDefault(),e.stopPropagation()}(e)}}),[n,r,i,o]),d=Object(c.useCallback)((function(e){h(e,e.deltaY)}),[h]),f=Object(c.useCallback)((function(e){l.current=e.changedTouches[0].clientY}),[]),p=Object(c.useCallback)((function(e){var t=l.current-e.changedTouches[0].clientY;h(e,t)}),[h]),m=Object(c.useCallback)((function(e){if(e){var t=!!te&&{passive:!1};e.addEventListener("wheel",d,t),e.addEventListener("touchstart",f,t),e.addEventListener("touchmove",p,t)}}),[p,f,d]),_=Object(c.useCallback)((function(e){e&&(e.removeEventListener("wheel",d,!1),e.removeEventListener("touchstart",f,!1),e.removeEventListener("touchmove",p,!1))}),[p,f,d]);return Object(c.useEffect)((function(){if(t){var e=u.current;return m(e),function(){_(e)}}}),[t,m,_]),function(e){u.current=e}}({isEnabled:void 0===r||r,onBottomArrive:e.onBottomArrive,onBottomLeave:e.onBottomLeave,onTopArrive:e.onTopArrive,onTopLeave:e.onTopLeave}),o=function(e){var t=e.isEnabled,n=e.accountForScrollbars,r=void 0===n||n,i=Object(c.useRef)({}),o=Object(c.useRef)(null),a=Object(c.useCallback)((function(e){if(it){var t=document.body,n=t&&t.style;if(r&&Je.forEach((function(e){var t=n&&n[e];i.current[e]=t})),r&&ot<1){var o=parseInt(i.current.paddingRight,10)||0,a=document.body?document.body.clientWidth:0,s=window.innerWidth-a+o||0;Object.keys(Qe).forEach((function(e){var t=Qe[e];n&&(n[e]=t)})),n&&(n.paddingRight="".concat(s,"px"))}t&&rt()&&(t.addEventListener("touchmove",et,at),e&&(e.addEventListener("touchstart",nt,at),e.addEventListener("touchmove",tt,at))),ot+=1}}),[r]),s=Object(c.useCallback)((function(e){if(it){var t=document.body,n=t&&t.style;ot=Math.max(ot-1,0),r&&ot<1&&Je.forEach((function(e){var t=i.current[e];n&&(n[e]=t)})),t&&rt()&&(t.removeEventListener("touchmove",et,at),e&&(e.removeEventListener("touchstart",nt,at),e.removeEventListener("touchmove",tt,at)))}}),[r]);return Object(c.useEffect)((function(){if(t){var e=o.current;return a(e),function(){s(e)}}}),[t,a,s]),function(e){o.current=e}}({isEnabled:n});return Object(x.c)(c.Fragment,null,n&&Object(x.c)("div",{onClick:st,css:lt}),t((function(e){i(e),o(e)})))}var ct={name:"1a0ro4n-requiredInput",styles:"label:requiredInput;opacity:0;pointer-events:none;position:absolute;bottom:0;left:0;right:0;width:100%"},ht=function(e){var t=e.name,n=e.onFocus;return Object(x.c)("input",{required:!0,name:t,tabIndex:-1,onFocus:n,css:ct,value:"",onChange:function(){}})},dt={clearIndicator:Ee,container:function(e){var t=e.isDisabled;return{label:"container",direction:e.isRtl?"rtl":void 0,pointerEvents:t?"none":void 0,position:"relative"}},control:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.theme,a=i.colors,s=i.borderRadius;return o({label:"control",alignItems:"center",cursor:"default",display:"flex",flexWrap:"wrap",justifyContent:"space-between",minHeight:i.spacing.controlHeight,outline:"0 !important",position:"relative",transition:"all 100ms"},t?{}:{backgroundColor:n?a.neutral5:a.neutral0,borderColor:n?a.neutral10:r?a.primary:a.neutral20,borderRadius:s,borderStyle:"solid",borderWidth:1,boxShadow:r?"0 0 0 1px ".concat(a.primary):void 0,"&:hover":{borderColor:r?a.primary:a.neutral30}})},dropdownIndicator:we,group:function(e,t){var n=e.theme.spacing;return t?{}:{paddingBottom:2*n.baseUnit,paddingTop:2*n.baseUnit}},groupHeading:function(e,t){var n=e.theme,r=n.colors,i=n.spacing;return o({label:"group",cursor:"default",display:"block"},t?{}:{color:r.neutral40,fontSize:"75%",fontWeight:500,marginBottom:"0.25em",paddingLeft:3*i.baseUnit,paddingRight:3*i.baseUnit,textTransform:"uppercase"})},indicatorsContainer:function(){return{alignItems:"center",alignSelf:"stretch",display:"flex",flexShrink:0}},indicatorSeparator:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing.baseUnit,a=r.colors;return o({label:"indicatorSeparator",alignSelf:"stretch",width:1},t?{}:{backgroundColor:n?a.neutral10:a.neutral20,marginBottom:2*i,marginTop:2*i})},input:function(e,t){var n=e.isDisabled,r=e.value,i=e.theme,a=i.spacing,s=i.colors;return o(o({visibility:n?"hidden":"visible",transform:r?"translateZ(0)":""},Ie),t?{}:{margin:a.baseUnit/2,paddingBottom:a.baseUnit/2,paddingTop:a.baseUnit/2,color:s.neutral80})},loadingIndicator:function(e,t){var n=e.isFocused,r=e.size,i=e.theme,a=i.colors,s=i.spacing.baseUnit;return o({label:"loadingIndicator",display:"flex",transition:"color 150ms",alignSelf:"center",fontSize:r,lineHeight:1,marginRight:r,textAlign:"center",verticalAlign:"middle"},t?{}:{color:n?a.neutral60:a.neutral20,padding:2*s})},loadingMessage:ce,menu:function(e,t){var n,i=e.placement,a=e.theme,s=a.borderRadius,l=a.spacing,u=a.colors;return o((r(n={label:"menu"},function(e){return e?{bottom:"top",top:"bottom"}[e]:"bottom"}(i),"100%"),r(n,"position","absolute"),r(n,"width","100%"),r(n,"zIndex",1),n),t?{}:{backgroundColor:u.neutral0,borderRadius:s,boxShadow:"0 0 0 1px hsla(0, 0%, 0%, 0.1), 0 4px 11px hsla(0, 0%, 0%, 0.1)",marginBottom:l.menuGutter,marginTop:l.menuGutter})},menuList:function(e,t){var n=e.maxHeight,r=e.theme.spacing.baseUnit;return o({maxHeight:n,overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},t?{}:{paddingBottom:r,paddingTop:r})},menuPortal:function(e){var t=e.rect,n=e.offset,r=e.position;return{left:t.left,position:r,top:n,width:t.width,zIndex:1}},multiValue:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors;return o({label:"multiValue",display:"flex",minWidth:0},t?{}:{backgroundColor:a.neutral10,borderRadius:i/2,margin:r.baseUnit/2})},multiValueLabel:function(e,t){var n=e.theme,r=n.borderRadius,i=n.colors,a=e.cropWithEllipsis;return o({overflow:"hidden",textOverflow:a||void 0===a?"ellipsis":void 0,whiteSpace:"nowrap"},t?{}:{borderRadius:r/2,color:i.neutral80,fontSize:"85%",padding:3,paddingLeft:6})},multiValueRemove:function(e,t){var n=e.theme,r=n.spacing,i=n.borderRadius,a=n.colors,s=e.isFocused;return o({alignItems:"center",display:"flex"},t?{}:{borderRadius:i/2,backgroundColor:s?a.dangerLight:void 0,paddingLeft:r.baseUnit,paddingRight:r.baseUnit,":hover":{backgroundColor:a.dangerLight,color:a.danger}})},noOptionsMessage:ue,option:function(e,t){var n=e.isDisabled,r=e.isFocused,i=e.isSelected,a=e.theme,s=a.spacing,l=a.colors;return o({label:"option",cursor:"default",display:"block",fontSize:"inherit",width:"100%",userSelect:"none",WebkitTapHighlightColor:"rgba(0, 0, 0, 0)"},t?{}:{backgroundColor:i?l.primary:r?l.primary25:"transparent",color:n?l.neutral20:i?l.neutral0:"inherit",padding:"".concat(2*s.baseUnit,"px ").concat(3*s.baseUnit,"px"),":active":{backgroundColor:n?void 0:i?l.primary:l.primary50}})},placeholder:function(e,t){var n=e.theme,r=n.spacing,i=n.colors;return o({label:"placeholder",gridArea:"1 / 1 / 2 / 3"},t?{}:{color:i.neutral50,marginLeft:r.baseUnit/2,marginRight:r.baseUnit/2})},singleValue:function(e,t){var n=e.isDisabled,r=e.theme,i=r.spacing,a=r.colors;return o({label:"singleValue",gridArea:"1 / 1 / 2 / 3",maxWidth:"100%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},t?{}:{color:n?a.neutral40:a.neutral80,marginLeft:i.baseUnit/2,marginRight:i.baseUnit/2})},valueContainer:function(e,t){var n=e.theme.spacing,r=e.isMulti,i=e.hasValue,a=e.selectProps.controlShouldRenderValue;return o({alignItems:"center",display:r&&i&&a?"flex":"grid",flex:1,flexWrap:"wrap",WebkitOverflowScrolling:"touch",position:"relative",overflow:"hidden"},t?{}:{padding:"".concat(n.baseUnit/2,"px ").concat(2*n.baseUnit,"px")})}};var ft,pt={borderRadius:4,colors:{primary:"#2684FF",primary75:"#4C9AFF",primary50:"#B2D4FF",primary25:"#DEEBFF",danger:"#DE350B",dangerLight:"#FFBDAD",neutral0:"hsl(0, 0%, 100%)",neutral5:"hsl(0, 0%, 95%)",neutral10:"hsl(0, 0%, 90%)",neutral20:"hsl(0, 0%, 80%)",neutral30:"hsl(0, 0%, 70%)",neutral40:"hsl(0, 0%, 60%)",neutral50:"hsl(0, 0%, 50%)",neutral60:"hsl(0, 0%, 40%)",neutral70:"hsl(0, 0%, 30%)",neutral80:"hsl(0, 0%, 20%)",neutral90:"hsl(0, 0%, 10%)"},spacing:{baseUnit:4,controlHeight:38,menuGutter:8}},mt={"aria-live":"polite",backspaceRemovesValue:!0,blurInputOnSelect:K(),captureMenuScroll:!K(),classNames:{},closeMenuOnSelect:!0,closeMenuOnScroll:!1,components:{},controlShouldRenderValue:!0,escapeClearsValue:!1,filterOption:function(e,t){if(e.data.__isNew__)return!0;var n=o({ignoreCase:!0,ignoreAccents:!0,stringify:He,trim:!0,matchFrom:"any"},ft),r=n.ignoreCase,i=n.ignoreAccents,a=n.stringify,s=n.trim,l=n.matchFrom,u=s?Xe(t):t,c=s?Xe(a(e)):a(e);return r&&(u=u.toLowerCase(),c=c.toLowerCase()),i&&(u=We(u),c=Ze(c)),"start"===l?c.substr(0,u.length)===u:c.indexOf(u)>-1},formatGroupLabel:function(e){return e.label},getOptionLabel:function(e){return e.label},getOptionValue:function(e){return e.value},isDisabled:!1,isLoading:!1,isMulti:!1,isRtl:!1,isSearchable:!0,isOptionDisabled:function(e){return!!e.isDisabled},loadingMessage:function(){return"Loading..."},maxMenuHeight:300,minMenuHeight:140,menuIsOpen:!1,menuPlacement:"bottom",menuPosition:"absolute",menuShouldBlockScroll:!1,menuShouldScrollIntoView:!function(){try{return/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)}catch(e){return!1}}(),noOptionsMessage:function(){return"No options"},openMenuOnFocus:!1,openMenuOnClick:!0,options:[],pageSize:5,placeholder:"Select...",screenReaderStatus:function(e){var t=e.count;return"".concat(t," result").concat(1!==t?"s":""," available")},styles:{},tabIndex:0,tabSelectsValue:!0,unstyled:!1};function _t(e,t,n,r){return{type:"option",data:t,isDisabled:wt(e,t,n),isSelected:Et(e,t,n),label:xt(e,t),value:bt(e,t),index:r}}function gt(e,t){return e.options.map((function(n,r){if("options"in n){var i=n.options.map((function(n,r){return _t(e,n,t,r)})).filter((function(t){return vt(e,t)}));return i.length>0?{type:"group",data:n,options:i,index:r}:void 0}var o=_t(e,n,t,r);return vt(e,o)?o:void 0})).filter(ne)}function yt(e){return e.reduce((function(e,t){return"group"===t.type?e.push.apply(e,v(t.options.map((function(e){return e.data})))):e.push(t.data),e}),[])}function vt(e,t){var n=e.inputValue,r=void 0===n?"":n,i=t.data,o=t.isSelected,a=t.label,s=t.value;return(!St(e)||!o)&&Tt(e,{label:a,value:s,data:i},r)}var xt=function(e,t){return e.getOptionLabel(t)},bt=function(e,t){return e.getOptionValue(t)};function wt(e,t,n){return"function"==typeof e.isOptionDisabled&&e.isOptionDisabled(t,n)}function Et(e,t,n){if(n.indexOf(t)>-1)return!0;if("function"==typeof e.isOptionSelected)return e.isOptionSelected(t,n);var r=bt(e,t);return n.some((function(t){return bt(e,t)===r}))}function Tt(e,t,n){return!e.filterOption||e.filterOption(t,n)}var St=function(e){var t=e.hideSelectedOptions,n=e.isMulti;return void 0===t?n:t},kt=1,Ct=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&p(e,t)}(a,e);var t,n,r,i=y(a);function a(e){var t;if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,a),(t=i.call(this,e)).state={ariaSelection:null,focusedOption:null,focusedValue:null,inputIsHidden:!1,isFocused:!1,selectValue:[],clearFocusValueOnUpdate:!1,prevWasFocused:!1,inputIsHiddenAfterUpdate:void 0,prevProps:void 0},t.blockOptionHover=!1,t.isComposing=!1,t.commonProps=void 0,t.initialTouchX=0,t.initialTouchY=0,t.instancePrefix="",t.openAfterFocus=!1,t.scrollToFocusedOptionOnUpdate=!1,t.userIsDragging=void 0,t.controlRef=null,t.getControlRef=function(e){t.controlRef=e},t.focusedOptionRef=null,t.getFocusedOptionRef=function(e){t.focusedOptionRef=e},t.menuListRef=null,t.getMenuListRef=function(e){t.menuListRef=e},t.inputRef=null,t.getInputRef=function(e){t.inputRef=e},t.focus=t.focusInput,t.blur=t.blurInput,t.onChange=function(e,n){var r=t.props,i=r.onChange,o=r.name;n.name=o,t.ariaOnChange(e,n),i(e,n)},t.setValue=function(e,n,r){var i=t.props,o=i.closeMenuOnSelect,a=i.isMulti,s=i.inputValue;t.onInputChange("",{action:"set-value",prevInputValue:s}),o&&(t.setState({inputIsHiddenAfterUpdate:!a}),t.onMenuClose()),t.setState({clearFocusValueOnUpdate:!0}),t.onChange(e,{action:n,option:r})},t.selectOption=function(e){var n=t.props,r=n.blurInputOnSelect,i=n.isMulti,o=n.name,a=t.state.selectValue,s=i&&t.isOptionSelected(e,a),l=t.isOptionDisabled(e,a);if(s){var u=t.getOptionValue(e);t.setValue(a.filter((function(e){return t.getOptionValue(e)!==u})),"deselect-option",e)}else{if(l)return void t.ariaOnChange(e,{action:"select-option",option:e,name:o});i?t.setValue([].concat(v(a),[e]),"select-option",e):t.setValue(e,"select-option")}r&&t.blurInput()},t.removeValue=function(e){var n=t.props.isMulti,r=t.state.selectValue,i=t.getOptionValue(e),o=r.filter((function(e){return t.getOptionValue(e)!==i})),a=re(n,o,o[0]||null);t.onChange(a,{action:"remove-value",removedValue:e}),t.focusInput()},t.clearValue=function(){var e=t.state.selectValue;t.onChange(re(t.props.isMulti,[],null),{action:"clear",removedValues:e})},t.popValue=function(){var e=t.props.isMulti,n=t.state.selectValue,r=n[n.length-1],i=n.slice(0,n.length-1),o=re(e,i,i[0]||null);t.onChange(o,{action:"pop-value",removedValue:r})},t.getValue=function(){return t.state.selectValue},t.cx=function(){for(var e=arguments.length,n=new Array(e),r=0;r5||o>5}},t.onTouchEnd=function(e){t.userIsDragging||(t.controlRef&&!t.controlRef.contains(e.target)&&t.menuListRef&&!t.menuListRef.contains(e.target)&&t.blurInput(),t.initialTouchX=0,t.initialTouchY=0)},t.onControlTouchEnd=function(e){t.userIsDragging||t.onControlMouseDown(e)},t.onClearIndicatorTouchEnd=function(e){t.userIsDragging||t.onClearIndicatorMouseDown(e)},t.onDropdownIndicatorTouchEnd=function(e){t.userIsDragging||t.onDropdownIndicatorMouseDown(e)},t.handleInputChange=function(e){var n=t.props.inputValue,r=e.currentTarget.value;t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange(r,{action:"input-change",prevInputValue:n}),t.props.menuIsOpen||t.onMenuOpen()},t.onInputFocus=function(e){t.props.onFocus&&t.props.onFocus(e),t.setState({inputIsHiddenAfterUpdate:!1,isFocused:!0}),(t.openAfterFocus||t.props.openMenuOnFocus)&&t.openMenu("first"),t.openAfterFocus=!1},t.onInputBlur=function(e){var n=t.props.inputValue;t.menuListRef&&t.menuListRef.contains(document.activeElement)?t.inputRef.focus():(t.props.onBlur&&t.props.onBlur(e),t.onInputChange("",{action:"input-blur",prevInputValue:n}),t.onMenuClose(),t.setState({focusedValue:null,isFocused:!1}))},t.onOptionHover=function(e){t.blockOptionHover||t.state.focusedOption===e||t.setState({focusedOption:e})},t.shouldHideSelectedOptions=function(){return St(t.props)},t.onValueInputFocus=function(e){e.preventDefault(),e.stopPropagation(),t.focus()},t.onKeyDown=function(e){var n=t.props,r=n.isMulti,i=n.backspaceRemovesValue,o=n.escapeClearsValue,a=n.inputValue,s=n.isClearable,l=n.isDisabled,u=n.menuIsOpen,c=n.onKeyDown,h=n.tabSelectsValue,d=n.openMenuOnFocus,f=t.state,p=f.focusedOption,m=f.focusedValue,_=f.selectValue;if(!(l||"function"==typeof c&&(c(e),e.defaultPrevented))){switch(t.blockOptionHover=!0,e.key){case"ArrowLeft":if(!r||a)return;t.focusValue("previous");break;case"ArrowRight":if(!r||a)return;t.focusValue("next");break;case"Delete":case"Backspace":if(a)return;if(m)t.removeValue(m);else{if(!i)return;r?t.popValue():s&&t.clearValue()}break;case"Tab":if(t.isComposing)return;if(e.shiftKey||!u||!h||!p||d&&t.isOptionSelected(p,_))return;t.selectOption(p);break;case"Enter":if(229===e.keyCode)break;if(u){if(!p)return;if(t.isComposing)return;t.selectOption(p);break}return;case"Escape":u?(t.setState({inputIsHiddenAfterUpdate:!1}),t.onInputChange("",{action:"menu-close",prevInputValue:a}),t.onMenuClose()):s&&o&&t.clearValue();break;case" ":if(a)return;if(!u){t.openMenu("first");break}if(!p)return;t.selectOption(p);break;case"ArrowUp":u?t.focusOption("up"):t.openMenu("last");break;case"ArrowDown":u?t.focusOption("down"):t.openMenu("first");break;case"PageUp":if(!u)return;t.focusOption("pageup");break;case"PageDown":if(!u)return;t.focusOption("pagedown");break;case"Home":if(!u)return;t.focusOption("first");break;case"End":if(!u)return;t.focusOption("last");break;default:return}e.preventDefault()}},t.instancePrefix="react-select-"+(t.props.instanceId||++kt),t.state.selectValue=V(e.value),e.menuIsOpen&&t.state.selectValue.length){var n=t.buildFocusableOptions(),r=n.indexOf(t.state.selectValue[0]);t.state.focusedOption=n[r]}return t}return t=a,r=[{key:"getDerivedStateFromProps",value:function(e,t){var n=t.prevProps,r=t.clearFocusValueOnUpdate,i=t.inputIsHiddenAfterUpdate,a=t.ariaSelection,s=t.isFocused,l=t.prevWasFocused,u=e.options,c=e.value,h=e.menuIsOpen,d=e.inputValue,f=e.isMulti,p=V(c),m={};if(n&&(c!==n.value||u!==n.options||h!==n.menuIsOpen||d!==n.inputValue)){var _=h?function(e,t){return yt(gt(e,t))}(e,p):[],g=r?function(e,t){var n=e.focusedValue,r=e.selectValue.indexOf(n);if(r>-1){if(t.indexOf(n)>-1)return n;if(r-1?n:t[0]}(t,_),focusedValue:g,clearFocusValueOnUpdate:!1}}var y=null!=i&&e!==n?{inputIsHidden:i,inputIsHiddenAfterUpdate:void 0}:{},v=a,x=s&&l;return s&&!x&&(v={value:re(f,p,p[0]||null),options:p,action:"initial-input-focus"},x=!l),"initial-input-focus"===(null==a?void 0:a.action)&&(v=null),o(o(o({},m),y),{},{prevProps:e,ariaSelection:v,prevWasFocused:x})}}],(n=[{key:"componentDidMount",value:function(){this.startListeningComposition(),this.startListeningToTouch(),this.props.closeMenuOnScroll&&document&&document.addEventListener&&document.addEventListener("scroll",this.onScroll,!0),this.props.autoFocus&&this.focusInput(),this.props.menuIsOpen&&this.state.focusedOption&&this.menuListRef&&this.focusedOptionRef&&Y(this.menuListRef,this.focusedOptionRef)}},{key:"componentDidUpdate",value:function(e){var t=this.props,n=t.isDisabled,r=t.menuIsOpen,i=this.state.isFocused;(i&&!n&&e.isDisabled||i&&r&&!e.menuIsOpen)&&this.focusInput(),i&&n&&!e.isDisabled?this.setState({isFocused:!1},this.onMenuClose):i||n||!e.isDisabled||this.inputRef!==document.activeElement||this.setState({isFocused:!0}),this.menuListRef&&this.focusedOptionRef&&this.scrollToFocusedOptionOnUpdate&&(Y(this.menuListRef,this.focusedOptionRef),this.scrollToFocusedOptionOnUpdate=!1)}},{key:"componentWillUnmount",value:function(){this.stopListeningComposition(),this.stopListeningToTouch(),document.removeEventListener("scroll",this.onScroll,!0)}},{key:"onMenuOpen",value:function(){this.props.onMenuOpen()}},{key:"onMenuClose",value:function(){this.onInputChange("",{action:"menu-close",prevInputValue:this.props.inputValue}),this.props.onMenuClose()}},{key:"onInputChange",value:function(e,t){this.props.onInputChange(e,t)}},{key:"focusInput",value:function(){this.inputRef&&this.inputRef.focus()}},{key:"blurInput",value:function(){this.inputRef&&this.inputRef.blur()}},{key:"openMenu",value:function(e){var t=this,n=this.state,r=n.selectValue,i=n.isFocused,o=this.buildFocusableOptions(),a="first"===e?0:o.length-1;if(!this.props.isMulti){var s=o.indexOf(r[0]);s>-1&&(a=s)}this.scrollToFocusedOptionOnUpdate=!(i&&this.menuListRef),this.setState({inputIsHiddenAfterUpdate:!1,focusedValue:null,focusedOption:o[a]},(function(){return t.onMenuOpen()}))}},{key:"focusValue",value:function(e){var t=this.state,n=t.selectValue,r=t.focusedValue;if(this.props.isMulti){this.setState({focusedOption:null});var i=n.indexOf(r);r||(i=-1);var o=n.length-1,a=-1;if(n.length){switch(e){case"previous":a=0===i?0:-1===i?o:i-1;break;case"next":i>-1&&i0&&void 0!==arguments[0]?arguments[0]:"first",t=this.props.pageSize,n=this.state.focusedOption,r=this.getFocusableOptions();if(r.length){var i=0,o=r.indexOf(n);n||(o=-1),"up"===e?i=o>0?o-1:r.length-1:"down"===e?i=(o+1)%r.length:"pageup"===e?(i=o-t)<0&&(i=0):"pagedown"===e?(i=o+t)>r.length-1&&(i=r.length-1):"last"===e&&(i=r.length-1),this.scrollToFocusedOptionOnUpdate=!0,this.setState({focusedOption:r[i],focusedValue:null})}}},{key:"getTheme",value:function(){return this.props.theme?"function"==typeof this.props.theme?this.props.theme(pt):o(o({},pt),this.props.theme):pt}},{key:"getCommonProps",value:function(){var e=this.clearValue,t=this.cx,n=this.getStyles,r=this.getClassNames,i=this.getValue,o=this.selectOption,a=this.setValue,s=this.props,l=s.isMulti,u=s.isRtl,c=s.options;return{clearValue:e,cx:t,getStyles:n,getClassNames:r,getValue:i,hasValue:this.hasValue(),isMulti:l,isRtl:u,options:c,selectOption:o,selectProps:s,setValue:a,theme:this.getTheme()}}},{key:"hasValue",value:function(){return this.state.selectValue.length>0}},{key:"hasOptions",value:function(){return!!this.getFocusableOptions().length}},{key:"isClearable",value:function(){var e=this.props,t=e.isClearable,n=e.isMulti;return void 0===t?n:t}},{key:"isOptionDisabled",value:function(e,t){return wt(this.props,e,t)}},{key:"isOptionSelected",value:function(e,t){return Et(this.props,e,t)}},{key:"filterOption",value:function(e,t){return Tt(this.props,e,t)}},{key:"formatOptionLabel",value:function(e,t){if("function"==typeof this.props.formatOptionLabel){var n=this.props.inputValue,r=this.state.selectValue;return this.props.formatOptionLabel(e,{context:t,inputValue:n,selectValue:r})}return this.getOptionLabel(e)}},{key:"formatGroupLabel",value:function(e){return this.props.formatGroupLabel(e)}},{key:"startListeningComposition",value:function(){document&&document.addEventListener&&(document.addEventListener("compositionstart",this.onCompositionStart,!1),document.addEventListener("compositionend",this.onCompositionEnd,!1))}},{key:"stopListeningComposition",value:function(){document&&document.removeEventListener&&(document.removeEventListener("compositionstart",this.onCompositionStart),document.removeEventListener("compositionend",this.onCompositionEnd))}},{key:"startListeningToTouch",value:function(){document&&document.addEventListener&&(document.addEventListener("touchstart",this.onTouchStart,!1),document.addEventListener("touchmove",this.onTouchMove,!1),document.addEventListener("touchend",this.onTouchEnd,!1))}},{key:"stopListeningToTouch",value:function(){document&&document.removeEventListener&&(document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchmove",this.onTouchMove),document.removeEventListener("touchend",this.onTouchEnd))}},{key:"renderInput",value:function(){var e=this.props,t=e.isDisabled,n=e.isSearchable,r=e.inputId,i=e.inputValue,a=e.tabIndex,s=e.form,l=e.menuIsOpen,u=e.required,h=this.getComponents().Input,f=this.state,p=f.inputIsHidden,m=f.ariaSelection,_=this.commonProps,g=r||this.getElementId("input"),y=o(o(o({"aria-autocomplete":"list","aria-expanded":l,"aria-haspopup":!0,"aria-errormessage":this.props["aria-errormessage"],"aria-invalid":this.props["aria-invalid"],"aria-label":this.props["aria-label"],"aria-labelledby":this.props["aria-labelledby"],"aria-required":u,role:"combobox"},l&&{"aria-controls":this.getElementId("listbox"),"aria-owns":this.getElementId("listbox")}),!n&&{"aria-readonly":!0}),this.hasValue()?"initial-input-focus"===(null==m?void 0:m.action)&&{"aria-describedby":this.getElementId("live-region")}:{"aria-describedby":this.getElementId("placeholder")});return n?c.createElement(h,d({},_,{autoCapitalize:"none",autoComplete:"off",autoCorrect:"off",id:g,innerRef:this.getInputRef,isDisabled:t,isHidden:p,onBlur:this.onInputBlur,onChange:this.handleInputChange,onFocus:this.onInputFocus,spellCheck:"false",tabIndex:a,form:s,type:"text",value:i},y)):c.createElement(Ke,d({id:g,innerRef:this.getInputRef,onBlur:this.onInputBlur,onChange:j,onFocus:this.onInputFocus,disabled:t,tabIndex:a,inputMode:"none",form:s,value:""},y))}},{key:"renderPlaceholderOrValue",value:function(){var e=this,t=this.getComponents(),n=t.MultiValue,r=t.MultiValueContainer,i=t.MultiValueLabel,o=t.MultiValueRemove,a=t.SingleValue,s=t.Placeholder,l=this.commonProps,u=this.props,h=u.controlShouldRenderValue,f=u.isDisabled,p=u.isMulti,m=u.inputValue,_=u.placeholder,g=this.state,y=g.selectValue,v=g.focusedValue,x=g.isFocused;if(!this.hasValue()||!h)return m?null:c.createElement(s,d({},l,{key:"placeholder",isDisabled:f,isFocused:x,innerProps:{id:this.getElementId("placeholder")}}),_);if(p)return y.map((function(t,a){var s=t===v,u="".concat(e.getOptionLabel(t),"-").concat(e.getOptionValue(t));return c.createElement(n,d({},l,{components:{Container:r,Label:i,Remove:o},isFocused:s,isDisabled:f,key:u,index:a,removeProps:{onClick:function(){return e.removeValue(t)},onTouchEnd:function(){return e.removeValue(t)},onMouseDown:function(e){e.preventDefault()}},data:t}),e.formatOptionLabel(t,"value"))}));if(m)return null;var b=y[0];return c.createElement(a,d({},l,{data:b,isDisabled:f}),this.formatOptionLabel(b,"value"))}},{key:"renderClearIndicator",value:function(){var e=this.getComponents().ClearIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;if(!this.isClearable()||!e||r||!this.hasValue()||i)return null;var a={onMouseDown:this.onClearIndicatorMouseDown,onTouchEnd:this.onClearIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:a,isFocused:o}))}},{key:"renderLoadingIndicator",value:function(){var e=this.getComponents().LoadingIndicator,t=this.commonProps,n=this.props,r=n.isDisabled,i=n.isLoading,o=this.state.isFocused;return e&&i?c.createElement(e,d({},t,{innerProps:{"aria-hidden":"true"},isDisabled:r,isFocused:o})):null}},{key:"renderIndicatorSeparator",value:function(){var e=this.getComponents(),t=e.DropdownIndicator,n=e.IndicatorSeparator;if(!t||!n)return null;var r=this.commonProps,i=this.props.isDisabled,o=this.state.isFocused;return c.createElement(n,d({},r,{isDisabled:i,isFocused:o}))}},{key:"renderDropdownIndicator",value:function(){var e=this.getComponents().DropdownIndicator;if(!e)return null;var t=this.commonProps,n=this.props.isDisabled,r=this.state.isFocused,i={onMouseDown:this.onDropdownIndicatorMouseDown,onTouchEnd:this.onDropdownIndicatorTouchEnd,"aria-hidden":"true"};return c.createElement(e,d({},t,{innerProps:i,isDisabled:n,isFocused:r}))}},{key:"renderMenu",value:function(){var e=this,t=this.getComponents(),n=t.Group,r=t.GroupHeading,i=t.Menu,o=t.MenuList,a=t.MenuPortal,s=t.LoadingMessage,l=t.NoOptionsMessage,u=t.Option,h=this.commonProps,f=this.state.focusedOption,p=this.props,m=p.captureMenuScroll,_=p.inputValue,g=p.isLoading,y=p.loadingMessage,v=p.minMenuHeight,x=p.maxMenuHeight,b=p.menuIsOpen,w=p.menuPlacement,E=p.menuPosition,T=p.menuPortalTarget,S=p.menuShouldBlockScroll,k=p.menuShouldScrollIntoView,C=p.noOptionsMessage,M=p.onMenuScrollToTop,A=p.onMenuScrollToBottom;if(!b)return null;var I,P=function(t,n){var r=t.type,i=t.data,o=t.isDisabled,a=t.isSelected,s=t.label,l=t.value,p=f===i,m=o?void 0:function(){return e.onOptionHover(i)},_=o?void 0:function(){return e.selectOption(i)},g="".concat(e.getElementId("option"),"-").concat(n),y={id:g,onClick:_,onMouseMove:m,onMouseOver:m,tabIndex:-1};return c.createElement(u,d({},h,{innerProps:y,data:i,isDisabled:o,isSelected:a,key:g,label:s,type:r,value:l,isFocused:p,innerRef:p?e.getFocusedOptionRef:void 0}),e.formatOptionLabel(t.data,"menu"))};if(this.hasOptions())I=this.getCategorizedOptions().map((function(t){if("group"===t.type){var i=t.data,o=t.options,a=t.index,s="".concat(e.getElementId("group"),"-").concat(a),l="".concat(s,"-heading");return c.createElement(n,d({},h,{key:s,data:i,options:o,Heading:r,headingProps:{id:l,data:t.data},label:e.formatGroupLabel(t.data)}),t.options.map((function(e){return P(e,"".concat(a,"-").concat(e.index))})))}if("option"===t.type)return P(t,"".concat(t.index))}));else if(g){var z=y({inputValue:_});if(null===z)return null;I=c.createElement(s,h,z)}else{var O=C({inputValue:_});if(null===O)return null;I=c.createElement(l,h,O)}var D={minMenuHeight:v,maxMenuHeight:x,menuPlacement:w,menuPosition:E,menuShouldScrollIntoView:k},L=c.createElement(se,d({},h,D),(function(t){var n=t.ref,r=t.placerProps,a=r.placement,s=r.maxHeight;return c.createElement(i,d({},h,D,{innerRef:n,innerProps:{onMouseDown:e.onMenuMouseDown,onMouseMove:e.onMenuMouseMove,id:e.getElementId("listbox")},isLoading:g,placement:a}),c.createElement(ut,{captureEnabled:m,onTopArrive:M,onBottomArrive:A,lockEnabled:S},(function(t){return c.createElement(o,d({},h,{innerRef:function(n){e.getMenuListRef(n),t(n)},isLoading:g,maxHeight:s,focusedOption:f}),I)})))}));return T||"fixed"===E?c.createElement(a,d({},h,{appendTo:T,controlElement:this.controlRef,menuPlacement:w,menuPosition:E}),L):L}},{key:"renderFormField",value:function(){var e=this,t=this.props,n=t.delimiter,r=t.isDisabled,i=t.isMulti,o=t.name,a=t.required,s=this.state.selectValue;if(o&&!r){if(a&&!this.hasValue())return c.createElement(ht,{name:o,onFocus:this.onValueInputFocus});if(i){if(n){var l=s.map((function(t){return e.getOptionValue(t)})).join(n);return c.createElement("input",{name:o,type:"hidden",value:l})}var u=s.length>0?s.map((function(t,n){return c.createElement("input",{key:"i-".concat(n),name:o,type:"hidden",value:e.getOptionValue(t)})})):c.createElement("input",{name:o,type:"hidden",value:""});return c.createElement("div",null,u)}var h=s[0]?this.getOptionValue(s[0]):"";return c.createElement("input",{name:o,type:"hidden",value:h})}}},{key:"renderLiveRegion",value:function(){var e=this.commonProps,t=this.state,n=t.ariaSelection,r=t.focusedOption,i=t.focusedValue,o=t.isFocused,a=t.selectValue,s=this.getFocusableOptions();return c.createElement(je,d({},e,{id:this.getElementId("live-region"),ariaSelection:n,focusedOption:r,focusedValue:i,isFocused:o,selectValue:a,focusableOptions:s}))}},{key:"render",value:function(){var e=this.getComponents(),t=e.Control,n=e.IndicatorsContainer,r=e.SelectContainer,i=e.ValueContainer,o=this.props,a=o.className,s=o.id,l=o.isDisabled,u=o.menuIsOpen,h=this.state.isFocused,f=this.commonProps=this.getCommonProps();return c.createElement(r,d({},f,{className:a,innerProps:{id:s,onKeyDown:this.onKeyDown},isDisabled:l,isFocused:h}),this.renderLiveRegion(),c.createElement(t,d({},f,{innerRef:this.getControlRef,innerProps:{onMouseDown:this.onControlMouseDown,onTouchEnd:this.onControlTouchEnd},isDisabled:l,isFocused:h,menuIsOpen:u}),c.createElement(i,d({},f,{isDisabled:l}),this.renderPlaceholderOrValue(),this.renderInput()),c.createElement(n,d({},f,{isDisabled:l}),this.renderClearIndicator(),this.renderLoadingIndicator(),this.renderIndicatorSeparator(),this.renderDropdownIndicator())),this.renderMenu(),this.renderFormField())}}])&&f(t.prototype,n),r&&f(t,r),Object.defineProperty(t,"prototype",{writable:!1}),a}(c.Component);Ct.defaultProps=mt;n(5),n(17),n(53),n(54),n(58),n(60),n(61),n(62),n(64),n(69),n(30),n(73),n(27);var Mt=Object(c.forwardRef)((function(e,t){var n,r,i,a,s,f,p,m,_,g,y,v,x,b,w,E,T,S,k,C,M,A,I,P,z,O,D,L,R,B,F,j=(r=(n=e).defaultInputValue,i=void 0===r?"":r,a=n.defaultMenuIsOpen,s=void 0!==a&&a,f=n.defaultValue,p=void 0===f?null:f,m=n.inputValue,_=n.menuIsOpen,g=n.onChange,y=n.onInputChange,v=n.onMenuClose,x=n.onMenuOpen,b=n.value,w=u(n,h),E=l(Object(c.useState)(void 0!==m?m:i),2),T=E[0],S=E[1],k=l(Object(c.useState)(void 0!==_?_:s),2),C=k[0],M=k[1],A=l(Object(c.useState)(void 0!==b?b:p),2),I=A[0],P=A[1],z=Object(c.useCallback)((function(e,t){"function"==typeof g&&g(e,t),P(e)}),[g]),O=Object(c.useCallback)((function(e,t){var n;"function"==typeof y&&(n=y(e,t)),S(void 0!==n?n:e)}),[y]),D=Object(c.useCallback)((function(){"function"==typeof x&&x(),M(!0)}),[x]),L=Object(c.useCallback)((function(){"function"==typeof v&&v(),M(!1)}),[v]),R=void 0!==m?m:T,B=void 0!==_?_:C,F=void 0!==b?b:I,o(o({},w),{},{inputValue:R,menuIsOpen:B,onChange:z,onInputChange:O,onMenuClose:L,onMenuOpen:D,value:F}));return c.createElement(Ct,d({ref:t},j))}));t.a=Mt},,function(e,t,n){"use strict"; /** * @license React * react-dom.production.min.js @@ -27,7 +27,7 @@ License: MIT * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var r=n(0),i=n(42);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n