(function(On,Sn){typeof exports=="object"&&typeof module<"u"?Sn(exports):typeof define=="function"&&define.amd?define(["exports"],Sn):(On=typeof globalThis<"u"?globalThis:On||self,Sn(On["geojson-map"]={}))})(this,function(On){"use strict";var cf=Object.defineProperty;var uf=(On,Sn,to)=>Sn in On?cf(On,Sn,{enumerable:!0,configurable:!0,writable:!0,value:to}):On[Sn]=to;var Te=(On,Sn,to)=>(uf(On,typeof Sn!="symbol"?Sn+"":Sn,to),to);var Sn=typeof document<"u"?document.currentScript:null,to=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qh(Q){return Q&&Q.__esModule&&Object.prototype.hasOwnProperty.call(Q,"default")?Q.default:Q}var eu={exports:{}};(function(Q,w){(function(I,L){Q.exports=L()})(to,function(){var I=function(f,b){var D={drag:[],click:[],mousemove:[],mousedown:[],mouseup:[],mouseout:[],keydown:[],keyup:[],touchstart:[],touchmove:[],touchend:[],tap:[]},W={on:function(ie,ue,ke){if(D[ie]===void 0)throw new Error("Invalid event type: "+ie);D[ie].push({selector:ue,fn:ke})},render:function(ie){b.store.featureChanged(ie)}},te=function(ie,ue){for(var ke=D[ie],Be=ke.length;Be--;){var Xe=ke[Be];if(Xe.selector(ue)){Xe.fn.call(W,ue)||b.store.render(),b.ui.updateMapClasses();break}}};return f.start.call(W),{render:f.render,stop:function(){f.stop&&f.stop()},trash:function(){f.trash&&(f.trash(),b.store.render())},combineFeatures:function(){f.combineFeatures&&f.combineFeatures()},uncombineFeatures:function(){f.uncombineFeatures&&f.uncombineFeatures()},drag:function(ie){te("drag",ie)},click:function(ie){te("click",ie)},mousemove:function(ie){te("mousemove",ie)},mousedown:function(ie){te("mousedown",ie)},mouseup:function(ie){te("mouseup",ie)},mouseout:function(ie){te("mouseout",ie)},keydown:function(ie){te("keydown",ie)},keyup:function(ie){te("keyup",ie)},touchstart:function(ie){te("touchstart",ie)},touchmove:function(ie){te("touchmove",ie)},touchend:function(ie){te("touchend",ie)},tap:function(ie){te("tap",ie)}}};function L(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}function U(f){if(f.__esModule)return f;var b=f.default;if(typeof b=="function"){var D=function W(){if(this instanceof W){var te=[null];te.push.apply(te,arguments);var ie=Function.bind.apply(b,te);return new ie}return b.apply(this,arguments)};D.prototype=b.prototype}else D={};return Object.defineProperty(D,"__esModule",{value:!0}),Object.keys(f).forEach(function(W){var te=Object.getOwnPropertyDescriptor(f,W);Object.defineProperty(D,W,te.get?te:{enumerable:!0,get:function(){return f[W]}})}),D}var de={},M={RADIUS:6378137,FLATTENING:1/298.257223563,POLAR_RADIUS:63567523142e-4},d=M;function Se(f){var b=0;if(f&&f.length>0){b+=Math.abs(Re(f[0]));for(var D=1;D2){for(ue=0;ue=Math.pow(2,f)?$i(f,b):ie};$i.rack=function(f,b,D){var W=function(ie){var ue=0;do{if(ue++>10){if(!D)throw new Error("too many ID collisions, use more bits");f+=D}var ke=$i(f,b)}while(Object.hasOwnProperty.call(te,ke));return te[ke]=ie,ke},te=W.hats={};return W.get=function(ie){return W.hats[ie]},W.set=function(ie,ue){return W.hats[ie]=ue,W},W.bits=f||128,W.base=b||16,W};var Ai=L(dn.exports),ii=function(f,b){this.ctx=f,this.properties=b.properties||{},this.coordinates=b.geometry.coordinates,this.id=b.id||Ai(),this.type=b.geometry.type};ii.prototype.changed=function(){this.ctx.store.featureChanged(this.id)},ii.prototype.incomingCoords=function(f){this.setCoordinates(f)},ii.prototype.setCoordinates=function(f){this.coordinates=f,this.changed()},ii.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.coordinates))},ii.prototype.setProperty=function(f,b){this.properties[f]=b},ii.prototype.toGeoJSON=function(){return JSON.parse(JSON.stringify({id:this.id,type:De.FEATURE,properties:this.properties,geometry:{coordinates:this.getCoordinates(),type:this.type}}))},ii.prototype.internal=function(f){var b={id:this.id,meta:Mt.FEATURE,"meta:type":this.type,active:xt.INACTIVE,mode:f};if(this.ctx.options.userProperties)for(var D in this.properties)b["user_"+D]=this.properties[D];return{type:De.FEATURE,properties:b,geometry:{coordinates:this.getCoordinates(),type:this.type}}};var Sr=function(f,b){ii.call(this,f,b)};(Sr.prototype=Object.create(ii.prototype)).isValid=function(){return typeof this.coordinates[0]=="number"&&typeof this.coordinates[1]=="number"},Sr.prototype.updateCoordinate=function(f,b,D){this.coordinates=arguments.length===3?[b,D]:[f,b],this.changed()},Sr.prototype.getCoordinate=function(){return this.getCoordinates()};var bi=function(f,b){ii.call(this,f,b)};(bi.prototype=Object.create(ii.prototype)).isValid=function(){return this.coordinates.length>1},bi.prototype.addCoordinate=function(f,b,D){this.changed();var W=parseInt(f,10);this.coordinates.splice(W,0,[b,D])},bi.prototype.getCoordinate=function(f){var b=parseInt(f,10);return JSON.parse(JSON.stringify(this.coordinates[b]))},bi.prototype.removeCoordinate=function(f){this.changed(),this.coordinates.splice(parseInt(f,10),1)},bi.prototype.updateCoordinate=function(f,b,D){var W=parseInt(f,10);this.coordinates[W]=[b,D],this.changed()};var wi=function(f,b){ii.call(this,f,b),this.coordinates=this.coordinates.map(function(D){return D.slice(0,-1)})};(wi.prototype=Object.create(ii.prototype)).isValid=function(){return this.coordinates.length!==0&&this.coordinates.every(function(f){return f.length>2})},wi.prototype.incomingCoords=function(f){this.coordinates=f.map(function(b){return b.slice(0,-1)}),this.changed()},wi.prototype.setCoordinates=function(f){this.coordinates=f,this.changed()},wi.prototype.addCoordinate=function(f,b,D){this.changed();var W=f.split(".").map(function(te){return parseInt(te,10)});this.coordinates[W[0]].splice(W[1],0,[b,D])},wi.prototype.removeCoordinate=function(f){this.changed();var b=f.split(".").map(function(W){return parseInt(W,10)}),D=this.coordinates[b[0]];D&&(D.splice(b[1],1),D.length<3&&this.coordinates.splice(b[0],1))},wi.prototype.getCoordinate=function(f){var b=f.split(".").map(function(W){return parseInt(W,10)}),D=this.coordinates[b[0]];return JSON.parse(JSON.stringify(D[b[1]]))},wi.prototype.getCoordinates=function(){return this.coordinates.map(function(f){return f.concat([f[0]])})},wi.prototype.updateCoordinate=function(f,b,D){this.changed();var W=f.split("."),te=parseInt(W[0],10),ie=parseInt(W[1],10);this.coordinates[te]===void 0&&(this.coordinates[te]=[]),this.coordinates[te][ie]=[b,D]};var or={MultiPoint:Sr,MultiLineString:bi,MultiPolygon:wi},sr=function(f,b,D,W,te){var ie=D.split("."),ue=parseInt(ie[0],10),ke=ie[1]?ie.slice(1).join("."):null;return f[ue][b](ke,W,te)},Ii=function(f,b){if(ii.call(this,f,b),delete this.coordinates,this.model=or[b.geometry.type],this.model===void 0)throw new TypeError(b.geometry.type+" is not a valid type");this.features=this._coordinatesToFeatures(b.geometry.coordinates)};function bt(f){this.map=f.map,this.drawConfig=JSON.parse(JSON.stringify(f.options||{})),this._ctx=f}(Ii.prototype=Object.create(ii.prototype))._coordinatesToFeatures=function(f){var b=this,D=this.model.bind(this);return f.map(function(W){return new D(b.ctx,{id:Ai(),type:De.FEATURE,properties:{},geometry:{coordinates:W,type:b.type.replace("Multi","")}})})},Ii.prototype.isValid=function(){return this.features.every(function(f){return f.isValid()})},Ii.prototype.setCoordinates=function(f){this.features=this._coordinatesToFeatures(f),this.changed()},Ii.prototype.getCoordinate=function(f){return sr(this.features,"getCoordinate",f)},Ii.prototype.getCoordinates=function(){return JSON.parse(JSON.stringify(this.features.map(function(f){return f.type===De.POLYGON?f.getCoordinates():f.coordinates})))},Ii.prototype.updateCoordinate=function(f,b,D){sr(this.features,"updateCoordinate",f,b,D),this.changed()},Ii.prototype.addCoordinate=function(f,b,D){sr(this.features,"addCoordinate",f,b,D),this.changed()},Ii.prototype.removeCoordinate=function(f){sr(this.features,"removeCoordinate",f),this.changed()},Ii.prototype.getFeatures=function(){return this.features},bt.prototype.setSelected=function(f){return this._ctx.store.setSelected(f)},bt.prototype.setSelectedCoordinates=function(f){var b=this;this._ctx.store.setSelectedCoordinates(f),f.reduce(function(D,W){return D[W.feature_id]===void 0&&(D[W.feature_id]=!0,b._ctx.store.get(W.feature_id).changed()),D},{})},bt.prototype.getSelected=function(){return this._ctx.store.getSelected()},bt.prototype.getSelectedIds=function(){return this._ctx.store.getSelectedIds()},bt.prototype.isSelected=function(f){return this._ctx.store.isSelected(f)},bt.prototype.getFeature=function(f){return this._ctx.store.get(f)},bt.prototype.select=function(f){return this._ctx.store.select(f)},bt.prototype.deselect=function(f){return this._ctx.store.deselect(f)},bt.prototype.deleteFeature=function(f,b){return b===void 0&&(b={}),this._ctx.store.delete(f,b)},bt.prototype.addFeature=function(f){return this._ctx.store.add(f)},bt.prototype.clearSelectedFeatures=function(){return this._ctx.store.clearSelected()},bt.prototype.clearSelectedCoordinates=function(){return this._ctx.store.clearSelectedCoordinates()},bt.prototype.setActionableState=function(f){f===void 0&&(f={});var b={trash:f.trash||!1,combineFeatures:f.combineFeatures||!1,uncombineFeatures:f.uncombineFeatures||!1};return this._ctx.events.actionable(b)},bt.prototype.changeMode=function(f,b,D){return b===void 0&&(b={}),D===void 0&&(D={}),this._ctx.events.changeMode(f,b,D)},bt.prototype.updateUIClasses=function(f){return this._ctx.ui.queueMapClasses(f)},bt.prototype.activateUIButton=function(f){return this._ctx.ui.setActiveButton(f)},bt.prototype.featuresAt=function(f,b,D){if(D===void 0&&(D="click"),D!=="click"&&D!=="touch")throw new Error("invalid buffer type");return fi[D](f,b,this._ctx)},bt.prototype.newFeature=function(f){var b=f.geometry.type;return b===De.POINT?new Sr(this._ctx,f):b===De.LINE_STRING?new bi(this._ctx,f):b===De.POLYGON?new wi(this._ctx,f):new Ii(this._ctx,f)},bt.prototype.isInstanceOf=function(f,b){if(f===De.POINT)return b instanceof Sr;if(f===De.LINE_STRING)return b instanceof bi;if(f===De.POLYGON)return b instanceof wi;if(f==="MultiFeature")return b instanceof Ii;throw new Error("Unknown feature class: "+f)},bt.prototype.doRender=function(f){return this._ctx.store.featureChanged(f)},bt.prototype.onSetup=function(){},bt.prototype.onDrag=function(){},bt.prototype.onClick=function(){},bt.prototype.onMouseMove=function(){},bt.prototype.onMouseDown=function(){},bt.prototype.onMouseUp=function(){},bt.prototype.onMouseOut=function(){},bt.prototype.onKeyUp=function(){},bt.prototype.onKeyDown=function(){},bt.prototype.onTouchStart=function(){},bt.prototype.onTouchMove=function(){},bt.prototype.onTouchEnd=function(){},bt.prototype.onTap=function(){},bt.prototype.onStop=function(){},bt.prototype.onTrash=function(){},bt.prototype.onCombineFeature=function(){},bt.prototype.onUncombineFeature=function(){},bt.prototype.toDisplayFeatures=function(){throw new Error("You must overwrite toDisplayFeatures")};var Vn={drag:"onDrag",click:"onClick",mousemove:"onMouseMove",mousedown:"onMouseDown",mouseup:"onMouseUp",mouseout:"onMouseOut",keyup:"onKeyUp",keydown:"onKeyDown",touchstart:"onTouchStart",touchmove:"onTouchMove",touchend:"onTouchEnd",tap:"onTap"},Vr=Object.keys(Vn);function Xr(f){var b=Object.keys(f);return function(D,W){W===void 0&&(W={});var te={},ie=b.reduce(function(ue,ke){return ue[ke]=f[ke],ue},new bt(D));return{start:function(){var ue=this;te=ie.onSetup(W),Vr.forEach(function(ke){var Be,Xe=Vn[ke],Je=function(){return!1};f[Xe]&&(Je=function(){return!0}),ue.on(ke,Je,(Be=Xe,function(Ve){return ie[Be](te,Ve)}))})},stop:function(){ie.onStop(te)},trash:function(){ie.onTrash(te)},combineFeatures:function(){ie.onCombineFeatures(te)},uncombineFeatures:function(){ie.onUncombineFeatures(te)},render:function(ue,ke){ie.toDisplayFeatures(te,ue,ke)}}}}function Yt(f){return[].concat(f).filter(function(b){return b!==void 0})}function Jr(){var f=this;if(!(f.ctx.map&&f.ctx.map.getSource(oe.HOT)!==void 0))return Be();var b=f.ctx.events.currentModeName();f.ctx.ui.queueMapClasses({mode:b});var D=[],W=[];f.isDirty?W=f.getAllIds():(D=f.getChangedIds().filter(function(Xe){return f.get(Xe)!==void 0}),W=f.sources.hot.filter(function(Xe){return Xe.properties.id&&D.indexOf(Xe.properties.id)===-1&&f.get(Xe.properties.id)!==void 0}).map(function(Xe){return Xe.properties.id})),f.sources.hot=[];var te=f.sources.cold.length;f.sources.cold=f.isDirty?[]:f.sources.cold.filter(function(Xe){var Je=Xe.properties.id||Xe.properties.parent;return D.indexOf(Je)===-1});var ie=te!==f.sources.cold.length||W.length>0;function ue(Xe,Je){var Ve=f.get(Xe).internal(b);f.ctx.events.currentModeRender(Ve,function(wt){f.sources[Je].push(wt)})}if(D.forEach(function(Xe){return ue(Xe,"hot")}),W.forEach(function(Xe){return ue(Xe,"cold")}),ie&&f.ctx.map.getSource(oe.COLD).setData({type:De.FEATURE_COLLECTION,features:f.sources.cold}),f.ctx.map.getSource(oe.HOT).setData({type:De.FEATURE_COLLECTION,features:f.sources.hot}),f._emitSelectionChange&&(f.ctx.map.fire($t.SELECTION_CHANGE,{features:f.getSelected().map(function(Xe){return Xe.toGeoJSON()}),points:f.getSelectedCoordinates().map(function(Xe){return{type:De.FEATURE,properties:{},geometry:{type:De.POINT,coordinates:Xe.coordinates}}})}),f._emitSelectionChange=!1),f._deletedFeaturesToEmit.length){var ke=f._deletedFeaturesToEmit.map(function(Xe){return Xe.toGeoJSON()});f._deletedFeaturesToEmit=[],f.ctx.map.fire($t.DELETE,{features:ke})}function Be(){f.isDirty=!1,f.clearChangedIds()}Be(),f.ctx.map.fire($t.RENDER,{})}function Ot(f){var b,D=this;this._features={},this._featureIds=new xi,this._selectedFeatureIds=new xi,this._selectedCoordinates=[],this._changedFeatureIds=new xi,this._deletedFeaturesToEmit=[],this._emitSelectionChange=!1,this._mapInitialConfig={},this.ctx=f,this.sources={hot:[],cold:[]},this.render=function(){b||(b=requestAnimationFrame(function(){b=null,Jr.call(D)}))},this.isDirty=!1}function be(f,b){var D=f._selectedCoordinates.filter(function(W){return f._selectedFeatureIds.has(W.feature_id)});f._selectedCoordinates.length===D.length||b.silent||(f._emitSelectionChange=!0),f._selectedCoordinates=D}Ot.prototype.createRenderBatch=function(){var f=this,b=this.render,D=0;return this.render=function(){D++},function(){f.render=b,D>0&&f.render()}},Ot.prototype.setDirty=function(){return this.isDirty=!0,this},Ot.prototype.featureChanged=function(f){return this._changedFeatureIds.add(f),this},Ot.prototype.getChangedIds=function(){return this._changedFeatureIds.values()},Ot.prototype.clearChangedIds=function(){return this._changedFeatureIds.clear(),this},Ot.prototype.getAllIds=function(){return this._featureIds.values()},Ot.prototype.add=function(f){return this.featureChanged(f.id),this._features[f.id]=f,this._featureIds.add(f.id),this},Ot.prototype.delete=function(f,b){var D=this;return b===void 0&&(b={}),Yt(f).forEach(function(W){D._featureIds.has(W)&&(D._featureIds.delete(W),D._selectedFeatureIds.delete(W),b.silent||D._deletedFeaturesToEmit.indexOf(D._features[W])===-1&&D._deletedFeaturesToEmit.push(D._features[W]),delete D._features[W],D.isDirty=!0)}),be(this,b),this},Ot.prototype.get=function(f){return this._features[f]},Ot.prototype.getAll=function(){var f=this;return Object.keys(this._features).map(function(b){return f._features[b]})},Ot.prototype.select=function(f,b){var D=this;return b===void 0&&(b={}),Yt(f).forEach(function(W){D._selectedFeatureIds.has(W)||(D._selectedFeatureIds.add(W),D._changedFeatureIds.add(W),b.silent||(D._emitSelectionChange=!0))}),this},Ot.prototype.deselect=function(f,b){var D=this;return b===void 0&&(b={}),Yt(f).forEach(function(W){D._selectedFeatureIds.has(W)&&(D._selectedFeatureIds.delete(W),D._changedFeatureIds.add(W),b.silent||(D._emitSelectionChange=!0))}),be(this,b),this},Ot.prototype.clearSelected=function(f){return f===void 0&&(f={}),this.deselect(this._selectedFeatureIds.values(),{silent:f.silent}),this},Ot.prototype.setSelected=function(f,b){var D=this;return b===void 0&&(b={}),f=Yt(f),this.deselect(this._selectedFeatureIds.values().filter(function(W){return f.indexOf(W)===-1}),{silent:b.silent}),this.select(f.filter(function(W){return!D._selectedFeatureIds.has(W)}),{silent:b.silent}),this},Ot.prototype.setSelectedCoordinates=function(f){return this._selectedCoordinates=f,this._emitSelectionChange=!0,this},Ot.prototype.clearSelectedCoordinates=function(){return this._selectedCoordinates=[],this._emitSelectionChange=!0,this},Ot.prototype.getSelectedIds=function(){return this._selectedFeatureIds.values()},Ot.prototype.getSelected=function(){var f=this;return this._selectedFeatureIds.values().map(function(b){return f.get(b)})},Ot.prototype.getSelectedCoordinates=function(){var f=this;return this._selectedCoordinates.map(function(b){return{coordinates:f.get(b.feature_id).getCoordinate(b.coord_path)}})},Ot.prototype.isSelected=function(f){return this._selectedFeatureIds.has(f)},Ot.prototype.setFeatureProperty=function(f,b,D){this.get(f).setProperty(b,D),this.featureChanged(f)},Ot.prototype.storeMapConfig=function(){var f=this;Gt.forEach(function(b){f.ctx.map[b]&&(f._mapInitialConfig[b]=f.ctx.map[b].isEnabled())})},Ot.prototype.restoreMapConfig=function(){var f=this;Object.keys(this._mapInitialConfig).forEach(function(b){f._mapInitialConfig[b]?f.ctx.map[b].enable():f.ctx.map[b].disable()})},Ot.prototype.getInitialConfigValue=function(f){return this._mapInitialConfig[f]===void 0||this._mapInitialConfig[f]};var Tn=function(){for(var f=arguments,b={},D=0;D=48&&Ee<=57)};function It(Ee,rt,zt){zt===void 0&&(zt={}),wt.stop();var ki=ke[Ee];if(ki===void 0)throw new Error(Ee+" is not valid");Ve=Ee;var Ti=ki(ue,rt);wt=I(Ti,ue),zt.silent||ue.map.fire($t.MODE_CHANGE,{mode:Ee}),ue.store.setDirty(),ue.store.render()}Je.keydown=function(Ee){(Ee.srcElement||Ee.target).classList.contains("mapboxgl-canvas")&&(Ee.keyCode!==8&&Ee.keyCode!==46||!ue.options.controls.trash?gi(Ee.keyCode)?wt.keydown(Ee):Ee.keyCode===49&&ue.options.controls.point?It(it.DRAW_POINT):Ee.keyCode===50&&ue.options.controls.line_string?It(it.DRAW_LINE_STRING):Ee.keyCode===51&&ue.options.controls.polygon&&It(it.DRAW_POLYGON):(Ee.preventDefault(),wt.trash()))},Je.keyup=function(Ee){gi(Ee.keyCode)&&wt.keyup(Ee)},Je.zoomend=function(){ue.store.changeZoom()},Je.data=function(Ee){if(Ee.dataType==="style"){var rt=ue.setup,zt=ue.map,ki=ue.options,Ti=ue.store;ki.styles.some(function(yo){return zt.getLayer(yo.id)})||(rt.addLayers(),Ti.setDirty(),Ti.render())}};var Vi={trash:!1,combineFeatures:!1,uncombineFeatures:!1};return{start:function(){Ve=ue.options.defaultMode,wt=I(ke[Ve](ue),ue)},changeMode:It,actionable:function(Ee){var rt=!1;Object.keys(Ee).forEach(function(zt){if(Vi[zt]===void 0)throw new Error("Invalid action type");Vi[zt]!==Ee[zt]&&(rt=!0),Vi[zt]=Ee[zt]}),rt&&ue.map.fire($t.ACTIONABLE,{actions:Vi})},currentModeName:function(){return Ve},currentModeRender:function(Ee,rt){return wt.render(Ee,rt)},fire:function(Ee,rt){Je[Ee]&&Je[Ee](rt)},addEventListeners:function(){ue.map.on("mousemove",Je.mousemove),ue.map.on("mousedown",Je.mousedown),ue.map.on("mouseup",Je.mouseup),ue.map.on("data",Je.data),ue.map.on("touchmove",Je.touchmove),ue.map.on("touchstart",Je.touchstart),ue.map.on("touchend",Je.touchend),ue.container.addEventListener("mouseout",Je.mouseout),ue.options.keybindings&&(ue.container.addEventListener("keydown",Je.keydown),ue.container.addEventListener("keyup",Je.keyup))},removeEventListeners:function(){ue.map.off("mousemove",Je.mousemove),ue.map.off("mousedown",Je.mousedown),ue.map.off("mouseup",Je.mouseup),ue.map.off("data",Je.data),ue.map.off("touchmove",Je.touchmove),ue.map.off("touchstart",Je.touchstart),ue.map.off("touchend",Je.touchend),ue.container.removeEventListener("mouseout",Je.mouseout),ue.options.keybindings&&(ue.container.removeEventListener("keydown",Je.keydown),ue.container.removeEventListener("keyup",Je.keyup))},trash:function(Ee){wt.trash(Ee)},combineFeatures:function(){wt.combineFeatures()},uncombineFeatures:function(){wt.uncombineFeatures()},getMode:function(){return Ve}}}(f),f.ui=function(ue){var ke={},Be=null,Xe={mode:null,feature:null,mouse:null},Je={mode:null,feature:null,mouse:null};function Ve(Ee){Je=ft(Je,Ee)}function wt(){var Ee,rt;if(ue.container){var zt=[],ki=[];ci.forEach(function(Ti){Je[Ti]!==Xe[Ti]&&(zt.push(Ti+"-"+Xe[Ti]),Je[Ti]!==null&&ki.push(Ti+"-"+Je[Ti]))}),zt.length>0&&(Ee=ue.container.classList).remove.apply(Ee,zt),ki.length>0&&(rt=ue.container.classList).add.apply(rt,ki),Xe=ft(Xe,Je)}}function gi(Ee,rt){rt===void 0&&(rt={});var zt=document.createElement("button");return zt.className=ce.CONTROL_BUTTON+" "+rt.className,zt.setAttribute("title",rt.title),rt.container.appendChild(zt),zt.addEventListener("click",function(ki){if(ki.preventDefault(),ki.stopPropagation(),ki.target===Be)return It(),void rt.onDeactivate();Vi(Ee),rt.onActivate()},!0),zt}function It(){Be&&(Be.classList.remove(ce.ACTIVE_BUTTON),Be=null)}function Vi(Ee){It();var rt=ke[Ee];rt&&rt&&Ee!=="trash"&&(rt.classList.add(ce.ACTIVE_BUTTON),Be=rt)}return{setActiveButton:Vi,queueMapClasses:Ve,updateMapClasses:wt,clearMapClasses:function(){Ve({mode:null,feature:null,mouse:null}),wt()},addButtons:function(){var Ee=ue.options.controls,rt=document.createElement("div");return rt.className=ce.CONTROL_GROUP+" "+ce.CONTROL_BASE,Ee&&(Ee[et.LINE]&&(ke[et.LINE]=gi(et.LINE,{container:rt,className:ce.CONTROL_BUTTON_LINE,title:"LineString tool "+(ue.options.keybindings?"(l)":""),onActivate:function(){return ue.events.changeMode(it.DRAW_LINE_STRING)},onDeactivate:function(){return ue.events.trash()}})),Ee[et.POLYGON]&&(ke[et.POLYGON]=gi(et.POLYGON,{container:rt,className:ce.CONTROL_BUTTON_POLYGON,title:"Polygon tool "+(ue.options.keybindings?"(p)":""),onActivate:function(){return ue.events.changeMode(it.DRAW_POLYGON)},onDeactivate:function(){return ue.events.trash()}})),Ee[et.POINT]&&(ke[et.POINT]=gi(et.POINT,{container:rt,className:ce.CONTROL_BUTTON_POINT,title:"Marker tool "+(ue.options.keybindings?"(m)":""),onActivate:function(){return ue.events.changeMode(it.DRAW_POINT)},onDeactivate:function(){return ue.events.trash()}})),Ee.trash&&(ke.trash=gi("trash",{container:rt,className:ce.CONTROL_BUTTON_TRASH,title:"Delete",onActivate:function(){ue.events.trash()}})),Ee.combine_features&&(ke.combine_features=gi("combineFeatures",{container:rt,className:ce.CONTROL_BUTTON_COMBINE_FEATURES,title:"Combine",onActivate:function(){ue.events.combineFeatures()}})),Ee.uncombine_features&&(ke.uncombine_features=gi("uncombineFeatures",{container:rt,className:ce.CONTROL_BUTTON_UNCOMBINE_FEATURES,title:"Uncombine",onActivate:function(){ue.events.uncombineFeatures()}}))),rt},removeButtons:function(){Object.keys(ke).forEach(function(Ee){var rt=ke[Ee];rt.parentNode&&rt.parentNode.removeChild(rt),delete ke[Ee]})}}}(f),f.container=te.getContainer(),f.store=new Ot(f),b=f.ui.addButtons(),f.options.boxSelect&&(f.boxZoomInitial=te.boxZoom.isEnabled(),te.boxZoom.disable(),te.dragPan.disable(),te.dragPan.enable()),te.loaded()?W.connect():(te.on("load",W.connect),D=setInterval(function(){te.loaded()&&W.connect()},16)),f.events.start(),b},addLayers:function(){f.map.addSource(oe.COLD,{data:{type:De.FEATURE_COLLECTION,features:[]},type:"geojson"}),f.map.addSource(oe.HOT,{data:{type:De.FEATURE_COLLECTION,features:[]},type:"geojson"}),f.options.styles.forEach(function(te){f.map.addLayer(te)}),f.store.setDirty(!0),f.store.render()},removeLayers:function(){f.options.styles.forEach(function(te){f.map.getLayer(te.id)&&f.map.removeLayer(te.id)}),f.map.getSource(oe.COLD)&&f.map.removeSource(oe.COLD),f.map.getSource(oe.HOT)&&f.map.removeSource(oe.HOT)}};return f.setup=W,W}var Cn=[{id:"gl-draw-polygon-fill-inactive",type:"fill",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],paint:{"fill-color":"#3bb2d0","fill-outline-color":"#3bb2d0","fill-opacity":.1}},{id:"gl-draw-polygon-fill-active",type:"fill",filter:["all",["==","active","true"],["==","$type","Polygon"]],paint:{"fill-color":"#fbb03b","fill-outline-color":"#fbb03b","fill-opacity":.1}},{id:"gl-draw-polygon-midpoint",type:"circle",filter:["all",["==","$type","Point"],["==","meta","midpoint"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-stroke-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","Polygon"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-polygon-stroke-active",type:"line",filter:["all",["==","active","true"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-line-inactive",type:"line",filter:["all",["==","active","false"],["==","$type","LineString"],["!=","mode","static"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#3bb2d0","line-width":2}},{id:"gl-draw-line-active",type:"line",filter:["all",["==","$type","LineString"],["==","active","true"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#fbb03b","line-dasharray":[.2,2],"line-width":2}},{id:"gl-draw-polygon-and-line-vertex-stroke-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-color":"#fff"}},{id:"gl-draw-polygon-and-line-vertex-inactive",type:"circle",filter:["all",["==","meta","vertex"],["==","$type","Point"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#fbb03b"}},{id:"gl-draw-point-point-stroke-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":5,"circle-opacity":1,"circle-color":"#fff"}},{id:"gl-draw-point-inactive",type:"circle",filter:["all",["==","active","false"],["==","$type","Point"],["==","meta","feature"],["!=","mode","static"]],paint:{"circle-radius":3,"circle-color":"#3bb2d0"}},{id:"gl-draw-point-stroke-active",type:"circle",filter:["all",["==","$type","Point"],["==","active","true"],["!=","meta","midpoint"]],paint:{"circle-radius":7,"circle-color":"#fff"}},{id:"gl-draw-point-active",type:"circle",filter:["all",["==","$type","Point"],["!=","meta","midpoint"],["==","active","true"]],paint:{"circle-radius":5,"circle-color":"#fbb03b"}},{id:"gl-draw-polygon-fill-static",type:"fill",filter:["all",["==","mode","static"],["==","$type","Polygon"]],paint:{"fill-color":"#404040","fill-outline-color":"#404040","fill-opacity":.1}},{id:"gl-draw-polygon-stroke-static",type:"line",filter:["all",["==","mode","static"],["==","$type","Polygon"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-line-static",type:"line",filter:["all",["==","mode","static"],["==","$type","LineString"]],layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":"#404040","line-width":2}},{id:"gl-draw-point-static",type:"circle",filter:["all",["==","mode","static"],["==","$type","Point"]],paint:{"circle-radius":5,"circle-color":"#404040"}}];function Kr(f){return function(b){var D=b.featureTarget;return!!D&&!!D.properties&&D.properties.meta===f}}function Ur(f){return!!f.originalEvent&&!!f.originalEvent.shiftKey&&f.originalEvent.button===0}function Fi(f){return!!f.featureTarget&&!!f.featureTarget.properties&&f.featureTarget.properties.active===xt.ACTIVE&&f.featureTarget.properties.meta===Mt.FEATURE}function jn(f){return!!f.featureTarget&&!!f.featureTarget.properties&&f.featureTarget.properties.active===xt.INACTIVE&&f.featureTarget.properties.meta===Mt.FEATURE}function jr(f){return f.featureTarget===void 0}function ze(f){return!!f.featureTarget&&!!f.featureTarget.properties&&f.featureTarget.properties.meta===Mt.FEATURE}function ar(f){var b=f.featureTarget;return!!b&&!!b.properties&&b.properties.meta===Mt.VERTEX}function Wi(f){return!!f.originalEvent&&f.originalEvent.shiftKey===!0}function pn(f){return f.keyCode===27}function Xi(f){return f.keyCode===13}var Ue=Object.freeze({__proto__:null,isOfMetaType:Kr,isShiftMousedown:Ur,isActiveFeature:Fi,isInactiveFeature:jn,noTarget:jr,isFeature:ze,isVertex:ar,isShiftDown:Wi,isEscapeKey:pn,isEnterKey:Xi,isTrue:function(){return!0}}),Tt=yt;function yt(f,b){this.x=f,this.y=b}yt.prototype={clone:function(){return new yt(this.x,this.y)},add:function(f){return this.clone()._add(f)},sub:function(f){return this.clone()._sub(f)},multByPoint:function(f){return this.clone()._multByPoint(f)},divByPoint:function(f){return this.clone()._divByPoint(f)},mult:function(f){return this.clone()._mult(f)},div:function(f){return this.clone()._div(f)},rotate:function(f){return this.clone()._rotate(f)},rotateAround:function(f,b){return this.clone()._rotateAround(f,b)},matMult:function(f){return this.clone()._matMult(f)},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(f){return this.x===f.x&&this.y===f.y},dist:function(f){return Math.sqrt(this.distSqr(f))},distSqr:function(f){var b=f.x-this.x,D=f.y-this.y;return b*b+D*D},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(f){return Math.atan2(this.y-f.y,this.x-f.x)},angleWith:function(f){return this.angleWithSep(f.x,f.y)},angleWithSep:function(f,b){return Math.atan2(this.x*b-this.y*f,this.x*f+this.y*b)},_matMult:function(f){var b=f[0]*this.x+f[1]*this.y,D=f[2]*this.x+f[3]*this.y;return this.x=b,this.y=D,this},_add:function(f){return this.x+=f.x,this.y+=f.y,this},_sub:function(f){return this.x-=f.x,this.y-=f.y,this},_mult:function(f){return this.x*=f,this.y*=f,this},_div:function(f){return this.x/=f,this.y/=f,this},_multByPoint:function(f){return this.x*=f.x,this.y*=f.y,this},_divByPoint:function(f){return this.x/=f.x,this.y/=f.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var f=this.y;return this.y=this.x,this.x=-f,this},_rotate:function(f){var b=Math.cos(f),D=Math.sin(f),W=b*this.x-D*this.y,te=D*this.x+b*this.y;return this.x=W,this.y=te,this},_rotateAround:function(f,b){var D=Math.cos(f),W=Math.sin(f),te=b.x+D*(this.x-b.x)-W*(this.y-b.y),ie=b.y+W*(this.x-b.x)+D*(this.y-b.y);return this.x=te,this.y=ie,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},yt.convert=function(f){return f instanceof yt?f:Array.isArray(f)?new yt(f[0],f[1]):f};var Gi=L(Tt);function Yr(f,b){var D=b.getBoundingClientRect();return new Gi(f.clientX-D.left-(b.clientLeft||0),f.clientY-D.top-(b.clientTop||0))}function mt(f,b,D,W){return{type:De.FEATURE,properties:{meta:Mt.VERTEX,parent:f,coord_path:D,active:W?xt.ACTIVE:xt.INACTIVE},geometry:{type:De.POINT,coordinates:b}}}function ro(f,b,D){var W=b.geometry.coordinates,te=D.geometry.coordinates;if(W[1]>85||W[1]85||te[1]=b&&this._bbox[3]>=D},ut.prototype.intersect=function(f){return this._valid?(b=f instanceof ut?f.bbox():f,!(this._bbox[0]>b[2]||this._bbox[2]b[3])):null;var b},ut.prototype._fastContains=function(){if(!this._valid)return new Function("return null;");var f="return "+this._bbox[0]+"<= ll[0] &&"+this._bbox[1]+"<= ll[1] &&"+this._bbox[2]+">= ll[0] &&"+this._bbox[3]+">= ll[1]";return new Function("ll",f)},ut.prototype.polygon=function(){return this._valid?{type:"Polygon",coordinates:[[[this._bbox[0],this._bbox[1]],[this._bbox[2],this._bbox[1]],[this._bbox[2],this._bbox[3]],[this._bbox[0],this._bbox[3]],[this._bbox[0],this._bbox[1]]]]}:null};var Si=function(f){if(!f)return[];var b=le(ne(f)),D=[];return b.features.forEach(function(W){W.geometry&&(D=D.concat(K(W.geometry.coordinates)))}),D},Ji=ui,Tr=Zi,Er={features:["FeatureCollection"],coordinates:["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],geometry:["Feature"],geometries:["GeometryCollection"]},er=Object.keys(Er);function Qr(f){for(var b=Tr(),D=Si(f),W=0;WD&&(D=Ve),wtte&&(te=wt),Veke&&(ke=It)});var Be=b;return D+Be.lat>85&&(Be.lat=85-D),te+Be.lat>90&&(Be.lat=90-te),W+Be.lat<-85&&(Be.lat=-85-W),ie+Be.lat=270&&(Be.lng-=360*Math.ceil(Math.abs(Be.lng)/360)),Be}function qo(f,b){var D=Jt(f.map(function(W){return W.toGeoJSON()}),b);f.forEach(function(W){var te,ie=W.getCoordinates(),ue=function(Be){var Xe={lng:Be[0]+D.lng,lat:Be[1]+D.lat};return[Xe.lng,Xe.lat]},ke=function(Be){return Be.map(function(Xe){return ue(Xe)})};W.type===De.POINT?te=ue(ie):W.type===De.LINE_STRING||W.type===De.MULTI_POINT?te=ie.map(ue):W.type===De.POLYGON||W.type===De.MULTI_LINE_STRING?te=ie.map(ke):W.type===De.MULTI_POLYGON&&(te=ie.map(function(Be){return Be.map(function(Xe){return ke(Xe)})})),W.incomingCoords(te)})}var Bi={onSetup:function(f){var b=this,D={dragMoveLocation:null,boxSelectStartLocation:null,boxSelectElement:void 0,boxSelecting:!1,canBoxSelect:!1,dragMoving:!1,canDragMove:!1,initiallySelectedFeatureIds:f.featureIds||[]};return this.setSelected(D.initiallySelectedFeatureIds.filter(function(W){return b.getFeature(W)!==void 0})),this.fireActionable(),this.setActionableState({combineFeatures:!0,uncombineFeatures:!0,trash:!0}),D},fireUpdate:function(){this.map.fire($t.UPDATE,{action:di.MOVE,features:this.getSelected().map(function(f){return f.toGeoJSON()})})},fireActionable:function(){var f=this,b=this.getSelected(),D=b.filter(function(ke){return f.isInstanceOf("MultiFeature",ke)}),W=!1;if(b.length>1){W=!0;var te=b[0].type.replace("Multi","");b.forEach(function(ke){ke.type.replace("Multi","")!==te&&(W=!1)})}var ie=D.length>0,ue=b.length>0;this.setActionableState({combineFeatures:W,uncombineFeatures:ie,trash:ue})},getUniqueIds:function(f){return f.length?f.map(function(b){return b.properties.id}).filter(function(b){return b!==void 0}).reduce(function(b,D){return b.add(D),b},new xi).values():[]},stopExtendedInteractions:function(f){f.boxSelectElement&&(f.boxSelectElement.parentNode&&f.boxSelectElement.parentNode.removeChild(f.boxSelectElement),f.boxSelectElement=null),this.map.dragPan.enable(),f.boxSelecting=!1,f.canBoxSelect=!1,f.dragMoving=!1,f.canDragMove=!1},onStop:function(){G.enable(this)},onMouseMove:function(f,b){return ze(b)&&f.dragMoving&&this.fireUpdate(),this.stopExtendedInteractions(f),!0},onMouseOut:function(f){return!f.dragMoving||this.fireUpdate()}};Bi.onTap=Bi.onClick=function(f,b){return jr(b)?this.clickAnywhere(f,b):Kr(Mt.VERTEX)(b)?this.clickOnVertex(f,b):ze(b)?this.clickOnFeature(f,b):void 0},Bi.clickAnywhere=function(f){var b=this,D=this.getSelectedIds();D.length&&(this.clearSelectedFeatures(),D.forEach(function(W){return b.doRender(W)})),G.enable(this),this.stopExtendedInteractions(f)},Bi.clickOnVertex=function(f,b){this.changeMode(it.DIRECT_SELECT,{featureId:b.featureTarget.properties.parent,coordPath:b.featureTarget.properties.coord_path,startPos:b.lngLat}),this.updateUIClasses({mouse:We.MOVE})},Bi.startOnActiveFeature=function(f,b){this.stopExtendedInteractions(f),this.map.dragPan.disable(),this.doRender(b.featureTarget.properties.id),f.canDragMove=!0,f.dragMoveLocation=b.lngLat},Bi.clickOnFeature=function(f,b){var D=this;G.disable(this),this.stopExtendedInteractions(f);var W=Wi(b),te=this.getSelectedIds(),ie=b.featureTarget.properties.id,ue=this.isSelected(ie);if(!W&&ue&&this.getFeature(ie).type!==De.POINT)return this.changeMode(it.DIRECT_SELECT,{featureId:ie});ue&&W?(this.deselect(ie),this.updateUIClasses({mouse:We.POINTER}),te.length===1&&G.enable(this)):!ue&&W?(this.select(ie),this.updateUIClasses({mouse:We.MOVE})):ue||W||(te.forEach(function(ke){return D.doRender(ke)}),this.setSelected(ie),this.updateUIClasses({mouse:We.MOVE})),this.doRender(ie)},Bi.onMouseDown=function(f,b){return Fi(b)?this.startOnActiveFeature(f,b):this.drawConfig.boxSelect&&Ur(b)?this.startBoxSelect(f,b):void 0},Bi.startBoxSelect=function(f,b){this.stopExtendedInteractions(f),this.map.dragPan.disable(),f.boxSelectStartLocation=Yr(b.originalEvent,this.map.getContainer()),f.canBoxSelect=!0},Bi.onTouchStart=function(f,b){if(Fi(b))return this.startOnActiveFeature(f,b)},Bi.onDrag=function(f,b){return f.canDragMove?this.dragMove(f,b):this.drawConfig.boxSelect&&f.canBoxSelect?this.whileBoxSelect(f,b):void 0},Bi.whileBoxSelect=function(f,b){f.boxSelecting=!0,this.updateUIClasses({mouse:We.ADD}),f.boxSelectElement||(f.boxSelectElement=document.createElement("div"),f.boxSelectElement.classList.add(ce.BOX_SELECT),this.map.getContainer().appendChild(f.boxSelectElement));var D=Yr(b.originalEvent,this.map.getContainer()),W=Math.min(f.boxSelectStartLocation.x,D.x),te=Math.max(f.boxSelectStartLocation.x,D.x),ie=Math.min(f.boxSelectStartLocation.y,D.y),ue=Math.max(f.boxSelectStartLocation.y,D.y),ke="translate("+W+"px, "+ie+"px)";f.boxSelectElement.style.transform=ke,f.boxSelectElement.style.WebkitTransform=ke,f.boxSelectElement.style.width=te-W+"px",f.boxSelectElement.style.height=ue-ie+"px"},Bi.dragMove=function(f,b){f.dragMoving=!0,b.originalEvent.stopPropagation();var D={lng:b.lngLat.lng-f.dragMoveLocation.lng,lat:b.lngLat.lat-f.dragMoveLocation.lat};qo(this.getSelected(),D),f.dragMoveLocation=b.lngLat},Bi.onTouchEnd=Bi.onMouseUp=function(f,b){var D=this;if(f.dragMoving)this.fireUpdate();else if(f.boxSelecting){var W=[f.boxSelectStartLocation,Yr(b.originalEvent,this.map.getContainer())],te=this.featuresAt(null,W,"click"),ie=this.getUniqueIds(te).filter(function(ue){return!D.isSelected(ue)});ie.length&&(this.select(ie),ie.forEach(function(ue){return D.doRender(ue)}),this.updateUIClasses({mouse:We.MOVE}))}this.stopExtendedInteractions(f)},Bi.toDisplayFeatures=function(f,b,D){b.properties.active=this.isSelected(b.properties.id)?xt.ACTIVE:xt.INACTIVE,D(b),this.fireActionable(),b.properties.active===xt.ACTIVE&&b.geometry.type!==De.POINT&&Pi(b).forEach(D)},Bi.onTrash=function(){this.deleteFeature(this.getSelectedIds()),this.fireActionable()},Bi.onCombineFeatures=function(){var f=this.getSelected();if(!(f.length===0||f.length<2)){for(var b=[],D=[],W=f[0].type.replace("Multi",""),te=0;te1){var ue=this.newFeature({type:De.FEATURE,properties:D[0].properties,geometry:{type:"Multi"+W,coordinates:b}});this.addFeature(ue),this.deleteFeature(this.getSelectedIds(),{silent:!0}),this.setSelected([ue.id]),this.map.fire($t.COMBINE_FEATURES,{createdFeatures:[ue.toGeoJSON()],deletedFeatures:D})}this.fireActionable()}},Bi.onUncombineFeatures=function(){var f=this,b=this.getSelected();if(b.length!==0){for(var D=[],W=[],te=function(ue){var ke=b[ue];f.isInstanceOf("MultiFeature",ke)&&(ke.getFeatures().forEach(function(Be){f.addFeature(Be),Be.properties=ke.properties,D.push(Be.toGeoJSON()),f.select([Be.id])}),f.deleteFeature(ke.id,{silent:!0}),W.push(ke.toGeoJSON()))},ie=0;ie1&&this.map.fire($t.UNCOMBINE_FEATURES,{createdFeatures:D,deletedFeatures:W}),this.fireActionable()}};var Rr=Kr(Mt.VERTEX),Cr=Kr(Mt.MIDPOINT),en={fireUpdate:function(){this.map.fire($t.UPDATE,{action:di.CHANGE_COORDINATES,features:this.getSelected().map(function(f){return f.toGeoJSON()})})},fireActionable:function(f){this.setActionableState({combineFeatures:!1,uncombineFeatures:!1,trash:f.selectedCoordPaths.length>0})},startDragging:function(f,b){this.map.dragPan.disable(),f.canDragMove=!0,f.dragMoveLocation=b.lngLat},stopDragging:function(f){this.map.dragPan.enable(),f.dragMoving=!1,f.canDragMove=!1,f.dragMoveLocation=null},onVertex:function(f,b){this.startDragging(f,b);var D=b.featureTarget.properties,W=f.selectedCoordPaths.indexOf(D.coord_path);Wi(b)||W!==-1?Wi(b)&&W===-1&&f.selectedCoordPaths.push(D.coord_path):f.selectedCoordPaths=[D.coord_path];var te=this.pathsToCoordinates(f.featureId,f.selectedCoordPaths);this.setSelectedCoordinates(te)},onMidpoint:function(f,b){this.startDragging(f,b);var D=b.featureTarget.properties;f.feature.addCoordinate(D.coord_path,D.lng,D.lat),this.fireUpdate(),f.selectedCoordPaths=[D.coord_path]},pathsToCoordinates:function(f,b){return b.map(function(D){return{feature_id:f,coord_path:D}})},onFeature:function(f,b){f.selectedCoordPaths.length===0?this.startDragging(f,b):this.stopDragging(f)},dragFeature:function(f,b,D){qo(this.getSelected(),D),f.dragMoveLocation=b.lngLat},dragVertex:function(f,b,D){for(var W=f.selectedCoordPaths.map(function(ke){return f.feature.getCoordinate(ke)}),te=Jt(W.map(function(ke){return{type:De.FEATURE,properties:{},geometry:{type:De.POINT,coordinates:ke}}}),D),ie=0;ie0?this.dragVertex(f,b,D):this.dragFeature(f,b,D),f.dragMoveLocation=b.lngLat}},en.onClick=function(f,b){return jr(b)?this.clickNoTarget(f,b):Fi(b)?this.clickActiveFeature(f,b):jn(b)?this.clickInactive(f,b):void this.stopDragging(f)},en.onTap=function(f,b){return jr(b)?this.clickNoTarget(f,b):Fi(b)?this.clickActiveFeature(f,b):jn(b)?this.clickInactive(f,b):void 0},en.onTouchEnd=en.onMouseUp=function(f){f.dragMoving&&this.fireUpdate(),this.stopDragging(f)};var Oi={};function Mr(f,b){return!!f.lngLat&&f.lngLat.lng===b[0]&&f.lngLat.lat===b[1]}Oi.onSetup=function(){var f=this.newFeature({type:De.FEATURE,properties:{},geometry:{type:De.POINT,coordinates:[]}});return this.addFeature(f),this.clearSelectedFeatures(),this.updateUIClasses({mouse:We.ADD}),this.activateUIButton(et.POINT),this.setActionableState({trash:!0}),{point:f}},Oi.stopDrawingAndRemove=function(f){this.deleteFeature([f.point.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT)},Oi.onTap=Oi.onClick=function(f,b){this.updateUIClasses({mouse:We.MOVE}),f.point.updateCoordinate("",b.lngLat.lng,b.lngLat.lat),this.map.fire($t.CREATE,{features:[f.point.toGeoJSON()]}),this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.point.id]})},Oi.onStop=function(f){this.activateUIButton(),f.point.getCoordinate().length||this.deleteFeature([f.point.id],{silent:!0})},Oi.toDisplayFeatures=function(f,b,D){var W=b.properties.id===f.point.id;if(b.properties.active=W?xt.ACTIVE:xt.INACTIVE,!W)return D(b)},Oi.onTrash=Oi.stopDrawingAndRemove,Oi.onKeyUp=function(f,b){if(pn(b)||Xi(b))return this.stopDrawingAndRemove(f,b)};var tn={onSetup:function(){var f=this.newFeature({type:De.FEATURE,properties:{},geometry:{type:De.POLYGON,coordinates:[[]]}});return this.addFeature(f),this.clearSelectedFeatures(),G.disable(this),this.updateUIClasses({mouse:We.ADD}),this.activateUIButton(et.POLYGON),this.setActionableState({trash:!0}),{polygon:f,currentVertexPosition:0}},clickAnywhere:function(f,b){if(f.currentVertexPosition>0&&Mr(b,f.polygon.coordinates[0][f.currentVertexPosition-1]))return this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.polygon.id]});this.updateUIClasses({mouse:We.ADD}),f.polygon.updateCoordinate("0."+f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat),f.currentVertexPosition++,f.polygon.updateCoordinate("0."+f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat)},clickOnVertex:function(f){return this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.polygon.id]})},onMouseMove:function(f,b){f.polygon.updateCoordinate("0."+f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat),ar(b)&&this.updateUIClasses({mouse:We.POINTER})}};tn.onTap=tn.onClick=function(f,b){return ar(b)?this.clickOnVertex(f,b):this.clickAnywhere(f,b)},tn.onKeyUp=function(f,b){pn(b)?(this.deleteFeature([f.polygon.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT)):Xi(b)&&this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.polygon.id]})},tn.onStop=function(f){this.updateUIClasses({mouse:We.NONE}),G.enable(this),this.activateUIButton(),this.getFeature(f.polygon.id)!==void 0&&(f.polygon.removeCoordinate("0."+f.currentVertexPosition),f.polygon.isValid()?this.map.fire($t.CREATE,{features:[f.polygon.toGeoJSON()]}):(this.deleteFeature([f.polygon.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT,{},{silent:!0})))},tn.toDisplayFeatures=function(f,b,D){var W=b.properties.id===f.polygon.id;if(b.properties.active=W?xt.ACTIVE:xt.INACTIVE,!W)return D(b);if(b.geometry.coordinates.length!==0){var te=b.geometry.coordinates[0].length;if(!(te<3)){if(b.properties.meta=Mt.FEATURE,D(mt(f.polygon.id,b.geometry.coordinates[0][0],"0.0",!1)),te>3){var ie=b.geometry.coordinates[0].length-3;D(mt(f.polygon.id,b.geometry.coordinates[0][ie],"0."+ie,!1))}if(te<=4){var ue=[[b.geometry.coordinates[0][0][0],b.geometry.coordinates[0][0][1]],[b.geometry.coordinates[0][1][0],b.geometry.coordinates[0][1][1]]];if(D({type:De.FEATURE,properties:b.properties,geometry:{coordinates:ue,type:De.LINE_STRING}}),te===3)return}return D(b)}}},tn.onTrash=function(f){this.deleteFeature([f.polygon.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT)};var Mn={onSetup:function(f){var b,D,W=(f=f||{}).featureId,te="forward";if(W){if(!(b=this.getFeature(W)))throw new Error("Could not find a feature with the provided featureId");var ie=f.from;if(ie&&ie.type==="Feature"&&ie.geometry&&ie.geometry.type==="Point"&&(ie=ie.geometry),ie&&ie.type==="Point"&&ie.coordinates&&ie.coordinates.length===2&&(ie=ie.coordinates),!ie||!Array.isArray(ie))throw new Error("Please use the `from` property to indicate which point to continue the line from");var ue=b.coordinates.length-1;if(b.coordinates[ue][0]===ie[0]&&b.coordinates[ue][1]===ie[1])D=ue+1,b.addCoordinate.apply(b,[D].concat(b.coordinates[ue]));else{if(b.coordinates[0][0]!==ie[0]||b.coordinates[0][1]!==ie[1])throw new Error("`from` should match the point at either the start or the end of the provided LineString");te="backwards",D=0,b.addCoordinate.apply(b,[D].concat(b.coordinates[0]))}}else b=this.newFeature({type:De.FEATURE,properties:{},geometry:{type:De.LINE_STRING,coordinates:[]}}),D=0,this.addFeature(b);return this.clearSelectedFeatures(),G.disable(this),this.updateUIClasses({mouse:We.ADD}),this.activateUIButton(et.LINE),this.setActionableState({trash:!0}),{line:b,currentVertexPosition:D,direction:te}},clickAnywhere:function(f,b){if(f.currentVertexPosition>0&&Mr(b,f.line.coordinates[f.currentVertexPosition-1])||f.direction==="backwards"&&Mr(b,f.line.coordinates[f.currentVertexPosition+1]))return this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.line.id]});this.updateUIClasses({mouse:We.ADD}),f.line.updateCoordinate(f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat),f.direction==="forward"?(f.currentVertexPosition++,f.line.updateCoordinate(f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat)):f.line.addCoordinate(0,b.lngLat.lng,b.lngLat.lat)},clickOnVertex:function(f){return this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.line.id]})},onMouseMove:function(f,b){f.line.updateCoordinate(f.currentVertexPosition,b.lngLat.lng,b.lngLat.lat),ar(b)&&this.updateUIClasses({mouse:We.POINTER})}};Mn.onTap=Mn.onClick=function(f,b){if(ar(b))return this.clickOnVertex(f,b);this.clickAnywhere(f,b)},Mn.onKeyUp=function(f,b){Xi(b)?this.changeMode(it.SIMPLE_SELECT,{featureIds:[f.line.id]}):pn(b)&&(this.deleteFeature([f.line.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT))},Mn.onStop=function(f){G.enable(this),this.activateUIButton(),this.getFeature(f.line.id)!==void 0&&(f.line.removeCoordinate(""+f.currentVertexPosition),f.line.isValid()?this.map.fire($t.CREATE,{features:[f.line.toGeoJSON()]}):(this.deleteFeature([f.line.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT,{},{silent:!0})))},Mn.onTrash=function(f){this.deleteFeature([f.line.id],{silent:!0}),this.changeMode(it.SIMPLE_SELECT)},Mn.toDisplayFeatures=function(f,b,D){var W=b.properties.id===f.line.id;if(b.properties.active=W?xt.ACTIVE:xt.INACTIVE,!W)return D(b);b.geometry.coordinates.length<2||(b.properties.meta=Mt.FEATURE,D(mt(f.line.id,b.geometry.coordinates[f.direction==="forward"?b.geometry.coordinates.length-2:1],""+(f.direction==="forward"?b.geometry.coordinates.length-2:1),!1)),D(b))};var Ni={simple_select:Bi,direct_select:en,draw_point:Oi,draw_polygon:tn,draw_line_string:Mn},Ho={defaultMode:it.SIMPLE_SELECT,keybindings:!0,touchEnabled:!0,clickBuffer:2,touchBuffer:25,boxSelect:!0,displayControlsDefault:!0,styles:Cn,modes:Ni,controls:{},userProperties:!1},no={point:!0,line_string:!0,polygon:!0,trash:!0,combine_features:!0,uncombine_features:!0},mi={point:!1,line_string:!1,polygon:!1,trash:!1,combine_features:!1,uncombine_features:!1};function Wo(f,b){return f.map(function(D){return D.source?D:ft(D,{id:D.id+"."+b,source:b==="hot"?oe.HOT:oe.COLD})})}var Ar={exports:{}};(function(f,b){var D="__lodash_hash_undefined__",W=9007199254740991,te="[object Arguments]",ie="[object Array]",ue="[object Boolean]",ke="[object Date]",Be="[object Error]",Xe="[object Function]",Je="[object Map]",Ve="[object Number]",wt="[object Object]",gi="[object Promise]",It="[object RegExp]",Vi="[object Set]",Ee="[object String]",rt="[object Symbol]",zt="[object WeakMap]",ki="[object ArrayBuffer]",Ti="[object DataView]",yo=/^\[object .+?Constructor\]$/,Ko=/^(?:0|[1-9]\d*)$/,ei={};ei["[object Float32Array]"]=ei["[object Float64Array]"]=ei["[object Int8Array]"]=ei["[object Int16Array]"]=ei["[object Int32Array]"]=ei["[object Uint8Array]"]=ei["[object Uint8ClampedArray]"]=ei["[object Uint16Array]"]=ei["[object Uint32Array]"]=!0,ei[te]=ei[ie]=ei[ki]=ei[ue]=ei[Ti]=ei[ke]=ei[Be]=ei[Xe]=ei[Je]=ei[Ve]=ei[wt]=ei[It]=ei[Vi]=ei[Ee]=ei[zt]=!1;var Lo=typeof to=="object"&&to&&to.Object===Object&&to,Ga=typeof self=="object"&&self&&self.Object===Object&&self,Gn=Lo||Ga||Function("return this")(),Us=b&&!b.nodeType&&b,ga=Us&&f&&!f.nodeType&&f,oo=ga&&ga.exports===Us,zo=oo&&Lo.process,wr=function(){try{return zo&&zo.binding&&zo.binding("util")}catch{}}(),lr=wr&&wr.isTypedArray;function Ht(he,_e){for(var je=-1,ct=he==null?0:he.length;++jeLi))return!1;var hi=Ft.get(he);if(hi&&Ft.get(_e))return hi==_e;var qi=-1,gn=!0,kn=2&je?new Ro:void 0;for(Ft.set(he,_e),Ft.set(_e,he);++qi-1},Hn.prototype.set=function(he,_e){var je=this.__data__,ct=Pn(je,he);return ct<0?(++this.size,je.push([he,_e])):je[ct][1]=_e,this},At.prototype.clear=function(){this.size=0,this.__data__={hash:new oi,map:new(vo||Hn),string:new oi}},At.prototype.delete=function(he){var _e=bo(this,he).delete(he);return this.size-=_e?1:0,_e},At.prototype.get=function(he){return bo(this,he).get(he)},At.prototype.has=function(he){return bo(this,he).has(he)},At.prototype.set=function(he,_e){var je=bo(this,he),ct=je.size;return je.set(he,_e),this.size+=je.size==ct?0:1,this},Ro.prototype.add=Ro.prototype.push=function(he){return this.__data__.set(he,D),this},Ro.prototype.has=function(he){return this.__data__.has(he)},Wt.prototype.clear=function(){this.__data__=new Hn,this.size=0},Wt.prototype.delete=function(he){var _e=this.__data__,je=_e.delete(he);return this.size=_e.size,je},Wt.prototype.get=function(he){return this.__data__.get(he)},Wt.prototype.has=function(he){return this.__data__.has(he)},Wt.prototype.set=function(he,_e){var je=this.__data__;if(je instanceof Hn){var ct=je.__data__;if(!vo||ct.length<199)return ct.push([he,_e]),this.size=++je.size,this;je=this.__data__=new At(ct)}return je.set(he,_e),this.size=je.size,this};var Ms=bs?function(he){return he==null?[]:(he=Object(he),function(_e,je){for(var ct=-1,si=_e==null?0:_e.length,Ft=0,_i=[];++ct-1&&he%1==0&&he<_e}function lo(he){if(he!=null){try{return Gs.call(he)}catch{}try{return he+""}catch{}}return""}function Js(he,_e){return he===_e||he!=he&&_e!=_e}(ws&&mn(new ws(new ArrayBuffer(1)))!=Ti||vo&&mn(new vo)!=Je||qn&&mn(qn.resolve())!=gi||Is&&mn(new Is)!=Vi||so&&mn(new so)!=zt)&&(mn=function(he){var _e=ao(he),je=_e==wt?he.constructor:void 0,ct=je?lo(je):"";if(ct)switch(ct){case wa:return Ti;case Zs:return Je;case Ut:return gi;case Ss:return Vi;case qa:return zt}return _e});var As=Ts(function(){return arguments}())?Ts:function(he){return Ki(he)&&Pr.call(he,"callee")&&!vs.call(he,"callee")},Fo=Array.isArray,Ks=Do||function(){return!1};function Ys(he){if(!Wn(he))return!1;var _e=ao(he);return _e==Xe||_e=="[object GeneratorFunction]"||_e=="[object AsyncFunction]"||_e=="[object Proxy]"}function yi(he){return typeof he=="number"&&he>-1&&he%1==0&&he<=W}function Wn(he){var _e=typeof he;return he!=null&&(_e=="object"||_e=="function")}function Ki(he){return he!=null&&typeof he=="object"}var Ps=lr?function(he){return function(_e){return he(_e)}}(lr):function(he){return Ki(he)&&yi(he.length)&&!!ei[ao(he)]};function ks(he){return(_e=he)!=null&&yi(_e.length)&&!Ys(_e)?ri(he):Cs(he);var _e}f.exports=function(he,_e){return Hs(he,_e)}})(Ar,Ar.exports);var Xo=L(Ar.exports);function fn(f,b){return f.length===b.length&&JSON.stringify(f.map(function(D){return D}).sort())===JSON.stringify(b.map(function(D){return D}).sort())}var Jo={Polygon:wi,LineString:bi,Point:Sr,MultiPolygon:Ii,MultiLineString:Ii,MultiPoint:Ii},Qt=Object.freeze({__proto__:null,CommonSelectors:Ue,constrainFeatureMovement:Jt,createMidPoint:ro,createSupplementaryPoints:Pi,createVertex:mt,doubleClickZoom:G,euclideanDistance:br,featuresAt:fi,getFeatureAtAndSetCursors:xr,isClick:hn,isEventAtCoordinates:Mr,isTap:Dr,mapEventToBoundingBox:St,ModeHandler:I,moveFeatures:qo,sortFeatures:Zt,stringSetsAreEqual:fn,StringSet:xi,theme:Cn,toDenseArray:Yt}),ds=function(f,b){var D={options:f=function(te){te===void 0&&(te={});var ie=ft(te);return te.controls||(ie.controls={}),te.displayControlsDefault===!1?ie.controls=ft(mi,te.controls):ie.controls=ft(no,te.controls),(ie=ft(Ho,ie)).styles=Wo(ie.styles,"cold").concat(Wo(ie.styles,"hot")),ie}(f)};b=function(te,ie){return ie.modes=it,ie.getFeatureIdsAt=function(ue){return fi.click({point:ue},null,te).map(function(ke){return ke.properties.id})},ie.getSelectedIds=function(){return te.store.getSelectedIds()},ie.getSelected=function(){return{type:De.FEATURE_COLLECTION,features:te.store.getSelectedIds().map(function(ue){return te.store.get(ue)}).map(function(ue){return ue.toGeoJSON()})}},ie.getSelectedPoints=function(){return{type:De.FEATURE_COLLECTION,features:te.store.getSelectedCoordinates().map(function(ue){return{type:De.FEATURE,properties:{},geometry:{type:De.POINT,coordinates:ue.coordinates}}})}},ie.set=function(ue){if(ue.type===void 0||ue.type!==De.FEATURE_COLLECTION||!Array.isArray(ue.features))throw new Error("Invalid FeatureCollection");var ke=te.store.createRenderBatch(),Be=te.store.getAllIds().slice(),Xe=ie.add(ue),Je=new xi(Xe);return(Be=Be.filter(function(Ve){return!Je.has(Ve)})).length&&ie.delete(Be),ke(),Xe},ie.add=function(ue){var ke=JSON.parse(JSON.stringify(j(ue))).features.map(function(Be){if(Be.id=Be.id||Ai(),Be.geometry===null)throw new Error("Invalid geometry: null");if(te.store.get(Be.id)===void 0||te.store.get(Be.id).type!==Be.geometry.type){var Xe=Jo[Be.geometry.type];if(Xe===void 0)throw new Error("Invalid geometry type: "+Be.geometry.type+".");var Je=new Xe(te,Be);te.store.add(Je)}else{var Ve=te.store.get(Be.id);Ve.properties=Be.properties,Xo(Ve.properties,Be.properties)||te.store.featureChanged(Ve.id),Xo(Ve.getCoordinates(),Be.geometry.coordinates)||Ve.incomingCoords(Be.geometry.coordinates)}return Be.id});return te.store.render(),ke},ie.get=function(ue){var ke=te.store.get(ue);if(ke)return ke.toGeoJSON()},ie.getAll=function(){return{type:De.FEATURE_COLLECTION,features:te.store.getAll().map(function(ue){return ue.toGeoJSON()})}},ie.delete=function(ue){return te.store.delete(ue,{silent:!0}),ie.getMode()!==it.DIRECT_SELECT||te.store.getSelectedIds().length?te.store.render():te.events.changeMode(it.SIMPLE_SELECT,void 0,{silent:!0}),ie},ie.deleteAll=function(){return te.store.delete(te.store.getAllIds(),{silent:!0}),ie.getMode()===it.DIRECT_SELECT?te.events.changeMode(it.SIMPLE_SELECT,void 0,{silent:!0}):te.store.render(),ie},ie.changeMode=function(ue,ke){return ke===void 0&&(ke={}),ue===it.SIMPLE_SELECT&&ie.getMode()===it.SIMPLE_SELECT?(fn(ke.featureIds||[],te.store.getSelectedIds())||(te.store.setSelected(ke.featureIds,{silent:!0}),te.store.render()),ie):(ue===it.DIRECT_SELECT&&ie.getMode()===it.DIRECT_SELECT&&ke.featureId===te.store.getSelectedIds()[0]||te.events.changeMode(ue,ke,{silent:!0}),ie)},ie.getMode=function(){return te.events.getMode()},ie.trash=function(){return te.events.trash({silent:!0}),ie},ie.combineFeatures=function(){return te.events.combineFeatures({silent:!0}),ie},ie.uncombineFeatures=function(){return te.events.uncombineFeatures({silent:!0}),ie},ie.setFeatureProperty=function(ue,ke,Be){return te.store.setFeatureProperty(ue,ke,Be),ie},ie}(D,b),D.api=b;var W=Un(D);return b.onAdd=W.onAdd,b.onRemove=W.onRemove,b.types=et,b.options=f,b};function $n(f){ds(f,this)}return $n.modes=Ni,$n.constants=li,$n.lib=Qt,$n})})(eu);var Hh=eu.exports;const pa=qh(Hh);var tu={exports:{}};/** * MapLibre GL JS * @license 3-Clause BSD. Full text of license: https://github.com/maplibre/maplibre-gl-js/blob/v4.1.3/LICENSE.txt */(function(Q,w){(function(I,L){Q.exports=L()})(to,function(){var I={},L={};function U(M,d,Se){if(L[M]=Se,M==="index"){var Re="var sharedModule = {}; ("+L.shared+")(sharedModule); ("+L.worker+")(sharedModule);",He={};return L.shared(He),L.index(I,He),typeof window<"u"&&I.setWorkerUrl(window.URL.createObjectURL(new Blob([Re],{type:"text/javascript"}))),I}}U("shared",["exports"],function(M){function d(i,e,r,o){return new(r||(r=Promise))(function(l,h){function p(x){try{_(o.next(x))}catch(T){h(T)}}function m(x){try{_(o.throw(x))}catch(T){h(T)}}function _(x){var T;x.done?l(x.value):(T=x.value,T instanceof r?T:new r(function(E){E(T)})).then(p,m)}_((o=o.apply(i,e||[])).next())})}function Se(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}typeof SuppressedError=="function"&&SuppressedError;var Re=He;function He(i,e){this.x=i,this.y=e}He.prototype={clone:function(){return new He(this.x,this.y)},add:function(i){return this.clone()._add(i)},sub:function(i){return this.clone()._sub(i)},multByPoint:function(i){return this.clone()._multByPoint(i)},divByPoint:function(i){return this.clone()._divByPoint(i)},mult:function(i){return this.clone()._mult(i)},div:function(i){return this.clone()._div(i)},rotate:function(i){return this.clone()._rotate(i)},rotateAround:function(i,e){return this.clone()._rotateAround(i,e)},matMult:function(i){return this.clone()._matMult(i)},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(i){return this.x===i.x&&this.y===i.y},dist:function(i){return Math.sqrt(this.distSqr(i))},distSqr:function(i){var e=i.x-this.x,r=i.y-this.y;return e*e+r*r},angle:function(){return Math.atan2(this.y,this.x)},angleTo:function(i){return Math.atan2(this.y-i.y,this.x-i.x)},angleWith:function(i){return this.angleWithSep(i.x,i.y)},angleWithSep:function(i,e){return Math.atan2(this.x*e-this.y*i,this.x*i+this.y*e)},_matMult:function(i){var e=i[2]*this.x+i[3]*this.y;return this.x=i[0]*this.x+i[1]*this.y,this.y=e,this},_add:function(i){return this.x+=i.x,this.y+=i.y,this},_sub:function(i){return this.x-=i.x,this.y-=i.y,this},_mult:function(i){return this.x*=i,this.y*=i,this},_div:function(i){return this.x/=i,this.y/=i,this},_multByPoint:function(i){return this.x*=i.x,this.y*=i.y,this},_divByPoint:function(i){return this.x/=i.x,this.y/=i.y,this},_unit:function(){return this._div(this.mag()),this},_perp:function(){var i=this.y;return this.y=this.x,this.x=-i,this},_rotate:function(i){var e=Math.cos(i),r=Math.sin(i),o=r*this.x+e*this.y;return this.x=e*this.x-r*this.y,this.y=o,this},_rotateAround:function(i,e){var r=Math.cos(i),o=Math.sin(i),l=e.y+o*(this.x-e.x)+r*(this.y-e.y);return this.x=e.x+r*(this.x-e.x)-o*(this.y-e.y),this.y=l,this},_round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}},He.convert=function(i){return i instanceof He?i:Array.isArray(i)?new He(i[0],i[1]):i};var ce=Se(Re),oe=We;function We(i,e,r,o){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(o-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=o}We.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,o=0;o<8;o++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?p=r:m=r,r=.5*(m-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var et=Se(oe);let De,it;function $t(){return De==null&&(De=typeof OffscreenCanvas<"u"&&new OffscreenCanvas(1,1).getContext("2d")&&typeof createImageBitmap=="function"),De}function di(){if(it==null&&(it=!1,$t())){const e=new OffscreenCanvas(5,5).getContext("2d",{willReadFrequently:!0});if(e){for(let o=0;o<5*5;o++){const l=4*o;e.fillStyle=`rgb(${l},${l+1},${l+2})`,e.fillRect(o%5,Math.floor(o/5),1,1)}const r=e.getImageData(0,0,5,5).data;for(let o=0;o<5*5*4;o++)if(o%4!=3&&r[o]!==o){it=!0;break}}}return it||!1}function Mt(i,e,r,o){const l=new et(i,e,r,o);return function(h){return l.solve(h)}}const xt=Mt(.25,.1,.25,1);function Gt(i,e,r){return Math.min(r,Math.max(e,i))}function ti(i,e,r){const o=r-e,l=((i-e)%o+o)%o+e;return l===e?r:l}function li(i,...e){for(const r of e)for(const o in r)i[o]=r[o];return i}let kt=1;function Bt(i,e,r){const o={};for(const l in i)o[l]=e.call(r||this,i[l],l,i);return o}function Zt(i,e,r){const o={};for(const l in i)e.call(r||this,i[l],l,i)&&(o[l]=i[l]);return o}function St(i){return Array.isArray(i)?i.map(St):typeof i=="object"&&i?Bt(i,St):i}const xi={};function pi(i){xi[i]||(typeof console<"u"&&console.warn(i),xi[i]=!0)}function fi(i,e,r){return(r.y-i.y)*(e.x-i.x)>(e.y-i.y)*(r.x-i.x)}function Nn(i){let e=0;for(let r,o,l=0,h=i.length,p=h-1;l"u")throw new Error("VideoFrame not supported");const h=new VideoFrame(i,{timestamp:0});try{const p=h==null?void 0:h.format;if(!p||!p.startsWith("BGR")&&!p.startsWith("RGB"))throw new Error(`Unrecognized format ${p}`);const m=p.startsWith("BGR"),_=new Uint8ClampedArray(o*l*4);if(yield h.copyTo(_,function(x,T,E,k,R){const B=4*Math.max(-T,0),V=(Math.max(0,E)-E)*k*4+B,q=4*k,J=Math.max(0,T),pe=Math.max(0,E);return{rect:{x:J,y:pe,width:Math.min(x.width,T+k)-J,height:Math.min(x.height,E+R)-pe},layout:[{offset:V,stride:q}]}}(i,e,r,o,l)),m)for(let x=0;x<_.length;x+=4){const T=_[x];_[x]=_[x+2],_[x+2]=T}return _}finally{h.close()}})}let $i,Ai;const ii="AbortError";function Sr(){return new Error(ii)}const bi={MAX_PARALLEL_IMAGE_REQUESTS:16,MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:8,MAX_TILE_CACHE_ZOOM_LEVELS:5,REGISTERED_PROTOCOLS:{},WORKER_URL:""};function wi(i){return bi.REGISTERED_PROTOCOLS[i.substring(0,i.indexOf("://"))]}const or="global-dispatcher";class sr extends Error{constructor(e,r,o,l){super(`AJAXError: ${r} (${e}): ${o}`),this.status=e,this.statusText=r,this.url=o,this.body=l}}const Ii=()=>xr(self)?self.worker&&self.worker.referrer:(window.location.protocol==="blob:"?window.parent:window).location.href,bt=function(i,e){if(/:\/\//.test(i.url)&&!/^https?:|^file:/.test(i.url)){const o=wi(i.url);if(o)return o(i,e);if(xr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,targetMapId:or},e)}if(!(/^file:/.test(r=i.url)||/^file:/.test(Ii())&&!/^\w+:/.test(r))){if(fetch&&Request&&AbortController&&Object.prototype.hasOwnProperty.call(Request.prototype,"signal"))return function(o,l){return d(this,void 0,void 0,function*(){const h=new Request(o.url,{method:o.method||"GET",body:o.body,credentials:o.credentials,headers:o.headers,cache:o.cache,referrer:Ii(),signal:l.signal});o.type==="json"&&h.headers.set("Accept","application/json");const p=yield fetch(h);if(!p.ok){const x=yield p.blob();throw new sr(p.status,p.statusText,o.url,x)}let m;m=o.type==="arrayBuffer"||o.type==="image"?p.arrayBuffer():o.type==="json"?p.json():p.text();const _=yield m;if(l.signal.aborted)throw Sr();return{data:_,cacheControl:p.headers.get("Cache-Control"),expires:p.headers.get("Expires")}})}(i,e);if(xr(self)&&self.worker&&self.worker.actor)return self.worker.actor.sendAsync({type:"GR",data:i,mustQueue:!0,targetMapId:or},e)}var r;return function(o,l){return new Promise((h,p)=>{const m=new XMLHttpRequest;m.open(o.method||"GET",o.url,!0),o.type!=="arrayBuffer"&&o.type!=="image"||(m.responseType="arraybuffer");for(const _ in o.headers)m.setRequestHeader(_,o.headers[_]);o.type==="json"&&(m.responseType="text",m.setRequestHeader("Accept","application/json")),m.withCredentials=o.credentials==="include",m.onerror=()=>{p(new Error(m.statusText))},m.onload=()=>{if(!l.signal.aborted)if((m.status>=200&&m.status<300||m.status===0)&&m.response!==null){let _=m.response;if(o.type==="json")try{_=JSON.parse(m.response)}catch(x){return void p(x)}h({data:_,cacheControl:m.getResponseHeader("Cache-Control"),expires:m.getResponseHeader("Expires")})}else{const _=new Blob([m.response],{type:m.getResponseHeader("Content-Type")});p(new sr(m.status,m.statusText,o.url,_))}},l.signal.addEventListener("abort",()=>{m.abort(),p(Sr())}),m.send(o.body)})}(i,e)};function Vn(i){if(!i||i.indexOf("://")<=0||i.indexOf("data:image/")===0||i.indexOf("blob:")===0)return!0;const e=new URL(i),r=window.location;return e.protocol===r.protocol&&e.host===r.host}function Vr(i,e,r){r[i]&&r[i].indexOf(e)!==-1||(r[i]=r[i]||[],r[i].push(e))}function Xr(i,e,r){if(r&&r[i]){const o=r[i].indexOf(e);o!==-1&&r[i].splice(o,1)}}class Yt{constructor(e,r={}){li(this,r),this.type=e}}class Jr extends Yt{constructor(e,r={}){super("error",li({error:e},r))}}class Ot{on(e,r){return this._listeners=this._listeners||{},Vr(e,r,this._listeners),this}off(e,r){return Xr(e,r,this._listeners),Xr(e,r,this._oneTimeListeners),this}once(e,r){return r?(this._oneTimeListeners=this._oneTimeListeners||{},Vr(e,r,this._oneTimeListeners),this):new Promise(o=>this.once(e,o))}fire(e,r){typeof e=="string"&&(e=new Yt(e,r||{}));const o=e.type;if(this.listens(o)){e.target=this;const l=this._listeners&&this._listeners[o]?this._listeners[o].slice():[];for(const m of l)m.call(this,e);const h=this._oneTimeListeners&&this._oneTimeListeners[o]?this._oneTimeListeners[o].slice():[];for(const m of h)Xr(o,m,this._oneTimeListeners),m.call(this,e);const p=this._eventedParent;p&&(li(e,typeof this._eventedParentData=="function"?this._eventedParentData():this._eventedParentData),p.fire(e))}else e instanceof Jr&&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,r){return this._eventedParent=e,this._eventedParentData=r,this}}var be={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},sky:{type:"sky"},terrain:{type:"terrain"},sources:{required:!0,type:"sources"},sprite:{type:"sprite"},glyphs:{type:"string"},transition:{type:"transition"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{},custom:{}},default:"mapbox"},redFactor:{type:"number",default:1},blueFactor:{type:"number",default:1},greenFactor:{type:"number",default:1},baseShift:{type:"number",default:0},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{required:!0,type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image",{"!":"icon-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"padding",default:[2],units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},"viewport-glyph":{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-variable-anchor-offset":{type:"variableAnchorOffsetCollection",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field",{"!":"text-overlap"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-overlap":{type:"enum",values:{never:{},always:{},cooperative:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},sky:{"sky-color":{type:"color","property-type":"data-constant",default:"#88C6FC",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-color":{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fog-blend":{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:.8,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number",minimum:0,default:1}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!0,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"line-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"cross-faded-data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-dasharray"},{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"cross-faded"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"cross-faded":{type:"property-type"},"cross-faded-data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};const Tn=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function En(i,e){const r={};for(const o in i)o!=="ref"&&(r[o]=i[o]);return Tn.forEach(o=>{o in e&&(r[o]=e[o])}),r}function ft(i,e){if(Array.isArray(i)){if(!Array.isArray(e)||i.length!==e.length)return!1;for(let r=0;r`:i.itemType.kind==="value"?"array":`array<${e}>`}return i.kind}const re=[Xi,Ue,Tt,yt,Gi,Pi,Yr,O(mt),G,P,z];function ne(i,e){if(e.kind==="error")return null;if(i.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!ne(i.itemType,e.itemType))&&(typeof i.N!="number"||i.N===e.N))return null}else{if(i.kind===e.kind)return null;if(i.kind==="value"){for(const r of re)if(!ne(r,e))return null}}return`Expected ${j(i)} but found ${j(e)} instead.`}function le(i,e){return e.some(r=>r.kind===i.kind)}function K(i,e){return e.some(r=>r==="null"?i===null:r==="array"?Array.isArray(i):r==="object"?i&&!Array.isArray(i)&&typeof i=="object":r===typeof i)}function fe(i,e){return i.kind==="array"&&e.kind==="array"?i.itemType.kind===e.itemType.kind&&typeof i.N=="number":i.kind===e.kind}const Ce=.96422,ve=.82521,we=4/29,ot=6/29,lt=3*ot*ot,gt=ot*ot*ot,_t=Math.PI/180,Lt=180/Math.PI;function Xt(i){return(i%=360)<0&&(i+=360),i}function ui([i,e,r,o]){let l,h;const p=ut((.2225045*(i=Zi(i))+.7168786*(e=Zi(e))+.0606169*(r=Zi(r)))/1);i===e&&e===r?l=h=p:(l=ut((.4360747*i+.3850649*e+.1430804*r)/Ce),h=ut((.0139322*i+.0971045*e+.7141733*r)/ve));const m=116*p-16;return[m<0?0:m,500*(l-p),200*(p-h),o]}function Zi(i){return i<=.04045?i/12.92:Math.pow((i+.055)/1.055,2.4)}function ut(i){return i>gt?Math.pow(i,1/3):i/lt+we}function Si([i,e,r,o]){let l=(i+16)/116,h=isNaN(e)?l:l+e/500,p=isNaN(r)?l:l-r/200;return l=1*Tr(l),h=Ce*Tr(h),p=ve*Tr(p),[Ji(3.1338561*h-1.6168667*l-.4906146*p),Ji(-.9787684*h+1.9161415*l+.033454*p),Ji(.0719453*h-.2289914*l+1.4052427*p),o]}function Ji(i){return(i=i<=.00304?12.92*i:1.055*Math.pow(i,1/2.4)-.055)<0?0:i>1?1:i}function Tr(i){return i>ot?i*i*i:lt*(i-we)}function Er(i){return parseInt(i.padEnd(2,i),16)/255}function er(i,e){return Qr(e?i/100:i,0,1)}function Qr(i,e,r){return Math.min(Math.max(e,i),r)}function ma(i){return!i.some(Number.isNaN)}const hs={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]};class Jt{constructor(e,r,o,l=1,h=!0){this.r=e,this.g=r,this.b=o,this.a=l,h||(this.r*=l,this.g*=l,this.b*=l,l||this.overwriteGetter("rgb",[e,r,o,l]))}static parse(e){if(e instanceof Jt)return e;if(typeof e!="string")return;const r=function(o){if((o=o.toLowerCase().trim())==="transparent")return[0,0,0,0];const l=hs[o];if(l){const[p,m,_]=l;return[p/255,m/255,_/255,1]}if(o.startsWith("#")&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(o)){const p=o.length<6?1:2;let m=1;return[Er(o.slice(m,m+=p)),Er(o.slice(m,m+=p)),Er(o.slice(m,m+=p)),Er(o.slice(m,m+p)||"ff")]}if(o.startsWith("rgb")){const p=o.match(/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(p){const[m,_,x,T,E,k,R,B,V,q,J,pe]=p,Y=[T||" ",R||" ",q].join("");if(Y===" "||Y===" /"||Y===",,"||Y===",,,"){const se=[x,k,V].join(""),Ie=se==="%%%"?100:se===""?255:0;if(Ie){const Me=[Qr(+_/Ie,0,1),Qr(+E/Ie,0,1),Qr(+B/Ie,0,1),J?er(+J,pe):1];if(ma(Me))return Me}}return}}const h=o.match(/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,\/])\s*([\de.+-]+)(%)?)?\s*\)$/);if(h){const[p,m,_,x,T,E,k,R,B]=h,V=[_||" ",T||" ",k].join("");if(V===" "||V===" /"||V===",,"||V===",,,"){const q=[+m,Qr(+x,0,100),Qr(+E,0,100),R?er(+R,B):1];if(ma(q))return function([J,pe,Y,se]){function Ie(Me){const Qe=(Me+J/30)%12,nt=pe*Math.min(Y,1-Y);return Y-nt*Math.max(-1,Math.min(Qe-3,9-Qe,1))}return J=Xt(J),pe/=100,Y/=100,[Ie(0),Ie(8),Ie(4),se]}(q)}}}(e);return r?new Jt(...r,!1):void 0}get rgb(){const{r:e,g:r,b:o,a:l}=this,h=l||1/0;return this.overwriteGetter("rgb",[e/h,r/h,o/h,l])}get hcl(){return this.overwriteGetter("hcl",function(e){const[r,o,l,h]=ui(e),p=Math.sqrt(o*o+l*l);return[Math.round(1e4*p)?Xt(Math.atan2(l,o)*Lt):NaN,p,r,h]}(this.rgb))}get lab(){return this.overwriteGetter("lab",ui(this.rgb))}overwriteGetter(e,r){return Object.defineProperty(this,e,{value:r}),r}toString(){const[e,r,o,l]=this.rgb;return`rgba(${[e,r,o].map(h=>Math.round(255*h)).join(",")},${l})`}}Jt.black=new Jt(0,0,0,1),Jt.white=new Jt(1,1,1,1),Jt.transparent=new Jt(0,0,0,0),Jt.red=new Jt(1,0,0,1);class qo{constructor(e,r,o){this.sensitivity=e?r?"variant":"case":r?"accent":"base",this.locale=o,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,r){return this.collator.compare(e,r)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class Bi{constructor(e,r,o,l,h){this.text=e,this.image=r,this.scale=o,this.fontStack=l,this.textColor=h}}class Rr{constructor(e){this.sections=e}static fromString(e){return new Rr([new Bi(e,null,null,null,null)])}isEmpty(){return this.sections.length===0||!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Rr?e:Rr.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}}class Cr{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Cr)return e;if(typeof e=="number")return new Cr([e,e,e,e]);if(Array.isArray(e)&&!(e.length<1||e.length>4)){for(const r of e)if(typeof r!="number")return;switch(e.length){case 1:e=[e[0],e[0],e[0],e[0]];break;case 2:e=[e[0],e[1],e[0],e[1]];break;case 3:e=[e[0],e[1],e[2],e[1]]}return new Cr(e)}}toString(){return JSON.stringify(this.values)}}const en=new Set(["center","left","right","top","bottom","top-left","top-right","bottom-left","bottom-right"]);class Oi{constructor(e){this.values=e.slice()}static parse(e){if(e instanceof Oi)return e;if(Array.isArray(e)&&!(e.length<1)&&e.length%2==0){for(let r=0;r=0&&i<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof r=="number"&&r>=0&&r<=255?o===void 0||typeof o=="number"&&o>=0&&o<=1?null:`Invalid rgba value [${[i,e,r,o].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof o=="number"?[i,e,r,o]:[i,e,r]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Mn(i){if(i===null||typeof i=="string"||typeof i=="boolean"||typeof i=="number"||i instanceof Jt||i instanceof qo||i instanceof Rr||i instanceof Cr||i instanceof Oi||i instanceof Mr)return!0;if(Array.isArray(i)){for(const e of i)if(!Mn(e))return!1;return!0}if(typeof i=="object"){for(const e in i)if(!Mn(i[e]))return!1;return!0}return!1}function Ni(i){if(i===null)return Xi;if(typeof i=="string")return Tt;if(typeof i=="boolean")return yt;if(typeof i=="number")return Ue;if(i instanceof Jt)return Gi;if(i instanceof qo)return ro;if(i instanceof Rr)return Pi;if(i instanceof Cr)return G;if(i instanceof Oi)return z;if(i instanceof Mr)return P;if(Array.isArray(i)){const e=i.length;let r;for(const o of i){const l=Ni(o);if(r){if(r===l)continue;r=mt;break}r=l}return O(r||mt,e)}return Yr}function Ho(i){const e=typeof i;return i===null?"":e==="string"||e==="number"||e==="boolean"?String(i):i instanceof Jt||i instanceof Rr||i instanceof Cr||i instanceof Oi||i instanceof Mr?i.toString():JSON.stringify(i)}class no{constructor(e,r){this.type=e,this.value=r}static parse(e,r){if(e.length!==2)return r.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Mn(e[1]))return r.error("invalid value");const o=e[1];let l=Ni(o);const h=r.expectedType;return l.kind!=="array"||l.N!==0||!h||h.kind!=="array"||typeof h.N=="number"&&h.N!==0||(l=h),new no(l,o)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}}class mi{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}const Wo={string:Tt,number:Ue,boolean:yt,object:Yr};class Ar{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");let o,l=1;const h=e[0];if(h==="array"){let m,_;if(e.length>2){const x=e[1];if(typeof x!="string"||!(x in Wo)||x==="object")return r.error('The item type argument of "array" must be one of string, number, boolean',1);m=Wo[x],l++}else m=mt;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return r.error('The length argument to "array" must be a positive integer literal',2);_=e[2],l++}o=O(m,_)}else{if(!Wo[h])throw new Error(`Types doesn't contain name = ${h}`);o=Wo[h]}const p=[];for(;le.outputDefined())}}const Xo={"to-boolean":yt,"to-color":Gi,"to-number":Ue,"to-string":Tt};class fn{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[0];if(!Xo[o])throw new Error(`Can't parse ${o} as it is not part of the known types`);if((o==="to-boolean"||o==="to-string")&&e.length!==2)return r.error("Expected one argument.");const l=Xo[o],h=[];for(let p=1;p4?`Invalid rbga value ${JSON.stringify(r)}: expected an array containing either three or four numeric values.`:tn(r[0],r[1],r[2],r[3]),!o))return new Jt(r[0]/255,r[1]/255,r[2]/255,r[3])}throw new mi(o||`Could not parse color from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"padding":{let r;for(const o of this.args){r=o.evaluate(e);const l=Cr.parse(r);if(l)return l}throw new mi(`Could not parse padding from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"variableAnchorOffsetCollection":{let r;for(const o of this.args){r=o.evaluate(e);const l=Oi.parse(r);if(l)return l}throw new mi(`Could not parse variableAnchorOffsetCollection from value '${typeof r=="string"?r:JSON.stringify(r)}'`)}case"number":{let r=null;for(const o of this.args){if(r=o.evaluate(e),r===null)return 0;const l=Number(r);if(!isNaN(l))return l}throw new mi(`Could not convert ${JSON.stringify(r)} to number.`)}case"formatted":return Rr.fromString(Ho(this.args[0].evaluate(e)));case"resolvedImage":return Mr.fromString(Ho(this.args[0].evaluate(e)));default:return Ho(this.args[0].evaluate(e))}}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}const Jo=["Unknown","Point","LineString","Polygon"];class Qt{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null}id(){return this.feature&&"id"in this.feature?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?Jo[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}parseColor(e){let r=this._parseColorCache[e];return r||(r=this._parseColorCache[e]=Jt.parse(e)),r}}class ds{constructor(e,r,o=[],l,h=new pn,p=[]){this.registry=e,this.path=o,this.key=o.map(m=>`[${m}]`).join(""),this.scope=h,this.errors=p,this.expectedType=l,this._isConstant=r}parse(e,r,o,l,h={}){return r?this.concat(r,o,l)._parse(e,h):this._parse(e,h)}_parse(e,r){function o(l,h,p){return p==="assert"?new Ar(h,[l]):p==="coerce"?new fn(h,[l]):l}if(e!==null&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"||(e=["literal",e]),Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const l=e[0];if(typeof l!="string")return this.error(`Expression name must be a string, but found ${typeof l} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const h=this.registry[l];if(h){let p=h.parse(e,this);if(!p)return null;if(this.expectedType){const m=this.expectedType,_=p.type;if(m.kind!=="string"&&m.kind!=="number"&&m.kind!=="boolean"&&m.kind!=="object"&&m.kind!=="array"||_.kind!=="value")if(m.kind!=="color"&&m.kind!=="formatted"&&m.kind!=="resolvedImage"||_.kind!=="value"&&_.kind!=="string")if(m.kind!=="padding"||_.kind!=="value"&&_.kind!=="number"&&_.kind!=="array")if(m.kind!=="variableAnchorOffsetCollection"||_.kind!=="value"&&_.kind!=="array"){if(this.checkSubtype(m,_))return null}else p=o(p,m,r.typeAnnotation||"coerce");else p=o(p,m,r.typeAnnotation||"coerce");else p=o(p,m,r.typeAnnotation||"coerce");else p=o(p,m,r.typeAnnotation||"assert")}if(!(p instanceof no)&&p.type.kind!=="resolvedImage"&&this._isConstant(p)){const m=new Qt;try{p=new no(p.type,p.evaluate(m))}catch(_){return this.error(_.message),null}}return p}return this.error(`Unknown expression "${l}". If you wanted a literal array, use ["literal", [...]].`,0)}return this.error(e===void 0?"'undefined' value invalid. Use null instead.":typeof e=="object"?'Bare objects invalid. Use ["literal", {...}] instead.':`Expected an array, but found ${typeof e} instead.`)}concat(e,r,o){const l=typeof e=="number"?this.path.concat(e):this.path,h=o?this.scope.concat(o):this.scope;return new ds(this.registry,this._isConstant,l,r||null,h,this.errors)}error(e,...r){const o=`${this.key}${r.map(l=>`[${l}]`).join("")}`;this.errors.push(new Wi(o,e))}checkSubtype(e,r){const o=ne(e,r);return o&&this.error(o),o}}class $n{constructor(e,r,o){this.type=ro,this.locale=o,this.caseSensitive=e,this.diacriticSensitive=r}static parse(e,r){if(e.length!==2)return r.error("Expected one argument.");const o=e[1];if(typeof o!="object"||Array.isArray(o))return r.error("Collator options argument must be an object.");const l=r.parse(o["case-sensitive"]!==void 0&&o["case-sensitive"],1,yt);if(!l)return null;const h=r.parse(o["diacritic-sensitive"]!==void 0&&o["diacritic-sensitive"],1,yt);if(!h)return null;let p=null;return o.locale&&(p=r.parse(o.locale,1,Tt),!p)?null:new $n(l,h,p)}evaluate(e){return new qo(this.caseSensitive.evaluate(e),this.diacriticSensitive.evaluate(e),this.locale?this.locale.evaluate(e):null)}eachChild(e){e(this.caseSensitive),e(this.diacriticSensitive),this.locale&&e(this.locale)}outputDefined(){return!1}}const f=8192;function b(i,e){i[0]=Math.min(i[0],e[0]),i[1]=Math.min(i[1],e[1]),i[2]=Math.max(i[2],e[0]),i[3]=Math.max(i[3],e[1])}function D(i,e){return!(i[0]<=e[0]||i[2]>=e[2]||i[1]<=e[1]||i[3]>=e[3])}function W(i,e){const r=(180+i[0])/360,o=(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i[1]*Math.PI/360)))/360,l=Math.pow(2,e.z);return[Math.round(r*l*f),Math.round(o*l*f)]}function te(i,e,r){const o=i[0]-e[0],l=i[1]-e[1],h=i[0]-r[0],p=i[1]-r[1];return o*p-h*l==0&&o*h<=0&&l*p<=0}function ie(i,e){let r=!1;for(let p=0,m=e.length;p(o=i)[1]!=(h=_[x+1])[1]>o[1]&&o[0]<(h[0]-l[0])*(o[1]-l[1])/(h[1]-l[1])+l[0]&&(r=!r)}}var o,l,h;return r}function ue(i,e){for(let r=0;r0&&m<0||p<0&&m>0}function Be(i,e,r){for(const x of r)for(let T=0;Tr[2]){const l=.5*o;let h=i[0]-r[0]>l?-o:r[0]-i[0]>l?o:0;h===0&&(h=i[0]-r[2]>l?-o:r[2]-i[0]>l?o:0),i[0]+=h}b(e,i)}function It(i,e,r,o){const l=Math.pow(2,o.z)*f,h=[o.x*f,o.y*f],p=[];for(const m of i)for(const _ of m){const x=[_.x+h[0],_.y+h[1]];gi(x,e,r,l),p.push(x)}return p}function Vi(i,e,r,o){const l=Math.pow(2,o.z)*f,h=[o.x*f,o.y*f],p=[];for(const _ of i){const x=[];for(const T of _){const E=[T.x+h[0],T.y+h[1]];b(e,E),x.push(E)}p.push(x)}if(e[2]-e[0]<=l/2){(m=e)[0]=m[1]=1/0,m[2]=m[3]=-1/0;for(const _ of p)for(const x of _)gi(x,e,r,l)}var m;return p}class Ee{constructor(e,r){this.type=yt,this.geojson=e,this.geometries=r}static parse(e,r){if(e.length!==2)return r.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Mn(e[1])){const o=e[1];if(o.type==="FeatureCollection"){const l=[];for(const h of o.features){const{type:p,coordinates:m}=h.geometry;p==="Polygon"&&l.push(m),p==="MultiPolygon"&&l.push(...m)}if(l.length)return new Ee(o,{type:"MultiPolygon",coordinates:l})}else if(o.type==="Feature"){const l=o.geometry.type;if(l==="Polygon"||l==="MultiPolygon")return new Ee(o,o.geometry)}else if(o.type==="Polygon"||o.type==="MultiPolygon")return new Ee(o,o)}return r.error("'within' expression requires valid geojson object that contains polygon geometry type.")}evaluate(e){if(e.geometry()!=null&&e.canonicalID()!=null){if(e.geometryType()==="Point")return function(r,o){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(o.type==="Polygon"){const m=Ve(o.coordinates,h,p),_=It(r.geometry(),l,h,p);if(!D(l,h))return!1;for(const x of _)if(!ie(x,m))return!1}if(o.type==="MultiPolygon"){const m=wt(o.coordinates,h,p),_=It(r.geometry(),l,h,p);if(!D(l,h))return!1;for(const x of _)if(!ue(x,m))return!1}return!0}(e,this.geometries);if(e.geometryType()==="LineString")return function(r,o){const l=[1/0,1/0,-1/0,-1/0],h=[1/0,1/0,-1/0,-1/0],p=r.canonicalID();if(o.type==="Polygon"){const m=Ve(o.coordinates,h,p),_=Vi(r.geometry(),l,h,p);if(!D(l,h))return!1;for(const x of _)if(!Xe(x,m))return!1}if(o.type==="MultiPolygon"){const m=wt(o.coordinates,h,p),_=Vi(r.geometry(),l,h,p);if(!D(l,h))return!1;for(const x of _)if(!Je(x,m))return!1}return!0}(e,this.geometries)}return!1}eachChild(){}outputDefined(){return!0}}class rt{constructor(e,r){this.type=r.type,this.name=e,this.boundExpression=r}static parse(e,r){if(e.length!==2||typeof e[1]!="string")return r.error("'var' expression requires exactly one string literal argument.");const o=e[1];return r.scope.has(o)?new rt(o,r.scope.get(o)):r.error(`Unknown variable "${o}". Make sure "${o}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}}class zt{constructor(e,r,o,l){this.name=e,this.type=r,this._evaluate=o,this.args=l}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}static parse(e,r){const o=e[0],l=zt.definitions[o];if(!l)return r.error(`Unknown expression "${o}". If you wanted a literal array, use ["literal", [...]].`,0);const h=Array.isArray(l)?l[0]:l.type,p=Array.isArray(l)?[[l[1],l[2]]]:l.overloads,m=p.filter(([x])=>!Array.isArray(x)||x.length===e.length-1);let _=null;for(const[x,T]of m){_=new ds(r.registry,ki,r.path,null,r.scope);const E=[];let k=!1;for(let R=1;R{return k=E,Array.isArray(k)?`(${k.map(j).join(", ")})`:`(${j(k.type)}...)`;var k}).join(" | "),T=[];for(let E=1;E{r=e?r&&ki(o):r&&o instanceof no}),!!r&&Ti(i)&&Ko(i,["zoom","heatmap-density","line-progress","accumulated","is-supported-script"])}function Ti(i){if(i instanceof zt&&(i.name==="get"&&i.args.length===1||i.name==="feature-state"||i.name==="has"&&i.args.length===1||i.name==="properties"||i.name==="geometry-type"||i.name==="id"||/^filter-/.test(i.name))||i instanceof Ee)return!1;let e=!0;return i.eachChild(r=>{e&&!Ti(r)&&(e=!1)}),e}function yo(i){if(i instanceof zt&&i.name==="feature-state")return!1;let e=!0;return i.eachChild(r=>{e&&!yo(r)&&(e=!1)}),e}function Ko(i,e){if(i instanceof zt&&e.indexOf(i.name)>=0)return!1;let r=!0;return i.eachChild(o=>{r&&!Ko(o,e)&&(r=!1)}),r}function ei(i,e){const r=i.length-1;let o,l,h=0,p=r,m=0;for(;h<=p;)if(m=Math.floor((h+p)/2),o=i[m],l=i[m+1],o<=e){if(m===r||ee))throw new mi("Input is not a number.");p=m-1}return 0}class Lo{constructor(e,r,o){this.type=e,this.input=r,this.labels=[],this.outputs=[];for(const[l,h]of o)this.labels.push(l),this.outputs.push(h)}static parse(e,r){if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");const o=r.parse(e[1],1,Ue);if(!o)return null;const l=[];let h=null;r.expectedType&&r.expectedType.kind!=="value"&&(h=r.expectedType);for(let p=1;p=m)return r.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',x);const E=r.parse(_,T,h);if(!E)return null;h=h||E.type,l.push([m,E])}return new Lo(h,o,l)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;return l>=r[h-1]?o[h-1].evaluate(e):o[ei(r,l)].evaluate(e)}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Ga(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var Gn=Us;function Us(i,e,r,o){this.cx=3*i,this.bx=3*(r-i)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(o-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=i,this.p1y=e,this.p2x=r,this.p2y=o}Us.prototype={sampleCurveX:function(i){return((this.ax*i+this.bx)*i+this.cx)*i},sampleCurveY:function(i){return((this.ay*i+this.by)*i+this.cy)*i},sampleCurveDerivativeX:function(i){return(3*this.ax*i+2*this.bx)*i+this.cx},solveCurveX:function(i,e){if(e===void 0&&(e=1e-6),i<0)return 0;if(i>1)return 1;for(var r=i,o=0;o<8;o++){var l=this.sampleCurveX(r)-i;if(Math.abs(l)l?p=r:m=r,r=.5*(m-p)+p;return r},solve:function(i,e){return this.sampleCurveY(this.solveCurveX(i,e))}};var ga=Ga(Gn);function oo(i,e,r){return i+r*(e-i)}function zo(i,e,r){return i.map((o,l)=>oo(o,e[l],r))}const wr={number:oo,color:function(i,e,r,o="rgb"){switch(o){case"rgb":{const[l,h,p,m]=zo(i.rgb,e.rgb,r);return new Jt(l,h,p,m,!1)}case"hcl":{const[l,h,p,m]=i.hcl,[_,x,T,E]=e.hcl;let k,R;if(isNaN(l)||isNaN(_))isNaN(l)?isNaN(_)?k=NaN:(k=_,p!==1&&p!==0||(R=x)):(k=l,T!==1&&T!==0||(R=h));else{let pe=_-l;_>l&&pe>180?pe-=360:_180&&(pe+=360),k=l+r*pe}const[B,V,q,J]=function([pe,Y,se,Ie]){return pe=isNaN(pe)?0:pe*_t,Si([se,Math.cos(pe)*Y,Math.sin(pe)*Y,Ie])}([k,R??oo(h,x,r),oo(p,T,r),oo(m,E,r)]);return new Jt(B,V,q,J,!1)}case"lab":{const[l,h,p,m]=Si(zo(i.lab,e.lab,r));return new Jt(l,h,p,m,!1)}}},array:zo,padding:function(i,e,r){return new Cr(zo(i.values,e.values,r))},variableAnchorOffsetCollection:function(i,e,r){const o=i.values,l=e.values;if(o.length!==l.length)throw new mi(`Cannot interpolate values of different length. from: ${i.toString()}, to: ${e.toString()}`);const h=[];for(let p=0;ptypeof T!="number"||T<0||T>1))return r.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);l={name:"cubic-bezier",controlPoints:x}}}if(e.length-1<4)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!=0)return r.error("Expected an even number of arguments.");if(h=r.parse(h,2,Ue),!h)return null;const m=[];let _=null;o==="interpolate-hcl"||o==="interpolate-lab"?_=Gi:r.expectedType&&r.expectedType.kind!=="value"&&(_=r.expectedType);for(let x=0;x=T)return r.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',k);const B=r.parse(E,R,_);if(!B)return null;_=_||B.type,m.push([T,B])}return fe(_,Ue)||fe(_,Gi)||fe(_,G)||fe(_,z)||fe(_,O(Ue))?new lr(_,o,l,h,m):r.error(`Type ${j(_)} is not interpolatable.`)}evaluate(e){const r=this.labels,o=this.outputs;if(r.length===1)return o[0].evaluate(e);const l=this.input.evaluate(e);if(l<=r[0])return o[0].evaluate(e);const h=r.length;if(l>=r[h-1])return o[h-1].evaluate(e);const p=ei(r,l),m=lr.interpolationFactor(this.interpolation,l,r[p],r[p+1]),_=o[p].evaluate(e),x=o[p+1].evaluate(e);switch(this.operator){case"interpolate":return wr[this.type.kind](_,x,m);case"interpolate-hcl":return wr.color(_,x,m,"hcl");case"interpolate-lab":return wr.color(_,x,m,"lab")}}eachChild(e){e(this.input);for(const r of this.outputs)e(r)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}}function Ht(i,e,r,o){const l=o-r,h=i-r;return l===0?0:e===1?h/l:(Math.pow(e,h)-1)/(Math.pow(e,l)-1)}class ps{constructor(e,r){this.type=e,this.args=r}static parse(e,r){if(e.length<2)return r.error("Expectected at least one argument.");let o=null;const l=r.expectedType;l&&l.kind!=="value"&&(o=l);const h=[];for(const m of e.slice(1)){const _=r.parse(m,1+h.length,o,void 0,{typeAnnotation:"omit"});if(!_)return null;o=o||_.type,h.push(_)}if(!o)throw new Error("No output type");const p=l&&h.some(m=>ne(l,m.type));return new ps(p?mt:o,h)}evaluate(e){let r,o=null,l=0;for(const h of this.args)if(l++,o=h.evaluate(e),o&&o instanceof Mr&&!o.available&&(r||(r=o.name),o=null,l===this.args.length&&(o=r)),o!==null)break;return o}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}}class fs{constructor(e,r){this.type=r.type,this.bindings=[].concat(e),this.result=r}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const r of this.bindings)e(r[1]);e(this.result)}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const o=[];for(let h=1;h=o.length)throw new mi(`Array index out of bounds: ${r} > ${o.length-1}.`);if(r!==Math.floor(r))throw new mi(`Array index must be an integer, but found ${r} instead.`);return o[r]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}}class gs{constructor(e,r){this.type=yt,this.needle=e,this.haystack=r}static parse(e,r){if(e.length!==3)return r.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,mt),l=r.parse(e[2],2,mt);return o&&l?le(o.type,[yt,Tt,Ue,Xi,mt])?new gs(o,l):r.error(`Expected first argument to be of type boolean, string, number or null, but found ${j(o.type)} instead`):null}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!o)return!1;if(!K(r,["boolean","string","number","null"]))throw new mi(`Expected first argument to be of type boolean, string, number or null, but found ${j(Ni(r))} instead.`);if(!K(o,["string","array"]))throw new mi(`Expected second argument to be of type array or string, but found ${j(Ni(o))} instead.`);return o.indexOf(r)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}}class Yo{constructor(e,r,o){this.type=Ue,this.needle=e,this.haystack=r,this.fromIndex=o}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,mt),l=r.parse(e[2],2,mt);if(!o||!l)return null;if(!le(o.type,[yt,Tt,Ue,Xi,mt]))return r.error(`Expected first argument to be of type boolean, string, number or null, but found ${j(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,Ue);return h?new Yo(o,l,h):null}return new Yo(o,l)}evaluate(e){const r=this.needle.evaluate(e),o=this.haystack.evaluate(e);if(!K(r,["boolean","string","number","null"]))throw new mi(`Expected first argument to be of type boolean, string, number or null, but found ${j(Ni(r))} instead.`);if(!K(o,["string","array"]))throw new mi(`Expected second argument to be of type array or string, but found ${j(Ni(o))} instead.`);if(this.fromIndex){const l=this.fromIndex.evaluate(e);return o.indexOf(r,l)}return o.indexOf(r)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}}class js{constructor(e,r,o,l,h,p){this.inputType=e,this.type=r,this.input=o,this.cases=l,this.outputs=h,this.otherwise=p}static parse(e,r){if(e.length<5)return r.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!=1)return r.error("Expected an even number of arguments.");let o,l;r.expectedType&&r.expectedType.kind!=="value"&&(l=r.expectedType);const h={},p=[];for(let x=2;xNumber.MAX_SAFE_INTEGER)return k.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof B=="number"&&Math.floor(B)!==B)return k.error("Numeric branch labels must be integer values.");if(o){if(k.checkSubtype(o,Ni(B)))return null}else o=Ni(B);if(h[String(B)]!==void 0)return k.error("Branch labels must be unique.");h[String(B)]=p.length}const R=r.parse(E,x,l);if(!R)return null;l=l||R.type,p.push(R)}const m=r.parse(e[1],1,mt);if(!m)return null;const _=r.parse(e[e.length-1],e.length-1,l);return _?m.type.kind!=="value"&&r.concat(1).checkSubtype(o,m.type)?null:new js(o,l,m,h,p,_):null}evaluate(e){const r=this.input.evaluate(e);return(Ni(r)===this.inputType&&this.outputs[this.cases[r]]||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()}}class $s{constructor(e,r,o){this.type=e,this.branches=r,this.otherwise=o}static parse(e,r){if(e.length<4)return r.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!=0)return r.error("Expected an odd number of arguments.");let o;r.expectedType&&r.expectedType.kind!=="value"&&(o=r.expectedType);const l=[];for(let p=1;pr.outputDefined())&&this.otherwise.outputDefined()}}class _o{constructor(e,r,o,l){this.type=e,this.input=r,this.beginIndex=o,this.endIndex=l}static parse(e,r){if(e.length<=2||e.length>=5)return r.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const o=r.parse(e[1],1,mt),l=r.parse(e[2],2,Ue);if(!o||!l)return null;if(!le(o.type,[O(mt),Tt,mt]))return r.error(`Expected first argument to be of type array or string, but found ${j(o.type)} instead`);if(e.length===4){const h=r.parse(e[3],3,Ue);return h?new _o(o.type,o,l,h):null}return new _o(o.type,o,l)}evaluate(e){const r=this.input.evaluate(e),o=this.beginIndex.evaluate(e);if(!K(r,["string","array"]))throw new mi(`Expected first argument to be of type array or string, but found ${j(Ni(r))} instead.`);if(this.endIndex){const l=this.endIndex.evaluate(e);return r.slice(o,l)}return r.slice(o)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}}function ys(i,e){return i==="=="||i==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Gs(i,e,r,o){return o.compare(e,r)===0}function Pr(i,e,r){const o=i!=="=="&&i!=="!=";return class Zh{constructor(h,p,m){this.type=yt,this.lhs=h,this.rhs=p,this.collator=m,this.hasUntypedArgument=h.type.kind==="value"||p.type.kind==="value"}static parse(h,p){if(h.length!==3&&h.length!==4)return p.error("Expected two or three arguments.");const m=h[0];let _=p.parse(h[1],1,mt);if(!_)return null;if(!ys(m,_.type))return p.concat(1).error(`"${m}" comparisons are not supported for type '${j(_.type)}'.`);let x=p.parse(h[2],2,mt);if(!x)return null;if(!ys(m,x.type))return p.concat(2).error(`"${m}" comparisons are not supported for type '${j(x.type)}'.`);if(_.type.kind!==x.type.kind&&_.type.kind!=="value"&&x.type.kind!=="value")return p.error(`Cannot compare types '${j(_.type)}' and '${j(x.type)}'.`);o&&(_.type.kind==="value"&&x.type.kind!=="value"?_=new Ar(x.type,[_]):_.type.kind!=="value"&&x.type.kind==="value"&&(x=new Ar(_.type,[x])));let T=null;if(h.length===4){if(_.type.kind!=="string"&&x.type.kind!=="string"&&_.type.kind!=="value"&&x.type.kind!=="value")return p.error("Cannot use collator to compare non-string types.");if(T=p.parse(h[3],3,ro),!T)return null}return new Zh(_,x,T)}evaluate(h){const p=this.lhs.evaluate(h),m=this.rhs.evaluate(h);if(o&&this.hasUntypedArgument){const _=Ni(p),x=Ni(m);if(_.kind!==x.kind||_.kind!=="string"&&_.kind!=="number")throw new mi(`Expected arguments for "${i}" to be (string, string) or (number, number), but found (${_.kind}, ${x.kind}) instead.`)}if(this.collator&&!o&&this.hasUntypedArgument){const _=Ni(p),x=Ni(m);if(_.kind!=="string"||x.kind!=="string")return e(h,p,m)}return this.collator?r(h,p,m,this.collator.evaluate(h)):e(h,p,m)}eachChild(h){h(this.lhs),h(this.rhs),this.collator&&h(this.collator)}outputDefined(){return!0}}}const ya=Pr("==",function(i,e,r){return e===r},Gs),_a=Pr("!=",function(i,e,r){return e!==r},function(i,e,r,o){return!Gs(0,e,r,o)}),Za=Pr("<",function(i,e,r){return e",function(i,e,r){return e>r},function(i,e,r,o){return o.compare(e,r)>0}),_s=Pr("<=",function(i,e,r){return e<=r},function(i,e,r,o){return o.compare(e,r)<=0}),xa=Pr(">=",function(i,e,r){return e>=r},function(i,e,r,o){return o.compare(e,r)>=0});class vs{constructor(e,r,o,l,h){this.type=Tt,this.number=e,this.locale=r,this.currency=o,this.minFractionDigits=l,this.maxFractionDigits=h}static parse(e,r){if(e.length!==3)return r.error("Expected two arguments.");const o=r.parse(e[1],1,Ue);if(!o)return null;const l=e[2];if(typeof l!="object"||Array.isArray(l))return r.error("NumberFormat options argument must be an object.");let h=null;if(l.locale&&(h=r.parse(l.locale,1,Tt),!h))return null;let p=null;if(l.currency&&(p=r.parse(l.currency,1,Tt),!p))return null;let m=null;if(l["min-fraction-digits"]&&(m=r.parse(l["min-fraction-digits"],1,Ue),!m))return null;let _=null;return l["max-fraction-digits"]&&(_=r.parse(l["max-fraction-digits"],1,Ue),!_)?null:new vs(o,h,p,m,_)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency?"currency":"decimal",currency:this.currency?this.currency.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}}class xs{constructor(e){this.type=Pi,this.sections=e}static parse(e,r){if(e.length<2)return r.error("Expected at least one argument.");const o=e[1];if(!Array.isArray(o)&&typeof o=="object")return r.error("First argument must be an image or text section.");const l=[];let h=!1;for(let p=1;p<=e.length-1;++p){const m=e[p];if(h&&typeof m=="object"&&!Array.isArray(m)){h=!1;let _=null;if(m["font-scale"]&&(_=r.parse(m["font-scale"],1,Ue),!_))return null;let x=null;if(m["text-font"]&&(x=r.parse(m["text-font"],1,O(Tt)),!x))return null;let T=null;if(m["text-color"]&&(T=r.parse(m["text-color"],1,Gi),!T))return null;const E=l[l.length-1];E.scale=_,E.font=x,E.textColor=T}else{const _=r.parse(e[p],1,mt);if(!_)return null;const x=_.type.kind;if(x!=="string"&&x!=="value"&&x!=="null"&&x!=="resolvedImage")return r.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");h=!0,l.push({content:_,scale:null,font:null,textColor:null})}}return new xs(l)}evaluate(e){return new Rr(this.sections.map(r=>{const o=r.content.evaluate(e);return Ni(o)===P?new Bi("",o,null,null,null):new Bi(Ho(o),null,r.scale?r.scale.evaluate(e):null,r.font?r.font.evaluate(e).join(","):null,r.textColor?r.textColor.evaluate(e):null)}))}eachChild(e){for(const r of this.sections)e(r.content),r.scale&&e(r.scale),r.font&&e(r.font),r.textColor&&e(r.textColor)}outputDefined(){return!1}}class Zn{constructor(e){this.type=P,this.input=e}static parse(e,r){if(e.length!==2)return r.error("Expected two arguments.");const o=r.parse(e[1],1,Tt);return o?new Zn(o):r.error("No image name provided.")}evaluate(e){const r=this.input.evaluate(e),o=Mr.fromString(r);return o&&e.availableImages&&(o.available=e.availableImages.indexOf(r)>-1),o}eachChild(e){e(this.input)}outputDefined(){return!1}}class bs{constructor(e){this.type=Ue,this.input=e}static parse(e,r){if(e.length!==2)return r.error(`Expected 1 argument, but found ${e.length-1} instead.`);const o=r.parse(e[1],1);return o?o.type.kind!=="array"&&o.type.kind!=="string"&&o.type.kind!=="value"?r.error(`Expected argument of type string or array, but found ${j(o.type)} instead.`):new bs(o):null}evaluate(e){const r=this.input.evaluate(e);if(typeof r=="string"||Array.isArray(r))return r.length;throw new mi(`Expected value to be of type string or array, but found ${j(Ni(r))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}}const Do={"==":ya,"!=":_a,">":va,"<":Za,">=":xa,"<=":_s,array:Ar,at:ms,boolean:Ar,case:$s,coalesce:ps,collator:$n,format:xs,image:Zn,in:gs,"index-of":Yo,interpolate:lr,"interpolate-hcl":lr,"interpolate-lab":lr,length:bs,let:fs,literal:no,match:js,number:Ar,"number-format":vs,object:Ar,slice:_o,step:Lo,string:Ar,"to-boolean":fn,"to-color":fn,"to-number":fn,"to-string":fn,var:rt,within:Ee};function ba(i,[e,r,o,l]){e=e.evaluate(i),r=r.evaluate(i),o=o.evaluate(i);const h=l?l.evaluate(i):1,p=tn(e,r,o,h);if(p)throw new mi(p);return new Jt(e/255,r/255,o/255,h,!1)}function ws(i,e){return i in e}function vo(i,e){const r=e[i];return r===void 0?null:r}function qn(i){return{type:i}}function Is(i){return{result:"success",value:i}}function so(i){return{result:"error",value:i}}function An(i){return i["property-type"]==="data-driven"||i["property-type"]==="cross-faded-data-driven"}function wa(i){return!!i.expression&&i.expression.parameters.indexOf("zoom")>-1}function Zs(i){return!!i.expression&&i.expression.interpolated}function Ut(i){return i instanceof Number?"number":i instanceof String?"string":i instanceof Boolean?"boolean":Array.isArray(i)?"array":i===null?"null":typeof i}function Ss(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function qa(i){return i}function qs(i,e){const r=e.type==="color",o=i.stops&&typeof i.stops[0][0]=="object",l=o||!(o||i.property!==void 0),h=i.type||(Zs(e)?"exponential":"interval");if(r||e.type==="padding"){const T=r?Jt.parse:Cr.parse;(i=ar({},i)).stops&&(i.stops=i.stops.map(E=>[E[0],T(E[1])])),i.default=T(i.default?i.default:e.default)}if(i.colorSpace&&(p=i.colorSpace)!=="rgb"&&p!=="hcl"&&p!=="lab")throw new Error(`Unknown color space: "${i.colorSpace}"`);var p;let m,_,x;if(h==="exponential")m=At;else if(h==="interval")m=Hn;else if(h==="categorical"){m=oi,_=Object.create(null);for(const T of i.stops)_[T[0]]=T[1];x=typeof i.stops[0][0]}else{if(h!=="identity")throw new Error(`Unknown function type "${h}"`);m=Ro}if(o){const T={},E=[];for(let B=0;BB[0]),evaluate:({zoom:B},V)=>At({stops:k,base:i.base},e,B).evaluate(B,V)}}if(l){const T=h==="exponential"?{name:"exponential",base:i.base!==void 0?i.base:1}:null;return{kind:"camera",interpolationType:T,interpolationFactor:lr.interpolationFactor.bind(void 0,T),zoomStops:i.stops.map(E=>E[0]),evaluate:({zoom:E})=>m(i,e,E,_,x)}}return{kind:"source",evaluate(T,E){const k=E&&E.properties?E.properties[i.property]:void 0;return k===void 0?xo(i.default,e.default):m(i,e,k,_,x)}}}function xo(i,e,r){return i!==void 0?i:e!==void 0?e:r!==void 0?r:void 0}function oi(i,e,r,o,l){return xo(typeof r===l?o[r]:void 0,i.default,e.default)}function Hn(i,e,r){if(Ut(r)!=="number")return xo(i.default,e.default);const o=i.stops.length;if(o===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[o-1][0])return i.stops[o-1][1];const l=ei(i.stops.map(h=>h[0]),r);return i.stops[l][1]}function At(i,e,r){const o=i.base!==void 0?i.base:1;if(Ut(r)!=="number")return xo(i.default,e.default);const l=i.stops.length;if(l===1||r<=i.stops[0][0])return i.stops[0][1];if(r>=i.stops[l-1][0])return i.stops[l-1][1];const h=ei(i.stops.map(T=>T[0]),r),p=function(T,E,k,R){const B=R-k,V=T-k;return B===0?0:E===1?V/B:(Math.pow(E,V)-1)/(Math.pow(E,B)-1)}(r,o,i.stops[h][0],i.stops[h+1][0]),m=i.stops[h][1],_=i.stops[h+1][1],x=wr[e.type]||qa;return typeof m.evaluate=="function"?{evaluate(...T){const E=m.evaluate.apply(void 0,T),k=_.evaluate.apply(void 0,T);if(E!==void 0&&k!==void 0)return x(E,k,p,i.colorSpace)}}:x(m,_,p,i.colorSpace)}function Ro(i,e,r){switch(e.type){case"color":r=Jt.parse(r);break;case"formatted":r=Rr.fromString(r.toString());break;case"resolvedImage":r=Mr.fromString(r.toString());break;case"padding":r=Cr.parse(r);break;default:Ut(r)===e.type||e.type==="enum"&&e.values[r]||(r=void 0)}return xo(r,i.default,e.default)}zt.register(Do,{error:[{kind:"error"},[Tt],(i,[e])=>{throw new mi(e.evaluate(i))}],typeof:[Tt,[mt],(i,[e])=>j(Ni(e.evaluate(i)))],"to-rgba":[O(Ue,4),[Gi],(i,[e])=>{const[r,o,l,h]=e.evaluate(i).rgb;return[255*r,255*o,255*l,h]}],rgb:[Gi,[Ue,Ue,Ue],ba],rgba:[Gi,[Ue,Ue,Ue,Ue],ba],has:{type:yt,overloads:[[[Tt],(i,[e])=>ws(e.evaluate(i),i.properties())],[[Tt,Yr],(i,[e,r])=>ws(e.evaluate(i),r.evaluate(i))]]},get:{type:mt,overloads:[[[Tt],(i,[e])=>vo(e.evaluate(i),i.properties())],[[Tt,Yr],(i,[e,r])=>vo(e.evaluate(i),r.evaluate(i))]]},"feature-state":[mt,[Tt],(i,[e])=>vo(e.evaluate(i),i.featureState||{})],properties:[Yr,[],i=>i.properties()],"geometry-type":[Tt,[],i=>i.geometryType()],id:[mt,[],i=>i.id()],zoom:[Ue,[],i=>i.globals.zoom],"heatmap-density":[Ue,[],i=>i.globals.heatmapDensity||0],"line-progress":[Ue,[],i=>i.globals.lineProgress||0],accumulated:[mt,[],i=>i.globals.accumulated===void 0?null:i.globals.accumulated],"+":[Ue,qn(Ue),(i,e)=>{let r=0;for(const o of e)r+=o.evaluate(i);return r}],"*":[Ue,qn(Ue),(i,e)=>{let r=1;for(const o of e)r*=o.evaluate(i);return r}],"-":{type:Ue,overloads:[[[Ue,Ue],(i,[e,r])=>e.evaluate(i)-r.evaluate(i)],[[Ue],(i,[e])=>-e.evaluate(i)]]},"/":[Ue,[Ue,Ue],(i,[e,r])=>e.evaluate(i)/r.evaluate(i)],"%":[Ue,[Ue,Ue],(i,[e,r])=>e.evaluate(i)%r.evaluate(i)],ln2:[Ue,[],()=>Math.LN2],pi:[Ue,[],()=>Math.PI],e:[Ue,[],()=>Math.E],"^":[Ue,[Ue,Ue],(i,[e,r])=>Math.pow(e.evaluate(i),r.evaluate(i))],sqrt:[Ue,[Ue],(i,[e])=>Math.sqrt(e.evaluate(i))],log10:[Ue,[Ue],(i,[e])=>Math.log(e.evaluate(i))/Math.LN10],ln:[Ue,[Ue],(i,[e])=>Math.log(e.evaluate(i))],log2:[Ue,[Ue],(i,[e])=>Math.log(e.evaluate(i))/Math.LN2],sin:[Ue,[Ue],(i,[e])=>Math.sin(e.evaluate(i))],cos:[Ue,[Ue],(i,[e])=>Math.cos(e.evaluate(i))],tan:[Ue,[Ue],(i,[e])=>Math.tan(e.evaluate(i))],asin:[Ue,[Ue],(i,[e])=>Math.asin(e.evaluate(i))],acos:[Ue,[Ue],(i,[e])=>Math.acos(e.evaluate(i))],atan:[Ue,[Ue],(i,[e])=>Math.atan(e.evaluate(i))],min:[Ue,qn(Ue),(i,e)=>Math.min(...e.map(r=>r.evaluate(i)))],max:[Ue,qn(Ue),(i,e)=>Math.max(...e.map(r=>r.evaluate(i)))],abs:[Ue,[Ue],(i,[e])=>Math.abs(e.evaluate(i))],round:[Ue,[Ue],(i,[e])=>{const r=e.evaluate(i);return r<0?-Math.round(-r):Math.round(r)}],floor:[Ue,[Ue],(i,[e])=>Math.floor(e.evaluate(i))],ceil:[Ue,[Ue],(i,[e])=>Math.ceil(e.evaluate(i))],"filter-==":[yt,[Tt,mt],(i,[e,r])=>i.properties()[e.value]===r.value],"filter-id-==":[yt,[mt],(i,[e])=>i.id()===e.value],"filter-type-==":[yt,[Tt],(i,[e])=>i.geometryType()===e.value],"filter-<":[yt,[Tt,mt],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o{const r=i.id(),o=e.value;return typeof r==typeof o&&r":[yt,[Tt,mt],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>l}],"filter-id->":[yt,[mt],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>o}],"filter-<=":[yt,[Tt,mt],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o<=l}],"filter-id-<=":[yt,[mt],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r<=o}],"filter->=":[yt,[Tt,mt],(i,[e,r])=>{const o=i.properties()[e.value],l=r.value;return typeof o==typeof l&&o>=l}],"filter-id->=":[yt,[mt],(i,[e])=>{const r=i.id(),o=e.value;return typeof r==typeof o&&r>=o}],"filter-has":[yt,[mt],(i,[e])=>e.value in i.properties()],"filter-has-id":[yt,[],i=>i.id()!==null&&i.id()!==void 0],"filter-type-in":[yt,[O(Tt)],(i,[e])=>e.value.indexOf(i.geometryType())>=0],"filter-id-in":[yt,[O(mt)],(i,[e])=>e.value.indexOf(i.id())>=0],"filter-in-small":[yt,[Tt,O(mt)],(i,[e,r])=>r.value.indexOf(i.properties()[e.value])>=0],"filter-in-large":[yt,[Tt,O(mt)],(i,[e,r])=>function(o,l,h,p){for(;h<=p;){const m=h+p>>1;if(l[m]===o)return!0;l[m]>o?p=m-1:h=m+1}return!1}(i.properties()[e.value],r.value,0,r.value.length-1)],all:{type:yt,overloads:[[[yt,yt],(i,[e,r])=>e.evaluate(i)&&r.evaluate(i)],[qn(yt),(i,e)=>{for(const r of e)if(!r.evaluate(i))return!1;return!0}]]},any:{type:yt,overloads:[[[yt,yt],(i,[e,r])=>e.evaluate(i)||r.evaluate(i)],[qn(yt),(i,e)=>{for(const r of e)if(r.evaluate(i))return!0;return!1}]]},"!":[yt,[yt],(i,[e])=>!e.evaluate(i)],"is-supported-script":[yt,[Tt],(i,[e])=>{const r=i.globals&&i.globals.isSupportedScript;return!r||r(e.evaluate(i))}],upcase:[Tt,[Tt],(i,[e])=>e.evaluate(i).toUpperCase()],downcase:[Tt,[Tt],(i,[e])=>e.evaluate(i).toLowerCase()],concat:[Tt,qn(mt),(i,e)=>e.map(r=>Ho(r.evaluate(i))).join("")],"resolved-locale":[Tt,[ro],(i,[e])=>e.evaluate(i).resolvedLocale()]});class Wt{constructor(e,r){var o;this.expression=e,this._warningHistory={},this._evaluator=new Qt,this._defaultValue=r?(o=r).type==="color"&&Ss(o.default)?new Jt(0,0,0,0):o.type==="color"?Jt.parse(o.default)||null:o.type==="padding"?Cr.parse(o.default)||null:o.type==="variableAnchorOffsetCollection"?Oi.parse(o.default)||null:o.default===void 0?null:o.default:null,this._enumValues=r&&r.type==="enum"?r.values:null}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._evaluator.globals=e,this._evaluator.feature=r,this._evaluator.featureState=o,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p,this.expression.evaluate(this._evaluator)}evaluate(e,r,o,l,h,p){this._evaluator.globals=e,this._evaluator.feature=r||null,this._evaluator.featureState=o||null,this._evaluator.canonical=l,this._evaluator.availableImages=h||null,this._evaluator.formattedSection=p||null;try{const m=this.expression.evaluate(this._evaluator);if(m==null||typeof m=="number"&&m!=m)return this._defaultValue;if(this._enumValues&&!(m in this._enumValues))throw new mi(`Expected value to be one of ${Object.keys(this._enumValues).map(_=>JSON.stringify(_)).join(", ")}, but found ${JSON.stringify(m)} instead.`);return m}catch(m){return this._warningHistory[m.message]||(this._warningHistory[m.message]=!0,typeof console<"u"&&console.warn(m.message)),this._defaultValue}}}function ri(i){return Array.isArray(i)&&i.length>0&&typeof i[0]=="string"&&i[0]in Do}function Pn(i,e){const r=new ds(Do,ki,[],e?function(l){const h={color:Gi,string:Tt,number:Ue,enum:Tt,boolean:yt,formatted:Pi,padding:G,resolvedImage:P,variableAnchorOffsetCollection:z};return l.type==="array"?O(h[l.value]||mt,l.length):h[l.type]}(e):void 0),o=r.parse(i,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return o?Is(new Wt(o,e)):so(r.errors)}class ao{constructor(e,r){this.kind=e,this._styleExpression=r,this.isStateDependent=e!=="constant"&&!yo(r.expression)}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}}class Ts{constructor(e,r,o,l){this.kind=e,this.zoomStops=o,this._styleExpression=r,this.isStateDependent=e!=="camera"&&!yo(r.expression),this.interpolationType=l}evaluateWithoutErrorHandling(e,r,o,l,h,p){return this._styleExpression.evaluateWithoutErrorHandling(e,r,o,l,h,p)}evaluate(e,r,o,l,h,p){return this._styleExpression.evaluate(e,r,o,l,h,p)}interpolationFactor(e,r,o){return this.interpolationType?lr.interpolationFactor(this.interpolationType,e,r,o):0}}function Hs(i,e){const r=Pn(i,e);if(r.result==="error")return r;const o=r.value.expression,l=Ti(o);if(!l&&!An(e))return so([new Wi("","data expressions not supported")]);const h=Ko(o,["zoom"]);if(!h&&!wa(e))return so([new Wi("","zoom expressions not supported")]);const p=Cs(o);return p||h?p instanceof Wi?so([p]):p instanceof lr&&!Zs(e)?so([new Wi("",'"interpolate" expressions cannot be used with this property')]):Is(p?new Ts(l?"camera":"composite",r.value,p.labels,p instanceof lr?p.interpolation:void 0):new ao(l?"constant":"source",r.value)):so([new Wi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')])}class Es{constructor(e,r){this._parameters=e,this._specification=r,ar(this,qs(this._parameters,this._specification))}static deserialize(e){return new Es(e._parameters,e._specification)}static serialize(e){return{_parameters:e._parameters,_specification:e._specification}}}function Cs(i){let e=null;if(i instanceof fs)e=Cs(i.result);else if(i instanceof ps){for(const r of i.args)if(e=Cs(r),e)break}else(i instanceof Lo||i instanceof lr)&&i.input instanceof zt&&i.input.name==="zoom"&&(e=i);return e instanceof Wi||i.eachChild(r=>{const o=Cs(r);o instanceof Wi?e=o:!e&&o?e=new Wi("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&o&&e!==o&&(e=new Wi("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function Qo(i){if(i===!0||i===!1)return!0;if(!Array.isArray(i)||i.length===0)return!1;switch(i[0]){case"has":return i.length>=2&&i[1]!=="$id"&&i[1]!=="$type";case"in":return i.length>=3&&(typeof i[1]!="string"||Array.isArray(i[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return i.length!==3||Array.isArray(i[1])||Array.isArray(i[2]);case"any":case"all":for(const e of i.slice(1))if(!Qo(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}const Ws={type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}};function bo(i){if(i==null)return{filter:()=>!0,needGeometry:!1};Qo(i)||(i=mn(i));const e=Pn(i,Ws);if(e.result==="error")throw new Error(e.value.map(r=>`${r.key}: ${r.message}`).join(", "));return{filter:(r,o,l)=>e.value.evaluate(r,o,{},l),needGeometry:Ms(i)}}function wo(i,e){return ie?1:0}function Ms(i){if(!Array.isArray(i))return!1;if(i[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?Xs(i[1],i[2],e):e==="any"?(r=i.slice(1),["any"].concat(r.map(mn))):e==="all"?["all"].concat(i.slice(1).map(mn)):e==="none"?["all"].concat(i.slice(1).map(mn).map(As)):e==="in"?lo(i[1],i.slice(2)):e==="!in"?As(lo(i[1],i.slice(2))):e==="has"?Js(i[1]):e==="!has"?As(Js(i[1])):e!=="within"||i;var r}function Xs(i,e,r){switch(i){case"$type":return[`filter-type-${r}`,e];case"$id":return[`filter-id-${r}`,e];default:return[`filter-${r}`,i,e]}}function lo(i,e){if(e.length===0)return!1;switch(i){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(r=>typeof r!=typeof e[0])?["filter-in-large",i,["literal",e.sort(wo)]]:["filter-in-small",i,["literal",e]]}}function Js(i){switch(i){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",i]}}function As(i){return["!",i]}function Fo(i){const e=typeof i;if(e==="number"||e==="boolean"||e==="string"||i==null)return JSON.stringify(i);if(Array.isArray(i)){let l="[";for(const h of i)l+=`${Fo(h)},`;return`${l}]`}const r=Object.keys(i).sort();let o="{";for(let l=0;lo.maximum?[new ze(e,r,`${r} is greater than the maximum value ${o.maximum}`)]:[]}function he(i){const e=i.valueSpec,r=yi(i.value.type);let o,l,h,p={};const m=r!=="categorical"&&i.value.property===void 0,_=!m,x=Ut(i.value.stops)==="array"&&Ut(i.value.stops[0])==="array"&&Ut(i.value.stops[0][0])==="object",T=Ki({key:i.key,value:i.value,valueSpec:i.styleSpec.function,validateSpec:i.validateSpec,style:i.style,styleSpec:i.styleSpec,objectElementValidators:{stops:function(R){if(r==="identity")return[new ze(R.key,R.value,'identity function may not have a "stops" property')];let B=[];const V=R.value;return B=B.concat(Ps({key:R.key,value:V,valueSpec:R.valueSpec,validateSpec:R.validateSpec,style:R.style,styleSpec:R.styleSpec,arrayElementValidator:E})),Ut(V)==="array"&&V.length===0&&B.push(new ze(R.key,V,"array must have at least one stop")),B},default:function(R){return R.validateSpec({key:R.key,value:R.value,valueSpec:e,validateSpec:R.validateSpec,style:R.style,styleSpec:R.styleSpec})}}});return r==="identity"&&m&&T.push(new ze(i.key,i.value,'missing required property "property"')),r==="identity"||i.value.stops||T.push(new ze(i.key,i.value,'missing required property "stops"')),r==="exponential"&&i.valueSpec.expression&&!Zs(i.valueSpec)&&T.push(new ze(i.key,i.value,"exponential functions not supported")),i.styleSpec.$version>=8&&(_&&!An(i.valueSpec)?T.push(new ze(i.key,i.value,"property functions not supported")):m&&!wa(i.valueSpec)&&T.push(new ze(i.key,i.value,"zoom functions not supported"))),r!=="categorical"&&!x||i.value.property!==void 0||T.push(new ze(i.key,i.value,'"property" property is required')),T;function E(R){let B=[];const V=R.value,q=R.key;if(Ut(V)!=="array")return[new ze(q,V,`array expected, ${Ut(V)} found`)];if(V.length!==2)return[new ze(q,V,`array length 2 expected, length ${V.length} found`)];if(x){if(Ut(V[0])!=="object")return[new ze(q,V,`object expected, ${Ut(V[0])} found`)];if(V[0].zoom===void 0)return[new ze(q,V,"object stop key must have zoom")];if(V[0].value===void 0)return[new ze(q,V,"object stop key must have value")];if(h&&h>yi(V[0].zoom))return[new ze(q,V[0].zoom,"stop zoom values must appear in ascending order")];yi(V[0].zoom)!==h&&(h=yi(V[0].zoom),l=void 0,p={}),B=B.concat(Ki({key:`${q}[0]`,value:V[0],valueSpec:{zoom:{}},validateSpec:R.validateSpec,style:R.style,styleSpec:R.styleSpec,objectElementValidators:{zoom:ks,value:k}}))}else B=B.concat(k({key:`${q}[0]`,value:V[0],valueSpec:{},validateSpec:R.validateSpec,style:R.style,styleSpec:R.styleSpec},V));return ri(Wn(V[1]))?B.concat([new ze(`${q}[1]`,V[1],"expressions are not allowed in function stops.")]):B.concat(R.validateSpec({key:`${q}[1]`,value:V[1],valueSpec:e,validateSpec:R.validateSpec,style:R.style,styleSpec:R.styleSpec}))}function k(R,B){const V=Ut(R.value),q=yi(R.value),J=R.value!==null?R.value:B;if(o){if(V!==o)return[new ze(R.key,J,`${V} stop domain type must match previous stop domain type ${o}`)]}else o=V;if(V!=="number"&&V!=="string"&&V!=="boolean")return[new ze(R.key,J,"stop domain value must be a number, string, or boolean")];if(V!=="number"&&r!=="categorical"){let pe=`number expected, ${V} found`;return An(e)&&r===void 0&&(pe+='\nIf you intended to use a categorical function, specify `"type": "categorical"`.'),[new ze(R.key,J,pe)]}return r!=="categorical"||V!=="number"||isFinite(q)&&Math.floor(q)===q?r!=="categorical"&&V==="number"&&l!==void 0&&qnew ze(`${i.key}${o.key}`,i.value,o.message));const r=e.value.expression||e.value._styleExpression.expression;if(i.expressionContext==="property"&&i.propertyKey==="text-font"&&!r.outputDefined())return[new ze(i.key,i.value,`Invalid data expression for "${i.propertyKey}". Output values must be contained as literals within the expression.`)];if(i.expressionContext==="property"&&i.propertyType==="layout"&&!yo(r))return[new ze(i.key,i.value,'"feature-state" data expressions are not supported with layout properties.')];if(i.expressionContext==="filter"&&!yo(r))return[new ze(i.key,i.value,'"feature-state" data expressions are not supported with filters.')];if(i.expressionContext&&i.expressionContext.indexOf("cluster")===0){if(!Ko(r,["zoom","feature-state"]))return[new ze(i.key,i.value,'"zoom" and "feature-state" expressions are not supported with cluster properties.')];if(i.expressionContext==="cluster-initial"&&!Ti(r))return[new ze(i.key,i.value,"Feature data expressions are not supported with initial expression part of cluster properties.")]}return[]}function je(i){const e=i.key,r=i.value,o=i.valueSpec,l=[];return Array.isArray(o.values)?o.values.indexOf(yi(r))===-1&&l.push(new ze(e,r,`expected one of [${o.values.join(", ")}], ${JSON.stringify(r)} found`)):Object.keys(o.values).indexOf(yi(r))===-1&&l.push(new ze(e,r,`expected one of [${Object.keys(o.values).join(", ")}], ${JSON.stringify(r)} found`)),l}function ct(i){return Qo(Wn(i.value))?_e(ar({},i,{expressionContext:"filter",valueSpec:{value:"boolean"}})):si(i)}function si(i){const e=i.value,r=i.key;if(Ut(e)!=="array")return[new ze(r,e,`array expected, ${Ut(e)} found`)];const o=i.styleSpec;let l,h=[];if(e.length<1)return[new ze(r,e,"filter array must have at least 1 element")];switch(h=h.concat(je({key:`${r}[0]`,value:e[0],valueSpec:o.filter_operator,style:i.style,styleSpec:i.styleSpec})),yi(e[0])){case"<":case"<=":case">":case">=":e.length>=2&&yi(e[1])==="$type"&&h.push(new ze(r,e,`"$type" cannot be use with operator "${e[0]}"`));case"==":case"!=":e.length!==3&&h.push(new ze(r,e,`filter array for operator "${e[0]}" must have 3 elements`));case"in":case"!in":e.length>=2&&(l=Ut(e[1]),l!=="string"&&h.push(new ze(`${r}[1]`,e[1],`string expected, ${l} found`)));for(let p=2;p{x in r&&e.push(new ze(o,r[x],`"${x}" is prohibited for ref layers`))}),l.layers.forEach(x=>{yi(x.id)===m&&(_=x)}),_?_.ref?e.push(new ze(o,r.ref,"ref cannot reference another ref layer")):p=yi(_.type):e.push(new ze(o,r.ref,`ref layer "${m}" not found`))}else if(p!=="background")if(r.source){const _=l.sources&&l.sources[r.source],x=_&&yi(_.type);_?x==="vector"&&p==="raster"?e.push(new ze(o,r.source,`layer "${r.id}" requires a raster source`)):x!=="raster-dem"&&p==="hillshade"?e.push(new ze(o,r.source,`layer "${r.id}" requires a raster-dem source`)):x==="raster"&&p!=="raster"?e.push(new ze(o,r.source,`layer "${r.id}" requires a vector source`)):x!=="vector"||r["source-layer"]?x==="raster-dem"&&p!=="hillshade"?e.push(new ze(o,r.source,"raster-dem source can only be used with layer type 'hillshade'.")):p!=="line"||!r.paint||!r.paint["line-gradient"]||x==="geojson"&&_.lineMetrics||e.push(new ze(o,r,`layer "${r.id}" specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.`)):e.push(new ze(o,r,`layer "${r.id}" must specify a "source-layer"`)):e.push(new ze(o,r.source,`source "${r.source}" not found`))}else e.push(new ze(o,r,'missing required property "source"'));return e=e.concat(Ki({key:o,value:r,valueSpec:h.layer,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,objectElementValidators:{"*":()=>[],type:()=>i.validateSpec({key:`${o}.type`,value:r.type,valueSpec:h.layer.type,style:i.style,styleSpec:i.styleSpec,validateSpec:i.validateSpec,object:r,objectKey:"type"}),filter:ct,layout:_=>Ki({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>Li(ar({layerType:p},x))}}),paint:_=>Ki({layer:r,key:_.key,value:_.value,style:_.style,styleSpec:_.styleSpec,validateSpec:_.validateSpec,objectElementValidators:{"*":x=>_i(ar({layerType:p},x))}})}})),e}function hi(i){const e=i.value,r=i.key,o=Ut(e);return o!=="string"?[new ze(r,e,`string expected, ${o} found`)]:[]}const qi={promoteId:function({key:i,value:e}){if(Ut(e)==="string")return hi({key:i,value:e});{const r=[];for(const o in e)r.push(...hi({key:`${i}.${o}`,value:e[o]}));return r}}};function gn(i){const e=i.value,r=i.key,o=i.styleSpec,l=i.style,h=i.validateSpec;if(!e.type)return[new ze(r,e,'"type" is required')];const p=yi(e.type);let m;switch(p){case"vector":case"raster":return m=Ki({key:r,value:e,valueSpec:o[`source_${p.replace("-","_")}`],style:i.style,styleSpec:o,objectElementValidators:qi,validateSpec:h}),m;case"raster-dem":return m=function(_){var x;const T=(x=_.sourceName)!==null&&x!==void 0?x:"",E=_.value,k=_.styleSpec,R=k.source_raster_dem,B=_.style;let V=[];const q=Ut(E);if(E===void 0)return V;if(q!=="object")return V.push(new ze("source_raster_dem",E,`object expected, ${q} found`)),V;const J=yi(E.encoding)==="custom",pe=["redFactor","greenFactor","blueFactor","baseShift"],Y=_.value.encoding?`"${_.value.encoding}"`:"Default";for(const se in E)!J&&pe.includes(se)?V.push(new ze(se,E[se],`In "${T}": "${se}" is only valid when "encoding" is set to "custom". ${Y} encoding found`)):R[se]?V=V.concat(_.validateSpec({key:se,value:E[se],valueSpec:R[se],validateSpec:_.validateSpec,style:B,styleSpec:k})):V.push(new ze(se,E[se],`unknown property "${se}"`));return V}({sourceName:r,value:e,style:i.style,styleSpec:o,validateSpec:h}),m;case"geojson":if(m=Ki({key:r,value:e,valueSpec:o.source_geojson,style:l,styleSpec:o,validateSpec:h,objectElementValidators:qi}),e.cluster)for(const _ in e.clusterProperties){const[x,T]=e.clusterProperties[_],E=typeof x=="string"?[x,["accumulated"],["get",_]]:x;m.push(..._e({key:`${r}.${_}.map`,value:T,validateSpec:h,expressionContext:"cluster-map"})),m.push(..._e({key:`${r}.${_}.reduce`,value:E,validateSpec:h,expressionContext:"cluster-reduce"}))}return m;case"video":return Ki({key:r,value:e,valueSpec:o.source_video,style:l,validateSpec:h,styleSpec:o});case"image":return Ki({key:r,value:e,valueSpec:o.source_image,style:l,validateSpec:h,styleSpec:o});case"canvas":return[new ze(r,null,"Please use runtime APIs to add canvas sources, rather than including them in stylesheets.","source.canvas")];default:return je({key:`${r}.type`,value:e.type,valueSpec:{values:["vector","raster","raster-dem","geojson","video","image"]},style:l,validateSpec:h,styleSpec:o})}}function kn(i){const e=i.value,r=i.styleSpec,o=r.light,l=i.style;let h=[];const p=Ut(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new ze("light",e,`object expected, ${p} found`)]),h;for(const m in e){const _=m.match(/^(.*)-transition$/);h=h.concat(_&&o[_[1]]&&o[_[1]].transition?i.validateSpec({key:m,value:e[m],valueSpec:r.transition,validateSpec:i.validateSpec,style:l,styleSpec:r}):o[m]?i.validateSpec({key:m,value:e[m],valueSpec:o[m],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ze(m,e[m],`unknown property "${m}"`)])}return h}function Ir(i){const e=i.value,r=i.styleSpec,o=r.sky,l=i.style,h=Ut(e);if(e===void 0)return[];if(h!=="object")return[new ze("sky",e,`object expected, ${h} found`)];let p=[];for(const m in e)p=p.concat(o[m]?Lr({key:m,value:e[m],valueSpec:o[m],style:l,styleSpec:r}):[new ze(m,e[m],`unknown property "${m}"`)]);return p}function $r(i){const e=i.value,r=i.styleSpec,o=r.terrain,l=i.style;let h=[];const p=Ut(e);if(e===void 0)return h;if(p!=="object")return h=h.concat([new ze("terrain",e,`object expected, ${p} found`)]),h;for(const m in e)h=h.concat(o[m]?i.validateSpec({key:m,value:e[m],valueSpec:o[m],validateSpec:i.validateSpec,style:l,styleSpec:r}):[new ze(m,e[m],`unknown property "${m}"`)]);return h}function Ln(i){let e=[];const r=i.value,o=i.key;if(Array.isArray(r)){const l=[],h=[];for(const p in r)r[p].id&&l.includes(r[p].id)&&e.push(new ze(o,r,`all the sprites' ids must be unique, but ${r[p].id} is duplicated`)),l.push(r[p].id),r[p].url&&h.includes(r[p].url)&&e.push(new ze(o,r,`all the sprites' URLs must be unique, but ${r[p].url} is duplicated`)),h.push(r[p].url),e=e.concat(Ki({key:`${o}[${p}]`,value:r[p],valueSpec:{id:{type:"string",required:!0},url:{type:"string",required:!0}},validateSpec:i.validateSpec}));return e}return hi({key:o,value:r})}const cr={"*":()=>[],array:Ps,boolean:function(i){const e=i.value,r=i.key,o=Ut(e);return o!=="boolean"?[new ze(r,e,`boolean expected, ${o} found`)]:[]},number:ks,color:function(i){const e=i.key,r=i.value,o=Ut(r);return o!=="string"?[new ze(e,r,`color expected, ${o} found`)]:Jt.parse(String(r))?[]:[new ze(e,r,`color expected, "${r}" found`)]},constants:Ys,enum:je,filter:ct,function:he,layer:kr,object:Ki,source:gn,light:kn,sky:Ir,terrain:$r,string:hi,formatted:function(i){return hi(i).length===0?[]:_e(i)},resolvedImage:function(i){return hi(i).length===0?[]:_e(i)},padding:function(i){const e=i.key,r=i.value;if(Ut(r)==="array"){if(r.length<1||r.length>4)return[new ze(e,r,`padding requires 1 to 4 values; ${r.length} values found`)];const o={type:"number"};let l=[];for(let h=0;h[]}})),i.constants&&(r=r.concat(Ys({key:"constants",value:i.constants,style:i,styleSpec:e,validateSpec:Lr}))),Bo(r)}function zn(i){return function(e){return i({...e,validateSpec:Lr})}}function Bo(i){return[].concat(i).sort((e,r)=>e.line-r.line)}function Nt(i){return function(...e){return Bo(i.apply(this,e))}}rn.source=Nt(zn(gn)),rn.sprite=Nt(zn(Ln)),rn.glyphs=Nt(zn(Io)),rn.light=Nt(zn(kn)),rn.sky=Nt(zn(Ir)),rn.terrain=Nt(zn($r)),rn.layer=Nt(zn(kr)),rn.filter=Nt(zn(ct)),rn.paintProperty=Nt(zn(_i)),rn.layoutProperty=Nt(zn(Li));const qt=rn,Ls=qt.light,Dn=qt.paintProperty,Qs=qt.layoutProperty;function ur(i,e){let r=!1;if(e&&e.length)for(const o of e)i.fire(new Jr(new Error(o.message))),r=!0;return r}class Gr{constructor(e,r,o){const l=this.cells=[];if(e instanceof ArrayBuffer){this.arrayBuffer=e;const p=new Int32Array(this.arrayBuffer);e=p[0],this.d=(r=p[1])+2*(o=p[2]);for(let _=0;_=E[B+0]&&l>=E[B+1])?(m[R]=!0,p.push(T[R])):m[R]=!1}}}}_forEachCell(e,r,o,l,h,p,m,_){const x=this._convertToCellCoord(e),T=this._convertToCellCoord(r),E=this._convertToCellCoord(o),k=this._convertToCellCoord(l);for(let R=x;R<=E;R++)for(let B=T;B<=k;B++){const V=this.d*B+R;if((!_||_(this._convertFromCellCoord(R),this._convertFromCellCoord(B),this._convertFromCellCoord(R+1),this._convertFromCellCoord(B+1)))&&h.call(this,e,r,o,l,V,p,m,_))return}}_convertFromCellCoord(e){return(e-this.padding)/this.scale}_convertToCellCoord(e){return Math.max(0,Math.min(this.d-1,Math.floor(e*this.scale)+this.padding))}toArrayBuffer(){if(this.arrayBuffer)return this.arrayBuffer;const e=this.cells,r=3+this.cells.length+1+1;let o=0;for(let p=0;p=0)continue;const p=i[h];l[h]=hr[o].shallow.indexOf(h)>=0?p:yn(p,e)}i instanceof Error&&(l.message=i.message)}if(l.$name)throw new Error("$name property is reserved for worker serialization logic.");return o!=="Object"&&(l.$name=o),l}throw new Error("can't serialize object of type "+typeof i)}function nn(i){if(i==null||typeof i=="boolean"||typeof i=="number"||typeof i=="string"||i instanceof Boolean||i instanceof Number||i instanceof String||i instanceof Date||i instanceof RegExp||i instanceof Blob||i instanceof Error||So(i)||hn(i)||ArrayBuffer.isView(i)||i instanceof ImageData)return i;if(Array.isArray(i))return i.map(nn);if(typeof i=="object"){const e=i.$name||"Object";if(!hr[e])throw new Error(`can't deserialize unregistered class ${e}`);const{klass:r}=hr[e];if(!r)throw new Error(`can't deserialize unregistered class ${e}`);if(r.deserialize)return r.deserialize(i);const o=Object.create(r.prototype);for(const l of Object.keys(i)){if(l==="$name")continue;const h=i[l];o[l]=hr[e].shallow.indexOf(l)>=0?h:nn(h)}return o}throw new Error("can't deserialize object of type "+typeof i)}class ea{constructor(){this.first=!0}update(e,r){const o=Math.floor(e);return this.first?(this.first=!1,this.lastIntegerZoom=o,this.lastIntegerZoomTime=0,this.lastZoom=e,this.lastFloorZoom=o,!0):(this.lastFloorZoom>o?(this.lastIntegerZoom=o+1,this.lastIntegerZoomTime=r):this.lastFloorZoomi>=128&&i<=255,Arabic:i=>i>=1536&&i<=1791,"Arabic Supplement":i=>i>=1872&&i<=1919,"Arabic Extended-A":i=>i>=2208&&i<=2303,"Hangul Jamo":i=>i>=4352&&i<=4607,"Unified Canadian Aboriginal Syllabics":i=>i>=5120&&i<=5759,Khmer:i=>i>=6016&&i<=6143,"Unified Canadian Aboriginal Syllabics Extended":i=>i>=6320&&i<=6399,"General Punctuation":i=>i>=8192&&i<=8303,"Letterlike Symbols":i=>i>=8448&&i<=8527,"Number Forms":i=>i>=8528&&i<=8591,"Miscellaneous Technical":i=>i>=8960&&i<=9215,"Control Pictures":i=>i>=9216&&i<=9279,"Optical Character Recognition":i=>i>=9280&&i<=9311,"Enclosed Alphanumerics":i=>i>=9312&&i<=9471,"Geometric Shapes":i=>i>=9632&&i<=9727,"Miscellaneous Symbols":i=>i>=9728&&i<=9983,"Miscellaneous Symbols and Arrows":i=>i>=11008&&i<=11263,"CJK Radicals Supplement":i=>i>=11904&&i<=12031,"Kangxi Radicals":i=>i>=12032&&i<=12255,"Ideographic Description Characters":i=>i>=12272&&i<=12287,"CJK Symbols and Punctuation":i=>i>=12288&&i<=12351,Hiragana:i=>i>=12352&&i<=12447,Katakana:i=>i>=12448&&i<=12543,Bopomofo:i=>i>=12544&&i<=12591,"Hangul Compatibility Jamo":i=>i>=12592&&i<=12687,Kanbun:i=>i>=12688&&i<=12703,"Bopomofo Extended":i=>i>=12704&&i<=12735,"CJK Strokes":i=>i>=12736&&i<=12783,"Katakana Phonetic Extensions":i=>i>=12784&&i<=12799,"Enclosed CJK Letters and Months":i=>i>=12800&&i<=13055,"CJK Compatibility":i=>i>=13056&&i<=13311,"CJK Unified Ideographs Extension A":i=>i>=13312&&i<=19903,"Yijing Hexagram Symbols":i=>i>=19904&&i<=19967,"CJK Unified Ideographs":i=>i>=19968&&i<=40959,"Yi Syllables":i=>i>=40960&&i<=42127,"Yi Radicals":i=>i>=42128&&i<=42191,"Hangul Jamo Extended-A":i=>i>=43360&&i<=43391,"Hangul Syllables":i=>i>=44032&&i<=55215,"Hangul Jamo Extended-B":i=>i>=55216&&i<=55295,"Private Use Area":i=>i>=57344&&i<=63743,"CJK Compatibility Ideographs":i=>i>=63744&&i<=64255,"Arabic Presentation Forms-A":i=>i>=64336&&i<=65023,"Vertical Forms":i=>i>=65040&&i<=65055,"CJK Compatibility Forms":i=>i>=65072&&i<=65103,"Small Form Variants":i=>i>=65104&&i<=65135,"Arabic Presentation Forms-B":i=>i>=65136&&i<=65279,"Halfwidth and Fullwidth Forms":i=>i>=65280&&i<=65519};function co(i){for(const e of i)if(is(e.charCodeAt(0)))return!0;return!1}function es(i){for(const e of i)if(!ts(e.charCodeAt(0)))return!1;return!0}function ts(i){return!(Ze.Arabic(i)||Ze["Arabic Supplement"](i)||Ze["Arabic Extended-A"](i)||Ze["Arabic Presentation Forms-A"](i)||Ze["Arabic Presentation Forms-B"](i))}function is(i){return!(i!==746&&i!==747&&(i<4352||!(Ze["Bopomofo Extended"](i)||Ze.Bopomofo(i)||Ze["CJK Compatibility Forms"](i)&&!(i>=65097&&i<=65103)||Ze["CJK Compatibility Ideographs"](i)||Ze["CJK Compatibility"](i)||Ze["CJK Radicals Supplement"](i)||Ze["CJK Strokes"](i)||!(!Ze["CJK Symbols and Punctuation"](i)||i>=12296&&i<=12305||i>=12308&&i<=12319||i===12336)||Ze["CJK Unified Ideographs Extension A"](i)||Ze["CJK Unified Ideographs"](i)||Ze["Enclosed CJK Letters and Months"](i)||Ze["Hangul Compatibility Jamo"](i)||Ze["Hangul Jamo Extended-A"](i)||Ze["Hangul Jamo Extended-B"](i)||Ze["Hangul Jamo"](i)||Ze["Hangul Syllables"](i)||Ze.Hiragana(i)||Ze["Ideographic Description Characters"](i)||Ze.Kanbun(i)||Ze["Kangxi Radicals"](i)||Ze["Katakana Phonetic Extensions"](i)||Ze.Katakana(i)&&i!==12540||!(!Ze["Halfwidth and Fullwidth Forms"](i)||i===65288||i===65289||i===65293||i>=65306&&i<=65310||i===65339||i===65341||i===65343||i>=65371&&i<=65503||i===65507||i>=65512&&i<=65519)||!(!Ze["Small Form Variants"](i)||i>=65112&&i<=65118||i>=65123&&i<=65126)||Ze["Unified Canadian Aboriginal Syllabics"](i)||Ze["Unified Canadian Aboriginal Syllabics Extended"](i)||Ze["Vertical Forms"](i)||Ze["Yijing Hexagram Symbols"](i)||Ze["Yi Syllables"](i)||Ze["Yi Radicals"](i))))}function Oo(i){return!(is(i)||function(e){return!!(Ze["Latin-1 Supplement"](e)&&(e===167||e===169||e===174||e===177||e===188||e===189||e===190||e===215||e===247)||Ze["General Punctuation"](e)&&(e===8214||e===8224||e===8225||e===8240||e===8241||e===8251||e===8252||e===8258||e===8263||e===8264||e===8265||e===8273)||Ze["Letterlike Symbols"](e)||Ze["Number Forms"](e)||Ze["Miscellaneous Technical"](e)&&(e>=8960&&e<=8967||e>=8972&&e<=8991||e>=8996&&e<=9e3||e===9003||e>=9085&&e<=9114||e>=9150&&e<=9165||e===9167||e>=9169&&e<=9179||e>=9186&&e<=9215)||Ze["Control Pictures"](e)&&e!==9251||Ze["Optical Character Recognition"](e)||Ze["Enclosed Alphanumerics"](e)||Ze["Geometric Shapes"](e)||Ze["Miscellaneous Symbols"](e)&&!(e>=9754&&e<=9759)||Ze["Miscellaneous Symbols and Arrows"](e)&&(e>=11026&&e<=11055||e>=11088&&e<=11097||e>=11192&&e<=11243)||Ze["CJK Symbols and Punctuation"](e)||Ze.Katakana(e)||Ze["Private Use Area"](e)||Ze["CJK Compatibility Forms"](e)||Ze["Small Form Variants"](e)||Ze["Halfwidth and Fullwidth Forms"](e)||e===8734||e===8756||e===8757||e>=9984&&e<=10087||e>=10102&&e<=10131||e===65532||e===65533)}(i))}function To(i){return i>=1424&&i<=2303||Ze["Arabic Presentation Forms-A"](i)||Ze["Arabic Presentation Forms-B"](i)}function kl(i,e){return!(!e&&To(i)||i>=2304&&i<=3583||i>=3840&&i<=4255||Ze.Khmer(i))}function pc(i){for(const e of i)if(To(e.charCodeAt(0)))return!0;return!1}const No=new class{constructor(){this.applyArabicShaping=null,this.processBidirectionalText=null,this.processStyledBidirectionalText=null,this.pluginStatus="unavailable",this.pluginURL=null}setState(i){this.pluginStatus=i.pluginStatus,this.pluginURL=i.pluginURL}getState(){return{pluginStatus:this.pluginStatus,pluginURL:this.pluginURL}}setMethods(i){this.applyArabicShaping=i.applyArabicShaping,this.processBidirectionalText=i.processBidirectionalText,this.processStyledBidirectionalText=i.processStyledBidirectionalText}isParsed(){return this.applyArabicShaping!=null&&this.processBidirectionalText!=null&&this.processStyledBidirectionalText!=null}getPluginURL(){return this.pluginURL}getRTLTextPluginStatus(){return this.pluginStatus}};class Ei{constructor(e,r){this.zoom=e,r?(this.now=r.now,this.fadeDuration=r.fadeDuration,this.zoomHistory=r.zoomHistory,this.transition=r.transition):(this.now=0,this.fadeDuration=0,this.zoomHistory=new ea,this.transition={})}isSupportedScript(e){return function(r,o){for(const l of r)if(!kl(l.charCodeAt(0),o))return!1;return!0}(e,No.getRTLTextPluginStatus()==="loaded")}crossFadingFactor(){return this.fadeDuration===0?1:Math.min((this.now-this.zoomHistory.lastIntegerZoomTime)/this.fadeDuration,1)}getCrossfadeParameters(){const e=this.zoom,r=e-Math.floor(e),o=this.crossFadingFactor();return e>this.zoomHistory.lastIntegerZoom?{fromScale:2,toScale:1,t:r+(1-r)*o}:{fromScale:.5,toScale:1,t:1-(1-o)*r}}}class ta{constructor(e,r){this.property=e,this.value=r,this.expression=function(o,l){if(Ss(o))return new Es(o,l);if(ri(o)){const h=Hs(o,l);if(h.result==="error")throw new Error(h.value.map(p=>`${p.key}: ${p.message}`).join(", "));return h.value}{let h=o;return l.type==="color"&&typeof o=="string"?h=Jt.parse(o):l.type!=="padding"||typeof o!="number"&&!Array.isArray(o)?l.type==="variableAnchorOffsetCollection"&&Array.isArray(o)&&(h=Oi.parse(o)):h=Cr.parse(o),{kind:"constant",evaluate:()=>h}}}(r===void 0?e.specification.default:r,e.specification)}isDataDriven(){return this.expression.kind==="source"||this.expression.kind==="composite"}possiblyEvaluate(e,r,o){return this.property.possiblyEvaluate(this,e,r,o)}}class Ia{constructor(e){this.property=e,this.value=new ta(e,void 0)}transitioned(e,r){return new Ll(this.property,this.value,r,li({},e.transition,this.transition),e.now)}untransitioned(){return new Ll(this.property,this.value,null,{},0)}}class Ha{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitionablePropertyValues)}getValue(e){return St(this._values[e].value.value)}setValue(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ia(this._values[e].property)),this._values[e].value=new ta(this._values[e].property,r===null?void 0:St(r))}getTransition(e){return St(this._values[e].transition)}setTransition(e,r){Object.prototype.hasOwnProperty.call(this._values,e)||(this._values[e]=new Ia(this._values[e].property)),this._values[e].transition=St(r)||void 0}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o);const l=this.getTransition(r);l!==void 0&&(e[`${r}-transition`]=l)}return e}transitioned(e,r){const o=new zl(this._properties);for(const l of Object.keys(this._values))o._values[l]=this._values[l].transitioned(e,r._values[l]);return o}untransitioned(){const e=new zl(this._properties);for(const r of Object.keys(this._values))e._values[r]=this._values[r].untransitioned();return e}}class Ll{constructor(e,r,o,l,h){this.property=e,this.value=r,this.begin=h+l.delay||0,this.end=this.begin+l.duration||0,e.specification.transition&&(l.delay||l.duration)&&(this.prior=o)}possiblyEvaluate(e,r,o){const l=e.now||0,h=this.value.possiblyEvaluate(e,r,o),p=this.prior;if(p){if(l>this.end)return this.prior=null,h;if(this.value.isDataDriven())return this.prior=null,h;if(l=1)return 1;const x=_*_,T=x*_;return 4*(_<.5?T:3*(_-x)+T-.75)}(m))}}return h}}class zl{constructor(e){this._properties=e,this._values=Object.create(e.defaultTransitioningPropertyValues)}possiblyEvaluate(e,r,o){const l=new ia(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}hasTransition(){for(const e of Object.keys(this._values))if(this._values[e].prior)return!0;return!1}}class Dl{constructor(e){this._properties=e,this._values=Object.create(e.defaultPropertyValues)}hasValue(e){return this._values[e].value!==void 0}getValue(e){return St(this._values[e].value)}setValue(e,r){this._values[e]=new ta(this._values[e].property,r===null?void 0:St(r))}serialize(){const e={};for(const r of Object.keys(this._values)){const o=this.getValue(r);o!==void 0&&(e[r]=o)}return e}possiblyEvaluate(e,r,o){const l=new ia(this._properties);for(const h of Object.keys(this._values))l._values[h]=this._values[h].possiblyEvaluate(e,r,o);return l}}class Xn{constructor(e,r,o){this.property=e,this.value=r,this.parameters=o}isConstant(){return this.value.kind==="constant"}constantOr(e){return this.value.kind==="constant"?this.value.value:e}evaluate(e,r,o,l){return this.property.evaluate(this.value,this.parameters,e,r,o,l)}}class ia{constructor(e){this._properties=e,this._values=Object.create(e.defaultPossiblyEvaluatedValues)}get(e){return this._values[e]}}class at{constructor(e){this.specification=e}possiblyEvaluate(e,r){if(e.isDataDriven())throw new Error("Value should not be data driven");return e.expression.evaluate(r)}interpolate(e,r,o){const l=wr[this.specification.type];return l?l(e,r,o):e}}class dt{constructor(e,r){this.specification=e,this.overrides=r}possiblyEvaluate(e,r,o,l){return new Xn(this,e.expression.kind==="constant"||e.expression.kind==="camera"?{kind:"constant",value:e.expression.evaluate(r,null,{},o,l)}:e.expression,r)}interpolate(e,r,o){if(e.value.kind!=="constant"||r.value.kind!=="constant")return e;if(e.value.value===void 0||r.value.value===void 0)return new Xn(this,{kind:"constant",value:void 0},e.parameters);const l=wr[this.specification.type];if(l){const h=l(e.value.value,r.value.value,o);return new Xn(this,{kind:"constant",value:h},e.parameters)}return e}evaluate(e,r,o,l,h,p){return e.kind==="constant"?e.value:e.evaluate(r,o,l,h,p)}}class Sa extends dt{possiblyEvaluate(e,r,o,l){if(e.value===void 0)return new Xn(this,{kind:"constant",value:void 0},r);if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l),p=e.property.specification.type==="resolvedImage"&&typeof h!="string"?h.name:h,m=this._calculate(p,p,p,r);return new Xn(this,{kind:"constant",value:m},r)}if(e.expression.kind==="camera"){const h=this._calculate(e.expression.evaluate({zoom:r.zoom-1}),e.expression.evaluate({zoom:r.zoom}),e.expression.evaluate({zoom:r.zoom+1}),r);return new Xn(this,{kind:"constant",value:h},r)}return new Xn(this,e.expression,r)}evaluate(e,r,o,l,h,p){if(e.kind==="source"){const m=e.evaluate(r,o,l,h,p);return this._calculate(m,m,m,r)}return e.kind==="composite"?this._calculate(e.evaluate({zoom:Math.floor(r.zoom)-1},o,l),e.evaluate({zoom:Math.floor(r.zoom)},o,l),e.evaluate({zoom:Math.floor(r.zoom)+1},o,l),r):e.value}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class ra{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){if(e.value!==void 0){if(e.expression.kind==="constant"){const h=e.expression.evaluate(r,null,{},o,l);return this._calculate(h,h,h,r)}return this._calculate(e.expression.evaluate(new Ei(Math.floor(r.zoom-1),r)),e.expression.evaluate(new Ei(Math.floor(r.zoom),r)),e.expression.evaluate(new Ei(Math.floor(r.zoom+1),r)),r)}}_calculate(e,r,o,l){return l.zoom>l.zoomHistory.lastIntegerZoom?{from:e,to:r}:{from:o,to:r}}interpolate(e){return e}}class Wa{constructor(e){this.specification=e}possiblyEvaluate(e,r,o,l){return!!e.expression.evaluate(r,null,{},o,l)}interpolate(){return!1}}class on{constructor(e){this.properties=e,this.defaultPropertyValues={},this.defaultTransitionablePropertyValues={},this.defaultTransitioningPropertyValues={},this.defaultPossiblyEvaluatedValues={},this.overridableProperties=[];for(const r in e){const o=e[r];o.specification.overridable&&this.overridableProperties.push(r);const l=this.defaultPropertyValues[r]=new ta(o,void 0),h=this.defaultTransitionablePropertyValues[r]=new Ia(o);this.defaultTransitioningPropertyValues[r]=h.untransitioned(),this.defaultPossiblyEvaluatedValues[r]=l.possiblyEvaluate({})}}}Ye("DataDrivenProperty",dt),Ye("DataConstantProperty",at),Ye("CrossFadedDataDrivenProperty",Sa),Ye("CrossFadedProperty",ra),Ye("ColorRampProperty",Wa);const Xa="-transition";class Jn extends Ot{constructor(e,r){if(super(),this.id=e.id,this.type=e.type,this._featureFilter={filter:()=>!0,needGeometry:!1},e.type!=="custom"&&(this.metadata=e.metadata,this.minzoom=e.minzoom,this.maxzoom=e.maxzoom,e.type!=="background"&&(this.source=e.source,this.sourceLayer=e["source-layer"],this.filter=e.filter),r.layout&&(this._unevaluatedLayout=new Dl(r.layout)),r.paint)){this._transitionablePaint=new Ha(r.paint);for(const o in e.paint)this.setPaintProperty(o,e.paint[o],{validate:!1});for(const o in e.layout)this.setLayoutProperty(o,e.layout[o],{validate:!1});this._transitioningPaint=this._transitionablePaint.untransitioned(),this.paint=new ia(r.paint)}}getCrossfadeParameters(){return this._crossfadeParameters}getLayoutProperty(e){return e==="visibility"?this.visibility:this._unevaluatedLayout.getValue(e)}setLayoutProperty(e,r,o={}){r!=null&&this._validate(Qs,`layers.${this.id}.layout.${e}`,e,r,o)||(e!=="visibility"?this._unevaluatedLayout.setValue(e,r):this.visibility=r)}getPaintProperty(e){return e.endsWith(Xa)?this._transitionablePaint.getTransition(e.slice(0,-11)):this._transitionablePaint.getValue(e)}setPaintProperty(e,r,o={}){if(r!=null&&this._validate(Dn,`layers.${this.id}.paint.${e}`,e,r,o))return!1;if(e.endsWith(Xa))return this._transitionablePaint.setTransition(e.slice(0,-11),r||void 0),!1;{const l=this._transitionablePaint._values[e],h=l.property.specification["property-type"]==="cross-faded-data-driven",p=l.value.isDataDriven(),m=l.value;this._transitionablePaint.setValue(e,r),this._handleSpecialPaintPropertyUpdate(e);const _=this._transitionablePaint._values[e].value;return _.isDataDriven()||p||h||this._handleOverridablePaintPropertyUpdate(e,m,_)}}_handleSpecialPaintPropertyUpdate(e){}_handleOverridablePaintPropertyUpdate(e,r,o){return!1}isHidden(e){return!!(this.minzoom&&e=this.maxzoom)||this.visibility==="none"}updateTransitions(e){this._transitioningPaint=this._transitionablePaint.transitioned(e,this._transitioningPaint)}hasTransition(){return this._transitioningPaint.hasTransition()}recalculate(e,r){e.getCrossfadeParameters&&(this._crossfadeParameters=e.getCrossfadeParameters()),this._unevaluatedLayout&&(this.layout=this._unevaluatedLayout.possiblyEvaluate(e,void 0,r)),this.paint=this._transitioningPaint.possiblyEvaluate(e,void 0,r)}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),Zt(e,(r,o)=>!(r===void 0||o==="layout"&&!Object.keys(r).length||o==="paint"&&!Object.keys(r).length))}_validate(e,r,o,l,h={}){return(!h||h.validate!==!1)&&ur(this,e.call(qt,{key:r,layerType:this.type,objectKey:o,value:l,styleSpec:be,style:{glyphs:!0,sprite:!0}}))}is3D(){return!1}isTileClipped(){return!1}hasOffscreenPass(){return!1}resize(){}isStateDependent(){for(const e in this.paint._values){const r=this.paint.get(e);if(r instanceof Xn&&An(r.property.specification)&&(r.value.kind==="source"||r.value.kind==="composite")&&r.value.isStateDependent)return!0}return!1}}const Rl={Int8:Int8Array,Uint8:Uint8Array,Int16:Int16Array,Uint16:Uint16Array,Int32:Int32Array,Uint32:Uint32Array,Float32:Float32Array};class na{constructor(e,r){this._structArray=e,this._pos1=r*this.size,this._pos2=this._pos1/2,this._pos4=this._pos1/4,this._pos8=this._pos1/8}}class Ui{constructor(){this.isTransferred=!1,this.capacity=-1,this.resize(0)}static serialize(e,r){return e._trim(),r&&(e.isTransferred=!0,r.push(e.arrayBuffer)),{length:e.length,arrayBuffer:e.arrayBuffer}}static deserialize(e){const r=Object.create(this.prototype);return r.arrayBuffer=e.arrayBuffer,r.length=e.length,r.capacity=e.arrayBuffer.byteLength/r.bytesPerElement,r._refreshViews(),r}_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 r=this.uint8;this._refreshViews(),r&&this.uint8.set(r)}}_refreshViews(){throw new Error("_refreshViews() must be implemented by each concrete StructArray layout")}}function Yi(i,e=1){let r=0,o=0;return{members:i.map(l=>{const h=Rl[l.type].BYTES_PER_ELEMENT,p=r=Fl(r,Math.max(e,h)),m=l.components||1;return o=Math.max(o,h),r+=h*m,{name:l.name,type:l.type,components:m,offset:p}}),size:Fl(r,Math.max(o,e)),alignment:e}}function Fl(i,e){return Math.ceil(i/e)*e}class oa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.int16[l+0]=r,this.int16[l+1]=o,e}}oa.prototype.bytesPerElement=4,Ye("StructArrayLayout2i4",oa);class Eo extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.int16[h+0]=r,this.int16[h+1]=o,this.int16[h+2]=l,e}}Eo.prototype.bytesPerElement=6,Ye("StructArrayLayout3i6",Eo);class Ja extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.int16[p+0]=r,this.int16[p+1]=o,this.int16[p+2]=l,this.int16[p+3]=h,e}}Ja.prototype.bytesPerElement=8,Ye("StructArrayLayout4i8",Ja);class Ka extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,m){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=o,this.int16[_+2]=l,this.int16[_+3]=h,this.int16[_+4]=p,this.int16[_+5]=m,e}}Ka.prototype.bytesPerElement=12,Ye("StructArrayLayout2i4i12",Ka);class Ya extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,m){const _=4*e,x=8*e;return this.int16[_+0]=r,this.int16[_+1]=o,this.uint8[x+4]=l,this.uint8[x+5]=h,this.uint8[x+6]=p,this.uint8[x+7]=m,e}}Ya.prototype.bytesPerElement=8,Ye("StructArrayLayout2i4ub8",Ya);class sa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.float32[l+0]=r,this.float32[l+1]=o,e}}sa.prototype.bytesPerElement=8,Ye("StructArrayLayout2f8",sa);class Ta extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,m,_,x,T){const E=this.length;return this.resize(E+1),this.emplace(E,e,r,o,l,h,p,m,_,x,T)}emplace(e,r,o,l,h,p,m,_,x,T,E){const k=10*e;return this.uint16[k+0]=r,this.uint16[k+1]=o,this.uint16[k+2]=l,this.uint16[k+3]=h,this.uint16[k+4]=p,this.uint16[k+5]=m,this.uint16[k+6]=_,this.uint16[k+7]=x,this.uint16[k+8]=T,this.uint16[k+9]=E,e}}Ta.prototype.bytesPerElement=20,Ye("StructArrayLayout10ui20",Ta);class Qa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,m,_,x,T,E,k){const R=this.length;return this.resize(R+1),this.emplace(R,e,r,o,l,h,p,m,_,x,T,E,k)}emplace(e,r,o,l,h,p,m,_,x,T,E,k,R){const B=12*e;return this.int16[B+0]=r,this.int16[B+1]=o,this.int16[B+2]=l,this.int16[B+3]=h,this.uint16[B+4]=p,this.uint16[B+5]=m,this.uint16[B+6]=_,this.uint16[B+7]=x,this.int16[B+8]=T,this.int16[B+9]=E,this.int16[B+10]=k,this.int16[B+11]=R,e}}Qa.prototype.bytesPerElement=24,Ye("StructArrayLayout4i4ui4i24",Qa);class el extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.float32[h+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}el.prototype.bytesPerElement=12,Ye("StructArrayLayout3f12",el);class Co extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint32[1*e+0]=r,e}}Co.prototype.bytesPerElement=4,Ye("StructArrayLayout1ul4",Co);class Ea extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,m,_,x){const T=this.length;return this.resize(T+1),this.emplace(T,e,r,o,l,h,p,m,_,x)}emplace(e,r,o,l,h,p,m,_,x,T){const E=10*e,k=5*e;return this.int16[E+0]=r,this.int16[E+1]=o,this.int16[E+2]=l,this.int16[E+3]=h,this.int16[E+4]=p,this.int16[E+5]=m,this.uint32[k+3]=_,this.uint16[E+8]=x,this.uint16[E+9]=T,e}}Ea.prototype.bytesPerElement=20,Ye("StructArrayLayout6i1ul2ui20",Ea);class aa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p){const m=this.length;return this.resize(m+1),this.emplace(m,e,r,o,l,h,p)}emplace(e,r,o,l,h,p,m){const _=6*e;return this.int16[_+0]=r,this.int16[_+1]=o,this.int16[_+2]=l,this.int16[_+3]=h,this.int16[_+4]=p,this.int16[_+5]=m,e}}aa.prototype.bytesPerElement=12,Ye("StructArrayLayout2i2i2i12",aa);class Ca extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h){const p=this.length;return this.resize(p+1),this.emplace(p,e,r,o,l,h)}emplace(e,r,o,l,h,p){const m=4*e,_=8*e;return this.float32[m+0]=r,this.float32[m+1]=o,this.float32[m+2]=l,this.int16[_+6]=h,this.int16[_+7]=p,e}}Ca.prototype.bytesPerElement=16,Ye("StructArrayLayout2f1f2i16",Ca);class la extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=12*e,m=3*e;return this.uint8[p+0]=r,this.uint8[p+1]=o,this.float32[m+1]=l,this.float32[m+2]=h,e}}la.prototype.bytesPerElement=12,Ye("StructArrayLayout2ub2f12",la);class Ma extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[h+0]=r,this.uint16[h+1]=o,this.uint16[h+2]=l,e}}Ma.prototype.bytesPerElement=6,Ye("StructArrayLayout3ui6",Ma);class zs extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J){const pe=this.length;return this.resize(pe+1),this.emplace(pe,e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J)}emplace(e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J,pe){const Y=24*e,se=12*e,Ie=48*e;return this.int16[Y+0]=r,this.int16[Y+1]=o,this.uint16[Y+2]=l,this.uint16[Y+3]=h,this.uint32[se+2]=p,this.uint32[se+3]=m,this.uint32[se+4]=_,this.uint16[Y+10]=x,this.uint16[Y+11]=T,this.uint16[Y+12]=E,this.float32[se+7]=k,this.float32[se+8]=R,this.uint8[Ie+36]=B,this.uint8[Ie+37]=V,this.uint8[Ie+38]=q,this.uint32[se+10]=J,this.int16[Y+22]=pe,e}}zs.prototype.bytesPerElement=48,Ye("StructArrayLayout2i2ui3ul3ui2f3ub1ul1i48",zs);class rs extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.int16=new Int16Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J,pe,Y,se,Ie,Me,Qe,nt,Ke,qe,Oe,tt){const Ge=this.length;return this.resize(Ge+1),this.emplace(Ge,e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J,pe,Y,se,Ie,Me,Qe,nt,Ke,qe,Oe,tt)}emplace(e,r,o,l,h,p,m,_,x,T,E,k,R,B,V,q,J,pe,Y,se,Ie,Me,Qe,nt,Ke,qe,Oe,tt,Ge){const Le=32*e,ht=16*e;return this.int16[Le+0]=r,this.int16[Le+1]=o,this.int16[Le+2]=l,this.int16[Le+3]=h,this.int16[Le+4]=p,this.int16[Le+5]=m,this.int16[Le+6]=_,this.int16[Le+7]=x,this.uint16[Le+8]=T,this.uint16[Le+9]=E,this.uint16[Le+10]=k,this.uint16[Le+11]=R,this.uint16[Le+12]=B,this.uint16[Le+13]=V,this.uint16[Le+14]=q,this.uint16[Le+15]=J,this.uint16[Le+16]=pe,this.uint16[Le+17]=Y,this.uint16[Le+18]=se,this.uint16[Le+19]=Ie,this.uint16[Le+20]=Me,this.uint16[Le+21]=Qe,this.uint16[Le+22]=nt,this.uint32[ht+12]=Ke,this.float32[ht+13]=qe,this.float32[ht+14]=Oe,this.uint16[Le+30]=tt,this.uint16[Le+31]=Ge,e}}rs.prototype.bytesPerElement=64,Ye("StructArrayLayout8i15ui1ul2f2ui64",rs);class Aa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.float32[1*e+0]=r,e}}Aa.prototype.bytesPerElement=4,Ye("StructArrayLayout1f4",Aa);class Pa extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=3*e;return this.uint16[6*e+0]=r,this.float32[h+1]=o,this.float32[h+2]=l,e}}Pa.prototype.bytesPerElement=12,Ye("StructArrayLayout1ui2f12",Pa);class ns extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint32=new Uint32Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r,o){const l=this.length;return this.resize(l+1),this.emplace(l,e,r,o)}emplace(e,r,o,l){const h=4*e;return this.uint32[2*e+0]=r,this.uint16[h+2]=o,this.uint16[h+3]=l,e}}ns.prototype.bytesPerElement=8,Ye("StructArrayLayout1ul2ui8",ns);class tl extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e,r){const o=this.length;return this.resize(o+1),this.emplace(o,e,r)}emplace(e,r,o){const l=2*e;return this.uint16[l+0]=r,this.uint16[l+1]=o,e}}tl.prototype.bytesPerElement=4,Ye("StructArrayLayout2ui4",tl);class il extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.uint16=new Uint16Array(this.arrayBuffer)}emplaceBack(e){const r=this.length;return this.resize(r+1),this.emplace(r,e)}emplace(e,r){return this.uint16[1*e+0]=r,e}}il.prototype.bytesPerElement=2,Ye("StructArrayLayout1ui2",il);class ka extends Ui{_refreshViews(){this.uint8=new Uint8Array(this.arrayBuffer),this.float32=new Float32Array(this.arrayBuffer)}emplaceBack(e,r,o,l){const h=this.length;return this.resize(h+1),this.emplace(h,e,r,o,l)}emplace(e,r,o,l,h){const p=4*e;return this.float32[p+0]=r,this.float32[p+1]=o,this.float32[p+2]=l,this.float32[p+3]=h,e}}ka.prototype.bytesPerElement=16,Ye("StructArrayLayout4f16",ka);class Bl extends na{get anchorPointX(){return this._structArray.int16[this._pos2+0]}get anchorPointY(){return this._structArray.int16[this._pos2+1]}get x1(){return this._structArray.int16[this._pos2+2]}get y1(){return this._structArray.int16[this._pos2+3]}get x2(){return this._structArray.int16[this._pos2+4]}get y2(){return this._structArray.int16[this._pos2+5]}get featureIndex(){return this._structArray.uint32[this._pos4+3]}get sourceLayerIndex(){return this._structArray.uint16[this._pos2+8]}get bucketIndex(){return this._structArray.uint16[this._pos2+9]}get anchorPoint(){return new ce(this.anchorPointX,this.anchorPointY)}}Bl.prototype.size=20;class c extends Ea{get(e){return new Bl(this,e)}}Ye("CollisionBoxArray",c);class t extends na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get glyphStartIndex(){return this._structArray.uint16[this._pos2+2]}get numGlyphs(){return this._structArray.uint16[this._pos2+3]}get vertexStartIndex(){return this._structArray.uint32[this._pos4+2]}get lineStartIndex(){return this._structArray.uint32[this._pos4+3]}get lineLength(){return this._structArray.uint32[this._pos4+4]}get segment(){return this._structArray.uint16[this._pos2+10]}get lowerSize(){return this._structArray.uint16[this._pos2+11]}get upperSize(){return this._structArray.uint16[this._pos2+12]}get lineOffsetX(){return this._structArray.float32[this._pos4+7]}get lineOffsetY(){return this._structArray.float32[this._pos4+8]}get writingMode(){return this._structArray.uint8[this._pos1+36]}get placedOrientation(){return this._structArray.uint8[this._pos1+37]}set placedOrientation(e){this._structArray.uint8[this._pos1+37]=e}get hidden(){return this._structArray.uint8[this._pos1+38]}set hidden(e){this._structArray.uint8[this._pos1+38]=e}get crossTileID(){return this._structArray.uint32[this._pos4+10]}set crossTileID(e){this._structArray.uint32[this._pos4+10]=e}get associatedIconIndex(){return this._structArray.int16[this._pos2+22]}}t.prototype.size=48;class n extends zs{get(e){return new t(this,e)}}Ye("PlacedSymbolArray",n);class s extends na{get anchorX(){return this._structArray.int16[this._pos2+0]}get anchorY(){return this._structArray.int16[this._pos2+1]}get rightJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+2]}get centerJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+3]}get leftJustifiedTextSymbolIndex(){return this._structArray.int16[this._pos2+4]}get verticalPlacedTextSymbolIndex(){return this._structArray.int16[this._pos2+5]}get placedIconSymbolIndex(){return this._structArray.int16[this._pos2+6]}get verticalPlacedIconSymbolIndex(){return this._structArray.int16[this._pos2+7]}get key(){return this._structArray.uint16[this._pos2+8]}get textBoxStartIndex(){return this._structArray.uint16[this._pos2+9]}get textBoxEndIndex(){return this._structArray.uint16[this._pos2+10]}get verticalTextBoxStartIndex(){return this._structArray.uint16[this._pos2+11]}get verticalTextBoxEndIndex(){return this._structArray.uint16[this._pos2+12]}get iconBoxStartIndex(){return this._structArray.uint16[this._pos2+13]}get iconBoxEndIndex(){return this._structArray.uint16[this._pos2+14]}get verticalIconBoxStartIndex(){return this._structArray.uint16[this._pos2+15]}get verticalIconBoxEndIndex(){return this._structArray.uint16[this._pos2+16]}get featureIndex(){return this._structArray.uint16[this._pos2+17]}get numHorizontalGlyphVertices(){return this._structArray.uint16[this._pos2+18]}get numVerticalGlyphVertices(){return this._structArray.uint16[this._pos2+19]}get numIconVertices(){return this._structArray.uint16[this._pos2+20]}get numVerticalIconVertices(){return this._structArray.uint16[this._pos2+21]}get useRuntimeCollisionCircles(){return this._structArray.uint16[this._pos2+22]}get crossTileID(){return this._structArray.uint32[this._pos4+12]}set crossTileID(e){this._structArray.uint32[this._pos4+12]=e}get textBoxScale(){return this._structArray.float32[this._pos4+13]}get collisionCircleDiameter(){return this._structArray.float32[this._pos4+14]}get textAnchorOffsetStartIndex(){return this._structArray.uint16[this._pos2+30]}get textAnchorOffsetEndIndex(){return this._structArray.uint16[this._pos2+31]}}s.prototype.size=64;class a extends rs{get(e){return new s(this,e)}}Ye("SymbolInstanceArray",a);class u extends Aa{getoffsetX(e){return this.float32[1*e+0]}}Ye("GlyphOffsetArray",u);class g extends Eo{getx(e){return this.int16[3*e+0]}gety(e){return this.int16[3*e+1]}gettileUnitDistanceFromAnchor(e){return this.int16[3*e+2]}}Ye("SymbolLineVertexArray",g);class y extends na{get textAnchor(){return this._structArray.uint16[this._pos2+0]}get textOffset0(){return this._structArray.float32[this._pos4+1]}get textOffset1(){return this._structArray.float32[this._pos4+2]}}y.prototype.size=12;class v extends Pa{get(e){return new y(this,e)}}Ye("TextAnchorOffsetArray",v);class S extends na{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]}}S.prototype.size=8;class C extends ns{get(e){return new S(this,e)}}Ye("FeatureIndexArray",C);class A extends oa{}class F extends oa{}class Z extends oa{}class $ extends Ka{}class H extends Ya{}class N extends sa{}class ee extends Ta{}class me extends Qa{}class X extends el{}class ae extends Co{}class ge extends aa{}class ye extends la{}class xe extends Ma{}class Pe extends tl{}const Ae=Yi([{name:"a_pos",components:2,type:"Int16"}],4),{members:Fe}=Ae;class Ne{constructor(e=[]){this.segments=e}prepareSegment(e,r,o,l){let h=this.segments[this.segments.length-1];return e>Ne.MAX_VERTEX_ARRAY_LENGTH&&pi(`Max vertices per segment is ${Ne.MAX_VERTEX_ARRAY_LENGTH}: bucket requested ${e}`),(!h||h.vertexLength+e>Ne.MAX_VERTEX_ARRAY_LENGTH||h.sortKey!==l)&&(h={vertexOffset:r.length,primitiveOffset:o.length,vertexLength:0,primitiveLength:0},l!==void 0&&(h.sortKey=l),this.segments.push(h)),h}get(){return this.segments}destroy(){for(const e of this.segments)for(const r in e.vaos)e.vaos[r].destroy()}static simpleSegment(e,r,o,l){return new Ne([{vertexOffset:e,primitiveOffset:r,vertexLength:o,primitiveLength:l,vaos:{},sortKey:0}])}}function Et(i,e){return 256*(i=Gt(Math.floor(i),0,255))+Gt(Math.floor(e),0,255)}Ne.MAX_VERTEX_ARRAY_LENGTH=Math.pow(2,16)-1,Ye("SegmentVector",Ne);const $e=Yi([{name:"a_pattern_from",components:4,type:"Uint16"},{name:"a_pattern_to",components:4,type:"Uint16"},{name:"a_pixel_ratio_from",components:1,type:"Uint16"},{name:"a_pixel_ratio_to",components:1,type:"Uint16"}]);var pt={exports:{}},Ct={exports:{}};Ct.exports=function(i,e){var r,o,l,h,p,m,_,x;for(o=i.length-(r=3&i.length),l=e,p=3432918353,m=461845907,x=0;x>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295)<<13|l>>>19))+((5*(l>>>16)&65535)<<16)&4294967295))+((58964+(h>>>16)&65535)<<16);switch(_=0,r){case 3:_^=(255&i.charCodeAt(x+2))<<16;case 2:_^=(255&i.charCodeAt(x+1))<<8;case 1:l^=_=(65535&(_=(_=(65535&(_^=255&i.charCodeAt(x)))*p+(((_>>>16)*p&65535)<<16)&4294967295)<<15|_>>>17))*m+(((_>>>16)*m&65535)<<16)&4294967295}return l^=i.length,l=2246822507*(65535&(l^=l>>>16))+((2246822507*(l>>>16)&65535)<<16)&4294967295,l=3266489909*(65535&(l^=l>>>13))+((3266489909*(l>>>16)&65535)<<16)&4294967295,(l^=l>>>16)>>>0};var jt=Ct.exports,vt={exports:{}};vt.exports=function(i,e){for(var r,o=i.length,l=e^o,h=0;o>=4;)r=1540483477*(65535&(r=255&i.charCodeAt(h)|(255&i.charCodeAt(++h))<<8|(255&i.charCodeAt(++h))<<16|(255&i.charCodeAt(++h))<<24))+((1540483477*(r>>>16)&65535)<<16),l=1540483477*(65535&l)+((1540483477*(l>>>16)&65535)<<16)^(r=1540483477*(65535&(r^=r>>>24))+((1540483477*(r>>>16)&65535)<<16)),o-=4,++h;switch(o){case 3:l^=(255&i.charCodeAt(h+2))<<16;case 2:l^=(255&i.charCodeAt(h+1))<<8;case 1:l=1540483477*(65535&(l^=255&i.charCodeAt(h)))+((1540483477*(l>>>16)&65535)<<16)}return l=1540483477*(65535&(l^=l>>>13))+((1540483477*(l>>>16)&65535)<<16),(l^=l>>>15)>>>0};var Pt=jt,Dt=vt.exports;pt.exports=Pt,pt.exports.murmur3=Pt,pt.exports.murmur2=Dt;var ji=Se(pt.exports);class ni{constructor(){this.ids=[],this.positions=[],this.indexed=!1}add(e,r,o,l){this.ids.push(_n(e)),this.positions.push(r,o,l)}getPositions(e){if(!this.indexed)throw new Error("Trying to get index, but feature positions are not indexed");const r=_n(e);let o=0,l=this.ids.length-1;for(;o>1;this.ids[p]>=r?l=p:o=p+1}const h=[];for(;this.ids[o]===r;)h.push({index:this.positions[3*o],start:this.positions[3*o+1],end:this.positions[3*o+2]}),o++;return h}static serialize(e,r){const o=new Float64Array(e.ids),l=new Uint32Array(e.positions);return dr(o,l,0,o.length-1),r&&r.push(o.buffer,l.buffer),{ids:o,positions:l}}static deserialize(e){const r=new ni;return r.ids=e.ids,r.positions=e.positions,r.indexed=!0,r}}function _n(i){const e=+i;return!isNaN(e)&&e<=Number.MAX_SAFE_INTEGER?e:ji(String(i))}function dr(i,e,r,o){for(;r>1];let h=r-1,p=o+1;for(;;){do h++;while(i[h]l);if(h>=p)break;zi(i,h,p),zi(e,3*h,3*p),zi(e,3*h+1,3*p+1),zi(e,3*h+2,3*p+2)}p-r`u_${l}`),this.type=o}setUniform(e,r,o){e.set(o.constantOr(this.value))}getBinding(e,r,o){return this.type==="color"?new Vo(e,r):new vn(e,r)}}class tr{constructor(e,r){this.uniformNames=r.map(o=>`u_${o}`),this.patternFrom=null,this.patternTo=null,this.pixelRatioFrom=1,this.pixelRatioTo=1}setConstantPatternPositions(e,r){this.pixelRatioFrom=r.pixelRatio,this.pixelRatioTo=e.pixelRatio,this.patternFrom=r.tlbr,this.patternTo=e.tlbr}setUniform(e,r,o,l){const h=l==="u_pattern_to"?this.patternTo:l==="u_pattern_from"?this.patternFrom:l==="u_pixel_ratio_to"?this.pixelRatioTo:l==="u_pixel_ratio_from"?this.pixelRatioFrom:null;h&&e.set(h)}getBinding(e,r,o){return o.substr(0,9)==="u_pattern"?new uo(e,r):new vn(e,r)}}class Di{constructor(e,r,o,l){this.expression=e,this.type=o,this.maxValue=0,this.paintVertexAttributes=r.map(h=>({name:`a_${h}`,type:"Float32",components:o==="color"?2:1,offset:0})),this.paintVertexArray=new l}populatePaintArray(e,r,o,l,h){const p=this.paintVertexArray.length,m=this.expression.evaluate(new Ei(0),r,{},l,[],h);this.paintVertexArray.resize(e),this._setPaintValue(p,e,m)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:0},o,l);this._setPaintValue(e,r,h)}_setPaintValue(e,r,o){if(this.type==="color"){const l=Uo(o);for(let h=e;h`u_${m}_t`),this.type=o,this.useIntegerZoom=l,this.zoom=h,this.maxValue=0,this.paintVertexAttributes=r.map(m=>({name:`a_${m}`,type:"Float32",components:o==="color"?4:2,offset:0})),this.paintVertexArray=new p}populatePaintArray(e,r,o,l,h){const p=this.expression.evaluate(new Ei(this.zoom),r,{},l,[],h),m=this.expression.evaluate(new Ei(this.zoom+1),r,{},l,[],h),_=this.paintVertexArray.length;this.paintVertexArray.resize(e),this._setPaintValue(_,e,p,m)}updatePaintArray(e,r,o,l){const h=this.expression.evaluate({zoom:this.zoom},o,l),p=this.expression.evaluate({zoom:this.zoom+1},o,l);this._setPaintValue(e,r,h,p)}_setPaintValue(e,r,o,l){if(this.type==="color"){const h=Uo(o),p=Uo(l);for(let m=e;m`#define HAS_UNIFORM_${l}`))}return e}getBinderAttributes(){const e=[];for(const r in this.binders){const o=this.binders[r];if(o instanceof Di||o instanceof Ci)for(let l=0;l!0){this.programConfigurations={};for(const l of e)this.programConfigurations[l.id]=new ir(l,r,o);this.needsUpload=!1,this._featureMap=new ni,this._bufferOffset=0}populatePaintArrays(e,r,o,l,h,p){for(const m in this.programConfigurations)this.programConfigurations[m].populatePaintArrays(e,r,l,h,p);r.id!==void 0&&this._featureMap.add(r.id,o,this._bufferOffset,e),this._bufferOffset=e,this.needsUpload=!0}updatePaintArrays(e,r,o,l){for(const h of o)this.needsUpload=this.programConfigurations[h.id].updatePaintArrays(e,this._featureMap,r,h,l)||this.needsUpload}get(e){return this.programConfigurations[e]}upload(e){if(this.needsUpload){for(const r in this.programConfigurations)this.programConfigurations[r].upload(e);this.needsUpload=!1}}destroy(){for(const e in this.programConfigurations)this.programConfigurations[e].destroy()}}function Fn(i,e){return{"text-opacity":["opacity"],"icon-opacity":["opacity"],"text-color":["fill_color"],"icon-color":["fill_color"],"text-halo-color":["halo_color"],"icon-halo-color":["halo_color"],"text-halo-blur":["halo_blur"],"icon-halo-blur":["halo_blur"],"text-halo-width":["halo_width"],"icon-halo-width":["halo_width"],"line-gap-width":["gapwidth"],"line-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"],"fill-extrusion-pattern":["pattern_to","pattern_from","pixel_ratio_to","pixel_ratio_from"]}[i]||[i.replace(`${e}-`,"").replace(/-/g,"_")]}function rr(i,e,r){const o={color:{source:sa,composite:ka},number:{source:Aa,composite:sa}},l=function(h){return{"line-pattern":{source:ee,composite:ee},"fill-pattern":{source:ee,composite:ee},"fill-extrusion-pattern":{source:ee,composite:ee}}[h]}(i);return l&&l[r]||o[e][r]}Ye("ConstantBinder",ho),Ye("CrossFadedConstantBinder",tr),Ye("SourceExpressionBinder",Di),Ye("CrossFadedCompositeBinder",Rn),Ye("CompositeExpressionBinder",Ci),Ye("ProgramConfiguration",ir,{omit:["_buffers"]}),Ye("ProgramConfigurationSet",Ri);const Hi=8192,rl=Math.pow(2,14)-1,Ol=-rl-1;function os(i){const e=Hi/i.extent,r=i.loadGeometry();for(let o=0;op.x+1||_p.y+1)&&pi("Geometry exceeds allowed extent, reduce your vector tile buffer size")}}return r}function ss(i,e){return{type:i.type,id:i.id,properties:i.properties,geometry:e?os(i):[]}}function La(i,e,r,o,l){i.emplaceBack(2*e+(o+1)/2,2*r+(l+1)/2)}class jo{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new F,this.indexArray=new xe,this.segments=new Ne,this.programConfigurations=new Ri(e.layers,e.zoom),this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){const l=this.layers[0],h=[];let p=null,m=!1;l.type==="circle"&&(p=l.layout.get("circle-sort-key"),m=!p.isConstant());for(const{feature:_,id:x,index:T,sourceLayerIndex:E}of e){const k=this.layers[0]._featureFilter.needGeometry,R=ss(_,k);if(!this.layers[0]._featureFilter.filter(new Ei(this.zoom),R,o))continue;const B=m?p.evaluate(R,{},o):void 0,V={id:x,properties:_.properties,type:_.type,sourceLayerIndex:E,index:T,geometry:k?R.geometry:os(_),patterns:{},sortKey:B};h.push(V)}m&&h.sort((_,x)=>_.sortKey-x.sortKey);for(const _ of h){const{geometry:x,index:T,sourceLayerIndex:E}=_,k=e[T].feature;this.addFeature(_,x,T,o),r.featureIndex.insert(k,x,T,E,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Fe),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())}addFeature(e,r,o,l){for(const h of r)for(const p of h){const m=p.x,_=p.y;if(m<0||m>=Hi||_<0||_>=Hi)continue;const x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray,e.sortKey),T=x.vertexLength;La(this.layoutVertexArray,m,_,-1,-1),La(this.layoutVertexArray,m,_,1,-1),La(this.layoutVertexArray,m,_,1,1),La(this.layoutVertexArray,m,_,-1,1),this.indexArray.emplaceBack(T,T+1,T+2),this.indexArray.emplaceBack(T,T+3,T+2),x.vertexLength+=4,x.primitiveLength+=2}this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,{},l)}}function nl(i,e){for(let r=0;r1){if(za(i,e))return!0;for(let o=0;o1?r:r.sub(e)._mult(l)._add(e))}function yu(i,e){let r,o,l,h=!1;for(let p=0;pe.y!=l.y>e.y&&e.x<(l.x-o.x)*(e.y-o.y)/(l.y-o.y)+o.x&&(h=!h)}return h}function Da(i,e){let r=!1;for(let o=0,l=i.length-1;oe.y!=p.y>e.y&&e.x<(p.x-h.x)*(e.y-h.y)/(p.y-h.y)+h.x&&(r=!r)}return r}function _d(i,e,r){const o=r[0],l=r[2];if(i.xl.x&&e.x>l.x||i.yl.y&&e.y>l.y)return!1;const h=fi(i,e,r[0]);return h!==fi(i,e,r[1])||h!==fi(i,e,r[2])||h!==fi(i,e,r[3])}function ll(i,e,r){const o=e.paint.get(i).value;return o.kind==="constant"?o.value:r.programConfigurations.get(e.id).getMaxValue(i)}function Vl(i){return Math.sqrt(i[0]*i[0]+i[1]*i[1])}function Ul(i,e,r,o,l){if(!e[0]&&!e[1])return i;const h=ce.convert(e)._mult(l);r==="viewport"&&h._rotate(-o);const p=[];for(let m=0;mbu(q,V))}(x,_),R=E?T*m:T;for(const B of l)for(const V of B){const q=E?V:bu(V,_);let J=R;const pe=jl([],[V.x,V.y,0,1],_);if(this.paint.get("circle-pitch-scale")==="viewport"&&this.paint.get("circle-pitch-alignment")==="map"?J*=pe[3]/p.cameraToCenterDistance:this.paint.get("circle-pitch-scale")==="map"&&this.paint.get("circle-pitch-alignment")==="viewport"&&(J*=p.cameraToCenterDistance/pe[3]),Nl(k,q,J))return!0}return!1}}function bu(i,e){const r=jl([],[i.x,i.y,0,1],e);return new ce(r[0]/r[3],r[1]/r[3])}class wu extends jo{}let Iu;Ye("HeatmapBucket",wu,{omit:["layers"]});var wd={get paint(){return Iu=Iu||new on({"heatmap-radius":new dt(be.paint_heatmap["heatmap-radius"]),"heatmap-weight":new dt(be.paint_heatmap["heatmap-weight"]),"heatmap-intensity":new at(be.paint_heatmap["heatmap-intensity"]),"heatmap-color":new Wa(be.paint_heatmap["heatmap-color"]),"heatmap-opacity":new at(be.paint_heatmap["heatmap-opacity"])})}};function gc(i,{width:e,height:r},o,l){if(l){if(l instanceof Uint8ClampedArray)l=new Uint8Array(l.buffer);else if(l.length!==e*r*o)throw new RangeError(`mismatched image size. expected: ${l.length} but got: ${e*r*o}`)}else l=new Uint8Array(e*r*o);return i.width=e,i.height=r,i.data=l,i}function Su(i,{width:e,height:r},o){if(e===i.width&&r===i.height)return;const l=gc({},{width:e,height:r},o);yc(i,l,{x:0,y:0},{x:0,y:0},{width:Math.min(i.width,e),height:Math.min(i.height,r)},o),i.width=e,i.height=r,i.data=l.data}function yc(i,e,r,o,l,h){if(l.width===0||l.height===0)return e;if(l.width>i.width||l.height>i.height||r.x>i.width-l.width||r.y>i.height-l.height)throw new RangeError("out of range source coordinates for image copy");if(l.width>e.width||l.height>e.height||o.x>e.width-l.width||o.y>e.height-l.height)throw new RangeError("out of range destination coordinates for image copy");const p=i.data,m=e.data;if(p===m)throw new Error("srcData equals dstData, so image is already copied");for(let _=0;_{e[i.evaluationKey]=_;const x=i.expression.evaluate(e);l.data[p+m+0]=Math.floor(255*x.r/x.a),l.data[p+m+1]=Math.floor(255*x.g/x.a),l.data[p+m+2]=Math.floor(255*x.b/x.a),l.data[p+m+3]=Math.floor(255*x.a)};if(i.clips)for(let p=0,m=0;p80*r){o=h=i[0],l=p=i[1];for(var B=r;Bh&&(h=m),_>p&&(p=_);x=(x=Math.max(h-o,p-l))!==0?32767/x:0}return hl(k,R,r,o,l,x,0),R}function Cu(i,e,r,o,l){var h,p;if(l===bc(i,e,r,o)>0)for(h=e;h=e;h-=o)p=Pu(h,i[h],i[h+1],p);return p&&Gl(p,p.next)&&(pl(p),p=p.next),p}function ua(i,e){if(!i)return i;e||(e=i);var r,o=i;do if(r=!1,o.steiner||!Gl(o,o.next)&&Qi(o.prev,o,o.next)!==0)o=o.next;else{if(pl(o),(o=e=o.prev)===o.next)break;r=!0}while(r||o!==e);return e}function hl(i,e,r,o,l,h,p){if(i){!p&&h&&function(T,E,k,R){var B=T;do B.z===0&&(B.z=vc(B.x,B.y,E,k,R)),B.prevZ=B.prev,B.nextZ=B.next,B=B.next;while(B!==T);B.prevZ.nextZ=null,B.prevZ=null,function(V){var q,J,pe,Y,se,Ie,Me,Qe,nt=1;do{for(J=V,V=null,se=null,Ie=0;J;){for(Ie++,pe=J,Me=0,q=0;q0||Qe>0&&pe;)Me!==0&&(Qe===0||!pe||J.z<=pe.z)?(Y=J,J=J.nextZ,Me--):(Y=pe,pe=pe.nextZ,Qe--),se?se.nextZ=Y:V=Y,Y.prevZ=se,se=Y;J=pe}se.nextZ=null,nt*=2}while(Ie>1)}(B)}(i,o,l,h);for(var m,_,x=i;i.prev!==i.next;)if(m=i.prev,_=i.next,h?Ad(i,o,l,h):Md(i))e.push(m.i/r|0),e.push(i.i/r|0),e.push(_.i/r|0),pl(i),i=_.next,x=_.next;else if((i=_)===x){p?p===1?hl(i=Pd(ua(i),e,r),e,r,o,l,h,2):p===2&&kd(i,e,r,o,l,h):hl(ua(i),e,r,o,l,h,1);break}}}function Md(i){var e=i.prev,r=i,o=i.next;if(Qi(e,r,o)>=0)return!1;for(var l=e.x,h=r.x,p=o.x,m=e.y,_=r.y,x=o.y,T=lh?l>p?l:p:h>p?h:p,R=m>_?m>x?m:x:_>x?_:x,B=o.next;B!==e;){if(B.x>=T&&B.x<=k&&B.y>=E&&B.y<=R&&Fa(l,m,h,_,p,x,B.x,B.y)&&Qi(B.prev,B,B.next)>=0)return!1;B=B.next}return!0}function Ad(i,e,r,o){var l=i.prev,h=i,p=i.next;if(Qi(l,h,p)>=0)return!1;for(var m=l.x,_=h.x,x=p.x,T=l.y,E=h.y,k=p.y,R=m<_?m_?m>x?m:x:_>x?_:x,q=T>E?T>k?T:k:E>k?E:k,J=vc(R,B,e,r,o),pe=vc(V,q,e,r,o),Y=i.prevZ,se=i.nextZ;Y&&Y.z>=J&&se&&se.z<=pe;){if(Y.x>=R&&Y.x<=V&&Y.y>=B&&Y.y<=q&&Y!==l&&Y!==p&&Fa(m,T,_,E,x,k,Y.x,Y.y)&&Qi(Y.prev,Y,Y.next)>=0||(Y=Y.prevZ,se.x>=R&&se.x<=V&&se.y>=B&&se.y<=q&&se!==l&&se!==p&&Fa(m,T,_,E,x,k,se.x,se.y)&&Qi(se.prev,se,se.next)>=0))return!1;se=se.nextZ}for(;Y&&Y.z>=J;){if(Y.x>=R&&Y.x<=V&&Y.y>=B&&Y.y<=q&&Y!==l&&Y!==p&&Fa(m,T,_,E,x,k,Y.x,Y.y)&&Qi(Y.prev,Y,Y.next)>=0)return!1;Y=Y.prevZ}for(;se&&se.z<=pe;){if(se.x>=R&&se.x<=V&&se.y>=B&&se.y<=q&&se!==l&&se!==p&&Fa(m,T,_,E,x,k,se.x,se.y)&&Qi(se.prev,se,se.next)>=0)return!1;se=se.nextZ}return!0}function Pd(i,e,r){var o=i;do{var l=o.prev,h=o.next.next;!Gl(l,h)&&Mu(l,o,o.next,h)&&dl(l,h)&&dl(h,l)&&(e.push(l.i/r|0),e.push(o.i/r|0),e.push(h.i/r|0),pl(o),pl(o.next),o=i=h),o=o.next}while(o!==i);return ua(o)}function kd(i,e,r,o,l,h){var p=i;do{for(var m=p.next.next;m!==p.prev;){if(p.i!==m.i&&Fd(p,m)){var _=Au(p,m);return p=ua(p,p.next),_=ua(_,_.next),hl(p,e,r,o,l,h,0),void hl(_,e,r,o,l,h,0)}m=m.next}p=p.next}while(p!==i)}function Ld(i,e){return i.x-e.x}function zd(i,e){var r=function(l,h){var p,m=h,_=l.x,x=l.y,T=-1/0;do{if(x<=m.y&&x>=m.next.y&&m.next.y!==m.y){var E=m.x+(x-m.y)*(m.next.x-m.x)/(m.next.y-m.y);if(E<=_&&E>T&&(T=E,p=m.x=m.x&&m.x>=B&&_!==m.x&&Fa(xp.x||m.x===p.x&&Dd(p,m)))&&(p=m,q=k)),m=m.next;while(m!==R);return p}(i,e);if(!r)return e;var o=Au(r,i);return ua(o,o.next),ua(r,r.next)}function Dd(i,e){return Qi(i.prev,i,e.prev)<0&&Qi(e.next,i,i.next)<0}function vc(i,e,r,o,l){return(i=1431655765&((i=858993459&((i=252645135&((i=16711935&((i=(i-r)*l|0)|i<<8))|i<<4))|i<<2))|i<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=(e-o)*l|0)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function Rd(i){var e=i,r=i;do(e.x=(i-p)*(h-m)&&(i-p)*(o-m)>=(r-p)*(e-m)&&(r-p)*(h-m)>=(l-p)*(o-m)}function Fd(i,e){return i.next.i!==e.i&&i.prev.i!==e.i&&!function(r,o){var l=r;do{if(l.i!==r.i&&l.next.i!==r.i&&l.i!==o.i&&l.next.i!==o.i&&Mu(l,l.next,r,o))return!0;l=l.next}while(l!==r);return!1}(i,e)&&(dl(i,e)&&dl(e,i)&&function(r,o){var l=r,h=!1,p=(r.x+o.x)/2,m=(r.y+o.y)/2;do l.y>m!=l.next.y>m&&l.next.y!==l.y&&p<(l.next.x-l.x)*(m-l.y)/(l.next.y-l.y)+l.x&&(h=!h),l=l.next;while(l!==r);return h}(i,e)&&(Qi(i.prev,i,e.prev)||Qi(i,e.prev,e))||Gl(i,e)&&Qi(i.prev,i,i.next)>0&&Qi(e.prev,e,e.next)>0)}function Qi(i,e,r){return(e.y-i.y)*(r.x-e.x)-(e.x-i.x)*(r.y-e.y)}function Gl(i,e){return i.x===e.x&&i.y===e.y}function Mu(i,e,r,o){var l=ql(Qi(i,e,r)),h=ql(Qi(i,e,o)),p=ql(Qi(r,o,i)),m=ql(Qi(r,o,e));return l!==h&&p!==m||!(l!==0||!Zl(i,r,e))||!(h!==0||!Zl(i,o,e))||!(p!==0||!Zl(r,i,o))||!(m!==0||!Zl(r,e,o))}function Zl(i,e,r){return e.x<=Math.max(i.x,r.x)&&e.x>=Math.min(i.x,r.x)&&e.y<=Math.max(i.y,r.y)&&e.y>=Math.min(i.y,r.y)}function ql(i){return i>0?1:i<0?-1:0}function dl(i,e){return Qi(i.prev,i,i.next)<0?Qi(i,e,i.next)>=0&&Qi(i,i.prev,e)>=0:Qi(i,e,i.prev)<0||Qi(i,i.next,e)<0}function Au(i,e){var r=new xc(i.i,i.x,i.y),o=new xc(e.i,e.x,e.y),l=i.next,h=e.prev;return i.next=e,e.prev=i,r.next=l,l.prev=r,o.next=r,r.prev=o,h.next=o,o.prev=h,o}function Pu(i,e,r,o){var l=new xc(i,e,r);return o?(l.next=o.next,l.prev=o,o.next.prev=l,o.next=l):(l.prev=l,l.next=l),l}function pl(i){i.next.prev=i.prev,i.prev.next=i.next,i.prevZ&&(i.prevZ.nextZ=i.nextZ),i.nextZ&&(i.nextZ.prevZ=i.prevZ)}function xc(i,e,r){this.i=i,this.x=e,this.y=r,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}function bc(i,e,r,o){for(var l=0,h=e,p=r-o;h0&&r.holes.push(o+=i[l-1].length)}return r};var ku=Se(_c.exports);function Bd(i,e,r,o,l){Lu(i,e,r||0,o||i.length-1,l||Od)}function Lu(i,e,r,o,l){for(;o>r;){if(o-r>600){var h=o-r+1,p=e-r+1,m=Math.log(h),_=.5*Math.exp(2*m/3),x=.5*Math.sqrt(m*_*(h-_)/h)*(p-h/2<0?-1:1);Lu(i,e,Math.max(r,Math.floor(e-p*_/h+x)),Math.min(o,Math.floor(e+(h-p)*_/h+x)),l)}var T=i[e],E=r,k=o;for(fl(i,r,e),l(i[o],T)>0&&fl(i,r,o);E0;)k--}l(i[r],T)===0?fl(i,r,k):fl(i,++k,o),k<=e&&(r=k+1),e<=k&&(o=k-1)}}function fl(i,e,r){var o=i[e];i[e]=i[r],i[r]=o}function Od(i,e){return ie?1:0}function wc(i,e){const r=i.length;if(r<=1)return[i];const o=[];let l,h;for(let p=0;p1)for(let p=0;pr.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.layoutVertexArray=new Z,this.indexArray=new xe,this.indexArray2=new Pe,this.programConfigurations=new Ri(e.layers,e.zoom),this.segments=new Ne,this.segments2=new Ne,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Ic("fill",this.layers,r);const l=this.layers[0].layout.get("fill-sort-key"),h=!l.isConstant(),p=[];for(const{feature:m,id:_,index:x,sourceLayerIndex:T}of e){const E=this.layers[0]._featureFilter.needGeometry,k=ss(m,E);if(!this.layers[0]._featureFilter.filter(new Ei(this.zoom),k,o))continue;const R=h?l.evaluate(k,{},o,r.availableImages):void 0,B={id:_,properties:m.properties,type:m.type,sourceLayerIndex:T,index:x,geometry:E?k.geometry:os(m),patterns:{},sortKey:R};p.push(B)}h&&p.sort((m,_)=>m.sortKey-_.sortKey);for(const m of p){const{geometry:_,index:x,sourceLayerIndex:T}=m;if(this.hasPattern){const E=Sc("fill",this.layers,m,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(m,_,x,o,{});r.featureIndex.insert(e[x].feature,_,x,T,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Cd),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,r,o,l,h){for(const p of wc(r,500)){let m=0;for(const R of p)m+=R.length;const _=this.segments.prepareSegment(m,this.layoutVertexArray,this.indexArray),x=_.vertexLength,T=[],E=[];for(const R of p){if(R.length===0)continue;R!==p[0]&&E.push(T.length/2);const B=this.segments2.prepareSegment(R.length,this.layoutVertexArray,this.indexArray2),V=B.vertexLength;this.layoutVertexArray.emplaceBack(R[0].x,R[0].y),this.indexArray2.emplaceBack(V+R.length-1,V),T.push(R[0].x),T.push(R[0].y);for(let q=1;q>3}if(l--,o===1||o===2)h+=i.readSVarint(),p+=i.readSVarint(),o===1&&(e&&m.push(e),e=[]),e.push(new Zd(h,p));else{if(o!==7)throw new Error("unknown command "+o);e&&e.push(e[0].clone())}}return e&&m.push(e),m},Ba.prototype.bbox=function(){var i=this._pbf;i.pos=this._geometry;for(var e=i.readVarint()+i.pos,r=1,o=0,l=0,h=0,p=1/0,m=-1/0,_=1/0,x=-1/0;i.pos>3}if(o--,r===1||r===2)(l+=i.readSVarint())m&&(m=l),(h+=i.readSVarint())<_&&(_=h),h>x&&(x=h);else if(r!==7)throw new Error("unknown command "+r)}return[p,_,m,x]},Ba.prototype.toGeoJSON=function(i,e,r){var o,l,h=this.extent*Math.pow(2,r),p=this.extent*i,m=this.extent*e,_=this.loadGeometry(),x=Ba.types[this.type];function T(R){for(var B=0;B>3;l=p===1?o.readString():p===2?o.readFloat():p===3?o.readDouble():p===4?o.readVarint64():p===5?o.readVarint():p===6?o.readSVarint():p===7?o.readBoolean():null}return l}(r))}Bu.prototype.feature=function(i){if(i<0||i>=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[i];var e=this._pbf.readVarint()+this._pbf.pos;return new Wd(this._pbf,e,this.extent,this._keys,this._values)};var Jd=Fu;function Kd(i,e,r){if(i===3){var o=new Jd(r,r.readVarint()+r.pos);o.length&&(e[o.name]=o)}}Ds.VectorTile=function(i,e){this.layers=i.readFields(Kd,{},e)},Ds.VectorTileFeature=Ru,Ds.VectorTileLayer=Fu;const Yd=Ds.VectorTileFeature.types,Ec=Math.pow(2,13);function ml(i,e,r,o,l,h,p,m){i.emplaceBack(e,r,2*Math.floor(o*Ec)+p,l*Ec*2,h*Ec*2,Math.round(m))}class Cc{constructor(e){this.zoom=e.zoom,this.overscaling=e.overscaling,this.layers=e.layers,this.layerIds=this.layers.map(r=>r.id),this.index=e.index,this.hasPattern=!1,this.layoutVertexArray=new $,this.centroidVertexArray=new A,this.indexArray=new xe,this.programConfigurations=new Ri(e.layers,e.zoom),this.segments=new Ne,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.features=[],this.hasPattern=Ic("fill-extrusion",this.layers,r);for(const{feature:l,id:h,index:p,sourceLayerIndex:m}of e){const _=this.layers[0]._featureFilter.needGeometry,x=ss(l,_);if(!this.layers[0]._featureFilter.filter(new Ei(this.zoom),x,o))continue;const T={id:h,sourceLayerIndex:m,index:p,geometry:_?x.geometry:os(l),properties:l.properties,type:l.type,patterns:{}};this.hasPattern?this.features.push(Sc("fill-extrusion",this.layers,T,this.zoom,r)):this.addFeature(T,T.geometry,p,o,{}),r.featureIndex.insert(l,T.geometry,p,m,this.index,!0)}}addFeatures(e,r,o){for(const l of this.features){const{geometry:h}=l;this.addFeature(l,h,l.index,r,o)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}isEmpty(){return this.layoutVertexArray.length===0&&this.centroidVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,Gd),this.centroidVertexBuffer=e.createVertexBuffer(this.centroidVertexArray,$d.members,!0),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(),this.centroidVertexBuffer.destroy())}addFeature(e,r,o,l,h){const p={x:0,y:0,vertexCount:0};for(const m of wc(r,500)){let _=0;for(const B of m)_+=B.length;let x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray);for(const B of m){if(B.length===0||ep(B))continue;let V=0;for(let q=0;q=1){const pe=B[q-1];if(!Qd(J,pe)){x.vertexLength+4>Ne.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(4,this.layoutVertexArray,this.indexArray));const Y=J.sub(pe)._perp()._unit(),se=pe.dist(J);V+se>32768&&(V=0),ml(this.layoutVertexArray,J.x,J.y,Y.x,Y.y,0,0,V),ml(this.layoutVertexArray,J.x,J.y,Y.x,Y.y,0,1,V),p.x+=2*J.x,p.y+=2*J.y,p.vertexCount+=2,V+=se,ml(this.layoutVertexArray,pe.x,pe.y,Y.x,Y.y,0,0,V),ml(this.layoutVertexArray,pe.x,pe.y,Y.x,Y.y,0,1,V),p.x+=2*pe.x,p.y+=2*pe.y,p.vertexCount+=2;const Ie=x.vertexLength;this.indexArray.emplaceBack(Ie,Ie+2,Ie+1),this.indexArray.emplaceBack(Ie+1,Ie+2,Ie+3),x.vertexLength+=4,x.primitiveLength+=2}}}}if(x.vertexLength+_>Ne.MAX_VERTEX_ARRAY_LENGTH&&(x=this.segments.prepareSegment(_,this.layoutVertexArray,this.indexArray)),Yd[e.type]!=="Polygon")continue;const T=[],E=[],k=x.vertexLength;for(const B of m)if(B.length!==0){B!==m[0]&&E.push(T.length/2);for(let V=0;VHi)||i.y===e.y&&(i.y<0||i.y>Hi)}function ep(i){return i.every(e=>e.x<0)||i.every(e=>e.x>Hi)||i.every(e=>e.y<0)||i.every(e=>e.y>Hi)}let Ou;Ye("FillExtrusionBucket",Cc,{omit:["layers","features"]});var tp={get paint(){return Ou=Ou||new on({"fill-extrusion-opacity":new at(be["paint_fill-extrusion"]["fill-extrusion-opacity"]),"fill-extrusion-color":new dt(be["paint_fill-extrusion"]["fill-extrusion-color"]),"fill-extrusion-translate":new at(be["paint_fill-extrusion"]["fill-extrusion-translate"]),"fill-extrusion-translate-anchor":new at(be["paint_fill-extrusion"]["fill-extrusion-translate-anchor"]),"fill-extrusion-pattern":new Sa(be["paint_fill-extrusion"]["fill-extrusion-pattern"]),"fill-extrusion-height":new dt(be["paint_fill-extrusion"]["fill-extrusion-height"]),"fill-extrusion-base":new dt(be["paint_fill-extrusion"]["fill-extrusion-base"]),"fill-extrusion-vertical-gradient":new at(be["paint_fill-extrusion"]["fill-extrusion-vertical-gradient"])})}};class ip extends Jn{constructor(e){super(e,tp)}createBucket(e){return new Cc(e)}queryRadius(){return Vl(this.paint.get("fill-extrusion-translate"))}is3D(){return!0}queryIntersectsFeature(e,r,o,l,h,p,m,_){const x=Ul(e,this.paint.get("fill-extrusion-translate"),this.paint.get("fill-extrusion-translate-anchor"),p.angle,m),T=this.paint.get("fill-extrusion-height").evaluate(r,o),E=this.paint.get("fill-extrusion-base").evaluate(r,o),k=function(B,V,q,J){const pe=[];for(const Y of B){const se=[Y.x,Y.y,0,1];jl(se,se,V),pe.push(new ce(se[0]/se[3],se[1]/se[3]))}return pe}(x,_),R=function(B,V,q,J){const pe=[],Y=[],se=J[8]*V,Ie=J[9]*V,Me=J[10]*V,Qe=J[11]*V,nt=J[8]*q,Ke=J[9]*q,qe=J[10]*q,Oe=J[11]*q;for(const tt of B){const Ge=[],Le=[];for(const ht of tt){const st=ht.x,Rt=ht.y,vi=J[0]*st+J[4]*Rt+J[12],Mi=J[1]*st+J[5]*Rt+J[13],mr=J[2]*st+J[6]*Rt+J[14],Bn=J[3]*st+J[7]*Rt+J[15],an=mr+Me,nr=Bn+Qe,zr=vi+nt,Br=Mi+Ke,ln=mr+qe,cn=Bn+Oe,gr=new ce((vi+se)/nr,(Mi+Ie)/nr);gr.z=an/nr,Ge.push(gr);const yr=new ce(zr/cn,Br/cn);yr.z=ln/cn,Le.push(yr)}pe.push(Ge),Y.push(Le)}return[pe,Y]}(l,E,T,_);return function(B,V,q){let J=1/0;ol(q,V)&&(J=Nu(q,V[0]));for(let pe=0;per.id),this.index=e.index,this.hasPattern=!1,this.patternFeatures=[],this.lineClipsArray=[],this.gradients={},this.layers.forEach(r=>{this.gradients[r.id]={}}),this.layoutVertexArray=new H,this.layoutVertexArray2=new N,this.indexArray=new xe,this.programConfigurations=new Ri(e.layers,e.zoom),this.segments=new Ne,this.maxLineLength=0,this.stateDependentLayerIds=this.layers.filter(r=>r.isStateDependent()).map(r=>r.id)}populate(e,r,o){this.hasPattern=Ic("line",this.layers,r);const l=this.layers[0].layout.get("line-sort-key"),h=!l.isConstant(),p=[];for(const{feature:m,id:_,index:x,sourceLayerIndex:T}of e){const E=this.layers[0]._featureFilter.needGeometry,k=ss(m,E);if(!this.layers[0]._featureFilter.filter(new Ei(this.zoom),k,o))continue;const R=h?l.evaluate(k,{},o):void 0,B={id:_,properties:m.properties,type:m.type,sourceLayerIndex:T,index:x,geometry:E?k.geometry:os(m),patterns:{},sortKey:R};p.push(B)}h&&p.sort((m,_)=>m.sortKey-_.sortKey);for(const m of p){const{geometry:_,index:x,sourceLayerIndex:T}=m;if(this.hasPattern){const E=Sc("line",this.layers,m,this.zoom,r);this.patternFeatures.push(E)}else this.addFeature(m,_,x,o,{});r.featureIndex.insert(e[x].feature,_,x,T,this.index)}}update(e,r,o){this.stateDependentLayers.length&&this.programConfigurations.updatePaintArrays(e,r,this.stateDependentLayers,o)}addFeatures(e,r,o){for(const l of this.patternFeatures)this.addFeature(l,l.geometry,l.index,r,o)}isEmpty(){return this.layoutVertexArray.length===0}uploadPending(){return!this.uploaded||this.programConfigurations.needsUpload}upload(e){this.uploaded||(this.layoutVertexArray2.length!==0&&(this.layoutVertexBuffer2=e.createVertexBuffer(this.layoutVertexArray2,sp)),this.layoutVertexBuffer=e.createVertexBuffer(this.layoutVertexArray,np),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&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_start")&&Object.prototype.hasOwnProperty.call(e.properties,"mapbox_clip_end"))return{start:+e.properties.mapbox_clip_start,end:+e.properties.mapbox_clip_end}}addFeature(e,r,o,l,h){const p=this.layers[0].layout,m=p.get("line-join").evaluate(e,{}),_=p.get("line-cap"),x=p.get("line-miter-limit"),T=p.get("line-round-limit");this.lineClips=this.lineFeatureClips(e);for(const E of r)this.addLine(E,e,m,_,x,T);this.programConfigurations.populatePaintArrays(this.layoutVertexArray.length,e,o,h,l)}addLine(e,r,o,l,h,p){if(this.distance=0,this.scaledDistance=0,this.totalDistance=0,this.lineClips){this.lineClipsArray.push(this.lineClips);for(let J=0;J=2&&e[_-1].equals(e[_-2]);)_--;let x=0;for(;x<_-1&&e[x].equals(e[x+1]);)x++;if(_<(m?3:2))return;o==="bevel"&&(h=1.05);const T=this.overscaling<=16?15*Hi/(512*this.overscaling):0,E=this.segments.prepareSegment(10*_,this.layoutVertexArray,this.indexArray);let k,R,B,V,q;this.e1=this.e2=-1,m&&(k=e[_-2],q=e[x].sub(k)._unit()._perp());for(let J=x;J<_;J++){if(B=J===_-1?m?e[x+1]:void 0:e[J+1],B&&e[J].equals(B))continue;q&&(V=q),k&&(R=k),k=e[J],q=B?B.sub(k)._unit()._perp():V,V=V||q;let pe=V.add(q);pe.x===0&&pe.y===0||pe._unit();const Y=V.x*q.x+V.y*q.y,se=pe.x*q.x+pe.y*q.y,Ie=se!==0?1/se:1/0,Me=2*Math.sqrt(2-2*se),Qe=se0;if(Qe&&J>x){const Oe=k.dist(R);if(Oe>2*T){const tt=k.sub(k.sub(R)._mult(T/Oe)._round());this.updateDistance(R,tt),this.addCurrentVertex(tt,V,0,0,E),R=tt}}const Ke=R&&B;let qe=Ke?o:m?"butt":l;if(Ke&&qe==="round"&&(Ieh&&(qe="bevel"),qe==="bevel"&&(Ie>2&&(qe="flipbevel"),Ie100)pe=q.mult(-1);else{const Oe=Ie*V.add(q).mag()/V.sub(q).mag();pe._perp()._mult(Oe*(nt?-1:1))}this.addCurrentVertex(k,pe,0,0,E),this.addCurrentVertex(k,pe.mult(-1),0,0,E)}else if(qe==="bevel"||qe==="fakeround"){const Oe=-Math.sqrt(Ie*Ie-1),tt=nt?Oe:0,Ge=nt?0:Oe;if(R&&this.addCurrentVertex(k,V,tt,Ge,E),qe==="fakeround"){const Le=Math.round(180*Me/Math.PI/20);for(let ht=1;ht2*T){const tt=k.add(B.sub(k)._mult(T/Oe)._round());this.updateDistance(k,tt),this.addCurrentVertex(tt,q,0,0,E),k=tt}}}}addCurrentVertex(e,r,o,l,h,p=!1){const m=r.y*l-r.x,_=-r.y-r.x*l;this.addHalfVertex(e,r.x+r.y*o,r.y-r.x*o,p,!1,o,h),this.addHalfVertex(e,m,_,p,!0,-l,h),this.distance>Vu/2&&this.totalDistance===0&&(this.distance=0,this.updateScaledDistance(),this.addCurrentVertex(e,r,o,l,h,p))}addHalfVertex({x:e,y:r},o,l,h,p,m,_){const x=.5*(this.lineClips?this.scaledDistance*(Vu-1):this.scaledDistance);this.layoutVertexArray.emplaceBack((e<<1)+(h?1:0),(r<<1)+(p?1:0),Math.round(63*o)+128,Math.round(63*l)+128,1+(m===0?0:m<0?-1:1)|(63&x)<<2,x>>6),this.lineClips&&this.layoutVertexArray2.emplaceBack((this.scaledDistance-this.lineClips.start)/(this.lineClips.end-this.lineClips.start),this.lineClipsArray.length);const T=_.vertexLength++;this.e1>=0&&this.e2>=0&&(this.indexArray.emplaceBack(this.e1,this.e2,T),_.primitiveLength++),p?this.e2=T:this.e1=T}updateScaledDistance(){this.scaledDistance=this.lineClips?this.lineClips.start+(this.lineClips.end-this.lineClips.start)*this.distance/this.totalDistance:this.distance}updateDistance(e,r){this.distance+=e.dist(r),this.updateScaledDistance()}}let Uu,ju;Ye("LineBucket",Mc,{omit:["layers","patternFeatures"]});var $u={get paint(){return ju=ju||new on({"line-opacity":new dt(be.paint_line["line-opacity"]),"line-color":new dt(be.paint_line["line-color"]),"line-translate":new at(be.paint_line["line-translate"]),"line-translate-anchor":new at(be.paint_line["line-translate-anchor"]),"line-width":new dt(be.paint_line["line-width"]),"line-gap-width":new dt(be.paint_line["line-gap-width"]),"line-offset":new dt(be.paint_line["line-offset"]),"line-blur":new dt(be.paint_line["line-blur"]),"line-dasharray":new ra(be.paint_line["line-dasharray"]),"line-pattern":new Sa(be.paint_line["line-pattern"]),"line-gradient":new Wa(be.paint_line["line-gradient"])})},get layout(){return Uu=Uu||new on({"line-cap":new at(be.layout_line["line-cap"]),"line-join":new dt(be.layout_line["line-join"]),"line-miter-limit":new at(be.layout_line["line-miter-limit"]),"line-round-limit":new at(be.layout_line["line-round-limit"]),"line-sort-key":new dt(be.layout_line["line-sort-key"])})}};class cp extends dt{possiblyEvaluate(e,r){return r=new Ei(Math.floor(r.zoom),{now:r.now,fadeDuration:r.fadeDuration,zoomHistory:r.zoomHistory,transition:r.transition}),super.possiblyEvaluate(e,r)}evaluate(e,r,o,l){return r=li({},r,{zoom:Math.floor(r.zoom)}),super.evaluate(e,r,o,l)}}let Hl;class up extends Jn{constructor(e){super(e,$u),this.gradientVersion=0,Hl||(Hl=new cp($u.paint.properties["line-width"].specification),Hl.useIntegerZoom=!0)}_handleSpecialPaintPropertyUpdate(e){if(e==="line-gradient"){const r=this.gradientExpression();this.stepInterpolant=!!function(o){return o._styleExpression!==void 0}(r)&&r._styleExpression.expression instanceof Lo,this.gradientVersion=(this.gradientVersion+1)%Number.MAX_SAFE_INTEGER}}gradientExpression(){return this._transitionablePaint._values["line-gradient"].value.expression}recalculate(e,r){super.recalculate(e,r),this.paint._values["line-floorwidth"]=Hl.possiblyEvaluate(this._transitioningPaint._values["line-width"].value,e)}createBucket(e){return new Mc(e)}queryRadius(e){const r=e,o=Gu(ll("line-width",this,r),ll("line-gap-width",this,r)),l=ll("line-offset",this,r);return o/2+Math.abs(l)+Vl(this.paint.get("line-translate"))}queryIntersectsFeature(e,r,o,l,h,p,m){const _=Ul(e,this.paint.get("line-translate"),this.paint.get("line-translate-anchor"),p.angle,m),x=m/2*Gu(this.paint.get("line-width").evaluate(r,o),this.paint.get("line-gap-width").evaluate(r,o)),T=this.paint.get("line-offset").evaluate(r,o);return T&&(l=function(E,k){const R=[];for(let B=0;B=3){for(let q=0;q0?e+2*i:i}const hp=Yi([{name:"a_pos_offset",components:4,type:"Int16"},{name:"a_data",components:4,type:"Uint16"},{name:"a_pixeloffset",components:4,type:"Int16"}],4),dp=Yi([{name:"a_projected_pos",components:3,type:"Float32"}],4);Yi([{name:"a_fade_opacity",components:1,type:"Uint32"}],4);const pp=Yi([{name:"a_placed",components:2,type:"Uint8"},{name:"a_shift",components:2,type:"Float32"}]);Yi([{type:"Int16",name:"anchorPointX"},{type:"Int16",name:"anchorPointY"},{type:"Int16",name:"x1"},{type:"Int16",name:"y1"},{type:"Int16",name:"x2"},{type:"Int16",name:"y2"},{type:"Uint32",name:"featureIndex"},{type:"Uint16",name:"sourceLayerIndex"},{type:"Uint16",name:"bucketIndex"}]);const Zu=Yi([{name:"a_pos",components:2,type:"Int16"},{name:"a_anchor_pos",components:2,type:"Int16"},{name:"a_extrude",components:2,type:"Int16"}],4),fp=Yi([{name:"a_pos",components:2,type:"Float32"},{name:"a_radius",components:1,type:"Float32"},{name:"a_flags",components:2,type:"Int16"}],4);function mp(i,e,r){return i.sections.forEach(o=>{o.text=function(l,h,p){const m=h.layout.get("text-transform").evaluate(p,{});return m==="uppercase"?l=l.toLocaleUpperCase():m==="lowercase"&&(l=l.toLocaleLowerCase()),No.applyArabicShaping&&(l=No.applyArabicShaping(l)),l}(o.text,e,r)}),i}Yi([{name:"triangle",components:3,type:"Uint16"}]),Yi([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Uint16",name:"glyphStartIndex"},{type:"Uint16",name:"numGlyphs"},{type:"Uint32",name:"vertexStartIndex"},{type:"Uint32",name:"lineStartIndex"},{type:"Uint32",name:"lineLength"},{type:"Uint16",name:"segment"},{type:"Uint16",name:"lowerSize"},{type:"Uint16",name:"upperSize"},{type:"Float32",name:"lineOffsetX"},{type:"Float32",name:"lineOffsetY"},{type:"Uint8",name:"writingMode"},{type:"Uint8",name:"placedOrientation"},{type:"Uint8",name:"hidden"},{type:"Uint32",name:"crossTileID"},{type:"Int16",name:"associatedIconIndex"}]),Yi([{type:"Int16",name:"anchorX"},{type:"Int16",name:"anchorY"},{type:"Int16",name:"rightJustifiedTextSymbolIndex"},{type:"Int16",name:"centerJustifiedTextSymbolIndex"},{type:"Int16",name:"leftJustifiedTextSymbolIndex"},{type:"Int16",name:"verticalPlacedTextSymbolIndex"},{type:"Int16",name:"placedIconSymbolIndex"},{type:"Int16",name:"verticalPlacedIconSymbolIndex"},{type:"Uint16",name:"key"},{type:"Uint16",name:"textBoxStartIndex"},{type:"Uint16",name:"textBoxEndIndex"},{type:"Uint16",name:"verticalTextBoxStartIndex"},{type:"Uint16",name:"verticalTextBoxEndIndex"},{type:"Uint16",name:"iconBoxStartIndex"},{type:"Uint16",name:"iconBoxEndIndex"},{type:"Uint16",name:"verticalIconBoxStartIndex"},{type:"Uint16",name:"verticalIconBoxEndIndex"},{type:"Uint16",name:"featureIndex"},{type:"Uint16",name:"numHorizontalGlyphVertices"},{type:"Uint16",name:"numVerticalGlyphVertices"},{type:"Uint16",name:"numIconVertices"},{type:"Uint16",name:"numVerticalIconVertices"},{type:"Uint16",name:"useRuntimeCollisionCircles"},{type:"Uint32",name:"crossTileID"},{type:"Float32",name:"textBoxScale"},{type:"Float32",name:"collisionCircleDiameter"},{type:"Uint16",name:"textAnchorOffsetStartIndex"},{type:"Uint16",name:"textAnchorOffsetEndIndex"}]),Yi([{type:"Float32",name:"offsetX"}]),Yi([{type:"Int16",name:"x"},{type:"Int16",name:"y"},{type:"Int16",name:"tileUnitDistanceFromAnchor"}]),Yi([{type:"Uint16",name:"textAnchor"},{type:"Float32",components:2,name:"textOffset"}]);const yl={"!":"︕","#":"#",$:"$","%":"%","&":"&","(":"︵",")":"︶","*":"*","+":"+",",":"︐","-":"︲",".":"・","/":"/",":":"︓",";":"︔","<":"︿","=":"=",">":"﹀","?":"︖","@":"@","[":"﹇","\\":"\","]":"﹈","^":"^",_:"︳","`":"`","{":"︷","|":"―","}":"︸","~":"~","¢":"¢","£":"£","¥":"¥","¦":"¦","¬":"¬","¯":" ̄","–":"︲","—":"︱","‘":"﹃","’":"﹄","“":"﹁","”":"﹂","…":"︙","‧":"・","₩":"₩","、":"︑","。":"︒","〈":"︿","〉":"﹀","《":"︽","》":"︾","「":"﹁","」":"﹂","『":"﹃","』":"﹄","【":"︻","】":"︼","〔":"︹","〕":"︺","〖":"︗","〗":"︘","!":"︕","(":"︵",")":"︶",",":"︐","-":"︲",".":"・",":":"︓",";":"︔","<":"︿",">":"﹀","?":"︖","[":"﹇","]":"﹈","_":"︳","{":"︷","|":"―","}":"︸","⦅":"︵","⦆":"︶","。":"︒","「":"﹁","」":"﹂"};var fr=24,qu=ai,Hu=function(i,e,r,o,l){var h,p,m=8*l-o-1,_=(1<>1,T=-7,E=r?l-1:0,k=r?-1:1,R=i[e+E];for(E+=k,h=R&(1<<-T)-1,R>>=-T,T+=m;T>0;h=256*h+i[e+E],E+=k,T-=8);for(p=h&(1<<-T)-1,h>>=-T,T+=o;T>0;p=256*p+i[e+E],E+=k,T-=8);if(h===0)h=1-x;else{if(h===_)return p?NaN:1/0*(R?-1:1);p+=Math.pow(2,o),h-=x}return(R?-1:1)*p*Math.pow(2,h-o)},Wu=function(i,e,r,o,l,h){var p,m,_,x=8*h-l-1,T=(1<>1,k=l===23?Math.pow(2,-24)-Math.pow(2,-77):0,R=o?0:h-1,B=o?1:-1,V=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(m=isNaN(e)?1:0,p=T):(p=Math.floor(Math.log(e)/Math.LN2),e*(_=Math.pow(2,-p))<1&&(p--,_*=2),(e+=p+E>=1?k/_:k*Math.pow(2,1-E))*_>=2&&(p++,_/=2),p+E>=T?(m=0,p=T):p+E>=1?(m=(e*_-1)*Math.pow(2,l),p+=E):(m=e*Math.pow(2,E-1)*Math.pow(2,l),p=0));l>=8;i[r+R]=255&m,R+=B,m/=256,l-=8);for(p=p<0;i[r+R]=255&p,R+=B,p/=256,x-=8);i[r+R-B]|=128*V};function ai(i){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(i)?i:new Uint8Array(i||0),this.pos=0,this.type=0,this.length=this.buf.length}ai.Varint=0,ai.Fixed64=1,ai.Bytes=2,ai.Fixed32=5;var Ac=4294967296,Xu=1/Ac,Ju=typeof TextDecoder>"u"?null:new TextDecoder("utf8");function as(i){return i.type===ai.Bytes?i.readVarint()+i.pos:i.pos+1}function Oa(i,e,r){return r?4294967296*e+(i>>>0):4294967296*(e>>>0)+(i>>>0)}function Ku(i,e,r){var o=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(7*Math.LN2));r.realloc(o);for(var l=r.pos-1;l>=i;l--)r.buf[l+o]=r.buf[l]}function gp(i,e){for(var r=0;r>>8,i[r+2]=e>>>16,i[r+3]=e>>>24}function Yu(i,e){return(i[e]|i[e+1]<<8|i[e+2]<<16)+(i[e+3]<<24)}ai.prototype={destroy:function(){this.buf=null},readFields:function(i,e,r){for(r=r||this.length;this.pos>3,h=this.pos;this.type=7&o,i(l,e,this),this.pos===h&&this.skip(o)}return e},readMessage:function(i,e){return this.readFields(i,e,this.readVarint()+this.pos)},readFixed32:function(){var i=Wl(this.buf,this.pos);return this.pos+=4,i},readSFixed32:function(){var i=Yu(this.buf,this.pos);return this.pos+=4,i},readFixed64:function(){var i=Wl(this.buf,this.pos)+Wl(this.buf,this.pos+4)*Ac;return this.pos+=8,i},readSFixed64:function(){var i=Wl(this.buf,this.pos)+Yu(this.buf,this.pos+4)*Ac;return this.pos+=8,i},readFloat:function(){var i=Hu(this.buf,this.pos,!0,23,4);return this.pos+=4,i},readDouble:function(){var i=Hu(this.buf,this.pos,!0,52,8);return this.pos+=8,i},readVarint:function(i){var e,r,o=this.buf;return e=127&(r=o[this.pos++]),r<128?e:(e|=(127&(r=o[this.pos++]))<<7,r<128?e:(e|=(127&(r=o[this.pos++]))<<14,r<128?e:(e|=(127&(r=o[this.pos++]))<<21,r<128?e:function(l,h,p){var m,_,x=p.buf;if(m=(112&(_=x[p.pos++]))>>4,_<128||(m|=(127&(_=x[p.pos++]))<<3,_<128)||(m|=(127&(_=x[p.pos++]))<<10,_<128)||(m|=(127&(_=x[p.pos++]))<<17,_<128)||(m|=(127&(_=x[p.pos++]))<<24,_<128)||(m|=(1&(_=x[p.pos++]))<<31,_<128))return Oa(l,m,h);throw new Error("Expected varint not more than 10 bytes")}(e|=(15&(r=o[this.pos]))<<28,i,this))))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var i=this.readVarint();return i%2==1?(i+1)/-2:i/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var i=this.readVarint()+this.pos,e=this.pos;return this.pos=i,i-e>=12&&Ju?function(r,o,l){return Ju.decode(r.subarray(o,l))}(this.buf,e,i):function(r,o,l){for(var h="",p=o;p239?4:T>223?3:T>191?2:1;if(p+k>l)break;k===1?T<128&&(E=T):k===2?(192&(m=r[p+1]))==128&&(E=(31&T)<<6|63&m)<=127&&(E=null):k===3?(_=r[p+2],(192&(m=r[p+1]))==128&&(192&_)==128&&((E=(15&T)<<12|(63&m)<<6|63&_)<=2047||E>=55296&&E<=57343)&&(E=null)):k===4&&(_=r[p+2],x=r[p+3],(192&(m=r[p+1]))==128&&(192&_)==128&&(192&x)==128&&((E=(15&T)<<18|(63&m)<<12|(63&_)<<6|63&x)<=65535||E>=1114112)&&(E=null)),E===null?(E=65533,k=1):E>65535&&(E-=65536,h+=String.fromCharCode(E>>>10&1023|55296),E=56320|1023&E),h+=String.fromCharCode(E),p+=k}return h}(this.buf,e,i)},readBytes:function(){var i=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,i);return this.pos=i,e},readPackedVarint:function(i,e){if(this.type!==ai.Bytes)return i.push(this.readVarint(e));var r=as(this);for(i=i||[];this.pos127;);else if(e===ai.Bytes)this.pos=this.readVarint()+this.pos;else if(e===ai.Fixed32)this.pos+=4;else{if(e!==ai.Fixed64)throw new Error("Unimplemented type: "+e);this.pos+=8}},writeTag:function(i,e){this.writeVarint(i<<3|e)},realloc:function(i){for(var e=this.length||16;e268435455||i<0?function(e,r){var o,l;if(e>=0?(o=e%4294967296|0,l=e/4294967296|0):(l=~(-e/4294967296),4294967295^(o=~(-e%4294967296))?o=o+1|0:(o=0,l=l+1|0)),e>=18446744073709552e3||e<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");r.realloc(10),function(h,p,m){m.buf[m.pos++]=127&h|128,h>>>=7,m.buf[m.pos++]=127&h|128,h>>>=7,m.buf[m.pos++]=127&h|128,h>>>=7,m.buf[m.pos++]=127&h|128,m.buf[m.pos]=127&(h>>>=7)}(o,0,r),function(h,p){var m=(7&h)<<4;p.buf[p.pos++]|=m|((h>>>=3)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h|((h>>>=7)?128:0),h&&(p.buf[p.pos++]=127&h)))))}(l,r)}(i,this):(this.realloc(4),this.buf[this.pos++]=127&i|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=127&(i>>>=7)|(i>127?128:0),i<=127||(this.buf[this.pos++]=i>>>7&127))))},writeSVarint:function(i){this.writeVarint(i<0?2*-i-1:2*i)},writeBoolean:function(i){this.writeVarint(!!i)},writeString:function(i){i=String(i),this.realloc(4*i.length),this.pos++;var e=this.pos;this.pos=function(o,l,h){for(var p,m,_=0;_55295&&p<57344){if(!m){p>56319||_+1===l.length?(o[h++]=239,o[h++]=191,o[h++]=189):m=p;continue}if(p<56320){o[h++]=239,o[h++]=191,o[h++]=189,m=p;continue}p=m-55296<<10|p-56320|65536,m=null}else m&&(o[h++]=239,o[h++]=191,o[h++]=189,m=null);p<128?o[h++]=p:(p<2048?o[h++]=p>>6|192:(p<65536?o[h++]=p>>12|224:(o[h++]=p>>18|240,o[h++]=p>>12&63|128),o[h++]=p>>6&63|128),o[h++]=63&p|128)}return h}(this.buf,i,this.pos);var r=this.pos-e;r>=128&&Ku(e,r,this),this.pos=e-1,this.writeVarint(r),this.pos+=r},writeFloat:function(i){this.realloc(4),Wu(this.buf,i,this.pos,!0,23,4),this.pos+=4},writeDouble:function(i){this.realloc(8),Wu(this.buf,i,this.pos,!0,52,8),this.pos+=8},writeBytes:function(i){var e=i.length;this.writeVarint(e),this.realloc(e);for(var r=0;r=128&&Ku(r,o,this),this.pos=r-1,this.writeVarint(o),this.pos+=o},writeMessage:function(i,e,r){this.writeTag(i,ai.Bytes),this.writeRawMessage(e,r)},writePackedVarint:function(i,e){e.length&&this.writeMessage(i,gp,e)},writePackedSVarint:function(i,e){e.length&&this.writeMessage(i,yp,e)},writePackedBoolean:function(i,e){e.length&&this.writeMessage(i,xp,e)},writePackedFloat:function(i,e){e.length&&this.writeMessage(i,_p,e)},writePackedDouble:function(i,e){e.length&&this.writeMessage(i,vp,e)},writePackedFixed32:function(i,e){e.length&&this.writeMessage(i,bp,e)},writePackedSFixed32:function(i,e){e.length&&this.writeMessage(i,wp,e)},writePackedFixed64:function(i,e){e.length&&this.writeMessage(i,Ip,e)},writePackedSFixed64:function(i,e){e.length&&this.writeMessage(i,Sp,e)},writeBytesField:function(i,e){this.writeTag(i,ai.Bytes),this.writeBytes(e)},writeFixed32Field:function(i,e){this.writeTag(i,ai.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(i,e){this.writeTag(i,ai.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(i,e){this.writeTag(i,ai.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(i,e){this.writeTag(i,ai.Fixed64),this.writeSFixed64(e)},writeVarintField:function(i,e){this.writeTag(i,ai.Varint),this.writeVarint(e)},writeSVarintField:function(i,e){this.writeTag(i,ai.Varint),this.writeSVarint(e)},writeStringField:function(i,e){this.writeTag(i,ai.Bytes),this.writeString(e)},writeFloatField:function(i,e){this.writeTag(i,ai.Fixed32),this.writeFloat(e)},writeDoubleField:function(i,e){this.writeTag(i,ai.Fixed64),this.writeDouble(e)},writeBooleanField:function(i,e){this.writeVarintField(i,!!e)}};var Pc=Se(qu);const kc=3;function Tp(i,e,r){i===1&&r.readMessage(Ep,e)}function Ep(i,e,r){if(i===3){const{id:o,bitmap:l,width:h,height:p,left:m,top:_,advance:x}=r.readMessage(Cp,{});e.push({id:o,bitmap:new ul({width:h+2*kc,height:p+2*kc},l),metrics:{width:h,height:p,left:m,top:_,advance:x}})}}function Cp(i,e,r){i===1?e.id=r.readVarint():i===2?e.bitmap=r.readBytes():i===3?e.width=r.readVarint():i===4?e.height=r.readVarint():i===5?e.left=r.readSVarint():i===6?e.top=r.readSVarint():i===7&&(e.advance=r.readVarint())}const Qu=kc;function eh(i){let e=0,r=0;for(const p of i)e+=p.w*p.h,r=Math.max(r,p.w);i.sort((p,m)=>m.h-p.h);const o=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),r),h:1/0}];let l=0,h=0;for(const p of i)for(let m=o.length-1;m>=0;m--){const _=o[m];if(!(p.w>_.w||p.h>_.h)){if(p.x=_.x,p.y=_.y,h=Math.max(h,p.y+p.h),l=Math.max(l,p.x+p.w),p.w===_.w&&p.h===_.h){const x=o.pop();m=0&&o>=e&&Jl[this.text.charCodeAt(o)];o--)r--;this.text=this.text.substring(e,r),this.sectionIndex=this.sectionIndex.slice(e,r)}substring(e,r){const o=new Va;return o.text=this.text.substring(e,r),o.sectionIndex=this.sectionIndex.slice(e,r),o.sections=this.sections,o}toString(){return this.text}getMaxScale(){return this.sectionIndex.reduce((e,r)=>Math.max(e,this.sections[r].scale),0)}addTextSection(e,r){this.text+=e.text,this.sections.push(vl.forText(e.scale,e.fontStack||r));const o=this.sections.length-1;for(let l=0;l=63743?null:++this.imageSectionID:(this.imageSectionID=57344,this.imageSectionID)}}function Xl(i,e,r,o,l,h,p,m,_,x,T,E,k,R,B,V){const q=Va.fromFeature(i,l);let J;E===M.ah.vertical&&q.verticalizePunctuation();const{processBidirectionalText:pe,processStyledBidirectionalText:Y}=No;if(pe&&q.sections.length===1){J=[];const Me=pe(q.toString(),zc(q,x,h,e,o,R,B));for(const Qe of Me){const nt=new Va;nt.text=Qe,nt.sections=q.sections;for(let Ke=0;Ke0&&cs>bn&&(bn=cs)}else{const Qn=nt[Vt.fontStack],In=Qn&&Qn[Or];if(In&&In.rect)Mo=In.rect,po=In.metrics;else{const cs=Qe[Vt.fontStack],Sl=cs&&cs[Or];if(!Sl)continue;po=Sl.metrics}vr=(yr-Vt.scale)*fr}fo?(Me.verticalizable=!0,qr.push({glyph:Or,imageName:Ao,x:vi,y:Mi+vr,vertical:fo,scale:Vt.scale,fontStack:Vt.fontStack,sectionIndex:Hr,metrics:po,rect:Mo}),vi+=ls*Vt.scale+ht):(qr.push({glyph:Or,imageName:Ao,x:vi,y:Mi+vr,vertical:fo,scale:Vt.scale,fontStack:Vt.fontStack,sectionIndex:Hr,metrics:po,rect:Mo}),vi+=po.advance*Vt.scale+ht)}qr.length!==0&&(mr=Math.max(vi-ht,mr),Pp(qr,0,qr.length-1,an,bn)),vi=0;const wn=Oe*yr+bn;un.lineOffset=Math.max(bn,Zr),Mi+=wn,Bn=Math.max(wn,Bn),++nr}var zr;const Br=Mi-_l,{horizontalAlign:ln,verticalAlign:cn}=Dc(tt);(function(gr,yr,Zr,un,qr,bn,wn,_r,Vt){const Hr=(yr-Zr)*qr;let Or=0;Or=bn!==wn?-_r*un-_l:(-un*Vt+.5)*wn;for(const vr of gr)for(const po of vr.positionedGlyphs)po.x+=Hr,po.y+=Or})(Me.positionedLines,an,ln,cn,mr,Bn,Oe,Br,qe.length),Me.top+=-cn*Br,Me.bottom=Me.top+Br,Me.left+=-ln*mr,Me.right=Me.left+mr}(Ie,e,r,o,J,p,m,_,E,x,k,V),!function(Me){for(const Qe of Me)if(Qe.positionedGlyphs.length!==0)return!1;return!0}(se)&&Ie}const Jl={9:!0,10:!0,11:!0,12:!0,13:!0,32:!0},Mp={10:!0,32:!0,38:!0,40:!0,41:!0,43:!0,45:!0,47:!0,173:!0,183:!0,8203:!0,8208:!0,8211:!0,8231:!0};function ih(i,e,r,o,l,h){if(e.imageName){const p=o[e.imageName];return p?p.displaySize[0]*e.scale*fr/h+l:0}{const p=r[e.fontStack],m=p&&p[i];return m?m.metrics.advance*e.scale+l:0}}function rh(i,e,r,o){const l=Math.pow(i-e,2);return o?i=0;let T=0;for(let k=0;kp.id),this.index=e.index,this.pixelRatio=e.pixelRatio,this.sourceLayerIndex=e.sourceLayerIndex,this.hasPattern=!1,this.hasRTLText=!1,this.sortKeyRanges=[],this.collisionCircleArray=[],this.placementInvProjMatrix=mc([]),this.placementViewportMatrix=mc([]);const r=this.layers[0]._unevaluatedLayout._values;this.textSizeData=ah(this.zoom,r["text-size"]),this.iconSizeData=ah(this.zoom,r["icon-size"]);const o=this.layers[0].layout,l=o.get("symbol-sort-key"),h=o.get("symbol-z-order");this.canOverlap=Rc(o,"text-overlap","text-allow-overlap")!=="never"||Rc(o,"icon-overlap","icon-allow-overlap")!=="never"||o.get("text-ignore-placement")||o.get("icon-ignore-placement"),this.sortFeaturesByKey=h!=="viewport-y"&&!l.isConstant(),this.sortFeaturesByY=(h==="viewport-y"||h==="auto"&&!this.sortFeaturesByKey)&&this.canOverlap,o.get("symbol-placement")==="point"&&(this.writingModes=o.get("text-writing-mode").map(p=>M.ah[p])),this.stateDependentLayerIds=this.layers.filter(p=>p.isStateDependent()).map(p=>p.id),this.sourceID=e.sourceID}createArrays(){this.text=new Bc(new Ri(this.layers,this.zoom,e=>/^text/.test(e))),this.icon=new Bc(new Ri(this.layers,this.zoom,e=>/^icon/.test(e))),this.glyphOffsetArray=new u,this.lineVertexArray=new g,this.symbolInstances=new a,this.textAnchorOffsets=new v}calculateGlyphDependencies(e,r,o,l,h){for(let p=0;p0)&&(p.value.kind!=="constant"||p.value.value.length>0),T=_.value.kind!=="constant"||!!_.value.value||Object.keys(_.parameters).length>0,E=h.get("symbol-sort-key");if(this.features=[],!x&&!T)return;const k=r.iconDependencies,R=r.glyphDependencies,B=r.availableImages,V=new Ei(this.zoom);for(const{feature:q,id:J,index:pe,sourceLayerIndex:Y}of e){const se=l._featureFilter.needGeometry,Ie=ss(q,se);if(!l._featureFilter.filter(V,Ie,o))continue;let Me,Qe;if(se||(Ie.geometry=os(q)),x){const Ke=l.getValueAndResolveTokens("text-field",Ie,o,B),qe=Rr.factory(Ke),Oe=this.hasRTLText=this.hasRTLText||Dp(qe);(!Oe||No.getRTLTextPluginStatus()==="unavailable"||Oe&&No.isParsed())&&(Me=mp(qe,l,Ie))}if(T){const Ke=l.getValueAndResolveTokens("icon-image",Ie,o,B);Qe=Ke instanceof Mr?Ke:Mr.fromString(Ke)}if(!Me&&!Qe)continue;const nt=this.sortFeaturesByKey?E.evaluate(Ie,{},o):void 0;if(this.features.push({id:J,text:Me,icon:Qe,index:pe,sourceLayerIndex:Y,geometry:Ie.geometry,properties:q.properties,type:Lp[q.type],sortKey:nt}),Qe&&(k[Qe.name]=!0),Me){const Ke=p.evaluate(Ie,{},o).join(","),qe=h.get("text-rotation-alignment")!=="viewport"&&h.get("symbol-placement")!=="point";this.allowVerticalPlacement=this.writingModes&&this.writingModes.indexOf(M.ah.vertical)>=0;for(const Oe of Me.sections)if(Oe.image)k[Oe.image.name]=!0;else{const tt=co(Me.toString()),Ge=Oe.fontStack||Ke,Le=R[Ge]=R[Ge]||{};this.calculateGlyphDependencies(Oe.text,Le,qe,this.allowVerticalPlacement,tt)}}}h.get("symbol-placement")==="line"&&(this.features=function(q){const J={},pe={},Y=[];let se=0;function Ie(Ke){Y.push(q[Ke]),se++}function Me(Ke,qe,Oe){const tt=pe[Ke];return delete pe[Ke],pe[qe]=tt,Y[tt].geometry[0].pop(),Y[tt].geometry[0]=Y[tt].geometry[0].concat(Oe[0]),tt}function Qe(Ke,qe,Oe){const tt=J[qe];return delete J[qe],J[Ke]=tt,Y[tt].geometry[0].shift(),Y[tt].geometry[0]=Oe[0].concat(Y[tt].geometry[0]),tt}function nt(Ke,qe,Oe){const tt=Oe?qe[0][qe[0].length-1]:qe[0][0];return`${Ke}:${tt.x}:${tt.y}`}for(let Ke=0;KeKe.geometry)}(this.features)),this.sortFeaturesByKey&&this.features.sort((q,J)=>q.sortKey-J.sortKey)}update(e,r,o){this.stateDependentLayers.length&&(this.text.programConfigurations.updatePaintArrays(e,r,this.layers,o),this.icon.programConfigurations.updatePaintArrays(e,r,this.layers,o))}isEmpty(){return this.symbolInstances.length===0&&!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()}destroy(){this.text.destroy(),this.icon.destroy(),this.hasDebugData()&&this.destroyDebugData()}addToLineVertexArray(e,r){const o=this.lineVertexArray.length;if(e.segment!==void 0){let l=e.dist(r[e.segment+1]),h=e.dist(r[e.segment]);const p={};for(let m=e.segment+1;m=0;m--)p[m]={x:r[m].x,y:r[m].y,tileUnitDistanceFromAnchor:h},m>0&&(h+=r[m-1].dist(r[m]));for(let m=0;m0}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,r){const o=e.placedSymbolArray.get(r),l=o.vertexStartIndex+4*o.numGlyphs;for(let h=o.vertexStartIndex;hl[m]-l[_]||h[_]-h[m]),p}addToSortKeyRanges(e,r){const o=this.sortKeyRanges[this.sortKeyRanges.length-1];o&&o.sortKey===r?o.symbolInstanceEnd=e+1:this.sortKeyRanges.push({sortKey:r,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 r of this.symbolInstanceIndexes){const o=this.symbolInstances.get(r);this.featureSortOrder.push(o.featureIndex),[o.rightJustifiedTextSymbolIndex,o.centerJustifiedTextSymbolIndex,o.leftJustifiedTextSymbolIndex].forEach((l,h,p)=>{l>=0&&p.indexOf(l)===h&&this.addIndicesForPlacedSymbol(this.text,l)}),o.verticalPlacedTextSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.text,o.verticalPlacedTextSymbolIndex),o.placedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.placedIconSymbolIndex),o.verticalPlacedIconSymbolIndex>=0&&this.addIndicesForPlacedSymbol(this.icon,o.verticalPlacedIconSymbolIndex)}this.text.indexBuffer&&this.text.indexBuffer.updateData(this.text.indexArray),this.icon.indexBuffer&&this.icon.indexBuffer.updateData(this.icon.indexArray)}}}let lh,ch;Ye("SymbolBucket",Ua,{omit:["layers","collisionBoxArray","features","compareText"]}),Ua.MAX_GLYPHS=65535,Ua.addDynamicAttributes=Fc;var Nc={get paint(){return ch=ch||new on({"icon-opacity":new dt(be.paint_symbol["icon-opacity"]),"icon-color":new dt(be.paint_symbol["icon-color"]),"icon-halo-color":new dt(be.paint_symbol["icon-halo-color"]),"icon-halo-width":new dt(be.paint_symbol["icon-halo-width"]),"icon-halo-blur":new dt(be.paint_symbol["icon-halo-blur"]),"icon-translate":new at(be.paint_symbol["icon-translate"]),"icon-translate-anchor":new at(be.paint_symbol["icon-translate-anchor"]),"text-opacity":new dt(be.paint_symbol["text-opacity"]),"text-color":new dt(be.paint_symbol["text-color"],{runtimeType:Gi,getOverride:i=>i.textColor,hasOverride:i=>!!i.textColor}),"text-halo-color":new dt(be.paint_symbol["text-halo-color"]),"text-halo-width":new dt(be.paint_symbol["text-halo-width"]),"text-halo-blur":new dt(be.paint_symbol["text-halo-blur"]),"text-translate":new at(be.paint_symbol["text-translate"]),"text-translate-anchor":new at(be.paint_symbol["text-translate-anchor"])})},get layout(){return lh=lh||new on({"symbol-placement":new at(be.layout_symbol["symbol-placement"]),"symbol-spacing":new at(be.layout_symbol["symbol-spacing"]),"symbol-avoid-edges":new at(be.layout_symbol["symbol-avoid-edges"]),"symbol-sort-key":new dt(be.layout_symbol["symbol-sort-key"]),"symbol-z-order":new at(be.layout_symbol["symbol-z-order"]),"icon-allow-overlap":new at(be.layout_symbol["icon-allow-overlap"]),"icon-overlap":new at(be.layout_symbol["icon-overlap"]),"icon-ignore-placement":new at(be.layout_symbol["icon-ignore-placement"]),"icon-optional":new at(be.layout_symbol["icon-optional"]),"icon-rotation-alignment":new at(be.layout_symbol["icon-rotation-alignment"]),"icon-size":new dt(be.layout_symbol["icon-size"]),"icon-text-fit":new at(be.layout_symbol["icon-text-fit"]),"icon-text-fit-padding":new at(be.layout_symbol["icon-text-fit-padding"]),"icon-image":new dt(be.layout_symbol["icon-image"]),"icon-rotate":new dt(be.layout_symbol["icon-rotate"]),"icon-padding":new dt(be.layout_symbol["icon-padding"]),"icon-keep-upright":new at(be.layout_symbol["icon-keep-upright"]),"icon-offset":new dt(be.layout_symbol["icon-offset"]),"icon-anchor":new dt(be.layout_symbol["icon-anchor"]),"icon-pitch-alignment":new at(be.layout_symbol["icon-pitch-alignment"]),"text-pitch-alignment":new at(be.layout_symbol["text-pitch-alignment"]),"text-rotation-alignment":new at(be.layout_symbol["text-rotation-alignment"]),"text-field":new dt(be.layout_symbol["text-field"]),"text-font":new dt(be.layout_symbol["text-font"]),"text-size":new dt(be.layout_symbol["text-size"]),"text-max-width":new dt(be.layout_symbol["text-max-width"]),"text-line-height":new at(be.layout_symbol["text-line-height"]),"text-letter-spacing":new dt(be.layout_symbol["text-letter-spacing"]),"text-justify":new dt(be.layout_symbol["text-justify"]),"text-radial-offset":new dt(be.layout_symbol["text-radial-offset"]),"text-variable-anchor":new at(be.layout_symbol["text-variable-anchor"]),"text-variable-anchor-offset":new dt(be.layout_symbol["text-variable-anchor-offset"]),"text-anchor":new dt(be.layout_symbol["text-anchor"]),"text-max-angle":new at(be.layout_symbol["text-max-angle"]),"text-writing-mode":new at(be.layout_symbol["text-writing-mode"]),"text-rotate":new dt(be.layout_symbol["text-rotate"]),"text-padding":new at(be.layout_symbol["text-padding"]),"text-keep-upright":new at(be.layout_symbol["text-keep-upright"]),"text-transform":new dt(be.layout_symbol["text-transform"]),"text-offset":new dt(be.layout_symbol["text-offset"]),"text-allow-overlap":new at(be.layout_symbol["text-allow-overlap"]),"text-overlap":new at(be.layout_symbol["text-overlap"]),"text-ignore-placement":new at(be.layout_symbol["text-ignore-placement"]),"text-optional":new at(be.layout_symbol["text-optional"])})}};class uh{constructor(e){if(e.property.overrides===void 0)throw new Error("overrides must be provided to instantiate FormatSectionOverride class");this.type=e.property.overrides?e.property.overrides.runtimeType:Xi,this.defaultValue=e}evaluate(e){if(e.formattedSection){const r=this.defaultValue.property.overrides;if(r&&r.hasOverride(e.formattedSection))return r.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}}Ye("FormatSectionOverride",uh,{omit:["defaultValue"]});class Yl extends Jn{constructor(e){super(e,Nc)}recalculate(e,r){if(super.recalculate(e,r),this.layout.get("icon-rotation-alignment")==="auto"&&(this.layout._values["icon-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-rotation-alignment")==="auto"&&(this.layout._values["text-rotation-alignment"]=this.layout.get("symbol-placement")!=="point"?"map":"viewport"),this.layout.get("text-pitch-alignment")==="auto"&&(this.layout._values["text-pitch-alignment"]=this.layout.get("text-rotation-alignment")==="map"?"map":"viewport"),this.layout.get("icon-pitch-alignment")==="auto"&&(this.layout._values["icon-pitch-alignment"]=this.layout.get("icon-rotation-alignment")),this.layout.get("symbol-placement")==="point"){const o=this.layout.get("text-writing-mode");if(o){const l=[];for(const h of o)l.indexOf(h)<0&&l.push(h);this.layout._values["text-writing-mode"]=l}else this.layout._values["text-writing-mode"]=["horizontal"]}this._setPaintOverrides()}getValueAndResolveTokens(e,r,o,l){const h=this.layout.get(e).evaluate(r,{},o,l),p=this._unevaluatedLayout._values[e];return p.isDataDriven()||ri(p.value)||!h?h:function(m,_){return _.replace(/{([^{}]+)}/g,(x,T)=>m&&T in m?String(m[T]):"")}(r.properties,h)}createBucket(e){return new Ua(e)}queryRadius(){return 0}queryIntersectsFeature(){throw new Error("Should take a different path in FeatureIndex")}_setPaintOverrides(){for(const e of Nc.paint.overridableProperties){if(!Yl.hasPaintOverride(this.layout,e))continue;const r=this.paint.get(e),o=new uh(r),l=new Wt(o,r.property.specification);let h=null;h=r.value.kind==="constant"||r.value.kind==="source"?new ao("source",l):new Ts("composite",l,r.value.zoomStops),this.paint._values[e]=new Xn(r.property,h,r.parameters)}}_handleOverridablePaintPropertyUpdate(e,r,o){return!(!this.layout||r.isDataDriven()||o.isDataDriven())&&Yl.hasPaintOverride(this.layout,e)}static hasPaintOverride(e,r){const o=e.get("text-field"),l=Nc.paint.properties[r];let h=!1;const p=m=>{for(const _ of m)if(l.overrides&&l.overrides.hasOverride(_))return void(h=!0)};if(o.value.kind==="constant"&&o.value.value instanceof Rr)p(o.value.value.sections);else if(o.value.kind==="source"){const m=x=>{h||(x instanceof no&&Ni(x.value)===Pi?p(x.value.sections):x instanceof xs?p(x.sections):x.eachChild(m))},_=o.value;_._styleExpression&&m(_._styleExpression.expression)}return h}}let hh;var Rp={get paint(){return hh=hh||new on({"background-color":new at(be.paint_background["background-color"]),"background-pattern":new ra(be.paint_background["background-pattern"]),"background-opacity":new at(be.paint_background["background-opacity"])})}};class Fp extends Jn{constructor(e){super(e,Rp)}}let dh;var Bp={get paint(){return dh=dh||new on({"raster-opacity":new at(be.paint_raster["raster-opacity"]),"raster-hue-rotate":new at(be.paint_raster["raster-hue-rotate"]),"raster-brightness-min":new at(be.paint_raster["raster-brightness-min"]),"raster-brightness-max":new at(be.paint_raster["raster-brightness-max"]),"raster-saturation":new at(be.paint_raster["raster-saturation"]),"raster-contrast":new at(be.paint_raster["raster-contrast"]),"raster-resampling":new at(be.paint_raster["raster-resampling"]),"raster-fade-duration":new at(be.paint_raster["raster-fade-duration"])})}};class Op extends Jn{constructor(e){super(e,Bp)}}class Np extends Jn{constructor(e){super(e,{}),this.onAdd=r=>{this.implementation.onAdd&&this.implementation.onAdd(r,r.painter.context.gl)},this.onRemove=r=>{this.implementation.onRemove&&this.implementation.onRemove(r,r.painter.context.gl)},this.implementation=e}is3D(){return this.implementation.renderingMode==="3d"}hasOffscreenPass(){return this.implementation.prerender!==void 0}recalculate(){}updateTransitions(){}hasTransition(){return!1}serialize(){throw new Error("Custom layers cannot be serialized")}}class Vp{constructor(e){this._methodToThrottle=e,this._triggered=!1,typeof MessageChannel<"u"&&(this._channel=new MessageChannel,this._channel.port2.onmessage=()=>{this._triggered=!1,this._methodToThrottle()})}trigger(){this._triggered||(this._triggered=!0,this._channel?this._channel.port1.postMessage(!0):setTimeout(()=>{this._triggered=!1,this._methodToThrottle()},0))}remove(){delete this._channel,this._methodToThrottle=()=>{}}}const Vc=63710088e-1;class Bs{constructor(e,r){if(isNaN(e)||isNaN(r))throw new Error(`Invalid LngLat object: (${e}, ${r})`);if(this.lng=+e,this.lat=+r,this.lat>90||this.lat<-90)throw new Error("Invalid LngLat latitude value: must be between -90 and 90")}wrap(){return new Bs(ti(this.lng,-180,180),this.lat)}toArray(){return[this.lng,this.lat]}toString(){return`LngLat(${this.lng}, ${this.lat})`}distanceTo(e){const r=Math.PI/180,o=this.lat*r,l=e.lat*r,h=Math.sin(o)*Math.sin(l)+Math.cos(o)*Math.cos(l)*Math.cos((e.lng-this.lng)*r);return Vc*Math.acos(Math.min(h,1))}static convert(e){if(e instanceof Bs)return e;if(Array.isArray(e)&&(e.length===2||e.length===3))return new Bs(Number(e[0]),Number(e[1]));if(!Array.isArray(e)&&typeof e=="object"&&e!==null)return new Bs(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 ph=2*Math.PI*Vc;function fh(i){return ph*Math.cos(i*Math.PI/180)}function mh(i){return(180+i)/360}function gh(i){return(180-180/Math.PI*Math.log(Math.tan(Math.PI/4+i*Math.PI/360)))/360}function yh(i,e){return i/fh(e)}function Uc(i){return 360/Math.PI*Math.atan(Math.exp((180-360*i)*Math.PI/180))-90}class Ql{constructor(e,r,o=0){this.x=+e,this.y=+r,this.z=+o}static fromLngLat(e,r=0){const o=Bs.convert(e);return new Ql(mh(o.lng),gh(o.lat),yh(r,o.lat))}toLngLat(){return new Bs(360*this.x-180,Uc(this.y))}toAltitude(){return this.z*fh(Uc(this.y))}meterInMercatorCoordinateUnits(){return 1/ph*(e=Uc(this.y),1/Math.cos(e*Math.PI/180));var e}}function _h(i,e,r){var o=2*Math.PI*6378137/256/Math.pow(2,r);return[i*o-2*Math.PI*6378137/2,e*o-2*Math.PI*6378137/2]}class jc{constructor(e,r,o){if(e<0||e>25||o<0||o>=Math.pow(2,e)||r<0||r>=Math.pow(2,e))throw new Error(`x=${r}, y=${o}, z=${e} outside of bounds. 0<=x<${Math.pow(2,e)}, 0<=y<${Math.pow(2,e)} 0<=z<=25 `);this.z=e,this.x=r,this.y=o,this.key=bl(0,e,e,r,o)}equals(e){return this.z===e.z&&this.x===e.x&&this.y===e.y}url(e,r,o){const l=(p=this.y,m=this.z,_=_h(256*(h=this.x),256*(p=Math.pow(2,m)-p-1),m),x=_h(256*(h+1),256*(p+1),m),_[0]+","+_[1]+","+x[0]+","+x[1]);var h,p,m,_,x;const T=function(E,k,R){let B,V="";for(let q=E;q>0;q--)B=1<1?"@2x":"").replace(/{quadkey}/g,T).replace(/{bbox-epsg-3857}/g,l)}isChildOf(e){const r=this.z-e.z;return r>0&&e.x===this.x>>r&&e.y===this.y>>r}getTilePoint(e){const r=Math.pow(2,this.z);return new ce((e.x*r-this.x)*Hi,(e.y*r-this.y)*Hi)}toString(){return`${this.z}/${this.x}/${this.y}`}}class vh{constructor(e,r){this.wrap=e,this.canonical=r,this.key=bl(e,r.z,r.z,r.x,r.y)}}class Yn{constructor(e,r,o,l,h){if(e= z; overscaledZ = ${e}; z = ${o}`);this.overscaledZ=e,this.wrap=r,this.canonical=new jc(o,+l,+h),this.key=bl(r,e,o,l,h)}clone(){return new Yn(this.overscaledZ,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)}equals(e){return this.overscaledZ===e.overscaledZ&&this.wrap===e.wrap&&this.canonical.equals(e.canonical)}scaledTo(e){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const r=this.canonical.z-e;return e>this.canonical.z?new Yn(e,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y):new Yn(e,this.wrap,e,this.canonical.x>>r,this.canonical.y>>r)}calculateScaledKey(e,r){if(e>this.overscaledZ)throw new Error(`targetZ > this.overscaledZ; targetZ = ${e}; overscaledZ = ${this.overscaledZ}`);const o=this.canonical.z-e;return e>this.canonical.z?bl(this.wrap*+r,e,this.canonical.z,this.canonical.x,this.canonical.y):bl(this.wrap*+r,e,e,this.canonical.x>>o,this.canonical.y>>o)}isChildOf(e){if(e.wrap!==this.wrap)return!1;const r=this.canonical.z-e.canonical.z;return e.overscaledZ===0||e.overscaledZ>r&&e.canonical.y===this.canonical.y>>r}children(e){if(this.overscaledZ>=e)return[new Yn(this.overscaledZ+1,this.wrap,this.canonical.z,this.canonical.x,this.canonical.y)];const r=this.canonical.z+1,o=2*this.canonical.x,l=2*this.canonical.y;return[new Yn(r,this.wrap,r,o,l),new Yn(r,this.wrap,r,o+1,l),new Yn(r,this.wrap,r,o,l+1),new Yn(r,this.wrap,r,o+1,l+1)]}isLessThan(e){return this.wrape.wrap)&&(this.overscaledZe.overscaledZ)&&(this.canonical.xe.canonical.x)&&this.canonical.ythis.max&&(this.max=E),E=this.dim+1||r<-1||r>=this.dim+1)throw new RangeError("out of range source coordinates for DEM data");return(r+1)*this.stride+(e+1)}unpack(e,r,o){return e*this.redFactor+r*this.greenFactor+o*this.blueFactor-this.baseShift}getPixels(){return new Kn({width:this.stride,height:this.stride},new Uint8Array(this.data.buffer))}backfillBorder(e,r,o){if(this.dim!==e.dim)throw new Error("dem dimension mismatch");let l=r*this.dim,h=r*this.dim+this.dim,p=o*this.dim,m=o*this.dim+this.dim;switch(r){case-1:l=h-1;break;case 1:h=l+1}switch(o){case-1:p=m-1;break;case 1:m=p+1}const _=-r*this.dim,x=-o*this.dim;for(let T=p;T=this._numberToString.length)throw new Error(`Out of bounds. Index requested n=${e} can't be >= this._numberToString.length ${this._numberToString.length}`);return this._numberToString[e]}}class wh{constructor(e,r,o,l,h){this.type="Feature",this._vectorTileFeature=e,e._z=r,e._x=o,e._y=l,this.properties=e.properties,this.id=h}get geometry(){return this._geometry===void 0&&(this._geometry=this._vectorTileFeature.toGeoJSON(this._vectorTileFeature._x,this._vectorTileFeature._y,this._vectorTileFeature._z).geometry),this._geometry}set geometry(e){this._geometry=e}toJSON(){const e={geometry:this.geometry};for(const r in this)r!=="_geometry"&&r!=="_vectorTileFeature"&&(e[r]=this[r]);return e}}class Ih{constructor(e,r){this.tileID=e,this.x=e.canonical.x,this.y=e.canonical.y,this.z=e.canonical.z,this.grid=new Gr(Hi,16,0),this.grid3D=new Gr(Hi,16,0),this.featureIndexArray=new C,this.promoteId=r}insert(e,r,o,l,h,p){const m=this.featureIndexArray.length;this.featureIndexArray.emplaceBack(o,l,h);const _=p?this.grid3D:this.grid;for(let x=0;x=0&&E[3]>=0&&_.insert(m,E[0],E[1],E[2],E[3])}}loadVTLayers(){return this.vtLayers||(this.vtLayers=new Ds.VectorTile(new Pc(this.rawTileData)).layers,this.sourceLayerCoder=new bh(this.vtLayers?Object.keys(this.vtLayers).sort():["_geojsonTileLayer"])),this.vtLayers}query(e,r,o,l){this.loadVTLayers();const h=e.params||{},p=Hi/e.tileSize/e.scale,m=bo(h.filter),_=e.queryGeometry,x=e.queryPadding*p,T=Th(_),E=this.grid.query(T.minX-x,T.minY-x,T.maxX+x,T.maxY+x),k=Th(e.cameraQueryGeometry),R=this.grid3D.query(k.minX-x,k.minY-x,k.maxX+x,k.maxY+x,(q,J,pe,Y)=>function(se,Ie,Me,Qe,nt){for(const qe of se)if(Ie<=qe.x&&Me<=qe.y&&Qe>=qe.x&&nt>=qe.y)return!0;const Ke=[new ce(Ie,Me),new ce(Ie,nt),new ce(Qe,nt),new ce(Qe,Me)];if(se.length>2){for(const qe of Ke)if(Da(se,qe))return!0}for(let qe=0;qe(Y||(Y=os(se)),Ie.queryIntersectsFeature(_,se,Me,Y,this.z,e.transform,p,e.pixelPosMatrix)))}return B}loadMatchingFeature(e,r,o,l,h,p,m,_,x,T,E){const k=this.bucketLayerIDs[r];if(p&&!function(q,J){for(let pe=0;pe=0)return!0;return!1}(p,k))return;const R=this.sourceLayerCoder.decode(o),B=this.vtLayers[R].feature(l);if(h.needGeometry){const q=ss(B,!0);if(!h.filter(new Ei(this.tileID.overscaledZ),q,this.tileID.canonical))return}else if(!h.filter(new Ei(this.tileID.overscaledZ),B))return;const V=this.getId(B,R);for(let q=0;q{const m=e instanceof ia?e.get(p):null;return m&&m.evaluate?m.evaluate(r,o,l):m})}function Th(i){let e=1/0,r=1/0,o=-1/0,l=-1/0;for(const h of i)e=Math.min(e,h.x),r=Math.min(r,h.y),o=Math.max(o,h.x),l=Math.max(l,h.y);return{minX:e,minY:r,maxX:o,maxY:l}}function Up(i,e){return e-i}function Eh(i,e,r,o,l){const h=[];for(let p=0;p=o&&E.x>=o||(T.x>=o?T=new ce(o,T.y+(o-T.x)/(E.x-T.x)*(E.y-T.y))._round():E.x>=o&&(E=new ce(o,T.y+(o-T.x)/(E.x-T.x)*(E.y-T.y))._round()),T.y>=l&&E.y>=l||(T.y>=l?T=new ce(T.x+(l-T.y)/(E.y-T.y)*(E.x-T.x),l)._round():E.y>=l&&(E=new ce(T.x+(l-T.y)/(E.y-T.y)*(E.x-T.x),l)._round()),_&&T.equals(_[_.length-1])||(_=[T],h.push(_)),_.push(E)))))}}return h}Ye("FeatureIndex",Ih,{omit:["rawTileData","sourceLayerCoder"]});class Os extends ce{constructor(e,r,o,l){super(e,r),this.angle=o,l!==void 0&&(this.segment=l)}clone(){return new Os(this.x,this.y,this.angle,this.segment)}}function Ch(i,e,r,o,l){if(e.segment===void 0||r===0)return!0;let h=e,p=e.segment+1,m=0;for(;m>-r/2;){if(p--,p<0)return!1;m-=i[p].dist(h),h=i[p]}m+=i[p].dist(i[p+1]),p++;const _=[];let x=0;for(;mo;)x-=_.shift().angleDelta;if(x>l)return!1;p++,m+=T.dist(E)}return!0}function Mh(i){let e=0;for(let r=0;rx){const B=(x-_)/R,V=wr.number(E.x,k.x,B),q=wr.number(E.y,k.y,B),J=new Os(V,q,k.angleTo(E),T);return J._round(),!p||Ch(i,J,m,p,e)?J:void 0}_+=R}}function $p(i,e,r,o,l,h,p,m,_){const x=Ah(o,h,p),T=Ph(o,l),E=T*p,k=i[0].x===0||i[0].x===_||i[0].y===0||i[0].y===_;return e-E=0&&se<_&&Ie>=0&&Ie<_&&k-x>=0&&k+x<=T){const Me=new Os(se,Ie,pe,B);Me._round(),o&&!Ch(i,Me,h,o,l)||R.push(Me)}}E+=J}return m||R.length||p||(R=kh(i,E/2,r,o,l,h,p,!0,_)),R}Ye("Anchor",Os);const ja=xn;function Lh(i,e,r,o){const l=[],h=i.image,p=h.pixelRatio,m=h.paddedRect.w-2*ja,_=h.paddedRect.h-2*ja,x=i.right-i.left,T=i.bottom-i.top,E=h.stretchX||[[0,m]],k=h.stretchY||[[0,_]],R=(Oe,tt)=>Oe+tt[1]-tt[0],B=E.reduce(R,0),V=k.reduce(R,0),q=m-B,J=_-V;let pe=0,Y=B,se=0,Ie=V,Me=0,Qe=q,nt=0,Ke=J;if(h.content&&o){const Oe=h.content;pe=ec(E,0,Oe[0]),se=ec(k,0,Oe[1]),Y=ec(E,Oe[0],Oe[2]),Ie=ec(k,Oe[1],Oe[3]),Me=Oe[0]-pe,nt=Oe[1]-se,Qe=Oe[2]-Oe[0]-Y,Ke=Oe[3]-Oe[1]-Ie}const qe=(Oe,tt,Ge,Le)=>{const ht=tc(Oe.stretch-pe,Y,x,i.left),st=ic(Oe.fixed-Me,Qe,Oe.stretch,B),Rt=tc(tt.stretch-se,Ie,T,i.top),vi=ic(tt.fixed-nt,Ke,tt.stretch,V),Mi=tc(Ge.stretch-pe,Y,x,i.left),mr=ic(Ge.fixed-Me,Qe,Ge.stretch,B),Bn=tc(Le.stretch-se,Ie,T,i.top),an=ic(Le.fixed-nt,Ke,Le.stretch,V),nr=new ce(ht,Rt),zr=new ce(Mi,Rt),Br=new ce(Mi,Bn),ln=new ce(ht,Bn),cn=new ce(st/p,vi/p),gr=new ce(mr/p,an/p),yr=e*Math.PI/180;if(yr){const qr=Math.sin(yr),bn=Math.cos(yr),wn=[bn,-qr,qr,bn];nr._matMult(wn),zr._matMult(wn),ln._matMult(wn),Br._matMult(wn)}const Zr=Oe.stretch+Oe.fixed,un=tt.stretch+tt.fixed;return{tl:nr,tr:zr,bl:ln,br:Br,tex:{x:h.paddedRect.x+ja+Zr,y:h.paddedRect.y+ja+un,w:Ge.stretch+Ge.fixed-Zr,h:Le.stretch+Le.fixed-un},writingMode:void 0,glyphOffset:[0,0],sectionIndex:0,pixelOffsetTL:cn,pixelOffsetBR:gr,minFontScaleX:Qe/p/x,minFontScaleY:Ke/p/T,isSDF:r}};if(o&&(h.stretchX||h.stretchY)){const Oe=zh(E,q,B),tt=zh(k,J,V);for(let Ge=0;Ge0&&(B=Math.max(10,B),this.circleDiameter=B)}else{let E=p.top*m-_[0],k=p.bottom*m+_[2],R=p.left*m-_[3],B=p.right*m+_[1];const V=p.collisionPadding;if(V&&(R-=V[0]*m,E-=V[1]*m,B+=V[2]*m,k+=V[3]*m),T){const q=new ce(R,E),J=new ce(B,E),pe=new ce(R,k),Y=new ce(B,k),se=T*Math.PI/180;q._rotate(se),J._rotate(se),pe._rotate(se),Y._rotate(se),R=Math.min(q.x,J.x,pe.x,Y.x),B=Math.max(q.x,J.x,pe.x,Y.x),E=Math.min(q.y,J.y,pe.y,Y.y),k=Math.max(q.y,J.y,pe.y,Y.y)}e.emplaceBack(r.x,r.y,R,E,B,k,o,l,h)}this.boxEndIndex=e.length}}class Gp{constructor(e=[],r=Zp){if(this.data=e,this.length=this.data.length,this.compare=r,this.length>0)for(let o=(this.length>>1)-1;o>=0;o--)this._down(o)}push(e){this.data.push(e),this.length++,this._up(this.length-1)}pop(){if(this.length===0)return;const e=this.data[0],r=this.data.pop();return this.length--,this.length>0&&(this.data[0]=r,this._down(0)),e}peek(){return this.data[0]}_up(e){const{data:r,compare:o}=this,l=r[e];for(;e>0;){const h=e-1>>1,p=r[h];if(o(l,p)>=0)break;r[e]=p,e=h}r[e]=l}_down(e){const{data:r,compare:o}=this,l=this.length>>1,h=r[e];for(;e=0)break;r[e]=m,e=p}r[e]=h}}function Zp(i,e){return ie?1:0}function qp(i,e=1,r=!1){let o=1/0,l=1/0,h=-1/0,p=-1/0;const m=i[0];for(let R=0;Rh)&&(h=B.x),(!R||B.y>p)&&(p=B.y)}const _=Math.min(h-o,p-l);let x=_/2;const T=new Gp([],Hp);if(_===0)return new ce(o,l);for(let R=o;RE.d||!E.d)&&(E=R,r&&console.log("found best %d after %d probes",Math.round(1e4*R.d)/1e4,k)),R.max-E.d<=e||(x=R.h/2,T.push(new $a(R.p.x-x,R.p.y-x,x,i)),T.push(new $a(R.p.x+x,R.p.y-x,x,i)),T.push(new $a(R.p.x-x,R.p.y+x,x,i)),T.push(new $a(R.p.x+x,R.p.y+x,x,i)),k+=4)}return r&&(console.log(`num probes: ${k}`),console.log(`best distance: ${E.d}`)),E.p}function Hp(i,e){return e.max-i.max}function $a(i,e,r,o){this.p=new ce(i,e),this.h=r,this.d=function(l,h){let p=!1,m=1/0;for(let _=0;_l.y!=B.y>l.y&&l.x<(B.x-R.x)*(l.y-R.y)/(B.y-R.y)+R.x&&(p=!p),m=Math.min(m,gu(l,R,B))}}return(p?1:-1)*Math.sqrt(m)}(this.p,o),this.max=this.d+this.h*Math.SQRT2}var Fr;M.ap=void 0,(Fr=M.ap||(M.ap={}))[Fr.center=1]="center",Fr[Fr.left=2]="left",Fr[Fr.right=3]="right",Fr[Fr.top=4]="top",Fr[Fr.bottom=5]="bottom",Fr[Fr["top-left"]=6]="top-left",Fr[Fr["top-right"]=7]="top-right",Fr[Fr["bottom-left"]=8]="bottom-left",Fr[Fr["bottom-right"]=9]="bottom-right";const Ns=7,$c=Number.POSITIVE_INFINITY;function Dh(i,e){return e[1]!==$c?function(r,o,l){let h=0,p=0;switch(o=Math.abs(o),l=Math.abs(l),r){case"top-right":case"top-left":case"top":p=l-Ns;break;case"bottom-right":case"bottom-left":case"bottom":p=-l+Ns}switch(r){case"top-right":case"bottom-right":case"right":h=-o;break;case"top-left":case"bottom-left":case"left":h=o}return[h,p]}(i,e[0],e[1]):function(r,o){let l=0,h=0;o<0&&(o=0);const p=o/Math.SQRT2;switch(r){case"top-right":case"top-left":h=p-Ns;break;case"bottom-right":case"bottom-left":h=-p+Ns;break;case"bottom":h=-o+Ns;break;case"top":h=o-Ns}switch(r){case"top-right":case"bottom-right":l=-p;break;case"top-left":case"bottom-left":l=p;break;case"left":l=o;break;case"right":l=-o}return[l,h]}(i,e[0])}function Rh(i,e,r){var o;const l=i.layout,h=(o=l.get("text-variable-anchor-offset"))===null||o===void 0?void 0:o.evaluate(e,{},r);if(h){const m=h.values,_=[];for(let x=0;xk*fr);T.startsWith("top")?E[1]-=Ns:T.startsWith("bottom")&&(E[1]+=Ns),_[x+1]=E}return new Oi(_)}const p=l.get("text-variable-anchor");if(p){let m;m=i._unevaluatedLayout.getValue("text-radial-offset")!==void 0?[l.get("text-radial-offset").evaluate(e,{},r)*fr,$c]:l.get("text-offset").evaluate(e,{},r).map(x=>x*fr);const _=[];for(const x of p)_.push(x,Dh(x,m));return new Oi(_)}return null}function Gc(i){switch(i){case"right":case"top-right":case"bottom-right":return"right";case"left":case"top-left":case"bottom-left":return"left"}return"center"}function Wp(i,e,r,o,l,h,p,m,_,x,T){let E=h.textMaxSize.evaluate(e,{});E===void 0&&(E=p);const k=i.layers[0].layout,R=k.get("icon-offset").evaluate(e,{},T),B=Bh(r.horizontal),V=p/24,q=i.tilePixelRatio*V,J=i.tilePixelRatio*E/24,pe=i.tilePixelRatio*m,Y=i.tilePixelRatio*k.get("symbol-spacing"),se=k.get("text-padding")*i.tilePixelRatio,Ie=function(Le,ht,st,Rt=1){const vi=Le.get("icon-padding").evaluate(ht,{},st),Mi=vi&&vi.values;return[Mi[0]*Rt,Mi[1]*Rt,Mi[2]*Rt,Mi[3]*Rt]}(k,e,T,i.tilePixelRatio),Me=k.get("text-max-angle")/180*Math.PI,Qe=k.get("text-rotation-alignment")!=="viewport"&&k.get("symbol-placement")!=="point",nt=k.get("icon-rotation-alignment")==="map"&&k.get("symbol-placement")!=="point",Ke=k.get("symbol-placement"),qe=Y/2,Oe=k.get("icon-text-fit");let tt;o&&Oe!=="none"&&(i.allowVerticalPlacement&&r.vertical&&(tt=sh(o,r.vertical,Oe,k.get("icon-text-fit-padding"),R,V)),B&&(o=sh(o,B,Oe,k.get("icon-text-fit-padding"),R,V)));const Ge=(Le,ht)=>{ht.x<0||ht.x>=Hi||ht.y<0||ht.y>=Hi||function(st,Rt,vi,Mi,mr,Bn,an,nr,zr,Br,ln,cn,gr,yr,Zr,un,qr,bn,wn,_r,Vt,Hr,Or,vr,po){const Mo=st.addToLineVertexArray(Rt,vi);let Ao,ls,fo,Qn,In=0,cs=0,Sl=0,Uh=0,Yc=-1,Qc=-1;const us={};let jh=ji("");if(st.allowVerticalPlacement&&Mi.vertical){const Wr=nr.layout.get("text-rotate").evaluate(Vt,{},vr)+90;fo=new rc(zr,Rt,Br,ln,cn,Mi.vertical,gr,yr,Zr,Wr),an&&(Qn=new rc(zr,Rt,Br,ln,cn,an,qr,bn,Zr,Wr))}if(mr){const Wr=nr.layout.get("icon-rotate").evaluate(Vt,{}),eo=nr.layout.get("icon-text-fit")!=="none",ha=Lh(mr,Wr,Or,eo),ko=an?Lh(an,Wr,Or,eo):void 0;ls=new rc(zr,Rt,Br,ln,cn,mr,qr,bn,!1,Wr),In=4*ha.length;const da=st.iconSizeData;let Go=null;da.kind==="source"?(Go=[$o*nr.layout.get("icon-size").evaluate(Vt,{})],Go[0]>Fs&&pi(`${st.layerIds[0]}: Value for "icon-size" is >= ${xl}. Reduce your "icon-size".`)):da.kind==="composite"&&(Go=[$o*Hr.compositeIconSizes[0].evaluate(Vt,{},vr),$o*Hr.compositeIconSizes[1].evaluate(Vt,{},vr)],(Go[0]>Fs||Go[1]>Fs)&&pi(`${st.layerIds[0]}: Value for "icon-size" is >= ${xl}. Reduce your "icon-size".`)),st.addSymbols(st.icon,ha,Go,_r,wn,Vt,M.ah.none,Rt,Mo.lineStartIndex,Mo.lineLength,-1,vr),Yc=st.icon.placedSymbolArray.length-1,ko&&(cs=4*ko.length,st.addSymbols(st.icon,ko,Go,_r,wn,Vt,M.ah.vertical,Rt,Mo.lineStartIndex,Mo.lineLength,-1,vr),Qc=st.icon.placedSymbolArray.length-1)}const $h=Object.keys(Mi.horizontal);for(const Wr of $h){const eo=Mi.horizontal[Wr];if(!Ao){jh=ji(eo.text);const ko=nr.layout.get("text-rotate").evaluate(Vt,{},vr);Ao=new rc(zr,Rt,Br,ln,cn,eo,gr,yr,Zr,ko)}const ha=eo.positionedLines.length===1;if(Sl+=Fh(st,Rt,eo,Bn,nr,Zr,Vt,un,Mo,Mi.vertical?M.ah.horizontal:M.ah.horizontalOnly,ha?$h:[Wr],us,Yc,Hr,vr),ha)break}Mi.vertical&&(Uh+=Fh(st,Rt,Mi.vertical,Bn,nr,Zr,Vt,un,Mo,M.ah.vertical,["vertical"],us,Qc,Hr,vr));const Kp=Ao?Ao.boxStartIndex:st.collisionBoxArray.length,Yp=Ao?Ao.boxEndIndex:st.collisionBoxArray.length,Qp=fo?fo.boxStartIndex:st.collisionBoxArray.length,ef=fo?fo.boxEndIndex:st.collisionBoxArray.length,tf=ls?ls.boxStartIndex:st.collisionBoxArray.length,rf=ls?ls.boxEndIndex:st.collisionBoxArray.length,nf=Qn?Qn.boxStartIndex:st.collisionBoxArray.length,of=Qn?Qn.boxEndIndex:st.collisionBoxArray.length;let Po=-1;const oc=(Wr,eo)=>Wr&&Wr.circleDiameter?Math.max(Wr.circleDiameter,eo):eo;Po=oc(Ao,Po),Po=oc(fo,Po),Po=oc(ls,Po),Po=oc(Qn,Po);const Gh=Po>-1?1:0;Gh&&(Po*=po/fr),st.glyphOffsetArray.length>=Ua.MAX_GLYPHS&&pi("Too many glyphs being rendered in a tile. See https://github.com/mapbox/mapbox-gl-js/issues/2907"),Vt.sortKey!==void 0&&st.addToSortKeyRanges(st.symbolInstances.length,Vt.sortKey);const sf=Rh(nr,Vt,vr),[af,lf]=function(Wr,eo){const ha=Wr.length,ko=eo==null?void 0:eo.values;if((ko==null?void 0:ko.length)>0)for(let da=0;da=0?us.right:-1,us.center>=0?us.center:-1,us.left>=0?us.left:-1,us.vertical||-1,Yc,Qc,jh,Kp,Yp,Qp,ef,tf,rf,nf,of,Br,Sl,Uh,In,cs,Gh,0,gr,Po,af,lf)}(i,ht,Le,r,o,l,tt,i.layers[0],i.collisionBoxArray,e.index,e.sourceLayerIndex,i.index,q,[se,se,se,se],Qe,_,pe,Ie,nt,R,e,h,x,T,p)};if(Ke==="line")for(const Le of Eh(e.geometry,0,0,Hi,Hi)){const ht=$p(Le,Y,Me,r.vertical||B,o,24,J,i.overscaling,Hi);for(const st of ht)B&&Xp(i,B.text,qe,st)||Ge(Le,st)}else if(Ke==="line-center"){for(const Le of e.geometry)if(Le.length>1){const ht=jp(Le,Me,r.vertical||B,o,24,J);ht&&Ge(Le,ht)}}else if(e.type==="Polygon")for(const Le of wc(e.geometry,0)){const ht=qp(Le,16);Ge(Le[0],new Os(ht.x,ht.y,0))}else if(e.type==="LineString")for(const Le of e.geometry)Ge(Le,new Os(Le[0].x,Le[0].y,0));else if(e.type==="Point")for(const Le of e.geometry)for(const ht of Le)Ge([ht],new Os(ht.x,ht.y,0))}function Fh(i,e,r,o,l,h,p,m,_,x,T,E,k,R,B){const V=function(pe,Y,se,Ie,Me,Qe,nt,Ke){const qe=Ie.layout.get("text-rotate").evaluate(Qe,{})*Math.PI/180,Oe=[];for(const tt of Y.positionedLines)for(const Ge of tt.positionedGlyphs){if(!Ge.rect)continue;const Le=Ge.rect||{};let ht=Qu+1,st=!0,Rt=1,vi=0;const Mi=(Me||Ke)&&Ge.vertical,mr=Ge.metrics.advance*Ge.scale/2;if(Ke&&Y.verticalizable&&(vi=tt.lineOffset/2-(Ge.imageName?-(fr-Ge.metrics.width*Ge.scale)/2:(Ge.scale-1)*fr)),Ge.imageName){const _r=nt[Ge.imageName];st=_r.sdf,Rt=_r.pixelRatio,ht=xn/Rt}const Bn=Me?[Ge.x+mr,Ge.y]:[0,0];let an=Me?[0,0]:[Ge.x+mr+se[0],Ge.y+se[1]-vi],nr=[0,0];Mi&&(nr=an,an=[0,0]);const zr=Ge.metrics.isDoubleResolution?2:1,Br=(Ge.metrics.left-ht)*Ge.scale-mr+an[0],ln=(-Ge.metrics.top-ht)*Ge.scale+an[1],cn=Br+Le.w/zr*Ge.scale/Rt,gr=ln+Le.h/zr*Ge.scale/Rt,yr=new ce(Br,ln),Zr=new ce(cn,ln),un=new ce(Br,gr),qr=new ce(cn,gr);if(Mi){const _r=new ce(-mr,mr-_l),Vt=-Math.PI/2,Hr=fr/2-mr,Or=new ce(5-_l-Hr,-(Ge.imageName?Hr:0)),vr=new ce(...nr);yr._rotateAround(Vt,_r)._add(Or)._add(vr),Zr._rotateAround(Vt,_r)._add(Or)._add(vr),un._rotateAround(Vt,_r)._add(Or)._add(vr),qr._rotateAround(Vt,_r)._add(Or)._add(vr)}if(qe){const _r=Math.sin(qe),Vt=Math.cos(qe),Hr=[Vt,-_r,_r,Vt];yr._matMult(Hr),Zr._matMult(Hr),un._matMult(Hr),qr._matMult(Hr)}const bn=new ce(0,0),wn=new ce(0,0);Oe.push({tl:yr,tr:Zr,bl:un,br:qr,tex:Le,writingMode:Y.writingMode,glyphOffset:Bn,sectionIndex:Ge.sectionIndex,isSDF:st,pixelOffsetTL:bn,pixelOffsetBR:wn,minFontScaleX:0,minFontScaleY:0})}return Oe}(0,r,m,l,h,p,o,i.allowVerticalPlacement),q=i.textSizeData;let J=null;q.kind==="source"?(J=[$o*l.layout.get("text-size").evaluate(p,{})],J[0]>Fs&&pi(`${i.layerIds[0]}: Value for "text-size" is >= ${xl}. Reduce your "text-size".`)):q.kind==="composite"&&(J=[$o*R.compositeTextSizes[0].evaluate(p,{},B),$o*R.compositeTextSizes[1].evaluate(p,{},B)],(J[0]>Fs||J[1]>Fs)&&pi(`${i.layerIds[0]}: Value for "text-size" is >= ${xl}. Reduce your "text-size".`)),i.addSymbols(i.text,V,J,m,h,p,x,e,_.lineStartIndex,_.lineLength,k,B);for(const pe of T)E[pe]=i.text.placedSymbolArray.length-1;return 4*V.length}function Bh(i){for(const e in i)return i[e];return null}function Xp(i,e,r,o){const l=i.compareText;if(e in l){const h=l[e];for(let p=h.length-1;p>=0;p--)if(o.dist(h[p])>4;if(l!==1)throw new Error(`Got v${l} data when expected v1.`);const h=Oh[15&o];if(!h)throw new Error("Unrecognized array type.");const[p]=new Uint16Array(e,2,1),[m]=new Uint32Array(e,4,1);return new Zc(m,p,h,e)}constructor(e,r=64,o=Float64Array,l){if(isNaN(e)||e<0)throw new Error(`Unpexpected numItems value: ${e}.`);this.numItems=+e,this.nodeSize=Math.min(Math.max(+r,2),65535),this.ArrayType=o,this.IndexArrayType=e<65536?Uint16Array:Uint32Array;const h=Oh.indexOf(this.ArrayType),p=2*e*this.ArrayType.BYTES_PER_ELEMENT,m=e*this.IndexArrayType.BYTES_PER_ELEMENT,_=(8-m%8)%8;if(h<0)throw new Error(`Unexpected typed array class: ${o}.`);l&&l instanceof ArrayBuffer?(this.data=l,this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=2*e,this._finished=!0):(this.data=new ArrayBuffer(8+p+m+_),this.ids=new this.IndexArrayType(this.data,8,e),this.coords=new this.ArrayType(this.data,8+m+_,2*e),this._pos=0,this._finished=!1,new Uint8Array(this.data,0,2).set([219,16+h]),new Uint16Array(this.data,2,1)[0]=r,new Uint32Array(this.data,4,1)[0]=e)}add(e,r){const o=this._pos>>1;return this.ids[o]=o,this.coords[this._pos++]=e,this.coords[this._pos++]=r,o}finish(){const e=this._pos>>1;if(e!==this.numItems)throw new Error(`Added ${e} items when expected ${this.numItems}.`);return qc(this.ids,this.coords,this.nodeSize,0,this.numItems-1,0),this._finished=!0,this}range(e,r,o,l){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:h,coords:p,nodeSize:m}=this,_=[0,h.length-1,0],x=[];for(;_.length;){const T=_.pop()||0,E=_.pop()||0,k=_.pop()||0;if(E-k<=m){for(let q=k;q<=E;q++){const J=p[2*q],pe=p[2*q+1];J>=e&&J<=o&&pe>=r&&pe<=l&&x.push(h[q])}continue}const R=k+E>>1,B=p[2*R],V=p[2*R+1];B>=e&&B<=o&&V>=r&&V<=l&&x.push(h[R]),(T===0?e<=B:r<=V)&&(_.push(k),_.push(R-1),_.push(1-T)),(T===0?o>=B:l>=V)&&(_.push(R+1),_.push(E),_.push(1-T))}return x}within(e,r,o){if(!this._finished)throw new Error("Data not yet indexed - call index.finish().");const{ids:l,coords:h,nodeSize:p}=this,m=[0,l.length-1,0],_=[],x=o*o;for(;m.length;){const T=m.pop()||0,E=m.pop()||0,k=m.pop()||0;if(E-k<=p){for(let q=k;q<=E;q++)Vh(h[2*q],h[2*q+1],e,r)<=x&&_.push(l[q]);continue}const R=k+E>>1,B=h[2*R],V=h[2*R+1];Vh(B,V,e,r)<=x&&_.push(l[R]),(T===0?e-o<=B:r-o<=V)&&(m.push(k),m.push(R-1),m.push(1-T)),(T===0?e+o>=B:r+o>=V)&&(m.push(R+1),m.push(E),m.push(1-T))}return _}}function qc(i,e,r,o,l,h){if(l-o<=r)return;const p=o+l>>1;Nh(i,e,p,o,l,h),qc(i,e,r,o,p-1,1-h),qc(i,e,r,p+1,l,1-h)}function Nh(i,e,r,o,l,h){for(;l>o;){if(l-o>600){const x=l-o+1,T=r-o+1,E=Math.log(x),k=.5*Math.exp(2*E/3),R=.5*Math.sqrt(E*k*(x-k)/x)*(T-x/2<0?-1:1);Nh(i,e,r,Math.max(o,Math.floor(r-T*k/x+R)),Math.min(l,Math.floor(r+(x-T)*k/x+R)),h)}const p=e[2*r+h];let m=o,_=l;for(wl(i,e,o,r),e[2*l+h]>p&&wl(i,e,o,l);m<_;){for(wl(i,e,m,_),m++,_--;e[2*m+h]p;)_--}e[2*o+h]===p?wl(i,e,o,_):(_++,wl(i,e,_,l)),_<=r&&(o=_+1),r<=_&&(l=_-1)}}function wl(i,e,r,o){Hc(i,r,o),Hc(e,2*r,2*o),Hc(e,2*r+1,2*o+1)}function Hc(i,e,r){const o=i[e];i[e]=i[r],i[r]=o}function Vh(i,e,r,o){const l=i-r,h=e-o;return l*l+h*h}var Wc;M.bd=void 0,(Wc=M.bd||(M.bd={})).create="create",Wc.load="load",Wc.fullLoad="fullLoad";let nc=null,Il=[];const Xc=1e3/60,Jc="loadTime",Kc="fullLoadTime",Jp={mark(i){performance.mark(i)},frame(i){const e=i;nc!=null&&Il.push(e-nc),nc=e},clearMetrics(){nc=null,Il=[],performance.clearMeasures(Jc),performance.clearMeasures(Kc);for(const i in M.bd)performance.clearMarks(M.bd[i])},getPerformanceMetrics(){performance.measure(Jc,M.bd.create,M.bd.load),performance.measure(Kc,M.bd.create,M.bd.fullLoad);const i=performance.getEntriesByName(Jc)[0].duration,e=performance.getEntriesByName(Kc)[0].duration,r=Il.length,o=1/(Il.reduce((h,p)=>h+p,0)/r/1e3),l=Il.filter(h=>h>Xc).reduce((h,p)=>h+(p-Xc)/Xc,0);return{loadTime:i,fullLoadTime:e,fps:o,percentDroppedFrames:l/(r+l)*100,totalFrames:r}}};M.$=Ne,M.A=Ra,M.B=function(i){if(br==null){const e=i.navigator?i.navigator.userAgent:null;br=!!i.safari||!(!e||!(/\b(iPad|iPhone|iPod)\b/.test(e)||e.match("Safari")&&!e.match("Chrome")))}return br},M.C=class{constructor(i,e){this.target=i,this.mapId=e,this.resolveRejects={},this.tasks={},this.taskQueue=[],this.abortControllers={},this.messageHandlers={},this.invoker=new Vp(()=>this.process()),this.subscription=function(r,o,l,h){return r.addEventListener(o,l,!1),{unsubscribe:()=>{r.removeEventListener(o,l,!1)}}}(this.target,"message",r=>this.receive(r)),this.globalScope=xr(self)?i:window}registerMessageHandler(i,e){this.messageHandlers[i]=e}sendAsync(i,e){return new Promise((r,o)=>{const l=Math.round(1e18*Math.random()).toString(36).substring(0,10);this.resolveRejects[l]={resolve:r,reject:o},e&&e.signal.addEventListener("abort",()=>{delete this.resolveRejects[l];const m={id:l,type:"",origin:location.origin,targetMapId:i.targetMapId,sourceMapId:this.mapId};this.target.postMessage(m)},{once:!0});const h=[],p=Object.assign(Object.assign({},i),{id:l,sourceMapId:this.mapId,origin:location.origin,data:yn(i.data,h)});this.target.postMessage(p,{transfer:h})})}receive(i){const e=i.data,r=e.id;if(!(e.origin!=="file://"&&location.origin!=="file://"&&e.origin!==location.origin||e.targetMapId&&this.mapId!==e.targetMapId)){if(e.type===""){delete this.tasks[r];const o=this.abortControllers[r];return delete this.abortControllers[r],void(o&&o.abort())}if(xr(self)||e.mustQueue)return this.tasks[r]=e,this.taskQueue.push(r),void this.invoker.trigger();this.processTask(r,e)}}process(){if(this.taskQueue.length===0)return;const i=this.taskQueue.shift(),e=this.tasks[i];delete this.tasks[i],this.taskQueue.length>0&&this.invoker.trigger(),e&&this.processTask(i,e)}processTask(i,e){return d(this,void 0,void 0,function*(){if(e.type===""){const l=this.resolveRejects[i];return delete this.resolveRejects[i],l?void(e.error?l.reject(nn(e.error)):l.resolve(nn(e.data))):void 0}if(!this.messageHandlers[e.type])return void this.completeTask(i,new Error(`Could not find a registered handler for ${e.type}, map ID: ${this.mapId}, available handlers: ${Object.keys(this.messageHandlers).join(", ")}`));const r=nn(e.data),o=new AbortController;this.abortControllers[i]=o;try{const l=yield this.messageHandlers[e.type](e.sourceMapId,r,o);this.completeTask(i,null,l)}catch(l){this.completeTask(i,l)}})}completeTask(i,e,r){const o=[];delete this.abortControllers[i];const l={id:i,type:"",sourceMapId:this.mapId,origin:location.origin,error:e?yn(e):null,data:yn(r,o)};this.target.postMessage(l,{transfer:o})}remove(){this.invoker.remove(),this.subscription.unsubscribe()}},M.D=at,M.E=Ot,M.F=function(){var i=new Ra(16);return Ra!=Float32Array&&(i[1]=0,i[2]=0,i[3]=0,i[4]=0,i[6]=0,i[7]=0,i[8]=0,i[9]=0,i[11]=0,i[12]=0,i[13]=0,i[14]=0),i[0]=1,i[5]=1,i[10]=1,i[15]=1,i},M.G=or,M.H=function(i,e,r){var o,l,h,p,m,_,x,T,E,k,R,B,V=r[0],q=r[1],J=r[2];return e===i?(i[12]=e[0]*V+e[4]*q+e[8]*J+e[12],i[13]=e[1]*V+e[5]*q+e[9]*J+e[13],i[14]=e[2]*V+e[6]*q+e[10]*J+e[14],i[15]=e[3]*V+e[7]*q+e[11]*J+e[15]):(l=e[1],h=e[2],p=e[3],m=e[4],_=e[5],x=e[6],T=e[7],E=e[8],k=e[9],R=e[10],B=e[11],i[0]=o=e[0],i[1]=l,i[2]=h,i[3]=p,i[4]=m,i[5]=_,i[6]=x,i[7]=T,i[8]=E,i[9]=k,i[10]=R,i[11]=B,i[12]=o*V+m*q+E*J+e[12],i[13]=l*V+_*q+k*J+e[13],i[14]=h*V+x*q+R*J+e[14],i[15]=p*V+T*q+B*J+e[15]),i},M.I=Lc,M.J=function(i,e,r){var o=r[0],l=r[1],h=r[2];return i[0]=e[0]*o,i[1]=e[1]*o,i[2]=e[2]*o,i[3]=e[3]*o,i[4]=e[4]*l,i[5]=e[5]*l,i[6]=e[6]*l,i[7]=e[7]*l,i[8]=e[8]*h,i[9]=e[9]*h,i[10]=e[10]*h,i[11]=e[11]*h,i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15],i},M.K=xu,M.L=function(i,e){const r={};for(let o=0;o{const e=window.document.createElement("video");return e.muted=!0,new Promise(r=>{e.onloadstart=()=>{r(e)};for(const o of i){const l=window.document.createElement("source");Vn(o)||(e.crossOrigin="Anonymous"),l.src=o,e.appendChild(l)}})},M.a3=function(){return kt++},M.a4=c,M.a5=Ua,M.a6=bo,M.a7=ss,M.a8=Ei,M.a9=wh,M.aA=St,M.aB=function(i,e){if(!i)return[{command:"setStyle",args:[e]}];let r=[];try{if(!ft(i.version,e.version))return[{command:"setStyle",args:[e]}];ft(i.center,e.center)||r.push({command:"setCenter",args:[e.center]}),ft(i.zoom,e.zoom)||r.push({command:"setZoom",args:[e.zoom]}),ft(i.bearing,e.bearing)||r.push({command:"setBearing",args:[e.bearing]}),ft(i.pitch,e.pitch)||r.push({command:"setPitch",args:[e.pitch]}),ft(i.sprite,e.sprite)||r.push({command:"setSprite",args:[e.sprite]}),ft(i.glyphs,e.glyphs)||r.push({command:"setGlyphs",args:[e.glyphs]}),ft(i.transition,e.transition)||r.push({command:"setTransition",args:[e.transition]}),ft(i.light,e.light)||r.push({command:"setLight",args:[e.light]}),ft(i.terrain,e.terrain)||r.push({command:"setTerrain",args:[e.terrain]}),ft(i.sky,e.sky)||r.push({command:"setSky",args:[e.sky]});const o={},l=[];(function(p,m,_,x){let T;for(T in m=m||{},p=p||{})Object.prototype.hasOwnProperty.call(p,T)&&(Object.prototype.hasOwnProperty.call(m,T)||Cn(T,_,x));for(T in m)Object.prototype.hasOwnProperty.call(m,T)&&(Object.prototype.hasOwnProperty.call(p,T)?ft(p[T],m[T])||(p[T].type==="geojson"&&m[T].type==="geojson"&&Ur(p,m,T)?ci(_,{command:"setGeoJSONSourceData",args:[T,m[T].data]}):Kr(T,m,_,x)):Un(T,m,_))})(i.sources,e.sources,l,o);const h=[];i.layers&&i.layers.forEach(p=>{"source"in p&&o[p.source]?r.push({command:"removeLayer",args:[p.id]}):h.push(p)}),r=r.concat(l),function(p,m,_){m=m||[];const x=(p=p||[]).map(jn),T=m.map(jn),E=p.reduce(jr,{}),k=m.reduce(jr,{}),R=x.slice(),B=Object.create(null);let V,q,J,pe,Y;for(let se=0,Ie=0;se@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)(?:\=(?:([^\x00-\x20\(\)<>@\,;\:\\"\/\[\]\?\=\{\}\x7F]+)|(?:\"((?:[^"\\]|\\.)*)\")))?/g,(r,o,l,h)=>{const p=l||h;return e[o]=!p||p.toLowerCase(),""}),e["max-age"]){const r=parseInt(e["max-age"],10);isNaN(r)?delete e["max-age"]:e["max-age"]=r}return e},M.ab=function(i,e){const r=[];for(const o in i)o in e||r.push(o);return r},M.ac=Gt,M.ad=function(i,e,r){var o=Math.sin(r),l=Math.cos(r),h=e[0],p=e[1],m=e[2],_=e[3],x=e[4],T=e[5],E=e[6],k=e[7];return e!==i&&(i[8]=e[8],i[9]=e[9],i[10]=e[10],i[11]=e[11],i[12]=e[12],i[13]=e[13],i[14]=e[14],i[15]=e[15]),i[0]=h*l+x*o,i[1]=p*l+T*o,i[2]=m*l+E*o,i[3]=_*l+k*o,i[4]=x*l-h*o,i[5]=T*l-p*o,i[6]=E*l-m*o,i[7]=k*l-_*o,i},M.ae=function(i){var e=new Ra(16);return e[0]=i[0],e[1]=i[1],e[2]=i[2],e[3]=i[3],e[4]=i[4],e[5]=i[5],e[6]=i[6],e[7]=i[7],e[8]=i[8],e[9]=i[9],e[10]=i[10],e[11]=i[11],e[12]=i[12],e[13]=i[13],e[14]=i[14],e[15]=i[15],e},M.af=jl,M.ag=function(i,e){let r=0,o=0;if(i.kind==="constant")o=i.layoutSize;else if(i.kind!=="source"){const{interpolationType:l,minZoom:h,maxZoom:p}=i,m=l?Gt(lr.interpolationFactor(l,e,h,p),0,1):0;i.kind==="camera"?o=wr.number(i.minSize,i.maxSize,m):r=m}return{uSizeT:r,uSize:o}},M.ai=function(i,{uSize:e,uSizeT:r},{lowerSize:o,upperSize:l}){return i.kind==="source"?o/$o:i.kind==="composite"?wr.number(o/$o,l/$o,r):e},M.aj=Fc,M.ak=function(i,e,r,o){const l=e.y-i.y,h=e.x-i.x,p=o.y-r.y,m=o.x-r.x,_=p*h-m*l;if(_===0)return null;const x=(m*(i.y-r.y)-p*(i.x-r.x))/_;return new ce(i.x+x*h,i.y+x*l)},M.al=Eh,M.am=nl,M.an=mc,M.ao=fr,M.aq=Rc,M.ar=function(i,e){var r=e[0],o=e[1],l=e[2],h=e[3],p=e[4],m=e[5],_=e[6],x=e[7],T=e[8],E=e[9],k=e[10],R=e[11],B=e[12],V=e[13],q=e[14],J=e[15],pe=r*m-o*p,Y=r*_-l*p,se=r*x-h*p,Ie=o*_-l*m,Me=o*x-h*m,Qe=l*x-h*_,nt=T*V-E*B,Ke=T*q-k*B,qe=T*J-R*B,Oe=E*q-k*V,tt=E*J-R*V,Ge=k*J-R*q,Le=pe*Ge-Y*tt+se*Oe+Ie*qe-Me*Ke+Qe*nt;return Le?(i[0]=(m*Ge-_*tt+x*Oe)*(Le=1/Le),i[1]=(l*tt-o*Ge-h*Oe)*Le,i[2]=(V*Qe-q*Me+J*Ie)*Le,i[3]=(k*Me-E*Qe-R*Ie)*Le,i[4]=(_*qe-p*Ge-x*Ke)*Le,i[5]=(r*Ge-l*qe+h*Ke)*Le,i[6]=(q*se-B*Qe-J*Y)*Le,i[7]=(T*Qe-k*se+R*Y)*Le,i[8]=(p*tt-m*qe+x*nt)*Le,i[9]=(o*qe-r*tt-h*nt)*Le,i[10]=(B*Me-V*se+J*pe)*Le,i[11]=(E*se-T*Me-R*pe)*Le,i[12]=(m*Ke-p*Oe-_*nt)*Le,i[13]=(r*Oe-o*Ke+l*nt)*Le,i[14]=(V*Y-B*Ie-q*pe)*Le,i[15]=(T*Ie-E*Y+k*pe)*Le,i):null},M.as=Gc,M.at=Dc,M.au=Zc,M.av=function(){const i={},e=be.$version;for(const r in be.$root){const o=be.$root[r];if(o.required){let l=null;l=r==="version"?e:o.type==="array"?[]:{},l!=null&&(i[r]=l)}}return i},M.aw=ea,M.ax=Ii,M.ay=function(i){i=i.slice();const e=Object.create(null);for(let r=0;rLe*fr)}let Ke=p?"center":r.get("text-justify").evaluate(x,{},i.canonical);const qe=r.get("symbol-placement"),Oe=qe==="point"?r.get("text-max-width").evaluate(x,{},i.canonical)*fr:0,tt=()=>{i.bucket.allowVerticalPlacement&&co(se)&&(B.vertical=Xl(V,i.glyphMap,i.glyphPositions,i.imagePositions,T,Oe,h,Qe,"left",Me,J,M.ah.vertical,!0,qe,k,E))};if(!p&&nt){const Ge=new Set;if(Ke==="auto")for(let ht=0;htd(void 0,void 0,void 0,function*(){if(i.byteLength===0)return createImageBitmap(new ImageData(1,1));const e=new Blob([new Uint8Array(i)],{type:"image/png"});try{return createImageBitmap(e)}catch(r){throw new Error(`Could not load image because of ${r.message}. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported.`)}}),M.e=li,M.f=i=>new Promise((e,r)=>{const o=new Image;o.onload=()=>{e(o),URL.revokeObjectURL(o.src),o.onload=null,window.requestAnimationFrame(()=>{o.src=Dr})},o.onerror=()=>r(new Error("Could not load image. Please make sure to use a supported image type such as PNG or JPEG. Note that SVGs are not supported."));const l=new Blob([new Uint8Array(i)],{type:"image/png"});o.src=i.byteLength?URL.createObjectURL(l):Dr}),M.g=wi,M.h=(i,e)=>bt(li(i,{type:"json"}),e),M.i=xr,M.j=Jr,M.k=Yt,M.l=(i,e)=>bt(li(i,{type:"arrayBuffer"}),e),M.m=bt,M.n=function(i){return new Pc(i).readFields(Tp,[])},M.o=ul,M.p=eh,M.q=on,M.r=Ls,M.s=Vn,M.t=ur,M.u=Ze,M.v=be,M.w=pi,M.x=qt,M.y=function([i,e,r]){return e+=90,e*=Math.PI/180,r*=Math.PI/180,{x:i*Math.cos(e)*Math.sin(r),y:i*Math.sin(e)*Math.sin(r),z:i*Math.cos(r)}},M.z=wr}),U("worker",["./shared"],function(M){class d{constructor(P){this.keyCache={},P&&this.replace(P)}replace(P){this._layerConfigs={},this._layers={},this.update(P,[])}update(P,z){for(const j of P){this._layerConfigs[j.id]=j;const re=this._layers[j.id]=M.az(j);re._featureFilter=M.a6(re.filter),this.keyCache[j.id]&&delete this.keyCache[j.id]}for(const j of z)delete this.keyCache[j],delete this._layerConfigs[j],delete this._layers[j];this.familiesBySource={};const O=M.bh(Object.values(this._layerConfigs),this.keyCache);for(const j of O){const re=j.map(ve=>this._layers[ve.id]),ne=re[0];if(ne.visibility==="none")continue;const le=ne.source||"";let K=this.familiesBySource[le];K||(K=this.familiesBySource[le]={});const fe=ne.sourceLayer||"_geojsonTileLayer";let Ce=K[fe];Ce||(Ce=K[fe]=[]),Ce.push(re)}}}class Se{constructor(P){const z={},O=[];for(const le in P){const K=P[le],fe=z[le]={};for(const Ce in K){const ve=K[+Ce];if(!ve||ve.bitmap.width===0||ve.bitmap.height===0)continue;const we={x:0,y:0,w:ve.bitmap.width+2,h:ve.bitmap.height+2};O.push(we),fe[Ce]={rect:we,metrics:ve.metrics}}}const{w:j,h:re}=M.p(O),ne=new M.o({width:j||1,height:re||1});for(const le in P){const K=P[le];for(const fe in K){const Ce=K[+fe];if(!Ce||Ce.bitmap.width===0||Ce.bitmap.height===0)continue;const ve=z[le][fe].rect;M.o.copy(Ce.bitmap,ne,{x:0,y:0},{x:ve.x+1,y:ve.y+1},Ce.bitmap)}}this.image=ne,this.positions=z}}M.bi("GlyphAtlas",Se);class Re{constructor(P){this.tileID=new M.Q(P.tileID.overscaledZ,P.tileID.wrap,P.tileID.canonical.z,P.tileID.canonical.x,P.tileID.canonical.y),this.uid=P.uid,this.zoom=P.zoom,this.pixelRatio=P.pixelRatio,this.tileSize=P.tileSize,this.source=P.source,this.overscaling=this.tileID.overscaleFactor(),this.showCollisionBoxes=P.showCollisionBoxes,this.collectResourceTiming=!!P.collectResourceTiming,this.returnDependencies=!!P.returnDependencies,this.promoteId=P.promoteId,this.inFlightDependencies=[]}parse(P,z,O,j){return M._(this,void 0,void 0,function*(){this.status="parsing",this.data=P,this.collisionBoxArray=new M.a4;const re=new M.bj(Object.keys(P.layers).sort()),ne=new M.bk(this.tileID,this.promoteId);ne.bucketLayerIDs=[];const le={},K={featureIndex:ne,iconDependencies:{},patternDependencies:{},glyphDependencies:{},availableImages:O},fe=z.familiesBySource[this.source];for(const ut in fe){const Si=P.layers[ut];if(!Si)continue;Si.version===1&&M.w(`Vector tile source "${this.source}" layer "${ut}" does not use vector tile spec v2 and therefore may have some rendering errors.`);const Ji=re.encode(ut),Tr=[];for(let Er=0;Er=er.maxzoom||er.visibility!=="none"&&(He(Er,this.zoom,O),(le[er.id]=er.createBucket({index:ne.bucketLayerIDs.length,layers:Er,zoom:this.zoom,pixelRatio:this.pixelRatio,overscaling:this.overscaling,collisionBoxArray:this.collisionBoxArray,sourceLayerIndex:Ji,sourceID:this.source})).populate(Tr,K,this.tileID.canonical),ne.bucketLayerIDs.push(Er.map(Qr=>Qr.id)))}}const Ce=M.aE(K.glyphDependencies,ut=>Object.keys(ut).map(Number));this.inFlightDependencies.forEach(ut=>ut==null?void 0:ut.abort()),this.inFlightDependencies=[];let ve=Promise.resolve({});if(Object.keys(Ce).length){const ut=new AbortController;this.inFlightDependencies.push(ut),ve=j.sendAsync({type:"GG",data:{stacks:Ce,source:this.source,tileID:this.tileID,type:"glyphs"}},ut)}const we=Object.keys(K.iconDependencies);let ot=Promise.resolve({});if(we.length){const ut=new AbortController;this.inFlightDependencies.push(ut),ot=j.sendAsync({type:"GI",data:{icons:we,source:this.source,tileID:this.tileID,type:"icons"}},ut)}const lt=Object.keys(K.patternDependencies);let gt=Promise.resolve({});if(lt.length){const ut=new AbortController;this.inFlightDependencies.push(ut),gt=j.sendAsync({type:"GI",data:{icons:lt,source:this.source,tileID:this.tileID,type:"patterns"}},ut)}const[_t,Lt,Xt]=yield Promise.all([ve,ot,gt]),ui=new Se(_t),Zi=new M.bl(Lt,Xt);for(const ut in le){const Si=le[ut];Si instanceof M.a5?(He(Si.layers,this.zoom,O),M.bm({bucket:Si,glyphMap:_t,glyphPositions:ui.positions,imageMap:Lt,imagePositions:Zi.iconPositions,showCollisionBoxes:this.showCollisionBoxes,canonical:this.tileID.canonical})):Si.hasPattern&&(Si instanceof M.bn||Si instanceof M.bo||Si instanceof M.bp)&&(He(Si.layers,this.zoom,O),Si.addFeatures(K,this.tileID.canonical,Zi.patternPositions))}return this.status="done",{buckets:Object.values(le).filter(ut=>!ut.isEmpty()),featureIndex:ne,collisionBoxArray:this.collisionBoxArray,glyphAtlasImage:ui.image,imageAtlas:Zi,glyphMap:this.returnDependencies?_t:null,iconMap:this.returnDependencies?Lt:null,glyphPositions:this.returnDependencies?ui.positions:null}})}}function He(G,P,z){const O=new M.a8(P);for(const j of G)j.recalculate(O,z)}class ce{constructor(P,z,O){this.actor=P,this.layerIndex=z,this.availableImages=O,this.fetching={},this.loading={},this.loaded={}}loadVectorTile(P,z){return M._(this,void 0,void 0,function*(){const O=yield M.l(P.request,z);try{return{vectorTile:new M.bq.VectorTile(new M.br(O.data)),rawData:O.data,cacheControl:O.cacheControl,expires:O.expires}}catch(j){const re=new Uint8Array(O.data);let ne=`Unable to parse the tile at ${P.request.url}, `;throw ne+=re[0]===31&&re[1]===139?"please make sure the data is not gzipped and that you have configured the relevant header in the server":`got error: ${j.messge}`,new Error(ne)}})}loadTile(P){return M._(this,void 0,void 0,function*(){const z=P.uid,O=!!(P&&P.request&&P.request.collectResourceTiming)&&new M.bs(P.request),j=new Re(P);this.loading[z]=j;const re=new AbortController;j.abort=re;try{const ne=yield this.loadVectorTile(P,re);if(delete this.loading[z],!ne)return null;const le=ne.rawData,K={};ne.expires&&(K.expires=ne.expires),ne.cacheControl&&(K.cacheControl=ne.cacheControl);const fe={};if(O){const ve=O.finish();ve&&(fe.resourceTiming=JSON.parse(JSON.stringify(ve)))}j.vectorTile=ne.vectorTile;const Ce=j.parse(ne.vectorTile,this.layerIndex,this.availableImages,this.actor);this.loaded[z]=j,this.fetching[z]={rawTileData:le,cacheControl:K,resourceTiming:fe};try{const ve=yield Ce;return M.e({rawTileData:le.slice(0)},ve,K,fe)}finally{delete this.fetching[z]}}catch(ne){throw delete this.loading[z],j.status="done",this.loaded[z]=j,ne}})}reloadTile(P){return M._(this,void 0,void 0,function*(){const z=P.uid;if(!this.loaded||!this.loaded[z])throw new Error("Should not be trying to reload a tile that was never loaded or has been removed");const O=this.loaded[z];if(O.showCollisionBoxes=P.showCollisionBoxes,O.status==="parsing"){const j=yield O.parse(O.vectorTile,this.layerIndex,this.availableImages,this.actor);let re;if(this.fetching[z]){const{rawTileData:ne,cacheControl:le,resourceTiming:K}=this.fetching[z];delete this.fetching[z],re=M.e({rawTileData:ne.slice(0)},j,le,K)}else re=j;return re}if(O.status==="done"&&O.vectorTile)return O.parse(O.vectorTile,this.layerIndex,this.availableImages,this.actor)})}abortTile(P){return M._(this,void 0,void 0,function*(){const z=this.loading,O=P.uid;z&&z[O]&&z[O].abort&&(z[O].abort.abort(),delete z[O])})}removeTile(P){return M._(this,void 0,void 0,function*(){this.loaded&&this.loaded[P.uid]&&delete this.loaded[P.uid]})}}class oe{constructor(){this.loaded={}}loadTile(P){return M._(this,void 0,void 0,function*(){const{uid:z,encoding:O,rawImageData:j,redFactor:re,greenFactor:ne,blueFactor:le,baseShift:K}=P,fe=j.width+2,Ce=j.height+2,ve=M.b(j)?new M.R({width:fe,height:Ce},yield M.bt(j,-1,-1,fe,Ce)):j,we=new M.bu(z,ve,O,re,ne,le,K);return this.loaded=this.loaded||{},this.loaded[z]=we,we})}removeTile(P){const z=this.loaded,O=P.uid;z&&z[O]&&delete z[O]}}function We(G,P){if(G.length!==0){et(G[0],P);for(var z=1;z=Math.abs(le)?z-K+le:le-K+z,z=K}z+O>=0!=!!P&&G.reverse()}var De=M.bv(function G(P,z){var O,j=P&&P.type;if(j==="FeatureCollection")for(O=0;O>31}function Nn(G,P){for(var z=G.loadGeometry(),O=G.type,j=0,re=0,ne=z.length,le=0;leG},Dr=Math.fround||(dn=new Float32Array(1),G=>(dn[0]=+G,dn[0]));var dn;const $i=3,Ai=5,ii=6;class Sr{constructor(P){this.options=Object.assign(Object.create(hn),P),this.trees=new Array(this.options.maxZoom+1),this.stride=this.options.reduce?7:6,this.clusterProps=[]}load(P){const{log:z,minZoom:O,maxZoom:j}=this.options;z&&console.time("total time");const re=`prepare ${P.length} points`;z&&console.time(re),this.points=P;const ne=[];for(let K=0;K=O;K--){const fe=+Date.now();le=this.trees[K]=this._createTree(this._cluster(le,K)),z&&console.log("z%d: %d clusters in %dms",K,le.numItems,+Date.now()-fe)}return z&&console.timeEnd("total time"),this}getClusters(P,z){let O=((P[0]+180)%360+360)%360-180;const j=Math.max(-90,Math.min(90,P[1]));let re=P[2]===180?180:((P[2]+180)%360+360)%360-180;const ne=Math.max(-90,Math.min(90,P[3]));if(P[2]-P[0]>=360)O=-180,re=180;else if(O>re){const ve=this.getClusters([O,j,180,ne],z),we=this.getClusters([-180,j,re,ne],z);return ve.concat(we)}const le=this.trees[this._limitZoom(z)],K=le.range(or(O),sr(ne),or(re),sr(j)),fe=le.data,Ce=[];for(const ve of K){const we=this.stride*ve;Ce.push(fe[we+Ai]>1?bi(fe,we,this.clusterProps):this.points[fe[we+$i]])}return Ce}getChildren(P){const z=this._getOriginId(P),O=this._getOriginZoom(P),j="No cluster with the specified id.",re=this.trees[O];if(!re)throw new Error(j);const ne=re.data;if(z*this.stride>=ne.length)throw new Error(j);const le=this.options.radius/(this.options.extent*Math.pow(2,O-1)),K=re.within(ne[z*this.stride],ne[z*this.stride+1],le),fe=[];for(const Ce of K){const ve=Ce*this.stride;ne[ve+4]===P&&fe.push(ne[ve+Ai]>1?bi(ne,ve,this.clusterProps):this.points[ne[ve+$i]])}if(fe.length===0)throw new Error(j);return fe}getLeaves(P,z,O){const j=[];return this._appendLeaves(j,P,z=z||10,O=O||0,0),j}getTile(P,z,O){const j=this.trees[this._limitZoom(P)],re=Math.pow(2,P),{extent:ne,radius:le}=this.options,K=le/ne,fe=(O-K)/re,Ce=(O+1+K)/re,ve={features:[]};return this._addTileFeatures(j.range((z-K)/re,fe,(z+1+K)/re,Ce),j.data,z,O,re,ve),z===0&&this._addTileFeatures(j.range(1-K/re,fe,1,Ce),j.data,re,O,re,ve),z===re-1&&this._addTileFeatures(j.range(0,fe,K/re,Ce),j.data,-1,O,re,ve),ve.features.length?ve:null}getClusterExpansionZoom(P){let z=this._getOriginZoom(P)-1;for(;z<=this.options.maxZoom;){const O=this.getChildren(P);if(z++,O.length!==1)break;P=O[0].properties.cluster_id}return z}_appendLeaves(P,z,O,j,re){const ne=this.getChildren(z);for(const le of ne){const K=le.properties;if(K&&K.cluster?re+K.point_count<=j?re+=K.point_count:re=this._appendLeaves(P,K.cluster_id,O,j,re):re1;let Ce,ve,we;if(fe)Ce=wi(z,K,this.clusterProps),ve=z[K],we=z[K+1];else{const gt=this.points[z[K+$i]];Ce=gt.properties;const[_t,Lt]=gt.geometry.coordinates;ve=or(_t),we=sr(Lt)}const ot={type:1,geometry:[[Math.round(this.options.extent*(ve*re-O)),Math.round(this.options.extent*(we*re-j))]],tags:Ce};let lt;lt=fe||this.options.generateId?z[K+$i]:this.points[z[K+$i]].id,lt!==void 0&&(ot.id=lt),ne.features.push(ot)}}_limitZoom(P){return Math.max(this.options.minZoom,Math.min(Math.floor(+P),this.options.maxZoom+1))}_cluster(P,z){const{radius:O,extent:j,reduce:re,minPoints:ne}=this.options,le=O/(j*Math.pow(2,z)),K=P.data,fe=[],Ce=this.stride;for(let ve=0;vez&&(_t+=K[Xt+Ai])}if(_t>gt&&_t>=ne){let Lt,Xt=we*gt,ui=ot*gt,Zi=-1;const ut=((ve/Ce|0)<<5)+(z+1)+this.points.length;for(const Si of lt){const Ji=Si*Ce;if(K[Ji+2]<=z)continue;K[Ji+2]=z;const Tr=K[Ji+Ai];Xt+=K[Ji]*Tr,ui+=K[Ji+1]*Tr,K[Ji+4]=ut,re&&(Lt||(Lt=this._map(K,ve,!0),Zi=this.clusterProps.length,this.clusterProps.push(Lt)),re(Lt,this._map(K,Ji)))}K[ve+4]=ut,fe.push(Xt/_t,ui/_t,1/0,ut,-1,_t),re&&fe.push(Zi)}else{for(let Lt=0;Lt1)for(const Lt of lt){const Xt=Lt*Ce;if(!(K[Xt+2]<=z)){K[Xt+2]=z;for(let ui=0;ui>5}_getOriginZoom(P){return(P-this.points.length)%32}_map(P,z,O){if(P[z+Ai]>1){const ne=this.clusterProps[P[z+ii]];return O?Object.assign({},ne):ne}const j=this.points[P[z+$i]].properties,re=this.options.map(j);return O&&re===j?Object.assign({},re):re}}function bi(G,P,z){return{type:"Feature",id:G[P+$i],properties:wi(G,P,z),geometry:{type:"Point",coordinates:[(O=G[P],360*(O-.5)),Ii(G[P+1])]}};var O}function wi(G,P,z){const O=G[P+Ai],j=O>=1e4?`${Math.round(O/1e3)}k`:O>=1e3?Math.round(O/100)/10+"k":O,re=G[P+ii],ne=re===-1?{}:Object.assign({},z[re]);return Object.assign(ne,{cluster:!0,cluster_id:G[P+$i],point_count:O,point_count_abbreviated:j})}function or(G){return G/360+.5}function sr(G){const P=Math.sin(G*Math.PI/180),z=.5-.25*Math.log((1+P)/(1-P))/Math.PI;return z<0?0:z>1?1:z}function Ii(G){const P=(180-360*G)*Math.PI/180;return 360*Math.atan(Math.exp(P))/Math.PI-90}function bt(G,P,z,O){for(var j,re=O,ne=z-P>>1,le=z-P,K=G[P],fe=G[P+1],Ce=G[z],ve=G[z+1],we=P+3;were)j=we,re=ot;else if(ot===re){var lt=Math.abs(we-ne);ltO&&(j-P>3&&bt(G,P,j,O),G[j+2]=re,z-j>3&&bt(G,j,z,O))}function Vn(G,P,z,O,j,re){var ne=j-z,le=re-O;if(ne!==0||le!==0){var K=((G-z)*ne+(P-O)*le)/(ne*ne+le*le);K>1?(z=j,O=re):K>0&&(z+=ne*K,O+=le*K)}return(ne=G-z)*ne+(le=P-O)*le}function Vr(G,P,z,O){var j={id:G===void 0?null:G,type:P,geometry:z,tags:O,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0};return function(re){var ne=re.geometry,le=re.type;if(le==="Point"||le==="MultiPoint"||le==="LineString")Xr(re,ne);else if(le==="Polygon"||le==="MultiLineString")for(var K=0;K0&&(ne+=O?(j*fe-K*re)/2:Math.sqrt(Math.pow(K-j,2)+Math.pow(fe-re,2))),j=K,re=fe}var Ce=P.length-3;P[2]=1,bt(P,0,Ce,z),P[Ce+2]=1,P.size=Math.abs(ne),P.start=0,P.end=P.size}function be(G,P,z,O){for(var j=0;j1?1:z}function ft(G,P,z,O,j,re,ne,le){if(O/=P,re>=(z/=P)&&ne=O)return null;for(var K=[],fe=0;fe=z&<=O)){var gt=[];if(we==="Point"||we==="MultiPoint")ci(ve,gt,z,O,j);else if(we==="LineString")Un(ve,gt,z,O,j,!1,le.lineMetrics);else if(we==="MultiLineString")Kr(ve,gt,z,O,j,!1);else if(we==="Polygon")Kr(ve,gt,z,O,j,!0);else if(we==="MultiPolygon")for(var _t=0;_t=z&&ne<=O&&(P.push(G[re]),P.push(G[re+1]),P.push(G[re+2]))}}function Un(G,P,z,O,j,re,ne){for(var le,K,fe=Cn(G),Ce=j===0?Fi:jn,ve=G.start,we=0;wez&&(K=Ce(fe,ot,lt,_t,Lt,z),ne&&(fe.start=ve+le*K)):Xt>O?ui=z&&(K=Ce(fe,ot,lt,_t,Lt,z),Zi=!0),ui>O&&Xt<=O&&(K=Ce(fe,ot,lt,_t,Lt,O),Zi=!0),!re&&Zi&&(ne&&(fe.end=ve+le*K),P.push(fe),fe=Cn(G)),ne&&(ve+=le)}var ut=G.length-3;ot=G[ut],lt=G[ut+1],gt=G[ut+2],(Xt=j===0?ot:lt)>=z&&Xt<=O&&Ur(fe,ot,lt,gt),ut=fe.length-3,re&&ut>=3&&(fe[ut]!==fe[0]||fe[ut+1]!==fe[1])&&Ur(fe,fe[0],fe[1],fe[2]),fe.length&&P.push(fe)}function Cn(G){var P=[];return P.size=G.size,P.start=G.start,P.end=G.end,P}function Kr(G,P,z,O,j,re){for(var ne=0;nene.maxX&&(ne.maxX=Ce),ve>ne.maxY&&(ne.maxY=ve)}return ne}function Xi(G,P,z,O){var j=P.geometry,re=P.type,ne=[];if(re==="Point"||re==="MultiPoint")for(var le=0;le0&&P.size<(j?ne:O))z.numPoints+=P.length/3;else{for(var le=[],K=0;Kne)&&(z.numSimplified++,le.push(P[K]),le.push(P[K+1])),z.numPoints++;j&&function(fe,Ce){for(var ve=0,we=0,ot=fe.length,lt=ot-2;we0===Ce)for(we=0,ot=fe.length;we24)throw new Error("maxZoom should be in the 0-24 range");if(P.promoteId&&P.generateId)throw new Error("promoteId and generateId cannot be used together.");var O=function(j,re){var ne=[];if(j.type==="FeatureCollection")for(var le=0;le1&&console.time("creation"),we=this.tiles[ve]=pn(G,P,z,O,K),this.tileCoords.push({z:P,x:z,y:O}),fe)){fe>1&&(console.log("tile z%d-%d-%d (features: %d, points: %d, simplified: %d)",P,z,O,we.numFeatures,we.numPoints,we.numSimplified),console.timeEnd("creation"));var ot="z"+P;this.stats[ot]=(this.stats[ot]||0)+1,this.total++}if(we.source=G,j){if(P===K.maxZoom||P===j)continue;var lt=1<1&&console.time("clipping");var gt,_t,Lt,Xt,ui,Zi,ut=.5*K.buffer/K.extent,Si=.5-ut,Ji=.5+ut,Tr=1+ut;gt=_t=Lt=Xt=null,ui=ft(G,Ce,z-ut,z+Ji,0,we.minX,we.maxX,K),Zi=ft(G,Ce,z+Si,z+Tr,0,we.minX,we.maxX,K),G=null,ui&&(gt=ft(ui,Ce,O-ut,O+Ji,1,we.minY,we.maxY,K),_t=ft(ui,Ce,O+Si,O+Tr,1,we.minY,we.maxY,K),ui=null),Zi&&(Lt=ft(Zi,Ce,O-ut,O+Ji,1,we.minY,we.maxY,K),Xt=ft(Zi,Ce,O+Si,O+Tr,1,we.minY,we.maxY,K),Zi=null),fe>1&&console.timeEnd("clipping"),le.push(gt||[],P+1,2*z,2*O),le.push(_t||[],P+1,2*z,2*O+1),le.push(Lt||[],P+1,2*z+1,2*O),le.push(Xt||[],P+1,2*z+1,2*O+1)}}},Tt.prototype.getTile=function(G,P,z){var O=this.options,j=O.extent,re=O.debug;if(G<0||G>24)return null;var ne=1<1&&console.log("drilling down to z%d-%d-%d",G,P,z);for(var K,fe=G,Ce=P,ve=z;!K&&fe>0;)fe--,Ce=Math.floor(Ce/2),ve=Math.floor(ve/2),K=this.tiles[yt(fe,Ce,ve)];return K&&K.source?(re>1&&console.log("found parent tile z%d-%d-%d",fe,Ce,ve),re>1&&console.time("drilling down"),this.splitTile(K.source,fe,Ce,ve,G,P,z),re>1&&console.timeEnd("drilling down"),this.tiles[le]?ar(this.tiles[le],j):null):null};class ro extends ce{constructor(){super(...arguments),this._dataUpdateable=new Map}loadVectorTile(P,z){return M._(this,void 0,void 0,function*(){const O=P.tileID.canonical;if(!this._geoJSONIndex)throw new Error("Unable to parse the data into a cluster or geojson");const j=this._geoJSONIndex.getTile(O.z,O.x,O.y);if(!j)return null;const re=new class{constructor(le){this.layers={_geojsonTileLayer:this},this.name="_geojsonTileLayer",this.extent=M.W,this.length=le.length,this._features=le}feature(le){return new class{constructor(K){this._feature=K,this.extent=M.W,this.type=K.type,this.properties=K.tags,"id"in K&&!isNaN(K.id)&&(this.id=parseInt(K.id,10))}loadGeometry(){if(this._feature.type===1){const K=[];for(const fe of this._feature.geometry)K.push([new M.P(fe[0],fe[1])]);return K}{const K=[];for(const fe of this._feature.geometry){const Ce=[];for(const ve of fe)Ce.push(new M.P(ve[0],ve[1]));K.push(Ce)}return K}}toGeoJSON(K,fe,Ce){return it.call(this,K,fe,Ce)}}(this._features[le])}}(j.features);let ne=br(re);return ne.byteOffset===0&&ne.byteLength===ne.buffer.byteLength||(ne=new Uint8Array(ne)),{vectorTile:re,rawData:ne.buffer}})}loadData(P){return M._(this,void 0,void 0,function*(){var z;(z=this._pendingRequest)===null||z===void 0||z.abort();const O=!!(P&&P.request&&P.request.collectResourceTiming)&&new M.bs(P.request);this._pendingRequest=new AbortController;try{let j=yield this.loadGeoJSON(P,this._pendingRequest);if(delete this._pendingRequest,typeof j!="object")throw new Error(`Input data given to '${P.source}' is not a valid GeoJSON object.`);if(De(j,!0),P.filter){const ne=M.by(P.filter,{type:"boolean","property-type":"data-driven",overridable:!1,transition:!1});if(ne.result==="error")throw new Error(ne.value.map(K=>`${K.key}: ${K.message}`).join(", "));j={type:"FeatureCollection",features:j.features.filter(K=>ne.value.evaluate({zoom:0},K))}}this._geoJSONIndex=P.cluster?new Sr(function({superclusterOptions:ne,clusterProperties:le}){if(!le||!ne)return ne;const K={},fe={},Ce={accumulated:null,zoom:0},ve={properties:null},we=Object.keys(le);for(const ot of we){const[lt,gt]=le[ot],_t=M.by(gt),Lt=M.by(typeof lt=="string"?[lt,["accumulated"],["get",ot]]:lt);K[ot]=_t.value,fe[ot]=Lt.value}return ne.map=ot=>{ve.properties=ot;const lt={};for(const gt of we)lt[gt]=K[gt].evaluate(Ce,ve);return lt},ne.reduce=(ot,lt)=>{ve.properties=lt;for(const gt of we)Ce.accumulated=ot[gt],ot[gt]=fe[gt].evaluate(Ce,ve)},ne}(P)).load(j.features):function(ne,le){return new Tt(ne,le)}(j,P.geojsonVtOptions),this.loaded={};const re={};if(O){const ne=O.finish();ne&&(re.resourceTiming={},re.resourceTiming[P.source]=JSON.parse(JSON.stringify(ne)))}return re}catch(j){if(delete this._pendingRequest,M.bz(j))return{abandoned:!0};throw j}})}reloadTile(P){const z=this.loaded;return z&&z[P.uid]?super.reloadTile(P):this.loadTile(P)}loadGeoJSON(P,z){return M._(this,void 0,void 0,function*(){const{promoteId:O}=P;if(P.request){const j=yield M.h(P.request,z);return this._dataUpdateable=Yr(j.data,O)?mt(j.data,O):void 0,j.data}if(typeof P.data=="string")try{const j=JSON.parse(P.data);return this._dataUpdateable=Yr(j,O)?mt(j,O):void 0,j}catch{throw new Error(`Input data given to '${P.source}' is not a valid GeoJSON object.`)}if(!P.dataDiff)throw new Error(`Input data given to '${P.source}' is not a valid GeoJSON object.`);if(!this._dataUpdateable)throw new Error(`Cannot update existing geojson data in ${P.source}`);return function(j,re,ne){var le,K,fe,Ce;if(re.removeAll&&j.clear(),re.remove)for(const ve of re.remove)j.delete(ve);if(re.add)for(const ve of re.add){const we=Gi(ve,ne);we!=null&&j.set(we,ve)}if(re.update)for(const ve of re.update){let we=j.get(ve.id);if(we==null)continue;const ot=!ve.removeAllProperties&&(((le=ve.removeProperties)===null||le===void 0?void 0:le.length)>0||((K=ve.addOrUpdateProperties)===null||K===void 0?void 0:K.length)>0);if((ve.newGeometry||ve.removeAllProperties||ot)&&(we=Object.assign({},we),j.set(ve.id,we),ot&&(we.properties=Object.assign({},we.properties))),ve.newGeometry&&(we.geometry=ve.newGeometry),ve.removeAllProperties)we.properties={};else if(((fe=ve.removeProperties)===null||fe===void 0?void 0:fe.length)>0)for(const lt of ve.removeProperties)Object.prototype.hasOwnProperty.call(we.properties,lt)&&delete we.properties[lt];if(((Ce=ve.addOrUpdateProperties)===null||Ce===void 0?void 0:Ce.length)>0)for(const{key:lt,value:gt}of ve.addOrUpdateProperties)we.properties[lt]=gt}}(this._dataUpdateable,P.dataDiff,O),{type:"FeatureCollection",features:Array.from(this._dataUpdateable.values())}})}removeSource(P){return M._(this,void 0,void 0,function*(){this._pendingRequest&&this._pendingRequest.abort()})}getClusterExpansionZoom(P){return this._geoJSONIndex.getClusterExpansionZoom(P.clusterId)}getClusterChildren(P){return this._geoJSONIndex.getChildren(P.clusterId)}getClusterLeaves(P){return this._geoJSONIndex.getLeaves(P.clusterId,P.limit,P.offset)}}class Pi{constructor(P){this.self=P,this.actor=new M.C(P),this.layerIndexes={},this.availableImages={},this.workerSources={},this.demWorkerSources={},this.externalWorkerSourceTypes={},this.self.registerWorkerSource=(z,O)=>{if(this.externalWorkerSourceTypes[z])throw new Error(`Worker source with name "${z}" already registered.`);this.externalWorkerSourceTypes[z]=O},this.self.addProtocol=M.bf,this.self.removeProtocol=M.bg,this.self.registerRTLTextPlugin=z=>{if(M.bA.isParsed())throw new Error("RTL text plugin already registered.");M.bA.setMethods(z)},this.actor.registerMessageHandler("LDT",(z,O)=>this._getDEMWorkerSource(z,O.source).loadTile(O)),this.actor.registerMessageHandler("RDT",(z,O)=>M._(this,void 0,void 0,function*(){this._getDEMWorkerSource(z,O.source).removeTile(O)})),this.actor.registerMessageHandler("GCEZ",(z,O)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(z,O.type,O.source).getClusterExpansionZoom(O)})),this.actor.registerMessageHandler("GCC",(z,O)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(z,O.type,O.source).getClusterChildren(O)})),this.actor.registerMessageHandler("GCL",(z,O)=>M._(this,void 0,void 0,function*(){return this._getWorkerSource(z,O.type,O.source).getClusterLeaves(O)})),this.actor.registerMessageHandler("LD",(z,O)=>this._getWorkerSource(z,O.type,O.source).loadData(O)),this.actor.registerMessageHandler("LT",(z,O)=>this._getWorkerSource(z,O.type,O.source).loadTile(O)),this.actor.registerMessageHandler("RT",(z,O)=>this._getWorkerSource(z,O.type,O.source).reloadTile(O)),this.actor.registerMessageHandler("AT",(z,O)=>this._getWorkerSource(z,O.type,O.source).abortTile(O)),this.actor.registerMessageHandler("RMT",(z,O)=>this._getWorkerSource(z,O.type,O.source).removeTile(O)),this.actor.registerMessageHandler("RS",(z,O)=>M._(this,void 0,void 0,function*(){if(!this.workerSources[z]||!this.workerSources[z][O.type]||!this.workerSources[z][O.type][O.source])return;const j=this.workerSources[z][O.type][O.source];delete this.workerSources[z][O.type][O.source],j.removeSource!==void 0&&j.removeSource(O)})),this.actor.registerMessageHandler("RM",z=>M._(this,void 0,void 0,function*(){delete this.layerIndexes[z],delete this.availableImages[z],delete this.workerSources[z],delete this.demWorkerSources[z]})),this.actor.registerMessageHandler("SR",(z,O)=>M._(this,void 0,void 0,function*(){this.referrer=O})),this.actor.registerMessageHandler("SRPS",(z,O)=>this._syncRTLPluginState(z,O)),this.actor.registerMessageHandler("IS",(z,O)=>M._(this,void 0,void 0,function*(){this.self.importScripts(O)})),this.actor.registerMessageHandler("SI",(z,O)=>this._setImages(z,O)),this.actor.registerMessageHandler("UL",(z,O)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(z).update(O.layers,O.removedIds)})),this.actor.registerMessageHandler("SL",(z,O)=>M._(this,void 0,void 0,function*(){this._getLayerIndex(z).replace(O)}))}_setImages(P,z){return M._(this,void 0,void 0,function*(){this.availableImages[P]=z;for(const O in this.workerSources[P]){const j=this.workerSources[P][O];for(const re in j)j[re].availableImages=z}})}_syncRTLPluginState(P,z){return M._(this,void 0,void 0,function*(){if(M.bA.isParsed())return M.bA.getState();if(z.pluginStatus!=="loading")return M.bA.setState(z),z;const O=z.pluginURL;if(this.self.importScripts(O),M.bA.isParsed()){const j={pluginStatus:"loaded",pluginURL:O};return M.bA.setState(j),j}throw M.bA.setState({pluginStatus:"error",pluginURL:""}),new Error(`RTL Text Plugin failed to import scripts from ${O}`)})}_getAvailableImages(P){let z=this.availableImages[P];return z||(z=[]),z}_getLayerIndex(P){let z=this.layerIndexes[P];return z||(z=this.layerIndexes[P]=new d),z}_getWorkerSource(P,z,O){if(this.workerSources[P]||(this.workerSources[P]={}),this.workerSources[P][z]||(this.workerSources[P][z]={}),!this.workerSources[P][z][O]){const j={sendAsync:(re,ne)=>(re.targetMapId=P,this.actor.sendAsync(re,ne))};switch(z){case"vector":this.workerSources[P][z][O]=new ce(j,this._getLayerIndex(P),this._getAvailableImages(P));break;case"geojson":this.workerSources[P][z][O]=new ro(j,this._getLayerIndex(P),this._getAvailableImages(P));break;default:this.workerSources[P][z][O]=new this.externalWorkerSourceTypes[z](j,this._getLayerIndex(P),this._getAvailableImages(P))}}return this.workerSources[P][z][O]}_getDEMWorkerSource(P,z){return this.demWorkerSources[P]||(this.demWorkerSources[P]={}),this.demWorkerSources[P][z]||(this.demWorkerSources[P][z]=new oe),this.demWorkerSources[P][z]}}return M.i(self)&&(self.worker=new Pi(self)),Pi}),U("index",["exports","./shared"],function(M,d){var Se="4.1.3";let Re,He;const ce={now:typeof performance<"u"&&performance&&performance.now?performance.now.bind(performance):Date.now.bind(Date),frameAsync:c=>new Promise((t,n)=>{const s=requestAnimationFrame(t);c.signal.addEventListener("abort",()=>{cancelAnimationFrame(s),n(d.c())})}),getImageData(c,t=0){return this.getImageCanvasContext(c).getImageData(-t,-t,c.width+2*t,c.height+2*t)},getImageCanvasContext(c){const t=window.document.createElement("canvas"),n=t.getContext("2d",{willReadFrequently:!0});if(!n)throw new Error("failed to create canvas 2d context");return t.width=c.width,t.height=c.height,n.drawImage(c,0,0,c.width,c.height),n},resolveURL:c=>(Re||(Re=document.createElement("a")),Re.href=c,Re.href),hardwareConcurrency:typeof navigator<"u"&&navigator.hardwareConcurrency||4,get prefersReducedMotion(){return!!matchMedia&&(He==null&&(He=matchMedia("(prefers-reduced-motion: reduce)")),He.matches)}};class oe{static testProp(t){if(!oe.docStyle)return t[0];for(let n=0;n{window.removeEventListener("click",oe.suppressClickInternal,!0)},0)}static getScale(t){const n=t.getBoundingClientRect();return{x:n.width/t.offsetWidth||1,y:n.height/t.offsetHeight||1,boundingClientRect:n}}static getPoint(t,n,s){const a=n.boundingClientRect;return new d.P((s.clientX-a.left)/n.x-t.clientLeft,(s.clientY-a.top)/n.y-t.clientTop)}static mousePos(t,n){const s=oe.getScale(t);return oe.getPoint(t,s,n)}static touchPos(t,n){const s=[],a=oe.getScale(t);for(let u=0;u{t=[],n=0,s=0,a={}},c.addThrottleControl=v=>{const S=s++;return a[S]=v,S},c.removeThrottleControl=v=>{delete a[v],g()},c.getImage=(v,S,C=!0)=>new Promise((A,F)=>{We.supported&&(v.headers||(v.headers={}),v.headers.accept="image/webp,*/*"),d.e(v,{type:"image"}),t.push({abortController:S,requestParameters:v,supportImageRefresh:C,state:"queued",onError:Z=>{F(Z)},onSuccess:Z=>{A(Z)}}),g()});const u=v=>d._(this,void 0,void 0,function*(){v.state="running";const{requestParameters:S,supportImageRefresh:C,onError:A,onSuccess:F,abortController:Z}=v,$=C===!1&&!d.i(self)&&!d.g(S.url)&&(!S.headers||Object.keys(S.headers).reduce((ee,me)=>ee&&me==="accept",!0));n++;const H=$?y(S,Z):d.m(S,Z);try{const ee=yield H;delete v.abortController,v.state="completed",ee.data instanceof HTMLImageElement||d.b(ee.data)?F(ee):ee.data&&F({data:yield(N=ee.data,typeof createImageBitmap=="function"?d.d(N):d.f(N)),cacheControl:ee.cacheControl,expires:ee.expires})}catch(ee){delete v.abortController,A(ee)}finally{n--,g()}var N}),g=()=>{const v=(()=>{for(const S of Object.keys(a))if(a[S]())return!0;return!1})()?d.a.MAX_PARALLEL_IMAGE_REQUESTS_PER_FRAME:d.a.MAX_PARALLEL_IMAGE_REQUESTS;for(let S=n;S0;S++){const C=t.shift();C.abortController.signal.aborted?S--:u(C)}},y=(v,S)=>new Promise((C,A)=>{const F=new Image,Z=v.url,$=v.credentials;$&&$==="include"?F.crossOrigin="use-credentials":($&&$==="same-origin"||!d.s(Z))&&(F.crossOrigin="anonymous"),S.signal.addEventListener("abort",()=>{F.src="",A(d.c())}),F.fetchPriority="high",F.onload=()=>{F.onerror=F.onload=null,C({data:F})},F.onerror=()=>{F.onerror=F.onload=null,S.signal.aborted||A(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."))},F.src=Z})}(Mt||(Mt={})),Mt.resetRequestQueue();class xt{constructor(t){this._transformRequestFn=t}transformRequest(t,n){return this._transformRequestFn&&this._transformRequestFn(t,n)||{url:t}}normalizeSpriteURL(t,n,s){const a=function(u){const g=u.match(Gt);if(!g)throw new Error(`Unable to parse URL "${u}"`);return{protocol:g[1],authority:g[2],path:g[3]||"/",params:g[4]?g[4].split("&"):[]}}(t);return a.path+=`${n}${s}`,function(u){const g=u.params.length?`?${u.params.join("&")}`:"";return`${u.protocol}://${u.authority}${u.path}${g}`}(a)}setTransformRequest(t){this._transformRequestFn=t}}const Gt=/^(\w+):\/\/([^/?]*)(\/[^?]+)?\??(.+)?/;function ti(c){var t=new d.A(3);return t[0]=c[0],t[1]=c[1],t[2]=c[2],t}var li,kt=function(c,t,n){return c[0]=t[0]-n[0],c[1]=t[1]-n[1],c[2]=t[2]-n[2],c};li=new d.A(3),d.A!=Float32Array&&(li[0]=0,li[1]=0,li[2]=0);var Bt=function(c){var t=c[0],n=c[1];return t*t+n*n};function Zt(c){const t=[];if(typeof c=="string")t.push({id:"default",url:c});else if(c&&c.length>0){const n=[];for(const{id:s,url:a}of c){const u=`${s}${a}`;n.indexOf(u)===-1&&(n.push(u),t.push({id:s,url:a}))}}return t}(function(){var c=new d.A(2);d.A!=Float32Array&&(c[0]=0,c[1]=0)})();class St{constructor(t,n,s,a){this.context=t,this.format=s,this.texture=t.gl.createTexture(),this.update(n,a)}update(t,n,s){const{width:a,height:u}=t,g=!(this.size&&this.size[0]===a&&this.size[1]===u||s),{context:y}=this,{gl:v}=y;if(this.useMipmap=!!(n&&n.useMipmap),v.bindTexture(v.TEXTURE_2D,this.texture),y.pixelStoreUnpackFlipY.set(!1),y.pixelStoreUnpack.set(1),y.pixelStoreUnpackPremultiplyAlpha.set(this.format===v.RGBA&&(!n||n.premultiply!==!1)),g)this.size=[a,u],t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||d.b(t)?v.texImage2D(v.TEXTURE_2D,0,this.format,this.format,v.UNSIGNED_BYTE,t):v.texImage2D(v.TEXTURE_2D,0,this.format,a,u,0,this.format,v.UNSIGNED_BYTE,t.data);else{const{x:S,y:C}=s||{x:0,y:0};t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement||t instanceof ImageData||d.b(t)?v.texSubImage2D(v.TEXTURE_2D,0,S,C,v.RGBA,v.UNSIGNED_BYTE,t):v.texSubImage2D(v.TEXTURE_2D,0,S,C,a,u,v.RGBA,v.UNSIGNED_BYTE,t.data)}this.useMipmap&&this.isSizePowerOfTwo()&&v.generateMipmap(v.TEXTURE_2D)}bind(t,n,s){const{context:a}=this,{gl:u}=a;u.bindTexture(u.TEXTURE_2D,this.texture),s!==u.LINEAR_MIPMAP_NEAREST||this.isSizePowerOfTwo()||(s=u.LINEAR),t!==this.filter&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,t),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,s||t),this.filter=t),n!==this.wrap&&(u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,n),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,n),this.wrap=n)}isSizePowerOfTwo(){return this.size[0]===this.size[1]&&Math.log(this.size[0])/Math.LN2%1==0}destroy(){const{gl:t}=this.context;t.deleteTexture(this.texture),this.texture=null}}function xi(c){const{userImage:t}=c;return!!(t&&t.render&&t.render())&&(c.data.replace(new Uint8Array(t.data.buffer)),!0)}class pi extends d.E{constructor(){super(),this.images={},this.updatedImages={},this.callbackDispatchedThisFrame={},this.loaded=!1,this.requestors=[],this.patterns={},this.atlasImage=new d.R({width:1,height:1}),this.dirty=!0}isLoaded(){return this.loaded}setLoaded(t){if(this.loaded!==t&&(this.loaded=t,t)){for(const{ids:n,promiseResolve:s}of this.requestors)s(this._getImagesForIds(n));this.requestors=[]}}getImage(t){const n=this.images[t];if(n&&!n.data&&n.spriteData){const s=n.spriteData;n.data=new d.R({width:s.width,height:s.height},s.context.getImageData(s.x,s.y,s.width,s.height).data),n.spriteData=null}return n}addImage(t,n){if(this.images[t])throw new Error(`Image id ${t} already exist, use updateImage instead`);this._validate(t,n)&&(this.images[t]=n)}_validate(t,n){let s=!0;const a=n.data||n.spriteData;return this._validateStretch(n.stretchX,a&&a.width)||(this.fire(new d.j(new Error(`Image "${t}" has invalid "stretchX" value`))),s=!1),this._validateStretch(n.stretchY,a&&a.height)||(this.fire(new d.j(new Error(`Image "${t}" has invalid "stretchY" value`))),s=!1),this._validateContent(n.content,n)||(this.fire(new d.j(new Error(`Image "${t}" has invalid "content" value`))),s=!1),s}_validateStretch(t,n){if(!t)return!0;let s=0;for(const a of t){if(a[0]{let a=!0;if(!this.isLoaded())for(const u of t)this.images[u]||(a=!1);this.isLoaded()||a?n(this._getImagesForIds(t)):this.requestors.push({ids:t,promiseResolve:n})})}_getImagesForIds(t){const n={};for(const s of t){let a=this.getImage(s);a||(this.fire(new d.k("styleimagemissing",{id:s})),a=this.getImage(s)),a?n[s]={data:a.data.clone(),pixelRatio:a.pixelRatio,sdf:a.sdf,version:a.version,stretchX:a.stretchX,stretchY:a.stretchY,content:a.content,hasRenderCallback:!!(a.userImage&&a.userImage.render)}:d.w(`Image "${s}" could not be loaded. Please make sure you have added the image with map.addImage() or a "sprite" property in your style. You can provide missing images by listening for the "styleimagemissing" map event.`)}return n}getPixelSize(){const{width:t,height:n}=this.atlasImage;return{width:t,height:n}}getPattern(t){const n=this.patterns[t],s=this.getImage(t);if(!s)return null;if(n&&n.position.version===s.version)return n.position;if(n)n.position.version=s.version;else{const a={w:s.data.width+2,h:s.data.height+2,x:0,y:0},u=new d.I(a,s);this.patterns[t]={bin:a,position:u}}return this._updatePatternAtlas(),this.patterns[t].position}bind(t){const n=t.gl;this.atlasTexture?this.dirty&&(this.atlasTexture.update(this.atlasImage),this.dirty=!1):this.atlasTexture=new St(t,this.atlasImage,n.RGBA),this.atlasTexture.bind(n.LINEAR,n.CLAMP_TO_EDGE)}_updatePatternAtlas(){const t=[];for(const u in this.patterns)t.push(this.patterns[u].bin);const{w:n,h:s}=d.p(t),a=this.atlasImage;a.resize({width:n||1,height:s||1});for(const u in this.patterns){const{bin:g}=this.patterns[u],y=g.x+1,v=g.y+1,S=this.getImage(u).data,C=S.width,A=S.height;d.R.copy(S,a,{x:0,y:0},{x:y,y:v},{width:C,height:A}),d.R.copy(S,a,{x:0,y:A-1},{x:y,y:v-1},{width:C,height:1}),d.R.copy(S,a,{x:0,y:0},{x:y,y:v+A},{width:C,height:1}),d.R.copy(S,a,{x:C-1,y:0},{x:y-1,y:v},{width:1,height:A}),d.R.copy(S,a,{x:0,y:0},{x:y+C,y:v},{width:1,height:A})}this.dirty=!0}beginFrame(){this.callbackDispatchedThisFrame={}}dispatchRenderCallbacks(t){for(const n of t){if(this.callbackDispatchedThisFrame[n])continue;this.callbackDispatchedThisFrame[n]=!0;const s=this.getImage(n);s||d.w(`Image with ID: "${n}" was not found`),xi(s)&&this.updateImage(n,s)}}}const fi=1e20;function Nn(c,t,n,s,a,u,g,y,v){for(let S=t;S-1);v++,u[v]=y,g[v]=S,g[v+1]=fi}for(let y=0,v=0;y65535)throw new Error("glyphs > 65535 not supported");if(s.ranges[u])return{stack:t,id:n,glyph:a};if(!this.url)throw new Error("glyphsUrl is not set");if(!s.requests[u]){const y=br.loadGlyphRange(t,u,this.url,this.requestManager);s.requests[u]=y}const g=yield s.requests[u];for(const y in g)this._doesCharSupportLocalGlyph(+y)||(s.glyphs[+y]=g[+y]);return s.ranges[u]=!0,{stack:t,id:n,glyph:g[n]||null}})}_doesCharSupportLocalGlyph(t){return!!this.localIdeographFontFamily&&(d.u["CJK Unified Ideographs"](t)||d.u["Hangul Syllables"](t)||d.u.Hiragana(t)||d.u.Katakana(t))}_tinySDF(t,n,s){const a=this.localIdeographFontFamily;if(!a||!this._doesCharSupportLocalGlyph(s))return;let u=t.tinySDF;if(!u){let y="400";/bold/i.test(n)?y="900":/medium/i.test(n)?y="500":/light/i.test(n)&&(y="200"),u=t.tinySDF=new br.TinySDF({fontSize:48,buffer:6,radius:16,cutoff:.25,fontFamily:a,fontWeight:y})}const g=u.draw(String.fromCharCode(s));return{id:s,bitmap:new d.o({width:g.width||60,height:g.height||60},g.data),metrics:{width:g.glyphWidth/2||24,height:g.glyphHeight/2||24,left:g.glyphLeft/2+.5||0,top:g.glyphTop/2-27.5||-8,advance:g.glyphAdvance/2||24,isDoubleResolution:!0}}}}br.loadGlyphRange=function(c,t,n,s){return d._(this,void 0,void 0,function*(){const a=256*t,u=a+255,g=s.transformRequest(n.replace("{fontstack}",c).replace("{range}",`${a}-${u}`),"Glyphs"),y=yield d.l(g,new AbortController);if(!y||!y.data)throw new Error(`Could not load glyph range. range: ${t}, ${a}-${u}`);const v={};for(const S of d.n(y.data))v[S.id]=S;return v})},br.TinySDF=class{constructor({fontSize:c=24,buffer:t=3,radius:n=8,cutoff:s=.25,fontFamily:a="sans-serif",fontWeight:u="normal",fontStyle:g="normal"}={}){this.buffer=t,this.cutoff=s,this.radius=n;const y=this.size=c+4*t,v=this._createCanvas(y),S=this.ctx=v.getContext("2d",{willReadFrequently:!0});S.font=`${g} ${u} ${c}px ${a}`,S.textBaseline="alphabetic",S.textAlign="left",S.fillStyle="black",this.gridOuter=new Float64Array(y*y),this.gridInner=new Float64Array(y*y),this.f=new Float64Array(y),this.z=new Float64Array(y+1),this.v=new Uint16Array(y)}_createCanvas(c){const t=document.createElement("canvas");return t.width=t.height=c,t}draw(c){const{width:t,actualBoundingBoxAscent:n,actualBoundingBoxDescent:s,actualBoundingBoxLeft:a,actualBoundingBoxRight:u}=this.ctx.measureText(c),g=Math.ceil(n),y=Math.max(0,Math.min(this.size-this.buffer,Math.ceil(u-a))),v=Math.min(this.size-this.buffer,g+Math.ceil(s)),S=y+2*this.buffer,C=v+2*this.buffer,A=Math.max(S*C,0),F=new Uint8ClampedArray(A),Z={data:F,width:S,height:C,glyphWidth:y,glyphHeight:v,glyphTop:g,glyphLeft:0,glyphAdvance:t};if(y===0||v===0)return Z;const{ctx:$,buffer:H,gridInner:N,gridOuter:ee}=this;$.clearRect(H,H,y,v),$.fillText(c,H,H+g);const me=$.getImageData(H,H,y,v);ee.fill(fi,0,A),N.fill(0,0,A);for(let X=0;X0?xe*xe:0,N[ye]=xe<0?xe*xe:0}}Nn(ee,0,0,S,C,S,this.f,this.v,this.z),Nn(N,H,H,y,v,S,this.f,this.v,this.z);for(let X=0;X1&&(v=t[++y]);const C=Math.abs(S-v.left),A=Math.abs(S-v.right),F=Math.min(C,A);let Z;const $=u/s*(a+1);if(v.isDash){const H=a-Math.abs($);Z=Math.sqrt(F*F+H*H)}else Z=a-Math.sqrt(F*F+$*$);this.data[g+S]=Math.max(0,Math.min(255,Z+128))}}}addRegularDash(t){for(let y=t.length-1;y>=0;--y){const v=t[y],S=t[y+1];v.zeroLength?t.splice(y,1):S&&S.isDash===v.isDash&&(S.left=v.left,t.splice(y,1))}const n=t[0],s=t[t.length-1];n.isDash===s.isDash&&(n.left=s.left-this.width,s.right=n.right+this.width);const a=this.width*this.nextRow;let u=0,g=t[u];for(let y=0;y1&&(g=t[++u]);const v=Math.abs(y-g.left),S=Math.abs(y-g.right),C=Math.min(v,S);this.data[a+y]=Math.max(0,Math.min(255,(g.isDash?C:-C)+128))}}addDash(t,n){const s=n?7:0,a=2*s+1;if(this.nextRow+a>this.height)return d.w("LineAtlas out of space"),null;let u=0;for(let y=0;y{n.terminate()}),this.workers=null)}isPreloaded(){return!!this.active[Ai]}numActive(){return Object.keys(this.active).length}}const Sr=Math.floor(ce.hardwareConcurrency/2);let bi,wi;function or(){return bi||(bi=new ii),bi}ii.workerCount=d.B(globalThis)?Math.max(Math.min(Sr,3),1):1;class sr{constructor(t,n){this.workerPool=t,this.actors=[],this.currentActor=0,this.id=n;const s=this.workerPool.acquire(n);for(let a=0;a{n.remove()}),this.actors=[],t&&this.workerPool.release(this.id)}registerMessageHandler(t,n){for(const s of this.actors)s.registerMessageHandler(t,n)}}function Ii(){return wi||(wi=new sr(or(),d.G),wi.registerMessageHandler("GR",(c,t,n)=>d.m(t,n))),wi}function bt(c,t){const n=d.F();return d.H(n,n,[1,1,0]),d.J(n,n,[.5*c.width,.5*c.height,1]),d.K(n,n,c.calculatePosMatrix(t.toUnwrapped()))}function Vn(c,t,n,s,a,u){const g=function(A,F,Z){if(A)for(const $ of A){const H=F[$];if(H&&H.source===Z&&H.type==="fill-extrusion")return!0}else for(const $ in F){const H=F[$];if(H.source===Z&&H.type==="fill-extrusion")return!0}return!1}(a&&a.layers,t,c.id),y=u.maxPitchScaleFactor(),v=c.tilesIn(s,y,g);v.sort(Vr);const S=[];for(const A of v)S.push({wrappedTileID:A.tileID.wrapped().key,queryResults:A.tile.queryRenderedFeatures(t,n,c._state,A.queryGeometry,A.cameraQueryGeometry,A.scale,a,u,y,bt(c.transform,A.tileID))});const C=function(A){const F={},Z={};for(const $ of A){const H=$.queryResults,N=$.wrappedTileID,ee=Z[N]=Z[N]||{};for(const me in H){const X=H[me],ae=ee[me]=ee[me]||{},ge=F[me]=F[me]||[];for(const ye of X)ae[ye.featureIndex]||(ae[ye.featureIndex]=!0,ge.push(ye))}}return F}(S);for(const A in C)C[A].forEach(F=>{const Z=F.feature,$=c.getFeatureState(Z.layer["source-layer"],Z.id);Z.source=Z.layer.source,Z.layer["source-layer"]&&(Z.sourceLayer=Z.layer["source-layer"]),Z.state=$});return C}function Vr(c,t){const n=c.tileID,s=t.tileID;return n.overscaledZ-s.overscaledZ||n.canonical.y-s.canonical.y||n.wrap-s.wrap||n.canonical.x-s.canonical.x}function Xr(c,t,n){return d._(this,void 0,void 0,function*(){let s=c;if(c.url?s=(yield d.h(t.transformRequest(c.url,"Source"),n)).data:yield ce.frameAsync(n),!s)return null;const a=d.L(d.e(s,c),["tiles","minzoom","maxzoom","attribution","bounds","scheme","tileSize","encoding"]);return"vector_layers"in s&&s.vector_layers&&(a.vectorLayerIds=s.vector_layers.map(u=>u.id)),a})}class Yt{constructor(t,n){t&&(n?this.setSouthWest(t).setNorthEast(n):Array.isArray(t)&&(t.length===4?this.setSouthWest([t[0],t[1]]).setNorthEast([t[2],t[3]]):this.setSouthWest(t[0]).setNorthEast(t[1])))}setNorthEast(t){return this._ne=t instanceof d.M?new d.M(t.lng,t.lat):d.M.convert(t),this}setSouthWest(t){return this._sw=t instanceof d.M?new d.M(t.lng,t.lat):d.M.convert(t),this}extend(t){const n=this._sw,s=this._ne;let a,u;if(t instanceof d.M)a=t,u=t;else{if(!(t instanceof Yt))return Array.isArray(t)?t.length===4||t.every(Array.isArray)?this.extend(Yt.convert(t)):this.extend(d.M.convert(t)):t&&("lng"in t||"lon"in t)&&"lat"in t?this.extend(d.M.convert(t)):this;if(a=t._sw,u=t._ne,!a||!u)return this}return n||s?(n.lng=Math.min(a.lng,n.lng),n.lat=Math.min(a.lat,n.lat),s.lng=Math.max(u.lng,s.lng),s.lat=Math.max(u.lat,s.lat)):(this._sw=new d.M(a.lng,a.lat),this._ne=new d.M(u.lng,u.lat)),this}getCenter(){return new d.M((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 d.M(this.getWest(),this.getNorth())}getSouthEast(){return new d.M(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(t){const{lng:n,lat:s}=d.M.convert(t);let a=this._sw.lng<=n&&n<=this._ne.lng;return this._sw.lng>this._ne.lng&&(a=this._sw.lng>=n&&n>=this._ne.lng),this._sw.lat<=s&&s<=this._ne.lat&&a}static convert(t){return t instanceof Yt?t:t&&new Yt(t)}static fromLngLat(t,n=0){const s=360*n/40075017,a=s/Math.cos(Math.PI/180*t.lat);return new Yt(new d.M(t.lng-a,t.lat-s),new d.M(t.lng+a,t.lat+s))}}class Jr{constructor(t,n,s){this.bounds=Yt.convert(this.validateBounds(t)),this.minzoom=n||0,this.maxzoom=s||24}validateBounds(t){return Array.isArray(t)&&t.length===4?[Math.max(-180,t[0]),Math.max(-90,t[1]),Math.min(180,t[2]),Math.min(90,t[3])]:[-180,-90,180,90]}contains(t){const n=Math.pow(2,t.z),s=Math.floor(d.N(this.bounds.getWest())*n),a=Math.floor(d.O(this.bounds.getNorth())*n),u=Math.ceil(d.N(this.bounds.getEast())*n),g=Math.ceil(d.O(this.bounds.getSouth())*n);return t.x>=s&&t.x=a&&t.y{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}serialize(){return d.e({},this._options)}loadTile(t){return d._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),s={request:this.map._requestManager.transformRequest(n,"Tile"),uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,tileSize:this.tileSize*t.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};s.request.collectResourceTiming=this._collectResourceTiming;let a="RT";if(t.actor&&t.state!=="expired"){if(t.state==="loading")return new Promise((u,g)=>{t.reloadPromise={resolve:u,reject:g}})}else t.actor=this.dispatcher.getActor(),a="LT";t.abortController=new AbortController;try{const u=yield t.actor.sendAsync({type:a,data:s},t.abortController);if(delete t.abortController,t.aborted)return;this._afterTileLoadWorkerResponse(t,u)}catch(u){if(delete t.abortController,t.aborted)return;if(u&&u.status!==404)throw u;this._afterTileLoadWorkerResponse(t,null)}})}_afterTileLoadWorkerResponse(t,n){if(n&&n.resourceTiming&&(t.resourceTiming=n.resourceTiming),n&&this.map._refreshExpiredTiles&&t.setExpiryData(n),t.loadVectorData(n,this.map.painter),t.reloadPromise){const s=t.reloadPromise;t.reloadPromise=null,this.loadTile(t).then(s.resolve).catch(s.reject)}}abortTile(t){return d._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.actor&&(yield t.actor.sendAsync({type:"AT",data:{uid:t.uid,type:this.type,source:this.id}}))})}unloadTile(t){return d._(this,void 0,void 0,function*(){t.unloadVectorData(),t.actor&&(yield t.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}}))})}hasTransition(){return!1}}class be extends d.E{constructor(t,n,s,a){super(),this.id=t,this.dispatcher=s,this.setEventedParent(a),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=d.e({type:"raster"},n),d.e(this,d.L(n,["url","scheme","tileSize"]))}load(){return d._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new d.k("dataloading",{dataType:"source"})),this._tileJSONRequest=new AbortController;try{const t=yield Xr(this._options,this.map._requestManager,this._tileJSONRequest);this._tileJSONRequest=null,this._loaded=!0,t&&(d.e(this,t),t.bounds&&(this.tileBounds=new Jr(t.bounds,this.minzoom,this.maxzoom)),this.fire(new d.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new d.k("data",{dataType:"source",sourceDataType:"content"})))}catch(t){this._tileJSONRequest=null,this.fire(new d.j(t))}})}loaded(){return this._loaded}onAdd(t){this.map=t,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null)}setSourceProperty(t){this._tileJSONRequest&&(this._tileJSONRequest.abort(),this._tileJSONRequest=null),t(),this.load()}setTiles(t){return this.setSourceProperty(()=>{this._options.tiles=t}),this}setUrl(t){return this.setSourceProperty(()=>{this.url=t,this._options.url=t}),this}serialize(){return d.e({},this._options)}hasTile(t){return!this.tileBounds||this.tileBounds.contains(t.canonical)}loadTile(t){return d._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);t.abortController=new AbortController;try{const s=yield Mt.getImage(this.map._requestManager.transformRequest(n,"Tile"),t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(s&&s.data){this.map._refreshExpiredTiles&&s.cacheControl&&s.expires&&t.setExpiryData({cacheControl:s.cacheControl,expires:s.expires});const a=this.map.painter.context,u=a.gl,g=s.data;t.texture=this.map.painter.getTileTexture(g.width),t.texture?t.texture.update(g,{useMipmap:!0}):(t.texture=new St(a,g,u.RGBA,{useMipmap:!0}),t.texture.bind(u.LINEAR,u.CLAMP_TO_EDGE,u.LINEAR_MIPMAP_NEAREST),a.extTextureFilterAnisotropic&&u.texParameterf(u.TEXTURE_2D,a.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,a.extTextureFilterAnisotropicMax)),t.state="loaded"}}catch(s){if(delete t.abortController,t.aborted)t.state="unloaded";else if(s)throw t.state="errored",s}})}abortTile(t){return d._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController)})}unloadTile(t){return d._(this,void 0,void 0,function*(){t.texture&&this.map.painter.saveTileTexture(t.texture)})}hasTransition(){return!1}}class Tn extends be{constructor(t,n,s,a){super(t,n,s,a),this.type="raster-dem",this.maxzoom=22,this._options=d.e({type:"raster-dem"},n),this.encoding=n.encoding||"mapbox",this.redFactor=n.redFactor,this.greenFactor=n.greenFactor,this.blueFactor=n.blueFactor,this.baseShift=n.baseShift}loadTile(t){return d._(this,void 0,void 0,function*(){const n=t.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),s=this.map._requestManager.transformRequest(n,"Tile");t.neighboringTiles=this._getNeighboringTiles(t.tileID),t.abortController=new AbortController;try{const a=yield Mt.getImage(s,t.abortController,this.map._refreshExpiredTiles);if(delete t.abortController,t.aborted)return void(t.state="unloaded");if(a&&a.data){const u=a.data;this.map._refreshExpiredTiles&&a.cacheControl&&a.expires&&t.setExpiryData({cacheControl:a.cacheControl,expires:a.expires});const g=d.b(u)&&d.S()?u:yield this.readImageNow(u),y={type:this.type,uid:t.uid,source:this.id,rawImageData:g,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};if(!t.actor||t.state==="expired"){t.actor=this.dispatcher.getActor();const v=yield t.actor.sendAsync({type:"LDT",data:y});t.dem=v,t.needsHillshadePrepare=!0,t.needsTerrainPrepare=!0,t.state="loaded"}}}catch(a){if(delete t.abortController,t.aborted)t.state="unloaded";else if(a)throw t.state="errored",a}})}readImageNow(t){return d._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&d.U()){const n=t.width+2,s=t.height+2;try{return new d.R({width:n,height:s},yield d.V(t,-1,-1,n,s))}catch{}}return ce.getImageData(t,1)})}_getNeighboringTiles(t){const n=t.canonical,s=Math.pow(2,n.z),a=(n.x-1+s)%s,u=n.x===0?t.wrap-1:t.wrap,g=(n.x+1+s)%s,y=n.x+1===s?t.wrap+1:t.wrap,v={};return v[new d.Q(t.overscaledZ,u,n.z,a,n.y).key]={backfilled:!1},v[new d.Q(t.overscaledZ,y,n.z,g,n.y).key]={backfilled:!1},n.y>0&&(v[new d.Q(t.overscaledZ,u,n.z,a,n.y-1).key]={backfilled:!1},v[new d.Q(t.overscaledZ,t.wrap,n.z,n.x,n.y-1).key]={backfilled:!1},v[new d.Q(t.overscaledZ,y,n.z,g,n.y-1).key]={backfilled:!1}),n.y+10&&d.e(u,{resourceTiming:a}),this.fire(new d.k("data",Object.assign(Object.assign({},u),{sourceDataType:"metadata"}))),this.fire(new d.k("data",Object.assign(Object.assign({},u),{sourceDataType:"content"})))}catch(s){if(this._pendingLoads--,this._removed)return void this.fire(new d.k("dataabort",{dataType:"source"}));this.fire(new d.j(s))}})}loaded(){return this._pendingLoads===0}loadTile(t){return d._(this,void 0,void 0,function*(){const n=t.actor?"RT":"LT";t.actor=this.actor;const s={type:this.type,uid:t.uid,tileID:t.tileID,zoom:t.tileID.overscaledZ,maxZoom:this.maxzoom,tileSize:this.tileSize,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};t.abortController=new AbortController;const a=yield this.actor.sendAsync({type:n,data:s},t.abortController);delete t.abortController,t.unloadVectorData(),t.aborted||t.loadVectorData(a,this.map.painter,n==="RT")})}abortTile(t){return d._(this,void 0,void 0,function*(){t.abortController&&(t.abortController.abort(),delete t.abortController),t.aborted=!0})}unloadTile(t){return d._(this,void 0,void 0,function*(){t.unloadVectorData(),yield this.actor.sendAsync({type:"RMT",data:{uid:t.uid,type:this.type,source:this.id}})})}onRemove(){this._removed=!0,this.actor.sendAsync({type:"RS",data:{type:this.type,source:this.id}})}serialize(){return d.e({},this._options,{type:this.type,data:this._data})}hasTransition(){return!1}}var ft=d.X([{name:"a_pos",type:"Int16",components:2},{name:"a_texture_pos",type:"Int16",components:2}]);class ci extends d.E{constructor(t,n,s,a){super(),this.id=t,this.dispatcher=s,this.coordinates=n.coordinates,this.type="image",this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.tiles={},this._loaded=!1,this.setEventedParent(a),this.options=n}load(t){return d._(this,void 0,void 0,function*(){this._loaded=!1,this.fire(new d.k("dataloading",{dataType:"source"})),this.url=this.options.url,this._request=new AbortController;try{const n=yield Mt.getImage(this.map._requestManager.transformRequest(this.url,"Image"),this._request);this._request=null,this._loaded=!0,n&&n.data&&(this.image=n.data,t&&(this.coordinates=t),this._finishLoading())}catch(n){this._request=null,this._loaded=!0,this.fire(new d.j(n))}})}loaded(){return this._loaded}updateImage(t){return t.url?(this._request&&(this._request.abort(),this._request=null),this.options.url=t.url,this.load(t.coordinates).finally(()=>{this.texture=null}),this):this}_finishLoading(){this.map&&(this.setCoordinates(this.coordinates),this.fire(new d.k("data",{dataType:"source",sourceDataType:"metadata"})))}onAdd(t){this.map=t,this.load()}onRemove(){this._request&&(this._request.abort(),this._request=null)}setCoordinates(t){this.coordinates=t;const n=t.map(d.Y.fromLngLat);this.tileID=function(a){let u=1/0,g=1/0,y=-1/0,v=-1/0;for(const F of a)u=Math.min(u,F.x),g=Math.min(g,F.y),y=Math.max(y,F.x),v=Math.max(v,F.y);const S=Math.max(y-u,v-g),C=Math.max(0,Math.floor(-Math.log(S)/Math.LN2)),A=Math.pow(2,C);return new d.a0(C,Math.floor((u+y)/2*A),Math.floor((g+v)/2*A))}(n),this.minzoom=this.maxzoom=this.tileID.z;const s=n.map(a=>this.tileID.getTilePoint(a)._round());return this._boundsArray=new d.Z,this._boundsArray.emplaceBack(s[0].x,s[0].y,0,0),this._boundsArray.emplaceBack(s[1].x,s[1].y,d.W,0),this._boundsArray.emplaceBack(s[3].x,s[3].y,0,d.W),this._boundsArray.emplaceBack(s[2].x,s[2].y,d.W,d.W),this.boundsBuffer&&(this.boundsBuffer.destroy(),delete this.boundsBuffer),this.fire(new d.k("data",{dataType:"source",sourceDataType:"content"})),this}prepare(){if(Object.keys(this.tiles).length===0||!this.image)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,ft.members)),this.boundsSegments||(this.boundsSegments=d.$.simpleSegment(0,0,4,2)),this.texture||(this.texture=new St(t,this.image,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let s=!1;for(const a in this.tiles){const u=this.tiles[a];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,s=!0)}s&&this.fire(new d.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}loadTile(t){return d._(this,void 0,void 0,function*(){this.tileID&&this.tileID.equals(t.tileID.canonical)?(this.tiles[String(t.tileID.wrap)]=t,t.buckets={}):t.state="errored"})}serialize(){return{type:"image",url:this.options.url,coordinates:this.coordinates}}hasTransition(){return!1}}class Un extends ci{constructor(t,n,s,a){super(t,n,s,a),this.roundZoom=!0,this.type="video",this.options=n}load(){return d._(this,void 0,void 0,function*(){this._loaded=!1;const t=this.options;this.urls=[];for(const n of t.urls)this.urls.push(this.map._requestManager.transformRequest(n,"Source").url);try{const n=yield d.a2(this.urls);if(this._loaded=!0,!n)return;this.video=n,this.video.loop=!0,this.video.addEventListener("playing",()=>{this.map.triggerRepaint()}),this.map&&this.video.play(),this._finishLoading()}catch(n){this.fire(new d.j(n))}})}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 d.j(new d.a1(`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(t){this.map||(this.map=t,this.load(),this.video&&(this.video.play(),this.setCoordinates(this.coordinates)))}prepare(){if(Object.keys(this.tiles).length===0||this.video.readyState<2)return;const t=this.map.painter.context,n=t.gl;this.boundsBuffer||(this.boundsBuffer=t.createVertexBuffer(this._boundsArray,ft.members)),this.boundsSegments||(this.boundsSegments=d.$.simpleSegment(0,0,4,2)),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 St(t,this.video,n.RGBA),this.texture.bind(n.LINEAR,n.CLAMP_TO_EDGE));let s=!1;for(const a in this.tiles){const u=this.tiles[a];u.state!=="loaded"&&(u.state="loaded",u.texture=this.texture,s=!0)}s&&this.fire(new d.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"video",urls:this.urls,coordinates:this.coordinates}}hasTransition(){return this.video&&!this.video.paused}}class Cn extends ci{constructor(t,n,s,a){super(t,n,s,a),n.coordinates?Array.isArray(n.coordinates)&&n.coordinates.length===4&&!n.coordinates.some(u=>!Array.isArray(u)||u.length!==2||u.some(g=>typeof g!="number"))||this.fire(new d.j(new d.a1(`sources.${t}`,null,'"coordinates" property must be an array of 4 longitude/latitude array pairs'))):this.fire(new d.j(new d.a1(`sources.${t}`,null,'missing required property "coordinates"'))),n.animate&&typeof n.animate!="boolean"&&this.fire(new d.j(new d.a1(`sources.${t}`,null,'optional "animate" property must be a boolean value'))),n.canvas?typeof n.canvas=="string"||n.canvas instanceof HTMLCanvasElement||this.fire(new d.j(new d.a1(`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 d.j(new d.a1(`sources.${t}`,null,'missing required property "canvas"'))),this.options=n,this.animate=n.animate===void 0||n.animate}load(){return d._(this,void 0,void 0,function*(){this._loaded=!0,this.canvas||(this.canvas=this.options.canvas instanceof HTMLCanvasElement?this.options.canvas:document.getElementById(this.options.canvas)),this.width=this.canvas.width,this.height=this.canvas.height,this._hasInvalidDimensions()?this.fire(new d.j(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(t){this.map=t,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()||Object.keys(this.tiles).length===0)return;const n=this.map.painter.context,s=n.gl;this.boundsBuffer||(this.boundsBuffer=n.createVertexBuffer(this._boundsArray,ft.members)),this.boundsSegments||(this.boundsSegments=d.$.simpleSegment(0,0,4,2)),this.texture?(t||this._playing)&&this.texture.update(this.canvas,{premultiply:!0}):this.texture=new St(n,this.canvas,s.RGBA,{premultiply:!0});let a=!1;for(const u in this.tiles){const g=this.tiles[u];g.state!=="loaded"&&(g.state="loaded",g.texture=this.texture,a=!0)}a&&this.fire(new d.k("data",{dataType:"source",sourceDataType:"idle",sourceId:this.id}))}serialize(){return{type:"canvas",coordinates:this.coordinates}}hasTransition(){return this._playing}_hasInvalidDimensions(){for(const t of[this.canvas.width,this.canvas.height])if(isNaN(t)||t<=0)return!0;return!1}}const Kr={},Ur=c=>{switch(c){case"geojson":return En;case"image":return ci;case"raster":return be;case"raster-dem":return Tn;case"vector":return Ot;case"video":return Un;case"canvas":return Cn}return Kr[c]},Fi="RTLPluginLoaded";class jn extends d.E{constructor(){super(...arguments),this.status="unavailable",this.url=null,this.dispatcher=Ii()}_syncState(t){return this.status=t,this.dispatcher.broadcast("SRPS",{pluginStatus:t,pluginURL:this.url}).catch(n=>{throw this.status="error",n})}getRTLTextPluginStatus(){return this.status}clearRTLTextPlugin(){this.status="unavailable",this.url=null}setRTLTextPlugin(t){return d._(this,arguments,void 0,function*(n,s=!1){if(this.url)throw new Error("setRTLTextPlugin cannot be called multiple times.");if(this.url=ce.resolveURL(n),!this.url)throw new Error(`requested url ${n} is invalid`);if(this.status==="unavailable"){if(!s)return this._requestImport();this.status="deferred",this._syncState(this.status)}else if(this.status==="requested")return this._requestImport()})}_requestImport(){return d._(this,void 0,void 0,function*(){yield this._syncState("loading"),this.status="loaded",this.fire(new d.k(Fi))})}lazyLoad(){this.status==="unavailable"?this.status="requested":this.status==="deferred"&&this._requestImport()}}let jr=null;function ze(){return jr||(jr=new jn),jr}class ar{constructor(t,n){this.timeAdded=0,this.fadeEndTime=0,this.tileID=t,this.uid=d.a3(),this.uses=0,this.tileSize=n,this.buckets={},this.expirationTime=null,this.queryPadding=0,this.hasSymbolBuckets=!1,this.hasRTLText=!1,this.dependencies={},this.rtt=[],this.rttCoords={},this.expiredRequestCount=0,this.state="loading"}registerFadeDuration(t){const n=t+this.timeAdded;nu.getLayer(S)).filter(Boolean);if(v.length!==0){y.layers=v,y.stateDependentLayerIds&&(y.stateDependentLayers=y.stateDependentLayerIds.map(S=>v.filter(C=>C.id===S)[0]));for(const S of v)g[S.id]=y}}return g}(t.buckets,n.style),this.hasSymbolBuckets=!1;for(const a in this.buckets){const u=this.buckets[a];if(u instanceof d.a5){if(this.hasSymbolBuckets=!0,!s)break;u.justReloaded=!0}}if(this.hasRTLText=!1,this.hasSymbolBuckets)for(const a in this.buckets){const u=this.buckets[a];if(u instanceof d.a5&&u.hasRTLText){this.hasRTLText=!0,ze().lazyLoad();break}}this.queryPadding=0;for(const a in this.buckets){const u=this.buckets[a];this.queryPadding=Math.max(this.queryPadding,n.style.getLayer(a).queryRadius(u))}t.imageAtlas&&(this.imageAtlas=t.imageAtlas),t.glyphAtlasImage&&(this.glyphAtlasImage=t.glyphAtlasImage)}else this.collisionBoxArray=new d.a4}unloadVectorData(){for(const t in this.buckets)this.buckets[t].destroy();this.buckets={},this.imageAtlasTexture&&this.imageAtlasTexture.destroy(),this.imageAtlas&&(this.imageAtlas=null),this.glyphAtlasTexture&&this.glyphAtlasTexture.destroy(),this.latestFeatureIndex=null,this.state="unloaded"}getBucket(t){return this.buckets[t.id]}upload(t){for(const s in this.buckets){const a=this.buckets[s];a.uploadPending()&&a.upload(t)}const n=t.gl;this.imageAtlas&&!this.imageAtlas.uploaded&&(this.imageAtlasTexture=new St(t,this.imageAtlas.image,n.RGBA),this.imageAtlas.uploaded=!0),this.glyphAtlasImage&&(this.glyphAtlasTexture=new St(t,this.glyphAtlasImage,n.ALPHA),this.glyphAtlasImage=null)}prepare(t){this.imageAtlas&&this.imageAtlas.patchUpdatedImages(t,this.imageAtlasTexture)}queryRenderedFeatures(t,n,s,a,u,g,y,v,S,C){return this.latestFeatureIndex&&this.latestFeatureIndex.rawTileData?this.latestFeatureIndex.query({queryGeometry:a,cameraQueryGeometry:u,scale:g,tileSize:this.tileSize,pixelPosMatrix:C,transform:v,params:y,queryPadding:this.queryPadding*S},t,n,s):{}}querySourceFeatures(t,n){const s=this.latestFeatureIndex;if(!s||!s.rawTileData)return;const a=s.loadVTLayers(),u=n&&n.sourceLayer?n.sourceLayer:"",g=a._geojsonTileLayer||a[u];if(!g)return;const y=d.a6(n&&n.filter),{z:v,x:S,y:C}=this.tileID.canonical,A={z:v,x:S,y:C};for(let F=0;Fs)a=!1;else if(n)if(this.expirationTime{this.remove(t,u)},s)),this.data[a].push(u),this.order.push(a),this.order.length>this.max){const g=this._getAndRemoveByKey(this.order[0]);g&&this.onRemove(g)}return this}has(t){return t.wrapped().key in this.data}getAndRemove(t){return this.has(t)?this._getAndRemoveByKey(t.wrapped().key):null}_getAndRemoveByKey(t){const n=this.data[t].shift();return n.timeout&&clearTimeout(n.timeout),this.data[t].length===0&&delete this.data[t],this.order.splice(this.order.indexOf(t),1),n.value}getByKey(t){const n=this.data[t];return n?n[0].value:null}get(t){return this.has(t)?this.data[t.wrapped().key][0].value:null}remove(t,n){if(!this.has(t))return this;const s=t.wrapped().key,a=n===void 0?0:this.data[s].indexOf(n),u=this.data[s][a];return this.data[s].splice(a,1),u.timeout&&clearTimeout(u.timeout),this.data[s].length===0&&delete this.data[s],this.onRemove(u.value),this.order.splice(this.order.indexOf(s),1),this}setMaxSize(t){for(this.max=t;this.order.length>this.max;){const n=this._getAndRemoveByKey(this.order[0]);n&&this.onRemove(n)}return this}filter(t){const n=[];for(const s in this.data)for(const a of this.data[s])t(a.value)||n.push(a);for(const s of n)this.remove(s.value.tileID,s)}}class pn{constructor(){this.state={},this.stateChanges={},this.deletedStates={}}updateState(t,n,s){const a=String(n);if(this.stateChanges[t]=this.stateChanges[t]||{},this.stateChanges[t][a]=this.stateChanges[t][a]||{},d.e(this.stateChanges[t][a],s),this.deletedStates[t]===null){this.deletedStates[t]={};for(const u in this.state[t])u!==a&&(this.deletedStates[t][u]=null)}else if(this.deletedStates[t]&&this.deletedStates[t][a]===null){this.deletedStates[t][a]={};for(const u in this.state[t][a])s[u]||(this.deletedStates[t][a][u]=null)}else for(const u in s)this.deletedStates[t]&&this.deletedStates[t][a]&&this.deletedStates[t][a][u]===null&&delete this.deletedStates[t][a][u]}removeFeatureState(t,n,s){if(this.deletedStates[t]===null)return;const a=String(n);if(this.deletedStates[t]=this.deletedStates[t]||{},s&&n!==void 0)this.deletedStates[t][a]!==null&&(this.deletedStates[t][a]=this.deletedStates[t][a]||{},this.deletedStates[t][a][s]=null);else if(n!==void 0)if(this.stateChanges[t]&&this.stateChanges[t][a])for(s in this.deletedStates[t][a]={},this.stateChanges[t][a])this.deletedStates[t][a][s]=null;else this.deletedStates[t][a]=null;else this.deletedStates[t]=null}getState(t,n){const s=String(n),a=d.e({},(this.state[t]||{})[s],(this.stateChanges[t]||{})[s]);if(this.deletedStates[t]===null)return{};if(this.deletedStates[t]){const u=this.deletedStates[t][n];if(u===null)return{};for(const g in u)delete a[g]}return a}initializeTileState(t,n){t.setFeatureState(this.state,n)}coalesceChanges(t,n){const s={};for(const a in this.stateChanges){this.state[a]=this.state[a]||{};const u={};for(const g in this.stateChanges[a])this.state[a][g]||(this.state[a][g]={}),d.e(this.state[a][g],this.stateChanges[a][g]),u[g]=this.state[a][g];s[a]=u}for(const a in this.deletedStates){this.state[a]=this.state[a]||{};const u={};if(this.deletedStates[a]===null)for(const g in this.state[a])u[g]={},this.state[a][g]={};else for(const g in this.deletedStates[a]){if(this.deletedStates[a][g]===null)this.state[a][g]={};else for(const y of Object.keys(this.deletedStates[a][g]))delete this.state[a][g][y];u[g]=this.state[a][g]}s[a]=s[a]||{},d.e(s[a],u)}if(this.stateChanges={},this.deletedStates={},Object.keys(s).length!==0)for(const a in t)t[a].setFeatureState(s,n)}}class Xi extends d.E{constructor(t,n,s){super(),this.id=t,this.dispatcher=s,this.on("data",a=>this._dataHandler(a)),this.on("dataloading",()=>{this._sourceErrored=!1}),this.on("error",()=>{this._sourceErrored=this._source.loaded()}),this._source=((a,u,g,y)=>{const v=new(Ur(u.type))(a,u,g,y);if(v.id!==a)throw new Error(`Expected Source id to be ${a} instead of ${v.id}`);return v})(t,n,s,this),this._tiles={},this._cache=new Wi(0,a=>this._unloadTile(a)),this._timers={},this._cacheTimers={},this._maxTileCacheSize=null,this._maxTileCacheZoomLevels=null,this._loadedParentTiles={},this._coveredTiles={},this._state=new pn,this._didEmitContent=!1,this._updated=!1}onAdd(t){this.map=t,this._maxTileCacheSize=t?t._maxTileCacheSize:null,this._maxTileCacheZoomLevels=t?t._maxTileCacheZoomLevels:null,this._source&&this._source.onAdd&&this._source.onAdd(t)}onRemove(t){this.clearTiles(),this._source&&this._source.onRemove&&this._source.onRemove(t)}loaded(){if(this._sourceErrored)return!0;if(!this._sourceLoaded||!this._source.loaded())return!1;if(!(this.used===void 0&&this.usedForTerrain===void 0||this.used||this.usedForTerrain))return!0;if(!this._updated)return!1;for(const t in this._tiles){const n=this._tiles[t];if(n.state!=="loaded"&&n.state!=="errored")return!1}return!0}getSource(){return this._source}pause(){this._paused=!0}resume(){if(!this._paused)return;const t=this._shouldReloadOnResume;this._paused=!1,this._shouldReloadOnResume=!1,t&&this.reload(),this.transform&&this.update(this.transform,this.terrain)}_loadTile(t,n,s){return d._(this,void 0,void 0,function*(){try{yield this._source.loadTile(t),this._tileLoaded(t,n,s)}catch(a){t.state="errored",a.status!==404?this._source.fire(new d.j(a,{tile:t})):this.update(this.transform,this.terrain)}})}_unloadTile(t){this._source.unloadTile&&this._source.unloadTile(t)}_abortTile(t){this._source.abortTile&&this._source.abortTile(t),this._source.fire(new d.k("dataabort",{tile:t,coord:t.tileID,dataType:"source"}))}serialize(){return this._source.serialize()}prepare(t){this._source.prepare&&this._source.prepare(),this._state.coalesceChanges(this._tiles,this.map?this.map.painter:null);for(const n in this._tiles){const s=this._tiles[n];s.upload(t),s.prepare(this.map.style.imageManager)}}getIds(){return Object.values(this._tiles).map(t=>t.tileID).sort(Ue).map(t=>t.key)}getRenderableIds(t){const n=[];for(const s in this._tiles)this._isIdRenderable(s,t)&&n.push(this._tiles[s]);return t?n.sort((s,a)=>{const u=s.tileID,g=a.tileID,y=new d.P(u.canonical.x,u.canonical.y)._rotate(this.transform.angle),v=new d.P(g.canonical.x,g.canonical.y)._rotate(this.transform.angle);return u.overscaledZ-g.overscaledZ||v.y-y.y||v.x-y.x}).map(s=>s.tileID.key):n.map(s=>s.tileID).sort(Ue).map(s=>s.key)}hasRenderableParent(t){const n=this.findLoadedParent(t,0);return!!n&&this._isIdRenderable(n.tileID.key)}_isIdRenderable(t,n){return this._tiles[t]&&this._tiles[t].hasData()&&!this._coveredTiles[t]&&(n||!this._tiles[t].holdingForFade())}reload(){if(this._paused)this._shouldReloadOnResume=!0;else{this._cache.reset();for(const t in this._tiles)this._tiles[t].state!=="errored"&&this._reloadTile(t,"reloading")}}_reloadTile(t,n){return d._(this,void 0,void 0,function*(){const s=this._tiles[t];s&&(s.state!=="loading"&&(s.state=n),yield this._loadTile(s,t,n))})}_tileLoaded(t,n,s){t.timeAdded=ce.now(),s==="expired"&&(t.refreshedUponExpiration=!0),this._setTileReloadTimer(n,t),this.getSource().type==="raster-dem"&&t.dem&&this._backfillDEM(t),this._state.initializeTileState(t,this.map?this.map.painter:null),t.aborted||this._source.fire(new d.k("data",{dataType:"source",tile:t,coord:t.tileID}))}_backfillDEM(t){const n=this.getRenderableIds();for(let a=0;a1||(Math.abs(g)>1&&(Math.abs(g+v)===1?g+=v:Math.abs(g-v)===1&&(g-=v)),u.dem&&a.dem&&(a.dem.backfillBorder(u.dem,g,y),a.neighboringTiles&&a.neighboringTiles[S]&&(a.neighboringTiles[S].backfilled=!0)))}}getTile(t){return this.getTileByID(t.key)}getTileByID(t){return this._tiles[t]}_retainLoadedChildren(t,n,s,a){for(const u in this._tiles){let g=this._tiles[u];if(a[u]||!g.hasData()||g.tileID.overscaledZ<=n||g.tileID.overscaledZ>s)continue;let y=g.tileID;for(;g&&g.tileID.overscaledZ>n+1;){const S=g.tileID.scaledTo(g.tileID.overscaledZ-1);g=this._tiles[S.key],g&&g.hasData()&&(y=S)}let v=y;for(;v.overscaledZ>n;)if(v=v.scaledTo(v.overscaledZ-1),t[v.key]){a[y.key]=y;break}}}findLoadedParent(t,n){if(t.key in this._loadedParentTiles){const s=this._loadedParentTiles[t.key];return s&&s.tileID.overscaledZ>=n?s:null}for(let s=t.overscaledZ-1;s>=n;s--){const a=t.scaledTo(s),u=this._getLoadedTile(a);if(u)return u}}_getLoadedTile(t){const n=this._tiles[t.key];return n&&n.hasData()?n:this._cache.getByKey(t.wrapped().key)}updateCacheSize(t){const n=Math.ceil(t.width/this._source.tileSize)+1,s=Math.ceil(t.height/this._source.tileSize)+1,a=Math.floor(n*s*(this._maxTileCacheZoomLevels===null?d.a.MAX_TILE_CACHE_ZOOM_LEVELS:this._maxTileCacheZoomLevels)),u=typeof this._maxTileCacheSize=="number"?Math.min(this._maxTileCacheSize,a):a;this._cache.setMaxSize(u)}handleWrapJump(t){const n=Math.round((t-(this._prevLng===void 0?t:this._prevLng))/360);if(this._prevLng=t,n){const s={};for(const a in this._tiles){const u=this._tiles[a];u.tileID=u.tileID.unwrapTo(u.tileID.wrap+n),s[u.tileID.key]=u}this._tiles=s;for(const a in this._timers)clearTimeout(this._timers[a]),delete this._timers[a];for(const a in this._tiles)this._setTileReloadTimer(a,this._tiles[a])}}update(t,n){if(!this._sourceLoaded||this._paused)return;let s;this.transform=t,this.terrain=n,this.updateCacheSize(t),this.handleWrapJump(this.transform.center.lng),this._coveredTiles={},this.used||this.usedForTerrain?this._source.tileID?s=t.getVisibleUnwrappedCoordinates(this._source.tileID).map(C=>new d.Q(C.canonical.z,C.wrap,C.canonical.z,C.canonical.x,C.canonical.y)):(s=t.coveringTiles({tileSize:this.usedForTerrain?this.tileSize:this._source.tileSize,minzoom:this._source.minzoom,maxzoom:this._source.maxzoom,roundZoom:!this.usedForTerrain&&this._source.roundZoom,reparseOverscaled:this._source.reparseOverscaled,terrain:n}),this._source.hasTile&&(s=s.filter(C=>this._source.hasTile(C)))):s=[];const a=t.coveringZoomLevel(this._source),u=Math.max(a-Xi.maxOverzooming,this._source.minzoom),g=Math.max(a+Xi.maxUnderzooming,this._source.minzoom);if(this.usedForTerrain){const C={};for(const A of s)if(A.canonical.z>this._source.minzoom){const F=A.scaledTo(A.canonical.z-1);C[F.key]=F;const Z=A.scaledTo(Math.max(this._source.minzoom,Math.min(A.canonical.z,5)));C[Z.key]=Z}s=s.concat(Object.values(C))}const y=s.length===0&&!this._updated&&this._didEmitContent;this._updated=!0,y&&this.fire(new d.k("data",{sourceDataType:"idle",dataType:"source",sourceId:this.id}));const v=this._updateRetainedTiles(s,a);if(Tt(this._source.type)){const C={},A={},F=Object.keys(v),Z=ce.now();for(const $ of F){const H=v[$],N=this._tiles[$];if(!N||N.fadeEndTime!==0&&N.fadeEndTime<=Z)continue;const ee=this.findLoadedParent(H,u);ee&&(this._addTile(ee.tileID),C[ee.tileID.key]=ee.tileID),A[$]=H}this._retainLoadedChildren(A,a,g,v);for(const $ in C)v[$]||(this._coveredTiles[$]=!0,v[$]=C[$]);if(n){const $={},H={};for(const N of s)this._tiles[N.key].hasData()?$[N.key]=N:H[N.key]=N;for(const N in H){const ee=H[N].children(this._source.maxzoom);this._tiles[ee[0].key]&&this._tiles[ee[1].key]&&this._tiles[ee[2].key]&&this._tiles[ee[3].key]&&($[ee[0].key]=v[ee[0].key]=ee[0],$[ee[1].key]=v[ee[1].key]=ee[1],$[ee[2].key]=v[ee[2].key]=ee[2],$[ee[3].key]=v[ee[3].key]=ee[3],delete H[N])}for(const N in H){const ee=this.findLoadedParent(H[N],this._source.minzoom);if(ee){$[ee.tileID.key]=v[ee.tileID.key]=ee.tileID;for(const me in $)$[me].isChildOf(ee.tileID)&&delete $[me]}}for(const N in this._tiles)$[N]||(this._coveredTiles[N]=!0)}}for(const C in v)this._tiles[C].clearFadeHold();const S=d.ab(this._tiles,v);for(const C of S){const A=this._tiles[C];A.hasSymbolBuckets&&!A.holdingForFade()?A.setHoldDuration(this.map._fadeDuration):A.hasSymbolBuckets&&!A.symbolFadeFinished()||this._removeTile(C)}this._updateLoadedParentTileCache()}releaseSymbolFadeTiles(){for(const t in this._tiles)this._tiles[t].holdingForFade()&&this._removeTile(t)}_updateRetainedTiles(t,n){const s={},a={},u=Math.max(n-Xi.maxOverzooming,this._source.minzoom),g=Math.max(n+Xi.maxUnderzooming,this._source.minzoom),y={};for(const v of t){const S=this._addTile(v);s[v.key]=v,S.hasData()||nthis._source.maxzoom){const A=v.children(this._source.maxzoom)[0],F=this.getTile(A);if(F&&F.hasData()){s[A.key]=A;continue}}else{const A=v.children(this._source.maxzoom);if(s[A[0].key]&&s[A[1].key]&&s[A[2].key]&&s[A[3].key])continue}let C=S.wasRequested();for(let A=v.overscaledZ-1;A>=u;--A){const F=v.scaledTo(A);if(a[F.key])break;if(a[F.key]=!0,S=this.getTile(F),!S&&C&&(S=this._addTile(F)),S){const Z=S.hasData();if((C||Z)&&(s[F.key]=F),C=S.wasRequested(),Z)break}}}return s}_updateLoadedParentTileCache(){this._loadedParentTiles={};for(const t in this._tiles){const n=[];let s,a=this._tiles[t].tileID;for(;a.overscaledZ>0;){if(a.key in this._loadedParentTiles){s=this._loadedParentTiles[a.key];break}n.push(a.key);const u=a.scaledTo(a.overscaledZ-1);if(s=this._getLoadedTile(u),s)break;a=u}for(const u of n)this._loadedParentTiles[u]=s}}_addTile(t){let n=this._tiles[t.key];if(n)return n;n=this._cache.getAndRemove(t),n&&(this._setTileReloadTimer(t.key,n),n.tileID=t,this._state.initializeTileState(n,this.map?this.map.painter:null),this._cacheTimers[t.key]&&(clearTimeout(this._cacheTimers[t.key]),delete this._cacheTimers[t.key],this._setTileReloadTimer(t.key,n)));const s=n;return n||(n=new ar(t,this._source.tileSize*t.overscaleFactor()),this._loadTile(n,t.key,n.state)),n.uses++,this._tiles[t.key]=n,s||this._source.fire(new d.k("dataloading",{tile:n,coord:n.tileID,dataType:"source"})),n}_setTileReloadTimer(t,n){t in this._timers&&(clearTimeout(this._timers[t]),delete this._timers[t]);const s=n.getExpiryTimeout();s&&(this._timers[t]=setTimeout(()=>{this._reloadTile(t,"expired"),delete this._timers[t]},s))}_removeTile(t){const n=this._tiles[t];n&&(n.uses--,delete this._tiles[t],this._timers[t]&&(clearTimeout(this._timers[t]),delete this._timers[t]),n.uses>0||(n.hasData()&&n.state!=="reloading"?this._cache.add(n.tileID,n,n.getExpiryTimeout()):(n.aborted=!0,this._abortTile(n),this._unloadTile(n))))}_dataHandler(t){const n=t.sourceDataType;t.dataType==="source"&&n==="metadata"&&(this._sourceLoaded=!0),this._sourceLoaded&&!this._paused&&t.dataType==="source"&&n==="content"&&(this.reload(),this.transform&&this.update(this.transform,this.terrain),this._didEmitContent=!0)}clearTiles(){this._shouldReloadOnResume=!1,this._paused=!1;for(const t in this._tiles)this._removeTile(t);this._cache.reset()}tilesIn(t,n,s){const a=[],u=this.transform;if(!u)return a;const g=s?u.getCameraQueryGeometry(t):t,y=t.map($=>u.pointCoordinate($,this.terrain)),v=g.map($=>u.pointCoordinate($,this.terrain)),S=this.getIds();let C=1/0,A=1/0,F=-1/0,Z=-1/0;for(const $ of v)C=Math.min(C,$.x),A=Math.min(A,$.y),F=Math.max(F,$.x),Z=Math.max(Z,$.y);for(let $=0;$=0&&X[1].y+me>=0){const ae=y.map(ye=>N.getTilePoint(ye)),ge=v.map(ye=>N.getTilePoint(ye));a.push({tile:H,tileID:N,queryGeometry:ae,cameraQueryGeometry:ge,scale:ee})}}return a}getVisibleCoordinates(t){const n=this.getRenderableIds(t).map(s=>this._tiles[s].tileID);for(const s of n)s.posMatrix=this.transform.calculatePosMatrix(s.toUnwrapped());return n}hasTransition(){if(this._source.hasTransition())return!0;if(Tt(this._source.type)){const t=ce.now();for(const n in this._tiles)if(this._tiles[n].fadeEndTime>=t)return!0}return!1}setFeatureState(t,n,s){this._state.updateState(t=t||"_geojsonTileLayer",n,s)}removeFeatureState(t,n,s){this._state.removeFeatureState(t=t||"_geojsonTileLayer",n,s)}getFeatureState(t,n){return this._state.getState(t=t||"_geojsonTileLayer",n)}setDependencies(t,n,s){const a=this._tiles[t];a&&a.setDependencies(n,s)}reloadTilesForDependencies(t,n){for(const s in this._tiles)this._tiles[s].hasDependency(t,n)&&this._reloadTile(s,"reloading");this._cache.filter(s=>!s.hasDependency(t,n))}}function Ue(c,t){const n=Math.abs(2*c.wrap)-+(c.wrap<0),s=Math.abs(2*t.wrap)-+(t.wrap<0);return c.overscaledZ-t.overscaledZ||s-n||t.canonical.y-c.canonical.y||t.canonical.x-c.canonical.x}function Tt(c){return c==="raster"||c==="image"||c==="video"}Xi.maxOverzooming=10,Xi.maxUnderzooming=3;class yt{constructor(t,n){this.reset(t,n)}reset(t,n){this.points=t||[],this._distances=[0];for(let s=1;s0?(a-g)/y:0;return this.points[u].mult(1-v).add(this.points[n].mult(v))}}function Gi(c,t){let n=!0;return c==="always"||c!=="never"&&t!=="never"||(n=!1),n}class Yr{constructor(t,n,s){const a=this.boxCells=[],u=this.circleCells=[];this.xCellCount=Math.ceil(t/s),this.yCellCount=Math.ceil(n/s);for(let g=0;gthis.width||a<0||n>this.height)return[];const v=[];if(t<=0&&n<=0&&this.width<=s&&this.height<=a){if(u)return[{key:null,x1:t,y1:n,x2:s,y2:a}];for(let S=0;S0}hitTestCircle(t,n,s,a,u){const g=t-s,y=t+s,v=n-s,S=n+s;if(y<0||g>this.width||S<0||v>this.height)return!1;const C=[];return this._forEachCell(g,v,y,S,this._queryCellCircle,C,{hitTest:!0,overlapMode:a,circle:{x:t,y:n,radius:s},seenUids:{box:{},circle:{}}},u),C.length>0}_queryCell(t,n,s,a,u,g,y,v){const{seenUids:S,hitTest:C,overlapMode:A}=y,F=this.boxCells[u];if(F!==null){const $=this.bboxes;for(const H of F)if(!S.box[H]){S.box[H]=!0;const N=4*H,ee=this.boxKeys[H];if(t<=$[N+2]&&n<=$[N+3]&&s>=$[N+0]&&a>=$[N+1]&&(!v||v(ee))&&(!C||!Gi(A,ee.overlapMode))&&(g.push({key:ee,x1:$[N],y1:$[N+1],x2:$[N+2],y2:$[N+3]}),C))return!0}}const Z=this.circleCells[u];if(Z!==null){const $=this.circles;for(const H of Z)if(!S.circle[H]){S.circle[H]=!0;const N=3*H,ee=this.circleKeys[H];if(this._circleAndRectCollide($[N],$[N+1],$[N+2],t,n,s,a)&&(!v||v(ee))&&(!C||!Gi(A,ee.overlapMode))){const me=$[N],X=$[N+1],ae=$[N+2];if(g.push({key:ee,x1:me-ae,y1:X-ae,x2:me+ae,y2:X+ae}),C)return!0}}}return!1}_queryCellCircle(t,n,s,a,u,g,y,v){const{circle:S,seenUids:C,overlapMode:A}=y,F=this.boxCells[u];if(F!==null){const $=this.bboxes;for(const H of F)if(!C.box[H]){C.box[H]=!0;const N=4*H,ee=this.boxKeys[H];if(this._circleAndRectCollide(S.x,S.y,S.radius,$[N+0],$[N+1],$[N+2],$[N+3])&&(!v||v(ee))&&!Gi(A,ee.overlapMode))return g.push(!0),!0}}const Z=this.circleCells[u];if(Z!==null){const $=this.circles;for(const H of Z)if(!C.circle[H]){C.circle[H]=!0;const N=3*H,ee=this.circleKeys[H];if(this._circlesCollide($[N],$[N+1],$[N+2],S.x,S.y,S.radius)&&(!v||v(ee))&&!Gi(A,ee.overlapMode))return g.push(!0),!0}}}_forEachCell(t,n,s,a,u,g,y,v){const S=this._convertToXCellCoord(t),C=this._convertToYCellCoord(n),A=this._convertToXCellCoord(s),F=this._convertToYCellCoord(a);for(let Z=S;Z<=A;Z++)for(let $=C;$<=F;$++)if(u.call(this,t,n,s,a,this.xCellCount*$+Z,g,y,v))return}_convertToXCellCoord(t){return Math.max(0,Math.min(this.xCellCount-1,Math.floor(t*this.xScale)))}_convertToYCellCoord(t){return Math.max(0,Math.min(this.yCellCount-1,Math.floor(t*this.yScale)))}_circlesCollide(t,n,s,a,u,g){const y=a-t,v=u-n,S=s+g;return S*S>y*y+v*v}_circleAndRectCollide(t,n,s,a,u,g,y){const v=(g-a)/2,S=Math.abs(t-(a+v));if(S>v+s)return!1;const C=(y-u)/2,A=Math.abs(n-(u+C));if(A>C+s)return!1;if(S<=v||A<=C)return!0;const F=S-v,Z=A-C;return F*F+Z*Z<=s*s}}function mt(c,t,n,s,a){const u=d.F();return t?(d.J(u,u,[1/a,1/a,1]),n||d.ad(u,u,s.angle)):d.K(u,s.labelPlaneMatrix,c),u}function ro(c,t,n,s,a){if(t){const u=d.ae(c);return d.J(u,u,[a,a,1]),n||d.ad(u,u,-s.angle),u}return s.glCoordMatrix}function Pi(c,t,n){let s;n?(s=[c.x,c.y,n(c.x,c.y),1],d.af(s,s,t)):(s=[c.x,c.y,0,1],ot(s,s,t));const a=s[3];return{point:new d.P(s[0]/a,s[1]/a),signedDistanceFromCamera:a}}function G(c,t){return .5+c/t*.5}function P(c,t){const n=c[0]/c[3],s=c[1]/c[3];return n>=-t[0]&&n<=t[0]&&s>=-t[1]&&s<=t[1]}function z(c,t,n,s,a,u,g,y,v,S){const C=s?c.textSizeData:c.iconSizeData,A=d.ag(C,n.transform.zoom),F=[256/n.width*2+1,256/n.height*2+1],Z=s?c.text.dynamicLayoutVertexArray:c.icon.dynamicLayoutVertexArray;Z.clear();const $=c.lineVertexArray,H=s?c.text.placedSymbolArray:c.icon.placedSymbolArray,N=n.transform.width/n.transform.height;let ee=!1;for(let me=0;meMath.abs(n.x-t.x)*s?{useVertical:!0}:(c===d.ah.vertical?t.yn.x)?{needsFlipping:!0}:null}function re(c,t,n,s,a,u,g,y,v,S,C,A,F,Z,$,H){const N=t/24,ee=c.lineOffsetX*N,me=c.lineOffsetY*N;let X;if(c.numGlyphs>1){const ae=c.glyphStartIndex+c.numGlyphs,ge=c.lineStartIndex,ye=c.lineStartIndex+c.lineLength,xe=O(N,y,ee,me,n,C,A,c,v,u,F,$,H);if(!xe)return{notEnoughRoom:!0};const Pe=Pi(xe.first.point,g,H).point,Ae=Pi(xe.last.point,g,H).point;if(s&&!n){const Fe=j(c.writingMode,Pe,Ae,Z);if(Fe)return Fe}X=[xe.first];for(let Fe=c.glyphStartIndex+1;Fe0?Pe.point:ne(A,xe,ge,1,a,H),Fe=j(c.writingMode,ge,Ae,Z);if(Fe)return Fe}const ae=Ce(N*y.getoffsetX(c.glyphStartIndex),ee,me,n,C,A,c.segment,c.lineStartIndex,c.lineStartIndex+c.lineLength,v,u,F,$,H);if(!ae)return{notEnoughRoom:!0};X=[ae]}for(const ae of X)d.aj(S,ae.point,ae.angle);return{}}function ne(c,t,n,s,a,u){const g=Pi(c.add(c.sub(t)._unit()),a,u).point,y=n.sub(g);return n.add(y._mult(s/y.mag()))}function le(c,t){const{projectionCache:n,lineVertexArray:s,labelPlaneMatrix:a,tileAnchorPoint:u,distanceFromAnchor:g,getElevation:y,previousVertex:v,direction:S,absOffsetX:C}=t;if(n.projections[c])return n.projections[c];const A=new d.P(s.getx(c),s.gety(c)),F=Pi(A,a,y);if(F.signedDistanceFromCamera>0)return n.projections[c]=F.point,F.point;const Z=c-S;return ne(g===0?u:new d.P(s.getx(Z),s.gety(Z)),A,v,C-g+1,a,y)}function K(c,t,n){return c._unit()._perp()._mult(t*n)}function fe(c,t,n,s,a,u,g,y){const{projectionCache:v,direction:S}=y;if(v.offsets[c])return v.offsets[c];const C=n.add(t);if(c+S=a)return v.offsets[c]=C,C;const A=le(c+S,y),F=K(A.sub(n),g,S),Z=n.add(F),$=A.add(F);return v.offsets[c]=d.ak(u,C,Z,$)||C,v.offsets[c]}function Ce(c,t,n,s,a,u,g,y,v,S,C,A,F,Z){const $=s?c-t:c+t;let H=$>0?1:-1,N=0;s&&(H*=-1,N=Math.PI),H<0&&(N+=Math.PI);let ee,me,X=H>0?y+g:y+g+1,ae=a,ge=a,ye=0,xe=0;const Pe=Math.abs($),Ae=[];let Fe;for(;ye+xe<=Pe;){if(X+=H,X=v)return null;ye+=xe,ge=ae,me=ee;const $e={projectionCache:A,lineVertexArray:S,labelPlaneMatrix:C,tileAnchorPoint:u,distanceFromAnchor:ye,getElevation:Z,previousVertex:ge,direction:H,absOffsetX:Pe};if(ae=le(X,$e),n===0)Ae.push(ge),Fe=ae.sub(ge);else{let pt;const Ct=ae.sub(ge);pt=Ct.mag()===0?K(le(X+H,$e).sub(ae),n,H):K(Ct,n,H),me||(me=ge.add(pt)),ee=fe(X,pt,ae,y,v,me,n,$e),Ae.push(me),Fe=ee.sub(me)}xe=Fe.mag()}const Ne=Fe._mult((Pe-ye)/xe)._add(me||ge),Et=N+Math.atan2(ae.y-ge.y,ae.x-ge.x);return Ae.push(Ne),{point:Ne,angle:F?Et:0,path:Ae}}const ve=new Float32Array([-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0,-1/0,-1/0,0]);function we(c,t){for(let n=0;n=1;Pt--)Ct.push($e.path[Pt]);for(let Pt=1;PtPi(Dt,v,$));Ct=Pt.some(Dt=>Dt.signedDistanceFromCamera<=0)?[]:Pt.map(Dt=>Dt.point)}let vt=[];if(Ct.length>0){const Pt=Ct[0].clone(),Dt=Ct[0].clone();for(let ji=1;ji=Fe.x&&Dt.x<=Ne.x&&Pt.y>=Fe.y&&Dt.y<=Ne.y?[Ct]:Dt.xNe.x||Dt.yNe.y?[]:d.al([Ct],Fe.x,Fe.y,Ne.x,Ne.y)}for(const Pt of vt){Et.reset(Pt,.25*Ae);let Dt=0;Dt=Et.length<=.5*Ae?1:Math.ceil(Et.paddedLength/jt)+1;for(let ji=0;ji=this.screenRightBoundary||athis.screenBottomBoundary}isInsideGrid(t,n,s,a){return s>=0&&t=0&&ns.collisionGroupID===n}}return this.collisionGroups[t]}}function Ji(c,t,n,s,a){const{horizontalAlign:u,verticalAlign:g}=d.at(c);return new d.P(-(u-.5)*t+s[0]*a,-(g-.5)*n+s[1]*a)}function Tr(c,t,n,s,a,u){const{x1:g,x2:y,y1:v,y2:S,anchorPointX:C,anchorPointY:A}=c,F=new d.P(t,n);return s&&F._rotate(a?u:-u),{x1:g+F.x,y1:v+F.y,x2:y+F.x,y2:S+F.y,anchorPointX:C,anchorPointY:A}}class Er{constructor(t,n,s,a,u){this.transform=t.clone(),this.terrain=n,this.collisionIndex=new gt(this.transform),this.placements={},this.opacities={},this.variableOffsets={},this.stale=!1,this.commitTime=0,this.fadeDuration=s,this.retainedQueryData={},this.collisionGroups=new Si(a),this.collisionCircleArrays={},this.prevPlacement=u,u&&(u.prevPlacement=void 0),this.placedOrientations={}}getBucketParts(t,n,s,a){const u=s.getBucket(n),g=s.latestFeatureIndex;if(!u||!g||n.id!==u.layerIds[0])return;const y=s.collisionBoxArray,v=u.layers[0].layout,S=Math.pow(2,this.transform.zoom-s.tileID.overscaledZ),C=s.tileSize/d.W,A=this.transform.calculatePosMatrix(s.tileID.toUnwrapped()),F=v.get("text-pitch-alignment")==="map",Z=v.get("text-rotation-alignment")==="map",$=_t(s,1,this.transform.zoom),H=mt(A,F,Z,this.transform,$);let N=null;if(F){const me=ro(A,F,Z,this.transform,$);N=d.K([],this.transform.labelPlaneMatrix,me)}this.retainedQueryData[u.bucketInstanceId]=new ut(u.bucketInstanceId,g,u.sourceLayerIndex,u.index,s.tileID);const ee={bucket:u,layout:v,posMatrix:A,textLabelPlaneMatrix:H,labelToScreenMatrix:N,scale:S,textPixelRatio:C,holdingForFade:s.holdingForFade(),collisionBoxArray:y,partiallyEvaluatedTextSize:d.ag(u.textSizeData,this.transform.zoom),collisionGroup:this.collisionGroups.get(u.sourceID)};if(a)for(const me of u.sortKeyRanges){const{sortKey:X,symbolInstanceStart:ae,symbolInstanceEnd:ge}=me;t.push({sortKey:X,symbolInstanceStart:ae,symbolInstanceEnd:ge,parameters:ee})}else t.push({symbolInstanceStart:0,symbolInstanceEnd:u.symbolInstances.length,parameters:ee})}attemptAnchorPlacement(t,n,s,a,u,g,y,v,S,C,A,F,Z,$,H,N){const ee=d.ap[t.textAnchor],me=[t.textOffset0,t.textOffset1],X=Ji(ee,s,a,me,u),ae=this.collisionIndex.placeCollisionBox(Tr(n,X.x,X.y,g,y,this.transform.angle),A,v,S,C.predicate,N);if((!H||this.collisionIndex.placeCollisionBox(Tr(H,X.x,X.y,g,y,this.transform.angle),A,v,S,C.predicate,N).box.length!==0)&&ae.box.length>0){let ge;if(this.prevPlacement&&this.prevPlacement.variableOffsets[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID]&&this.prevPlacement.placements[F.crossTileID].text&&(ge=this.prevPlacement.variableOffsets[F.crossTileID].anchor),F.crossTileID===0)throw new Error("symbolInstance.crossTileID can't be 0");return this.variableOffsets[F.crossTileID]={textOffset:me,width:s,height:a,anchor:ee,textBoxScale:u,prevAnchor:ge},this.markUsedJustification(Z,ee,F,$),Z.allowVerticalPlacement&&(this.markUsedOrientation(Z,$,F),this.placedOrientations[F.crossTileID]=$),{shift:X,placedGlyphBoxes:ae}}}placeLayerBucketPart(t,n,s){const{bucket:a,layout:u,posMatrix:g,textLabelPlaneMatrix:y,labelToScreenMatrix:v,textPixelRatio:S,holdingForFade:C,collisionBoxArray:A,partiallyEvaluatedTextSize:F,collisionGroup:Z}=t.parameters,$=u.get("text-optional"),H=u.get("icon-optional"),N=d.aq(u,"text-overlap","text-allow-overlap"),ee=N==="always",me=d.aq(u,"icon-overlap","icon-allow-overlap"),X=me==="always",ae=u.get("text-rotation-alignment")==="map",ge=u.get("text-pitch-alignment")==="map",ye=u.get("icon-text-fit")!=="none",xe=u.get("symbol-z-order")==="viewport-y",Pe=ee&&(X||!a.hasIconData()||H),Ae=X&&(ee||!a.hasTextData()||$);!a.collisionArrays&&A&&a.deserializeCollisionBoxes(A);const Fe=this.retainedQueryData[a.bucketInstanceId].tileID,Ne=this.terrain?($e,pt)=>this.terrain.getElevation(Fe,$e,pt):null,Et=($e,pt)=>{var Ct,jt;if(n[$e.crossTileID])return;if(C)return void(this.placements[$e.crossTileID]=new ui(!1,!1,!1));let vt=!1,Pt=!1,Dt=!0,ji=null,ni={box:null,offscreen:null},_n={box:null,offscreen:null},dr=null,zi=null,pr=null,vn=0,uo=0,Vo=0;pt.textFeatureIndex?vn=pt.textFeatureIndex:$e.useRuntimeCollisionCircles&&(vn=$e.featureIndex),pt.verticalTextFeatureIndex&&(uo=pt.verticalTextFeatureIndex);const ca=pt.textBox;if(ca){const tr=ir=>{let Ri=d.ah.horizontal;if(a.allowVerticalPlacement&&!ir&&this.prevPlacement){const Fn=this.prevPlacement.placedOrientations[$e.crossTileID];Fn&&(this.placedOrientations[$e.crossTileID]=Fn,Ri=Fn,this.markUsedOrientation(a,Ri,$e))}return Ri},Di=(ir,Ri)=>{if(a.allowVerticalPlacement&&$e.numVerticalGlyphVertices>0&&pt.verticalTextBox){for(const Fn of a.writingModes)if(Fn===d.ah.vertical?(ni=Ri(),_n=ni):ni=ir(),ni&&ni.box&&ni.box.length)break}else ni=ir()},Ci=$e.textAnchorOffsetStartIndex,Rn=$e.textAnchorOffsetEndIndex;if(Rn===Ci){const ir=(Ri,Fn)=>{const rr=this.collisionIndex.placeCollisionBox(Ri,N,S,g,Z.predicate,Ne);return rr&&rr.box&&rr.box.length&&(this.markUsedOrientation(a,Fn,$e),this.placedOrientations[$e.crossTileID]=Fn),rr};Di(()=>ir(ca,d.ah.horizontal),()=>{const Ri=pt.verticalTextBox;return a.allowVerticalPlacement&&$e.numVerticalGlyphVertices>0&&Ri?ir(Ri,d.ah.vertical):{box:null,offscreen:null}}),tr(ni&&ni.box&&ni.box.length)}else{let ir=d.ap[(jt=(Ct=this.prevPlacement)===null||Ct===void 0?void 0:Ct.variableOffsets[$e.crossTileID])===null||jt===void 0?void 0:jt.anchor];const Ri=(rr,Hi,rl)=>{const Ol=rr.x2-rr.x1,os=rr.y2-rr.y1,ss=$e.textBoxScale,La=ye&&me==="never"?Hi:null;let jo={box:[],offscreen:!1},nl=N==="never"?1:2,Nl="never";ir&&nl++;for(let ol=0;olRi(ca,pt.iconBox,d.ah.horizontal),()=>{const rr=pt.verticalTextBox;return a.allowVerticalPlacement&&!(ni&&ni.box&&ni.box.length)&&$e.numVerticalGlyphVertices>0&&rr?Ri(rr,pt.verticalIconBox,d.ah.vertical):{box:null,offscreen:null}}),ni&&(vt=ni.box,Dt=ni.offscreen);const Fn=tr(ni&&ni.box);if(!vt&&this.prevPlacement){const rr=this.prevPlacement.variableOffsets[$e.crossTileID];rr&&(this.variableOffsets[$e.crossTileID]=rr,this.markUsedJustification(a,rr.anchor,$e,Fn))}}}if(dr=ni,vt=dr&&dr.box&&dr.box.length>0,Dt=dr&&dr.offscreen,$e.useRuntimeCollisionCircles){const tr=a.text.placedSymbolArray.get($e.centerJustifiedTextSymbolIndex),Di=d.ai(a.textSizeData,F,tr),Ci=u.get("text-padding");zi=this.collisionIndex.placeCollisionCircles(N,tr,a.lineVertexArray,a.glyphOffsetArray,Di,g,y,v,s,ge,Z.predicate,$e.collisionCircleDiameter,Ci,Ne),zi.circles.length&&zi.collisionDetected&&!s&&d.w("Collisions detected, but collision boxes are not shown"),vt=ee||zi.circles.length>0&&!zi.collisionDetected,Dt=Dt&&zi.offscreen}if(pt.iconFeatureIndex&&(Vo=pt.iconFeatureIndex),pt.iconBox){const tr=Di=>{const Ci=ye&&ji?Tr(Di,ji.x,ji.y,ae,ge,this.transform.angle):Di;return this.collisionIndex.placeCollisionBox(Ci,me,S,g,Z.predicate,Ne)};_n&&_n.box&&_n.box.length&&pt.verticalIconBox?(pr=tr(pt.verticalIconBox),Pt=pr.box.length>0):(pr=tr(pt.iconBox),Pt=pr.box.length>0),Dt=Dt&&pr.offscreen}const Uo=$||$e.numHorizontalGlyphVertices===0&&$e.numVerticalGlyphVertices===0,ho=H||$e.numIconVertices===0;if(Uo||ho?ho?Uo||(Pt=Pt&&vt):vt=Pt&&vt:Pt=vt=Pt&&vt,vt&&dr&&dr.box&&this.collisionIndex.insertCollisionBox(dr.box,N,u.get("text-ignore-placement"),a.bucketInstanceId,_n&&_n.box&&uo?uo:vn,Z.ID),Pt&&pr&&this.collisionIndex.insertCollisionBox(pr.box,me,u.get("icon-ignore-placement"),a.bucketInstanceId,Vo,Z.ID),zi&&(vt&&this.collisionIndex.insertCollisionCircles(zi.circles,N,u.get("text-ignore-placement"),a.bucketInstanceId,vn,Z.ID),s)){const tr=a.bucketInstanceId;let Di=this.collisionCircleArrays[tr];Di===void 0&&(Di=this.collisionCircleArrays[tr]=new Zi);for(let Ci=0;Ci=0;--pt){const Ct=$e[pt];Et(a.symbolInstances.get(Ct),a.collisionArrays[Ct])}}else for(let $e=t.symbolInstanceStart;$e=0&&(t.text.placedSymbolArray.get(y).crossTileID=u>=0&&y!==u?0:s.crossTileID)}markUsedOrientation(t,n,s){const a=n===d.ah.horizontal||n===d.ah.horizontalOnly?n:0,u=n===d.ah.vertical?n:0,g=[s.leftJustifiedTextSymbolIndex,s.centerJustifiedTextSymbolIndex,s.rightJustifiedTextSymbolIndex];for(const y of g)t.text.placedSymbolArray.get(y).placedOrientation=a;s.verticalPlacedTextSymbolIndex&&(t.text.placedSymbolArray.get(s.verticalPlacedTextSymbolIndex).placedOrientation=u)}commit(t){this.commitTime=t,this.zoomAtLastRecencyCheck=this.transform.zoom;const n=this.prevPlacement;let s=!1;this.prevZoomAdjustment=n?n.zoomAdjustment(this.transform.zoom):0;const a=n?n.symbolFadeChange(t):1,u=n?n.opacities:{},g=n?n.variableOffsets:{},y=n?n.placedOrientations:{};for(const v in this.placements){const S=this.placements[v],C=u[v];C?(this.opacities[v]=new Xt(C,a,S.text,S.icon),s=s||S.text!==C.text.placed||S.icon!==C.icon.placed):(this.opacities[v]=new Xt(null,a,S.text,S.icon,S.skipFade),s=s||S.text||S.icon)}for(const v in u){const S=u[v];if(!this.opacities[v]){const C=new Xt(S,a,!1,!1);C.isHidden()||(this.opacities[v]=C,s=s||S.text.placed||S.icon.placed)}}for(const v in g)this.variableOffsets[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.variableOffsets[v]=g[v]);for(const v in y)this.placedOrientations[v]||!this.opacities[v]||this.opacities[v].isHidden()||(this.placedOrientations[v]=y[v]);if(n&&n.lastPlacementChangeTime===void 0)throw new Error("Last placement time for previous placement is not defined");s?this.lastPlacementChangeTime=t:typeof this.lastPlacementChangeTime!="number"&&(this.lastPlacementChangeTime=n?n.lastPlacementChangeTime:t)}updateLayerOpacities(t,n){const s={};for(const a of n){const u=a.getBucket(t);u&&a.latestFeatureIndex&&t.id===u.layerIds[0]&&this.updateBucketOpacities(u,s,a.collisionBoxArray)}}updateBucketOpacities(t,n,s){t.hasTextData()&&(t.text.opacityVertexArray.clear(),t.text.hasVisibleVertices=!1),t.hasIconData()&&(t.icon.opacityVertexArray.clear(),t.icon.hasVisibleVertices=!1),t.hasIconCollisionBoxData()&&t.iconCollisionBox.collisionVertexArray.clear(),t.hasTextCollisionBoxData()&&t.textCollisionBox.collisionVertexArray.clear();const a=t.layers[0],u=a.layout,g=new Xt(null,0,!1,!1,!0),y=u.get("text-allow-overlap"),v=u.get("icon-allow-overlap"),S=a._unevaluatedLayout.hasValue("text-variable-anchor")||a._unevaluatedLayout.hasValue("text-variable-anchor-offset"),C=u.get("text-rotation-alignment")==="map",A=u.get("text-pitch-alignment")==="map",F=u.get("icon-text-fit")!=="none",Z=new Xt(null,0,y&&(v||!t.hasIconData()||u.get("icon-optional")),v&&(y||!t.hasTextData()||u.get("text-optional")),!0);!t.collisionArrays&&s&&(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData())&&t.deserializeCollisionBoxes(s);const $=(H,N,ee)=>{for(let me=0;me0,ye=this.placedOrientations[N.crossTileID],xe=ye===d.ah.vertical,Pe=ye===d.ah.horizontal||ye===d.ah.horizontalOnly;if(ee>0||me>0){const Ae=Cr(ae.text);$(t.text,ee,xe?en:Ae),$(t.text,me,Pe?en:Ae);const Fe=ae.text.isHidden();[N.rightJustifiedTextSymbolIndex,N.centerJustifiedTextSymbolIndex,N.leftJustifiedTextSymbolIndex].forEach($e=>{$e>=0&&(t.text.placedSymbolArray.get($e).hidden=Fe||xe?1:0)}),N.verticalPlacedTextSymbolIndex>=0&&(t.text.placedSymbolArray.get(N.verticalPlacedTextSymbolIndex).hidden=Fe||Pe?1:0);const Ne=this.variableOffsets[N.crossTileID];Ne&&this.markUsedJustification(t,Ne.anchor,N,ye);const Et=this.placedOrientations[N.crossTileID];Et&&(this.markUsedJustification(t,"left",N,Et),this.markUsedOrientation(t,Et,N))}if(ge){const Ae=Cr(ae.icon),Fe=!(F&&N.verticalPlacedIconSymbolIndex&&xe);N.placedIconSymbolIndex>=0&&($(t.icon,N.numIconVertices,Fe?Ae:en),t.icon.placedSymbolArray.get(N.placedIconSymbolIndex).hidden=ae.icon.isHidden()),N.verticalPlacedIconSymbolIndex>=0&&($(t.icon,N.numVerticalIconVertices,Fe?en:Ae),t.icon.placedSymbolArray.get(N.verticalPlacedIconSymbolIndex).hidden=ae.icon.isHidden())}if(t.hasIconCollisionBoxData()||t.hasTextCollisionBoxData()){const Ae=t.collisionArrays[H];if(Ae){let Fe=new d.P(0,0);if(Ae.textBox||Ae.verticalTextBox){let Et=!0;if(S){const $e=this.variableOffsets[X];$e?(Fe=Ji($e.anchor,$e.width,$e.height,$e.textOffset,$e.textBoxScale),C&&Fe._rotate(A?this.transform.angle:-this.transform.angle)):Et=!1}Ae.textBox&&er(t.textCollisionBox.collisionVertexArray,ae.text.placed,!Et||xe,Fe.x,Fe.y),Ae.verticalTextBox&&er(t.textCollisionBox.collisionVertexArray,ae.text.placed,!Et||Pe,Fe.x,Fe.y)}const Ne=!!(!Pe&&Ae.verticalIconBox);Ae.iconBox&&er(t.iconCollisionBox.collisionVertexArray,ae.icon.placed,Ne,F?Fe.x:0,F?Fe.y:0),Ae.verticalIconBox&&er(t.iconCollisionBox.collisionVertexArray,ae.icon.placed,!Ne,F?Fe.x:0,F?Fe.y:0)}}}if(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.text.opacityVertexArray.length!==t.text.layoutVertexArray.length/4)throw new Error(`bucket.text.opacityVertexArray.length (= ${t.text.opacityVertexArray.length}) !== bucket.text.layoutVertexArray.length (= ${t.text.layoutVertexArray.length}) / 4`);if(t.icon.opacityVertexArray.length!==t.icon.layoutVertexArray.length/4)throw new Error(`bucket.icon.opacityVertexArray.length (= ${t.icon.opacityVertexArray.length}) !== bucket.icon.layoutVertexArray.length (= ${t.icon.layoutVertexArray.length}) / 4`);if(t.bucketInstanceId in this.collisionCircleArrays){const H=this.collisionCircleArrays[t.bucketInstanceId];t.placementInvProjMatrix=H.invProjMatrix,t.placementViewportMatrix=H.viewportMatrix,t.collisionCircleArray=H.circles,delete this.collisionCircleArrays[t.bucketInstanceId]}}symbolFadeChange(t){return this.fadeDuration===0?1:(t-this.commitTime)/this.fadeDuration+this.prevZoomAdjustment}zoomAdjustment(t){return Math.max(0,(this.transform.zoom-t)/1.5)}hasTransitions(t){return this.stale||t-this.lastPlacementChangeTimet}setStale(){this.stale=!0}}function er(c,t,n,s,a){c.emplaceBack(t?1:0,n?1:0,s||0,a||0),c.emplaceBack(t?1:0,n?1:0,s||0,a||0),c.emplaceBack(t?1:0,n?1:0,s||0,a||0),c.emplaceBack(t?1:0,n?1:0,s||0,a||0)}const Qr=Math.pow(2,25),ma=Math.pow(2,24),hs=Math.pow(2,17),Jt=Math.pow(2,16),qo=Math.pow(2,9),Bi=Math.pow(2,8),Rr=Math.pow(2,1);function Cr(c){if(c.opacity===0&&!c.placed)return 0;if(c.opacity===1&&c.placed)return 4294967295;const t=c.placed?1:0,n=Math.floor(127*c.opacity);return n*Qr+t*ma+n*hs+t*Jt+n*qo+t*Bi+n*Rr+t}const en=0;class Oi{constructor(t){this._sortAcrossTiles=t.layout.get("symbol-z-order")!=="viewport-y"&&!t.layout.get("symbol-sort-key").isConstant(),this._currentTileIndex=0,this._currentPartIndex=0,this._seenCrossTileIDs={},this._bucketParts=[]}continuePlacement(t,n,s,a,u){const g=this._bucketParts;for(;this._currentTileIndexy.sortKey-v.sortKey));this._currentPartIndex!this._forceFullPlacement&&ce.now()-a>2;for(;this._currentPlacementIndex>=0;){const g=n[t[this._currentPlacementIndex]],y=this.placement.collisionIndex.transform.zoom;if(g.type==="symbol"&&(!g.minzoom||g.minzoom<=y)&&(!g.maxzoom||g.maxzoom>y)){if(this._inProgressLayer||(this._inProgressLayer=new Oi(g)),this._inProgressLayer.continuePlacement(s[g.source],this.placement,this._showCollisionBoxes,g,u))return;delete this._inProgressLayer}this._currentPlacementIndex--}this._done=!0}commit(t){return this.placement.commit(t),this.placement}}const tn=512/d.W/2;class Mn{constructor(t,n,s){this.tileID=t,this.bucketInstanceId=s,this._symbolsByKey={};const a=new Map;for(let u=0;u({x:Math.floor(v.anchorX*tn),y:Math.floor(v.anchorY*tn)})),crossTileIDs:g.map(v=>v.crossTileID)};if(y.positions.length>128){const v=new d.au(y.positions.length,16,Uint16Array);for(const{x:S,y:C}of y.positions)v.add(S,C);v.finish(),delete y.positions,y.index=v}this._symbolsByKey[u]=y}}getScaledCoordinates(t,n){const{x:s,y:a,z:u}=this.tileID.canonical,{x:g,y,z:v}=n.canonical,S=tn/Math.pow(2,v-u),C=(y*d.W+t.anchorY)*S,A=a*d.W*tn;return{x:Math.floor((g*d.W+t.anchorX)*S-s*d.W*tn),y:Math.floor(C-A)}}findMatches(t,n,s){const a=this.tileID.canonical.zt)}}class Ni{constructor(){this.maxCrossTileID=0}generate(){return++this.maxCrossTileID}}class Ho{constructor(){this.indexes={},this.usedCrossTileIDs={},this.lng=0}handleWrapJump(t){const n=Math.round((t-this.lng)/360);if(n!==0)for(const s in this.indexes){const a=this.indexes[s],u={};for(const g in a){const y=a[g];y.tileID=y.tileID.unwrapTo(y.tileID.wrap+n),u[y.tileID.key]=y}this.indexes[s]=u}this.lng=t}addBucket(t,n,s){if(this.indexes[t.overscaledZ]&&this.indexes[t.overscaledZ][t.key]){if(this.indexes[t.overscaledZ][t.key].bucketInstanceId===n.bucketInstanceId)return!1;this.removeBucketCrossTileIDs(t.overscaledZ,this.indexes[t.overscaledZ][t.key])}for(let u=0;ut.overscaledZ)for(const y in g){const v=g[y];v.tileID.isChildOf(t)&&v.findMatches(n.symbolInstances,t,a)}else{const y=g[t.scaledTo(Number(u)).key];y&&y.findMatches(n.symbolInstances,t,a)}}for(let u=0;u{n[s]=!0});for(const s in this.layerIndexes)n[s]||delete this.layerIndexes[s]}}const mi=(c,t)=>d.t(c,t&&t.filter(n=>n.identifier!=="source.canvas")),Wo=d.av();class Ar extends d.E{constructor(t,n={}){super(),this._rtlPluginLoaded=()=>{for(const s in this.sourceCaches){const a=this.sourceCaches[s].getSource().type;a!=="vector"&&a!=="geojson"||this.sourceCaches[s].reload()}},this.map=t,this.dispatcher=new sr(or(),t._getMapId()),this.dispatcher.registerMessageHandler("GG",(s,a)=>this.getGlyphs(s,a)),this.dispatcher.registerMessageHandler("GI",(s,a)=>this.getImages(s,a)),this.imageManager=new pi,this.imageManager.setEventedParent(this),this.glyphManager=new br(t._requestManager,n.localIdeographFontFamily),this.lineAtlas=new $i(256,512),this.crossTileSymbolIndex=new no,this._spritesImagesIds={},this._layers={},this._order=[],this.sourceCaches={},this.zoomHistory=new d.aw,this._loaded=!1,this._availableImages=[],this._resetUpdates(),this.dispatcher.broadcast("SR",d.ax()),ze().on(Fi,this._rtlPluginLoaded),this.on("data",s=>{if(s.dataType!=="source"||s.sourceDataType!=="metadata")return;const a=this.sourceCaches[s.sourceId];if(!a)return;const u=a.getSource();if(u&&u.vectorLayerIds)for(const g in this._layers){const y=this._layers[g];y.source===u.id&&this._validateLayer(y)}})}loadURL(t,n={},s){this.fire(new d.k("dataloading",{dataType:"style"})),n.validate=typeof n.validate!="boolean"||n.validate;const a=this.map._requestManager.transformRequest(t,"Style");this._loadStyleRequest=new AbortController,d.h(a,this._loadStyleRequest).then(u=>{this._loadStyleRequest=null,this._load(u.data,n,s)}).catch(u=>{this._loadStyleRequest=null,u&&this.fire(new d.j(u))})}loadJSON(t,n={},s){this.fire(new d.k("dataloading",{dataType:"style"})),this._frameRequest=new AbortController,ce.frameAsync(this._frameRequest).then(()=>{this._frameRequest=null,n.validate=n.validate!==!1,this._load(t,n,s)}).catch(()=>{})}loadEmpty(){this.fire(new d.k("dataloading",{dataType:"style"})),this._load(Wo,{validate:!1})}_load(t,n,s){var a;const u=n.transformStyle?n.transformStyle(s,t):t;if(!n.validate||!mi(this,d.x(u))){this._loaded=!0,this.stylesheet=u;for(const g in u.sources)this.addSource(g,u.sources[g],{validate:!1});u.sprite?this._loadSprite(u.sprite):this.imageManager.setLoaded(!0),this.glyphManager.setURL(u.glyphs),this._createLayers(),this.light=new dn(this.stylesheet.light),this.map.setTerrain((a=this.stylesheet.terrain)!==null&&a!==void 0?a:null),this.fire(new d.k("data",{dataType:"style"})),this.fire(new d.k("style.load"))}}_createLayers(){const t=d.ay(this.stylesheet.layers);this.dispatcher.broadcast("SL",t),this._order=t.map(n=>n.id),this._layers={},this._serializedLayers=null;for(const n of t){const s=d.az(n);s.setEventedParent(this,{layer:{id:n.id}}),this._layers[n.id]=s}}_loadSprite(t,n=!1,s=void 0){let a;this.imageManager.setLoaded(!1),this._spriteRequest=new AbortController,function(u,g,y,v){return d._(this,void 0,void 0,function*(){const S=Zt(u),C=y>1?"@2x":"",A={},F={};for(const{id:Z,url:$}of S){const H=g.transformRequest(g.normalizeSpriteURL($,C,".json"),"SpriteJSON");A[Z]=d.h(H,v);const N=g.transformRequest(g.normalizeSpriteURL($,C,".png"),"SpriteImage");F[Z]=Mt.getImage(N,v)}return yield Promise.all([...Object.values(A),...Object.values(F)]),function(Z,$){return d._(this,void 0,void 0,function*(){const H={};for(const N in Z){H[N]={};const ee=ce.getImageCanvasContext((yield $[N]).data),me=(yield Z[N]).data;for(const X in me){const{width:ae,height:ge,x:ye,y:xe,sdf:Pe,pixelRatio:Ae,stretchX:Fe,stretchY:Ne,content:Et}=me[X];H[N][X]={data:null,pixelRatio:Ae,sdf:Pe,stretchX:Fe,stretchY:Ne,content:Et,spriteData:{width:ae,height:ge,x:ye,y:xe,context:ee}}}}return H})}(A,F)})}(t,this.map._requestManager,this.map.getPixelRatio(),this._spriteRequest).then(u=>{if(this._spriteRequest=null,u)for(const g in u){this._spritesImagesIds[g]=[];const y=this._spritesImagesIds[g]?this._spritesImagesIds[g].filter(v=>!(v in u)):[];for(const v of y)this.imageManager.removeImage(v),this._changedImages[v]=!0;for(const v in u[g]){const S=g==="default"?v:`${g}:${v}`;this._spritesImagesIds[g].push(S),S in this.imageManager.images?this.imageManager.updateImage(S,u[g][v],!1):this.imageManager.addImage(S,u[g][v]),n&&(this._changedImages[S]=!0)}}}).catch(u=>{this._spriteRequest=null,a=u,this.fire(new d.j(a))}).finally(()=>{this.imageManager.setLoaded(!0),this._availableImages=this.imageManager.listImages(),n&&(this._changed=!0),this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"})),s&&s(a)})}_unloadSprite(){for(const t of Object.values(this._spritesImagesIds).flat())this.imageManager.removeImage(t),this._changedImages[t]=!0;this._spritesImagesIds={},this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}_validateLayer(t){const n=this.sourceCaches[t.source];if(!n)return;const s=t.sourceLayer;if(!s)return;const a=n.getSource();(a.type==="geojson"||a.vectorLayerIds&&a.vectorLayerIds.indexOf(s)===-1)&&this.fire(new d.j(new Error(`Source layer "${s}" does not exist on source "${a.id}" as specified by style layer "${t.id}".`)))}loaded(){if(!this._loaded||Object.keys(this._updatedSources).length)return!1;for(const t in this.sourceCaches)if(!this.sourceCaches[t].loaded())return!1;return!!this.imageManager.isLoaded()}_serializeByIds(t){const n=this._serializedAllLayers();if(!t||t.length===0)return Object.values(n);const s=[];for(const a of t)n[a]&&s.push(n[a]);return s}_serializedAllLayers(){let t=this._serializedLayers;if(t)return t;t=this._serializedLayers={};const n=Object.keys(this._layers);for(const s of n){const a=this._layers[s];a.type!=="custom"&&(t[s]=a.serialize())}return t}hasTransitions(){if(this.light&&this.light.hasTransition())return!0;for(const t in this.sourceCaches)if(this.sourceCaches[t].hasTransition())return!0;for(const t in this._layers)if(this._layers[t].hasTransition())return!0;return!1}_checkLoaded(){if(!this._loaded)throw new Error("Style is not done loading.")}update(t){if(!this._loaded)return;const n=this._changed;if(n){const a=Object.keys(this._updatedLayers),u=Object.keys(this._removedLayers);(a.length||u.length)&&this._updateWorkerLayers(a,u);for(const g in this._updatedSources){const y=this._updatedSources[g];if(y==="reload")this._reloadSource(g);else{if(y!=="clear")throw new Error(`Invalid action ${y}`);this._clearSource(g)}}this._updateTilesForChangedImages(),this._updateTilesForChangedGlyphs();for(const g in this._updatedPaintProps)this._layers[g].updateTransitions(t);this.light.updateTransitions(t),this._resetUpdates()}const s={};for(const a in this.sourceCaches){const u=this.sourceCaches[a];s[a]=u.used,u.used=!1}for(const a of this._order){const u=this._layers[a];u.recalculate(t,this._availableImages),!u.isHidden(t.zoom)&&u.source&&(this.sourceCaches[u.source].used=!0)}for(const a in s){const u=this.sourceCaches[a];!!s[a]!=!!u.used&&u.fire(new d.k("data",{sourceDataType:"visibility",dataType:"source",sourceId:a}))}this.light.recalculate(t),this.z=t.zoom,n&&this.fire(new d.k("data",{dataType:"style"}))}_updateTilesForChangedImages(){const t=Object.keys(this._changedImages);if(t.length){for(const n in this.sourceCaches)this.sourceCaches[n].reloadTilesForDependencies(["icons","patterns"],t);this._changedImages={}}}_updateTilesForChangedGlyphs(){if(this._glyphsDidChange){for(const t in this.sourceCaches)this.sourceCaches[t].reloadTilesForDependencies(["glyphs"],[""]);this._glyphsDidChange=!1}}_updateWorkerLayers(t,n){this.dispatcher.broadcast("UL",{layers:this._serializeByIds(t),removedIds:n})}_resetUpdates(){this._changed=!1,this._updatedLayers={},this._removedLayers={},this._updatedSources={},this._updatedPaintProps={},this._changedImages={},this._glyphsDidChange=!1}setState(t,n={}){var s;this._checkLoaded();const a=this.serialize();if(t=n.transformStyle?n.transformStyle(a,t):t,((s=n.validate)===null||s===void 0||s)&&mi(this,d.x(t)))return!1;(t=d.aA(t)).layers=d.ay(t.layers);const u=d.aB(a,t),g=this._getOperationsToPerform(u);if(g.unimplemented.length>0)throw new Error(`Unimplemented: ${g.unimplemented.join(", ")}.`);if(g.operations.length===0)return!1;for(const y of g.operations)y();return this.stylesheet=t,this._serializedLayers=null,!0}_getOperationsToPerform(t){const n=[],s=[];for(const a of t)switch(a.command){case"setCenter":case"setZoom":case"setBearing":case"setPitch":continue;case"addLayer":n.push(()=>this.addLayer.apply(this,a.args));break;case"removeLayer":n.push(()=>this.removeLayer.apply(this,a.args));break;case"setPaintProperty":n.push(()=>this.setPaintProperty.apply(this,a.args));break;case"setLayoutProperty":n.push(()=>this.setLayoutProperty.apply(this,a.args));break;case"setFilter":n.push(()=>this.setFilter.apply(this,a.args));break;case"addSource":n.push(()=>this.addSource.apply(this,a.args));break;case"removeSource":n.push(()=>this.removeSource.apply(this,a.args));break;case"setLayerZoomRange":n.push(()=>this.setLayerZoomRange.apply(this,a.args));break;case"setLight":n.push(()=>this.setLight.apply(this,a.args));break;case"setGeoJSONSourceData":n.push(()=>this.setGeoJSONSourceData.apply(this,a.args));break;case"setGlyphs":n.push(()=>this.setGlyphs.apply(this,a.args));break;case"setSprite":n.push(()=>this.setSprite.apply(this,a.args));break;case"setTerrain":n.push(()=>this.map.setTerrain.apply(this,a.args));break;case"setTransition":n.push(()=>{});break;default:s.push(a.command)}return{operations:n,unimplemented:s}}addImage(t,n){if(this.getImage(t))return this.fire(new d.j(new Error(`An image named "${t}" already exists.`)));this.imageManager.addImage(t,n),this._afterImageUpdated(t)}updateImage(t,n){this.imageManager.updateImage(t,n)}getImage(t){return this.imageManager.getImage(t)}removeImage(t){if(!this.getImage(t))return this.fire(new d.j(new Error(`An image named "${t}" does not exist.`)));this.imageManager.removeImage(t),this._afterImageUpdated(t)}_afterImageUpdated(t){this._availableImages=this.imageManager.listImages(),this._changedImages[t]=!0,this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}listImages(){return this._checkLoaded(),this.imageManager.listImages()}addSource(t,n,s={}){if(this._checkLoaded(),this.sourceCaches[t]!==void 0)throw new Error(`Source "${t}" already exists.`);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(d.x.source,`sources.${t}`,n,null,s))return;this.map&&this.map._collectResourceTiming&&(n.collectResourceTiming=!0);const a=this.sourceCaches[t]=new Xi(t,n,this.dispatcher);a.style=this,a.setEventedParent(this,()=>({isSourceLoaded:a.loaded(),source:a.serialize(),sourceId:t})),a.onAdd(this.map),this._changed=!0}removeSource(t){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error("There is no source with this ID");for(const s in this._layers)if(this._layers[s].source===t)return this.fire(new d.j(new Error(`Source "${t}" cannot be removed while layer "${s}" is using it.`)));const n=this.sourceCaches[t];delete this.sourceCaches[t],delete this._updatedSources[t],n.fire(new d.k("data",{sourceDataType:"metadata",dataType:"source",sourceId:t})),n.setEventedParent(null),n.onRemove(this.map),this._changed=!0}setGeoJSONSourceData(t,n){if(this._checkLoaded(),this.sourceCaches[t]===void 0)throw new Error(`There is no source with this ID=${t}`);const s=this.sourceCaches[t].getSource();if(s.type!=="geojson")throw new Error(`geojsonSource.type is ${s.type}, which is !== 'geojson`);s.setData(n),this._changed=!0}getSource(t){return this.sourceCaches[t]&&this.sourceCaches[t].getSource()}addLayer(t,n,s={}){this._checkLoaded();const a=t.id;if(this.getLayer(a))return void this.fire(new d.j(new Error(`Layer "${a}" already exists on this map.`)));let u;if(t.type==="custom"){if(mi(this,d.aC(t)))return;u=d.az(t)}else{if("source"in t&&typeof t.source=="object"&&(this.addSource(a,t.source),t=d.aA(t),t=d.e(t,{source:a})),this._validate(d.x.layer,`layers.${a}`,t,{arrayIndex:-1},s))return;u=d.az(t),this._validateLayer(u),u.setEventedParent(this,{layer:{id:a}})}const g=n?this._order.indexOf(n):this._order.length;if(n&&g===-1)this.fire(new d.j(new Error(`Cannot add layer "${a}" before non-existing layer "${n}".`)));else{if(this._order.splice(g,0,a),this._layerOrderChanged=!0,this._layers[a]=u,this._removedLayers[a]&&u.source&&u.type!=="custom"){const y=this._removedLayers[a];delete this._removedLayers[a],y.type!==u.type?this._updatedSources[u.source]="clear":(this._updatedSources[u.source]="reload",this.sourceCaches[u.source].pause())}this._updateLayer(u),u.onAdd&&u.onAdd(this.map)}}moveLayer(t,n){if(this._checkLoaded(),this._changed=!0,!this._layers[t])return void this.fire(new d.j(new Error(`The layer '${t}' does not exist in the map's style and cannot be moved.`)));if(t===n)return;const s=this._order.indexOf(t);this._order.splice(s,1);const a=n?this._order.indexOf(n):this._order.length;n&&a===-1?this.fire(new d.j(new Error(`Cannot move layer "${t}" before non-existing layer "${n}".`))):(this._order.splice(a,0,t),this._layerOrderChanged=!0)}removeLayer(t){this._checkLoaded();const n=this._layers[t];if(!n)return void this.fire(new d.j(new Error(`Cannot remove non-existing layer "${t}".`)));n.setEventedParent(null);const s=this._order.indexOf(t);this._order.splice(s,1),this._layerOrderChanged=!0,this._changed=!0,this._removedLayers[t]=n,delete this._layers[t],this._serializedLayers&&delete this._serializedLayers[t],delete this._updatedLayers[t],delete this._updatedPaintProps[t],n.onRemove&&n.onRemove(this.map)}getLayer(t){return this._layers[t]}getLayersOrder(){return[...this._order]}hasLayer(t){return t in this._layers}setLayerZoomRange(t,n,s){this._checkLoaded();const a=this.getLayer(t);a?a.minzoom===n&&a.maxzoom===s||(n!=null&&(a.minzoom=n),s!=null&&(a.maxzoom=s),this._updateLayer(a)):this.fire(new d.j(new Error(`Cannot set the zoom range of non-existing layer "${t}".`)))}setFilter(t,n,s={}){this._checkLoaded();const a=this.getLayer(t);if(a){if(!d.aD(a.filter,n))return n==null?(a.filter=void 0,void this._updateLayer(a)):void(this._validate(d.x.filter,`layers.${a.id}.filter`,n,null,s)||(a.filter=d.aA(n),this._updateLayer(a)))}else this.fire(new d.j(new Error(`Cannot filter non-existing layer "${t}".`)))}getFilter(t){return d.aA(this.getLayer(t).filter)}setLayoutProperty(t,n,s,a={}){this._checkLoaded();const u=this.getLayer(t);u?d.aD(u.getLayoutProperty(n),s)||(u.setLayoutProperty(n,s,a),this._updateLayer(u)):this.fire(new d.j(new Error(`Cannot style non-existing layer "${t}".`)))}getLayoutProperty(t,n){const s=this.getLayer(t);if(s)return s.getLayoutProperty(n);this.fire(new d.j(new Error(`Cannot get style of non-existing layer "${t}".`)))}setPaintProperty(t,n,s,a={}){this._checkLoaded();const u=this.getLayer(t);u?d.aD(u.getPaintProperty(n),s)||(u.setPaintProperty(n,s,a)&&this._updateLayer(u),this._changed=!0,this._updatedPaintProps[t]=!0,this._serializedLayers=null):this.fire(new d.j(new Error(`Cannot style non-existing layer "${t}".`)))}getPaintProperty(t,n){return this.getLayer(t).getPaintProperty(n)}setFeatureState(t,n){this._checkLoaded();const s=t.source,a=t.sourceLayer,u=this.sourceCaches[s];if(u===void 0)return void this.fire(new d.j(new Error(`The source '${s}' does not exist in the map's style.`)));const g=u.getSource().type;g==="geojson"&&a?this.fire(new d.j(new Error("GeoJSON sources cannot have a sourceLayer parameter."))):g!=="vector"||a?(t.id===void 0&&this.fire(new d.j(new Error("The feature id parameter must be provided."))),u.setFeatureState(a,t.id,n)):this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}removeFeatureState(t,n){this._checkLoaded();const s=t.source,a=this.sourceCaches[s];if(a===void 0)return void this.fire(new d.j(new Error(`The source '${s}' does not exist in the map's style.`)));const u=a.getSource().type,g=u==="vector"?t.sourceLayer:void 0;u!=="vector"||g?n&&typeof t.id!="string"&&typeof t.id!="number"?this.fire(new d.j(new Error("A feature id is required to remove its specific state property."))):a.removeFeatureState(g,t.id,n):this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")))}getFeatureState(t){this._checkLoaded();const n=t.source,s=t.sourceLayer,a=this.sourceCaches[n];if(a!==void 0)return a.getSource().type!=="vector"||s?(t.id===void 0&&this.fire(new d.j(new Error("The feature id parameter must be provided."))),a.getFeatureState(s,t.id)):void this.fire(new d.j(new Error("The sourceLayer parameter must be provided for vector source types.")));this.fire(new d.j(new Error(`The source '${n}' does not exist in the map's style.`)))}getTransition(){return d.e({duration:300,delay:0},this.stylesheet&&this.stylesheet.transition)}serialize(){if(!this._loaded)return;const t=d.aE(this.sourceCaches,u=>u.serialize()),n=this._serializeByIds(this._order),s=this.map.getTerrain()||void 0,a=this.stylesheet;return d.aF({version:a.version,name:a.name,metadata:a.metadata,light:a.light,center:a.center,zoom:a.zoom,bearing:a.bearing,pitch:a.pitch,sprite:a.sprite,glyphs:a.glyphs,transition:a.transition,sources:t,layers:n,terrain:s},u=>u!==void 0)}_updateLayer(t){this._updatedLayers[t.id]=!0,t.source&&!this._updatedSources[t.source]&&this.sourceCaches[t.source].getSource().type!=="raster"&&(this._updatedSources[t.source]="reload",this.sourceCaches[t.source].pause()),this._serializedLayers=null,this._changed=!0}_flattenAndSortRenderedFeatures(t){const n=g=>this._layers[g].type==="fill-extrusion",s={},a=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(n(y)){s[y]=g;for(const v of t){const S=v[y];if(S)for(const C of S)a.push(C)}}}a.sort((g,y)=>y.intersectionZ-g.intersectionZ);const u=[];for(let g=this._order.length-1;g>=0;g--){const y=this._order[g];if(n(y))for(let v=a.length-1;v>=0;v--){const S=a[v].feature;if(s[S.layer.id]{const Pe=ee.featureSortOrder;if(Pe){const Ae=Pe.indexOf(ye.featureIndex);return Pe.indexOf(xe.featureIndex)-Ae}return xe.featureIndex-ye.featureIndex});for(const ye of ge)ae.push(ye)}}for(const ee in $)$[ee].forEach(me=>{const X=me.feature,ae=S[y[ee].source].getFeatureState(X.layer["source-layer"],X.id);X.source=X.layer.source,X.layer["source-layer"]&&(X.sourceLayer=X.layer["source-layer"]),X.state=ae});return $}(this._layers,g,this.sourceCaches,t,n,this.placement.collisionIndex,this.placement.retainedQueryData)),this._flattenAndSortRenderedFeatures(u)}querySourceFeatures(t,n){n&&n.filter&&this._validate(d.x.filter,"querySourceFeatures.filter",n.filter,null,n);const s=this.sourceCaches[t];return s?function(a,u){const g=a.getRenderableIds().map(S=>a.getTileByID(S)),y=[],v={};for(let S=0;SF.getTileByID(Z)).sort((Z,$)=>$.tileID.overscaledZ-Z.tileID.overscaledZ||(Z.tileID.isLessThan($.tileID)?-1:1))}const A=this.crossTileSymbolIndex.addLayer(C,v[C.source],t.center.lng);g=g||A}if(this.crossTileSymbolIndex.pruneUnusedLayers(this._order),((u=u||this._layerOrderChanged||s===0)||!this.pauseablePlacement||this.pauseablePlacement.isDone()&&!this.placement.stillRecent(ce.now(),t.zoom))&&(this.pauseablePlacement=new Mr(t,this.map.terrain,this._order,u,n,s,a,this.placement),this._layerOrderChanged=!1),this.pauseablePlacement.isDone()?this.placement.setStale():(this.pauseablePlacement.continuePlacement(this._order,this._layers,v),this.pauseablePlacement.isDone()&&(this.placement=this.pauseablePlacement.commit(ce.now()),y=!0),g&&this.pauseablePlacement.placement.setStale()),y||g)for(const S of this._order){const C=this._layers[S];C.type==="symbol"&&this.placement.updateLayerOpacities(C,v[C.source])}return!this.pauseablePlacement.isDone()||this.placement.hasTransitions(ce.now())}_releaseSymbolFadeTiles(){for(const t in this.sourceCaches)this.sourceCaches[t].releaseSymbolFadeTiles()}getImages(t,n){return d._(this,void 0,void 0,function*(){const s=yield this.imageManager.getImages(n.icons);this._updateTilesForChangedImages();const a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,n.icons),s})}getGlyphs(t,n){return d._(this,void 0,void 0,function*(){const s=yield this.glyphManager.getGlyphs(n.stacks),a=this.sourceCaches[n.source];return a&&a.setDependencies(n.tileID.key,n.type,[""]),s})}getGlyphsUrl(){return this.stylesheet.glyphs||null}setGlyphs(t,n={}){this._checkLoaded(),t&&this._validate(d.x.glyphs,"glyphs",t,null,n)||(this._glyphsDidChange=!0,this.stylesheet.glyphs=t,this.glyphManager.entries={},this.glyphManager.setURL(t))}addSprite(t,n,s={},a){this._checkLoaded();const u=[{id:t,url:n}],g=[...Zt(this.stylesheet.sprite),...u];this._validate(d.x.sprite,"sprite",g,null,s)||(this.stylesheet.sprite=g,this._loadSprite(u,!0,a))}removeSprite(t){this._checkLoaded();const n=Zt(this.stylesheet.sprite);if(n.find(s=>s.id===t)){if(this._spritesImagesIds[t])for(const s of this._spritesImagesIds[t])this.imageManager.removeImage(s),this._changedImages[s]=!0;n.splice(n.findIndex(s=>s.id===t),1),this.stylesheet.sprite=n.length>0?n:void 0,delete this._spritesImagesIds[t],this._availableImages=this.imageManager.listImages(),this._changed=!0,this.dispatcher.broadcast("SI",this._availableImages),this.fire(new d.k("data",{dataType:"style"}))}else this.fire(new d.j(new Error(`Sprite "${t}" doesn't exists on this map.`)))}getSprite(){return Zt(this.stylesheet.sprite)}setSprite(t,n={},s){this._checkLoaded(),t&&this._validate(d.x.sprite,"sprite",t,null,n)||(this.stylesheet.sprite=t,t?this._loadSprite(t,!0,s):(this._unloadSprite(),s&&s(null)))}}var Xo=d.X([{name:"a_pos",type:"Int16",components:2}]),fn="attribute vec3 a_pos3d;uniform mat4 u_matrix;uniform float u_ele_delta;varying vec2 v_texture_pos;varying float v_depth;void main() {float extent=8192.0;float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/extent;gl_Position=u_matrix*vec4(a_pos3d.xy,get_elevation(a_pos3d.xy)-ele_delta,1.0);v_depth=gl_Position.z/gl_Position.w;}";const Jo={prelude:Qt(`#ifdef GL_ES precision mediump float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif `,`#ifdef GL_ES precision highp float; #else #if !defined(lowp) #define lowp #endif #if !defined(mediump) #define mediump #endif #if !defined(highp) #define highp #endif #endif vec2 unpack_float(const float packedValue) {int packedIntValue=int(packedValue);int v0=packedIntValue/256;return vec2(v0,packedIntValue-v0*256);}vec2 unpack_opacity(const float packedOpacity) {int intOpacity=int(packedOpacity)/2;return vec2(float(intOpacity)/127.0,mod(packedOpacity,2.0));}vec4 decode_color(const vec2 encodedColor) {return vec4(unpack_float(encodedColor[0])/255.0,unpack_float(encodedColor[1])/255.0 );}float unpack_mix_vec2(const vec2 packedValue,const float t) {return mix(packedValue[0],packedValue[1],t);}vec4 unpack_mix_color(const vec4 packedColors,const float t) {vec4 minColor=decode_color(vec2(packedColors[0],packedColors[1]));vec4 maxColor=decode_color(vec2(packedColors[2],packedColors[3]));return mix(minColor,maxColor,t);}vec2 get_pattern_pos(const vec2 pixel_coord_upper,const vec2 pixel_coord_lower,const vec2 pattern_size,const float tile_units_to_pixels,const vec2 pos) {vec2 offset=mod(mod(mod(pixel_coord_upper,pattern_size)*256.0,pattern_size)*256.0+pixel_coord_lower,pattern_size);return (tile_units_to_pixels*pos+offset)/pattern_size;} #ifdef TERRAIN3D uniform sampler2D u_terrain;uniform float u_terrain_dim;uniform mat4 u_terrain_matrix;uniform vec4 u_terrain_unpack;uniform float u_terrain_exaggeration;uniform highp sampler2D u_depth; #endif const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitShifts=vec4(1.)/bitSh;highp float unpack(highp vec4 color) {return dot(color,bitShifts);}highp float depthOpacity(vec3 frag) { #ifdef TERRAIN3D highp float d=unpack(texture2D(u_depth,frag.xy*0.5+0.5))+0.0001-frag.z;return 1.0-max(0.0,min(1.0,-d*500.0)); #else return 1.0; #endif }float calculate_visibility(vec4 pos) { #ifdef TERRAIN3D vec3 frag=pos.xyz/pos.w;highp float d=depthOpacity(frag);if (d > 0.95) return 1.0;return (d+depthOpacity(frag+vec3(0.0,0.01,0.0)))/2.0; #else return 1.0; #endif }float ele(vec2 pos) { #ifdef TERRAIN3D vec4 rgb=(texture2D(u_terrain,pos)*255.0)*u_terrain_unpack;return rgb.r+rgb.g+rgb.b-u_terrain_unpack.a; #else return 0.0; #endif }float get_elevation(vec2 pos) { #ifdef TERRAIN3D vec2 coord=(u_terrain_matrix*vec4(pos,0.0,1.0)).xy*u_terrain_dim+1.0;vec2 f=fract(coord);vec2 c=(floor(coord)+0.5)/(u_terrain_dim+2.0);float d=1.0/(u_terrain_dim+2.0);float tl=ele(c);float tr=ele(c+vec2(d,0.0));float bl=ele(c+vec2(0.0,d));float br=ele(c+vec2(d,d));float elevation=mix(mix(tl,tr,f.x),mix(bl,br,f.x),f.y);return elevation*u_terrain_exaggeration; #else return 0.0; #endif }`),background:Qt(`uniform vec4 u_color;uniform float u_opacity;void main() {gl_FragColor=u_color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"attribute vec2 a_pos;uniform mat4 u_matrix;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);}"),backgroundPattern:Qt(`uniform vec2 u_pattern_tl_a;uniform vec2 u_pattern_br_a;uniform vec2 u_pattern_tl_b;uniform vec2 u_pattern_br_b;uniform vec2 u_texsize;uniform float u_mix;uniform float u_opacity;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(u_pattern_tl_a/u_texsize,u_pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(u_pattern_tl_b/u_texsize,u_pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_mix)*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}"),circle:Qt(`varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=v_data.xy;float extrude_length=length(extrude);lowp float antialiasblur=v_data.z;float antialiased_blur=-max(blur,antialiasblur);float opacity_t=smoothstep(0.0,antialiased_blur,extrude_length-1.0);float color_t=stroke_width < 0.01 ? 0.0 : smoothstep(antialiased_blur,0.0,extrude_length-radius/(radius+stroke_width));gl_FragColor=v_visibility*opacity_t*mix(color*opacity,stroke_color*stroke_opacity,color_t); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform bool u_scale_with_map;uniform bool u_pitch_with_map;uniform vec2 u_extrude_scale;uniform lowp float u_device_pixel_ratio;uniform highp float u_camera_to_center_distance;attribute vec2 a_pos;varying vec3 v_data;varying float v_visibility; #pragma mapbox: define highp vec4 color #pragma mapbox: define mediump float radius #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define highp vec4 stroke_color #pragma mapbox: define mediump float stroke_width #pragma mapbox: define lowp float stroke_opacity void main(void) { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize mediump float radius #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize highp vec4 stroke_color #pragma mapbox: initialize mediump float stroke_width #pragma mapbox: initialize lowp float stroke_opacity vec2 extrude=vec2(mod(a_pos,2.0)*2.0-1.0);vec2 circle_center=floor(a_pos*0.5);float ele=get_elevation(circle_center);v_visibility=calculate_visibility(u_matrix*vec4(circle_center,ele,1.0));if (u_pitch_with_map) {vec2 corner_position=circle_center;if (u_scale_with_map) {corner_position+=extrude*(radius+stroke_width)*u_extrude_scale;} else {vec4 projected_center=u_matrix*vec4(circle_center,0,1);corner_position+=extrude*(radius+stroke_width)*u_extrude_scale*(projected_center.w/u_camera_to_center_distance);}gl_Position=u_matrix*vec4(corner_position,ele,1);} else {gl_Position=u_matrix*vec4(circle_center,ele,1);if (u_scale_with_map) {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*u_camera_to_center_distance;} else {gl_Position.xy+=extrude*(radius+stroke_width)*u_extrude_scale*gl_Position.w;}}lowp float antialiasblur=1.0/u_device_pixel_ratio/(radius+stroke_width);v_data=vec3(extrude.x,extrude.y,antialiasblur);}`),clippingMask:Qt("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:Qt(`uniform highp float u_intensity;varying vec2 v_extrude; #pragma mapbox: define highp float weight #define GAUSS_COEF 0.3989422804014327 void main() { #pragma mapbox: initialize highp float weight float d=-0.5*3.0*3.0*dot(v_extrude,v_extrude);float val=weight*u_intensity*GAUSS_COEF*exp(d);gl_FragColor=vec4(val,1.0,1.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform float u_extrude_scale;uniform float u_opacity;uniform float u_intensity;attribute vec2 a_pos;varying vec2 v_extrude; #pragma mapbox: define highp float weight #pragma mapbox: define mediump float radius const highp float ZERO=1.0/255.0/16.0; #define GAUSS_COEF 0.3989422804014327 void main(void) { #pragma mapbox: initialize highp float weight #pragma mapbox: initialize mediump float radius vec2 unscaled_extrude=vec2(mod(a_pos,2.0)*2.0-1.0);float S=sqrt(-2.0*log(ZERO/weight/u_intensity/GAUSS_COEF))/3.0;v_extrude=S*unscaled_extrude;vec2 extrude=v_extrude*radius*u_extrude_scale;vec4 pos=vec4(floor(a_pos*0.5)+extrude,0,1);gl_Position=u_matrix*pos;}`),heatmapTexture:Qt(`uniform sampler2D u_image;uniform sampler2D u_color_ramp;uniform float u_opacity;varying vec2 v_pos;void main() {float t=texture2D(u_image,v_pos).r;vec4 color=texture2D(u_color_ramp,vec2(t,0.5));gl_FragColor=color*u_opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(0.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_world;attribute vec2 a_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:Qt("varying float v_placed;varying float v_notUsed;void main() {float alpha=0.5;gl_FragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {gl_FragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {gl_FragColor*=.1;}}","attribute vec2 a_pos;attribute vec2 a_anchor_pos;attribute vec2 a_extrude;attribute vec2 a_placed;attribute vec2 a_shift;uniform mat4 u_matrix;uniform vec2 u_extrude_scale;uniform float u_camera_to_center_distance;varying float v_placed;varying float v_notUsed;void main() {vec4 projectedPoint=u_matrix*vec4(a_anchor_pos,0,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);gl_Position=u_matrix*vec4(a_pos,get_elevation(a_pos),1.0);gl_Position.xy+=(a_extrude+a_shift)*u_extrude_scale*gl_Position.w*collision_perspective_ratio;v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:Qt("varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;void main() {float alpha=0.5*min(v_perspective_ratio,1.0);float stroke_radius=0.9*max(v_perspective_ratio,1.0);float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);gl_FragColor=color*alpha*opacity_t;}","attribute vec2 a_pos;attribute float a_radius;attribute vec2 a_flags;uniform mat4 u_matrix;uniform mat4 u_inv_matrix;uniform vec2 u_viewport_size;uniform float u_camera_to_center_distance;varying float v_radius;varying vec2 v_extrude;varying float v_perspective_ratio;varying float v_collision;vec3 toTilePosition(vec2 screenPos) {vec4 rayStart=u_inv_matrix*vec4(screenPos,-1.0,1.0);vec4 rayEnd =u_inv_matrix*vec4(screenPos, 1.0,1.0);rayStart.xyz/=rayStart.w;rayEnd.xyz /=rayEnd.w;highp float t=(0.0-rayStart.z)/(rayEnd.z-rayStart.z);return mix(rayStart.xyz,rayEnd.xyz,t);}void main() {vec2 quadCenterPos=a_pos;float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;vec3 tilePos=toTilePosition(quadCenterPos);vec4 clipPos=u_matrix*vec4(tilePos,1.0);highp float camera_to_anchor_distance=clipPos.w;highp float collision_perspective_ratio=clamp(0.5+0.5*(u_camera_to_center_distance/camera_to_anchor_distance),0.0,4.0);float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_perspective_ratio=collision_perspective_ratio;v_collision=collision;gl_Position=vec4(clipPos.xyz/clipPos.w,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),debug:Qt("uniform highp vec4 u_color;uniform sampler2D u_overlay;varying vec2 v_uv;void main() {vec4 overlay_color=texture2D(u_overlay,v_uv);gl_FragColor=mix(u_color,overlay_color,overlay_color.a);}","attribute vec2 a_pos;varying vec2 v_uv;uniform mat4 u_matrix;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=u_matrix*vec4(a_pos*u_overlay_scale,get_elevation(a_pos),1);}"),fill:Qt(`#pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_FragColor=color*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);}`),fillOutline:Qt(`varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=outline_color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`attribute vec2 a_pos;uniform mat4 u_matrix;uniform vec2 u_world;varying vec2 v_pos; #pragma mapbox: define highp vec4 outline_color #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 outline_color #pragma mapbox: initialize lowp float opacity gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillOutlinePattern:Qt(`uniform vec2 u_texsize;uniform sampler2D u_image;uniform float u_fade;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);float dist=length(v_pos-gl_FragCoord.xy);float alpha=1.0-smoothstep(0.0,1.0,dist);gl_FragColor=mix(color1,color2,u_fade)*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_world;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec2 v_pos; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;gl_Position=u_matrix*vec4(a_pos,0,1);vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,a_pos);v_pos=(gl_Position.xy/gl_Position.w+1.0)/2.0*u_world;}`),fillPattern:Qt(`#ifdef GL_ES precision highp float; #endif uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);gl_FragColor=mix(color1,color2,u_fade)*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform vec3 u_scale;attribute vec2 a_pos;varying vec2 v_pos_a;varying vec2 v_pos_b; #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;gl_Position=u_matrix*vec4(a_pos,0,1);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileZoomRatio,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileZoomRatio,a_pos);}`),fillExtrusion:Qt(`varying vec4 v_color;void main() {gl_FragColor=v_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;uniform float u_vertical_gradient;uniform lowp float u_opacity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec4 v_color; #pragma mapbox: define highp float base #pragma mapbox: define highp float height #pragma mapbox: define highp vec4 color void main() { #pragma mapbox: initialize highp float base #pragma mapbox: initialize highp float height #pragma mapbox: initialize highp vec4 color vec3 normal=a_normal_ed.xyz; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);gl_Position=u_matrix*vec4(a_pos,t > 0.0 ? height : base,1);float colorvalue=color.r*0.2126+color.g*0.7152+color.b*0.0722;v_color=vec4(0.0,0.0,0.0,1.0);vec4 ambientlight=vec4(0.03,0.03,0.03,1.0);color+=ambientlight;float directional=clamp(dot(normal/16384.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((1.0-colorvalue+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_color.r+=clamp(color.r*directional*u_lightcolor.r,mix(0.0,0.3,1.0-u_lightcolor.r),1.0);v_color.g+=clamp(color.g*directional*u_lightcolor.g,mix(0.0,0.3,1.0-u_lightcolor.g),1.0);v_color.b+=clamp(color.b*directional*u_lightcolor.b,mix(0.0,0.3,1.0-u_lightcolor.b),1.0);v_color*=u_opacity;}`),fillExtrusionPattern:Qt(`uniform vec2 u_texsize;uniform float u_fade;uniform sampler2D u_image;varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;vec2 imagecoord=mod(v_pos_a,1.0);vec2 pos=mix(pattern_tl_a/u_texsize,pattern_br_a/u_texsize,imagecoord);vec4 color1=texture2D(u_image,pos);vec2 imagecoord_b=mod(v_pos_b,1.0);vec2 pos2=mix(pattern_tl_b/u_texsize,pattern_br_b/u_texsize,imagecoord_b);vec4 color2=texture2D(u_image,pos2);vec4 mixedColor=mix(color1,color2,u_fade);gl_FragColor=mixedColor*v_lighting; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`uniform mat4 u_matrix;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_height_factor;uniform vec3 u_scale;uniform float u_vertical_gradient;uniform lowp float u_opacity;uniform vec3 u_lightcolor;uniform lowp vec3 u_lightpos;uniform lowp float u_lightintensity;attribute vec2 a_pos;attribute vec4 a_normal_ed; #ifdef TERRAIN3D attribute vec2 a_centroid; #endif varying vec2 v_pos_a;varying vec2 v_pos_b;varying vec4 v_lighting; #pragma mapbox: define lowp float base #pragma mapbox: define lowp float height #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float base #pragma mapbox: initialize lowp float height #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec3 normal=a_normal_ed.xyz;float edgedistance=a_normal_ed.w;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to; #ifdef TERRAIN3D float height_terrain3d_offset=get_elevation(a_centroid);float base_terrain3d_offset=height_terrain3d_offset-(base > 0.0 ? 0.0 : 10.0); #else float height_terrain3d_offset=0.0;float base_terrain3d_offset=0.0; #endif base=max(0.0,base)+base_terrain3d_offset;height=max(0.0,height)+height_terrain3d_offset;float t=mod(normal.x,2.0);float z=t > 0.0 ? height : base;gl_Position=u_matrix*vec4(a_pos,z,1);vec2 pos=normal.x==1.0 && normal.y==0.0 && normal.z==16384.0 ? a_pos : vec2(edgedistance,z*u_height_factor);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,fromScale*display_size_a,tileRatio,pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,toScale*display_size_b,tileRatio,pos);v_lighting=vec4(0.0,0.0,0.0,1.0);float directional=clamp(dot(normal/16383.0,u_lightpos),0.0,1.0);directional=mix((1.0-u_lightintensity),max((0.5+u_lightintensity),1.0),directional);if (normal.y !=0.0) {directional*=((1.0-u_vertical_gradient)+(u_vertical_gradient*clamp((t+base)*pow(height/150.0,0.5),mix(0.7,0.98,1.0-u_lightintensity),1.0)));}v_lighting.rgb+=clamp(directional*u_lightcolor,mix(vec3(0.0),vec3(0.3),1.0-u_lightcolor),vec3(1.0));v_lighting*=u_opacity;}`),hillshadePrepare:Qt(`#ifdef GL_ES precision highp float; #endif uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_dimension;uniform float u_zoom;uniform vec4 u_unpack;float getElevation(vec2 coord,float bias) {vec4 data=texture2D(u_image,coord)*255.0;data.a=-1.0;return dot(data,u_unpack)/4.0;}void main() {vec2 epsilon=1.0/u_dimension;float a=getElevation(v_pos+vec2(-epsilon.x,-epsilon.y),0.0);float b=getElevation(v_pos+vec2(0,-epsilon.y),0.0);float c=getElevation(v_pos+vec2(epsilon.x,-epsilon.y),0.0);float d=getElevation(v_pos+vec2(-epsilon.x,0),0.0);float e=getElevation(v_pos,0.0);float f=getElevation(v_pos+vec2(epsilon.x,0),0.0);float g=getElevation(v_pos+vec2(-epsilon.x,epsilon.y),0.0);float h=getElevation(v_pos+vec2(0,epsilon.y),0.0);float i=getElevation(v_pos+vec2(epsilon.x,epsilon.y),0.0);float exaggerationFactor=u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;float exaggeration=u_zoom < 15.0 ? (u_zoom-15.0)*exaggerationFactor : 0.0;vec2 deriv=vec2((c+f+f+i)-(a+d+d+g),(g+h+h+i)-(a+b+b+c))/pow(2.0,exaggeration+(19.2562-u_zoom));gl_FragColor=clamp(vec4(deriv.x/2.0+0.5,deriv.y/2.0+0.5,1.0,1.0),0.0,1.0); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_dimension;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:Qt(`uniform sampler2D u_image;varying vec2 v_pos;uniform vec2 u_latrange;uniform vec2 u_light;uniform vec4 u_shadow;uniform vec4 u_highlight;uniform vec4 u_accent; #define PI 3.141592653589793 void main() {vec4 pixel=texture2D(u_image,v_pos);vec2 deriv=((pixel.rg*2.0)-1.0);float scaleFactor=cos(radians((u_latrange[0]-u_latrange[1])*(1.0-v_pos.y)+u_latrange[1]));float slope=atan(1.25*length(deriv)/scaleFactor);float aspect=deriv.x !=0.0 ? atan(deriv.y,-deriv.x) : PI/2.0*(deriv.y > 0.0 ? 1.0 :-1.0);float intensity=u_light.x;float azimuth=u_light.y+PI;float base=1.875-intensity*1.75;float maxValue=0.5*PI;float scaledSlope=intensity !=0.5 ? ((pow(base,slope)-1.0)/(pow(base,maxValue)-1.0))*maxValue : slope;float accent=cos(scaledSlope);vec4 accent_color=(1.0-accent)*u_accent*clamp(intensity*2.0,0.0,1.0);float shade=abs(mod((aspect+azimuth)/PI+0.5,2.0)-1.0);vec4 shade_color=mix(u_shadow,u_highlight,shade)*sin(scaledSlope)*clamp(intensity*2.0,0.0,1.0);gl_FragColor=accent_color*(1.0-shade_color.a)+shade_color; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos=a_texture_pos/8192.0;}"),line:Qt(`uniform lowp float u_device_pixel_ratio;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform vec2 u_units_to_pixels;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp float v_linesofar; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;v_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*2.0;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),lineGradient:Qt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;varying vec2 v_width2;varying vec2 v_normal;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);vec4 color=texture2D(u_image,v_uv);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 attribute vec2 a_pos_normal;attribute vec4 a_data;attribute float a_uv_x;attribute float a_split_index;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_units_to_pixels;uniform float u_image_height;varying vec2 v_normal;varying vec2 v_width2;varying float v_gamma_scale;varying highp vec2 v_uv; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;highp float texel_height=1.0/u_image_height;highp float half_texel_height=0.5*texel_height;v_uv=vec2(a_uv_x,a_split_index*texel_height-half_texel_height);vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_width2=vec2(outset,inset);}`),linePattern:Qt(`#ifdef GL_ES precision highp float; #endif uniform lowp float u_device_pixel_ratio;uniform vec2 u_texsize;uniform float u_fade;uniform mediump vec3 u_scale;uniform sampler2D u_image;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity vec2 pattern_tl_a=pattern_from.xy;vec2 pattern_br_a=pattern_from.zw;vec2 pattern_tl_b=pattern_to.xy;vec2 pattern_br_b=pattern_to.zw;float tileZoomRatio=u_scale.x;float fromScale=u_scale.y;float toScale=u_scale.z;vec2 display_size_a=(pattern_br_a-pattern_tl_a)/pixel_ratio_from;vec2 display_size_b=(pattern_br_b-pattern_tl_b)/pixel_ratio_to;vec2 pattern_size_a=vec2(display_size_a.x*fromScale/tileZoomRatio,display_size_a.y);vec2 pattern_size_b=vec2(display_size_b.x*toScale/tileZoomRatio,display_size_b.y);float aspect_a=display_size_a.y/v_width;float aspect_b=display_size_b.y/v_width;float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float x_a=mod(v_linesofar/pattern_size_a.x*aspect_a,1.0);float x_b=mod(v_linesofar/pattern_size_b.x*aspect_b,1.0);float y=0.5*v_normal.y+0.5;vec2 texel_size=1.0/u_texsize;vec2 pos_a=mix(pattern_tl_a*texel_size-texel_size,pattern_br_a*texel_size+texel_size,vec2(x_a,y));vec2 pos_b=mix(pattern_tl_b*texel_size-texel_size,pattern_br_b*texel_size+texel_size,vec2(x_b,y));vec4 color=mix(texture2D(u_image,pos_a),texture2D(u_image,pos_b),u_fade);gl_FragColor=color*alpha*opacity; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform vec2 u_units_to_pixels;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;varying vec2 v_normal;varying vec2 v_width2;varying float v_linesofar;varying float v_gamma_scale;varying float v_width; #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float gapwidth #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth #pragma mapbox: define lowp vec4 pattern_from #pragma mapbox: define lowp vec4 pattern_to #pragma mapbox: define lowp float pixel_ratio_from #pragma mapbox: define lowp float pixel_ratio_to void main() { #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth #pragma mapbox: initialize mediump vec4 pattern_from #pragma mapbox: initialize mediump vec4 pattern_to #pragma mapbox: initialize lowp float pixel_ratio_from #pragma mapbox: initialize lowp float pixel_ratio_to float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_linesofar=a_linesofar;v_width2=vec2(outset,inset);v_width=floorwidth;}`),lineSDF:Qt(`uniform lowp float u_device_pixel_ratio;uniform sampler2D u_image;uniform float u_sdfgamma;uniform float u_mix;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float dist=length(v_normal)*v_width2.s;float blur2=(blur+1.0/u_device_pixel_ratio)*v_gamma_scale;float alpha=clamp(min(dist-(v_width2.t-blur2),v_width2.s-dist)/blur2,0.0,1.0);float sdfdist_a=texture2D(u_image,v_tex_a).a;float sdfdist_b=texture2D(u_image,v_tex_b).a;float sdfdist=mix(sdfdist_a,sdfdist_b,u_mix);alpha*=smoothstep(0.5-u_sdfgamma/floorwidth,0.5+u_sdfgamma/floorwidth,sdfdist);gl_FragColor=color*(alpha*opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,` #define scale 0.015873016 #define LINE_DISTANCE_SCALE 2.0 attribute vec2 a_pos_normal;attribute vec4 a_data;uniform mat4 u_matrix;uniform mediump float u_ratio;uniform lowp float u_device_pixel_ratio;uniform vec2 u_patternscale_a;uniform float u_tex_y_a;uniform vec2 u_patternscale_b;uniform float u_tex_y_b;uniform vec2 u_units_to_pixels;varying vec2 v_normal;varying vec2 v_width2;varying vec2 v_tex_a;varying vec2 v_tex_b;varying float v_gamma_scale; #pragma mapbox: define highp vec4 color #pragma mapbox: define lowp float blur #pragma mapbox: define lowp float opacity #pragma mapbox: define mediump float gapwidth #pragma mapbox: define lowp float offset #pragma mapbox: define mediump float width #pragma mapbox: define lowp float floorwidth void main() { #pragma mapbox: initialize highp vec4 color #pragma mapbox: initialize lowp float blur #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize mediump float gapwidth #pragma mapbox: initialize lowp float offset #pragma mapbox: initialize mediump float width #pragma mapbox: initialize lowp float floorwidth float ANTIALIASING=1.0/u_device_pixel_ratio/2.0;vec2 a_extrude=a_data.xy-128.0;float a_direction=mod(a_data.z,4.0)-1.0;float a_linesofar=(floor(a_data.z/4.0)+a_data.w*64.0)*LINE_DISTANCE_SCALE;vec2 pos=floor(a_pos_normal*0.5);mediump vec2 normal=a_pos_normal-2.0*pos;normal.y=normal.y*2.0-1.0;v_normal=normal;gapwidth=gapwidth/2.0;float halfwidth=width/2.0;offset=-1.0*offset;float inset=gapwidth+(gapwidth > 0.0 ? ANTIALIASING : 0.0);float outset=gapwidth+halfwidth*(gapwidth > 0.0 ? 2.0 : 1.0)+(halfwidth==0.0 ? 0.0 : ANTIALIASING);mediump vec2 dist=outset*a_extrude*scale;mediump float u=0.5*a_direction;mediump float t=1.0-abs(u);mediump vec2 offset2=offset*a_extrude*scale*normal.y*mat2(t,-u,u,t);vec4 projected_extrude=u_matrix*vec4(dist/u_ratio,0.0,0.0);gl_Position=u_matrix*vec4(pos+offset2/u_ratio,0.0,1.0)+projected_extrude; #ifdef TERRAIN3D v_gamma_scale=1.0; #else float extrude_length_without_perspective=length(dist);float extrude_length_with_perspective=length(projected_extrude.xy/gl_Position.w*u_units_to_pixels);v_gamma_scale=extrude_length_without_perspective/extrude_length_with_perspective; #endif v_tex_a=vec2(a_linesofar*u_patternscale_a.x/floorwidth,normal.y*u_patternscale_a.y+u_tex_y_a);v_tex_b=vec2(a_linesofar*u_patternscale_b.x/floorwidth,normal.y*u_patternscale_b.y+u_tex_y_b);v_width2=vec2(outset,inset);}`),raster:Qt(`uniform float u_fade_t;uniform float u_opacity;uniform sampler2D u_image0;uniform sampler2D u_image1;varying vec2 v_pos0;varying vec2 v_pos1;uniform float u_brightness_low;uniform float u_brightness_high;uniform float u_saturation_factor;uniform float u_contrast_factor;uniform vec3 u_spin_weights;void main() {vec4 color0=texture2D(u_image0,v_pos0);vec4 color1=texture2D(u_image1,v_pos1);if (color0.a > 0.0) {color0.rgb=color0.rgb/color0.a;}if (color1.a > 0.0) {color1.rgb=color1.rgb/color1.a;}vec4 color=mix(color0,color1,u_fade_t);color.a*=u_opacity;vec3 rgb=color.rgb;rgb=vec3(dot(rgb,u_spin_weights.xyz),dot(rgb,u_spin_weights.zxy),dot(rgb,u_spin_weights.yzx));float average=(color.r+color.g+color.b)/3.0;rgb+=(average-rgb)*u_saturation_factor;rgb=(rgb-0.5)*u_contrast_factor+0.5;vec3 u_high_vec=vec3(u_brightness_low,u_brightness_low,u_brightness_low);vec3 u_low_vec=vec3(u_brightness_high,u_brightness_high,u_brightness_high);gl_FragColor=vec4(mix(u_high_vec,u_low_vec,rgb)*color.a,color.a); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,"uniform mat4 u_matrix;uniform vec2 u_tl_parent;uniform float u_scale_parent;uniform float u_buffer_scale;attribute vec2 a_pos;attribute vec2 a_texture_pos;varying vec2 v_pos0;varying vec2 v_pos1;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);v_pos0=(((a_texture_pos/8192.0)-0.5)/u_buffer_scale )+0.5;v_pos1=(v_pos0*u_scale_parent)+u_tl_parent;}"),symbolIcon:Qt(`uniform sampler2D u_texture;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity lowp float alpha=opacity*v_fade_opacity;gl_FragColor=texture2D(u_texture,v_tex)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform highp float u_camera_to_center_distance;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform float u_fade_change;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform vec2 u_texsize;varying vec2 v_tex;varying float v_fade_opacity; #pragma mapbox: define lowp float opacity void main() { #pragma mapbox: initialize lowp float opacity vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;vec2 a_minFontScale=a_pixeloffset.zw/256.0;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*max(a_minFontScale,fontScale)+a_pxoffset/16.0),z,1.0);v_tex=a_tex/u_texsize;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float visibility=calculate_visibility(projectedPoint);v_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));}`),symbolSDF:Qt(`#define SDF_PX 8.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;uniform bool u_is_text;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float EDGE_GAMMA=0.105/u_device_pixel_ratio;vec2 tex=v_data0.xy;float gamma_scale=v_data1.x;float size=v_data1.y;float fade_opacity=v_data1[2];float fontScale=u_is_text ? size/24.0 : size;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float inner_edge=(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);inner_edge=inner_edge+gamma*gamma_scale;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(inner_edge-gamma_scaled,inner_edge+gamma_scaled,dist);if (u_is_halo) {lowp float halo_edge=(6.0-halo_width/fontScale)/SDF_PX;alpha=min(smoothstep(halo_edge-gamma_scaled,halo_edge+gamma_scaled,dist),1.0-alpha);}gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec4 a_pixeloffset;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;varying vec2 v_data0;varying vec3 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);vec2 a_pxoffset=a_pixeloffset.xy;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=u_is_text ? size/24.0 : size;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale+a_pxoffset),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0=a_tex/u_texsize;v_data1=vec3(gamma_scale,size,interpolated_fade_opacity);}`),symbolTextAndIcon:Qt(`#define SDF_PX 8.0 #define SDF 1.0 #define ICON 0.0 uniform bool u_is_halo;uniform sampler2D u_texture;uniform sampler2D u_texture_icon;uniform highp float u_gamma_scale;uniform lowp float u_device_pixel_ratio;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur float fade_opacity=v_data1[2];if (v_data1.w==ICON) {vec2 tex_icon=v_data0.zw;lowp float alpha=opacity*fade_opacity;gl_FragColor=texture2D(u_texture_icon,tex_icon)*alpha; #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif return;}vec2 tex=v_data0.xy;float EDGE_GAMMA=0.105/u_device_pixel_ratio;float gamma_scale=v_data1.x;float size=v_data1.y;float fontScale=size/24.0;lowp vec4 color=fill_color;highp float gamma=EDGE_GAMMA/(fontScale*u_gamma_scale);lowp float buff=(256.0-64.0)/256.0;if (u_is_halo) {color=halo_color;gamma=(halo_blur*1.19/SDF_PX+EDGE_GAMMA)/(fontScale*u_gamma_scale);buff=(6.0-halo_width/fontScale)/SDF_PX;}lowp float dist=texture2D(u_texture,tex).a;highp float gamma_scaled=gamma*gamma_scale;highp float alpha=smoothstep(buff-gamma_scaled,buff+gamma_scaled,dist);gl_FragColor=color*(alpha*opacity*fade_opacity); #ifdef OVERDRAW_INSPECTOR gl_FragColor=vec4(1.0); #endif }`,`const float PI=3.141592653589793;attribute vec4 a_pos_offset;attribute vec4 a_data;attribute vec3 a_projected_pos;attribute float a_fade_opacity;uniform bool u_is_size_zoom_constant;uniform bool u_is_size_feature_constant;uniform highp float u_size_t;uniform highp float u_size;uniform mat4 u_matrix;uniform mat4 u_label_plane_matrix;uniform mat4 u_coord_matrix;uniform bool u_is_text;uniform bool u_pitch_with_map;uniform highp float u_pitch;uniform bool u_rotate_symbol;uniform highp float u_aspect_ratio;uniform highp float u_camera_to_center_distance;uniform float u_fade_change;uniform vec2 u_texsize;uniform vec2 u_texsize_icon;varying vec4 v_data0;varying vec4 v_data1; #pragma mapbox: define highp vec4 fill_color #pragma mapbox: define highp vec4 halo_color #pragma mapbox: define lowp float opacity #pragma mapbox: define lowp float halo_width #pragma mapbox: define lowp float halo_blur void main() { #pragma mapbox: initialize highp vec4 fill_color #pragma mapbox: initialize highp vec4 halo_color #pragma mapbox: initialize lowp float opacity #pragma mapbox: initialize lowp float halo_width #pragma mapbox: initialize lowp float halo_blur vec2 a_pos=a_pos_offset.xy;vec2 a_offset=a_pos_offset.zw;vec2 a_tex=a_data.xy;vec2 a_size=a_data.zw;float a_size_min=floor(a_size[0]*0.5);float is_sdf=a_size[0]-2.0*a_size_min;float ele=get_elevation(a_pos);highp float segment_angle=-a_projected_pos[2];float size;if (!u_is_size_zoom_constant && !u_is_size_feature_constant) {size=mix(a_size_min,a_size[1],u_size_t)/128.0;} else if (u_is_size_zoom_constant && !u_is_size_feature_constant) {size=a_size_min/128.0;} else {size=u_size;}vec4 projectedPoint=u_matrix*vec4(a_pos,ele,1);highp float camera_to_anchor_distance=projectedPoint.w;highp float distance_ratio=u_pitch_with_map ? camera_to_anchor_distance/u_camera_to_center_distance : u_camera_to_center_distance/camera_to_anchor_distance;highp float perspective_ratio=clamp(0.5+0.5*distance_ratio,0.0,4.0);size*=perspective_ratio;float fontScale=size/24.0;highp float symbol_rotation=0.0;if (u_rotate_symbol) {vec4 offsetProjectedPoint=u_matrix*vec4(a_pos+vec2(1,0),ele,1);vec2 a=projectedPoint.xy/projectedPoint.w;vec2 b=offsetProjectedPoint.xy/offsetProjectedPoint.w;symbol_rotation=atan((b.y-a.y)/u_aspect_ratio,b.x-a.x);}highp float angle_sin=sin(segment_angle+symbol_rotation);highp float angle_cos=cos(segment_angle+symbol_rotation);mat2 rotation_matrix=mat2(angle_cos,-1.0*angle_sin,angle_sin,angle_cos);vec4 projected_pos=u_label_plane_matrix*vec4(a_projected_pos.xy,ele,1.0);float z=float(u_pitch_with_map)*projected_pos.z/projected_pos.w;gl_Position=u_coord_matrix*vec4(projected_pos.xy/projected_pos.w+rotation_matrix*(a_offset/32.0*fontScale),z,1.0);float gamma_scale=gl_Position.w;vec2 fade_opacity=unpack_opacity(a_fade_opacity);float visibility=calculate_visibility(projectedPoint);float fade_change=fade_opacity[1] > 0.5 ? u_fade_change :-u_fade_change;float interpolated_fade_opacity=max(0.0,min(visibility,fade_opacity[0]+fade_change));v_data0.xy=a_tex/u_texsize;v_data0.zw=a_tex/u_texsize_icon;v_data1=vec4(gamma_scale,size,interpolated_fade_opacity,is_sdf);}`),terrain:Qt("uniform sampler2D u_texture;varying vec2 v_texture_pos;void main() {gl_FragColor=texture2D(u_texture,v_texture_pos);}",fn),terrainDepth:Qt("varying float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {gl_FragColor=pack(v_depth);}",fn),terrainCoords:Qt("precision mediump float;uniform sampler2D u_texture;uniform float u_terrain_coords_id;varying vec2 v_texture_pos;void main() {vec4 rgba=texture2D(u_texture,v_texture_pos);gl_FragColor=vec4(rgba.r,rgba.g,rgba.b,u_terrain_coords_id);}",fn)};function Qt(c,t){const n=/#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,s=t.match(/attribute ([\w]+) ([\w]+)/g),a=c.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),u=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),g=u?u.concat(a):a,y={};return{fragmentSource:c=c.replace(n,(v,S,C,A,F)=>(y[F]=!0,S==="define"?` #ifndef HAS_UNIFORM_u_${F} varying ${C} ${A} ${F}; #else uniform ${C} ${A} u_${F}; #endif `:` #ifdef HAS_UNIFORM_u_${F} ${C} ${A} ${F} = u_${F}; #endif `)),vertexSource:t=t.replace(n,(v,S,C,A,F)=>{const Z=A==="float"?"vec2":"vec4",$=F.match(/color/)?"color":Z;return y[F]?S==="define"?` #ifndef HAS_UNIFORM_u_${F} uniform lowp float u_${F}_t; attribute ${C} ${Z} a_${F}; varying ${C} ${A} ${F}; #else uniform ${C} ${A} u_${F}; #endif `:$==="vec4"?` #ifndef HAS_UNIFORM_u_${F} ${F} = a_${F}; #else ${C} ${A} ${F} = u_${F}; #endif `:` #ifndef HAS_UNIFORM_u_${F} ${F} = unpack_mix_${$}(a_${F}, u_${F}_t); #else ${C} ${A} ${F} = u_${F}; #endif `:S==="define"?` #ifndef HAS_UNIFORM_u_${F} uniform lowp float u_${F}_t; attribute ${C} ${Z} a_${F}; #else uniform ${C} ${A} u_${F}; #endif `:$==="vec4"?` #ifndef HAS_UNIFORM_u_${F} ${C} ${A} ${F} = a_${F}; #else ${C} ${A} ${F} = u_${F}; #endif `:` #ifndef HAS_UNIFORM_u_${F} ${C} ${A} ${F} = unpack_mix_${$}(a_${F}, u_${F}_t); #else ${C} ${A} ${F} = u_${F}; #endif `}),staticAttributes:s,staticUniforms:g}}class ds{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,n,s,a,u,g,y,v,S){this.context=t;let C=this.boundPaintVertexBuffers.length!==a.length;for(let A=0;!C&&A({u_depth:new d.aG(ye,xe.u_depth),u_terrain:new d.aG(ye,xe.u_terrain),u_terrain_dim:new d.aH(ye,xe.u_terrain_dim),u_terrain_matrix:new d.aI(ye,xe.u_terrain_matrix),u_terrain_unpack:new d.aJ(ye,xe.u_terrain_unpack),u_terrain_exaggeration:new d.aH(ye,xe.u_terrain_exaggeration)}))(t,ge),this.binderUniforms=s?s.getUniforms(t,ge):[]}draw(t,n,s,a,u,g,y,v,S,C,A,F,Z,$,H,N,ee,me){const X=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(s),t.setStencilMode(a),t.setColorMode(u),t.setCullFace(g),v){t.activeTexture.set(X.TEXTURE2),X.bindTexture(X.TEXTURE_2D,v.depthTexture),t.activeTexture.set(X.TEXTURE3),X.bindTexture(X.TEXTURE_2D,v.texture);for(const ge in this.terrainUniforms)this.terrainUniforms[ge].set(v[ge])}for(const ge in this.fixedUniforms)this.fixedUniforms[ge].set(y[ge]);H&&H.setUniforms(t,this.binderUniforms,Z,{zoom:$});let ae=0;switch(n){case X.LINES:ae=2;break;case X.TRIANGLES:ae=3;break;case X.LINE_STRIP:ae=1}for(const ge of F.get()){const ye=ge.vaos||(ge.vaos={});(ye[S]||(ye[S]=new ds)).bind(t,this,C,H?H.getPaintVertexBuffers():[],A,ge.vertexOffset,N,ee,me),X.drawElements(n,ge.primitiveLength*ae,X.UNSIGNED_SHORT,ge.primitiveOffset*ae*2)}}}function b(c,t,n){const s=1/_t(n,1,t.transform.tileZoom),a=Math.pow(2,n.tileID.overscaledZ),u=n.tileSize*Math.pow(2,t.transform.tileZoom)/a,g=u*(n.tileID.canonical.x+n.tileID.wrap*a),y=u*n.tileID.canonical.y;return{u_image:0,u_texsize:n.imageAtlasTexture.size,u_scale:[s,c.fromScale,c.toScale],u_fade:c.t,u_pixel_coord_upper:[g>>16,y>>16],u_pixel_coord_lower:[65535&g,65535&y]}}const D=(c,t,n,s)=>{const a=t.style.light,u=a.properties.get("position"),g=[u.x,u.y,u.z],y=function(){var S=new d.A(9);return d.A!=Float32Array&&(S[1]=0,S[2]=0,S[3]=0,S[5]=0,S[6]=0,S[7]=0),S[0]=1,S[4]=1,S[8]=1,S}();a.properties.get("anchor")==="viewport"&&function(S,C){var A=Math.sin(C),F=Math.cos(C);S[0]=F,S[1]=A,S[2]=0,S[3]=-A,S[4]=F,S[5]=0,S[6]=0,S[7]=0,S[8]=1}(y,-t.transform.angle),function(S,C,A){var F=C[0],Z=C[1],$=C[2];S[0]=F*A[0]+Z*A[3]+$*A[6],S[1]=F*A[1]+Z*A[4]+$*A[7],S[2]=F*A[2]+Z*A[5]+$*A[8]}(g,g,y);const v=a.properties.get("color");return{u_matrix:c,u_lightpos:g,u_lightintensity:a.properties.get("intensity"),u_lightcolor:[v.r,v.g,v.b],u_vertical_gradient:+n,u_opacity:s}},W=(c,t,n,s,a,u,g)=>d.e(D(c,t,n,s),b(u,t,g),{u_height_factor:-Math.pow(2,a.overscaledZ)/g.tileSize/8}),te=c=>({u_matrix:c}),ie=(c,t,n,s)=>d.e(te(c),b(n,t,s)),ue=(c,t)=>({u_matrix:c,u_world:t}),ke=(c,t,n,s,a)=>d.e(ie(c,t,n,s),{u_world:a}),Be=(c,t,n,s)=>{const a=c.transform;let u,g;if(s.paint.get("circle-pitch-alignment")==="map"){const y=_t(n,1,a.zoom);u=!0,g=[y,y]}else u=!1,g=a.pixelsToGLUnits;return{u_camera_to_center_distance:a.cameraToCenterDistance,u_scale_with_map:+(s.paint.get("circle-pitch-scale")==="map"),u_matrix:c.translatePosMatrix(t.posMatrix,n,s.paint.get("circle-translate"),s.paint.get("circle-translate-anchor")),u_pitch_with_map:+u,u_device_pixel_ratio:c.pixelRatio,u_extrude_scale:g}},Xe=(c,t,n)=>{const s=_t(n,1,t.zoom),a=Math.pow(2,t.zoom-n.tileID.overscaledZ),u=n.tileID.overscaleFactor();return{u_matrix:c,u_camera_to_center_distance:t.cameraToCenterDistance,u_pixels_to_tile_units:s,u_extrude_scale:[t.pixelsToGLUnits[0]/(s*a),t.pixelsToGLUnits[1]/(s*a)],u_overscale_factor:u}},Je=(c,t,n=1)=>({u_matrix:c,u_color:t,u_overlay:0,u_overlay_scale:n}),Ve=c=>({u_matrix:c}),wt=(c,t,n,s)=>({u_matrix:c,u_extrude_scale:_t(t,1,n),u_intensity:s});function gi(c,t){const n=Math.pow(2,t.canonical.z),s=t.canonical.y;return[new d.Y(0,s/n).toLngLat().lat,new d.Y(0,(s+1)/n).toLngLat().lat]}const It=(c,t,n,s)=>{const a=c.transform;return{u_matrix:ki(c,t,n,s),u_ratio:1/_t(t,1,a.zoom),u_device_pixel_ratio:c.pixelRatio,u_units_to_pixels:[1/a.pixelsToGLUnits[0],1/a.pixelsToGLUnits[1]]}},Vi=(c,t,n,s,a)=>d.e(It(c,t,n,a),{u_image:0,u_image_height:s}),Ee=(c,t,n,s,a)=>{const u=c.transform,g=zt(t,u);return{u_matrix:ki(c,t,n,a),u_texsize:t.imageAtlasTexture.size,u_ratio:1/_t(t,1,u.zoom),u_device_pixel_ratio:c.pixelRatio,u_image:0,u_scale:[g,s.fromScale,s.toScale],u_fade:s.t,u_units_to_pixels:[1/u.pixelsToGLUnits[0],1/u.pixelsToGLUnits[1]]}},rt=(c,t,n,s,a,u)=>{const g=c.lineAtlas,y=zt(t,c.transform),v=n.layout.get("line-cap")==="round",S=g.getDash(s.from,v),C=g.getDash(s.to,v),A=S.width*a.fromScale,F=C.width*a.toScale;return d.e(It(c,t,n,u),{u_patternscale_a:[y/A,-S.height/2],u_patternscale_b:[y/F,-C.height/2],u_sdfgamma:g.width/(256*Math.min(A,F)*c.pixelRatio)/2,u_image:0,u_tex_y_a:S.y,u_tex_y_b:C.y,u_mix:a.t})};function zt(c,t){return 1/_t(c,1,t.tileZoom)}function ki(c,t,n,s){return c.translatePosMatrix(s?s.posMatrix:t.tileID.posMatrix,t,n.paint.get("line-translate"),n.paint.get("line-translate-anchor"))}const Ti=(c,t,n,s,a)=>{return{u_matrix:c,u_tl_parent:t,u_scale_parent:n,u_buffer_scale:1,u_fade_t:s.mix,u_opacity:s.opacity*a.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:a.paint.get("raster-brightness-min"),u_brightness_high:a.paint.get("raster-brightness-max"),u_saturation_factor:(g=a.paint.get("raster-saturation"),g>0?1-1/(1.001-g):-g),u_contrast_factor:(u=a.paint.get("raster-contrast"),u>0?1/(1-u):1+u),u_spin_weights:yo(a.paint.get("raster-hue-rotate"))};var u,g};function yo(c){c*=Math.PI/180;const t=Math.sin(c),n=Math.cos(c);return[(2*n+1)/3,(-Math.sqrt(3)*t-n+1)/3,(Math.sqrt(3)*t-n+1)/3]}const Ko=(c,t,n,s,a,u,g,y,v,S)=>{const C=a.transform;return{u_is_size_zoom_constant:+(c==="constant"||c==="source"),u_is_size_feature_constant:+(c==="constant"||c==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:C.cameraToCenterDistance,u_pitch:C.pitch/360*2*Math.PI,u_rotate_symbol:+n,u_aspect_ratio:C.width/C.height,u_fade_change:a.options.fadeDuration?a.symbolFadeChange:1,u_matrix:u,u_label_plane_matrix:g,u_coord_matrix:y,u_is_text:+v,u_pitch_with_map:+s,u_texsize:S,u_texture:0}},ei=(c,t,n,s,a,u,g,y,v,S,C)=>{const A=a.transform;return d.e(Ko(c,t,n,s,a,u,g,y,v,S),{u_gamma_scale:s?Math.cos(A._pitch)*A.cameraToCenterDistance:1,u_device_pixel_ratio:a.pixelRatio,u_is_halo:+C})},Lo=(c,t,n,s,a,u,g,y,v,S)=>d.e(ei(c,t,n,s,a,u,g,y,!0,v,!0),{u_texsize_icon:S,u_texture_icon:1}),Ga=(c,t,n)=>({u_matrix:c,u_opacity:t,u_color:n}),Gn=(c,t,n,s,a,u)=>d.e(function(g,y,v,S){const C=v.imageManager.getPattern(g.from.toString()),A=v.imageManager.getPattern(g.to.toString()),{width:F,height:Z}=v.imageManager.getPixelSize(),$=Math.pow(2,S.tileID.overscaledZ),H=S.tileSize*Math.pow(2,v.transform.tileZoom)/$,N=H*(S.tileID.canonical.x+S.tileID.wrap*$),ee=H*S.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:C.tl,u_pattern_br_a:C.br,u_pattern_tl_b:A.tl,u_pattern_br_b:A.br,u_texsize:[F,Z],u_mix:y.t,u_pattern_size_a:C.displaySize,u_pattern_size_b:A.displaySize,u_scale_a:y.fromScale,u_scale_b:y.toScale,u_tile_units_to_pixels:1/_t(S,1,v.transform.tileZoom),u_pixel_coord_upper:[N>>16,ee>>16],u_pixel_coord_lower:[65535&N,65535&ee]}}(s,u,n,a),{u_matrix:c,u_opacity:t}),Us={fillExtrusion:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_lightpos:new d.aK(c,t.u_lightpos),u_lightintensity:new d.aH(c,t.u_lightintensity),u_lightcolor:new d.aK(c,t.u_lightcolor),u_vertical_gradient:new d.aH(c,t.u_vertical_gradient),u_opacity:new d.aH(c,t.u_opacity)}),fillExtrusionPattern:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_lightpos:new d.aK(c,t.u_lightpos),u_lightintensity:new d.aH(c,t.u_lightintensity),u_lightcolor:new d.aK(c,t.u_lightcolor),u_vertical_gradient:new d.aH(c,t.u_vertical_gradient),u_height_factor:new d.aH(c,t.u_height_factor),u_image:new d.aG(c,t.u_image),u_texsize:new d.aL(c,t.u_texsize),u_pixel_coord_upper:new d.aL(c,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.aL(c,t.u_pixel_coord_lower),u_scale:new d.aK(c,t.u_scale),u_fade:new d.aH(c,t.u_fade),u_opacity:new d.aH(c,t.u_opacity)}),fill:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix)}),fillPattern:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_image:new d.aG(c,t.u_image),u_texsize:new d.aL(c,t.u_texsize),u_pixel_coord_upper:new d.aL(c,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.aL(c,t.u_pixel_coord_lower),u_scale:new d.aK(c,t.u_scale),u_fade:new d.aH(c,t.u_fade)}),fillOutline:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_world:new d.aL(c,t.u_world)}),fillOutlinePattern:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_world:new d.aL(c,t.u_world),u_image:new d.aG(c,t.u_image),u_texsize:new d.aL(c,t.u_texsize),u_pixel_coord_upper:new d.aL(c,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.aL(c,t.u_pixel_coord_lower),u_scale:new d.aK(c,t.u_scale),u_fade:new d.aH(c,t.u_fade)}),circle:(c,t)=>({u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_scale_with_map:new d.aG(c,t.u_scale_with_map),u_pitch_with_map:new d.aG(c,t.u_pitch_with_map),u_extrude_scale:new d.aL(c,t.u_extrude_scale),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_matrix:new d.aI(c,t.u_matrix)}),collisionBox:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_pixels_to_tile_units:new d.aH(c,t.u_pixels_to_tile_units),u_extrude_scale:new d.aL(c,t.u_extrude_scale),u_overscale_factor:new d.aH(c,t.u_overscale_factor)}),collisionCircle:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_inv_matrix:new d.aI(c,t.u_inv_matrix),u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_viewport_size:new d.aL(c,t.u_viewport_size)}),debug:(c,t)=>({u_color:new d.aM(c,t.u_color),u_matrix:new d.aI(c,t.u_matrix),u_overlay:new d.aG(c,t.u_overlay),u_overlay_scale:new d.aH(c,t.u_overlay_scale)}),clippingMask:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix)}),heatmap:(c,t)=>({u_extrude_scale:new d.aH(c,t.u_extrude_scale),u_intensity:new d.aH(c,t.u_intensity),u_matrix:new d.aI(c,t.u_matrix)}),heatmapTexture:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_world:new d.aL(c,t.u_world),u_image:new d.aG(c,t.u_image),u_color_ramp:new d.aG(c,t.u_color_ramp),u_opacity:new d.aH(c,t.u_opacity)}),hillshade:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_image:new d.aG(c,t.u_image),u_latrange:new d.aL(c,t.u_latrange),u_light:new d.aL(c,t.u_light),u_shadow:new d.aM(c,t.u_shadow),u_highlight:new d.aM(c,t.u_highlight),u_accent:new d.aM(c,t.u_accent)}),hillshadePrepare:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_image:new d.aG(c,t.u_image),u_dimension:new d.aL(c,t.u_dimension),u_zoom:new d.aH(c,t.u_zoom),u_unpack:new d.aJ(c,t.u_unpack)}),line:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_ratio:new d.aH(c,t.u_ratio),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_units_to_pixels:new d.aL(c,t.u_units_to_pixels)}),lineGradient:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_ratio:new d.aH(c,t.u_ratio),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_units_to_pixels:new d.aL(c,t.u_units_to_pixels),u_image:new d.aG(c,t.u_image),u_image_height:new d.aH(c,t.u_image_height)}),linePattern:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_texsize:new d.aL(c,t.u_texsize),u_ratio:new d.aH(c,t.u_ratio),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_image:new d.aG(c,t.u_image),u_units_to_pixels:new d.aL(c,t.u_units_to_pixels),u_scale:new d.aK(c,t.u_scale),u_fade:new d.aH(c,t.u_fade)}),lineSDF:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_ratio:new d.aH(c,t.u_ratio),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_units_to_pixels:new d.aL(c,t.u_units_to_pixels),u_patternscale_a:new d.aL(c,t.u_patternscale_a),u_patternscale_b:new d.aL(c,t.u_patternscale_b),u_sdfgamma:new d.aH(c,t.u_sdfgamma),u_image:new d.aG(c,t.u_image),u_tex_y_a:new d.aH(c,t.u_tex_y_a),u_tex_y_b:new d.aH(c,t.u_tex_y_b),u_mix:new d.aH(c,t.u_mix)}),raster:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_tl_parent:new d.aL(c,t.u_tl_parent),u_scale_parent:new d.aH(c,t.u_scale_parent),u_buffer_scale:new d.aH(c,t.u_buffer_scale),u_fade_t:new d.aH(c,t.u_fade_t),u_opacity:new d.aH(c,t.u_opacity),u_image0:new d.aG(c,t.u_image0),u_image1:new d.aG(c,t.u_image1),u_brightness_low:new d.aH(c,t.u_brightness_low),u_brightness_high:new d.aH(c,t.u_brightness_high),u_saturation_factor:new d.aH(c,t.u_saturation_factor),u_contrast_factor:new d.aH(c,t.u_contrast_factor),u_spin_weights:new d.aK(c,t.u_spin_weights)}),symbolIcon:(c,t)=>({u_is_size_zoom_constant:new d.aG(c,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aG(c,t.u_is_size_feature_constant),u_size_t:new d.aH(c,t.u_size_t),u_size:new d.aH(c,t.u_size),u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_pitch:new d.aH(c,t.u_pitch),u_rotate_symbol:new d.aG(c,t.u_rotate_symbol),u_aspect_ratio:new d.aH(c,t.u_aspect_ratio),u_fade_change:new d.aH(c,t.u_fade_change),u_matrix:new d.aI(c,t.u_matrix),u_label_plane_matrix:new d.aI(c,t.u_label_plane_matrix),u_coord_matrix:new d.aI(c,t.u_coord_matrix),u_is_text:new d.aG(c,t.u_is_text),u_pitch_with_map:new d.aG(c,t.u_pitch_with_map),u_texsize:new d.aL(c,t.u_texsize),u_texture:new d.aG(c,t.u_texture)}),symbolSDF:(c,t)=>({u_is_size_zoom_constant:new d.aG(c,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aG(c,t.u_is_size_feature_constant),u_size_t:new d.aH(c,t.u_size_t),u_size:new d.aH(c,t.u_size),u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_pitch:new d.aH(c,t.u_pitch),u_rotate_symbol:new d.aG(c,t.u_rotate_symbol),u_aspect_ratio:new d.aH(c,t.u_aspect_ratio),u_fade_change:new d.aH(c,t.u_fade_change),u_matrix:new d.aI(c,t.u_matrix),u_label_plane_matrix:new d.aI(c,t.u_label_plane_matrix),u_coord_matrix:new d.aI(c,t.u_coord_matrix),u_is_text:new d.aG(c,t.u_is_text),u_pitch_with_map:new d.aG(c,t.u_pitch_with_map),u_texsize:new d.aL(c,t.u_texsize),u_texture:new d.aG(c,t.u_texture),u_gamma_scale:new d.aH(c,t.u_gamma_scale),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_is_halo:new d.aG(c,t.u_is_halo)}),symbolTextAndIcon:(c,t)=>({u_is_size_zoom_constant:new d.aG(c,t.u_is_size_zoom_constant),u_is_size_feature_constant:new d.aG(c,t.u_is_size_feature_constant),u_size_t:new d.aH(c,t.u_size_t),u_size:new d.aH(c,t.u_size),u_camera_to_center_distance:new d.aH(c,t.u_camera_to_center_distance),u_pitch:new d.aH(c,t.u_pitch),u_rotate_symbol:new d.aG(c,t.u_rotate_symbol),u_aspect_ratio:new d.aH(c,t.u_aspect_ratio),u_fade_change:new d.aH(c,t.u_fade_change),u_matrix:new d.aI(c,t.u_matrix),u_label_plane_matrix:new d.aI(c,t.u_label_plane_matrix),u_coord_matrix:new d.aI(c,t.u_coord_matrix),u_is_text:new d.aG(c,t.u_is_text),u_pitch_with_map:new d.aG(c,t.u_pitch_with_map),u_texsize:new d.aL(c,t.u_texsize),u_texsize_icon:new d.aL(c,t.u_texsize_icon),u_texture:new d.aG(c,t.u_texture),u_texture_icon:new d.aG(c,t.u_texture_icon),u_gamma_scale:new d.aH(c,t.u_gamma_scale),u_device_pixel_ratio:new d.aH(c,t.u_device_pixel_ratio),u_is_halo:new d.aG(c,t.u_is_halo)}),background:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_opacity:new d.aH(c,t.u_opacity),u_color:new d.aM(c,t.u_color)}),backgroundPattern:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_opacity:new d.aH(c,t.u_opacity),u_image:new d.aG(c,t.u_image),u_pattern_tl_a:new d.aL(c,t.u_pattern_tl_a),u_pattern_br_a:new d.aL(c,t.u_pattern_br_a),u_pattern_tl_b:new d.aL(c,t.u_pattern_tl_b),u_pattern_br_b:new d.aL(c,t.u_pattern_br_b),u_texsize:new d.aL(c,t.u_texsize),u_mix:new d.aH(c,t.u_mix),u_pattern_size_a:new d.aL(c,t.u_pattern_size_a),u_pattern_size_b:new d.aL(c,t.u_pattern_size_b),u_scale_a:new d.aH(c,t.u_scale_a),u_scale_b:new d.aH(c,t.u_scale_b),u_pixel_coord_upper:new d.aL(c,t.u_pixel_coord_upper),u_pixel_coord_lower:new d.aL(c,t.u_pixel_coord_lower),u_tile_units_to_pixels:new d.aH(c,t.u_tile_units_to_pixels)}),terrain:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_texture:new d.aG(c,t.u_texture),u_ele_delta:new d.aH(c,t.u_ele_delta)}),terrainDepth:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_ele_delta:new d.aH(c,t.u_ele_delta)}),terrainCoords:(c,t)=>({u_matrix:new d.aI(c,t.u_matrix),u_texture:new d.aG(c,t.u_texture),u_terrain_coords_id:new d.aH(c,t.u_terrain_coords_id),u_ele_delta:new d.aH(c,t.u_ele_delta)})};class ga{constructor(t,n,s){this.context=t;const a=t.gl;this.buffer=a.createBuffer(),this.dynamicDraw=!!s,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),a.bufferData(a.ELEMENT_ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?a.DYNAMIC_DRAW:a.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){const n=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),n.bufferSubData(n.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const oo={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class zo{constructor(t,n,s,a){this.length=n.length,this.attributes=s,this.itemSize=n.bytesPerElement,this.dynamicDraw=a,this.context=t;const u=t.gl;this.buffer=u.createBuffer(),t.bindVertexBuffer.set(this.buffer),u.bufferData(u.ARRAY_BUFFER,n.arrayBuffer,this.dynamicDraw?u.DYNAMIC_DRAW:u.STATIC_DRAW),this.dynamicDraw||delete n.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(t){if(t.length!==this.length)throw new Error(`Length of new data is ${t.length}, which doesn't match current length of ${this.length}`);const n=this.context.gl;this.bind(),n.bufferSubData(n.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,n){for(let s=0;s0){const Fe=d.F(),Ne=xe;d.aP(Fe,ye.placementInvProjMatrix,c.transform.glCoordMatrix),d.aP(Fe,Fe,ye.placementViewportMatrix),C.push({circleArray:Ae,circleOffset:F,transform:Ne,invTransform:Fe,coord:ae}),A+=Ae.length/4,F=A}Pe&&S.draw(y,v.LINES,At.disabled,Wt.disabled,c.colorModeForRenderPass(),ri.disabled,Xe(xe,c.transform,ge),c.style.map.terrain&&c.style.map.terrain.getTerrainData(ae),n.id,Pe.layoutVertexBuffer,Pe.indexBuffer,Pe.segments,null,c.transform.zoom,null,null,Pe.collisionVertexBuffer)}if(!g||!C.length)return;const Z=c.useProgram("collisionCircle"),$=new d.aQ;$.resize(4*A),$._trim();let H=0;for(const X of C)for(let ae=0;ae=0&&($[N.associatedIconIndex]={shiftedAnchor:Et,angle:$e})}else we(N.numGlyphs,F)}if(S){Z.clear();const H=c.icon.placedSymbolArray;for(let N=0;Nc.style.map.terrain.getElevation(Pe,Fn,rr):null,Ri=n.layout.get("text-rotation-alignment")==="map";z(Fe,Pe.posMatrix,c,a,vn,uo,N,S,Ri,ir)}const Uo=c.translatePosMatrix(Pe.posMatrix,Ae,u,g),ho=ee||a&&ye||ca?Ts:vn,tr=c.translatePosMatrix(uo,Ae,u,g,!0),Di=$e&&n.paint.get(a?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Ci;Ci=$e?Fe.iconsInText?Lo(pt.kind,vt,me,N,c,Uo,ho,tr,Dt,dr):ei(pt.kind,vt,me,N,c,Uo,ho,tr,a,Dt,!0):Ko(pt.kind,vt,me,N,c,Uo,ho,tr,a,Dt);const Rn={program:jt,buffers:Ne,uniformValues:Ci,atlasTexture:ji,atlasTextureIcon:zi,atlasInterpolation:ni,atlasInterpolationIcon:_n,isSDF:$e,hasHalo:Di};if(X&&Fe.canOverlap){ae=!0;const ir=Ne.segments.get();for(const Ri of ir)xe.push({segments:new d.$([Ri]),sortKey:Ri.sortKey,state:Rn,terrainData:Pt})}else xe.push({segments:Ne.segments,sortKey:0,state:Rn,terrainData:Pt})}ae&&xe.sort((Pe,Ae)=>Pe.sortKey-Ae.sortKey);for(const Pe of xe){const Ae=Pe.state;if(F.activeTexture.set(Z.TEXTURE0),Ae.atlasTexture.bind(Ae.atlasInterpolation,Z.CLAMP_TO_EDGE),Ae.atlasTextureIcon&&(F.activeTexture.set(Z.TEXTURE1),Ae.atlasTextureIcon&&Ae.atlasTextureIcon.bind(Ae.atlasInterpolationIcon,Z.CLAMP_TO_EDGE)),Ae.isSDF){const Fe=Ae.uniformValues;Ae.hasHalo&&(Fe.u_is_halo=1,Ws(Ae.buffers,Pe.segments,n,c,Ae.program,ge,C,A,Fe,Pe.terrainData)),Fe.u_is_halo=0}Ws(Ae.buffers,Pe.segments,n,c,Ae.program,ge,C,A,Ae.uniformValues,Pe.terrainData)}}function Ws(c,t,n,s,a,u,g,y,v,S){const C=s.context;a.draw(C,C.gl.TRIANGLES,u,g,y,ri.disabled,v,S,n.id,c.layoutVertexBuffer,c.indexBuffer,t,n.paint,s.transform.zoom,c.programConfigurations.get(n.id),c.dynamicLayoutVertexBuffer,c.opacityVertexBuffer)}function bo(c,t,n,s,a){if(!n||!s||!s.imageAtlas)return;const u=s.imageAtlas.patternPositions;let g=u[n.to.toString()],y=u[n.from.toString()];if(!g&&y&&(g=y),!y&&g&&(y=g),!g||!y){const v=a.getPaintProperty(t);g=u[v],y=u[v]}g&&y&&c.setConstantPatternPositions(g,y)}function wo(c,t,n,s,a,u,g){const y=c.context.gl,v="fill-pattern",S=n.paint.get(v),C=S&&S.constantOr(1),A=n.getCrossfadeParameters();let F,Z,$,H,N;g?(Z=C&&!n.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",F=y.LINES):(Z=C?"fillPattern":"fill",F=y.TRIANGLES);const ee=S.constantOr(null);for(const me of s){const X=t.getTile(me);if(C&&!X.patternsLoaded())continue;const ae=X.getBucket(n);if(!ae)continue;const ge=ae.programConfigurations.get(n.id),ye=c.useProgram(Z,ge),xe=c.style.map.terrain&&c.style.map.terrain.getTerrainData(me);C&&(c.context.activeTexture.set(y.TEXTURE0),X.imageAtlasTexture.bind(y.LINEAR,y.CLAMP_TO_EDGE),ge.updatePaintBuffers(A)),bo(ge,v,ee,X,n);const Pe=xe?me:null,Ae=c.translatePosMatrix(Pe?Pe.posMatrix:me.posMatrix,X,n.paint.get("fill-translate"),n.paint.get("fill-translate-anchor"));if(g){H=ae.indexBuffer2,N=ae.segments2;const Fe=[y.drawingBufferWidth,y.drawingBufferHeight];$=Z==="fillOutlinePattern"&&C?ke(Ae,c,A,X,Fe):ue(Ae,Fe)}else H=ae.indexBuffer,N=ae.segments,$=C?ie(Ae,c,A,X):te(Ae);ye.draw(c.context,F,a,c.stencilModeForClipping(me),u,ri.disabled,$,xe,n.id,ae.layoutVertexBuffer,H,N,n.paint,c.transform.zoom,ge)}}function Ms(c,t,n,s,a,u,g){const y=c.context,v=y.gl,S="fill-extrusion-pattern",C=n.paint.get(S),A=C.constantOr(1),F=n.getCrossfadeParameters(),Z=n.paint.get("fill-extrusion-opacity"),$=C.constantOr(null);for(const H of s){const N=t.getTile(H),ee=N.getBucket(n);if(!ee)continue;const me=c.style.map.terrain&&c.style.map.terrain.getTerrainData(H),X=ee.programConfigurations.get(n.id),ae=c.useProgram(A?"fillExtrusionPattern":"fillExtrusion",X);A&&(c.context.activeTexture.set(v.TEXTURE0),N.imageAtlasTexture.bind(v.LINEAR,v.CLAMP_TO_EDGE),X.updatePaintBuffers(F)),bo(X,S,$,N,n);const ge=c.translatePosMatrix(H.posMatrix,N,n.paint.get("fill-extrusion-translate"),n.paint.get("fill-extrusion-translate-anchor")),ye=n.paint.get("fill-extrusion-vertical-gradient"),xe=A?W(ge,c,ye,Z,H,F,N):D(ge,c,ye,Z);ae.draw(y,y.gl.TRIANGLES,a,u,g,ri.backCCW,xe,me,n.id,ee.layoutVertexBuffer,ee.indexBuffer,ee.segments,n.paint,c.transform.zoom,X,c.style.map.terrain&&ee.centroidVertexBuffer)}}function mn(c,t,n,s,a,u,g){const y=c.context,v=y.gl,S=n.fbo;if(!S)return;const C=c.useProgram("hillshade"),A=c.style.map.terrain&&c.style.map.terrain.getTerrainData(t);y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,S.colorAttachment.get()),C.draw(y,v.TRIANGLES,a,u,g,ri.disabled,((F,Z,$,H)=>{const N=$.paint.get("hillshade-shadow-color"),ee=$.paint.get("hillshade-highlight-color"),me=$.paint.get("hillshade-accent-color");let X=$.paint.get("hillshade-illumination-direction")*(Math.PI/180);$.paint.get("hillshade-illumination-anchor")==="viewport"&&(X-=F.transform.angle);const ae=!F.options.moving;return{u_matrix:H?H.posMatrix:F.transform.calculatePosMatrix(Z.tileID.toUnwrapped(),ae),u_image:0,u_latrange:gi(0,Z.tileID),u_light:[$.paint.get("hillshade-exaggeration"),X],u_shadow:N,u_highlight:ee,u_accent:me}})(c,n,s,A?t:null),A,s.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments)}function Xs(c,t,n,s,a,u){const g=c.context,y=g.gl,v=t.dem;if(v&&v.data){const S=v.dim,C=v.stride,A=v.getPixels();if(g.activeTexture.set(y.TEXTURE1),g.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||c.getTileTexture(C),t.demTexture){const Z=t.demTexture;Z.update(A,{premultiply:!1}),Z.bind(y.NEAREST,y.CLAMP_TO_EDGE)}else t.demTexture=new St(g,A,y.RGBA,{premultiply:!1}),t.demTexture.bind(y.NEAREST,y.CLAMP_TO_EDGE);g.activeTexture.set(y.TEXTURE0);let F=t.fbo;if(!F){const Z=new St(g,{width:S,height:S,data:null},y.RGBA);Z.bind(y.LINEAR,y.CLAMP_TO_EDGE),F=t.fbo=g.createFramebuffer(S,S,!0,!1),F.colorAttachment.set(Z.texture)}g.bindFramebuffer.set(F.framebuffer),g.viewport.set([0,0,S,S]),c.useProgram("hillshadePrepare").draw(g,y.TRIANGLES,s,a,u,ri.disabled,((Z,$)=>{const H=$.stride,N=d.F();return d.aN(N,0,d.W,-d.W,0,0,1),d.H(N,N,[0,-d.W,0]),{u_matrix:N,u_image:1,u_dimension:[H,H],u_zoom:Z.overscaledZ,u_unpack:$.getUnpackVector()}})(t.tileID,v),null,n.id,c.rasterBoundsBuffer,c.quadTriangleIndexBuffer,c.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function lo(c,t,n,s,a,u){const g=s.paint.get("raster-fade-duration");if(!u&&g>0){const y=ce.now(),v=(y-c.timeAdded)/g,S=t?(y-t.timeAdded)/g:-1,C=n.getSource(),A=a.coveringZoomLevel({tileSize:C.tileSize,roundZoom:C.roundZoom}),F=!t||Math.abs(t.tileID.overscaledZ-A)>Math.abs(c.tileID.overscaledZ-A),Z=F&&c.refreshedUponExpiration?1:d.ac(F?v:1-S,0,1);return c.refreshedUponExpiration&&v>=1&&(c.refreshedUponExpiration=!1),t?{opacity:1,mix:1-Z}:{opacity:Z,mix:0}}return{opacity:1,mix:0}}const Js=new d.aO(1,0,0,1),As=new d.aO(0,1,0,1),Fo=new d.aO(0,0,1,1),Ks=new d.aO(1,0,1,1),Ys=new d.aO(0,1,1,1);function yi(c,t,n,s){Ki(c,0,t+n/2,c.transform.width,n,s)}function Wn(c,t,n,s){Ki(c,t-n/2,0,n,c.transform.height,s)}function Ki(c,t,n,s,a,u){const g=c.context,y=g.gl;y.enable(y.SCISSOR_TEST),y.scissor(t*c.pixelRatio,n*c.pixelRatio,s*c.pixelRatio,a*c.pixelRatio),g.clear({color:u}),y.disable(y.SCISSOR_TEST)}function Ps(c,t,n){const s=c.context,a=s.gl,u=n.posMatrix,g=c.useProgram("debug"),y=At.disabled,v=Wt.disabled,S=c.colorModeForRenderPass(),C="$debug",A=c.style.map.terrain&&c.style.map.terrain.getTerrainData(n);s.activeTexture.set(a.TEXTURE0);const F=t.getTileByID(n.key).latestRawTileData,Z=Math.floor((F&&F.byteLength||0)/1024),$=t.getTile(n).tileSize,H=512/Math.min($,512)*(n.overscaledZ/c.transform.zoom)*.5;let N=n.canonical.toString();n.overscaledZ!==n.canonical.z&&(N+=` => ${n.overscaledZ}`),function(ee,me){ee.initDebugOverlayCanvas();const X=ee.debugOverlayCanvas,ae=ee.context.gl,ge=ee.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,X.width,X.height),ge.shadowColor="white",ge.shadowBlur=2,ge.lineWidth=1.5,ge.strokeStyle="white",ge.textBaseline="top",ge.font="bold 36px Open Sans, sans-serif",ge.fillText(me,5,5),ge.strokeText(me,5,5),ee.debugOverlayTexture.update(X),ee.debugOverlayTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE)}(c,`${N} ${Z}kB`),g.draw(s,a.TRIANGLES,y,v,oi.alphaBlended,ri.disabled,Je(u,d.aO.transparent,H),null,C,c.debugBuffer,c.quadTriangleIndexBuffer,c.debugSegments),g.draw(s,a.LINE_STRIP,y,v,S,ri.disabled,Je(u,d.aO.red),A,C,c.debugBuffer,c.tileBorderIndexBuffer,c.debugSegments)}function ks(c,t,n){const s=c.context,a=s.gl,u=c.colorModeForRenderPass(),g=new At(a.LEQUAL,At.ReadWrite,c.depthRangeFor3D),y=c.useProgram("terrain"),v=t.getTerrainMesh();s.bindFramebuffer.set(null),s.viewport.set([0,0,c.width,c.height]);for(const S of n){const C=c.renderToTexture.getTexture(S),A=t.getTerrainData(S.tileID);s.activeTexture.set(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,C.texture);const F={u_matrix:c.transform.calculatePosMatrix(S.tileID.toUnwrapped()),u_texture:0,u_ele_delta:t.getMeshFrameDelta(c.transform.zoom)};y.draw(s,a.TRIANGLES,g,Wt.disabled,u,ri.backCCW,F,A,"terrain",v.vertexBuffer,v.indexBuffer,v.segments)}}class he{constructor(t,n){this.context=new Hn(t),this.transform=n,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:d.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Xi.maxUnderzooming+Xi.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new no}resize(t,n,s){if(this.width=Math.floor(t*s),this.height=Math.floor(n*s),this.pixelRatio=s,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const a of this.style._order)this.style._layers[a].resize()}setup(){const t=this.context,n=new d.aV;n.emplaceBack(0,0),n.emplaceBack(d.W,0),n.emplaceBack(0,d.W),n.emplaceBack(d.W,d.W),this.tileExtentBuffer=t.createVertexBuffer(n,Xo.members),this.tileExtentSegments=d.$.simpleSegment(0,0,4,2);const s=new d.aV;s.emplaceBack(0,0),s.emplaceBack(d.W,0),s.emplaceBack(0,d.W),s.emplaceBack(d.W,d.W),this.debugBuffer=t.createVertexBuffer(s,Xo.members),this.debugSegments=d.$.simpleSegment(0,0,4,5);const a=new d.Z;a.emplaceBack(0,0,0,0),a.emplaceBack(d.W,0,d.W,0),a.emplaceBack(0,d.W,0,d.W),a.emplaceBack(d.W,d.W,d.W,d.W),this.rasterBoundsBuffer=t.createVertexBuffer(a,ft.members),this.rasterBoundsSegments=d.$.simpleSegment(0,0,4,2);const u=new d.aV;u.emplaceBack(0,0),u.emplaceBack(1,0),u.emplaceBack(0,1),u.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(u,Xo.members),this.viewportSegments=d.$.simpleSegment(0,0,4,2);const g=new d.aW;g.emplaceBack(0),g.emplaceBack(1),g.emplaceBack(3),g.emplaceBack(2),g.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(g);const y=new d.aX;y.emplaceBack(0,1,2),y.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(y);const v=this.context.gl;this.stencilClearMode=new Wt({func:v.ALWAYS,mask:0},0,255,v.ZERO,v.ZERO,v.ZERO)}clearStencil(){const t=this.context,n=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const s=d.F();d.aN(s,0,this.width,this.height,0,0,1),d.J(s,s,[n.drawingBufferWidth,n.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,n.TRIANGLES,At.disabled,this.stencilClearMode,oi.disabled,ri.disabled,Ve(s),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,n){if(this.currentStencilSource===t.source||!t.isTileClipped()||!n||!n.length)return;this.currentStencilSource=t.source;const s=this.context,a=s.gl;this.nextStencilID+n.length>256&&this.clearStencil(),s.setColorMode(oi.disabled),s.setDepthMode(At.disabled);const u=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const g of n){const y=this._tileClippingMaskIDs[g.key]=this.nextStencilID++,v=this.style.map.terrain&&this.style.map.terrain.getTerrainData(g);u.draw(s,a.TRIANGLES,At.disabled,new Wt({func:a.ALWAYS,mask:0},y,255,a.KEEP,a.KEEP,a.REPLACE),oi.disabled,ri.disabled,Ve(g.posMatrix),v,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const t=this.nextStencilID++,n=this.context.gl;return new Wt({func:n.NOTEQUAL,mask:255},t,255,n.KEEP,n.KEEP,n.REPLACE)}stencilModeForClipping(t){const n=this.context.gl;return new Wt({func:n.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,n.KEEP,n.KEEP,n.REPLACE)}stencilConfigForOverlap(t){const n=this.context.gl,s=t.sort((g,y)=>y.overscaledZ-g.overscaledZ),a=s[s.length-1].overscaledZ,u=s[0].overscaledZ-a+1;if(u>1){this.currentStencilSource=void 0,this.nextStencilID+u>256&&this.clearStencil();const g={};for(let y=0;y=0;this.currentLayer--){const v=this.style._layers[s[this.currentLayer]],S=a[v.source],C=u[v.source];this._renderTileClippingMasks(v,C),this.renderLayer(this,S,v,C)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayerN.source&&!N.isHidden(C)?[S.sourceCaches[N.source]]:[]),Z=F.filter(N=>N.getSource().type==="vector"),$=F.filter(N=>N.getSource().type!=="vector"),H=N=>{(!A||A.getSource().maxzoomH(N)),A||$.forEach(N=>H(N)),A}(this.style,this.transform.zoom);v&&function(S,C,A){for(let F=0;F0),a&&(d.a_(n,s),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(u,g){const y=u.context,v=y.gl,S=oi.unblended,C=new At(v.LEQUAL,At.ReadWrite,[0,1]),A=g.getTerrainMesh(),F=g.sourceCache.getRenderableTiles(),Z=u.useProgram("terrainDepth");y.bindFramebuffer.set(g.getFramebuffer("depth").framebuffer),y.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),y.clear({color:d.aO.transparent,depth:1});for(const $ of F){const H=g.getTerrainData($.tileID),N={u_matrix:u.transform.calculatePosMatrix($.tileID.toUnwrapped()),u_ele_delta:g.getMeshFrameDelta(u.transform.zoom)};Z.draw(y,v.TRIANGLES,C,Wt.disabled,S,ri.backCCW,N,H,"terrain",A.vertexBuffer,A.indexBuffer,A.segments)}y.bindFramebuffer.set(null),y.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain),function(u,g){const y=u.context,v=y.gl,S=oi.unblended,C=new At(v.LEQUAL,At.ReadWrite,[0,1]),A=g.getTerrainMesh(),F=g.getCoordsTexture(),Z=g.sourceCache.getRenderableTiles(),$=u.useProgram("terrainCoords");y.bindFramebuffer.set(g.getFramebuffer("coords").framebuffer),y.viewport.set([0,0,u.width/devicePixelRatio,u.height/devicePixelRatio]),y.clear({color:d.aO.transparent,depth:1}),g.coordsIndex=[];for(const H of Z){const N=g.getTerrainData(H.tileID);y.activeTexture.set(v.TEXTURE0),v.bindTexture(v.TEXTURE_2D,F.texture);const ee={u_matrix:u.transform.calculatePosMatrix(H.tileID.toUnwrapped()),u_terrain_coords_id:(255-g.coordsIndex.length)/255,u_texture:0,u_ele_delta:g.getMeshFrameDelta(u.transform.zoom)};$.draw(y,v.TRIANGLES,C,Wt.disabled,S,ri.backCCW,ee,N,"terrain",A.vertexBuffer,A.indexBuffer,A.segments),g.coordsIndex.push(H.tileID.key)}y.bindFramebuffer.set(null),y.viewport.set([0,0,u.width,u.height])}(this,this.style.map.terrain))}renderLayer(t,n,s,a){if(!s.isHidden(this.transform.zoom)&&(s.type==="background"||s.type==="custom"||(a||[]).length))switch(this.id=s.id,s.type){case"symbol":(function(u,g,y,v,S){if(u.renderPass!=="translucent")return;const C=Wt.disabled,A=u.colorModeForRenderPass();(y._unevaluatedLayout.hasValue("text-variable-anchor")||y._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(F,Z,$,H,N,ee,me){const X=Z.transform,ae=N==="map",ge=ee==="map";for(const ye of F){const xe=H.getTile(ye),Pe=xe.getBucket($);if(!Pe||!Pe.text||!Pe.text.segments.get().length)continue;const Ae=d.ag(Pe.textSizeData,X.zoom),Fe=_t(xe,1,Z.transform.zoom),Ne=mt(ye.posMatrix,ge,ae,Z.transform,Fe),Et=$.layout.get("icon-text-fit")!=="none"&&Pe.hasIconData();if(Ae){const $e=Math.pow(2,X.zoom-xe.tileID.overscaledZ);Es(Pe,ae,ge,me,X,Ne,ye.posMatrix,$e,Ae,Et,Z.style.map.terrain?(pt,Ct)=>Z.style.map.terrain.getElevation(ye,pt,Ct):null)}}}(v,u,y,g,y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),S),y.paint.get("icon-opacity").constantOr(1)!==0&&Qo(u,g,y,v,!1,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),y.layout.get("icon-rotation-alignment"),y.layout.get("icon-pitch-alignment"),y.layout.get("icon-keep-upright"),C,A),y.paint.get("text-opacity").constantOr(1)!==0&&Qo(u,g,y,v,!0,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),y.layout.get("text-rotation-alignment"),y.layout.get("text-pitch-alignment"),y.layout.get("text-keep-upright"),C,A),g.map.showCollisionBoxes&&(ao(u,g,y,v,y.paint.get("text-translate"),y.paint.get("text-translate-anchor"),!0),ao(u,g,y,v,y.paint.get("icon-translate"),y.paint.get("icon-translate-anchor"),!1))})(t,n,s,a,this.style.placement.variableOffsets);break;case"circle":(function(u,g,y,v){if(u.renderPass!=="translucent")return;const S=y.paint.get("circle-opacity"),C=y.paint.get("circle-stroke-width"),A=y.paint.get("circle-stroke-opacity"),F=!y.layout.get("circle-sort-key").isConstant();if(S.constantOr(1)===0&&(C.constantOr(1)===0||A.constantOr(1)===0))return;const Z=u.context,$=Z.gl,H=u.depthModeForSublayer(0,At.ReadOnly),N=Wt.disabled,ee=u.colorModeForRenderPass(),me=[];for(let X=0;XX.sortKey-ae.sortKey);for(const X of me){const{programConfiguration:ae,program:ge,layoutVertexBuffer:ye,indexBuffer:xe,uniformValues:Pe,terrainData:Ae}=X.state;ge.draw(Z,$.TRIANGLES,H,N,ee,ri.disabled,Pe,Ae,y.id,ye,xe,X.segments,y.paint,u.transform.zoom,ae)}})(t,n,s,a);break;case"heatmap":(function(u,g,y,v){if(y.paint.get("heatmap-opacity")!==0)if(u.renderPass==="offscreen"){const S=u.context,C=S.gl,A=Wt.disabled,F=new oi([C.ONE,C.ONE],d.aO.transparent,[!0,!0,!0,!0]);(function(Z,$,H){const N=Z.gl;Z.activeTexture.set(N.TEXTURE1),Z.viewport.set([0,0,$.width/4,$.height/4]);let ee=H.heatmapFbo;if(ee)N.bindTexture(N.TEXTURE_2D,ee.colorAttachment.get()),Z.bindFramebuffer.set(ee.framebuffer);else{const me=N.createTexture();N.bindTexture(N.TEXTURE_2D,me),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_S,N.CLAMP_TO_EDGE),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_WRAP_T,N.CLAMP_TO_EDGE),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MIN_FILTER,N.LINEAR),N.texParameteri(N.TEXTURE_2D,N.TEXTURE_MAG_FILTER,N.LINEAR),ee=H.heatmapFbo=Z.createFramebuffer($.width/4,$.height/4,!1,!1),function(X,ae,ge,ye){var xe,Pe;const Ae=X.gl,Fe=(xe=X.HALF_FLOAT)!==null&&xe!==void 0?xe:Ae.UNSIGNED_BYTE,Ne=(Pe=X.RGBA16F)!==null&&Pe!==void 0?Pe:Ae.RGBA;Ae.texImage2D(Ae.TEXTURE_2D,0,Ne,ae.width/4,ae.height/4,0,Ae.RGBA,Fe,null),ye.colorAttachment.set(ge)}(Z,$,me,ee)}})(S,u,y),S.clear({color:d.aO.transparent});for(let Z=0;Z{const X=d.F();d.aN(X,0,H.width,H.height,0,0,1);const ae=H.context.gl;return{u_matrix:X,u_world:[ae.drawingBufferWidth,ae.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:N.paint.get("heatmap-opacity")}})(S,C),null,C.id,S.viewportBuffer,S.quadTriangleIndexBuffer,S.viewportSegments,C.paint,S.transform.zoom)}(u,y))})(t,n,s,a);break;case"line":(function(u,g,y,v){if(u.renderPass!=="translucent")return;const S=y.paint.get("line-opacity"),C=y.paint.get("line-width");if(S.constantOr(1)===0||C.constantOr(1)===0)return;const A=u.depthModeForSublayer(0,At.ReadOnly),F=u.colorModeForRenderPass(),Z=y.paint.get("line-dasharray"),$=y.paint.get("line-pattern"),H=$.constantOr(1),N=y.paint.get("line-gradient"),ee=y.getCrossfadeParameters(),me=H?"linePattern":Z?"lineSDF":N?"lineGradient":"line",X=u.context,ae=X.gl;let ge=!0;for(const ye of v){const xe=g.getTile(ye);if(H&&!xe.patternsLoaded())continue;const Pe=xe.getBucket(y);if(!Pe)continue;const Ae=Pe.programConfigurations.get(y.id),Fe=u.context.program.get(),Ne=u.useProgram(me,Ae),Et=ge||Ne.program!==Fe,$e=u.style.map.terrain&&u.style.map.terrain.getTerrainData(ye),pt=$.constantOr(null);if(pt&&xe.imageAtlas){const vt=xe.imageAtlas,Pt=vt.patternPositions[pt.to.toString()],Dt=vt.patternPositions[pt.from.toString()];Pt&&Dt&&Ae.setConstantPatternPositions(Pt,Dt)}const Ct=$e?ye:null,jt=H?Ee(u,xe,y,ee,Ct):Z?rt(u,xe,y,Z,ee,Ct):N?Vi(u,xe,y,Pe.lineClipsArray.length,Ct):It(u,xe,y,Ct);if(H)X.activeTexture.set(ae.TEXTURE0),xe.imageAtlasTexture.bind(ae.LINEAR,ae.CLAMP_TO_EDGE),Ae.updatePaintBuffers(ee);else if(Z&&(Et||u.lineAtlas.dirty))X.activeTexture.set(ae.TEXTURE0),u.lineAtlas.bind(X);else if(N){const vt=Pe.gradients[y.id];let Pt=vt.texture;if(y.gradientVersion!==vt.version){let Dt=256;if(y.stepInterpolant){const ji=g.getSource().maxzoom,ni=ye.canonical.z===ji?Math.ceil(1<0?n.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;const n=this.imageManager.getPattern(t.from.toString()),s=this.imageManager.getPattern(t.to.toString());return!n||!s}useProgram(t,n){this.cache=this.cache||{};const s=t+(n?n.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[s]||(this.cache[s]=new f(this.context,Jo[t],n,Us[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[s]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const t=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(t.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new St(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:t,drawingBufferHeight:n}=this.context.gl;return this.width!==t||this.height!==n}}class _e{constructor(t,n){this.points=t,this.planes=n}static fromInvProjectionMatrix(t,n,s){const a=Math.pow(2,s),u=[[-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(y=>{const v=1/(y=d.af([],y,t))[3]/n*a;return d.a$(y,y,[v,v,1/y[3],v])}),g=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(y=>{const v=function(F,Z){var $=Z[0],H=Z[1],N=Z[2],ee=$*$+H*H+N*N;return ee>0&&(ee=1/Math.sqrt(ee)),F[0]=Z[0]*ee,F[1]=Z[1]*ee,F[2]=Z[2]*ee,F}([],function(F,Z,$){var H=Z[0],N=Z[1],ee=Z[2],me=$[0],X=$[1],ae=$[2];return F[0]=N*ae-ee*X,F[1]=ee*me-H*ae,F[2]=H*X-N*me,F}([],kt([],u[y[0]],u[y[1]]),kt([],u[y[2]],u[y[1]]))),S=-((C=v)[0]*(A=u[y[1]])[0]+C[1]*A[1]+C[2]*A[2]);var C,A;return v.concat(S)});return new _e(u,g)}}class je{constructor(t,n){this.min=t,this.max=n,this.center=function(s,a,u){return s[0]=.5*a[0],s[1]=.5*a[1],s[2]=.5*a[2],s}([],function(s,a,u){return s[0]=a[0]+u[0],s[1]=a[1]+u[1],s[2]=a[2]+u[2],s}([],this.min,this.max))}quadrant(t){const n=[t%2==0,t<2],s=ti(this.min),a=ti(this.max);for(let u=0;u=0&&g++;if(g===0)return 0;g!==n.length&&(s=!1)}if(s)return 2;for(let a=0;a<3;a++){let u=Number.MAX_VALUE,g=-Number.MAX_VALUE;for(let y=0;ythis.max[a]-this.min[a])return 0}return 1}}class ct{constructor(t=0,n=0,s=0,a=0){if(isNaN(t)||t<0||isNaN(n)||n<0||isNaN(s)||s<0||isNaN(a)||a<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=n,this.left=s,this.right=a}interpolate(t,n,s){return n.top!=null&&t.top!=null&&(this.top=d.z.number(t.top,n.top,s)),n.bottom!=null&&t.bottom!=null&&(this.bottom=d.z.number(t.bottom,n.bottom,s)),n.left!=null&&t.left!=null&&(this.left=d.z.number(t.left,n.left,s)),n.right!=null&&t.right!=null&&(this.right=d.z.number(t.right,n.right,s)),this}getCenter(t,n){const s=d.ac((this.left+t-this.right)/2,0,t),a=d.ac((this.top+n-this.bottom)/2,0,n);return new d.P(s,a)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new ct(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const si=85.051129;class Ft{constructor(t,n,s,a,u){this.tileSize=512,this._renderWorldCopies=u===void 0||!!u,this._minZoom=t||0,this._maxZoom=n||22,this._minPitch=s??0,this._maxPitch=a??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new d.M(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ct,this._posMatrixCache={},this._alignedPosMatrixCache={},this.minElevationForCurrentTile=0}clone(){const t=new Ft(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return t.apply(this),t}apply(t){this.tileSize=t.tileSize,this.latRange=t.latRange,this.width=t.width,this.height=t.height,this._center=t._center,this._elevation=t._elevation,this.minElevationForCurrentTile=t.minElevationForCurrentTile,this.zoom=t.zoom,this.angle=t.angle,this._fov=t._fov,this._pitch=t._pitch,this._unmodified=t._unmodified,this._edgeInsets=t._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(t){this._minZoom!==t&&(this._minZoom=t,this.zoom=Math.max(this.zoom,t))}get maxZoom(){return this._maxZoom}set maxZoom(t){this._maxZoom!==t&&(this._maxZoom=t,this.zoom=Math.min(this.zoom,t))}get minPitch(){return this._minPitch}set minPitch(t){this._minPitch!==t&&(this._minPitch=t,this.pitch=Math.max(this.pitch,t))}get maxPitch(){return this._maxPitch}set maxPitch(t){this._maxPitch!==t&&(this._maxPitch=t,this.pitch=Math.min(this.pitch,t))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(t){t===void 0?t=!0:t===null&&(t=!1),this._renderWorldCopies=t}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new d.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){const n=-d.b1(t,-180,180)*Math.PI/180;this.angle!==n&&(this._unmodified=!1,this.angle=n,this._calcMatrices(),this.rotationMatrix=function(){var s=new d.A(4);return d.A!=Float32Array&&(s[1]=0,s[2]=0),s[0]=1,s[3]=1,s}(),function(s,a,u){var g=a[0],y=a[1],v=a[2],S=a[3],C=Math.sin(u),A=Math.cos(u);s[0]=g*A+v*C,s[1]=y*A+S*C,s[2]=g*-C+v*A,s[3]=y*-C+S*A}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){const n=d.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==n&&(this._unmodified=!1,this._pitch=n,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(t){t=Math.max(.01,Math.min(60,t)),this._fov!==t&&(this._unmodified=!1,this._fov=t/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(t){const n=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==n&&(this._unmodified=!1,this._zoom=n,this.tileZoom=Math.max(0,Math.floor(n)),this.scale=this.zoomScale(n),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(t){t.lat===this._center.lat&&t.lng===this._center.lng||(this._unmodified=!1,this._center=t,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(t){t!==this._elevation&&(this._elevation=t,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(t){this._edgeInsets.equals(t)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,t,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(t){return this._edgeInsets.equals(t)}interpolatePadding(t,n,s){this._unmodified=!1,this._edgeInsets.interpolate(t,n,s),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){const n=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,n)}getVisibleUnwrappedCoordinates(t){const n=[new d.b2(0,t)];if(this._renderWorldCopies){const s=this.pointCoordinate(new d.P(0,0)),a=this.pointCoordinate(new d.P(this.width,0)),u=this.pointCoordinate(new d.P(this.width,this.height)),g=this.pointCoordinate(new d.P(0,this.height)),y=Math.floor(Math.min(s.x,a.x,u.x,g.x)),v=Math.floor(Math.max(s.x,a.x,u.x,g.x)),S=1;for(let C=y-S;C<=v+S;C++)C!==0&&n.push(new d.b2(C,t))}return n}coveringTiles(t){var n,s;let a=this.coveringZoomLevel(t);const u=a;if(t.minzoom!==void 0&&at.maxzoom&&(a=t.maxzoom);const g=this.pointCoordinate(this.getCameraPoint()),y=d.Y.fromLngLat(this.center),v=Math.pow(2,a),S=[v*g.x,v*g.y,0],C=[v*y.x,v*y.y,0],A=_e.fromInvProjectionMatrix(this.invProjMatrix,this.worldSize,a);let F=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(F=a);const Z=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,$=X=>({aabb:new je([X*v,0,0],[(X+1)*v,v,0]),zoom:0,x:0,y:0,wrap:X,fullyVisible:!1}),H=[],N=[],ee=a,me=t.reparseOverscaled?u:a;if(this._renderWorldCopies)for(let X=1;X<=3;X++)H.push($(-X)),H.push($(X));for(H.push($(0));H.length>0;){const X=H.pop(),ae=X.x,ge=X.y;let ye=X.fullyVisible;if(!ye){const Ne=X.aabb.intersects(A);if(Ne===0)continue;ye=Ne===2}const xe=t.terrain?S:C,Pe=X.aabb.distanceX(xe),Ae=X.aabb.distanceY(xe),Fe=Math.max(Math.abs(Pe),Math.abs(Ae));if(X.zoom===ee||Fe>Z+(1<=F){const Ne=ee-X.zoom,Et=S[0]-.5-(ae<>1),pt=X.zoom+1;let Ct=X.aabb.quadrant(Ne);if(t.terrain){const jt=new d.Q(pt,X.wrap,pt,Et,$e),vt=t.terrain.getMinMaxElevation(jt),Pt=(n=vt.minElevation)!==null&&n!==void 0?n:this.elevation,Dt=(s=vt.maxElevation)!==null&&s!==void 0?s:this.elevation;Ct=new je([Ct.min[0],Ct.min[1],Pt],[Ct.max[0],Ct.max[1],Dt])}H.push({aabb:Ct,zoom:pt,x:Et,y:$e,wrap:X.wrap,fullyVisible:ye})}}return N.sort((X,ae)=>X.distanceSq-ae.distanceSq).map(X=>X.tileID)}resize(t,n){this.width=t,this.height=n,this.pixelsToGLUnits=[2/t,-2/n],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(t){return Math.pow(2,t)}scaleZoom(t){return Math.log(t)/Math.LN2}project(t){const n=d.ac(t.lat,-85.051129,si);return new d.P(d.N(t.lng)*this.worldSize,d.O(n)*this.worldSize)}unproject(t){return new d.Y(t.x/this.worldSize,t.y/this.worldSize).toLngLat()}get point(){return this.project(this.center)}getCameraPosition(){return{lngLat:this.pointLocation(this.getCameraPoint()),altitude:Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter+this.elevation}}recalculateZoom(t){const n=this.elevation,s=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,a=this.pointLocation(this.centerPoint,t),u=t.getElevationForLngLatZoom(a,this.tileZoom);if(!(this.elevation-u))return;const g=s+n-u,y=Math.cos(this._pitch)*this.cameraToCenterDistance/g/d.b3(1,a.lat),v=this.scaleZoom(y/this.tileSize);this._elevation=u,this._center=a,this.zoom=v}setLocationAtPoint(t,n){const s=this.pointCoordinate(n),a=this.pointCoordinate(this.centerPoint),u=this.locationCoordinate(t),g=new d.Y(u.x-(s.x-a.x),u.y-(s.y-a.y));this.center=this.coordinateLocation(g),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,n){return n?this.coordinatePoint(this.locationCoordinate(t),n.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,n){return this.coordinateLocation(this.pointCoordinate(t,n))}locationCoordinate(t){return d.Y.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,n){if(n){const F=n.pointCoordinate(t);if(F!=null)return F}const s=[t.x,t.y,0,1],a=[t.x,t.y,1,1];d.af(s,s,this.pixelMatrixInverse),d.af(a,a,this.pixelMatrixInverse);const u=s[3],g=a[3],y=s[1]/u,v=a[1]/g,S=s[2]/u,C=a[2]/g,A=S===C?0:(0-S)/(C-S);return new d.Y(d.z.number(s[0]/u,a[0]/g,A)/this.worldSize,d.z.number(y,v,A)/this.worldSize)}coordinatePoint(t,n=0,s=this.pixelMatrix){const a=[t.x*this.worldSize,t.y*this.worldSize,n,1];return d.af(a,a,s),new d.P(a[0]/a[3],a[1]/a[3])}getBounds(){const t=Math.max(0,this.height/2-this.getHorizon());return new Yt().extend(this.pointLocation(new d.P(0,t))).extend(this.pointLocation(new d.P(this.width,t))).extend(this.pointLocation(new d.P(this.width,this.height))).extend(this.pointLocation(new d.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new Yt([this.lngRange[0],this.latRange[0]],[this.lngRange[1],this.latRange[1]]):null}getHorizon(){return Math.tan(Math.PI/2-this._pitch)*this.cameraToCenterDistance*.85}setMaxBounds(t){t?(this.lngRange=[t.getWest(),t.getEast()],this.latRange=[t.getSouth(),t.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,si])}calculatePosMatrix(t,n=!1){const s=t.key,a=n?this._alignedPosMatrixCache:this._posMatrixCache;if(a[s])return a[s];const u=t.canonical,g=this.worldSize/this.zoomScale(u.z),y=u.x+Math.pow(2,u.z)*t.wrap,v=d.an(new Float64Array(16));return d.H(v,v,[y*g,u.y*g,0]),d.J(v,v,[g/d.W,g/d.W,1]),d.K(v,n?this.alignedProjMatrix:this.projMatrix,v),a[s]=new Float32Array(v),a[s]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,n){n=d.ac(+n,this.minZoom,this.maxZoom);const s={center:new d.M(t.lng,t.lat),zoom:n};let a=this.lngRange;if(!this._renderWorldCopies&&a===null){const X=179.9999999999;a=[-X,X]}const u=this.tileSize*this.zoomScale(s.zoom);let g=0,y=u,v=0,S=u,C=0,A=0;const{x:F,y:Z}=this.size;if(this.latRange){const X=this.latRange;g=d.O(X[1])*u,y=d.O(X[0])*u,y-gy&&(ee=y-X)}if(a){const X=(v+S)/2;let ae=$;this._renderWorldCopies&&(ae=d.b1($,X-u/2,X+u/2));const ge=F/2;ae-geS&&(N=S-ge)}if(N!==void 0||ee!==void 0){const X=new d.P(N??$,ee??H);s.center=this.unproject.call({worldSize:u},X).wrap()}return s}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const t=this._unmodified,{center:n,zoom:s}=this.getConstrained(this.center,this.zoom);this.center=n,this.zoom=s,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;const t=this.centerOffset,n=this.point.x,s=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=d.b3(1,this.center.lat)*this.worldSize;let a=d.an(new Float64Array(16));d.J(a,a,[this.width/2,-this.height/2,1]),d.H(a,a,[1,-1,0]),this.labelPlaneMatrix=a,a=d.an(new Float64Array(16)),d.J(a,a,[1,-1,1]),d.H(a,a,[-1,-1,0]),d.J(a,a,[2/this.width,2/this.height,1]),this.glCoordMatrix=a;const u=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),g=Math.min(this.elevation,this.minElevationForCurrentTile),y=u-g*this._pixelPerMeter/Math.cos(this._pitch),v=g<0?y:u,S=Math.PI/2+this._pitch,C=this._fov*(.5+t.y/this.height),A=Math.sin(C)*v/Math.sin(d.ac(Math.PI-S-C,.01,Math.PI-.01)),F=this.getHorizon(),Z=2*Math.atan(F/this.cameraToCenterDistance)*(.5+t.y/(2*F)),$=Math.sin(Z)*v/Math.sin(d.ac(Math.PI-S-Z,.01,Math.PI-.01)),H=Math.min(A,$),N=1.01*(Math.cos(Math.PI/2-this._pitch)*H+v),ee=this.height/50;a=new Float64Array(16),d.b4(a,this._fov,this.width/this.height,ee,N),a[8]=2*-t.x/this.width,a[9]=2*t.y/this.height,d.J(a,a,[1,-1,1]),d.H(a,a,[0,0,-this.cameraToCenterDistance]),d.b5(a,a,this._pitch),d.ad(a,a,this.angle),d.H(a,a,[-n,-s,0]),this.mercatorMatrix=d.J([],a,[this.worldSize,this.worldSize,this.worldSize]),d.J(a,a,[1,1,this._pixelPerMeter]),this.pixelMatrix=d.K(new Float64Array(16),this.labelPlaneMatrix,a),d.H(a,a,[0,0,-this.elevation]),this.projMatrix=a,this.invProjMatrix=d.ar([],a),this.pixelMatrix3D=d.K(new Float64Array(16),this.labelPlaneMatrix,a);const me=this.width%2/2,X=this.height%2/2,ae=Math.cos(this.angle),ge=Math.sin(this.angle),ye=n-Math.round(n)+ae*me+ge*X,xe=s-Math.round(s)+ae*X+ge*me,Pe=new Float64Array(a);if(d.H(Pe,Pe,[ye>.5?ye-1:ye,xe>.5?xe-1:xe,0]),this.alignedProjMatrix=Pe,a=d.ar(new Float64Array(16),this.pixelMatrix),!a)throw new Error("failed to invert matrix");this.pixelMatrixInverse=a,this._posMatrixCache={},this._alignedPosMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const t=this.pointCoordinate(new d.P(0,0)),n=[t.x*this.worldSize,t.y*this.worldSize,0,1];return d.af(n,n,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new d.P(0,t))}getCameraQueryGeometry(t){const n=this.getCameraPoint();if(t.length===1)return[t[0],n];{let s=n.x,a=n.y,u=n.x,g=n.y;for(const y of t)s=Math.min(s,y.x),a=Math.min(a,y.y),u=Math.max(u,y.x),g=Math.max(g,y.y);return[new d.P(s,a),new d.P(u,a),new d.P(u,g),new d.P(s,g),new d.P(s,a)]}}lngLatToCameraDepth(t,n){const s=this.locationCoordinate(t),a=[s.x*this.worldSize,s.y*this.worldSize,n,1];return d.af(a,a,this.projMatrix),a[2]/a[3]}}function _i(c,t){let n,s=!1,a=null,u=null;const g=()=>{a=null,s&&(c.apply(u,n),a=setTimeout(g,t),s=!1)};return(...y)=>(s=!0,u=this,n=y,a||g(),a)}class Li{constructor(t){this._getCurrentHash=()=>{const n=window.location.hash.replace("#","");if(this._hashName){let s;return n.split("&").map(a=>a.split("=")).forEach(a=>{a[0]===this._hashName&&(s=a)}),(s&&s[1]||"").split("/")}return n.split("/")},this._onHashChange=()=>{const n=this._getCurrentHash();if(n.length>=3&&!n.some(s=>isNaN(s))){const s=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(n[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+n[2],+n[1]],zoom:+n[0],bearing:s,pitch:+(n[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const n=window.location.href.replace(/(#.+)?$/,this.getHashString());try{window.history.replaceState(window.history.state,null,n)}catch{}},this._updateHash=_i(this._updateHashUnthrottled,300),this._hashName=t&&encodeURIComponent(t)}addTo(t){return this._map=t,addEventListener("hashchange",this._onHashChange,!1),this._map.on("moveend",this._updateHash),this}remove(){return removeEventListener("hashchange",this._onHashChange,!1),this._map.off("moveend",this._updateHash),clearTimeout(this._updateHash()),delete this._map,this}getHashString(t){const n=this._map.getCenter(),s=Math.round(100*this._map.getZoom())/100,a=Math.ceil((s*Math.LN2+Math.log(512/360/.5))/Math.LN10),u=Math.pow(10,a),g=Math.round(n.lng*u)/u,y=Math.round(n.lat*u)/u,v=this._map.getBearing(),S=this._map.getPitch();let C="";if(C+=t?`/${g}/${y}/${s}`:`${s}/${y}/${g}`,(v||S)&&(C+="/"+Math.round(10*v)/10),S&&(C+=`/${Math.round(S)}`),this._hashName){const A=this._hashName;let F=!1;const Z=window.location.hash.slice(1).split("&").map($=>{const H=$.split("=")[0];return H===A?(F=!0,`${H}=${C}`):$}).filter($=>$);return F||Z.push(`${A}=${C}`),`#${Z.join("&")}`}return`#${C}`}}const kr={linearity:.3,easing:d.b6(0,0,.3,1)},hi=d.e({deceleration:2500,maxSpeed:1400},kr),qi=d.e({deceleration:20,maxSpeed:1400},kr),gn=d.e({deceleration:1e3,maxSpeed:360},kr),kn=d.e({deceleration:1e3,maxSpeed:90},kr);class Ir{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:ce.now(),settings:t})}_drainInertiaBuffer(){const t=this._inertiaBuffer,n=ce.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 d.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:u}of this._inertiaBuffer)n.zoom+=u.zoomDelta||0,n.bearing+=u.bearingDelta||0,n.pitch+=u.pitchDelta||0,u.panDelta&&n.pan._add(u.panDelta),u.around&&(n.around=u.around),u.pinchAround&&(n.pinchAround=u.pinchAround);const s=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,a={};if(n.pan.mag()){const u=Ln(n.pan.mag(),s,d.e({},hi,t||{}));a.offset=n.pan.mult(u.amount/n.pan.mag()),a.center=this._map.transform.center,$r(a,u)}if(n.zoom){const u=Ln(n.zoom,s,qi);a.zoom=this._map.transform.zoom+u.amount,$r(a,u)}if(n.bearing){const u=Ln(n.bearing,s,gn);a.bearing=this._map.transform.bearing+d.ac(u.amount,-179,179),$r(a,u)}if(n.pitch){const u=Ln(n.pitch,s,kn);a.pitch=this._map.transform.pitch+u.amount,$r(a,u)}if(a.zoom||a.bearing){const u=n.pinchAround===void 0?n.around:n.pinchAround;a.around=u?this._map.unproject(u):this._map.getCenter()}return this.clear(),d.e(a,{noMoveStart:!0})}}function $r(c,t){(!c.duration||c.durationn.unproject(v)),y=u.reduce((v,S,C,A)=>v.add(S.div(A.length)),new d.P(0,0));super(t,{points:u,point:y,lngLats:g,lngLat:n.unproject(y),originalEvent:s}),this._defaultPrevented=!1}}class Io extends d.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,n,s){super(t,{originalEvent:s}),this._defaultPrevented=!1}}class rn{constructor(t,n){this._map=t,this._clickTolerance=n.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Io(t.type,this._map,t))}mousedown(t,n){return this._mousedownPos=n,this._firePreventable(new cr(t.type,this._map,t))}mouseup(t){this._map.fire(new cr(t.type,this._map,t))}click(t,n){this._mousedownPos&&this._mousedownPos.dist(n)>=this._clickTolerance||this._map.fire(new cr(t.type,this._map,t))}dblclick(t){return this._firePreventable(new cr(t.type,this._map,t))}mouseover(t){this._map.fire(new cr(t.type,this._map,t))}mouseout(t){this._map.fire(new cr(t.type,this._map,t))}touchstart(t){return this._firePreventable(new Lr(t.type,this._map,t))}touchmove(t){this._map.fire(new Lr(t.type,this._map,t))}touchend(t){this._map.fire(new Lr(t.type,this._map,t))}touchcancel(t){this._map.fire(new Lr(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class zn{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new cr(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new cr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new cr(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Bo{constructor(t){this._map=t}get transform(){return this._map._requestedCameraState||this._map.transform}get center(){return{lng:this.transform.center.lng,lat:this.transform.center.lat}}get zoom(){return this.transform.zoom}get pitch(){return this.transform.pitch}get bearing(){return this.transform.bearing}unproject(t){return this.transform.pointLocation(d.P.convert(t),this._map.terrain)}}class Nt{constructor(t,n){this._map=t,this._tr=new Bo(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=n.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,n){this.isEnabled()&&t.shiftKey&&t.button===0&&(oe.disableDrag(),this._startPos=this._lastPos=n,this._active=!0)}mousemoveWindow(t,n){if(!this._active)return;const s=n;if(this._lastPos.equals(s)||!this._box&&s.dist(this._startPos)u.fitScreenCoordinates(s,a,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",t)}keydown(t){this._active&&t.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",t))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(oe.remove(this._box),this._box=null),oe.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,n){return this._map.fire(new d.k(t,{originalEvent:n}))}}function qt(c,t){if(c.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${c.length}, points ${t.length}`);const n={};for(let s=0;sthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),s.length===this.numTouches&&(this.centroid=function(a){const u=new d.P(0,0);for(const g of a)u._add(g);return u.div(a.length)}(n),this.touches=qt(s,n)))}touchmove(t,n,s){if(this.aborted||!this.centroid)return;const a=qt(s,n);for(const u in this.touches){const g=a[u];(!g||g.dist(this.touches[u])>30)&&(this.aborted=!0)}}touchend(t,n,s){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),s.length===0){const a=!this.aborted&&this.centroid;if(this.reset(),a)return a}}}class Dn{constructor(t){this.singleTap=new Ls(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,n,s){this.singleTap.touchstart(t,n,s)}touchmove(t,n,s){this.singleTap.touchmove(t,n,s)}touchend(t,n,s){const a=this.singleTap.touchend(t,n,s);if(a){const u=t.timeStamp-this.lastTime<500,g=!this.lastTap||this.lastTap.dist(a)<30;if(u&&g||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=a,this.count===this.numTaps)return this.reset(),a}}}class Qs{constructor(t){this._tr=new Bo(t),this._zoomIn=new Dn({numTouches:1,numTaps:2}),this._zoomOut=new Dn({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,n,s){this._zoomIn.touchstart(t,n,s),this._zoomOut.touchstart(t,n,s)}touchmove(t,n,s){this._zoomIn.touchmove(t,n,s),this._zoomOut.touchmove(t,n,s)}touchend(t,n,s){const a=this._zoomIn.touchend(t,n,s),u=this._zoomOut.touchend(t,n,s),g=this._tr;return a?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:y=>y.easeTo({duration:300,zoom:g.zoom+1,around:g.unproject(a)},{originalEvent:t})}):u?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:y=>y.easeTo({duration:300,zoom:g.zoom-1,around:g.unproject(u)},{originalEvent:t})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class ur{constructor(t){this._enabled=!!t.enable,this._moveStateManager=t.moveStateManager,this._clickTolerance=t.clickTolerance||1,this._moveFunction=t.move,this._activateOnStart=!!t.activateOnStart,t.assignEvents(this),this.reset()}reset(t){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(t)}_move(...t){const n=this._moveFunction(...t);if(n.bearingDelta||n.pitchDelta||n.around||n.panDelta)return this._active=!0,n}dragStart(t,n){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=n.length?n[0]:n,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,n){if(!this.isEnabled())return;const s=this._lastPoint;if(!s)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);const a=n.length?n[0]:n;return!this._moved&&a.dist(s){c.mousedown=c.dragStart,c.mousemoveWindow=c.dragMove,c.mouseup=c.dragEnd,c.contextmenu=function(t){t.preventDefault()}},yn=({enable:c,clickTolerance:t,bearingDegreesPerPixelMoved:n=.8})=>{const s=new hr({checkCorrectEvent:a=>oe.mouseButton(a)===0&&a.ctrlKey||oe.mouseButton(a)===2});return new ur({clickTolerance:t,move:(a,u)=>({bearingDelta:(u.x-a.x)*n}),moveStateManager:s,enable:c,assignEvents:So})},nn=({enable:c,clickTolerance:t,pitchDegreesPerPixelMoved:n=-.5})=>{const s=new hr({checkCorrectEvent:a=>oe.mouseButton(a)===0&&a.ctrlKey||oe.mouseButton(a)===2});return new ur({clickTolerance:t,move:(a,u)=>({pitchDelta:(u.y-a.y)*n}),moveStateManager:s,enable:c,assignEvents:So})};class ea{constructor(t,n){this._clickTolerance=t.clickTolerance||1,this._map=n,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new d.P(0,0)}minTouchs(){return this._map.cooperativeGestures.isEnabled()?2:1}touchstart(t,n,s){return this._calculateTransform(t,n,s)}touchmove(t,n,s){if(this._active&&!(s.length0&&(this._active=!0);const a=qt(s,n),u=new d.P(0,0),g=new d.P(0,0);let y=0;for(const S in a){const C=a[S],A=this._touches[S];A&&(u._add(C),g._add(C.sub(A)),y++,a[S]=C)}if(this._touches=a,yMath.abs(c.x)}class kl extends Ze{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,n,s){super.touchstart(t,n,s),this._currentTouchCount=s.length}_start(t){this._lastPoints=t,To(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,n,s){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const a=t[0].sub(this._lastPoints[0]),u=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(a,u,s.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(a.y+u.y)/2*-.5}):void 0}gestureBeginsVertically(t,n,s){if(this._valid!==void 0)return this._valid;const a=t.mag()>=2,u=n.mag()>=2;if(!a&&!u)return;if(!a||!u)return this._firstMove===void 0&&(this._firstMove=s),s-this._firstMove<100&&void 0;const g=t.y>0==n.y>0;return To(t)&&To(n)&&g}}const pc={panStep:100,bearingStep:15,pitchStep:10};class No{constructor(t){this._tr=new Bo(t);const n=pc;this._panStep=n.panStep,this._bearingStep=n.bearingStep,this._pitchStep=n.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let n=0,s=0,a=0,u=0,g=0;switch(t.keyCode){case 61:case 107:case 171:case 187:n=1;break;case 189:case 109:case 173:n=-1;break;case 37:t.shiftKey?s=-1:(t.preventDefault(),u=-1);break;case 39:t.shiftKey?s=1:(t.preventDefault(),u=1);break;case 38:t.shiftKey?a=1:(t.preventDefault(),g=-1);break;case 40:t.shiftKey?a=-1:(t.preventDefault(),g=1);break;default:return}return this._rotationDisabled&&(s=0,a=0),{cameraAnimation:y=>{const v=this._tr;y.easeTo({duration:300,easeId:"keyboardHandler",easing:Ei,zoom:n?Math.round(v.zoom)+n*(t.shiftKey?2:1):v.zoom,bearing:v.bearing+s*this._bearingStep,pitch:v.pitch+a*this._pitchStep,offset:[-u*this._panStep,-g*this._panStep],center:v.center},{originalEvent:t})}}}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 Ei(c){return c*(2-c)}const ta=4.000244140625;class Ia{constructor(t,n){this._onTimeout=s=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(s)},this._map=t,this._tr=new Bo(t),this._triggerRenderFrame=n,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(t){this._defaultZoomRate=t}setWheelZoomRate(t){this._wheelZoomRate=t}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(t){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!t&&t.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}wheel(t){if(!this.isEnabled()||this._map.cooperativeGestures.isEnabled()&&!t[this._map.cooperativeGestures._bypassKey])return;let n=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY;const s=ce.now(),a=s-(this._lastWheelEventTime||0);this._lastWheelEventTime=s,n!==0&&n%ta==0?this._type="wheel":n!==0&&Math.abs(n)<4?this._type="trackpad":a>400?(this._type=null,this._lastValue=n,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(a*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()}_start(t){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 n=oe.mousePos(this._map.getCanvas(),t),s=this._tr;this._around=n.y>s.transform.height/2-s.transform.getHorizon()?d.M.convert(this._aroundCenter?s.center:s.unproject(n)):d.M.convert(s.center),this._aroundPoint=s.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const t=this._tr.transform;if(this._delta!==0){const y=this._type==="wheel"&&Math.abs(this._delta)>ta?this._wheelZoomRate:this._defaultZoomRate;let v=2/(1+Math.exp(-Math.abs(this._delta*y)));this._delta<0&&v!==0&&(v=1/v);const S=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(S*v))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const n=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,s=this._startZoom,a=this._easing;let u,g=!1;if(this._type==="wheel"&&s&&a){const y=Math.min((ce.now()-this._lastWheelEventTime)/200,1),v=a(y);u=d.z.number(s,n,v),y<1?this._frameId||(this._frameId=!0):g=!0}else u=n,g=!0;return this._active=!0,g&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!g,zoomDelta:u-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let n=d.b7;if(this._prevEase){const s=this._prevEase,a=(ce.now()-s.start)/s.duration,u=s.easing(a+.01)-s.easing(a),g=.27/Math.sqrt(u*u+1e-4)*.01,y=Math.sqrt(.0729-g*g);n=d.b6(g,y,.25,1)}return this._prevEase={start:ce.now(),duration:t,easing:n},n}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Ha{constructor(t,n){this._clickZoom=t,this._tapZoom=n}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 Ll{constructor(t){this._tr=new Bo(t),this.reset()}reset(){this._active=!1}dblclick(t,n){return t.preventDefault(),{cameraAnimation:s=>{s.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(n)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class zl{constructor(){this._tap=new Dn({numTouches:1,numTaps:1}),this.reset()}reset(){this._active=!1,delete this._swipePoint,delete this._swipeTouch,delete this._tapTime,delete this._tapPoint,this._tap.reset()}touchstart(t,n,s){if(!this._swipePoint)if(this._tapTime){const a=n[0],u=t.timeStamp-this._tapTime<500,g=this._tapPoint.dist(a)<30;u&&g?s.length>0&&(this._swipePoint=a,this._swipeTouch=s[0].identifier):this.reset()}else this._tap.touchstart(t,n,s)}touchmove(t,n,s){if(this._tapTime){if(this._swipePoint){if(s[0].identifier!==this._swipeTouch)return;const a=n[0],u=a.y-this._swipePoint.y;return this._swipePoint=a,t.preventDefault(),this._active=!0,{zoomDelta:u/128}}}else this._tap.touchmove(t,n,s)}touchend(t,n,s){if(this._tapTime)this._swipePoint&&s.length===0&&this.reset();else{const a=this._tap.touchend(t,n,s);a&&(this._tapTime=t.timeStamp,this._tapPoint=a)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Dl{constructor(t,n,s){this._el=t,this._mousePan=n,this._touchPan=s}enable(t){this._inertiaOptions=t||{},this._mousePan.enable(),this._touchPan.enable(),this._el.classList.add("maplibregl-touch-drag-pan")}disable(){this._mousePan.disable(),this._touchPan.disable(),this._el.classList.remove("maplibregl-touch-drag-pan")}isEnabled(){return this._mousePan.isEnabled()&&this._touchPan.isEnabled()}isActive(){return this._mousePan.isActive()||this._touchPan.isActive()}}class Xn{constructor(t,n,s){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=n,this._mousePitch=s}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 ia{constructor(t,n,s,a){this._el=t,this._touchZoom=n,this._touchRotate=s,this._tapDragZoom=a,this._rotationDisabled=!1,this._enabled=!0}enable(t){this._touchZoom.enable(t),this._rotationDisabled||this._touchRotate.enable(t),this._tapDragZoom.enable(),this._el.classList.add("maplibregl-touch-zoom-rotate")}disable(){this._touchZoom.disable(),this._touchRotate.disable(),this._tapDragZoom.disable(),this._el.classList.remove("maplibregl-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()}}class at{constructor(t,n){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=n,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=oe.create("div","maplibregl-cooperative-gesture-screen",t);let n=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(n=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const s=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),a=document.createElement("div");a.className="maplibregl-desktop-message",a.textContent=n,this._container.appendChild(a);const u=document.createElement("div");u.className="maplibregl-mobile-message",u.textContent=s,this._container.appendChild(u),this._container.setAttribute("aria-hidden","true")}_destoryUI(){this._container&&(oe.remove(this._container),this._map.getCanvasContainer().classList.remove("maplibregl-cooperative-gestures")),delete this._container}enable(){this._setupUI(),this._enabled=!0}disable(){this._enabled=!1,this._destoryUI()}isEnabled(){return this._enabled}touchmove(t){this._onCooperativeGesture(t.touches.length===1)}wheel(t){this._map.scrollZoom.isEnabled()&&this._onCooperativeGesture(!t[this._bypassKey])}_onCooperativeGesture(t){this._enabled&&t&&(this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const dt=c=>c.zoom||c.drag||c.pitch||c.rotate;class Sa extends d.k{}function ra(c){return c.panDelta&&c.panDelta.mag()||c.zoomDelta||c.bearingDelta||c.pitchDelta}class Wa{constructor(t,n){this.handleWindowEvent=a=>{this.handleEvent(a,`${a.type}Window`)},this.handleEvent=(a,u)=>{if(a.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const g=a.type==="renderFrame"?void 0:a,y={needsRenderFrame:!1},v={},S={},C=a.touches,A=C?this._getMapTouches(C):void 0,F=A?oe.touchPos(this._map.getCanvas(),A):oe.mousePos(this._map.getCanvas(),a);for(const{handlerName:H,handler:N,allowed:ee}of this._handlers){if(!N.isEnabled())continue;let me;this._blockedByActive(S,ee,H)?N.reset():N[u||a.type]&&(me=N[u||a.type](a,F,A),this.mergeHandlerResult(y,v,me,H,g),me&&me.needsRenderFrame&&this._triggerRenderFrame()),(me||N.isActive())&&(S[H]=N)}const Z={};for(const H in this._previousActiveHandlers)S[H]||(Z[H]=g);this._previousActiveHandlers=S,(Object.keys(Z).length||ra(y))&&(this._changes.push([y,v,Z]),this._triggerRenderFrame()),(Object.keys(S).length||ra(y))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:$}=y;$&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],$(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new Ir(t),this._bearingSnap=n.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(n);const s=this._el;this._listeners=[[s,"touchstart",{passive:!0}],[s,"touchmove",{passive:!1}],[s,"touchend",void 0],[s,"touchcancel",void 0],[s,"mousedown",void 0],[s,"mousemove",void 0],[s,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[s,"mouseover",void 0],[s,"mouseout",void 0],[s,"dblclick",void 0],[s,"click",void 0],[s,"keydown",{capture:!1}],[s,"keyup",void 0],[s,"wheel",{passive:!1}],[s,"contextmenu",void 0],[window,"blur",void 0]];for(const[a,u,g]of this._listeners)oe.addEventListener(a,u,a===document?this.handleWindowEvent:this.handleEvent,g)}destroy(){for(const[t,n,s]of this._listeners)oe.removeEventListener(t,n,t===document?this.handleWindowEvent:this.handleEvent,s)}_addDefaultHandlers(t){const n=this._map,s=n.getCanvasContainer();this._add("mapEvent",new rn(n,t));const a=n.boxZoom=new Nt(n,t);this._add("boxZoom",a),t.interactive&&t.boxZoom&&a.enable();const u=n.cooperativeGestures=new at(n,t.cooperativeGestures);this._add("cooperativeGestures",u),t.cooperativeGestures&&u.enable();const g=new Qs(n),y=new Ll(n);n.doubleClickZoom=new Ha(y,g),this._add("tapZoom",g),this._add("clickZoom",y),t.interactive&&t.doubleClickZoom&&n.doubleClickZoom.enable();const v=new zl;this._add("tapDragZoom",v);const S=n.touchPitch=new kl(n);this._add("touchPitch",S),t.interactive&&t.touchPitch&&n.touchPitch.enable(t.touchPitch);const C=yn(t),A=nn(t);n.dragRotate=new Xn(t,C,A),this._add("mouseRotate",C,["mousePitch"]),this._add("mousePitch",A,["mouseRotate"]),t.interactive&&t.dragRotate&&n.dragRotate.enable();const F=(({enable:me,clickTolerance:X})=>{const ae=new hr({checkCorrectEvent:ge=>oe.mouseButton(ge)===0&&!ge.ctrlKey});return new ur({clickTolerance:X,move:(ge,ye)=>({around:ye,panDelta:ye.sub(ge)}),activateOnStart:!0,moveStateManager:ae,enable:me,assignEvents:So})})(t),Z=new ea(t,n);n.dragPan=new Dl(s,F,Z),this._add("mousePan",F),this._add("touchPan",Z,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&n.dragPan.enable(t.dragPan);const $=new Oo,H=new ts;n.touchZoomRotate=new ia(s,H,$,v),this._add("touchRotate",$,["touchPan","touchZoom"]),this._add("touchZoom",H,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&n.touchZoomRotate.enable(t.touchZoomRotate);const N=n.scrollZoom=new Ia(n,()=>this._triggerRenderFrame());this._add("scrollZoom",N,["mousePan"]),t.interactive&&t.scrollZoom&&n.scrollZoom.enable(t.scrollZoom);const ee=n.keyboard=new No(n);this._add("keyboard",ee),t.interactive&&t.keyboard&&n.keyboard.enable(),this._add("blockableMapEvent",new zn(n))}_add(t,n,s){this._handlers.push({handlerName:t,handler:n,allowed:s}),this._handlersById[t]=n}stop(t){if(!this._updatingCamera){for(const{handler:n}of this._handlers)n.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(const{handler:t}of this._handlers)if(t.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!dt(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,n,s){for(const a in t)if(a!==s&&(!n||n.indexOf(a)<0))return!0;return!1}_getMapTouches(t){const n=[];for(const s of t)this._el.contains(s.target)&&n.push(s);return n}mergeHandlerResult(t,n,s,a,u){if(!s)return;d.e(t,s);const g={handlerName:a,originalEvent:s.originalEvent||u};s.zoomDelta!==void 0&&(n.zoom=g),s.panDelta!==void 0&&(n.drag=g),s.pitchDelta!==void 0&&(n.pitch=g),s.bearingDelta!==void 0&&(n.rotate=g)}_applyChanges(){const t={},n={},s={};for(const[a,u,g]of this._changes)a.panDelta&&(t.panDelta=(t.panDelta||new d.P(0,0))._add(a.panDelta)),a.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+a.zoomDelta),a.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+a.bearingDelta),a.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+a.pitchDelta),a.around!==void 0&&(t.around=a.around),a.pinchAround!==void 0&&(t.pinchAround=a.pinchAround),a.noInertia&&(t.noInertia=a.noInertia),d.e(n,u),d.e(s,g);this._updateMapTransform(t,n,s),this._changes=[]}_updateMapTransform(t,n,s){const a=this._map,u=a._getTransformForUpdate(),g=a.terrain;if(!(ra(t)||g&&this._terrainMovement))return this._fireEvents(n,s,!0);let{panDelta:y,zoomDelta:v,bearingDelta:S,pitchDelta:C,around:A,pinchAround:F}=t;F!==void 0&&(A=F),a._stop(!0),A=A||a.transform.centerPoint;const Z=u.pointLocation(y?A.sub(y):A);S&&(u.bearing+=S),C&&(u.pitch+=C),v&&(u.zoom+=v),g?this._terrainMovement||!n.drag&&!n.zoom?n.drag&&this._terrainMovement?u.center=u.pointLocation(u.centerPoint.sub(y)):u.setLocationAtPoint(Z,A):(this._terrainMovement=!0,this._map._elevationFreeze=!0,u.setLocationAtPoint(Z,A),this._map.once("moveend",()=>{this._map._elevationFreeze=!1,this._terrainMovement=!1,u.recalculateZoom(a.terrain)})):u.setLocationAtPoint(Z,A),a._applyUpdatedTransform(u),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(n,s,!0)}_fireEvents(t,n,s){const a=dt(this._eventsInProgress),u=dt(t),g={};for(const C in t){const{originalEvent:A}=t[C];this._eventsInProgress[C]||(g[`${C}start`]=A),this._eventsInProgress[C]=t[C]}!a&&u&&this._fireEvent("movestart",u.originalEvent);for(const C in g)this._fireEvent(C,g[C]);u&&this._fireEvent("move",u.originalEvent);for(const C in t){const{originalEvent:A}=t[C];this._fireEvent(C,A)}const y={};let v;for(const C in this._eventsInProgress){const{handlerName:A,originalEvent:F}=this._eventsInProgress[C];this._handlersById[A].isActive()||(delete this._eventsInProgress[C],v=n[A]||F,y[`${C}end`]=v)}for(const C in y)this._fireEvent(C,y[C]);const S=dt(this._eventsInProgress);if(s&&(a||u)&&!S){this._updatingCamera=!0;const C=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),A=F=>F!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Sa("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class on extends d.E{constructor(t,n){super(),this._renderFrameCallback=()=>{const s=Math.min((ce.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(s)),s<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=n.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new d.M(this.transform.center.lng,this.transform.center.lat)}setCenter(t,n){return this.jumpTo({center:t},n)}panBy(t,n,s){return t=d.P.convert(t).mult(-1),this.panTo(this.transform.center,d.e({offset:t},n),s)}panTo(t,n,s){return this.easeTo(d.e({center:t},n),s)}getZoom(){return this.transform.zoom}setZoom(t,n){return this.jumpTo({zoom:t},n),this}zoomTo(t,n,s){return this.easeTo(d.e({zoom:t},n),s)}zoomIn(t,n){return this.zoomTo(this.getZoom()+1,t,n),this}zoomOut(t,n){return this.zoomTo(this.getZoom()-1,t,n),this}getBearing(){return this.transform.bearing}setBearing(t,n){return this.jumpTo({bearing:t},n),this}getPadding(){return this.transform.padding}setPadding(t,n){return this.jumpTo({padding:t},n),this}rotateTo(t,n,s){return this.easeTo(d.e({bearing:t},n),s)}resetNorth(t,n){return this.rotateTo(0,d.e({duration:1e3},t),n),this}resetNorthPitch(t,n){return this.easeTo(d.e({bearing:0,pitch:0,duration:1e3},t),n),this}snapToNorth(t,n){return Math.abs(this.getBearing()){if(this._zooming&&(a.zoom=d.z.number(u,N,xe)),this._rotating&&(a.bearing=d.z.number(g,S,xe)),this._pitching&&(a.pitch=d.z.number(y,C,xe)),this._padding&&(a.interpolatePadding(v,A,xe),Z=a.centerPoint.add(F)),this.terrain&&!t.freezeElevation&&this._updateElevation(xe),ae)a.setLocationAtPoint(ae,ge);else{const Pe=a.zoomScale(a.zoom-u),Ae=N>u?Math.min(2,X):Math.max(.5,X),Fe=Math.pow(Ae,1-xe),Ne=a.unproject(ee.add(me.mult(xe*Fe)).mult(Pe));a.setLocationAtPoint(a.renderWorldCopies?Ne.wrap():Ne,Z)}this._applyUpdatedTransform(a),this._fireMoveEvents(n)},xe=>{this.terrain&&this._finalizeElevation(),this._afterEase(n,xe)},t),this}_prepareEase(t,n,s={}){this._moving=!0,n||s.moving||this.fire(new d.k("movestart",t)),this._zooming&&!s.zooming&&this.fire(new d.k("zoomstart",t)),this._rotating&&!s.rotating&&this.fire(new d.k("rotatestart",t)),this._pitching&&!s.pitching&&this.fire(new d.k("pitchstart",t))}_prepareElevation(t){this._elevationCenter=t,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(t,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(t){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const n=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&n!==this._elevationTarget){const s=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(s-(n-(s*t+this._elevationStart))/(1-t)),this._elevationTarget=n}this.transform.elevation=d.z.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_applyUpdatedTransform(t){if(!this.transformCameraUpdate)return;const n=t.clone(),{center:s,zoom:a,pitch:u,bearing:g,elevation:y}=this.transformCameraUpdate(n);s&&(n.center=s),a!==void 0&&(n.zoom=a),u!==void 0&&(n.pitch=u),g!==void 0&&(n.bearing=g),y!==void 0&&(n.elevation=y),this.transform.apply(n)}_fireMoveEvents(t){this.fire(new d.k("move",t)),this._zooming&&this.fire(new d.k("zoom",t)),this._rotating&&this.fire(new d.k("rotate",t)),this._pitching&&this.fire(new d.k("pitch",t))}_afterEase(t,n){if(this._easeId&&n&&this._easeId===n)return;delete this._easeId;const s=this._zooming,a=this._rotating,u=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,s&&this.fire(new d.k("zoomend",t)),a&&this.fire(new d.k("rotateend",t)),u&&this.fire(new d.k("pitchend",t)),this.fire(new d.k("moveend",t))}flyTo(t,n){var s;if(!t.essential&&ce.prefersReducedMotion){const jt=d.L(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(jt,n)}this.stop(),t=d.e({offset:[0,0],speed:1.2,curve:1.42,easing:d.b7},t);const a=this._getTransformForUpdate(),u=this.getZoom(),g=this.getBearing(),y=this.getPitch(),v=this.getPadding(),S="bearing"in t?this._normalizeBearing(t.bearing,g):g,C="pitch"in t?+t.pitch:y,A="padding"in t?t.padding:a.padding,F=d.P.convert(t.offset);let Z=a.centerPoint.add(F);const $=a.pointLocation(Z),{center:H,zoom:N}=a.getConstrained(d.M.convert(t.center||$),(s=t.zoom)!==null&&s!==void 0?s:u);this._normalizeCenter(H);const ee=a.zoomScale(N-u),me=a.project($),X=a.project(H).sub(me);let ae=t.curve;const ge=Math.max(a.width,a.height),ye=ge/ee,xe=X.mag();if("minZoom"in t){const jt=d.ac(Math.min(t.minZoom,u,N),a.minZoom,a.maxZoom),vt=ge/a.zoomScale(jt-u);ae=Math.sqrt(vt/xe*2)}const Pe=ae*ae;function Ae(jt){const vt=(ye*ye-ge*ge+(jt?-1:1)*Pe*Pe*xe*xe)/(2*(jt?ye:ge)*Pe*xe);return Math.log(Math.sqrt(vt*vt+1)-vt)}function Fe(jt){return(Math.exp(jt)-Math.exp(-jt))/2}function Ne(jt){return(Math.exp(jt)+Math.exp(-jt))/2}const Et=Ae(!1);let $e=function(jt){return Ne(Et)/Ne(Et+ae*jt)},pt=function(jt){return ge*((Ne(Et)*(Fe(vt=Et+ae*jt)/Ne(vt))-Fe(Et))/Pe)/xe;var vt},Ct=(Ae(!0)-Et)/ae;if(Math.abs(xe)<1e-6||!isFinite(Ct)){if(Math.abs(ge-ye)<1e-6)return this.easeTo(t,n);const jt=yet.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=g!==S,this._pitching=C!==y,this._padding=!a.isPaddingEqual(A),this._prepareEase(n,!1),this.terrain&&this._prepareElevation(H),this._ease(jt=>{const vt=jt*Ct,Pt=1/$e(vt);a.zoom=jt===1?N:u+a.scaleZoom(Pt),this._rotating&&(a.bearing=d.z.number(g,S,jt)),this._pitching&&(a.pitch=d.z.number(y,C,jt)),this._padding&&(a.interpolatePadding(v,A,jt),Z=a.centerPoint.add(F)),this.terrain&&!t.freezeElevation&&this._updateElevation(jt);const Dt=jt===1?H:a.unproject(me.add(X.mult(pt(vt))).mult(Pt));a.setLocationAtPoint(a.renderWorldCopies?Dt.wrap():Dt,Z),this._applyUpdatedTransform(a),this._fireMoveEvents(n)},()=>{this.terrain&&this._finalizeElevation(),this._afterEase(n)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,n){if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const s=this._onEaseEnd;delete this._onEaseEnd,s.call(this,n)}if(!t){const s=this.handlers;s&&s.stop(!1)}return this}_ease(t,n,s){s.animate===!1||s.duration===0?(t(1),n()):(this._easeStart=ce.now(),this._easeOptions=s,this._onEaseFrame=t,this._onEaseEnd=n,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,n){t=d.b1(t,-180,180);const s=Math.abs(t-n);return Math.abs(t-360-n)180?-360:s<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(d.M.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}const Xa={compact:!0,customAttribution:'MapLibre'};class Jn{constructor(t=Xa){this._toggleAttribution=()=>{this._container.classList.contains("maplibregl-compact")&&(this._container.classList.contains("maplibregl-compact-show")?(this._container.setAttribute("open",""),this._container.classList.remove("maplibregl-compact-show")):(this._container.classList.add("maplibregl-compact-show"),this._container.removeAttribute("open")))},this._updateData=n=>{!n||n.sourceDataType!=="metadata"&&n.sourceDataType!=="visibility"&&n.dataType!=="style"&&n.type!=="terrain"||this._updateAttributions()},this._updateCompact=()=>{this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact===!1?this._container.setAttribute("open",""):this._container.classList.contains("maplibregl-compact")||this._container.classList.contains("maplibregl-attrib-empty")||(this._container.setAttribute("open",""),this._container.classList.add("maplibregl-compact","maplibregl-compact-show")):(this._container.setAttribute("open",""),this._container.classList.contains("maplibregl-compact")&&this._container.classList.remove("maplibregl-compact","maplibregl-compact-show"))},this._updateCompactMinimize=()=>{this._container.classList.contains("maplibregl-compact")&&this._container.classList.contains("maplibregl-compact-show")&&this._container.classList.remove("maplibregl-compact-show")},this.options=t}getDefaultPosition(){return"bottom-right"}onAdd(t){return this._map=t,this._compact=this.options.compact,this._container=oe.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=oe.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=oe.create("div","maplibregl-ctrl-attrib-inner",this._container),this._updateAttributions(),this._updateCompact(),this._map.on("styledata",this._updateData),this._map.on("sourcedata",this._updateData),this._map.on("terrain",this._updateData),this._map.on("resize",this._updateCompact),this._map.on("drag",this._updateCompactMinimize),this._container}onRemove(){oe.remove(this._container),this._map.off("styledata",this._updateData),this._map.off("sourcedata",this._updateData),this._map.off("terrain",this._updateData),this._map.off("resize",this._updateCompact),this._map.off("drag",this._updateCompactMinimize),this._map=void 0,this._compact=void 0,this._attribHTML=void 0}_setElementTitle(t,n){const s=this._map._getUIString(`AttributionControl.${n}`);t.title=s,t.setAttribute("aria-label",s)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(a=>typeof a!="string"?"":a)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){const a=this._map.style.stylesheet;this.styleOwner=a.owner,this.styleId=a.id}const n=this._map.style.sourceCaches;for(const a in n){const u=n[a];if(u.used||u.usedForTerrain){const g=u.getSource();g.attribution&&t.indexOf(g.attribution)<0&&t.push(g.attribution)}}t=t.filter(a=>String(a).trim()),t.sort((a,u)=>a.length-u.length),t=t.filter((a,u)=>{for(let g=u+1;g=0)return!1;return!0});const s=t.join(" | ");s!==this._attribHTML&&(this._attribHTML=s,t.length?(this._innerContainer.innerHTML=s,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Rl{constructor(t={}){this._updateCompact=()=>{const n=this._container.children;if(n.length){const s=n[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&s.classList.add("maplibregl-compact"):s.classList.remove("maplibregl-compact")}},this.options=t}getDefaultPosition(){return"bottom-left"}onAdd(t){this._map=t,this._compact=this.options&&this.options.compact,this._container=oe.create("div","maplibregl-ctrl");const n=oe.create("a","maplibregl-ctrl-logo");return n.target="_blank",n.rel="noopener nofollow",n.href="https://maplibre.org/",n.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),n.setAttribute("rel","noopener nofollow"),this._container.appendChild(n),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){oe.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class na{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){const n=++this._id;return this._queue.push({callback:t,id:n,cancelled:!1}),n}remove(t){const n=this._currentlyRunning,s=n?this._queue.concat(n):this._queue;for(const a of s)if(a.id===t)return void(a.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const n=this._currentlyRunning=this._queue;this._queue=[];for(const s of n)if(!s.cancelled&&(s.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Ui=d.X([{name:"a_pos3d",type:"Int16",components:3}]);class Yi extends d.E{constructor(t){super(),this.sourceCache=t,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,t.usedForTerrain=!0,t.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(t,n){this.sourceCache.update(t,n),this._renderableTilesKeys=[];const s={};for(const a of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:n}))s[a.key]=!0,this._renderableTilesKeys.push(a.key),this._tiles[a.key]||(a.posMatrix=new Float64Array(16),d.aN(a.posMatrix,0,d.W,0,d.W,0,1),this._tiles[a.key]=new ar(a,this.tileSize));for(const a in this._tiles)s[a]||delete this._tiles[a]}freeRtt(t){for(const n in this._tiles){const s=this._tiles[n];(!t||s.tileID.equals(t)||s.tileID.isChildOf(t)||t.isChildOf(s.tileID))&&(s.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){const n={};for(const s of this._renderableTilesKeys){const a=this._tiles[s].tileID;if(a.canonical.equals(t.canonical)){const u=t.clone();u.posMatrix=new Float64Array(16),d.aN(u.posMatrix,0,d.W,0,d.W,0,1),n[s]=u}else if(a.canonical.isChildOf(t.canonical)){const u=t.clone();u.posMatrix=new Float64Array(16);const g=a.canonical.z-t.canonical.z,y=a.canonical.x-(a.canonical.x>>g<>g<>g;d.aN(u.posMatrix,0,S,0,S,0,1),d.H(u.posMatrix,u.posMatrix,[-y*S,-v*S,0]),n[s]=u}else if(t.canonical.isChildOf(a.canonical)){const u=t.clone();u.posMatrix=new Float64Array(16);const g=t.canonical.z-a.canonical.z,y=t.canonical.x-(t.canonical.x>>g<>g<>g;d.aN(u.posMatrix,0,d.W,0,d.W,0,1),d.H(u.posMatrix,u.posMatrix,[y*S,v*S,0]),d.J(u.posMatrix,u.posMatrix,[1/2**g,1/2**g,0]),n[s]=u}}return n}getSourceTile(t,n){const s=this.sourceCache._source;let a=t.overscaledZ-this.deltaZoom;if(a>s.maxzoom&&(a=s.maxzoom),a=s.minzoom&&(!u||!u.dem);)u=this.sourceCache.getTileByID(t.scaledTo(a--).key);return u}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(n=>n.timeAdded>=t)}}class Fl{constructor(t,n,s){this.painter=t,this.sourceCache=new Yi(n),this.options=s,this.exaggeration=typeof s.exaggeration=="number"?s.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,n,s,a=d.W){var u;if(!(n>=0&&n=0&&st.canonical.z&&(t.canonical.z>=a?u=t.canonical.z-a:d.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const g=t.canonical.x-(t.canonical.x>>u<>u<>8<<4|u>>8,n[g+3]=0;const s=new d.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(n.buffer)),a=new St(t,s,t.gl.RGBA,{premultiply:!1});return a.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=a,a}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);const n=new Uint8Array(4),s=this.painter.context,a=s.gl,u=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),g=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),y=Math.round(this.painter.height/devicePixelRatio);s.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),a.readPixels(u,y-g-1,1,1,a.RGBA,a.UNSIGNED_BYTE,n),s.bindFramebuffer.set(null);const v=n[0]+(n[2]>>4<<8),S=n[1]+((15&n[2])<<8),C=this.coordsIndex[255-n[3]],A=C&&this.sourceCache.getTileByID(C);if(!A)return null;const F=this._coordsTextureSize,Z=(1<t.id!==n),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(const n of this._recentlyUsed)if(!this._objects[n].inUse)return this._objects[n];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(const t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length!t.inUse)===!1}}const Eo={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ja{constructor(t,n){this.painter=t,this.terrain=n,this.pool=new oa(t.context,30,n.sourceCache.tileSize*n.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,n){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(s=>!t._layers[s].isHidden(n)),this._coordsDescendingInv={};for(const s in t.sourceCaches){this._coordsDescendingInv[s]={};const a=t.sourceCaches[s].getVisibleCoordinates();for(const u of a){const g=this.terrain.sourceCache.getTerrainCoords(u);for(const y in g)this._coordsDescendingInv[s][y]||(this._coordsDescendingInv[s][y]=[]),this._coordsDescendingInv[s][y].push(g[y])}}this._coordsDescendingInvStr={};for(const s of t._order){const a=t._layers[s],u=a.source;if(Eo[a.type]&&!this._coordsDescendingInvStr[u]){this._coordsDescendingInvStr[u]={};for(const g in this._coordsDescendingInv[u])this._coordsDescendingInvStr[u][g]=this._coordsDescendingInv[u][g].map(y=>y.key).sort().join()}}for(const s of this._renderableTiles)for(const a in this._coordsDescendingInvStr){const u=this._coordsDescendingInvStr[a][s.tileID.key];u&&u!==s.rttCoords[a]&&(s.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;const n=t.type,s=this.painter,a=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Eo[n]&&(this._prevType&&Eo[this._prevType]||this._stacks.push([]),this._prevType=n,this._stacks[this._stacks.length-1].push(t.id),!a))return!0;if(Eo[this._prevType]||Eo[n]&&a){this._prevType=n;const u=this._stacks.length-1,g=this._stacks[u]||[];for(const y of this._renderableTiles){if(this.pool.isFull()&&(ks(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(y),y.rtt[u]){const S=this.pool.getObjectForId(y.rtt[u].id);if(S.stamp===y.rtt[u].stamp){this.pool.useObject(S);continue}}const v=this.pool.getOrCreateFreeObject();this.pool.useObject(v),this.pool.stampObject(v),y.rtt[u]={id:v.id,stamp:v.stamp},s.context.bindFramebuffer.set(v.fbo.framebuffer),s.context.clear({color:d.aO.transparent,stencil:0}),s.currentStencilSource=void 0;for(let S=0;S{c.touchstart=c.dragStart,c.touchmoveWindow=c.dragMove,c.touchend=c.dragEnd},Qa={showCompass:!0,showZoom:!0,visualizePitch:!1};class el{constructor(t,n,s=!1){this.mousedown=g=>{this.startMouse(d.e({},g,{ctrlKey:!0,preventDefault:()=>g.preventDefault()}),oe.mousePos(this.element,g)),oe.addEventListener(window,"mousemove",this.mousemove),oe.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=g=>{this.moveMouse(g,oe.mousePos(this.element,g))},this.mouseup=g=>{this.mouseRotate.dragEnd(g),this.mousePitch&&this.mousePitch.dragEnd(g),this.offTemp()},this.touchstart=g=>{g.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=oe.touchPos(this.element,g.targetTouches)[0],this.startTouch(g,this._startPos),oe.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),oe.addEventListener(window,"touchend",this.touchend))},this.touchmove=g=>{g.targetTouches.length!==1?this.reset():(this._lastPos=oe.touchPos(this.element,g.targetTouches)[0],this.moveTouch(g,this._lastPos))},this.touchend=g=>{g.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const a=t.dragRotate._mouseRotate.getClickTolerance(),u=t.dragRotate._mousePitch.getClickTolerance();this.element=n,this.mouseRotate=yn({clickTolerance:a,enable:!0}),this.touchRotate=(({enable:g,clickTolerance:y,bearingDegreesPerPixelMoved:v=.8})=>{const S=new Ye;return new ur({clickTolerance:y,move:(C,A)=>({bearingDelta:(A.x-C.x)*v}),moveStateManager:S,enable:g,assignEvents:Ta})})({clickTolerance:a,enable:!0}),this.map=t,s&&(this.mousePitch=nn({clickTolerance:u,enable:!0}),this.touchPitch=(({enable:g,clickTolerance:y,pitchDegreesPerPixelMoved:v=-.5})=>{const S=new Ye;return new ur({clickTolerance:y,move:(C,A)=>({pitchDelta:(A.y-C.y)*v}),moveStateManager:S,enable:g,assignEvents:Ta})})({clickTolerance:u,enable:!0})),oe.addEventListener(n,"mousedown",this.mousedown),oe.addEventListener(n,"touchstart",this.touchstart,{passive:!1}),oe.addEventListener(n,"touchcancel",this.reset)}startMouse(t,n){this.mouseRotate.dragStart(t,n),this.mousePitch&&this.mousePitch.dragStart(t,n),oe.disableDrag()}startTouch(t,n){this.touchRotate.dragStart(t,n),this.touchPitch&&this.touchPitch.dragStart(t,n),oe.disableDrag()}moveMouse(t,n){const s=this.map,{bearingDelta:a}=this.mouseRotate.dragMove(t,n)||{};if(a&&s.setBearing(s.getBearing()+a),this.mousePitch){const{pitchDelta:u}=this.mousePitch.dragMove(t,n)||{};u&&s.setPitch(s.getPitch()+u)}}moveTouch(t,n){const s=this.map,{bearingDelta:a}=this.touchRotate.dragMove(t,n)||{};if(a&&s.setBearing(s.getBearing()+a),this.touchPitch){const{pitchDelta:u}=this.touchPitch.dragMove(t,n)||{};u&&s.setPitch(s.getPitch()+u)}}off(){const t=this.element;oe.removeEventListener(t,"mousedown",this.mousedown),oe.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),oe.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),oe.removeEventListener(window,"touchend",this.touchend),oe.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){oe.enableDrag(),oe.removeEventListener(window,"mousemove",this.mousemove),oe.removeEventListener(window,"mouseup",this.mouseup),oe.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),oe.removeEventListener(window,"touchend",this.touchend)}}let Co;function Ea(c,t,n){const s=new d.M(c.lng,c.lat);if(c=new d.M(c.lng,c.lat),t){const a=new d.M(c.lng-360,c.lat),u=new d.M(c.lng+360,c.lat),g=n.locationPoint(c).distSqr(t);n.locationPoint(a).distSqr(t)180;){const a=n.locationPoint(c);if(a.x>=0&&a.y>=0&&a.x<=n.width&&a.y<=n.height)break;c.lng>n.center.lng?c.lng-=360:c.lng+=360}return c.lng!==s.lng&&n.locationPoint(c).y>n.height/2-n.getHorizon()?c:s}const aa={center:"translate(-50%,-50%)",top:"translate(-50%,0)","top-left":"translate(0,0)","top-right":"translate(-100%,0)",bottom:"translate(-50%,-100%)","bottom-left":"translate(0,-100%)","bottom-right":"translate(-100%,-100%)",left:"translate(0,-50%)",right:"translate(-100%,-50%)"};function Ca(c,t,n){const s=c.classList;for(const a in aa)s.remove(`maplibregl-${n}-anchor-${a}`);s.add(`maplibregl-${n}-anchor-${t}`)}class la extends d.E{constructor(t){if(super(),this._onKeyPress=n=>{const s=n.code,a=n.charCode||n.keyCode;s!=="Space"&&s!=="Enter"&&a!==32&&a!==13||this.togglePopup()},this._onMapClick=n=>{const s=n.originalEvent.target,a=this._element;this._popup&&(s===a||a.contains(s))&&this.togglePopup()},this._update=n=>{var s;if(!this._map)return;const a=this._map.loaded()&&!this._map.isMoving();((n==null?void 0:n.type)==="terrain"||(n==null?void 0:n.type)==="render"&&!a)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Ea(this._lngLat,this._flatPos,this._map.transform):(s=this._lngLat)===null||s===void 0?void 0:s.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let u="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?u=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(u=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let g="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?g="rotateX(0deg)":this._pitchAlignment==="map"&&(g=`rotateX(${this._map.getPitch()}deg)`),n&&n.type!=="moveend"||(this._pos=this._pos.round()),oe.setTransform(this._element,`${aa[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${g} ${u}`),ce.frameAsync(new AbortController).then(()=>{this._updateOpacity(n&&n.type==="moveend")}).catch(()=>{})},this._onMove=n=>{if(!this._isDragging){const s=this._clickTolerance||this._map._clickTolerance;this._isDragging=n.point.dist(this._pointerdownPos)>=s}this._isDragging&&(this._pos=n.point.sub(this._positionDelta),this._lngLat=this._map.unproject(this._pos),this.setLngLat(this._lngLat),this._element.style.pointerEvents="none",this._state==="pending"&&(this._state="active",this.fire(new d.k("dragstart"))),this.fire(new d.k("drag")))},this._onUp=()=>{this._element.style.pointerEvents="auto",this._positionDelta=null,this._pointerdownPos=null,this._isDragging=!1,this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),this._state==="active"&&this.fire(new d.k("dragend")),this._state="inactive"},this._addDragHandler=n=>{this._element.contains(n.originalEvent.target)&&(n.preventDefault(),this._positionDelta=n.point.sub(this._pos).add(this._offset),this._pointerdownPos=n.point,this._state="pending",this._map.on("mousemove",this._onMove),this._map.on("touchmove",this._onMove),this._map.once("mouseup",this._onUp),this._map.once("touchend",this._onUp))},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"?t.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(t==null?void 0:t.opacity,t==null?void 0:t.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=d.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=oe.create("div"),this._element.setAttribute("aria-label","Map marker");const n=oe.createNS("http://www.w3.org/2000/svg","svg"),s=41,a=27;n.setAttributeNS(null,"display","block"),n.setAttributeNS(null,"height",`${s}px`),n.setAttributeNS(null,"width",`${a}px`),n.setAttributeNS(null,"viewBox",`0 0 ${a} ${s}`);const u=oe.createNS("http://www.w3.org/2000/svg","g");u.setAttributeNS(null,"stroke","none"),u.setAttributeNS(null,"stroke-width","1"),u.setAttributeNS(null,"fill","none"),u.setAttributeNS(null,"fill-rule","evenodd");const g=oe.createNS("http://www.w3.org/2000/svg","g");g.setAttributeNS(null,"fill-rule","nonzero");const y=oe.createNS("http://www.w3.org/2000/svg","g");y.setAttributeNS(null,"transform","translate(3.0, 29.0)"),y.setAttributeNS(null,"fill","#000000");const v=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ee of v){const me=oe.createNS("http://www.w3.org/2000/svg","ellipse");me.setAttributeNS(null,"opacity","0.04"),me.setAttributeNS(null,"cx","10.5"),me.setAttributeNS(null,"cy","5.80029008"),me.setAttributeNS(null,"rx",ee.rx),me.setAttributeNS(null,"ry",ee.ry),y.appendChild(me)}const S=oe.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"fill",this._color);const C=oe.createNS("http://www.w3.org/2000/svg","path");C.setAttributeNS(null,"d","M27,13.5 C27,19.074644 20.250001,27.000002 14.75,34.500002 C14.016665,35.500004 12.983335,35.500004 12.25,34.500002 C6.7499993,27.000002 0,19.222562 0,13.5 C0,6.0441559 6.0441559,0 13.5,0 C20.955844,0 27,6.0441559 27,13.5 Z"),S.appendChild(C);const A=oe.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"opacity","0.25"),A.setAttributeNS(null,"fill","#000000");const F=oe.createNS("http://www.w3.org/2000/svg","path");F.setAttributeNS(null,"d","M13.5,0 C6.0441559,0 0,6.0441559 0,13.5 C0,19.222562 6.7499993,27 12.25,34.5 C13,35.522727 14.016664,35.500004 14.75,34.5 C20.250001,27 27,19.074644 27,13.5 C27,6.0441559 20.955844,0 13.5,0 Z M13.5,1 C20.415404,1 26,6.584596 26,13.5 C26,15.898657 24.495584,19.181431 22.220703,22.738281 C19.945823,26.295132 16.705119,30.142167 13.943359,33.908203 C13.743445,34.180814 13.612715,34.322738 13.5,34.441406 C13.387285,34.322738 13.256555,34.180814 13.056641,33.908203 C10.284481,30.127985 7.4148684,26.314159 5.015625,22.773438 C2.6163816,19.232715 1,15.953538 1,13.5 C1,6.584596 6.584596,1 13.5,1 Z"),A.appendChild(F);const Z=oe.createNS("http://www.w3.org/2000/svg","g");Z.setAttributeNS(null,"transform","translate(6.0, 7.0)"),Z.setAttributeNS(null,"fill","#FFFFFF");const $=oe.createNS("http://www.w3.org/2000/svg","g");$.setAttributeNS(null,"transform","translate(8.0, 8.0)");const H=oe.createNS("http://www.w3.org/2000/svg","circle");H.setAttributeNS(null,"fill","#000000"),H.setAttributeNS(null,"opacity","0.25"),H.setAttributeNS(null,"cx","5.5"),H.setAttributeNS(null,"cy","5.5"),H.setAttributeNS(null,"r","5.4999962");const N=oe.createNS("http://www.w3.org/2000/svg","circle");N.setAttributeNS(null,"fill","#FFFFFF"),N.setAttributeNS(null,"cx","5.5"),N.setAttributeNS(null,"cy","5.5"),N.setAttributeNS(null,"r","5.4999962"),$.appendChild(H),$.appendChild(N),g.appendChild(y),g.appendChild(S),g.appendChild(A),g.appendChild(Z),g.appendChild($),n.appendChild(g),n.setAttributeNS(null,"height",s*this._scale+"px"),n.setAttributeNS(null,"width",a*this._scale+"px"),this._element.appendChild(n),this._offset=d.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",n=>{n.preventDefault()}),this._element.addEventListener("mousedown",n=>{n.preventDefault()}),Ca(this._element,this._anchor,"marker"),t&&t.className)for(const n of t.className.split(" "))this._element.classList.add(n);this._popup=null}addTo(t){return this.remove(),this._map=t,t.getCanvasContainer().appendChild(this._element),t.on("move",this._update),t.on("moveend",this._update),t.on("terrain",this._update),this.setDraggable(this._draggable),this._update(),this._map.on("click",this._onMapClick),this}remove(){return this._opacityTimeout&&(clearTimeout(this._opacityTimeout),delete this._opacityTimeout),this._map&&(this._map.off("click",this._onMapClick),this._map.off("move",this._update),this._map.off("moveend",this._update),this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler),this._map.off("mouseup",this._onUp),this._map.off("touchend",this._onUp),this._map.off("mousemove",this._onMove),this._map.off("touchmove",this._onMove),delete this._map),oe.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=d.M.convert(t),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(t){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),t){if(!("offset"in t.options)){const a=Math.abs(13.5)/Math.SQRT2;t.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[a,-1*(38.1-13.5+a)],"bottom-right":[-a,-1*(38.1-13.5+a)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=t,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}getPopup(){return this._popup}togglePopup(){const t=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:t?(t.isOpen()?t.remove():(t.setLngLat(this._lngLat),t.addTo(this._map)),this):this}_updateOpacity(t=!1){var n,s;if(!(!((n=this._map)===null||n===void 0)&&n.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(t)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const a=this._map,u=a.terrain.depthAtPoint(this._pos),g=a.terrain.getElevationForLngLatZoom(this._lngLat,a.transform.tileZoom);if(a.transform.lngLatToCameraDepth(this._lngLat,g)-u<.006)return void(this._element.style.opacity=this._opacity);const y=-this._offset.y/a.transform._pixelPerMeter,v=Math.sin(a.getPitch()*Math.PI/180)*y,S=a.terrain.depthAtPoint(new d.P(this._pos.x,this._pos.y-this._offset.y)),C=a.transform.lngLatToCameraDepth(this._lngLat,g+v)-S>.006;!((s=this._popup)===null||s===void 0)&&s.isOpen()&&C&&this._popup.remove(),this._element.style.opacity=C?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=d.P.convert(t),this._update(),this}addClassName(t){this._element.classList.add(t)}removeClassName(t){this._element.classList.remove(t)}toggleClassName(t){return this._element.classList.toggle(t)}setDraggable(t){return this._draggable=!!t,this._map&&(t?(this._map.on("mousedown",this._addDragHandler),this._map.on("touchstart",this._addDragHandler)):(this._map.off("mousedown",this._addDragHandler),this._map.off("touchstart",this._addDragHandler))),this}isDraggable(){return this._draggable}setRotation(t){return this._rotation=t||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(t){return this._rotationAlignment=t||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(t){return this._pitchAlignment=t&&t!=="auto"?t:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(t,n){return t===void 0&&n===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),n!==void 0&&(this._opacityWhenCovered=n),this._map&&this._updateOpacity(!0),this}}const Ma={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let zs=0,rs=!1;const Aa={maxWidth:100,unit:"metric"};function Pa(c,t,n){const s=n&&n.maxWidth||100,a=c._container.clientHeight/2,u=c.unproject([0,a]),g=c.unproject([s,a]),y=u.distanceTo(g);if(n&&n.unit==="imperial"){const v=3.2808*y;v>5280?ns(t,s,v/5280,c._getUIString("ScaleControl.Miles")):ns(t,s,v,c._getUIString("ScaleControl.Feet"))}else n&&n.unit==="nautical"?ns(t,s,y/1852,c._getUIString("ScaleControl.NauticalMiles")):y>=1e3?ns(t,s,y/1e3,c._getUIString("ScaleControl.Kilometers")):ns(t,s,y,c._getUIString("ScaleControl.Meters"))}function ns(c,t,n,s){const a=function(u){const g=Math.pow(10,`${Math.floor(u)}`.length-1);let y=u/g;return y=y>=10?10:y>=5?5:y>=3?3:y>=2?2:y>=1?1:function(v){const S=Math.pow(10,Math.ceil(-Math.log(v)/Math.LN10));return Math.round(v*S)/S}(y),g*y}(n);c.style.width=t*(a/n)+"px",c.innerHTML=`${a} ${s}`}const tl={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},il=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function ka(c){if(c){if(typeof c=="number"){const t=Math.round(Math.abs(c)/Math.SQRT2);return{center:new d.P(0,0),top:new d.P(0,c),"top-left":new d.P(t,t),"top-right":new d.P(-t,t),bottom:new d.P(0,-c),"bottom-left":new d.P(t,-t),"bottom-right":new d.P(-t,-t),left:new d.P(c,0),right:new d.P(-c,0)}}if(c instanceof d.P||Array.isArray(c)){const t=d.P.convert(c);return{center:t,top:t,"top-left":t,"top-right":t,bottom:t,"bottom-left":t,"bottom-right":t,left:t,right:t}}return{center:d.P.convert(c.center||[0,0]),top:d.P.convert(c.top||[0,0]),"top-left":d.P.convert(c["top-left"]||[0,0]),"top-right":d.P.convert(c["top-right"]||[0,0]),bottom:d.P.convert(c.bottom||[0,0]),"bottom-left":d.P.convert(c["bottom-left"]||[0,0]),"bottom-right":d.P.convert(c["bottom-right"]||[0,0]),left:d.P.convert(c.left||[0,0]),right:d.P.convert(c.right||[0,0])}}return ka(new d.P(0,0))}const Bl=Se;M.AJAXError=d.be,M.Evented=d.E,M.LngLat=d.M,M.MercatorCoordinate=d.Y,M.Point=d.P,M.addProtocol=d.bf,M.config=d.a,M.removeProtocol=d.bg,M.AttributionControl=Jn,M.BoxZoomHandler=Nt,M.CanvasSource=Cn,M.CooperativeGesturesHandler=at,M.DoubleClickZoomHandler=Ha,M.DragPanHandler=Dl,M.DragRotateHandler=Xn,M.EdgeInsets=ct,M.FullscreenControl=class extends d.E{constructor(c={}){super(),this._onFullscreenChange=()=>{var t;let n=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=n==null?void 0:n.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)n=n.shadowRoot.fullscreenElement;n===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,c&&c.container&&(c.container instanceof HTMLElement?this._container=c.container:d.w("Full screen control 'container' must be a DOM element.")),"onfullscreenchange"in document?this._fullscreenchange="fullscreenchange":"onmozfullscreenchange"in document?this._fullscreenchange="mozfullscreenchange":"onwebkitfullscreenchange"in document?this._fullscreenchange="webkitfullscreenchange":"onmsfullscreenchange"in document&&(this._fullscreenchange="MSFullscreenChange")}onAdd(c){return this._map=c,this._container||(this._container=this._map.getContainer()),this._controlContainer=oe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){oe.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const c=this._fullscreenButton=oe.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);oe.create("span","maplibregl-ctrl-icon",c).setAttribute("aria-hidden","true"),c.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const c=this._getTitle();this._fullscreenButton.setAttribute("aria-label",c),this._fullscreenButton.title=c}_getTitle(){return this._map._getUIString(this._isFullscreen()?"FullscreenControl.Exit":"FullscreenControl.Enter")}_isFullscreen(){return this._fullscreen}_handleFullscreenChange(){this._fullscreen=!this._fullscreen,this._fullscreenButton.classList.toggle("maplibregl-ctrl-shrink"),this._fullscreenButton.classList.toggle("maplibregl-ctrl-fullscreen"),this._updateTitle(),this._fullscreen?(this.fire(new d.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new d.k("fullscreenend")),this._prevCooperativeGesturesEnabled&&this._map.cooperativeGestures.enable())}_exitFullscreen(){window.document.exitFullscreen?window.document.exitFullscreen():window.document.mozCancelFullScreen?window.document.mozCancelFullScreen():window.document.msExitFullscreen?window.document.msExitFullscreen():window.document.webkitCancelFullScreen?window.document.webkitCancelFullScreen():this._togglePseudoFullScreen()}_requestFullscreen(){this._container.requestFullscreen?this._container.requestFullscreen():this._container.mozRequestFullScreen?this._container.mozRequestFullScreen():this._container.msRequestFullscreen?this._container.msRequestFullscreen():this._container.webkitRequestFullscreen?this._container.webkitRequestFullscreen():this._togglePseudoFullScreen()}_togglePseudoFullScreen(){this._container.classList.toggle("maplibregl-pseudo-fullscreen"),this._handleFullscreenChange(),this._map.resize()}},M.GeoJSONSource=En,M.GeolocateControl=class extends d.E{constructor(c){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new d.k("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("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"BACKGROUND":case"BACKGROUND_ERROR":this._watchState="BACKGROUND",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background");break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}this.options.showUserLocation&&this._watchState!=="OFF"&&this._updateMarker(t),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(t),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new d.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{const n=new d.M(t.coords.longitude,t.coords.latitude),s=t.coords.accuracy,a=this._map.getBearing(),u=d.e({bearing:a},this.options.fitBoundsOptions),g=Yt.fromLngLat(n,s);this._map.fitBounds(g,u,{geolocateSource:!0})},this._updateMarker=t=>{if(t){const n=new d.M(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()},this._onZoom=()=>{this.options.showUserLocation&&this.options.showAccuracyCircle&&this._updateCircleRadius()},this._onError=t=>{if(this._map){if(this.options.trackUserLocation)if(t.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&rs)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new d.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=t=>{if(this._map){if(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=oe.create("button","maplibregl-ctrl-geolocate",this._container),oe.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",t===!1){d.w("Geolocation support is not available so the GeolocateControl will be disabled.");const n=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}else{const n=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.title=n,this._geolocateButton.setAttribute("aria-label",n)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=oe.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new la({element:this._dotElement}),this._circleElement=oe.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new la({element:this._circleElement,pitchAlignment:"map"}),this.options.trackUserLocation&&(this._watchState="OFF"),this._map.on("zoom",this._onZoom)),this._geolocateButton.addEventListener("click",()=>this.trigger()),this._setup=!0,this.options.trackUserLocation&&this._map.on("movestart",n=>{n.geolocateSource||this._watchState!=="ACTIVE_LOCK"||n.originalEvent&&n.originalEvent.type==="resize"||(this._watchState="BACKGROUND",this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this.fire(new d.k("trackuserlocationend")))})}},this.options=d.e({},Ma,c)}onAdd(c){return this._map=c,this._container=oe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),function(){return d._(this,arguments,void 0,function*(t=!1){if(Co!==void 0&&!t)return Co;if(window.navigator.permissions===void 0)return Co=!!window.navigator.geolocation,Co;try{Co=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Co=!!window.navigator.geolocation}return Co})}().then(t=>this._setupUI(t)),this._container}onRemove(){this._geolocationWatchID!==void 0&&(window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0),this.options.showUserLocation&&this._userLocationDotMarker&&this._userLocationDotMarker.remove(),this.options.showAccuracyCircle&&this._accuracyCircleMarker&&this._accuracyCircleMarker.remove(),oe.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,zs=0,rs=!1}_isOutOfMapMaxBounds(c){const t=this._map.getMaxBounds(),n=c.coords;return t&&(n.longitudet.getEast()||n.latitudet.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const c=this._map.getBounds(),t=c.getSouthEast(),n=c.getNorthEast(),s=t.distanceTo(n),a=Math.ceil(this._accuracy/(s/this._map._container.clientHeight)*2);this._circleElement.style.width=`${a}px`,this._circleElement.style.height=`${a}px`}trigger(){if(!this._setup)return d.w("Geolocate control triggered before added to a map"),!1;if(this.options.trackUserLocation){switch(this._watchState){case"OFF":this._watchState="WAITING_ACTIVE",this.fire(new d.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":zs--,rs=!1,this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this.fire(new d.k("trackuserlocationend"));break;case"BACKGROUND":this._watchState="ACTIVE_LOCK",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._lastKnownPosition&&this._updateCamera(this._lastKnownPosition),this.fire(new d.k("trackuserlocationstart"));break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}switch(this._watchState){case"WAITING_ACTIVE":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"ACTIVE_LOCK":this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active");break;case"OFF":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}if(this._watchState==="OFF"&&this._geolocationWatchID!==void 0)this._clearWatch();else if(this._geolocationWatchID===void 0){let c;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),zs++,zs>1?(c={maximumAge:6e5,timeout:0},rs=!0):(c=this.options.positionOptions,rs=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,c)}}else window.navigator.geolocation.getCurrentPosition(this._onSuccess,this._onError,this.options.positionOptions),this._timeoutId=setTimeout(this._finish,1e4);return!0}_clearWatch(){window.navigator.geolocation.clearWatch(this._geolocationWatchID),this._geolocationWatchID=void 0,this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","false"),this.options.showUserLocation&&this._updateMarker(null)}},M.Hash=Li,M.ImageSource=ci,M.KeyboardHandler=No,M.LngLatBounds=Yt,M.LogoControl=Rl,M.Map=class extends on{constructor(c){if(d.bc.mark(d.bd.create),(c=d.e({},sa,c)).minZoom!=null&&c.maxZoom!=null&&c.minZoom>c.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(c.minPitch!=null&&c.maxPitch!=null&&c.minPitch>c.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(c.minPitch!=null&&c.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(c.maxPitch!=null&&c.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Ft(c.minZoom,c.maxZoom,c.minPitch,c.maxPitch,c.renderWorldCopies),{bearingSnap:c.bearingSnap}),this._contextLost=t=>{t.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new d.k("webglcontextlost",{originalEvent:t}))},this._contextRestored=t=>{this._setupPainter(),this.resize(),this._update(),this.fire(new d.k("webglcontextrestored",{originalEvent:t}))},this._onMapScroll=t=>{if(t.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=c.interactive,this._maxTileCacheSize=c.maxTileCacheSize,this._maxTileCacheZoomLevels=c.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=c.failIfMajorPerformanceCaveat,this._preserveDrawingBuffer=c.preserveDrawingBuffer,this._antialias=c.antialias,this._trackResize=c.trackResize,this._bearingSnap=c.bearingSnap,this._refreshExpiredTiles=c.refreshExpiredTiles,this._fadeDuration=c.fadeDuration,this._crossSourceCollisions=c.crossSourceCollisions,this._crossFadingFactor=1,this._collectResourceTiming=c.collectResourceTiming,this._renderTaskQueue=new na,this._controls=[],this._mapId=d.a3(),this._locale=d.e({},Ka,c.locale),this._clickTolerance=c.clickTolerance,this._overridePixelRatio=c.pixelRatio,this._maxCanvasSize=c.maxCanvasSize,this.transformCameraUpdate=c.transformCameraUpdate,this._imageQueueHandle=Mt.addThrottleControl(()=>this.isMoving()),this._requestManager=new xt(c.transformRequest),typeof c.container=="string"){if(this._container=document.getElementById(c.container),!this._container)throw new Error(`Container '${c.container}' not found.`)}else{if(!(c.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=c.container}if(c.maxBounds&&this.setMaxBounds(c.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)),this.on("moveend",()=>this._update(!1)),this.on("zoom",()=>this._update(!0)),this.on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}),this.once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let t=!1;const n=_i(s=>{this._trackResize&&!this._removed&&this.resize(s)._update()},50);this._resizeObserver=new ResizeObserver(s=>{t?n(s):t=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Wa(this,c),this._hash=c.hash&&new Li(typeof c.hash=="string"&&c.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:c.center,zoom:c.zoom,bearing:c.bearing,pitch:c.pitch}),c.bounds&&(this.resize(),this.fitBounds(c.bounds,d.e({},c.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=c.localIdeographFontFamily,this._validateStyle=c.validateStyle,c.style&&this.setStyle(c.style,{localIdeographFontFamily:c.localIdeographFontFamily}),c.attributionControl&&this.addControl(new Jn(typeof c.attributionControl=="boolean"?void 0:c.attributionControl)),c.maplibreLogo&&this.addControl(new Rl,c.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",t=>{this._update(t.dataType==="style"),this.fire(new d.k(`${t.dataType}data`,t))}),this.on("dataloading",t=>{this.fire(new d.k(`${t.dataType}dataloading`,t))}),this.on("dataabort",t=>{this.fire(new d.k("sourcedataabort",t))})}_getMapId(){return this._mapId}addControl(c,t){if(t===void 0&&(t=c.getDefaultPosition?c.getDefaultPosition():"top-right"),!c||!c.onAdd)return this.fire(new d.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const n=c.onAdd(this);this._controls.push(c);const s=this._controlPositions[t];return t.indexOf("bottom")!==-1?s.insertBefore(n,s.firstChild):s.appendChild(n),this}removeControl(c){if(!c||!c.onRemove)return this.fire(new d.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const t=this._controls.indexOf(c);return t>-1&&this._controls.splice(t,1),c.onRemove(this),this}hasControl(c){return this._controls.indexOf(c)>-1}calculateCameraOptionsFromTo(c,t,n,s){return s==null&&this.terrain&&(s=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(c,t,n,s)}resize(c){var t;const n=this._containerDimensions(),s=n[0],a=n[1],u=this._getClampedPixelRatio(s,a);if(this._resizeCanvas(s,a,u),this.painter.resize(s,a,u),this.painter.overLimit()){const y=this.painter.context.gl;this._maxCanvasSize=[y.drawingBufferWidth,y.drawingBufferHeight];const v=this._getClampedPixelRatio(s,a);this._resizeCanvas(s,a,v),this.painter.resize(s,a,v)}this.transform.resize(s,a),(t=this._requestedCameraState)===null||t===void 0||t.resize(s,a);const g=!this._moving;return g&&(this.stop(),this.fire(new d.k("movestart",c)).fire(new d.k("move",c))),this.fire(new d.k("resize",c)),g&&this.fire(new d.k("moveend",c)),this}_getClampedPixelRatio(c,t){const{0:n,1:s}=this._maxCanvasSize,a=this.getPixelRatio(),u=c*a,g=t*a;return Math.min(u>n?n/u:1,g>s?s/g:1)*a}getPixelRatio(){var c;return(c=this._overridePixelRatio)!==null&&c!==void 0?c:devicePixelRatio}setPixelRatio(c){this._overridePixelRatio=c,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(c){return this.transform.setMaxBounds(Yt.convert(c)),this._update()}setMinZoom(c){if((c=c??-2)>=-2&&c<=this.transform.maxZoom)return this.transform.minZoom=c,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=c,this._update(),this.getZoom()>c&&this.setZoom(c),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(c){if((c=c??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(c>=0&&c<=this.transform.maxPitch)return this.transform.minPitch=c,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(c>=this.transform.minPitch)return this.transform.maxPitch=c,this._update(),this.getPitch()>c&&this.setPitch(c),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(c){return this.transform.renderWorldCopies=c,this._update()}project(c){return this.transform.locationPoint(d.M.convert(c),this.style&&this.terrain)}unproject(c){return this.transform.pointLocation(d.P.convert(c),this.terrain)}isMoving(){var c;return this._moving||((c=this.handlers)===null||c===void 0?void 0:c.isMoving())}isZooming(){var c;return this._zooming||((c=this.handlers)===null||c===void 0?void 0:c.isZooming())}isRotating(){var c;return this._rotating||((c=this.handlers)===null||c===void 0?void 0:c.isRotating())}_createDelegatedListener(c,t,n){if(c==="mouseenter"||c==="mouseover"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:u=>{const g=this.getLayer(t)?this.queryRenderedFeatures(u.point,{layers:[t]}):[];g.length?s||(s=!0,n.call(this,new cr(c,this,u.originalEvent,{features:g}))):s=!1},mouseout:()=>{s=!1}}}}if(c==="mouseleave"||c==="mouseout"){let s=!1;return{layer:t,listener:n,delegates:{mousemove:g=>{(this.getLayer(t)?this.queryRenderedFeatures(g.point,{layers:[t]}):[]).length?s=!0:s&&(s=!1,n.call(this,new cr(c,this,g.originalEvent)))},mouseout:g=>{s&&(s=!1,n.call(this,new cr(c,this,g.originalEvent)))}}}}{const s=a=>{const u=this.getLayer(t)?this.queryRenderedFeatures(a.point,{layers:[t]}):[];u.length&&(a.features=u,n.call(this,a),delete a.features)};return{layer:t,listener:n,delegates:{[c]:s}}}}on(c,t,n){if(n===void 0)return super.on(c,t);const s=this._createDelegatedListener(c,t,n);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[c]=this._delegatedListeners[c]||[],this._delegatedListeners[c].push(s);for(const a in s.delegates)this.on(a,s.delegates[a]);return this}once(c,t,n){if(n===void 0)return super.once(c,t);const s=this._createDelegatedListener(c,t,n);for(const a in s.delegates)this.once(a,s.delegates[a]);return this}off(c,t,n){return n===void 0?super.off(c,t):(this._delegatedListeners&&this._delegatedListeners[c]&&(s=>{const a=this._delegatedListeners[c];for(let u=0;uthis._updateStyle(c,t));const n=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!c)),c?(this.style=new Ar(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof c=="string"?this.style.loadURL(c,t,n):this.style.loadJSON(c,t,n),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new Ar(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(c,t){if(typeof c=="string"){const n=this._requestManager.transformRequest(c,"Style");d.h(n,new AbortController).then(s=>{this._updateDiff(s.data,t)}).catch(s=>{s&&this.fire(new d.j(s))})}else typeof c=="object"&&this._updateDiff(c,t)}_updateDiff(c,t){try{this.style.setState(c,t)&&this._update(!0)}catch(n){d.w(`Unable to perform style diff: ${n.message||n.error||n}. Rebuilding the style from scratch.`),this._updateStyle(c,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():d.w("There is no style added to the map.")}addSource(c,t){return this._lazyInitEmptyStyle(),this.style.addSource(c,t),this._update(!0)}isSourceLoaded(c){const t=this.style&&this.style.sourceCaches[c];if(t!==void 0)return t.loaded();this.fire(new d.j(new Error(`There is no source with ID '${c}'`)))}setTerrain(c){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),c){const t=this.style.sourceCaches[c.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${c.source}`);this.terrain===null&&t.reload();for(const n in this.style._layers){const s=this.style._layers[n];s.type==="hillshade"&&s.source===c.source&&d.w("You are using the same source for a hillshade layer and for 3D terrain. Please consider using two separate sources to improve rendering quality.")}this.terrain=new Fl(this.painter,t,c),this.painter.renderToTexture=new Ja(this.painter,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._terrainDataCallback=n=>{n.dataType==="style"?this.terrain.sourceCache.freeRtt():n.dataType==="source"&&n.tile&&(n.sourceId!==c.source||this._elevationFreeze||(this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom)),this.terrain.sourceCache.freeRtt(n.tile.tileID))},this.style.on("data",this._terrainDataCallback)}else this.terrain&&this.terrain.sourceCache.destruct(),this.terrain=null,this.painter.renderToTexture&&this.painter.renderToTexture.destruct(),this.painter.renderToTexture=null,this.transform.minElevationForCurrentTile=0,this.transform.elevation=0;return this.fire(new d.k("terrain",{terrain:c})),this}getTerrain(){var c,t;return(t=(c=this.terrain)===null||c===void 0?void 0:c.options)!==null&&t!==void 0?t:null}areTilesLoaded(){const c=this.style&&this.style.sourceCaches;for(const t in c){const n=c[t]._tiles;for(const s in n){const a=n[s];if(a.state!=="loaded"&&a.state!=="errored")return!1}}return!0}removeSource(c){return this.style.removeSource(c),this._update(!0)}getSource(c){return this.style.getSource(c)}addImage(c,t,n={}){const{pixelRatio:s=1,sdf:a=!1,stretchX:u,stretchY:g,content:y}=n;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||d.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new d.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:v,height:S,data:C}=t,A=t;return this.style.addImage(c,{data:new d.R({width:v,height:S},new Uint8Array(C)),pixelRatio:s,stretchX:u,stretchY:g,content:y,sdf:a,version:0,userImage:A}),A.onAdd&&A.onAdd(this,c),this}}{const{width:v,height:S,data:C}=ce.getImageData(t);this.style.addImage(c,{data:new d.R({width:v,height:S},C),pixelRatio:s,stretchX:u,stretchY:g,content:y,sdf:a,version:0})}}updateImage(c,t){const n=this.style.getImage(c);if(!n)return this.fire(new d.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const s=t instanceof HTMLImageElement||d.b(t)?ce.getImageData(t):t,{width:a,height:u,data:g}=s;if(a===void 0||u===void 0)return this.fire(new d.j(new Error("Invalid arguments to map.updateImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));if(a!==n.data.width||u!==n.data.height)return this.fire(new d.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const y=!(t instanceof HTMLImageElement||d.b(t));return n.data.replace(g,y),this.style.updateImage(c,n),this}getImage(c){return this.style.getImage(c)}hasImage(c){return c?!!this.style.getImage(c):(this.fire(new d.j(new Error("Missing required image id"))),!1)}removeImage(c){this.style.removeImage(c)}loadImage(c){return Mt.getImage(this._requestManager.transformRequest(c,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(c,t){return this._lazyInitEmptyStyle(),this.style.addLayer(c,t),this._update(!0)}moveLayer(c,t){return this.style.moveLayer(c,t),this._update(!0)}removeLayer(c){return this.style.removeLayer(c),this._update(!0)}getLayer(c){return this.style.getLayer(c)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(c,t,n){return this.style.setLayerZoomRange(c,t,n),this._update(!0)}setFilter(c,t,n={}){return this.style.setFilter(c,t,n),this._update(!0)}getFilter(c){return this.style.getFilter(c)}setPaintProperty(c,t,n,s={}){return this.style.setPaintProperty(c,t,n,s),this._update(!0)}getPaintProperty(c,t){return this.style.getPaintProperty(c,t)}setLayoutProperty(c,t,n,s={}){return this.style.setLayoutProperty(c,t,n,s),this._update(!0)}getLayoutProperty(c,t){return this.style.getLayoutProperty(c,t)}setGlyphs(c,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(c,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(c,t,n={}){return this._lazyInitEmptyStyle(),this.style.addSprite(c,t,n,s=>{s||this._update(!0)}),this}removeSprite(c){return this._lazyInitEmptyStyle(),this.style.removeSprite(c),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(c,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(c,t,n=>{n||this._update(!0)}),this}setLight(c,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(c,t),this._update(!0)}getLight(){return this.style.getLight()}setFeatureState(c,t){return this.style.setFeatureState(c,t),this._update()}removeFeatureState(c,t){return this.style.removeFeatureState(c,t),this._update()}getFeatureState(c){return this.style.getFeatureState(c)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let c=0,t=0;return this._container&&(c=this._container.clientWidth||400,t=this._container.clientHeight||300),[c,t]}_setupContainer(){const c=this._container;c.classList.add("maplibregl-map");const t=this._canvasContainer=oe.create("div","maplibregl-canvas-container",c);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=oe.create("canvas","maplibregl-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","Map"),this._canvas.setAttribute("role","region");const n=this._containerDimensions(),s=this._getClampedPixelRatio(n[0],n[1]);this._resizeCanvas(n[0],n[1],s);const a=this._controlContainer=oe.create("div","maplibregl-control-container",c),u=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(g=>{u[g]=oe.create("div",`maplibregl-ctrl-${g} `,a)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(c,t,n){this._canvas.width=Math.floor(n*c),this._canvas.height=Math.floor(n*t),this._canvas.style.width=`${c}px`,this._canvas.style.height=`${t}px`}_setupPainter(){const c={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let t=null;this._canvas.addEventListener("webglcontextcreationerror",s=>{t={requestedAttributes:c},s&&(t.statusMessage=s.statusMessage,t.type=s.type)},{once:!0});const n=this._canvas.getContext("webgl2",c)||this._canvas.getContext("webgl",c);if(!n){const s="Failed to initialize WebGL";throw t?(t.message=s,new Error(JSON.stringify(t))):new Error(s)}this.painter=new he(n,this.transform),We.testSupport(n)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(c){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||c,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(c){return this._update(),this._renderTaskQueue.add(c)}_cancelRenderFrame(c){this._renderTaskQueue.remove(c)}_render(c){const t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(c),this._removed)return;let n=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const a=this.transform.zoom,u=ce.now();this.style.zoomHistory.update(a,u);const g=new d.a8(a,{now:u,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),y=g.crossFadingFactor();y===1&&y===this._crossFadingFactor||(n=!0,this._crossFadingFactor=y),this.style.update(g)}this.style&&this._sourcesDirty&&(this._sourcesDirty=!1,this.style._updateSources(this.transform)),this.terrain?(this.terrain.sourceCache.update(this.transform,this.terrain),this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this.transform.center,this.transform.tileZoom),this._elevationFreeze||(this.transform.elevation=this.terrain.getElevationForLngLatZoom(this.transform.center,this.transform.tileZoom))):(this.transform.minElevationForCurrentTile=0,this.transform.elevation=0),this._placementDirty=this.style&&this.style._updatePlacement(this.painter.transform,this.showCollisionBoxes,t,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:t,showPadding:this.showPadding}),this.fire(new d.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,d.bc.mark(d.bd.load),this.fire(new d.k("load"))),this.style&&(this.style.hasTransitions()||n)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const s=this._sourcesDirty||this._styleDirty||this._placementDirty;return s||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new d.k("idle")),!this._loaded||this._fullyLoaded||s||(this._fullyLoaded=!0,d.bc.mark(d.bd.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var c;this._hash&&this._hash.remove();for(const n of this._controls)n.onRemove(this);this._controls=[],this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._renderTaskQueue.clear(),this.painter.destroy(),this.handlers.destroy(),delete this.handlers,this.setStyle(null),typeof window<"u"&&removeEventListener("online",this._onWindowOnline,!1),Mt.removeThrottleControl(this._imageQueueHandle),(c=this._resizeObserver)===null||c===void 0||c.disconnect();const t=this.painter.context.gl.getExtension("WEBGL_lose_context");t&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),oe.remove(this._canvasContainer),oe.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),d.bc.clearMetrics(),this._removed=!0,this.fire(new d.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,ce.frameAsync(this._frameRequest).then(c=>{d.bc.frame(c),this._frameRequest=null,this._render(c)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(c){this._showTileBoundaries!==c&&(this._showTileBoundaries=c,this._update())}get showPadding(){return!!this._showPadding}set showPadding(c){this._showPadding!==c&&(this._showPadding=c,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(c){this._showCollisionBoxes!==c&&(this._showCollisionBoxes=c,c?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(c){this._showOverdrawInspector!==c&&(this._showOverdrawInspector=c,this._update())}get repaint(){return!!this._repaint}set repaint(c){this._repaint!==c&&(this._repaint=c,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(c){this._vertices=c,this._update()}get version(){return Ya}getCameraTargetElevation(){return this.transform.elevation}},M.MapMouseEvent=cr,M.MapTouchEvent=Lr,M.MapWheelEvent=Io,M.Marker=la,M.NavigationControl=class{constructor(c){this._updateZoomButtons=()=>{const t=this._map.getZoom(),n=t===this._map.getMaxZoom(),s=t===this._map.getMinZoom();this._zoomInButton.disabled=n,this._zoomOutButton.disabled=s,this._zoomInButton.setAttribute("aria-disabled",n.toString()),this._zoomOutButton.setAttribute("aria-disabled",s.toString())},this._rotateCompassArrow=()=>{const t=this.options.visualizePitch?`scale(${1/Math.pow(Math.cos(this._map.transform.pitch*(Math.PI/180)),.5)}) rotateX(${this._map.transform.pitch}deg) rotateZ(${this._map.transform.angle*(180/Math.PI)}deg)`:`rotate(${this._map.transform.angle*(180/Math.PI)}deg)`;this._compassIcon.style.transform=t},this._setButtonTitle=(t,n)=>{const s=this._map._getUIString(`NavigationControl.${n}`);t.title=s,t.setAttribute("aria-label",s)},this.options=d.e({},Qa,c),this._container=oe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",t=>t.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",t=>this._map.zoomIn({},{originalEvent:t})),oe.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",t=>this._map.zoomOut({},{originalEvent:t})),oe.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",t=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:t}):this._map.resetNorth({},{originalEvent:t})}),this._compassIcon=oe.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(c){return this._map=c,this.options.showZoom&&(this._setButtonTitle(this._zoomInButton,"ZoomIn"),this._setButtonTitle(this._zoomOutButton,"ZoomOut"),this._map.on("zoom",this._updateZoomButtons),this._updateZoomButtons()),this.options.showCompass&&(this._setButtonTitle(this._compass,"ResetBearing"),this.options.visualizePitch&&this._map.on("pitch",this._rotateCompassArrow),this._map.on("rotate",this._rotateCompassArrow),this._rotateCompassArrow(),this._handler=new el(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){oe.remove(this._container),this.options.showZoom&&this._map.off("zoom",this._updateZoomButtons),this.options.showCompass&&(this.options.visualizePitch&&this._map.off("pitch",this._rotateCompassArrow),this._map.off("rotate",this._rotateCompassArrow),this._handler.off(),delete this._handler),delete this._map}_createButton(c,t){const n=oe.create("button",c,this._container);return n.type="button",n.addEventListener("click",t),n}},M.Popup=class extends d.E{constructor(c){super(),this.remove=()=>(this._content&&oe.remove(this._content),this._container&&(oe.remove(this._container),delete this._container),this._map&&(this._map.off("move",this._update),this._map.off("move",this._onClose),this._map.off("click",this._onClose),this._map.off("remove",this.remove),this._map.off("mousemove",this._onMouseMove),this._map.off("mouseup",this._onMouseUp),this._map.off("drag",this._onDrag),this._map._canvasContainer.classList.remove("maplibregl-track-pointer"),delete this._map,this.fire(new d.k("close"))),this),this._onMouseUp=t=>{this._update(t.point)},this._onMouseMove=t=>{this._update(t.point)},this._onDrag=t=>{this._update(t.point)},this._update=t=>{var n;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=oe.create("div","maplibregl-popup",this._map.getContainer()),this._tip=oe.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const y of this.options.className.split(" "))this._container.classList.add(y);this._trackPointer&&this._container.classList.add("maplibregl-popup-track-pointer")}if(this.options.maxWidth&&this._container.style.maxWidth!==this.options.maxWidth&&(this._container.style.maxWidth=this.options.maxWidth),this._lngLat=this._map.transform.renderWorldCopies&&!this._trackPointer?Ea(this._lngLat,this._flatPos,this._map.transform):(n=this._lngLat)===null||n===void 0?void 0:n.wrap(),this._trackPointer&&!t)return;const s=this._flatPos=this._pos=this._trackPointer&&t?t:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&t?t:this._map.transform.locationPoint(this._lngLat));let a=this.options.anchor;const u=ka(this.options.offset);if(!a){const y=this._container.offsetWidth,v=this._container.offsetHeight;let S;S=s.y+u.bottom.ythis._map.transform.height-v?["bottom"]:[],s.xthis._map.transform.width-y/2&&S.push("right"),a=S.length===0?"bottom":S.join("-")}let g=s.add(u[a]);this.options.subpixelPositioning||(g=g.round()),oe.setTransform(this._container,`${aa[a]} translate(${g.x}px,${g.y}px)`),Ca(this._container,a,"popup")},this._onClose=()=>{this.remove()},this.options=d.e(Object.create(tl),c)}addTo(c){return this._map&&this.remove(),this._map=c,this.options.closeOnClick&&this._map.on("click",this._onClose),this.options.closeOnMove&&this._map.on("move",this._onClose),this._map.on("remove",this.remove),this._update(),this._focusFirstElement(),this._trackPointer?(this._map.on("mousemove",this._onMouseMove),this._map.on("mouseup",this._onMouseUp),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")):this._map.on("move",this._update),this.fire(new d.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(c){return this._lngLat=d.M.convert(c),this._pos=null,this._flatPos=null,this._trackPointer=!1,this._update(),this._map&&(this._map.on("move",this._update),this._map.off("mousemove",this._onMouseMove),this._container&&this._container.classList.remove("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.remove("maplibregl-track-pointer")),this}trackPointer(){return this._trackPointer=!0,this._pos=null,this._flatPos=null,this._update(),this._map&&(this._map.off("move",this._update),this._map.on("mousemove",this._onMouseMove),this._map.on("drag",this._onDrag),this._container&&this._container.classList.add("maplibregl-popup-track-pointer"),this._map._canvasContainer.classList.add("maplibregl-track-pointer")),this}getElement(){return this._container}setText(c){return this.setDOMContent(document.createTextNode(c))}setHTML(c){const t=document.createDocumentFragment(),n=document.createElement("body");let s;for(n.innerHTML=c;s=n.firstChild,s;)t.appendChild(s);return this.setDOMContent(t)}getMaxWidth(){var c;return(c=this._container)===null||c===void 0?void 0:c.style.maxWidth}setMaxWidth(c){return this.options.maxWidth=c,this._update(),this}setDOMContent(c){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=oe.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(c),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(c){this._container&&this._container.classList.add(c)}removeClassName(c){this._container&&this._container.classList.remove(c)}setOffset(c){return this.options.offset=c,this._update(),this}toggleClassName(c){if(this._container)return this._container.classList.toggle(c)}setSubpixelPositioning(c){this.options.subpixelPositioning=c}_createCloseButton(){this.options.closeButton&&(this._closeButton=oe.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.setAttribute("aria-label","Close popup"),this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const c=this._container.querySelector(il);c&&c.focus()}},M.RasterDEMTileSource=Tn,M.RasterTileSource=be,M.ScaleControl=class{constructor(c){this._onMove=()=>{Pa(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,Pa(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Aa),c)}getDefaultPosition(){return"bottom-left"}onAdd(c){return this._map=c,this._container=oe.create("div","maplibregl-ctrl maplibregl-ctrl-scale",c.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){oe.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},M.ScrollZoomHandler=Ia,M.Style=Ar,M.TerrainControl=class{constructor(c){this._toggleTerrain=()=>{this._map.getTerrain()?this._map.setTerrain(null):this._map.setTerrain(this.options),this._updateTerrainIcon()},this._updateTerrainIcon=()=>{this._terrainButton.classList.remove("maplibregl-ctrl-terrain"),this._terrainButton.classList.remove("maplibregl-ctrl-terrain-enabled"),this._map.terrain?(this._terrainButton.classList.add("maplibregl-ctrl-terrain-enabled"),this._terrainButton.title=this._map._getUIString("TerrainControl.Disable")):(this._terrainButton.classList.add("maplibregl-ctrl-terrain"),this._terrainButton.title=this._map._getUIString("TerrainControl.Enable"))},this.options=c}onAdd(c){return this._map=c,this._container=oe.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=oe.create("button","maplibregl-ctrl-terrain",this._container),oe.create("span","maplibregl-ctrl-icon",this._terrainButton).setAttribute("aria-hidden","true"),this._terrainButton.type="button",this._terrainButton.addEventListener("click",this._toggleTerrain),this._updateTerrainIcon(),this._map.on("terrain",this._updateTerrainIcon),this._container}onRemove(){oe.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},M.TwoFingersTouchPitchHandler=kl,M.TwoFingersTouchRotateHandler=Oo,M.TwoFingersTouchZoomHandler=ts,M.TwoFingersTouchZoomRotateHandler=ia,M.VectorTileSource=Ot,M.VideoSource=Un,M.addSourceType=(c,t)=>d._(void 0,void 0,void 0,function*(){if(Ur(c))throw new Error(`A source type called "${c}" already exists.`);((n,s)=>{Kr[n]=s})(c,t)}),M.clearPrewarmedResources=function(){const c=bi;c&&(c.isPreloaded()&&c.numActive()===1?(c.release(Ai),bi=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()"))},M.getMaxParallelImageRequests=function(){return d.a.MAX_PARALLEL_IMAGE_REQUESTS},M.getRTLTextPluginStatus=function(){return ze().getRTLTextPluginStatus()},M.getVersion=function(){return Bl},M.getWorkerCount=function(){return ii.workerCount},M.getWorkerUrl=function(){return d.a.WORKER_URL},M.importScriptInWorkers=function(c){return Ii().broadcast("IS",c)},M.prewarm=function(){or().acquire(Ai)},M.setMaxParallelImageRequests=function(c){d.a.MAX_PARALLEL_IMAGE_REQUESTS=c},M.setRTLTextPlugin=function(c,t){return ze().setRTLTextPlugin(c,t)},M.setWorkerCount=function(c){ii.workerCount=c},M.setWorkerUrl=function(c){d.a.WORKER_URL=c}});var de=I;return de})})(tu);var mo=tu.exports;let Tl;const Wh=new Uint8Array(16);function Xh(){if(!Tl&&(Tl=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!Tl))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return Tl(Wh)}const Nr=[];for(let Q=0;Q<256;++Q)Nr.push((Q+256).toString(16).slice(1));function Jh(Q,w=0){return Nr[Q[w+0]]+Nr[Q[w+1]]+Nr[Q[w+2]]+Nr[Q[w+3]]+"-"+Nr[Q[w+4]]+Nr[Q[w+5]]+"-"+Nr[Q[w+6]]+Nr[Q[w+7]]+"-"+Nr[Q[w+8]]+Nr[Q[w+9]]+"-"+Nr[Q[w+10]]+Nr[Q[w+11]]+Nr[Q[w+12]]+Nr[Q[w+13]]+Nr[Q[w+14]]+Nr[Q[w+15]]}const iu={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function Kh(Q,w,I){if(iu.randomUUID&&!w&&!Q)return iu.randomUUID();Q=Q||{};const L=Q.random||(Q.rng||Xh)();if(L[6]=L[6]&15|64,L[8]=L[8]&63|128,w){I=I||0;for(let U=0;U<16;++U)w[I+U]=L[U];return w}return Jh(L)}class Zo{static fadeOut(w,I){this.setRequestAnimationFrame(),this.resetAnimation(w);var L=250,U=null,de=d=>{U||(U=d);const Se=1-(d-U)/L;if(w.style.opacity=Se.toString(),w.style.filter="alpha(opacity="+Se*100+")",Se<=.1){w.style.display="none",this.resetAnimation(w);return}var Re=window.requestAnimationFrame(de);this.updateAnimation(w,Re)},M=requestAnimationFrame(de);this.addAnimation(w,M,I)}static fadeIn(w){this.resetAnimation(w);var I=.1;w.style.display="block",w.style.opacity=I.toString();var L=250,U=null,de=d=>{U||(U=d);const Se=(d-U)/L;if(w.style.opacity=Se.toString(),Se>=1){this.resetAnimation(w);return}var Re=window.requestAnimationFrame(de);this.updateAnimation(w,Re)},M=requestAnimationFrame(de);this.addAnimation(w,M)}static resetAnimation(w){var I=this.activeAnimations.find(U=>U.element===w);if(I){I.callback&&I.callback(),I.interval&&this.resetAnimation(I.interval);var L=this.activeAnimations.indexOf(I);L!==-1&&this.activeAnimations.splice(L,1)}}static addAnimation(w,I,L){this.activeAnimations.push({element:w,interval:I,callback:L})}static updateAnimation(w,I){var L=this.activeAnimations.find(U=>U.element===w);L&&(L.interval=I)}static setRequestAnimationFrame(){window.requestAnimationFrame||(window.requestAnimationFrame=function(w){setTimeout(w,16.66)})}}Te(Zo,"activeAnimations",[]);class Yh{constructor(w){Te(this,"backdrop");Te(this,"clickEvents",[]);this.backdrop=document.createElement("div"),this.backdrop.classList.add("map-back-drop");var I=document.getElementById(w);I==null||I.appendChild(this.backdrop),this.backdrop.onclick=()=>{this.clickEvents.forEach(L=>L())}}onClick(w){this.clickEvents.push(w)}offClick(w){var I=this.clickEvents.indexOf(w);I!==-1&&this.clickEvents.splice(I,1)}show(){Zo.fadeIn(this.backdrop)}hide(){Zo.fadeOut(this.backdrop)}}class El{static init(w,I){var ar;const L=document.createElement("div");L.classList.add("filter-ctrl");const U=document.createElement("input");U.id="filter-input",U.type="text",U.name="filter",U.classList.add("filter-input"),U.placeholder="Filter by name",U.style.display="none";const de=document.createElement("div");de.id="name-filter-button",de.classList.add("maplibregl-ctrl","maplibregl-ctrl-group","name-filter-button"),de.innerHTML='',de.style.display="none";var M=de.getElementsByTagName("button")[0];M.addEventListener("click",Wi=>{M.classList.contains("filter-on-btn")?M.classList.remove("filter-on-btn"):M.classList.add("filter-on-btn")}),L.appendChild(U),L.appendChild(de),(ar=document.getElementById(w))==null||ar.appendChild(L);const d=document.createElement("div");d.id="edit-popup",d.classList.add("hidden");const Se=document.createElement("div");Se.id="general",Se.classList.add("edit-properties");const Re=document.createElement("label");Re.setAttribute("for","general-name"),Re.textContent="Name";const He=document.createElement("input");He.id="general-name",He.type="text";const ce=document.createElement("label");ce.setAttribute("for","polygon-type"),ce.textContent="Type";const oe=document.createElement("select");oe.name="polygon-type",oe.id="polygon-type";const We=document.createElement("option");We.value="custom-building",We.textContent="Building",oe.appendChild(We);const et=document.createElement("option");et.value="custom-indoor",et.textContent="Indoor",oe.appendChild(et);const De=document.createElement("label");De.textContent="Current Zoom";const it=document.createElement("input");it.id="current-zoom-level",it.disabled=!0;const $t=document.createElement("label");$t.setAttribute("for","min-zoom-level"),$t.textContent="Max. Zoom";const di=document.createElement("input");di.id="min-zoom-level",di.type="text";const Mt=document.createElement("label");Mt.setAttribute("for","max-zoom-level"),Mt.textContent="Min. Zoom";const xt=document.createElement("input");xt.id="max-zoom-level",xt.type="text",Se.append(Re,He,ce,oe,De,it,$t,di,Mt,xt);const Gt=document.createElement("div");Gt.id="polygon",Gt.classList.add("edit-properties");const ti=document.createElement("label");ti.setAttribute("for","polygon-grid-id"),ti.textContent="Grid ID";const li=document.createElement("input");li.id="polygon-grid-id",li.type="text";const kt=document.createElement("label");kt.setAttribute("for","polygon-grid-zero-point-value"),kt.textContent="Grid Zero Point";const Bt=document.createElement("input");Bt.id="polygon-grid-zero-point-value",Bt.type="text",Bt.readOnly=!0;const Zt=document.createElement("label");Zt.setAttribute("for","polygon-grid-size"),Zt.textContent="Grid Size";const St=document.createElement("input");St.id="polygon-grid-size",St.type="number";const xi=document.createElement("label");xi.setAttribute("for","polygon-grid-x"),xi.textContent="Grid X";const pi=document.createElement("input");pi.id="polygon-grid-x",pi.type="number";const fi=document.createElement("label");fi.setAttribute("for","polygon-grid-y"),fi.textContent="Grid Y";const Nn=document.createElement("input");Nn.id="polygon-grid-y",Nn.type="number";const xr=document.createElement("label");xr.setAttribute("for","polygon-zero-point-id"),xr.textContent="Zero Point ID";const br=document.createElement("input");br.id="polygon-zero-point-id",br.type="text";const hn=document.createElement("label");hn.setAttribute("for","polygon-zero-point-value"),hn.textContent="Zero Point Value";const Dr=document.createElement("input");Dr.id="polygon-zero-point-value",Dr.type="text",Dr.readOnly=!0;const dn=document.createElement("label");dn.setAttribute("for","polygon-zone"),dn.textContent="Zone";const $i=document.createElement("input");$i.id="polygon-zone",$i.type="text";const Ai=document.createElement("label");Ai.setAttribute("for","polygon-image"),Ai.textContent="Image";const ii=document.createElement("input");ii.id="polygon-image",ii.type="text";const Sr=document.createElement("label");Sr.setAttribute("for","polygon-color"),Sr.textContent="Color";const bi=document.createElement("input");bi.id="polygon-color",bi.type="color";const wi=document.createElement("label");wi.setAttribute("for","polygon-opacity"),wi.textContent="Opacity";const or=document.createElement("input");or.id="polygon-opacity",or.type="range",or.min="0",or.max="1",or.step="0.1";const sr=document.createElement("label");sr.setAttribute("for","polygon-line-color"),sr.textContent="Line-Color";const Ii=document.createElement("input");Ii.id="polygon-line-color",Ii.type="color",Gt.append(ti,li,kt,Bt,Zt,St,xi,pi,fi,Nn,xr,br,hn,Dr,dn,$i,Ai,ii,Sr,bi,wi,or,sr,Ii);const bt=document.createElement("div");bt.id="line",bt.classList.add("edit-properties");const Vn=document.createElement("label");Vn.setAttribute("for","line-color"),Vn.textContent="Color";const Vr=document.createElement("input");Vr.id="line-color",Vr.type="color";const Xr=document.createElement("label");Xr.setAttribute("for","line-width"),Xr.textContent="Width";const Yt=document.createElement("input");Yt.id="line-width",Yt.type="range",Yt.min="0",Yt.max="10",Yt.step="0.1",bt.append(Vn,Vr,Xr,Yt);const Jr=document.createElement("div");Jr.id="line",Jr.classList.add("edit-properties");const Ot=document.createElement("input");Ot.id="button-save",Ot.type="button",Ot.name="button-save",Ot.value="Save",Jr.appendChild(Ot),d.append(Se,Gt,bt,document.createElement("br"),Jr),document.body.appendChild(d);const be=document.createElement("div");be.classList.add("context-menu");const Tn=document.createElement("div");Tn.classList.add("context-content");const En=document.createElement("ul");En.classList.add("menu");const ft=document.createElement("li");ft.classList.add("item"),ft.id="bringBackward";const ci=document.createElementNS("http://www.w3.org/2000/svg","svg");ci.setAttribute("xmlns","http://www.w3.org/2000/svg"),ci.setAttribute("width","24"),ci.setAttribute("height","24");const Un=document.createElementNS("http://www.w3.org/2000/svg","path");Un.setAttribute("d","M12 2a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8.009 8.009 0 0 1-8 8z");const Cn=document.createElementNS("http://www.w3.org/2000/svg","path");Cn.setAttribute("d","M12 12.586 8.707 9.293l-1.414 1.414L12 15.414l4.707-4.707-1.414-1.414L12 12.586z"),ci.appendChild(Un),ci.appendChild(Cn);const Kr=document.createElement("span");Kr.textContent="Send backward",ft.appendChild(ci),ft.appendChild(Kr);const Ur=document.createElement("li");Ur.classList.add("item"),Ur.id="bringForward";const Fi=document.createElementNS("http://www.w3.org/2000/svg","svg");Fi.setAttribute("xmlns","http://www.w3.org/2000/svg"),Fi.setAttribute("width","24"),Fi.setAttribute("height","24");const jn=document.createElementNS("http://www.w3.org/2000/svg","path");jn.setAttribute("d","M12 2a10 10 0 1 0 10 10A10.011 10.011 0 0 0 12 2zm0 18a8 8 0 1 1 8-8 8.009 8.009 0 0 1-8 8z");const jr=document.createElementNS("http://www.w3.org/2000/svg","path");jr.setAttribute("d","m7.293 13.293 1.414 1.414L12 11.414l3.293 3.293 1.414-1.414L12 8.586l-4.707 4.707z"),Fi.appendChild(jn),Fi.appendChild(jr);const ze=document.createElement("span");ze.textContent="Bring forward",Ur.appendChild(Fi),Ur.appendChild(ze),En.appendChild(ft),En.appendChild(Ur),Tn.appendChild(En),be.appendChild(Tn),document.body.appendChild(be);for(let Wi of d.getElementsByTagName("input"))Wi.onclick=pn=>{pn.target.id==="polygon-zero-point-value"?I.toggleZeroPoint():pn.target.id==="polygon-grid-zero-point-value"?I.toggleGridZeroPoint():I.hideZeroPoint()}}static remove(w){var I=document.getElementById(w);if(I){var L=I.getElementsByClassName("filter-ctrl");L.length>0&&I.removeChild(L[0])}for(var U=0;U0&&(L[0].style.display="block");var U=I==null?void 0:I.getElementsByClassName("name-filter-button");U&&U.length>0&&(U[0].style.display="block")}static hideFilters(w){var I=document.getElementById(w),L=I==null?void 0:I.getElementsByClassName("filter-input");L&&L.length>0&&(L[0].style.display="none");var U=I==null?void 0:I.getElementsByClassName("name-filter-button");U&&U.length>0&&(U[0].style.display="none")}}const ru={enable:Q=>{setTimeout(()=>{!Q.map||!Q.map.doubleClickZoom||!Q._ctx||!Q._ctx.store||!Q._ctx.store.getInitialConfigValue||Q._ctx.store.getInitialConfigValue("doubleClickZoom")&&Q.map.doubleClickZoom.enable()},0)},disable(Q){setTimeout(()=>{!Q.map||!Q.map.doubleClickZoom||Q.map.doubleClickZoom.disable()},0)}},Qh={nameId:"rectangle-size",info:"",onSetup:function(Q){const w=this.newFeature({type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:[[]]}});return this.addFeature(w),this.clearSelectedFeatures(),ru.disable(this),this.updateUIClasses({mouse:"add"}),this.setActionableState({trash:!0}),{rectangle:w}},onTap:function(Q,w){Q.startPoint&&this.onMouseMove(Q,w),this.onClick(Q,w)},onClick:function(Q,w){Q.startPoint&&Q.startPoint[0]!==w.lngLat.lng&&Q.startPoint[1]!==w.lngLat.lat&&(this.updateUIClasses({mouse:"pointer"}),Q.endPoint=[w.lngLat.lng,w.lngLat.lat],this.changeMode("simple_select",{featuresId:Q.rectangle.id}));const I=[w.lngLat.lng,w.lngLat.lat];Q.startPoint=I},onMouseMove:function(Q,w){if(Q.startPoint){Q.rectangle.updateCoordinate("0.0",Q.startPoint[0],Q.startPoint[1]),Q.rectangle.updateCoordinate("0.1",w.lngLat.lng,Q.startPoint[1]),Q.rectangle.updateCoordinate("0.2",w.lngLat.lng,w.lngLat.lat),Q.rectangle.updateCoordinate("0.3",Q.startPoint[0],w.lngLat.lat),Q.rectangle.updateCoordinate("0.4",Q.startPoint[0],Q.startPoint[1]);var I=this.distanceBetweenCoordinates(Q.startPoint[1],Q.startPoint[0],Q.startPoint[1],w.lngLat.lng),L=this.distanceBetweenCoordinates(Q.startPoint[1],w.lngLat.lng,w.lngLat.lat,w.lngLat.lng);Q.rectangle.properties.info=I.toFixed(2)+"x"+L.toFixed(2)}},onKeyUp:function(Q,w){if(w.keyCode===27)return this.changeMode("simple_select")},onStop:function(Q){if(ru.enable(this),this.updateUIClasses({mouse:"none"}),this.activateUIButton(),this.getFeature(Q.rectangle.id)!==void 0){var w=this.map.getSource(this.nameId);w&&(this.map.removeLayer(this.nameId),this.map.removeSource(this.nameId)),Q.rectangle.removeCoordinate("0.4"),Q.rectangle.isValid()?this.map.fire("draw.create",{features:[Q.rectangle.toGeoJSON()]}):(this.deleteFeature([Q.rectangle.id],{silent:!0}),this.changeMode("simple_select",{},{silent:!0}))}},toDisplayFeatures:function(Q,w,I){const L=w.properties.id===Q.rectangle.id;if(w.properties.active=L?"true":"false",!L)return I(w);var U=this.map.getSource(this.nameId);if(U||(this.map.addSource(this.nameId,{type:"geojson",data:w}),this.map.addLayer({id:this.nameId,type:"symbol",source:this.nameId,layout:{"text-field":["get","info"],"text-size":16,"text-font":Pl.TEXT_FONTS}})),U=this.map.getSource(this.nameId),w.properties.info=Q.rectangle.properties.info,U.setData(w),!!Q.startPoint)return I(w)},onTrash:function(Q){this.deleteFeature([Q.rectangle.id],{silent:!0}),this.changeMode("simple_select")},distanceBetweenCoordinates(Q,w,I,L){var U=this.degToRad(Q),de=this.degToRad(w),M=this.degToRad(I),d=this.degToRad(L),Se=M-U,Re=d-de,He=Math.pow(Math.sin(Se/2),2)+Math.cos(U)*Math.cos(M)*Math.pow(Math.sin(Re/2),2),ce=2*Math.atan2(Math.sqrt(He),Math.sqrt(1-He)),oe=6371e3*ce;return oe},degToRad(Q){return Q*(Math.PI/180)}};class ed{constructor(w,I,L){Te(this,"geoJsonMap");Te(this,"geoJsonMapOptions");Te(this,"draw");Te(this,"buttonClass","mapbox-gl-draw_ctrl-draw-btn");Te(this,"mode","");this.geoJsonMap=w,this.draw=I,this.geoJsonMapOptions=L}onAdd(w){const I=document.createElement("div");if(I.className="maplibregl-ctrl maplibregl-ctrl-group",this.geoJsonMapOptions.allowEdit!=!1){const He=document.createElement("button");He.className="edit-btn",He.onclick=ce=>{this.geoJsonMap.toggleDraw(void 0,ce.ctrlKey)},I.appendChild(He)}const L=document.createElement("button");L.classList.add("mapbox-gl-draw_line",this.buttonClass),L.onclick=()=>{this.mode="line",this.draw.changeMode("draw_line_string")},I.appendChild(L);const U=document.createElement("button");U.classList.add("polygon-btn",this.buttonClass),U.onclick=()=>{this.mode="polygon",this.draw.changeMode("draw_polygon")},I.appendChild(U);const de=document.createElement("button");de.classList.add("mapbox-gl-draw_polygon",this.buttonClass),de.onclick=()=>{this.mode="polygon",this.draw.changeMode("draw_rectangle")},I.appendChild(de);const M=document.createElement("button");M.classList.add("mapbox-gl-draw_point",this.buttonClass),M.onclick=()=>{this.mode="point",this.draw.changeMode("draw_point")},I.appendChild(M);const d=document.createElement("button");d.classList.add("mapbox-gl-draw_trash",this.buttonClass),d.onclick=()=>{this.draw.delete(this.draw.getSelectedIds()),this.geoJsonMap.getMap().fire("draw.delete",{features:this.draw.getSelected()})},I.appendChild(d);const Se=document.createElement("button");Se.classList.add("copy-btn",this.buttonClass),Se.onclick=()=>{this.geoJsonMap.copySelectedElement()},I.appendChild(Se);const Re=document.createElement("button");return Re.classList.add("download-btn",this.buttonClass),Re.onclick=()=>{const He=JSON.stringify(this.geoJsonMap.getGeoJson()),ce=new File([He],"map.geojson",{type:"application/json"}),oe=document.createElement("a"),We=URL.createObjectURL(ce);oe.href=We,oe.download=ce.name,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe),window.URL.revokeObjectURL(We)},I.appendChild(Re),I}onRemove(w){}toggleHidden(){const w=document.getElementsByClassName(this.buttonClass);for(let I=0;I255?255:w<0?0:w}static filter(w,I){return[this.clamp(w[0]*I[0]+w[1]*I[1]+w[2]*I[2]),this.clamp(w[3]*I[0]+w[4]*I[1]+w[5]*I[2]),this.clamp(w[6]*I[0]+w[7]*I[1]+w[8]*I[2])]}static invertBlack(w){return[w*255,w*255,w*255]}static generateColors(){let w=[],I=this.invertRange[0];for(I;I<=this.invertRange[1];I+=this.invertStep){let L=this.sepiaRange[0];for(L;L<=this.sepiaRange[1];L+=this.sepiaStep){let U=this.saturateRange[0];for(U;U<=this.saturateRange[1];U+=this.saturateStep){let de=this.hueRotateRange[0];for(de;de<=this.hueRotateRange[1];de+=this.hueRotateStep){let M=this.invertBlack(I),d=this.filter(this.sepiaMatrix(L),M),Se=this.filter(this.saturateMatrix(U),d),Re=this.filter(this.hueRotateMatrix(de),Se),He={filters:{invert:I,sepia:L,saturate:U,hueRotate:de},color:Re};w.push(He)}}}}return w}static getFilters(w,I){this.possibleColors=this.possibleColors||this.generateColors();for(var L=0;L>16&255,L>>8&255,L&255].join(",")+","+I+")";throw new Error("Bad Hex")}}Te(Kt,"tolerance",1),Te(Kt,"invertRange",[0,1]),Te(Kt,"invertStep",.1),Te(Kt,"sepiaRange",[0,1]),Te(Kt,"sepiaStep",.1),Te(Kt,"saturateRange",[5,100]),Te(Kt,"saturateStep",5),Te(Kt,"hueRotateRange",[0,360]),Te(Kt,"hueRotateStep",5),Te(Kt,"possibleColors"),Te(Kt,"color",document.getElementById("color")),Te(Kt,"pixel",document.getElementById("pixel")),Te(Kt,"filtersBox",document.getElementById("filters")),Te(Kt,"button",document.getElementById("button"));class td{constructor(w,I,L,U,de){Te(this,"popupElement");Te(this,"mapElement");Te(this,"gridOverlayContainer");Te(this,"gridDetailsElement");Te(this,"activeGridElement");Te(this,"backdrop");Te(this,"gridId");Te(this,"columns");Te(this,"rows");Te(this,"disposed",!1);Te(this,"onCloseListener",()=>this.close());Te(this,"deviceGridData",[]);Te(this,"deviceGridDataNameMap",{});Te(this,"deviceGridDataGridMap",{});Te(this,"deviceLocationData",[]);Te(this,"switchMode",!1);Te(this,"gridSize",0);this.gridId=I,this.columns=parseInt(L),this.rows=parseInt(U),this.backdrop=de,this.createElement(w,this.columns,this.rows),this.prepareBackdrop()}updateData(w){if(w){var I=w.filter(U=>U.targetZones&&U.targetZones.some(de=>de.indexOf(this.gridId+":")==0&&de.split(":").length==2)).map(U=>{var de;return{deviceId:U.deviceId,name:U.name,grid:(de=U.targetZones.find(M=>M.indexOf(this.gridId+":")==0&&M.split(":").length==2))==null?void 0:de.split(":")[1]}}).map(U=>({deviceId:U.deviceId,name:U.name,x:parseInt(U.grid.split(",")[0]),y:parseInt(U.grid.split(",")[1])}));if(I.length>0)for(let U=0;UM.x==U&&M.y==de).map(M=>M.deviceId);this.deviceGridData[U][de]={deviceIds:L,deviceCount:L.length}}}this.deviceGridDataNameMap={},I.forEach(U=>{this.deviceGridDataNameMap[U.deviceId]=U.name??U.deviceId})}}updateLocationData(w){var li;if(!this.disposed){this.deviceLocationData=w;var I=w.filter(kt=>kt.grids&&kt.grids[this.gridId]);this.deviceGridDataGridMap={},I.forEach(kt=>{if(kt.grids){var Bt=kt.grids[this.gridId];this.deviceGridDataGridMap[kt.deviceId]=this.colName(Bt[0])+(Bt[1]+1)}});var L=[];for(let kt=0;ktZt.grids&&Zt.grids[this.gridId]&&Zt.grids[this.gridId][0]==kt&&Zt.grids[this.gridId][1]==Bt).map(Zt=>Zt.deviceId)}for(let kt=0;kt{if(et.includes(Zt))it++,$t.push(this.deviceGridDataNameMap[Zt]??Zt);else{var St=(xi,pi)=>!!(xi>=0&&pi>=0&&xithis.deviceGridDataNameMap[Zt]??Zt).join(", ");var ti=ce?ce.toString():" ";ce&&ce>0&&(ti+=''+oe+""),de.innerHTML=ti,M.innerHTML=''+oe+""}else de.innerHTML=" ",M.innerHTML=""}else{L[Bt][kt]&&(ce=L[Bt][kt].length,oe=L[Bt][kt].slice(0,10).map(St=>this.deviceGridDataNameMap[St]??St).join(", "),L[Bt][kt].length>10&&(oe+=", ...")),ce>0&&(d=Kt.hexToRgbA("#6ec3b4",.8),Se=Kt.hexToRgbA("#6ec3b4",1));var ti=ce?ce.toString():" ";ce&&ce>0&&(ti+=''+oe+""),de.innerHTML=ti}U.dataset.value=ce.toString(),de.style.outline="1px solid "+Se,de.style.backgroundColor=d,M.style.backgroundColor=Re,M.style.display=He}}this.updateDetails()}}createElement(w,I,L){var Mt;this.mapElement=document.getElementById(w),this.popupElement=document.createElement("div"),this.popupElement.classList.add("grid-popup");var U=this.mapElement.clientWidth*.9,de=this.mapElement.clientHeight*.9,M=U>de?de:U;M>1e3&&(M=1e3);var d=I>L?I:L,Se=Math.floor(M/d);Se>46&&(Se=46),this.gridSize=Se;var Re=Se*I+60,He=Se*L+60,ce=this.mapElement.clientWidth/2-Re/2,oe=this.mapElement.clientHeight/2-He/2;this.popupElement.style.width=Re+"px",this.popupElement.style.height=He+"px",this.popupElement.style.left=ce+"px",this.popupElement.style.top=oe+"px";var We=document.createElement("div");We.classList.add("grid-container"),We.style.gridTemplateColumns="auto repeat("+I+", 1fr) auto",We.style.gridTemplateRows="auto repeat("+L+", 1fr) auto";for(let xt=0;xt",xt==0&&Gt==0)et.style.height="20px",et.style.width="20px",et.onclick=()=>{this.switchMode=!this.switchMode,this.updateLocationData(this.deviceLocationData)};else if(Gt==I+1||xt==L+1){if(et.style.width="20px",et.style.height="20px",et.style.lineHeight="20px",xt==0){et.innerHTML='';var De=et.children[0];De.onclick=()=>this.close()}}else if(xt==0&&Gt>0)et.innerText=this.colName(Gt-1),et.classList.add("grid-header"),et.style.height="20px",et.style.lineHeight="20px";else if(Gt==0&&xt>0)et.innerText=""+xt,et.classList.add("grid-header"),et.style.width="20px";else if(Gt>0&&xt>0){var it="rgba(0,0,0,0)",$t="rgba(0,0,0,0)";et.classList.add("grid-value"),et.dataset.x=(Gt-1).toString(),et.dataset.y=(xt-1).toString(),et.style.width=Se-6+"px",et.style.height=Se-6+"px",et.style.lineHeight=Se-6+"px",et.innerHTML=`
 
${this.colName(Gt-1)+xt.toString()}
`,et.onclick=ti=>{this.showDetails(ti.currentTarget)}}We.appendChild(et)}this.popupElement.appendChild(We),this.gridOverlayContainer=document.createElement("div"),this.gridOverlayContainer.classList.add("grid-container-overlay"),this.gridOverlayContainer.onclick=()=>{this.hideDetails()},this.popupElement.appendChild(this.gridOverlayContainer),this.gridDetailsElement=document.createElement("div"),this.gridDetailsElement.classList.add("grid-details"),this.gridDetailsElement.style.width=`calc((${Se}px * 3) - 4px)`,this.gridDetailsElement.style.height=`calc((${Se}px * 3) - 4px)`,this.gridDetailsElement.innerHTML=`
NEAR5
FAR5
OUT5
`,this.popupElement.appendChild(this.gridDetailsElement);var di=this.gridDetailsElement.querySelectorAll(".grid-details-type");di.forEach(xt=>{xt.style.fontSize=`${Se/100*22}px`,xt.style.lineHeight=`${Se/100*22+2}px`}),di=this.gridDetailsElement.querySelectorAll(".grid-details-value"),di.forEach(xt=>{xt.style.fontSize=`${Se/100*42}px`,xt.style.lineHeight=`${Se/100*42-1}px`}),(Mt=this.mapElement)==null||Mt.appendChild(this.popupElement),Zo.fadeIn(this.popupElement)}colName(w){for(var I=97,L=122,U=L-I+1,de="";w>=0;)de=String.fromCharCode(w%U+I)+de,w=Math.floor(w/U)-1;return de.toUpperCase()}prepareBackdrop(){this.backdrop.onClick(this.onCloseListener),this.backdrop.show()}close(){this.backdrop.offClick(this.onCloseListener),this.disposed=!0,this.backdrop.hide(),Zo.fadeOut(this.popupElement,()=>{var w;(w=this.popupElement)==null||w.remove()}),this.hideDetails()}hideDetails(){this.gridOverlayContainer&&this.gridDetailsElement&&(Zo.fadeOut(this.gridOverlayContainer),Zo.fadeOut(this.gridDetailsElement),this.activeGridElement=void 0)}showDetails(w){if(this.deviceGridData&&this.deviceGridData.length){this.activeGridElement=w;var I=parseInt(w.dataset.value);if(I&&this.gridOverlayContainer&&this.gridDetailsElement){this.updateDetails();var L=parseInt(w.dataset.x),U=parseInt(w.dataset.y);this.gridDetailsElement.style.left=30-this.gridSize+L*this.gridSize+"px",this.gridDetailsElement.style.top=30-this.gridSize+U*this.gridSize+"px",Zo.fadeIn(this.gridOverlayContainer),Zo.fadeIn(this.gridDetailsElement)}}}updateDetails(){var ce;if(this.gridDetailsElement&&this.activeGridElement){var w=parseInt(this.activeGridElement.dataset.ok),I=this.activeGridElement.dataset.okList,L=parseInt(this.activeGridElement.dataset.neighbor),U=this.activeGridElement.dataset.neighborList,de=parseInt(this.activeGridElement.dataset.notOk),M=this.activeGridElement.dataset.notOkList,d=parseInt(this.activeGridElement.dataset.x),Se=parseInt(this.activeGridElement.dataset.y),Re=this.gridDetailsElement.querySelectorAll(".grid-details-value");Re[0].innerHTML=w.toString()+(I?`${I}`:""),Re[1].innerHTML=L.toString()+(U?`${U}`:""),Re[2].innerHTML=de.toString()+(M?`${M}`:"");var He=(ce=this.popupElement)==null?void 0:ce.getElementsByClassName("grid-details-grid-item")[0];de>0?(this.gridDetailsElement.style.backgroundColor="rgba(225,112,110,0.6)",He.style.backgroundColor="rgba(225,112,110,1)",He.style.outline="1px solid rgba(225,112,110,1)"):L>0?(this.gridDetailsElement.style.backgroundColor="rgba(207,216,126,0.6)",He.style.backgroundColor="rgba(207,216,126,1)",He.style.outline="1px solid rgba(207,216,126,1)"):(this.gridDetailsElement.style.backgroundColor="rgba(110,195,189,0.6)",He.style.backgroundColor="rgba(110,195,189,1)",He.style.outline="1px solid rgba(110,195,189,1)"),He.style.outline="1px solid rgba(255,255,255,1)",He.children[0].textContent=this.colName(d)+(Se+1),He.children[1].textContent=this.deviceGridData[d][Se].deviceCount.toString()}}}class id{constructor(w,I,L,U){Te(this,"_container");Te(this,"_map");Te(this,"_canvas");Te(this,"_mapDraw");Te(this,"_options");Te(this,"angle",0);Te(this,"controlsCreated",!1);Te(this,"sliderTimeout");this._container=w,this._map=I,this._mapDraw=L,this._options=U,this._canvas=I.getCanvasContainer(),this.init()}init(){this._map.on("draw.selectionchange",w=>{if(w.features.length===1&&w.features[0].geometry.type=="Polygon"){this.angle=0,this._drawControls();return}this.removeControls()})}dispose(){this.removeControls()}_drawControls(){if(!this.controlsCreated){this.controlsCreated=!0;var w=`
Angle:
${this.angle}
`,I=document.createElement("div");I.id="rotate-slider-"+this._container,I.classList.add("rotate-slider"),I.innerHTML=w.trim(),I.firstChild;var L=document.getElementById(this._container);L.appendChild(I);var U=I.getElementsByClassName("angle-input")[0];U.addEventListener("input",de=>{var M=parseInt(de.target.value);L.getElementsByClassName("angle")[0].innerHTML=""+M,this.sliderTimeout&&clearTimeout(this.sliderTimeout),this.sliderTimeout=setTimeout(()=>{var d=M-this.angle;this.angle=M,this.updateElement(d*-1)},0)})}}removeControls(){for(var w=document.getElementById(this._container),I=0;I-1){w.removeChild(L);break}}this.controlsCreated=!1}updateElement(w){var I=this._mapDraw.getSelected();if(I.features[0].geometry&&I.features[0].geometry.coordinates){var L=this._mapDraw.get(I.features[0].id);if(L){var U=L.geometry.coordinates[0];U=U.map(de=>[de[1],de[0]]),U=this.rotatePolygon(U,w),U=U.map(de=>[de[1],de[0]]),L.geometry.coordinates[0]=U,this._mapDraw.add(L),this._map.fire("draw.update",{action:"change_coordinates",features:[L]})}}}rotatePolygon(w,I){var L=this.calculateCentroid(w),U=I*Math.PI/180,de=w.map(function(M){var d=M[0],Se=M[1],Re=(Se-L[1])*Math.cos(L[0]*Math.PI/180),He=d-L[0],ce=Re*Math.cos(U)-He*Math.sin(U),oe=Re*Math.sin(U)+He*Math.cos(U),We=oe+L[0],et=ce/Math.cos(L[0]*Math.PI/180)+L[1];return[We,et]});return de}calculateCentroid(w){var I=0,L=0,U=w.length;return w.forEach(function(de){I+=de[0],L+=de[1]}),I/=U,L/=U,[I,L]}}var sc=function(Q,w){return sc=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(I,L){I.__proto__=L}||function(I,L){for(var U in L)Object.prototype.hasOwnProperty.call(L,U)&&(I[U]=L[U])},sc(Q,w)};function nu(Q,w){if(typeof w!="function"&&w!==null)throw new TypeError("Class extends value "+String(w)+" is not a constructor or null");sc(Q,w);function I(){this.constructor=Q}Q.prototype=w===null?Object.create(w):(I.prototype=w.prototype,new I)}function ou(Q){var w=typeof Symbol=="function"&&Symbol.iterator,I=w&&Q[w],L=0;if(I)return I.call(Q);if(Q&&typeof Q.length=="number")return{next:function(){return Q&&L>=Q.length&&(Q=void 0),{value:Q&&Q[L++],done:!Q}}};throw new TypeError(w?"Object is not iterable.":"Symbol.iterator is not defined.")}function ac(Q,w){var I=typeof Symbol=="function"&&Q[Symbol.iterator];if(!I)return Q;var L=I.call(Q),U,de=[],M;try{for(;(w===void 0||w-- >0)&&!(U=L.next()).done;)de.push(U.value)}catch(d){M={error:d}}finally{try{U&&!U.done&&(I=L.return)&&I.call(L)}finally{if(M)throw M.error}}return de}function lc(Q,w,I){if(I||arguments.length===2)for(var L=0,U=w.length,de;L{var oe;io.popupOpenDate=new Date,io.popupOpenDate.setMilliseconds(io.popupOpenDate.getMilliseconds()+100);var ce=(oe=M==null?void 0:M.events)==null?void 0:oe.popupOpen({deviceId:this.deviceId});ce!=null?gd(ce)?Re=ce.subscribe(We=>{We?Se.setHTML(We):Se.setHTML(this.name)}):Se.setHTML(ce):Se.setHTML(this.name)}),Se.on("close",He=>{Re&&Re.unsubscribe()})}moveTo(I){this._slideToUntil=performance.now()+this._slideToDuration,this._slideToLatLng=new mo.LngLat(I.longitude,I.latitude),this._slideFromLatLng=this._currentPosition,this._point.icon=I.icon,io._setIcon(this.getElement(),!!this._point.icon,this._point.icon??this._options.icon,this._options.baseIconDir,this),requestAnimationFrame(this._animateSymbol.bind(this))}static _setIcon(I,L,U,de,M){var d="url("+de+io._removeIconSettings(U)+".png)",Se=io._getFilter(U);(I.style.backgroundImage!==d||I.style.filter!==Se)&&(I.style.backgroundImage=d,I.style.filter=L?Se:"",I.style.height=L?"36px":"25px",I.style.width=L?"36px":"25px",M==null||M.setOffset(L?this._getIconPosition(U):[3,-12.5]))}static _getFilter(I){if(this._filterCache[I])return this._filterCache[I];var L=this._getIconFilterColor(I),U="";switch(L){case"red":U=Kt.getCSSFilter([230,120,110]);break;case"yellow":U=Kt.getCSSFilter([255,195,0]);break;case"green":U=Kt.getCSSFilter([52,171,23]);break;default:U=Kt.getCSSFilter([44,35,79])}return this._filterCache[I]=U,U}static _removeIconSettings(I){var L=(I??"").split("-");return L[0]}static _getIconFilterColor(I){var L=(I??"").split("-");if(L.length>1){var U=L[L.length-1].split("_");return U[0]}return null}static _getIconPosition(I){var L=(I??"").split("-");if(L.length>1){var U=L[L.length-1].split("_");if(U.length>1)switch(U[1]){case"center":return[0,0]}return[0,-14]}return[0,-14]}_animateSymbol(I){let L=this._slideToUntil-I;if(L<0){this._currentPosition=this._slideToLatLng,this.setLngLat(this._slideToLatLng);return}else{if(this._slideFromLatLng.lat!==this._slideToLatLng.lat||this._slideFromLatLng.lng!==this._slideToLatLng.lng){let U=this.map.project([this._slideFromLatLng.lng,this._slideFromLatLng.lat]),de=this.map.project([this._slideToLatLng.lng,this._slideToLatLng.lat]),M=(this._slideToDuration-L)/this._slideToDuration,d=de.mult(M).add(U.mult(1-M)),Se=this.map.unproject(d);this.setLngLat([Se.lng,Se.lat]),this._currentPosition=Se}requestAnimationFrame(this._animateSymbol.bind(this))}}};Te(io,"popupOpenDate"),Te(io,"_filterCache",{});let Ml=io;const fa=class fa{constructor(w,I,L,U,de){Te(this,"_deviceId");Te(this,"_container");Te(this,"_map");Te(this,"_route",[]);Te(this,"_routeOptions");Te(this,"_data");Te(this,"_routeData",[]);Te(this,"sliderCreated",!1);Te(this,"sliderTouched",!1);Te(this,"sliderTimeout");Te(this,"minValue");Te(this,"maxValue");this._container=w,this._deviceId=I,this._map=U,this._route=L,this._routeOptions=de.routeOptions,this._route&&this._route.length>0&&(this._route[this._route.length-1].info=""),this._drwaRoute()}append(w){this._route&&(this._route.push(w),this._routeData.push([w.longitude,w.latitude]),this._data.features.push({type:"Feature",geometry:{type:"Point",coordinates:[w.longitude,w.latitude]},properties:{name:w.info}}),this._updateSlider(),this._refreshData())}dispose(){this._destroySlider(!0)}_drwaRoute(){var I,L,U,de,M,d,Se;if(this._map)if(this._map.getSource("route")!=null&&(this._map.removeLayer("route"),this._map.removeLayer("route-circles"),this._map.removeLayer("hidden-route-circles"),this._map.removeSource("route"),this._map.off("click","route-circles",this._onClick.bind(this))),this._route&&this._route.length>0){this._drwaSlider(),this._routeData=this._route.map(Re=>[Re.longitude,Re.latitude]),this._data={type:"FeatureCollection",features:[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:this._routeData}},{type:"Feature",geometry:{type:"MultiPoint",coordinates:this._routeData},properties:{visible:"1"}}]},this._route.forEach(Re=>{this._data.features.push({type:"Feature",geometry:{type:"Point",coordinates:[Re.longitude,Re.latitude]},properties:{name:Re.info,visible:"0"}})}),this._map.addSource("route",{type:"geojson",lineMetrics:!0,data:this._data});var w=this._map.getLayer("marker-groups");this._map.addLayer({id:"route-circles",type:"circle",source:"route",paint:{"circle-color":Kt.hexToRgbA(((I=this._routeOptions)==null?void 0:I.lineColor)??"#888",.8),"circle-radius":(((L=this._routeOptions)==null?void 0:L.lineWidth)??4)*1.5},filter:["==","visible","1"]},w==null?void 0:w.id),this._map.addLayer({id:"hidden-route-circles",type:"circle",source:"route",paint:{"circle-color":"#FF0000","circle-opacity":0},filter:["==","visible","0"]},w==null?void 0:w.id),this._map.addLayer({id:"route",type:"line",source:"route",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Kt.hexToRgbA(((U=this._routeOptions)==null?void 0:U.lineColor)??"#888",1),"line-width":((de=this._routeOptions)==null?void 0:de.lineWidth)??4,"line-gradient":["interpolate",["linear"],["line-progress"],0,Kt.hexToRgbA(((M=this._routeOptions)==null?void 0:M.lineColor)??"#888",.2),.6,Kt.hexToRgbA(((d=this._routeOptions)==null?void 0:d.lineColor)??"#888",.5),1,Kt.hexToRgbA(((Se=this._routeOptions)==null?void 0:Se.lineColor)??"#888",1)]}},w==null?void 0:w.id),this._map.on("click","hidden-route-circles",this._onClick.bind(this))}else this._destroySlider()}_updateSlider(){if(!this.sliderTouched){const U=document.querySelectorAll(".range-input input");if(U.length==2){var w=0,I=this._route.length-1,L=1;U[0].min=w,U[0].max=I,U[0].step=L,U[0].value=w,U[1].min=w,U[1].max=I,U[1].step=L,U[1].value=I}}}_drwaSlider(){var d;if(!this.sliderCreated){this.sliderCreated=!0;var w=0,I=this._route.length-1,L=1,U=`
12:00 - 15:00
`,de=document.createElement("div");de.id="slider-"+this._container,de.classList.add("slider-element"),de.innerHTML=U.trim(),de.firstChild;var M=document.getElementById(this._container);M.appendChild(de),setTimeout(()=>{de.style.opacity="1"},10);const Se=document.querySelector(`#${de.id} .slider-container .range-slider`),Re=document.querySelectorAll(`#${de.id} .range-input input`),He=document.querySelector(`#${de.id} .range-date-container`);for(let ce=0;ce{this.sliderTouched=!0;let We=parseInt(Re[0].value),et=parseInt(Re[1].value);if(et-Wethis.maxValue&&this._route[We]&&this._route[et]){var xt=this._route[We].dateTime,Gt=this._route[et].dateTime;He.innerHTML=`${this._formatDate(xt)} 🡆 ${this._formatDate(Gt)}`}var ti=!1;di==0&&Mt==0&&(this.minValue=void 0,this.maxValue=void 0,this.sliderTouched=!1,this._updateSlider(),ti=!0,He.style.opacity="0"),Se.style.left=`${di}%`,Se.style.right=`${Mt}%`,this.sliderTimeout&&clearTimeout(this.sliderTimeout),this.sliderTimeout=setTimeout(()=>{this._refreshData(ti),console.log("refresh")},50)}})}}_formatDate(w){var I=new Date(w);return("0"+I.getDate()).slice(-2)+"."+("0"+(I.getMonth()+1)).slice(-2)+"."+I.getFullYear()+" "+("0"+I.getHours()).slice(-2)+":"+("0"+I.getMinutes()).slice(-2)+":"+("0"+I.getSeconds()).slice(-2)}_destroySlider(w){for(var I=document.getElementById(this._container),L=0;L-1&&U.className.indexOf("slider-element-remove")==-1){U.style.opacity="0",U.className="slider-element-remove",w?I.removeChild(U):setTimeout(()=>{I.removeChild(U)},250);break}}this.sliderCreated=!1}_refreshData(w){if(this._route){var I=this._map.getSource("route");if(I){if(w)this._routeData.splice(0,this._routeData.length),this._route.forEach(U=>{this._routeData.push([U.longitude,U.latitude])});else if(this.minValue!=null&&this.maxValue!=null){this._routeData.splice(0,this._routeData.length);for(var L=this.minValue;L<=this.maxValue;L++)this._route.length>L&&this._route[L]&&this._routeData.push([this._route[L].longitude,this._route[L].latitude])}I.setData(this._data)}}}_onClick(w){var U;fa.popupOpenDate=new Date,fa.popupOpenDate.setMilliseconds(fa.popupOpenDate.getMilliseconds()+100);const I=w.features[0].geometry.coordinates.slice();for(w.features[0].properties.description;Math.abs(w.lngLat.lng-I[0])>180;)I[0]+=w.lngLat.lng>I[0]?360:-360;var L=(U=w.features.find(de=>de.properties.name))==null?void 0:U.properties.name;L&&new mo.Popup().setLngLat(I).setHTML(L).addTo(this._map)}};Te(fa,"popupOpenDate");let Al=fa;class yd{constructor(w,I){Te(this,"_container");Te(this,"_map");Te(this,"_geoJsonMap");Te(this,"_timeFilter");this._geoJsonMap=w,this._timeFilter=I,this._container=document.createElement("div"),this._container.classList.add("maplibregl-ctrl","maplibregl-ctrl-group","time-filter-control"),this._container.style.display="none"}onAdd(w){this._map=w;var I=[1,6,12,24,48,96,168,336,504,672],L=document.createElement("select");for(const de of I){var U=document.createElement("option");U.value=de.toString(),de<168?U.text=de.toString()+"h":U.text=(de/168).toString()+"w",L.appendChild(U)}return L.value=this._timeFilter.toString(),this._container.appendChild(L),L.onchange=de=>{this._timeFilter=parseInt(L.value),this._geoJsonMap.setTimeFilter(this._timeFilter)},this._container}onRemove(w){this._container&&this._container.parentNode&&this._container.parentNode.removeChild(this._container),this._map=void 0}show(){this._container.style.display="block"}hide(){this._container.style.display="none"}}class fu{constructor(w,I,L,U,de){Te(this,"_container");Te(this,"_map");Te(this,"_canvas");Te(this,"_options");Te(this,"_mapDraw");Te(this,"_type");Te(this,"lat",0);Te(this,"lng",0);Te(this,"angle",0);Te(this,"bindElement");Te(this,"lastMode","");Te(this,"lastSelected");Te(this,"controlsCreated",!1);Te(this,"geojson");Te(this,"onMoveListener",w=>this.onMove(w));Te(this,"onMouseDownListener",w=>this.onMouseDown(w));Te(this,"onTouchstartListener",w=>this.onTouchstart(w));this._container=w,this._type=I,this._map=L,this._mapDraw=U,this._options=de,this._canvas=L.getCanvasContainer(),this.init()}init(){this.lastMode=this._mapDraw.getMode(),this.lastSelected=this._mapDraw.getSelectedIds(),this._mapDraw.changeMode("static");var w=this._mapDraw.getSelected();if(this.bindElement=this._type=="ZERO_POINT"?document.getElementById("polygon-zero-point-value"):document.getElementById("polygon-grid-zero-point-value"),w.features.length>0&&this.bindElement.style.display!="none"){var I=this.bindElement.value;if(I){var L=I.split(",");if(L.length>1){var U=L[0].split(" ");this.lat=parseFloat(U[0]),this.lng=parseFloat(U[1]),this.angle=parseInt(L[1])}}else this.lat=w.features[0].geometry.coordinates[0][0][1],this.lng=w.features[0].geometry.coordinates[0][0][0]}if(!this.lat||!this.lng){var de=this._map.getCenter();this.lat=de.lat,this.lng=de.lng}this._drawControls();var M=new Image(200,200);M.src=this._type=="ZERO_POINT"?"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwIiBoZWlnaHQ9IjI1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KIDxnPgogIDx0aXRsZT5MYXllciAxPC90aXRsZT4KICA8bGluZSBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHgxPSIxMjQiIHkxPSI1IiB4Mj0iMTI0IiB5Mj0iMjQ1IiBpZD0ic3ZnXzEiLz4KICA8bGluZSBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHgxPSI1IiB5MT0iMTI1IiB4Mj0iMjQ1IiB5Mj0iMTI1IiBpZD0ic3ZnXzEiLz4KICA8dGV4dCBmaWxsPSIjMDAwMDAwIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMCIgeD0iMjE1IiB5PSIxMTIiIGlkPSJzdmdfMiIgZm9udC1zaXplPSIyNCIgZm9udC1mYW1pbHk9IidSb2JvdG8gTW9ubyciIHRleHQtYW5jaG9yPSJzdGFydCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+K3g8L3RleHQ+CiAgPHRleHQgZmlsbD0iIzAwMDAwMCIgc3Ryb2tlPSIjMDAwIiBzdHJva2Utd2lkdGg9IjAiIHg9IjUiIHk9IjE1NSIgaWQ9InN2Z18zIiBmb250LXNpemU9IjI0IiBmb250LWZhbWlseT0iJ1JvYm90byBNb25vJyIgdGV4dC1hbmNob3I9InN0YXJ0IiB4bWw6c3BhY2U9InByZXNlcnZlIj4teDwvdGV4dD4KICA8dGV4dCBmaWxsPSIjMDAwMDAwIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMCIgeD0iOTAiIHk9IjMwIiBpZD0ic3ZnXzQiIGZvbnQtc2l6ZT0iMjQiIGZvbnQtZmFtaWx5PSInUm9ib3RvIE1vbm8nIiB0ZXh0LWFuY2hvcj0ic3RhcnQiIHhtbDpzcGFjZT0icHJlc2VydmUiPit5PC90ZXh0PgogIDx0ZXh0IGZpbGw9IiMwMDAwMDAiIHN0cm9rZT0iIzAwMCIgc3Ryb2tlLXdpZHRoPSIwIiB4PSIxMzEiIHk9IjIzOSIgaWQ9InN2Z181IiBmb250LXNpemU9IjI0IiBmb250LWZhbWlseT0iJ1JvYm90byBNb25vJyIgdGV4dC1hbmNob3I9InN0YXJ0IiB4bWw6c3BhY2U9InByZXNlcnZlIj4teTwvdGV4dD4KIDwvZz4KCjwvc3ZnPg==":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjUwIiBoZWlnaHQ9IjI1MCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KIDxnPgogIDx0aXRsZT5MYXllciAxPC90aXRsZT4KICA8bGluZSBpZD0ic3ZnXzEiIHkyPSIyNDUiIHgyPSIxMjQiIHkxPSIxMjUiIHgxPSIxMjQiIHN0cm9rZT0iIzAwMCIgZmlsbD0ibm9uZSIvPgogIDxsaW5lIGlkPSJzdmdfMSIgeTI9IjEyNSIgeDI9IjI0NSIgeTE9IjEyNSIgeDE9IjEyNSIgc3Ryb2tlPSIjMDAwIiBmaWxsPSJub25lIi8+CiAgPHRleHQgc3R5bGU9ImN1cnNvcjogbW92ZTsiIHhtbDpzcGFjZT0icHJlc2VydmUiIHRleHQtYW5jaG9yPSJzdGFydCIgZm9udC1mYW1pbHk9IidSb2JvdG8gTW9ubyciIGZvbnQtc2l6ZT0iMjQiIGlkPSJzdmdfMiIgeT0iMTEzIiB4PSIxMzgiIHN0cm9rZS13aWR0aD0iMCIgc3Ryb2tlPSIjMDAwIiBmaWxsPSIjMDAwMDAwIj5BLEIsQywuLjwvdGV4dD4KICA8dGV4dCB0cmFuc2Zvcm09InJvdGF0ZSg5MCAxMDMuNjA5IDE4NSkiIHhtbDpzcGFjZT0icHJlc2VydmUiIHRleHQtYW5jaG9yPSJzdGFydCIgZm9udC1mYW1pbHk9IidSb2JvdG8gTW9ubyciIGZvbnQtc2l6ZT0iMjQiIGlkPSJzdmdfNSIgeT0iMTk0IiB4PSI0NiIgc3Ryb2tlLXdpZHRoPSIwIiBzdHJva2U9IiMwMDAiIGZpbGw9IiMwMDAwMDAiPjEsMiwzLC4uPC90ZXh0PgogPC9nPgoKPC9zdmc+",M.onload=()=>{this._map.addImage("zero-point",M),this.geojson={type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[this.lng,this.lat]}}]},this._map.addSource("zero-point",{type:"geojson",data:this.geojson}),this._map.addLayer({id:"zero-point",type:"symbol",source:"zero-point",layout:{"icon-image":"zero-point","icon-rotate":this.angle},paint:{"icon-opacity":1}}),this._map.on("mouseenter","zero-point",()=>{this._canvas.style.cursor="move"}),this._map.on("mouseleave","zero-point",()=>{this._canvas.style.cursor=""}),this._map.on("mousedown","zero-point",this.onMouseDownListener),this._map.on("touchstart","zero-point",this.onTouchstartListener)}}dispose(){this._mapDraw.changeMode(this.lastMode,{featureIds:this.lastSelected}),this.removeControls(),this.clearMap()}onTouchstart(w){w.points.length===1&&(w.preventDefault(),this._map.on("touchmove",this.onMoveListener),this._map.once("touchend",this.onUp.bind(this)))}onMouseDown(w){w.preventDefault(),this._canvas.style.cursor="grab",this._map.on("mousemove",this.onMoveListener),this._map.once("mouseup",this.onUp.bind(this))}onMove(w){console.log("move");const I=w.lngLat;this._canvas.style.cursor="grabbing",this.geojson.features[0].geometry.coordinates=[I.lng,I.lat];var L=this._map.getSource("zero-point");L&&L.setData(this.geojson)}onUp(w){const I=w.lngLat;this.lat=I.lat,this.lng=I.lng;var L=document.getElementById("zero-point-"+this._container);L&&(L.getElementsByClassName("lat")[0].innerHTML=""+I.lat,L.getElementsByClassName("lng")[0].innerHTML=""+I.lng),this._canvas.style.cursor="",this._map.off("mousemove",this.onMoveListener),this._map.off("touchmove",this.onMoveListener),this.updateElement()}_drawControls(){if(!this.controlsCreated){this.controlsCreated=!0;var w=`
Lat: ${this.lat} Lng: ${this.lng} Angle:
${this.angle}
`,I=document.createElement("div");I.id="zero-point-"+this._container,I.classList.add("zero-point"),I.innerHTML=w.trim(),I.firstChild;var L=document.getElementById(this._container);L.appendChild(I);var U=I.getElementsByClassName("angle-input")[0];U.addEventListener("input",de=>{this.angle=parseInt(de.target.value),this._map.setLayoutProperty("zero-point","icon-rotate",this.angle),I.getElementsByClassName("angle")[0].innerHTML=""+this.angle,this.updateElement()})}}removeControls(){for(var w=document.getElementById(this._container),I=0;I-1){w.removeChild(L);break}}this.controlsCreated=!1}updateElement(){var w=`${this.lat} ${this.lng}, ${this.angle}`;this.bindElement&&(this.bindElement.value=w)}clearMap(){this._map.getSource("zero-point")!=null&&(this._map.off("mousedown","zero-point",this.onMouseDownListener),this._map.off("touchstart","zero-point",this.onTouchstartListener),this._map.removeLayer("zero-point"),this._map.removeSource("zero-point"),this._map.removeImage("zero-point"))}}const Vs=class Vs{constructor(w,I,L){Te(this,"idPrefix","sepioo-");Te(this,"buildingLayer","custom-building");Te(this,"indoorLayer","custom-indoor");Te(this,"map");Te(this,"ready",!1);Te(this,"options");Te(this,"draw");Te(this,"rotateSlider");Te(this,"container");Te(this,"disposed",!1);Te(this,"backdrop");Te(this,"gridPopup");Te(this,"isNameFilterOn",!1);Te(this,"filter","");Te(this,"filterTimeout");Te(this,"controls");Te(this,"timeFilterControl");Te(this,"timeFilter",24);Te(this,"deviceLocationDataInit",[]);Te(this,"deviceLocationData",[]);Te(this,"deviceData",[]);Te(this,"deviceDataMapping",{});Te(this,"geojson",{type:"FeatureCollection",features:[]});Te(this,"drawingEnabled",!0);Te(this,"menuState",0);Te(this,"contextMenuActive","block");Te(this,"markers",[]);Te(this,"route");Te(this,"zeroPoint");Te(this,"geotagImage");Te(this,"callback");Te(this,"events",{popupOpen:w=>{},moveEnd:w=>{},zoomEnd:w=>{}});Te(this,"onClickListener",w=>this.onClick(w));Te(this,"popupOpenDate");Te(this,"onMouseMoveListener",w=>this.onMouseMove(w));Te(this,"onMouseLeaveListener",w=>this.onMouseLeave(w));Te(this,"_runIfReadyMap",{});var U,de;this.container=w,this.options=L,(U=document.getElementById(this.container))==null||U.classList.add("geo-map"),this.map=new mo.Map({container:w,style:new URL(I,typeof document>"u"&&typeof location>"u"?require("url").pathToFileURL(__filename).href:typeof document>"u"?location.href:Sn&&Sn.src||new URL("map-editor.umd.cjs",document.baseURI).href).href,center:L.center,zoom:L.zoom}),this.applyMarkerLayers(),this._preInitFixes(),this.draw=this._createDraw(),this.rotateSlider=new id(w,this.map,this.draw,{sliderColor:(de=L.deviceRouteOptions)==null?void 0:de.lineColor}),this.controls=new ed(this,this.draw,this.options),this.timeFilterControl=new yd(this,this.timeFilter),this._createControls(),this._applyListeners(),this._postInitFixes(),this.geotagImage=L.geotagImage,this._loadImages(),this._applyOnClickListeners(),this.toggleDraw(!0),this.backdrop=new Yh(w)}applyMarkerLayers(){this._runIfReady(()=>{var I,L,U,de,M,d,Se,Re;var w=this.map.getSource("marker-cluster");w||(this.map.addSource("marker-cluster",{type:"geojson",data:{type:"FeatureCollection",features:[]},cluster:!0,clusterMaxZoom:17,clusterRadius:50}),this.map.addSource("marker-groups",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"marker-cluster",type:"circle",source:"marker-cluster",filter:["has","point_count"],paint:{"circle-radius":50,"circle-color":Kt.hexToRgbA(((L=(I=this.options)==null?void 0:I.deviceRouteOptions)==null?void 0:L.lineColor)??"#888",.6),"circle-stroke-color":Kt.hexToRgbA(((de=(U=this.options)==null?void 0:U.deviceRouteOptions)==null?void 0:de.lineColor)??"#888",1),"circle-stroke-width":2}}),this.map.addLayer({id:"marker-cluster-count",type:"symbol",source:"marker-cluster",layout:{"text-field":["get","point_count_abbreviated"],"text-size":20,"text-font":Vs.TEXT_FONTS}}),this.map.addLayer({id:"marker-groups",type:"circle",source:"marker-groups",paint:{"circle-radius":20,"circle-color":Kt.hexToRgbA(((d=(M=this.options)==null?void 0:M.deviceRouteOptions)==null?void 0:d.lineColor)??"#888",.8),"circle-stroke-color":Kt.hexToRgbA(((Re=(Se=this.options)==null?void 0:Se.deviceRouteOptions)==null?void 0:Re.lineColor)??"#888",1),"circle-stroke-width":1},minzoom:18}),this.map.addLayer({id:"marker-groups-count",type:"symbol",source:"marker-groups",layout:{"text-field":["get","point_count_abbreviated"],"text-size":14,"text-font":Vs.TEXT_FONTS},minzoom:18}),this.map.on("click","marker-cluster",He=>{if(this.popupOpenDate=new Date,this.popupOpenDate.setMilliseconds(this.popupOpenDate.getMilliseconds()+100),He.features&&He.features.length>0){var ce=He.features[0];const We=ce.properties.cluster_id;var oe=this.map.getSource("marker-cluster");oe.getClusterExpansionZoom(We).then(et=>{this.map.easeTo({center:ce.geometry.coordinates,zoom:et})})}}),this.map.on("click","marker-groups",He=>{this.popupOpenDate=new Date,this.popupOpenDate.setMilliseconds(this.popupOpenDate.getMilliseconds()+100),He.features&&He.features.length>0&&new mo.Popup().setText(He.features[0].properties.deviceIds).setLngLat(He.features[0].geometry.coordinates).addTo(this.map)}))})}_loadImages(){this.map.on("load",()=>{this._applyFilterListener()})}dispose(){var w;this.disposed=!0,this.map.remove(),this.route&&this.route.dispose(),El.remove(this.container),(w=document.getElementById(this.container))==null||w.classList.remove("geo-map")}applyCenter(w){this._runIfReady(()=>this.map.setCenter(w))}applyZoom(w){this._runIfReady(()=>this.map.setZoom(w))}applyGeoJson(w){this._runIfReady(()=>{this.geojson=w,this.render()})}applyDeviceLocationRoute(w){this._runIfReady(()=>{var I;(I=this.route)==null||I.dispose(),this.route=new Al(this.container,"test",w,this.map,{routeOptions:this.options.deviceRouteOptions})})}applyDeviceLocationRouteAppend(w){this._runIfReady(()=>{var I;(I=this.route)==null||I.append(w)})}applyDeviceData(w){this.deviceData=w,this.deviceDataMapping={},w.forEach(I=>{this.deviceDataMapping[I.deviceId]=I})}applyDeviceLocationData(w){if(this.deviceLocationDataInit=w,w.length>1){El.showFilters(this.container),this.timeFilterControl.show();var I=new Date;I.setTime(I.getTime()-this.timeFilter*60*60*1e3),this.deviceLocationData=this.deviceLocationData.filter(L=>{var U;return new Date(L.lastUpdatedAt)>I||((U=L.source)==null?void 0:U.toLocaleLowerCase())=="static"})}else El.hideFilters(this.container),this.timeFilterControl.hide();this.isNameFilterOn?this.deviceLocationData=w.filter(L=>{var U;return((U=this.deviceDataMapping[L.deviceId])==null?void 0:U.name)!=null}):this.deviceLocationData=w,this.filter&&(this.deviceLocationData=this.deviceLocationData.filter(L=>{var U;return L.deviceId.toLocaleLowerCase().includes(this.filter.toLocaleLowerCase())||(((U=this.deviceDataMapping[L.deviceId])==null?void 0:U.name)??"").toLocaleLowerCase().includes(this.filter.toLocaleLowerCase())})),this.gridPopup&&this.gridPopup.updateLocationData(this.deviceLocationData),this._runIfReady(()=>{var L=this.map.getSource("marker-cluster"),U=this.map.getSource("marker-groups");if(L&&U){var de={type:"FeatureCollection",features:[...this.deviceLocationData.map(ce=>{var oe;return{type:"Feature",id:ce.deviceId,geometry:{type:"Point",coordinates:[ce.longitude,ce.latitude]},properties:{deviceId:ce.deviceId,name:(oe=this.deviceDataMapping[ce.deviceId])==null?void 0:oe.name,icon:ce.icon,source:ce.source,lastUpdatedAt:ce.lastUpdatedAt,grids:ce.grids}}})]},M={type:"FeatureCollection",features:[]},d=[],Se={};this.deviceLocationData.forEach(ce=>{var oe="key_"+ce.latitude.toFixed(7).toString().replace(".","")+ce.longitude.toFixed(7).toString().replace(".","");Se[oe]||(Se[oe]=[]),Se[oe].push(ce)}),Object.keys(Se).forEach(ce=>{if(Se[ce].length>1){Se[ce].forEach(We=>{d.push(We.deviceId)});var oe=Se[ce][0];M.features.push({type:"Feature",id:oe.deviceId,geometry:{type:"Point",coordinates:[oe.longitude,oe.latitude]},properties:{deviceIds:Se[ce].map(We=>{var et,De;return(et=this.deviceDataMapping[We.deviceId])!=null&&et.name?(De=this.deviceDataMapping[We.deviceId])==null?void 0:De.name:We.deviceId}).join(", "),point_count_abbreviated:Se[ce].length}})}}),L.setData(de),U.setData(M);for(var Re=0;Rece.deviceId==this.markers[Re].deviceId)||(this.markers[Re].remove(),this.markers.splice(Re,1),Re--);const He=this.map.querySourceFeatures("marker-cluster");this.deviceLocationData.forEach(ce=>{var De;let oe=!1;var We=He.find(it=>it.properties.deviceId===ce.deviceId);if(!We||d.indexOf(ce.deviceId)>-1){var et=this.markers.findIndex(it=>it.deviceId==ce.deviceId);et>-1&&(this.markers[et].remove(),this.markers.splice(et,1))}else if(this.markers.forEach(it=>{it.deviceId===ce.deviceId&&(oe=!0,it.moveTo(ce))}),!oe){let it=new Ml(ce.deviceId,(De=this.deviceDataMapping[ce.deviceId])==null?void 0:De.name,ce,this.map,{events:this.events,baseIconDir:this.options.baseImageDir,icon:this.geotagImage});it.setLngLat([ce.longitude,ce.latitude]),it.addTo(this.map),this.markers.push(it)}})}},"applyDeviceLocationData")}getGeoJson(){return this.geojson}toggleZeroPoint(){var w;this.zeroPoint?(this.zeroPoint.dispose(),this.zeroPoint=void 0):this.zeroPoint=new fu(this.container,"ZERO_POINT",this.map,this.draw,{sliderColor:(w=this.options.deviceRouteOptions)==null?void 0:w.lineColor})}toggleGridZeroPoint(){var w;this.zeroPoint?(this.zeroPoint.dispose(),this.zeroPoint=void 0):this.zeroPoint=new fu(this.container,"GRID_POINT",this.map,this.draw,{sliderColor:(w=this.options.deviceRouteOptions)==null?void 0:w.lineColor})}hideZeroPoint(){this.zeroPoint&&(this.zeroPoint.dispose(),this.zeroPoint=void 0)}setTimeFilter(w){this.timeFilter=w,this.applyDeviceLocationData(this.deviceLocationDataInit)}_preInitFixes(){pa.constants.classes.CONTROL_BASE="maplibregl-ctrl",pa.constants.classes.CONTROL_PREFIX="maplibregl-ctrl-",pa.constants.classes.CONTROL_GROUP="maplibregl-ctrl-group",pa.constants.classes.BOX_SELECT="maplibregl-boxselect"}_postInitFixes(){document.getElementsByClassName("maplibregl-canvas")[0].classList.add("mapboxgl-canvas")}getMap(){return this.map}toggleDraw(w,I){var L,U;this.drawingEnabled=!this.drawingEnabled,this.drawingEnabled||(L=document.getElementById("edit-popup"))==null||L.classList.add("hidden"),this.controls.toggleHidden(),w||this._runIfReady(()=>this.render(I)),this.drawingEnabled||(this.rotateSlider.dispose(),(U=this.zeroPoint)==null||U.dispose(),this.zeroPoint=void 0)}render(w){var I;if(this.draw.deleteAll(),this._clearMap(this.idPrefix),!this.map.getSource(this.buildingLayer)||!this.map.getSource(this.indoorLayer)||!this.map.getLayer(this.buildingLayer)||!this.map.getLayer(this.indoorLayer)){this.map.addSource(this.buildingLayer,{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addSource(this.indoorLayer,{type:"geojson",data:{type:"FeatureCollection",features:[]}});let U=(I=this.map.getStyle().layers.find(de=>de.id=="marker-cluster"))==null?void 0:I.id;this.map.addLayer({id:this.indoorLayer,type:"fill",source:this.indoorLayer},U),this.map.addLayer({id:this.buildingLayer,type:"fill",source:this.buildingLayer},this.indoorLayer)}this.geojson.features&&this.geojson.features.forEach(L=>{if(this.drawingEnabled){this.draw.add(L),L.geometry.type==="Polygon"&&L.properties!==void 0&&L.properties!==null&&L.properties.image!==void 0&&L.properties.image!==""&&this.applyImage(L,!0);return}switch(L.geometry.type){case"Polygon":L.properties!==void 0&&L.properties!==null&&L.properties.image!==void 0&&L.properties.image!==""?this.applyImage(L):this.applyFill(L);break;case"Point":this.applyPoint(L);break;case"LineString":this.applyLine(L);break;default:console.log("Unsupported geometry type: "+L.geometry.type);return}}),document.getElementById("current-zoom-level").value=this.map.getZoom().toString()}_clearMap(w){var I=this.map.getLayersOrder();I.filter(L=>L.startsWith(w)&&!L.endsWith("-name")).forEach(L=>{this.map.off("click",L,this.onClickListener),this.map.off("mouseenter",L,this.onMouseMoveListener),this.map.off("mouseleave",L,this.onMouseLeaveListener),this.map.removeLayer(L);var U=I.find(de=>de===L+"-name");U&&this.map.removeLayer(U),this.map.getSource(L)!==void 0&&this.map.removeSource(L)})}applyPoint(w){this.map.addSource(this.idPrefix+w.id,{type:"geojson",data:w}),this.map.addLayer({id:this.idPrefix+w.id,type:"symbol",source:this.idPrefix+w.id,layout:{"icon-image":"point","text-font":Vs.TEXT_FONTS},maxzoom:this.getMaxZoom(w),minzoom:this.getMinZoom(w)})}applyImage(w,I){let L={};this.setPaint(L,"raster-opacity",w);let U=w.geometry.coordinates[0];U=U.slice(0,4),this.map.addSource(this.idPrefix+w.id,{type:"image",url:w.properties.image,coordinates:U});let de=this.indoorLayer;if(w.properties!==void 0&&w.properties!==null&&w.properties.objecttype!==void 0&&w.properties.objecttype===this.buildingLayer&&(de=this.buildingLayer),I){var M=this.map.getLayersOrder(),d=M.find(Se=>Se.startsWith("gl-draw-polygon"));d&&(de=d)}this.map.addLayer({id:this.idPrefix+w.id,type:"raster",source:this.idPrefix+w.id,paint:L,maxzoom:this.getMaxZoom(w),minzoom:this.getMinZoom(w)},de),I||(this.map.addSource(this.idPrefix+w.id+"-overlay",{type:"geojson",data:w}),this.map.addLayer({id:this.idPrefix+w.id+"-overlay",type:"fill",source:this.idPrefix+w.id+"-overlay",paint:{"fill-opacity":0}},de),w&&w.properties&&w.properties["grid-id"]&&w.properties["grid-size"]&&w.properties["grid-x"]&&w.properties["grid-y"]&&(this.map.on("click",this.idPrefix+w.id+"-overlay",this.onClickListener),this.map.on("mouseleave",this.idPrefix+w.id+"-overlay",this.onMouseLeaveListener),this.map.on("mousemove",this.idPrefix+w.id+"-overlay",this.onMouseMoveListener)))}applyLine(w){let I={};w.properties!==void 0&&w.properties!==null?(this.setPaint(I,"line-color",w),this.setPaint(I,"line-width",w)):I={"line-color":"#2d2350","line-width":2},this.map.addSource(this.idPrefix+w.id,{type:"geojson",data:w});let L=this.indoorLayer;w.properties!==void 0&&w.properties!==null&&w.properties.objecttype!==void 0&&w.properties.objecttype===this.buildingLayer&&(L=this.buildingLayer),this.map.addLayer({id:this.idPrefix+w.id,type:"line",source:this.idPrefix+w.id,paint:I,maxzoom:this.getMaxZoom(w),minzoom:this.getMinZoom(w)},L)}setPaint(w,I,L){L.properties&&L.properties[I]!==void 0&&L.properties[I]!==null&&L.properties[I]!==""&&(I==="line-color"?w["fill-outline-color"]=L.properties[I]:I==="line-width"?w["stroke-width"]=L.properties[I]:w[I]=L.properties[I])}applyFill(w){let I={};w.properties!==void 0&&w.properties!==null?(this.setPaint(I,"fill-color",w),this.setPaint(I,"fill-opacity",w),this.setPaint(I,"line-color",w)):I={"fill-color":"#2d2350","fill-opacity":.2,"stroke-color":"#000000"};let L=this.indoorLayer;w.properties!==void 0&&w.properties!==null&&w.properties.objecttype!==void 0&&w.properties.objecttype===this.buildingLayer&&(L=this.buildingLayer),this.map.addSource(this.idPrefix+w.id,{type:"geojson",data:w}),this.map.addLayer({id:this.idPrefix+w.id,type:"fill",source:this.idPrefix+w.id,paint:I},L),this.map.addLayer({id:this.idPrefix+w.id+"-name",type:"symbol",source:this.idPrefix+w.id,layout:{"text-field":["get","name"],"text-size":12,"text-font":Vs.TEXT_FONTS},maxzoom:this.getMaxZoom(w),minzoom:this.getMinZoom(w)},L),w&&w.properties&&w.properties["grid-id"]&&w.properties["grid-size"]&&w.properties["grid-x"]&&w.properties["grid-y"]&&(this.map.on("click",this.idPrefix+w.id,this.onClickListener),this.map.on("mouseleave",this.idPrefix+w.id,this.onMouseLeaveListener),this.map.on("mousemove",this.idPrefix+w.id,this.onMouseMoveListener))}onClick(w){var I=w.features;setTimeout(()=>{new Date>(Ml.popupOpenDate??new Date(0))&&new Date>(Al.popupOpenDate??new Date(0))&&new Date>(this.popupOpenDate??new Date(0))&&I[0].properties["grid-id"]&&I[0].properties["grid-size"]&&I[0].properties["grid-x"]&&I[0].properties["grid-y"]&&(this.gridPopup=new td(this.container,I[0].properties["grid-id"],I[0].properties["grid-x"],I[0].properties["grid-y"],this.backdrop),this.gridPopup.updateData(this.deviceData),this.gridPopup.updateLocationData(this.deviceLocationData),this.popupOpenDate=new Date,this.popupOpenDate.setMilliseconds(this.popupOpenDate.getMilliseconds()+100))},10)}onMouseMove(w){w.features[0].properties["grid-id"]&&(this.map.getCanvas().style.cursor="pointer")}onMouseLeave(w){this.map.getCanvas().style.cursor="",console.log(w)}getMinZoom(w){if(w.properties&&w.properties["min-zoom-level"]!==null&&w.properties["min-zoom-level"]!==void 0){var I=parseInt(w.properties["min-zoom-level"]);if(typeof I=="number"&&!isNaN(I))return I}return 0}getMaxZoom(w){if(w.properties&&w.properties["max-zoom-level"]!==null&&w.properties["max-zoom-level"]!==void 0){var I=parseInt(w.properties["max-zoom-level"]);if(typeof I=="number"&&!isNaN(I))return I}return 0}_sendGeoJson(w){this.geojson=w,this.callback&&this.callback(JSON.stringify(w))}_createDraw(){var w={};w.onSetup=function(){return this.setActionableState(),{}},w.toDisplayFeatures=function(U,de,M){M(de)};var I=pa.modes;I.static=w,I.draw_rectangle=Qh;var L=new pa({displayControlsDefault:!1,keybindings:!1,modes:I,controls:{polygon:!1,point:!1,line_string:!1,trash:!1}});return L}_createControls(){this.map.addControl(new mo.GeolocateControl({positionOptions:{enableHighAccuracy:!0},trackUserLocation:!0}),"top-left"),this.map.addControl(new mo.NavigationControl({visualizePitch:!0}),"top-left"),this.map.addControl(this.timeFilterControl,"top-left"),this.map.addControl(this.draw,"top-right"),this.map.addControl(this.controls,"top-right"),El.init(this.container,this)}_applyListeners(){var L,U,de;this.map.on("load",()=>{this.ready=!0}),this.map.on("zoomend",M=>{this.applyDeviceLocationData(this.deviceLocationDataInit),this.events.zoomEnd({zoom:this.map.getZoom()})});const w=()=>{const M=this.draw.getAll();this._sendGeoJson(M)},I=()=>{var M;(M=document.getElementById("edit-popup"))==null||M.classList.add("hidden"),w()};this.map.on("draw.create",M=>{w()}),this.map.on("draw.update",w),this.map.on("draw.delete",I),this.map.on("draw.selectionchange",M=>{var d;if(M.features.length!==1){(d=document.getElementById("edit-popup"))==null||d.classList.add("hidden");return}this._displayEditPopup(M.features[0])}),(L=document.getElementById("button-save"))==null||L.addEventListener("click",M=>{this._savePopup()}),this.map.on("contextmenu",M=>{this.draw.getSelected().features.length===1&&(M.preventDefault(),this.toggleMenuOn(),this.positionMenu(M))}),this.map.on("click",M=>{this.toggleMenuOff()}),(U=document.getElementById("bringBackward"))==null||U.addEventListener("click",M=>{let d=this.draw.getSelected();if(d.features.length!==1)return;let Se=d.features[0],Re=this.geojson.features.findIndex(He=>He.id===Se.id);Re>0&&(this.geojson.features.splice(Re,1),this.geojson.features.splice(Re-1,0,Se),this._sendGeoJson(this.geojson)),this.toggleMenuOff()}),(de=document.getElementById("bringForward"))==null||de.addEventListener("click",M=>{let d=this.draw.getSelected();if(d.features.length!==1)return;let Se=d.features[0],Re=this.geojson.features.findIndex(He=>He.id===Se.id);Re{var d=this.map.getCenter();this.events.moveEnd({center:[d.lng,d.lat]})})}toggleMenuOn(){if(this.menuState!=1){this.menuState=1;let w=document.querySelector(".context-menu");w==null||w.classList.add(this.contextMenuActive)}}toggleMenuOff(){if(this.menuState!=0){this.menuState=0;let w=document.querySelector(".context-menu");w==null||w.classList.remove(this.contextMenuActive)}}positionMenu(w){let I=document.querySelector(".context-menu"),L=this.getPosition(w),U=L.x,de=L.y,M=(I==null?void 0:I.offsetWidth)+4,d=(I==null?void 0:I.offsetHeight)+4,Se=window.innerWidth,Re=window.innerHeight;Se-U{this.geojson.features.filter(I=>I.id===w).forEach(I=>{var L,U,de,M,d,Se,Re,He,ce,oe,We,et,De,it,$t,di,Mt,xt,Gt,ti;if(I.properties["min-zoom-level"]=parseFloat((L=document.getElementById("min-zoom-level"))==null?void 0:L.value),I.properties["max-zoom-level"]=parseFloat((U=document.getElementById("max-zoom-level"))==null?void 0:U.value),I.properties.name=(de=document.getElementById("general-name"))==null?void 0:de.value,I.geometry.type=="Polygon"){I.properties["grid-id"]=(M=document.getElementById("polygon-grid-id"))==null?void 0:M.value,I.properties["grid-zero-point-value"]=(d=document.getElementById("polygon-grid-zero-point-value"))==null?void 0:d.value,I.properties["grid-size"]=(Se=document.getElementById("polygon-grid-size"))==null?void 0:Se.value,I.properties["grid-x"]=(Re=document.getElementById("polygon-grid-x"))==null?void 0:Re.value,I.properties["grid-y"]=(He=document.getElementById("polygon-grid-y"))==null?void 0:He.value,I.properties["zero-point-id"]=(ce=document.getElementById("polygon-zero-point-id"))==null?void 0:ce.value,I.properties["zero-point-value"]=(oe=document.getElementById("polygon-zero-point-value"))==null?void 0:oe.value,I.properties.zone=(We=document.getElementById("polygon-zone"))==null?void 0:We.value,I.properties["line-color"]=(et=document.getElementById("polygon-line-color"))==null?void 0:et.value,I.properties.image=(De=document.getElementById("polygon-image"))==null?void 0:De.value,I.properties.objecttype=(it=document.getElementById("polygon-type"))==null?void 0:it.value;let li=($t=document.getElementById("polygon-color"))==null?void 0:$t.value;I.properties["fill-color"]=li,((di=document.getElementById("polygon-opacity"))==null?void 0:di.value)!=null&&((Mt=document.getElementById("polygon-opacity"))==null?void 0:Mt.value)!==""&&(I.properties["fill-opacity"]=parseFloat((xt=document.getElementById("polygon-opacity"))==null?void 0:xt.value))}else I.geometry.type=="Line"&&(I.properties["line-color"]=(Gt=document.getElementById("line-color"))==null?void 0:Gt.value,I.properties["line-width"]=parseFloat((ti=document.getElementById("line-width"))==null?void 0:ti.value))})}),this._sendGeoJson(this.geojson)}_displayEditPopup(w){var L,U,de,M,d,Se,Re,He,ce,oe;let I;if(this.geojson.features.filter(We=>We.id===w.id).forEach(We=>{I=We}),I!=null&&I!=null){switch(document.getElementById("min-zoom-level").value="",document.getElementById("max-zoom-level").value="",document.getElementById("polygon-image").value="",document.getElementById("polygon-color").value="",document.getElementById("polygon-opacity").value="",document.getElementById("line-color").value="",document.getElementById("line-width").value="",document.getElementById("general-name").value="",document.getElementById("polygon-zone").value="",document.getElementById("polygon-type").value=this.indoorLayer,I.geometry.type){case"Polygon":(L=document.getElementById("polygon"))==null||L.classList.remove("hidden"),(U=document.getElementById("point"))==null||U.classList.add("hidden"),(de=document.getElementById("line"))==null||de.classList.add("hidden"),I.properties!==void 0&&I.properties!==null&&(document.getElementById("polygon-grid-id").value=I.properties["grid-id"]!==void 0?I.properties["grid-id"]:"",document.getElementById("polygon-grid-zero-point-value").value=I.properties["grid-zero-point-value"]!==void 0?I.properties["grid-zero-point-value"]:"",document.getElementById("polygon-grid-size").value=I.properties["grid-size"]!==void 0?I.properties["grid-size"]:"",document.getElementById("polygon-grid-x").value=I.properties["grid-x"]!==void 0?I.properties["grid-x"]:"",document.getElementById("polygon-grid-y").value=I.properties["grid-y"]!==void 0?I.properties["grid-y"]:"",document.getElementById("polygon-zero-point-id").value=I.properties["zero-point-id"]!==void 0?I.properties["zero-point-id"]:"",document.getElementById("polygon-zero-point-value").value=I.properties["zero-point-value"]!==void 0?I.properties["zero-point-value"]:"",document.getElementById("polygon-zone").value=I.properties.zone!==void 0?I.properties.zone:"",document.getElementById("polygon-image").value=I.properties.image!==void 0?I.properties.image:"",document.getElementById("polygon-color").value=I.properties["fill-color"]!==void 0?I.properties["fill-color"]:"",document.getElementById("polygon-opacity").value=I.properties["fill-opacity"]!==void 0?I.properties["fill-opacity"]:"",document.getElementById("polygon-line-color").value=I.properties["line-color"]!==void 0?I.properties["line-color"]:"",document.getElementById("polygon-type").value=I.properties.objecttype!==void 0?I.properties.objecttype:"");break;case"Point":(M=document.getElementById("polygon"))==null||M.classList.add("hidden"),(d=document.getElementById("point"))==null||d.classList.remove("hidden"),(Se=document.getElementById("line"))==null||Se.classList.add("hidden");break;case"LineString":(Re=document.getElementById("polygon"))==null||Re.classList.add("hidden"),(He=document.getElementById("point"))==null||He.classList.add("hidden"),(ce=document.getElementById("line"))==null||ce.classList.remove("hidden"),I.properties!==void 0&&I.properties!==null&&(document.getElementById("line-color").value=I.properties["line-color"]!==void 0?I.properties["line-color"]:"",document.getElementById("line-width").value=I.properties["line-width"]!==void 0?I.properties["line-width"]:"");break}I.properties!==void 0&&I.properties!==null&&(document.getElementById("general-name").value=I.properties.name!==void 0?I.properties.name:"",document.getElementById("min-zoom-level").value=I.properties["min-zoom-level"]!==void 0&&I.properties["min-zoom-level"]!==null&&Number.isNaN(I.properties["min-zoom-level"])===!1?I.properties["min-zoom-level"]:"",document.getElementById("max-zoom-level").value=I.properties["max-zoom-level"]!==void 0&&I.properties["max-zoom-level"]!==null&&Number.isNaN(I.properties["max-zoom-level"])===!1?I.properties["max-zoom-level"]:""),(oe=document.getElementById("edit-popup"))==null||oe.classList.remove("hidden")}}_applyOnClickListeners(){this.map.on("click","devices",w=>{if(w.features!=null){const I=w.features[0].geometry.coordinates.slice(),L=w.features[0].properties.description;for(;Math.abs(w.lngLat.lng-I[0])>180;)I[0]+=w.lngLat.lng>I[0]?360:-360;new mo.Popup().setLngLat(I).setHTML(L).addTo(this.map)}})}_applyFilterListener(){let w=document.getElementById("filter-input");w!==null&&w.addEventListener("keyup",L=>{L!=null&&L.target!=null&&(this.filter=L.target.value,this.filterTimeout!=null&&clearTimeout(this.filterTimeout),this.filterTimeout=setTimeout(()=>{this.applyDeviceLocationData(this.deviceLocationDataInit)},250))});let I=document.getElementById("name-filter-button");I!==null&&(I.onclick=()=>{this.isNameFilterOn=!this.isNameFilterOn,this.applyDeviceLocationData(this.deviceLocationDataInit)})}copySelectedElement(){let w=this.draw.getSelected();if(w.features.length!==1)return;let I=w.features[0],L=JSON.parse(JSON.stringify(I));L.id=Kh(),L.properties.name=L.properties.name+" copy",this.geojson.features.push(L),this.draw.add(L),this.render(),this.draw.changeMode("simple_select",{featureIds:[L.id]}),this._displayEditPopup(L)}setGeoJson(w){this.applyGeoJson(JSON.parse(w))}setDevices(w){this.applyDeviceLocationData(w)}registerGeoJsonSaveEvent(w){this.callback=w}on(w,I){this.events[w]=I}_runIfReady(w,I,L){if(!this.disposed){if(this.ready)w();else if(L??0<500){I&&this._runIfReadyMap[I]&&clearTimeout(this._runIfReadyMap[I]);var U=setTimeout(()=>{I&&this._runIfReadyMap[I]&&delete this._runIfReadyMap[I],this._runIfReady(w,I,(L??0)+1)},10);I&&(this._runIfReadyMap[I]=U)}}}};Te(Vs,"TEXT_FONTS",["Noto Sans Regular"]);let Pl=Vs;var mu=(Q=>(Q.popupOpen="popupOpen",Q.moveEnd="moveEnd",Q.zoomEnd="zoomEnd",Q))(mu||{});On.GeoJsonMap=Pl,On.GeoJsonMapEventType=mu,Object.defineProperty(On,Symbol.toStringTag,{value:"Module"})});