=S&&l.y{this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=jo(this._options,this.map._requestManager,(P,B)=>{this._tileJSONRequest=null,this._loaded=!0,this.map.style.sourceCaches[this.id].clearTiles(),P?this.fire(new s.j(P)):B&&(s.e(this,B),B.bounds&&(this.tileBounds=new qs(B.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})},this.serialize=()=>s.e({},this._options),this.id=l,this.dispatcher=v,this.type="vector",this.minzoom=0,this.maxzoom=22,this.scheme="xyz",this.tileSize=512,this.reparseOverscaled=!0,this.isTileClipped=!0,this._loaded=!1,s.e(this,s.F(A,["url","scheme","tileSize","promoteId"])),this._options=s.e({type:"vector"},A),this._collectResourceTiming=A.collectResourceTiming,this.tileSize!==512)throw new Error("vector tile sources must have a tileSize of 512");this.setEventedParent(S)}loaded(){return this._loaded}hasTile(l){return!this.tileBounds||this.tileBounds.contains(l.canonical)}onAdd(l){this.map=l,this.load()}setSourceProperty(l){this._tileJSONRequest&&this._tileJSONRequest.cancel(),l(),this.load()}setTiles(l){return this.setSourceProperty(()=>{this._options.tiles=l}),this}setUrl(l){return this.setSourceProperty(()=>{this.url=l,this._options.url=l}),this}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}loadTile(l,A){let v=l.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),S={request:this.map._requestManager.transformRequest(v,$.Tile),uid:l.uid,tileID:l.tileID,zoom:l.tileID.overscaledZ,tileSize:this.tileSize*l.tileID.overscaleFactor(),type:this.type,source:this.id,pixelRatio:this.map.getPixelRatio(),showCollisionBoxes:this.map.showCollisionBoxes,promoteId:this.promoteId};function P(B,F){return delete l.request,l.aborted?A(null):B&&B.status!==404?A(B):(F&&F.resourceTiming&&(l.resourceTiming=F.resourceTiming),this.map._refreshExpiredTiles&&F&&l.setExpiryData(F),l.loadVectorData(F,this.map.painter),A(null),void(l.reloadCallback&&(this.loadTile(l,l.reloadCallback),l.reloadCallback=null)))}S.request.collectResourceTiming=this._collectResourceTiming,l.actor&&l.state!=="expired"?l.state==="loading"?l.reloadCallback=A:l.request=l.actor.send("reloadTile",S,P.bind(this)):(l.actor=this.dispatcher.getActor(),l.request=l.actor.send("loadTile",S,P.bind(this)))}abortTile(l){l.request&&(l.request.cancel(),delete l.request),l.actor&&l.actor.send("abortTile",{uid:l.uid,type:this.type,source:this.id},void 0)}unloadTile(l){l.unloadVectorData(),l.actor&&l.actor.send("removeTile",{uid:l.uid,type:this.type,source:this.id},void 0)}hasTransition(){return!1}}class kc extends s.E{constructor(l,A,v,S){super(),this.id=l,this.dispatcher=v,this.setEventedParent(S),this.type="raster",this.minzoom=0,this.maxzoom=22,this.roundZoom=!0,this.scheme="xyz",this.tileSize=512,this._loaded=!1,this._options=s.e({type:"raster"},A),s.e(this,s.F(A,["url","scheme","tileSize"]))}load(){this._loaded=!1,this.fire(new s.k("dataloading",{dataType:"source"})),this._tileJSONRequest=jo(this._options,this.map._requestManager,(l,A)=>{this._tileJSONRequest=null,this._loaded=!0,l?this.fire(new s.j(l)):A&&(s.e(this,A),A.bounds&&(this.tileBounds=new qs(A.bounds,this.minzoom,this.maxzoom)),this.fire(new s.k("data",{dataType:"source",sourceDataType:"metadata"})),this.fire(new s.k("data",{dataType:"source",sourceDataType:"content"})))})}loaded(){return this._loaded}onAdd(l){this.map=l,this.load()}onRemove(){this._tileJSONRequest&&(this._tileJSONRequest.cancel(),this._tileJSONRequest=null)}setSourceProperty(l){this._tileJSONRequest&&this._tileJSONRequest.cancel(),l(),this.load()}setTiles(l){return this.setSourceProperty(()=>{this._options.tiles=l}),this}serialize(){return s.e({},this._options)}hasTile(l){return!this.tileBounds||this.tileBounds.contains(l.canonical)}loadTile(l,A){let v=l.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme);l.request=V.getImage(this.map._requestManager.transformRequest(v,$.Tile),(S,P,B)=>{if(delete l.request,l.aborted)l.state="unloaded",A(null);else if(S)l.state="errored",A(S);else if(P){this.map._refreshExpiredTiles&&B&&l.setExpiryData(B);let F=this.map.painter.context,U=F.gl;l.texture=this.map.painter.getTileTexture(P.width),l.texture?l.texture.update(P,{useMipmap:!0}):(l.texture=new He(F,P,U.RGBA,{useMipmap:!0}),l.texture.bind(U.LINEAR,U.CLAMP_TO_EDGE,U.LINEAR_MIPMAP_NEAREST),F.extTextureFilterAnisotropic&&U.texParameterf(U.TEXTURE_2D,F.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,F.extTextureFilterAnisotropicMax)),l.state="loaded",A(null)}},this.map._refreshExpiredTiles)}abortTile(l,A){l.request&&(l.request.cancel(),delete l.request),A()}unloadTile(l,A){l.texture&&this.map.painter.saveTileTexture(l.texture),A()}hasTransition(){return!1}}class Lc extends kc{constructor(l,A,v,S){super(l,A,v,S),this.type="raster-dem",this.maxzoom=22,this._options=s.e({type:"raster-dem"},A),this.encoding=A.encoding||"mapbox",this.redFactor=A.redFactor,this.greenFactor=A.greenFactor,this.blueFactor=A.blueFactor,this.baseShift=A.baseShift}loadTile(l,A){let v=l.tileID.canonical.url(this.tiles,this.map.getPixelRatio(),this.scheme),S=this.map._requestManager.transformRequest(v,$.Tile);function P(B,F){B&&(l.state="errored",A(B)),F&&(l.dem=F,l.needsHillshadePrepare=!0,l.needsTerrainPrepare=!0,l.state="loaded",A(null))}l.neighboringTiles=this._getNeighboringTiles(l.tileID),l.request=V.getImage(S,(B,F,U)=>s._(this,void 0,void 0,function*(){if(delete l.request,l.aborted)l.state="unloaded",A(null);else if(B)l.state="errored",A(B);else if(F){this.map._refreshExpiredTiles&&l.setExpiryData(U);let H=s.a(F)&&s.J()?F:yield function(X){return s._(this,void 0,void 0,function*(){if(typeof VideoFrame<"u"&&s.K()){let se=X.width+2,ge=X.height+2;try{return new s.R({width:se,height:ge},yield s.M(X,-1,-1,se,ge))}catch{}}return s.h.getImageData(X,1)})}(F),Y={uid:l.uid,coord:l.tileID,source:this.id,rawImageData:H,encoding:this.encoding,redFactor:this.redFactor,greenFactor:this.greenFactor,blueFactor:this.blueFactor,baseShift:this.baseShift};l.actor&&l.state!=="expired"||(l.actor=this.dispatcher.getActor(),l.actor.send("loadDEMTile",Y,P))}}),this.map._refreshExpiredTiles)}_getNeighboringTiles(l){let A=l.canonical,v=Math.pow(2,A.z),S=(A.x-1+v)%v,P=A.x===0?l.wrap-1:l.wrap,B=(A.x+1+v)%v,F=A.x+1===v?l.wrap+1:l.wrap,U={};return U[new s.O(l.overscaledZ,P,A.z,S,A.y).key]={backfilled:!1},U[new s.O(l.overscaledZ,F,A.z,B,A.y).key]={backfilled:!1},A.y>0&&(U[new s.O(l.overscaledZ,P,A.z,S,A.y-1).key]={backfilled:!1},U[new s.O(l.overscaledZ,l.wrap,A.z,A.x,A.y-1).key]={backfilled:!1},U[new s.O(l.overscaledZ,F,A.z,B,A.y-1).key]={backfilled:!1}),A.y+1 =0;this.currentLayer--){let U=this.style._layers[v[this.currentLayer]],H=S[U.source],Y=P[U.source];this._renderTileClippingMasks(U,Y),this.renderLayer(this,H,U,Y)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer