mobility-toolbox-js 3.1.0-beta.0 → 3.1.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/mbt.min.js CHANGED
@@ -574,7 +574,7 @@ uniform ${D} ${F} u_${j};
574
574
  #endif
575
575
  `}),staticAttributes:d,staticUniforms:S}}class Zc{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(t,l,d,p,m,S,E,M,R){this.context=t;let D=this.boundPaintVertexBuffers.length!==p.length;for(let F=0;!D&&F<p.length;F++)this.boundPaintVertexBuffers[F]!==p[F]&&(D=!0);!this.vao||this.boundProgram!==l||this.boundLayoutVertexBuffer!==d||D||this.boundIndexBuffer!==m||this.boundVertexOffset!==S||this.boundDynamicVertexBuffer!==E||this.boundDynamicVertexBuffer2!==M||this.boundDynamicVertexBuffer3!==R?this.freshBind(l,d,p,m,S,E,M,R):(t.bindVertexArray.set(this.vao),E&&E.bind(),m&&m.dynamicDraw&&m.bind(),M&&M.bind(),R&&R.bind())}freshBind(t,l,d,p,m,S,E,M){let R=t.numAttributes,D=this.context,F=D.gl;this.vao&&this.destroy(),this.vao=D.createVertexArray(),D.bindVertexArray.set(this.vao),this.boundProgram=t,this.boundLayoutVertexBuffer=l,this.boundPaintVertexBuffers=d,this.boundIndexBuffer=p,this.boundVertexOffset=m,this.boundDynamicVertexBuffer=S,this.boundDynamicVertexBuffer2=E,this.boundDynamicVertexBuffer3=M,l.enableAttributes(F,t);for(let j of d)j.enableAttributes(F,t);S&&S.enableAttributes(F,t),E&&E.enableAttributes(F,t),M&&M.enableAttributes(F,t),l.bind(),l.setVertexAttribPointers(F,t,m);for(let j of d)j.bind(),j.setVertexAttribPointers(F,t,m);S&&(S.bind(),S.setVertexAttribPointers(F,t,m)),p&&p.bind(),E&&(E.bind(),E.setVertexAttribPointers(F,t,m)),M&&(M.bind(),M.setVertexAttribPointers(F,t,m)),D.currentNumAttributes=R}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}let Xc=(g,t,l,d,p)=>({u_matrix:g,u_texture:0,u_ele_delta:t,u_fog_matrix:l,u_fog_color:d?d.properties.get("fog-color"):s.aM.white,u_fog_ground_blend:d?d.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:d?d.calculateFogBlendOpacity(p):0,u_horizon_color:d?d.properties.get("horizon-color"):s.aM.white,u_horizon_fog_blend:d?d.properties.get("horizon-fog-blend"):1});function Ro(g){let t=[];for(let l=0;l<g.length;l++){if(g[l]===null)continue;let d=g[l].split(" ");t.push(d.pop())}return t}class Hc{constructor(t,l,d,p,m,S){let E=t.gl;this.program=E.createProgram();let M=Ro(l.staticAttributes),R=d?d.getBinderAttributes():[],D=M.concat(R),F=ks.prelude.staticUniforms?Ro(ks.prelude.staticUniforms):[],j=l.staticUniforms?Ro(l.staticUniforms):[],W=d?d.getBinderUniforms():[],Z=F.concat(j).concat(W),Y=[];for(let ge of Z)Y.indexOf(ge)<0&&Y.push(ge);let te=d?d.defines():[];m&&te.push("#define OVERDRAW_INSPECTOR;"),S&&te.push("#define TERRAIN3D;");let re=te.concat(ks.prelude.fragmentSource,l.fragmentSource).join(`
576
576
  `),ne=te.concat(ks.prelude.vertexSource,l.vertexSource).join(`
577
- `),H=E.createShader(E.FRAGMENT_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(H,re),E.compileShader(H),!E.getShaderParameter(H,E.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${E.getShaderInfoLog(H)}`);E.attachShader(this.program,H);let ce=E.createShader(E.VERTEX_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(ce,ne),E.compileShader(ce),!E.getShaderParameter(ce,E.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${E.getShaderInfoLog(ce)}`);E.attachShader(this.program,ce),this.attributes={};let ue={};this.numAttributes=D.length;for(let ge=0;ge<this.numAttributes;ge++)D[ge]&&(E.bindAttribLocation(this.program,ge,D[ge]),this.attributes[D[ge]]=ge);if(E.linkProgram(this.program),!E.getProgramParameter(this.program,E.LINK_STATUS))throw new Error(`Program failed to link: ${E.getProgramInfoLog(this.program)}`);E.deleteShader(ce),E.deleteShader(H);for(let ge=0;ge<Y.length;ge++){let Te=Y[ge];if(Te&&!ue[Te]){let Le=E.getUniformLocation(this.program,Te);Le&&(ue[Te]=Le)}}this.fixedUniforms=p(t,ue),this.terrainUniforms=((ge,Te)=>({u_depth:new s.aH(ge,Te.u_depth),u_terrain:new s.aH(ge,Te.u_terrain),u_terrain_dim:new s.aI(ge,Te.u_terrain_dim),u_terrain_matrix:new s.aJ(ge,Te.u_terrain_matrix),u_terrain_unpack:new s.aK(ge,Te.u_terrain_unpack),u_terrain_exaggeration:new s.aI(ge,Te.u_terrain_exaggeration)}))(t,ue),this.binderUniforms=d?d.getUniforms(t,ue):[]}draw(t,l,d,p,m,S,E,M,R,D,F,j,W,Z,Y,te,re,ne){let H=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(d),t.setStencilMode(p),t.setColorMode(m),t.setCullFace(S),M){t.activeTexture.set(H.TEXTURE2),H.bindTexture(H.TEXTURE_2D,M.depthTexture),t.activeTexture.set(H.TEXTURE3),H.bindTexture(H.TEXTURE_2D,M.texture);for(let ue in this.terrainUniforms)this.terrainUniforms[ue].set(M[ue])}for(let ue in this.fixedUniforms)this.fixedUniforms[ue].set(E[ue]);Y&&Y.setUniforms(t,this.binderUniforms,W,{zoom:Z});let ce=0;switch(l){case H.LINES:ce=2;break;case H.TRIANGLES:ce=3;break;case H.LINE_STRIP:ce=1}for(let ue of j.get()){let ge=ue.vaos||(ue.vaos={});(ge[R]||(ge[R]=new Zc)).bind(t,this,D,Y?Y.getPaintVertexBuffers():[],F,ue.vertexOffset,te,re,ne),H.drawElements(l,ue.primitiveLength*ce,H.UNSIGNED_SHORT,ue.primitiveOffset*ce*2)}}}function Sl(g,t,l){let d=1/Dt(l,1,t.transform.tileZoom),p=Math.pow(2,l.tileID.overscaledZ),m=l.tileSize*Math.pow(2,t.transform.tileZoom)/p,S=m*(l.tileID.canonical.x+l.tileID.wrap*p),E=m*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[d,g.fromScale,g.toScale],u_fade:g.t,u_pixel_coord_upper:[S>>16,E>>16],u_pixel_coord_lower:[65535&S,65535&E]}}let Pa=(g,t,l,d)=>{let p=t.style.light,m=p.properties.get("position"),S=[m.x,m.y,m.z],E=function(){var R=new s.A(9);return s.A!=Float32Array&&(R[1]=0,R[2]=0,R[3]=0,R[5]=0,R[6]=0,R[7]=0),R[0]=1,R[4]=1,R[8]=1,R}();p.properties.get("anchor")==="viewport"&&function(R,D){var F=Math.sin(D),j=Math.cos(D);R[0]=j,R[1]=F,R[2]=0,R[3]=-F,R[4]=j,R[5]=0,R[6]=0,R[7]=0,R[8]=1}(E,-t.transform.angle),function(R,D,F){var j=D[0],W=D[1],Z=D[2];R[0]=j*F[0]+W*F[3]+Z*F[6],R[1]=j*F[1]+W*F[4]+Z*F[7],R[2]=j*F[2]+W*F[5]+Z*F[8]}(S,S,E);let M=p.properties.get("color");return{u_matrix:g,u_lightpos:S,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[M.r,M.g,M.b],u_vertical_gradient:+l,u_opacity:d}},Il=(g,t,l,d,p,m,S)=>s.e(Pa(g,t,l,d),Sl(m,t,S),{u_height_factor:-Math.pow(2,p.overscaledZ)/S.tileSize/8}),ko=g=>({u_matrix:g}),ed=(g,t,l,d)=>s.e(ko(g),Sl(l,t,d)),xf=(g,t)=>({u_matrix:g,u_world:t}),td=(g,t,l,d,p)=>s.e(ed(g,t,l,d),{u_world:p}),vf=(g,t,l,d)=>{let p=g.transform,m,S;if(d.paint.get("circle-pitch-alignment")==="map"){let E=Dt(l,1,p.zoom);m=!0,S=[E,E]}else m=!1,S=p.pixelsToGLUnits;return{u_camera_to_center_distance:p.cameraToCenterDistance,u_scale_with_map:+(d.paint.get("circle-pitch-scale")==="map"),u_matrix:g.translatePosMatrix(t.posMatrix,l,d.paint.get("circle-translate"),d.paint.get("circle-translate-anchor")),u_pitch_with_map:+m,u_device_pixel_ratio:g.pixelRatio,u_extrude_scale:S}},eo=(g,t,l)=>({u_matrix:g,u_inv_matrix:t,u_camera_to_center_distance:l.cameraToCenterDistance,u_viewport_size:[l.width,l.height]}),Aa=(g,t,l=1)=>({u_matrix:g,u_color:t,u_overlay:0,u_overlay_scale:l}),kr=g=>({u_matrix:g}),Lr=(g,t,l,d)=>({u_matrix:g,u_extrude_scale:Dt(t,1,l),u_intensity:d}),Cl=(g,t,l,d)=>{let p=s.H();s.aP(p,0,g.width,g.height,0,0,1);let m=g.context.gl;return{u_matrix:p,u_world:[m.drawingBufferWidth,m.drawingBufferHeight],u_image:l,u_color_ramp:d,u_opacity:t.paint.get("heatmap-opacity")}};function El(g,t){let l=Math.pow(2,t.canonical.z),d=t.canonical.y;return[new s.Z(0,d/l).toLngLat().lat,new s.Z(0,(d+1)/l).toLngLat().lat]}let Tl=(g,t,l,d)=>{let p=g.transform;return{u_matrix:nd(g,t,l,d),u_ratio:1/Dt(t,1,p.zoom),u_device_pixel_ratio:g.pixelRatio,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},id=(g,t,l,d,p)=>s.e(Tl(g,t,l,p),{u_image:0,u_image_height:d}),Lo=(g,t,l,d,p)=>{let m=g.transform,S=rd(t,m);return{u_matrix:nd(g,t,l,p),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Dt(t,1,m.zoom),u_device_pixel_ratio:g.pixelRatio,u_image:0,u_scale:[S,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},bf=(g,t,l,d,p,m)=>{let S=g.lineAtlas,E=rd(t,g.transform),M=l.layout.get("line-cap")==="round",R=S.getDash(d.from,M),D=S.getDash(d.to,M),F=R.width*p.fromScale,j=D.width*p.toScale;return s.e(Tl(g,t,l,m),{u_patternscale_a:[E/F,-R.height/2],u_patternscale_b:[E/j,-D.height/2],u_sdfgamma:S.width/(256*Math.min(F,j)*g.pixelRatio)/2,u_image:0,u_tex_y_a:R.y,u_tex_y_b:D.y,u_mix:p.t})};function rd(g,t){return 1/Dt(g,1,t.tileZoom)}function nd(g,t,l,d){return g.translatePosMatrix(d?d.posMatrix:t.tileID.posMatrix,t,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}let wf=(g,t,l,d,p)=>{return{u_matrix:g,u_tl_parent:t,u_scale_parent:l,u_buffer_scale:1,u_fade_t:d.mix,u_opacity:d.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:(S=p.paint.get("raster-saturation"),S>0?1-1/(1.001-S):-S),u_contrast_factor:(m=p.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:Sf(p.paint.get("raster-hue-rotate"))};var m,S};function Sf(g){g*=Math.PI/180;let t=Math.sin(g),l=Math.cos(g);return[(2*l+1)/3,(-Math.sqrt(3)*t-l+1)/3,(Math.sqrt(3)*t-l+1)/3]}let sd=(g,t,l,d,p,m,S,E,M,R,D,F,j,W)=>{let Z=S.transform;return{u_is_size_zoom_constant:+(g==="constant"||g==="source"),u_is_size_feature_constant:+(g==="constant"||g==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:Z.cameraToCenterDistance,u_pitch:Z.pitch/360*2*Math.PI,u_rotate_symbol:+l,u_aspect_ratio:Z.width/Z.height,u_fade_change:S.options.fadeDuration?S.symbolFadeChange:1,u_matrix:E,u_label_plane_matrix:M,u_coord_matrix:R,u_is_text:+F,u_pitch_with_map:+d,u_is_along_line:p,u_is_variable_anchor:m,u_texsize:j,u_texture:0,u_translation:D,u_pitched_scale:W}},Ra=(g,t,l,d,p,m,S,E,M,R,D,F,j,W,Z)=>{let Y=S.transform;return s.e(sd(g,t,l,d,p,m,S,E,M,R,D,F,j,Z),{u_gamma_scale:d?Math.cos(Y._pitch)*Y.cameraToCenterDistance:1,u_device_pixel_ratio:S.pixelRatio,u_is_halo:+W})},Kc=(g,t,l,d,p,m,S,E,M,R,D,F,j,W)=>s.e(Ra(g,t,l,d,p,m,S,E,M,R,D,!0,F,!0,W),{u_texsize_icon:j,u_texture_icon:1}),Ml=(g,t,l)=>({u_matrix:g,u_opacity:t,u_color:l}),Yc=(g,t,l,d,p,m)=>s.e(function(S,E,M,R){let D=M.imageManager.getPattern(S.from.toString()),F=M.imageManager.getPattern(S.to.toString()),{width:j,height:W}=M.imageManager.getPixelSize(),Z=Math.pow(2,R.tileID.overscaledZ),Y=R.tileSize*Math.pow(2,M.transform.tileZoom)/Z,te=Y*(R.tileID.canonical.x+R.tileID.wrap*Z),re=Y*R.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:D.tl,u_pattern_br_a:D.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[j,W],u_mix:E.t,u_pattern_size_a:D.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/Dt(R,1,M.transform.tileZoom),u_pixel_coord_upper:[te>>16,re>>16],u_pixel_coord_lower:[65535&te,65535&re]}}(d,m,l,p),{u_matrix:g,u_opacity:t}),Jc={fillExtrusion:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_lightpos:new s.aN(g,t.u_lightpos),u_lightintensity:new s.aI(g,t.u_lightintensity),u_lightcolor:new s.aN(g,t.u_lightcolor),u_vertical_gradient:new s.aI(g,t.u_vertical_gradient),u_opacity:new s.aI(g,t.u_opacity)}),fillExtrusionPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_lightpos:new s.aN(g,t.u_lightpos),u_lightintensity:new s.aI(g,t.u_lightintensity),u_lightcolor:new s.aN(g,t.u_lightcolor),u_vertical_gradient:new s.aI(g,t.u_vertical_gradient),u_height_factor:new s.aI(g,t.u_height_factor),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade),u_opacity:new s.aI(g,t.u_opacity)}),fill:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix)}),fillPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),fillOutline:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world)}),fillOutlinePattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),circle:(g,t)=>({u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_scale_with_map:new s.aH(g,t.u_scale_with_map),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_extrude_scale:new s.aO(g,t.u_extrude_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_matrix:new s.aJ(g,t.u_matrix)}),collisionBox:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_pixel_extrude_scale:new s.aO(g,t.u_pixel_extrude_scale)}),collisionCircle:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_inv_matrix:new s.aJ(g,t.u_inv_matrix),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_viewport_size:new s.aO(g,t.u_viewport_size)}),debug:(g,t)=>({u_color:new s.aL(g,t.u_color),u_matrix:new s.aJ(g,t.u_matrix),u_overlay:new s.aH(g,t.u_overlay),u_overlay_scale:new s.aI(g,t.u_overlay_scale)}),clippingMask:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix)}),heatmap:(g,t)=>({u_extrude_scale:new s.aI(g,t.u_extrude_scale),u_intensity:new s.aI(g,t.u_intensity),u_matrix:new s.aJ(g,t.u_matrix)}),heatmapTexture:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world),u_image:new s.aH(g,t.u_image),u_color_ramp:new s.aH(g,t.u_color_ramp),u_opacity:new s.aI(g,t.u_opacity)}),hillshade:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_latrange:new s.aO(g,t.u_latrange),u_light:new s.aO(g,t.u_light),u_shadow:new s.aL(g,t.u_shadow),u_highlight:new s.aL(g,t.u_highlight),u_accent:new s.aL(g,t.u_accent)}),hillshadePrepare:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_dimension:new s.aO(g,t.u_dimension),u_zoom:new s.aI(g,t.u_zoom),u_unpack:new s.aK(g,t.u_unpack)}),line:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels)}),lineGradient:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_image:new s.aH(g,t.u_image),u_image_height:new s.aI(g,t.u_image_height)}),linePattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texsize:new s.aO(g,t.u_texsize),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_image:new s.aH(g,t.u_image),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),lineSDF:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_patternscale_a:new s.aO(g,t.u_patternscale_a),u_patternscale_b:new s.aO(g,t.u_patternscale_b),u_sdfgamma:new s.aI(g,t.u_sdfgamma),u_image:new s.aH(g,t.u_image),u_tex_y_a:new s.aI(g,t.u_tex_y_a),u_tex_y_b:new s.aI(g,t.u_tex_y_b),u_mix:new s.aI(g,t.u_mix)}),raster:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_tl_parent:new s.aO(g,t.u_tl_parent),u_scale_parent:new s.aI(g,t.u_scale_parent),u_buffer_scale:new s.aI(g,t.u_buffer_scale),u_fade_t:new s.aI(g,t.u_fade_t),u_opacity:new s.aI(g,t.u_opacity),u_image0:new s.aH(g,t.u_image0),u_image1:new s.aH(g,t.u_image1),u_brightness_low:new s.aI(g,t.u_brightness_low),u_brightness_high:new s.aI(g,t.u_brightness_high),u_saturation_factor:new s.aI(g,t.u_saturation_factor),u_contrast_factor:new s.aI(g,t.u_contrast_factor),u_spin_weights:new s.aN(g,t.u_spin_weights)}),symbolIcon:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texture:new s.aH(g,t.u_texture),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),symbolSDF:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texture:new s.aH(g,t.u_texture),u_gamma_scale:new s.aI(g,t.u_gamma_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_is_halo:new s.aH(g,t.u_is_halo),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),symbolTextAndIcon:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texsize_icon:new s.aO(g,t.u_texsize_icon),u_texture:new s.aH(g,t.u_texture),u_texture_icon:new s.aH(g,t.u_texture_icon),u_gamma_scale:new s.aI(g,t.u_gamma_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_is_halo:new s.aH(g,t.u_is_halo),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),background:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_opacity:new s.aI(g,t.u_opacity),u_color:new s.aL(g,t.u_color)}),backgroundPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_opacity:new s.aI(g,t.u_opacity),u_image:new s.aH(g,t.u_image),u_pattern_tl_a:new s.aO(g,t.u_pattern_tl_a),u_pattern_br_a:new s.aO(g,t.u_pattern_br_a),u_pattern_tl_b:new s.aO(g,t.u_pattern_tl_b),u_pattern_br_b:new s.aO(g,t.u_pattern_br_b),u_texsize:new s.aO(g,t.u_texsize),u_mix:new s.aI(g,t.u_mix),u_pattern_size_a:new s.aO(g,t.u_pattern_size_a),u_pattern_size_b:new s.aO(g,t.u_pattern_size_b),u_scale_a:new s.aI(g,t.u_scale_a),u_scale_b:new s.aI(g,t.u_scale_b),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_tile_units_to_pixels:new s.aI(g,t.u_tile_units_to_pixels)}),terrain:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texture:new s.aH(g,t.u_texture),u_ele_delta:new s.aI(g,t.u_ele_delta),u_fog_matrix:new s.aJ(g,t.u_fog_matrix),u_fog_color:new s.aL(g,t.u_fog_color),u_fog_ground_blend:new s.aI(g,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new s.aI(g,t.u_fog_ground_blend_opacity),u_horizon_color:new s.aL(g,t.u_horizon_color),u_horizon_fog_blend:new s.aI(g,t.u_horizon_fog_blend)}),terrainDepth:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ele_delta:new s.aI(g,t.u_ele_delta)}),terrainCoords:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texture:new s.aH(g,t.u_texture),u_terrain_coords_id:new s.aI(g,t.u_terrain_coords_id),u_ele_delta:new s.aI(g,t.u_ele_delta)}),sky:(g,t)=>({u_sky_color:new s.aL(g,t.u_sky_color),u_horizon_color:new s.aL(g,t.u_horizon_color),u_horizon:new s.aI(g,t.u_horizon),u_sky_horizon_blend:new s.aI(g,t.u_sky_horizon_blend)})};class Qn{constructor(t,l,d){this.context=t;let p=t.gl;this.buffer=p.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete l.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let l=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),l.bufferSubData(l.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let If={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qc{constructor(t,l,d,p){this.length=l.length,this.attributes=d,this.itemSize=l.bytesPerElement,this.dynamicDraw=p,this.context=t;let m=t.gl;this.buffer=m.createBuffer(),t.bindVertexBuffer.set(this.buffer),m.bufferData(m.ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||delete l.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}`);let l=this.context.gl;this.bind(),l.bufferSubData(l.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,l){for(let d=0;d<this.attributes.length;d++){let p=l.attributes[this.attributes[d].name];p!==void 0&&t.enableVertexAttribArray(p)}}setVertexAttribPointers(t,l,d){for(let p=0;p<this.attributes.length;p++){let m=this.attributes[p],S=l.attributes[m.name];S!==void 0&&t.vertexAttribPointer(S,m.components,t[If[m.type]],!1,this.itemSize,m.offset+this.itemSize*(d||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let to=new WeakMap;function Ls(g){var t;if(to.has(g))return to.get(g);{let l=(t=g.getParameter(g.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return to.set(g,l),l}}class Wt{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Pl extends Wt{getDefault(){return s.aM.transparent}set(t){let l=this.current;(t.r!==l.r||t.g!==l.g||t.b!==l.b||t.a!==l.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Cf extends Wt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Do extends Wt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Ef extends Wt{getDefault(){return[!0,!0,!0,!0]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||t[3]!==l[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class od extends Wt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Tf extends Wt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class ad extends Wt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let l=this.current;(t.func!==l.func||t.ref!==l.ref||t.mask!==l.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class eh extends Wt{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class ld extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.STENCIL_TEST):l.disable(l.STENCIL_TEST),this.current=t,this.dirty=!1}}class cd extends Wt{getDefault(){return[0,1]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class hd extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),this.current=t,this.dirty=!1}}class ud extends Wt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class io extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.BLEND):l.disable(l.BLEND),this.current=t,this.dirty=!1}}class dd extends Wt{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Mf extends Wt{getDefault(){return s.aM.transparent}set(t){let l=this.current;(t.r!==l.r||t.g!==l.g||t.b!==l.b||t.a!==l.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class pd extends Wt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ka extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.CULL_FACE):l.disable(l.CULL_FACE),this.current=t,this.dirty=!1}}class Pf extends Wt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Al extends Wt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Af extends Wt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Rf extends Wt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class fd extends Wt{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||t[3]!==l[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class md extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindFramebuffer(l.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class gd extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindRenderbuffer(l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class th extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindTexture(l.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class yd extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindBuffer(l.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Rl extends Wt{getDefault(){return null}set(t){let l=this.gl;l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ds extends Wt{getDefault(){return null}set(t){var l;if(t===this.current&&!this.dirty)return;let d=this.gl;Ls(d)?d.bindVertexArray(t):(l=d.getExtension("OES_vertex_array_object"))===null||l===void 0||l.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class ih extends Wt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class rh extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class nh extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class kl extends Wt{constructor(t,l){super(t),this.context=t,this.parent=l}getDefault(){return null}}class sh extends kl{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class ro extends kl{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class oh extends kl{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class kf{constructor(t,l,d,p,m){this.context=t,this.width=l,this.height=d;let S=t.gl,E=this.framebuffer=S.createFramebuffer();if(this.colorAttachment=new sh(t,E),p)this.depthAttachment=m?new oh(t,E):new ro(t,E);else if(m)throw new Error("Stencil cannot be set without depth");if(S.checkFramebufferStatus(S.FRAMEBUFFER)!==S.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){let t=this.context.gl,l=this.colorAttachment.get();if(l&&t.deleteTexture(l),this.depthAttachment){let d=this.depthAttachment.get();d&&t.deleteRenderbuffer(d)}t.deleteFramebuffer(this.framebuffer)}}class yi{constructor(t,l,d){this.blendFunction=t,this.blendColor=l,this.mask=d}}yi.Replace=[1,0],yi.disabled=new yi(yi.Replace,s.aM.transparent,[!1,!1,!1,!1]),yi.unblended=new yi(yi.Replace,s.aM.transparent,[!0,!0,!0,!0]),yi.alphaBlended=new yi([1,771],s.aM.transparent,[!0,!0,!0,!0]);class Lf{constructor(t){var l,d;if(this.gl=t,this.clearColor=new Pl(this),this.clearDepth=new Cf(this),this.clearStencil=new Do(this),this.colorMask=new Ef(this),this.depthMask=new od(this),this.stencilMask=new Tf(this),this.stencilFunc=new ad(this),this.stencilOp=new eh(this),this.stencilTest=new ld(this),this.depthRange=new cd(this),this.depthTest=new hd(this),this.depthFunc=new ud(this),this.blend=new io(this),this.blendFunc=new dd(this),this.blendColor=new Mf(this),this.blendEquation=new pd(this),this.cullFace=new ka(this),this.cullFaceSide=new Pf(this),this.frontFace=new Al(this),this.program=new Af(this),this.activeTexture=new Rf(this),this.viewport=new fd(this),this.bindFramebuffer=new md(this),this.bindRenderbuffer=new gd(this),this.bindTexture=new th(this),this.bindVertexBuffer=new yd(this),this.bindElementBuffer=new Rl(this),this.bindVertexArray=new ds(this),this.pixelStoreUnpack=new ih(this),this.pixelStoreUnpackPremultiplyAlpha=new rh(this),this.pixelStoreUnpackFlipY=new nh(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),Ls(t)){this.HALF_FLOAT=t.HALF_FLOAT;let p=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(l=t.RGBA16F)!==null&&l!==void 0?l:p?.RGBA16F_EXT,this.RGB16F=(d=t.RGB16F)!==null&&d!==void 0?d:p?.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");let p=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=p?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,l){return new Qn(this,t,l)}createVertexBuffer(t,l,d){return new Qc(this,t,l,d)}createRenderbuffer(t,l,d){let p=this.gl,m=p.createRenderbuffer();return this.bindRenderbuffer.set(m),p.renderbufferStorage(p.RENDERBUFFER,t,l,d),this.bindRenderbuffer.set(null),m}createFramebuffer(t,l,d,p){return new kf(this,t,l,d,p)}clear({color:t,depth:l,stencil:d}){let p=this.gl,m=0;t&&(m|=p.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),l!==void 0&&(m|=p.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(l),this.depthMask.set(!0)),d!==void 0&&(m|=p.STENCIL_BUFFER_BIT,this.clearStencil.set(d),this.stencilMask.set(255)),p.clear(m)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){s.aE(t.blendFunction,yi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Ls(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var l;return Ls(this.gl)?this.gl.deleteVertexArray(t):(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class At{constructor(t,l,d){this.func=t,this.mask=l,this.range=d}}At.ReadOnly=!1,At.ReadWrite=!0,At.disabled=new At(519,At.ReadOnly,[0,1]);let Ll=7680;class ii{constructor(t,l,d,p,m,S){this.test=t,this.ref=l,this.mask=d,this.fail=p,this.depthFail=m,this.pass=S}}ii.disabled=new ii({func:519,mask:0},0,0,Ll,Ll,Ll);class Kt{constructor(t,l,d){this.enable=t,this.mode=l,this.frontFace=d}}let no;function La(g,t,l,d,p){let m=g.context,S=m.gl,E=g.useProgram("collisionBox"),M=[],R=0,D=0;for(let re=0;re<d.length;re++){let ne=d[re],H=t.getTile(ne).getBucket(l);if(!H)continue;let ce=p?H.textCollisionBox:H.iconCollisionBox,ue=H.collisionCircleArray;if(ue.length>0){let ge=s.H();s.aQ(ge,H.placementInvProjMatrix,g.transform.glCoordMatrix),s.aQ(ge,ge,H.placementViewportMatrix),M.push({circleArray:ue,circleOffset:D,transform:ne.posMatrix,invTransform:ge,coord:ne}),R+=ue.length/4,D=R}ce&&E.draw(m,S.LINES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,{u_matrix:ne.posMatrix,u_pixel_extrude_scale:[1/(F=g.transform).width,1/F.height]},g.style.map.terrain&&g.style.map.terrain.getTerrainData(ne),l.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,null,g.transform.zoom,null,null,ce.collisionVertexBuffer)}var F;if(!p||!M.length)return;let j=g.useProgram("collisionCircle"),W=new s.aR;W.resize(4*R),W._trim();let Z=0;for(let re of M)for(let ne=0;ne<re.circleArray.length/4;ne++){let H=4*ne,ce=re.circleArray[H+0],ue=re.circleArray[H+1],ge=re.circleArray[H+2],Te=re.circleArray[H+3];W.emplace(Z++,ce,ue,ge,Te,0),W.emplace(Z++,ce,ue,ge,Te,1),W.emplace(Z++,ce,ue,ge,Te,2),W.emplace(Z++,ce,ue,ge,Te,3)}(!no||no.length<2*R)&&(no=function(re){let ne=2*re,H=new s.aT;H.resize(ne),H._trim();for(let ce=0;ce<ne;ce++){let ue=6*ce;H.uint16[ue+0]=4*ce+0,H.uint16[ue+1]=4*ce+1,H.uint16[ue+2]=4*ce+2,H.uint16[ue+3]=4*ce+2,H.uint16[ue+4]=4*ce+3,H.uint16[ue+5]=4*ce+0}return H}(R));let Y=m.createIndexBuffer(no,!0),te=m.createVertexBuffer(W,s.aS.members,!0);for(let re of M){let ne=eo(re.transform,re.invTransform,g.transform);j.draw(m,S.TRIANGLES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,ne,g.style.map.terrain&&g.style.map.terrain.getTerrainData(re.coord),l.id,te,Y,s.a0.simpleSegment(0,2*re.circleOffset,re.circleArray.length,re.circleArray.length/2),null,g.transform.zoom,null,null,null)}te.destroy(),Y.destroy()}Kt.disabled=new Kt(!1,1029,2305),Kt.backCCW=new Kt(!0,1029,2305);let Da=s.an(new Float32Array(16));function ah(g,t,l,d,p,m){let{horizontalAlign:S,verticalAlign:E}=s.au(g);return new s.P((-(S-.5)*t/p+d[0])*m,(-(E-.5)*l/p+d[1])*m)}function so(g,t,l,d,p,m){let S=t.tileAnchorPoint.add(new s.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let E=d.mult(m);l||(E=E.rotate(-p));let M=S.add(E);return Q(M.x,M.y,t.labelPlaneMatrix,t.getElevation).point}if(l){let E=xe(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(g),M=Math.atan(E.y/E.x)+(E.x<0?Math.PI:0);return g.add(d.rotate(M))}return g.add(d)}function Fo(g,t,l,d,p,m,S,E,M,R,D,F,j,W){let Z=g.text.placedSymbolArray,Y=g.text.dynamicLayoutVertexArray,te=g.icon.dynamicLayoutVertexArray,re={};Y.clear();for(let ne=0;ne<Z.length;ne++){let H=Z.get(ne),ce=H.hidden||!H.crossTileID||g.allowVerticalPlacement&&!H.placedOrientation?null:d[H.crossTileID];if(ce){let ue=new s.P(H.anchorX,H.anchorY),ge={getElevation:W,width:p.width,height:p.height,labelPlaneMatrix:m,lineVertexArray:null,pitchWithMap:l,projection:D,projectionCache:null,tileAnchorPoint:ue,translation:F,unwrappedTileID:j},Te=l?Q(ue.x,ue.y,S,W):xe(ue.x,ue.y,ge),Le=N(p.cameraToCenterDistance,Te.signedDistanceFromCamera),Ue=s.ai(g.textSizeData,M,H)*Le/s.ap;l&&(Ue*=g.tilePixelRatio/E);let{width:Xe,height:Oe,anchor:ze,textOffset:et,textBoxScale:_t}=ce,Ve=ah(ze,Xe,Oe,et,_t,Ue),We=D.getPitchedTextCorrection(p,ue.add(new s.P(F[0],F[1])),j),ft=so(Te.point,ge,t,Ve,p.angle,We),si=g.allowVerticalPlacement&&H.placedOrientation===s.ah.vertical?Math.PI/2:0;for(let Tt=0;Tt<H.numGlyphs;Tt++)s.aj(Y,ft,si);R&&H.associatedIconIndex>=0&&(re[H.associatedIconIndex]={shiftedAnchor:ft,angle:si})}else Ke(H.numGlyphs,Y)}if(R){te.clear();let ne=g.icon.placedSymbolArray;for(let H=0;H<ne.length;H++){let ce=ne.get(H);if(ce.hidden)Ke(ce.numGlyphs,te);else{let ue=re[H];if(ue)for(let ge=0;ge<ce.numGlyphs;ge++)s.aj(te,ue.shiftedAnchor,ue.angle);else Ke(ce.numGlyphs,te)}}g.icon.dynamicLayoutVertexBuffer.updateData(te)}g.text.dynamicLayoutVertexBuffer.updateData(Y)}function hn(g,t,l){return l.iconsInText&&t?"symbolTextAndIcon":g?"symbolSDF":"symbolIcon"}function lh(g,t,l,d,p,m,S,E,M,R,D,F){let j=g.context,W=j.gl,Z=g.transform,Y=Js(),te=E==="map",re=M==="map",ne=E!=="viewport"&&l.layout.get("symbol-placement")!=="point",H=te&&!re&&!ne,ce=!re&&ne,ue=!l.layout.get("symbol-sort-key").isConstant(),ge=!1,Te=g.depthModeForSublayer(0,At.ReadOnly),Le=l._unevaluatedLayout.hasValue("text-variable-anchor")||l._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ue=[],Xe=Y.getCircleRadiusCorrection(Z);for(let Oe of d){let ze=t.getTile(Oe),et=ze.getBucket(l);if(!et)continue;let _t=p?et.text:et.icon;if(!_t||!_t.segments.get().length||!_t.hasVisibleVertices)continue;let Ve=_t.programConfigurations.get(l.id),We=p||et.sdfIcons,ft=p?et.textSizeData:et.iconSizeData,si=re||Z.pitch!==0,Tt=g.useProgram(hn(We,p,et),Ve),Ft=s.ag(ft,Z.zoom),oi=g.style.map.terrain&&g.style.map.terrain.getTerrainData(Oe),Ji,Nn,ai,Dr,yr=[0,0],Qi=null;if(p)Nn=ze.glyphAtlasTexture,ai=W.LINEAR,Ji=ze.glyphAtlasTexture.size,et.iconsInText&&(yr=ze.imageAtlasTexture.size,Qi=ze.imageAtlasTexture,Dr=si||g.options.rotating||g.options.zooming||ft.kind==="composite"||ft.kind==="camera"?W.LINEAR:W.NEAREST);else{let Bt=l.layout.get("icon-size").constantOr(0)!==1||et.iconsNeedLinear;Nn=ze.imageAtlasTexture,ai=We||g.options.rotating||g.options.zooming||Bt||si?W.LINEAR:W.NEAREST,Ji=ze.imageAtlasTexture.size}let _r=Dt(ze,1,g.transform.zoom),is=ce?Oe.posMatrix:Da,Yo=Ln(is,re,te,g.transform,_r),Jl=ln(is,re,te,g.transform,_r),Jo=ln(Oe.posMatrix,re,te,g.transform,_r),pn=Y.translatePosition(g.transform,ze,m,S),Ql=Le&&et.hasTextData(),Lh=l.layout.get("icon-text-fit")!=="none"&&Ql&&et.hasIconData();if(ne){let Bt=g.style.map.terrain?(Qo,ea)=>g.style.map.terrain.getElevation(Oe,Qo,ea):null,ho=l.layout.get("text-rotation-alignment")==="map";q(et,Oe.posMatrix,g,p,Yo,Jo,re,R,ho,Y,Oe.toUnwrapped(),Z.width,Z.height,pn,Bt)}let fn=Oe.posMatrix,mn=p&&Le||Lh,Ds=ne||mn?Da:Yo,Vn=Jl,Ui=We&&l.paint.get(p?"text-halo-width":"icon-halo-width").constantOr(1)!==0,er;er=We?et.iconsInText?Kc(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,Ji,yr,Xe):Ra(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,p,Ji,!0,Xe):sd(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,p,Ji,Xe);let Jr={program:Tt,buffers:_t,uniformValues:er,atlasTexture:Nn,atlasTextureIcon:Qi,atlasInterpolation:ai,atlasInterpolationIcon:Dr,isSDF:We,hasHalo:Ui};if(ue&&et.canOverlap){ge=!0;let Bt=_t.segments.get();for(let ho of Bt)Ue.push({segments:new s.a0([ho]),sortKey:ho.sortKey,state:Jr,terrainData:oi})}else Ue.push({segments:_t.segments,sortKey:0,state:Jr,terrainData:oi})}ge&&Ue.sort((Oe,ze)=>Oe.sortKey-ze.sortKey);for(let Oe of Ue){let ze=Oe.state;if(j.activeTexture.set(W.TEXTURE0),ze.atlasTexture.bind(ze.atlasInterpolation,W.CLAMP_TO_EDGE),ze.atlasTextureIcon&&(j.activeTexture.set(W.TEXTURE1),ze.atlasTextureIcon&&ze.atlasTextureIcon.bind(ze.atlasInterpolationIcon,W.CLAMP_TO_EDGE)),ze.isSDF){let et=ze.uniformValues;ze.hasHalo&&(et.u_is_halo=1,ch(ze.buffers,Oe.segments,l,g,ze.program,Te,D,F,et,Oe.terrainData)),et.u_is_halo=0}ch(ze.buffers,Oe.segments,l,g,ze.program,Te,D,F,ze.uniformValues,Oe.terrainData)}}function ch(g,t,l,d,p,m,S,E,M,R){let D=d.context;p.draw(D,D.gl.TRIANGLES,m,S,E,Kt.disabled,M,R,l.id,g.layoutVertexBuffer,g.indexBuffer,t,l.paint,d.transform.zoom,g.programConfigurations.get(l.id),g.dynamicLayoutVertexBuffer,g.opacityVertexBuffer)}function hh(g,t,l,d){let p=g.context,m=p.gl,S=ii.disabled,E=new yi([m.ONE,m.ONE],s.aM.transparent,[!0,!0,!0,!0]),M=t.getBucket(l);if(!M)return;let R=d.key,D=l.heatmapFbos.get(R);D||(D=Fa(p,t.tileSize,t.tileSize),l.heatmapFbos.set(R,D)),p.bindFramebuffer.set(D.framebuffer),p.viewport.set([0,0,t.tileSize,t.tileSize]),p.clear({color:s.aM.transparent});let F=M.programConfigurations.get(l.id),j=g.useProgram("heatmap",F),W=g.style.map.terrain.getTerrainData(d);j.draw(p,m.TRIANGLES,At.disabled,S,E,Kt.disabled,Lr(d.posMatrix,t,g.transform.zoom,l.paint.get("heatmap-intensity")),W,l.id,M.layoutVertexBuffer,M.indexBuffer,M.segments,l.paint,g.transform.zoom,F)}function oo(g,t,l){let d=g.context,p=d.gl;d.setColorMode(g.colorModeForRenderPass());let m=za(d,t),S=l.key,E=t.heatmapFbos.get(S);E&&(d.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,E.colorAttachment.get()),d.activeTexture.set(p.TEXTURE1),m.bind(p.LINEAR,p.CLAMP_TO_EDGE),g.useProgram("heatmapTexture").draw(d,p.TRIANGLES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,Cl(g,t,0,1),null,t.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments,t.paint,g.transform.zoom),E.destroy(),t.heatmapFbos.delete(S))}function Fa(g,t,l){var d,p;let m=g.gl,S=m.createTexture();m.bindTexture(m.TEXTURE_2D,S),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR);let E=(d=g.HALF_FLOAT)!==null&&d!==void 0?d:m.UNSIGNED_BYTE,M=(p=g.RGBA16F)!==null&&p!==void 0?p:m.RGBA;m.texImage2D(m.TEXTURE_2D,0,M,t,l,0,m.RGBA,E,null);let R=g.createFramebuffer(t,l,!1,!1);return R.colorAttachment.set(S),R}function za(g,t){return t.colorRampTexture||(t.colorRampTexture=new Ae(g,t.colorRamp,g.gl.RGBA)),t.colorRampTexture}function zo(g,t,l,d,p){if(!l||!d||!d.imageAtlas)return;let m=d.imageAtlas.patternPositions,S=m[l.to.toString()],E=m[l.from.toString()];if(!S&&E&&(S=E),!E&&S&&(E=S),!S||!E){let M=p.getPaintProperty(t);S=m[M],E=m[M]}S&&E&&g.setConstantPatternPositions(S,E)}function Oa(g,t,l,d,p,m,S){let E=g.context.gl,M="fill-pattern",R=l.paint.get(M),D=R&&R.constantOr(1),F=l.getCrossfadeParameters(),j,W,Z,Y,te;S?(W=D&&!l.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",j=E.LINES):(W=D?"fillPattern":"fill",j=E.TRIANGLES);let re=R.constantOr(null);for(let ne of d){let H=t.getTile(ne);if(D&&!H.patternsLoaded())continue;let ce=H.getBucket(l);if(!ce)continue;let ue=ce.programConfigurations.get(l.id),ge=g.useProgram(W,ue),Te=g.style.map.terrain&&g.style.map.terrain.getTerrainData(ne);D&&(g.context.activeTexture.set(E.TEXTURE0),H.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),ue.updatePaintBuffers(F)),zo(ue,M,re,H,l);let Le=Te?ne:null,Ue=g.translatePosMatrix(Le?Le.posMatrix:ne.posMatrix,H,l.paint.get("fill-translate"),l.paint.get("fill-translate-anchor"));if(S){Y=ce.indexBuffer2,te=ce.segments2;let Xe=[E.drawingBufferWidth,E.drawingBufferHeight];Z=W==="fillOutlinePattern"&&D?td(Ue,g,F,H,Xe):xf(Ue,Xe)}else Y=ce.indexBuffer,te=ce.segments,Z=D?ed(Ue,g,F,H):ko(Ue);ge.draw(g.context,j,p,g.stencilModeForClipping(ne),m,Kt.disabled,Z,Te,l.id,ce.layoutVertexBuffer,Y,te,l.paint,g.transform.zoom,ue)}}function Dl(g,t,l,d,p,m,S){let E=g.context,M=E.gl,R="fill-extrusion-pattern",D=l.paint.get(R),F=D.constantOr(1),j=l.getCrossfadeParameters(),W=l.paint.get("fill-extrusion-opacity"),Z=D.constantOr(null);for(let Y of d){let te=t.getTile(Y),re=te.getBucket(l);if(!re)continue;let ne=g.style.map.terrain&&g.style.map.terrain.getTerrainData(Y),H=re.programConfigurations.get(l.id),ce=g.useProgram(F?"fillExtrusionPattern":"fillExtrusion",H);F&&(g.context.activeTexture.set(M.TEXTURE0),te.imageAtlasTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),H.updatePaintBuffers(j)),zo(H,R,Z,te,l);let ue=g.translatePosMatrix(Y.posMatrix,te,l.paint.get("fill-extrusion-translate"),l.paint.get("fill-extrusion-translate-anchor")),ge=l.paint.get("fill-extrusion-vertical-gradient"),Te=F?Il(ue,g,ge,W,Y,j,te):Pa(ue,g,ge,W);ce.draw(E,E.gl.TRIANGLES,p,m,S,Kt.backCCW,Te,ne,l.id,re.layoutVertexBuffer,re.indexBuffer,re.segments,l.paint,g.transform.zoom,H,g.style.map.terrain&&re.centroidVertexBuffer)}}function Oo(g,t,l,d,p,m,S){let E=g.context,M=E.gl,R=l.fbo;if(!R)return;let D=g.useProgram("hillshade"),F=g.style.map.terrain&&g.style.map.terrain.getTerrainData(t);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,R.colorAttachment.get()),D.draw(E,M.TRIANGLES,p,m,S,Kt.disabled,((j,W,Z,Y)=>{let te=Z.paint.get("hillshade-shadow-color"),re=Z.paint.get("hillshade-highlight-color"),ne=Z.paint.get("hillshade-accent-color"),H=Z.paint.get("hillshade-illumination-direction")*(Math.PI/180);Z.paint.get("hillshade-illumination-anchor")==="viewport"&&(H-=j.transform.angle);let ce=!j.options.moving;return{u_matrix:Y?Y.posMatrix:j.transform.calculatePosMatrix(W.tileID.toUnwrapped(),ce),u_image:0,u_latrange:El(0,W.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),H],u_shadow:te,u_highlight:re,u_accent:ne}})(g,l,d,F?t:null),F,d.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments)}function Bo(g,t,l,d,p,m){let S=g.context,E=S.gl,M=t.dem;if(M&&M.data){let R=M.dim,D=M.stride,F=M.getPixels();if(S.activeTexture.set(E.TEXTURE1),S.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||g.getTileTexture(D),t.demTexture){let W=t.demTexture;W.update(F,{premultiply:!1}),W.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else t.demTexture=new Ae(S,F,E.RGBA,{premultiply:!1}),t.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);S.activeTexture.set(E.TEXTURE0);let j=t.fbo;if(!j){let W=new Ae(S,{width:R,height:R,data:null},E.RGBA);W.bind(E.LINEAR,E.CLAMP_TO_EDGE),j=t.fbo=S.createFramebuffer(R,R,!0,!1),j.colorAttachment.set(W.texture)}S.bindFramebuffer.set(j.framebuffer),S.viewport.set([0,0,R,R]),g.useProgram("hillshadePrepare").draw(S,E.TRIANGLES,d,p,m,Kt.disabled,((W,Z)=>{let Y=Z.stride,te=s.H();return s.aP(te,0,s.X,-s.X,0,0,1),s.J(te,te,[0,-s.X,0]),{u_matrix:te,u_image:1,u_dimension:[Y,Y],u_zoom:W.overscaledZ,u_unpack:Z.getUnpackVector()}})(t.tileID,M),null,l.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function _d(g,t,l,d,p,m){let S=d.paint.get("raster-fade-duration");if(!m&&S>0){let E=T.now(),M=(E-g.timeAdded)/S,R=t?(E-t.timeAdded)/S:-1,D=l.getSource(),F=p.coveringZoomLevel({tileSize:D.tileSize,roundZoom:D.roundZoom}),j=!t||Math.abs(t.tileID.overscaledZ-F)>Math.abs(g.tileID.overscaledZ-F),W=j&&g.refreshedUponExpiration?1:s.ac(j?M:1-R,0,1);return g.refreshedUponExpiration&&M>=1&&(g.refreshedUponExpiration=!1),t?{opacity:1,mix:1-W}:{opacity:W,mix:0}}return{opacity:1,mix:0}}let uh=new s.aM(1,0,0,1),jt=new s.aM(0,1,0,1),Fl=new s.aM(0,0,1,1),Df=new s.aM(1,0,1,1),xd=new s.aM(0,1,1,1);function No(g,t,l,d){zl(g,0,t+l/2,g.transform.width,l,d)}function vd(g,t,l,d){zl(g,t-l/2,0,l,g.transform.height,d)}function zl(g,t,l,d,p,m){let S=g.context,E=S.gl;E.enable(E.SCISSOR_TEST),E.scissor(t*g.pixelRatio,l*g.pixelRatio,d*g.pixelRatio,p*g.pixelRatio),S.clear({color:m}),E.disable(E.SCISSOR_TEST)}function bd(g,t,l){let d=g.context,p=d.gl,m=l.posMatrix,S=g.useProgram("debug"),E=At.disabled,M=ii.disabled,R=g.colorModeForRenderPass(),D="$debug",F=g.style.map.terrain&&g.style.map.terrain.getTerrainData(l);d.activeTexture.set(p.TEXTURE0);let j=t.getTileByID(l.key).latestRawTileData,W=Math.floor((j&&j.byteLength||0)/1024),Z=t.getTile(l).tileSize,Y=512/Math.min(Z,512)*(l.overscaledZ/g.transform.zoom)*.5,te=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(te+=` => ${l.overscaledZ}`),function(re,ne){re.initDebugOverlayCanvas();let H=re.debugOverlayCanvas,ce=re.context.gl,ue=re.debugOverlayCanvas.getContext("2d");ue.clearRect(0,0,H.width,H.height),ue.shadowColor="white",ue.shadowBlur=2,ue.lineWidth=1.5,ue.strokeStyle="white",ue.textBaseline="top",ue.font="bold 36px Open Sans, sans-serif",ue.fillText(ne,5,5),ue.strokeText(ne,5,5),re.debugOverlayTexture.update(H),re.debugOverlayTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE)}(g,`${te} ${W}kB`),S.draw(d,p.TRIANGLES,E,M,yi.alphaBlended,Kt.disabled,Aa(m,s.aM.transparent,Y),null,D,g.debugBuffer,g.quadTriangleIndexBuffer,g.debugSegments),S.draw(d,p.LINE_STRIP,E,M,R,Kt.disabled,Aa(m,s.aM.red),F,D,g.debugBuffer,g.tileBorderIndexBuffer,g.debugSegments)}function wd(g,t,l){let d=g.context,p=d.gl,m=g.colorModeForRenderPass(),S=new At(p.LEQUAL,At.ReadWrite,g.depthRangeFor3D),E=g.useProgram("terrain"),M=t.getTerrainMesh();d.bindFramebuffer.set(null),d.viewport.set([0,0,g.width,g.height]);for(let R of l){let D=g.renderToTexture.getTexture(R),F=t.getTerrainData(R.tileID);d.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,D.texture);let j=g.transform.calculatePosMatrix(R.tileID.toUnwrapped()),W=t.getMeshFrameDelta(g.transform.zoom),Z=g.transform.calculateFogMatrix(R.tileID.toUnwrapped()),Y=Xc(j,W,Z,g.style.sky,g.transform.pitch);E.draw(d,p.TRIANGLES,S,ii.disabled,m,Kt.backCCW,Y,F,"terrain",M.vertexBuffer,M.indexBuffer,M.segments)}}class Ol{constructor(t,l,d){this.vertexBuffer=t,this.indexBuffer=l,this.segments=d}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Bl{constructor(t,l){this.context=new Lf(t),this.transform=l,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:s.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ht.maxUnderzooming+ht.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Wc}resize(t,l,d){if(this.width=Math.floor(t*d),this.height=Math.floor(l*d),this.pixelRatio=d,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let p of this.style._order)this.style._layers[p].resize()}setup(){let t=this.context,l=new s.aX;l.emplaceBack(0,0),l.emplaceBack(s.X,0),l.emplaceBack(0,s.X),l.emplaceBack(s.X,s.X),this.tileExtentBuffer=t.createVertexBuffer(l,Qs.members),this.tileExtentSegments=s.a0.simpleSegment(0,0,4,2);let d=new s.aX;d.emplaceBack(0,0),d.emplaceBack(s.X,0),d.emplaceBack(0,s.X),d.emplaceBack(s.X,s.X),this.debugBuffer=t.createVertexBuffer(d,Qs.members),this.debugSegments=s.a0.simpleSegment(0,0,4,5);let p=new s.$;p.emplaceBack(0,0,0,0),p.emplaceBack(s.X,0,s.X,0),p.emplaceBack(0,s.X,0,s.X),p.emplaceBack(s.X,s.X,s.X,s.X),this.rasterBoundsBuffer=t.createVertexBuffer(p,on.members),this.rasterBoundsSegments=s.a0.simpleSegment(0,0,4,2);let m=new s.aX;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(m,Qs.members),this.viewportSegments=s.a0.simpleSegment(0,0,4,2);let S=new s.aZ;S.emplaceBack(0),S.emplaceBack(1),S.emplaceBack(3),S.emplaceBack(2),S.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(S);let E=new s.aY;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(E);let M=this.context.gl;this.stencilClearMode=new ii({func:M.ALWAYS,mask:0},0,255,M.ZERO,M.ZERO,M.ZERO)}clearStencil(){let t=this.context,l=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let d=s.H();s.aP(d,0,this.width,this.height,0,0,1),s.K(d,d,[l.drawingBufferWidth,l.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,l.TRIANGLES,At.disabled,this.stencilClearMode,yi.disabled,Kt.disabled,kr(d),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,l){if(this.currentStencilSource===t.source||!t.isTileClipped()||!l||!l.length)return;this.currentStencilSource=t.source;let d=this.context,p=d.gl;this.nextStencilID+l.length>256&&this.clearStencil(),d.setColorMode(yi.disabled),d.setDepthMode(At.disabled);let m=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let S of l){let E=this._tileClippingMaskIDs[S.key]=this.nextStencilID++,M=this.style.map.terrain&&this.style.map.terrain.getTerrainData(S);m.draw(d,p.TRIANGLES,At.disabled,new ii({func:p.ALWAYS,mask:0},E,255,p.KEEP,p.KEEP,p.REPLACE),yi.disabled,Kt.disabled,kr(S.posMatrix),M,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,l=this.context.gl;return new ii({func:l.NOTEQUAL,mask:255},t,255,l.KEEP,l.KEEP,l.REPLACE)}stencilModeForClipping(t){let l=this.context.gl;return new ii({func:l.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,l.KEEP,l.KEEP,l.REPLACE)}stencilConfigForOverlap(t){let l=this.context.gl,d=t.sort((S,E)=>E.overscaledZ-S.overscaledZ),p=d[d.length-1].overscaledZ,m=d[0].overscaledZ-p+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();let S={};for(let E=0;E<m;E++)S[E+p]=new ii({func:l.GEQUAL,mask:255},E+this.nextStencilID,255,l.KEEP,l.KEEP,l.REPLACE);return this.nextStencilID+=m,[S,d]}return[{[p]:ii.disabled},d]}colorModeForRenderPass(){let t=this.context.gl;return this._showOverdrawInspector?new yi([t.CONSTANT_COLOR,t.ONE],new s.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?yi.unblended:yi.alphaBlended}depthModeForSublayer(t,l,d){if(!this.opaquePassEnabledForLayer())return At.disabled;let p=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new At(d||this.context.gl.LEQUAL,l,[p,p])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,l){this.style=t,this.options=l,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(T.now()),this.imageManager.beginFrame();let d=this.style._order,p=this.style.sourceCaches,m={},S={},E={};for(let M in p){let R=p[M];R.used&&R.prepare(this.context),m[M]=R.getVisibleCoordinates(),S[M]=m[M].slice().reverse(),E[M]=R.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let M=0;M<d.length;M++)if(this.style._layers[d[M]].is3D()){this.opaquePassCutoff=M;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(let M of d){let R=this.style._layers[M];if(!R.hasOffscreenPass()||R.isHidden(this.transform.zoom))continue;let D=S[R.source];(R.type==="custom"||D.length)&&this.renderLayer(this,p[R.source],R,D)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:l.showOverdrawInspector?s.aM.black:s.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(M,R){let D=M.context,F=D.gl,j=((re,ne,H)=>({u_sky_color:re.properties.get("sky-color"),u_horizon_color:re.properties.get("horizon-color"),u_horizon:(ne.height/2+ne.getHorizon())*H,u_sky_horizon_blend:re.properties.get("sky-horizon-blend")*ne.height/2*H}))(R,M.style.map.transform,M.pixelRatio),W=new At(F.LEQUAL,At.ReadWrite,[0,1]),Z=ii.disabled,Y=M.colorModeForRenderPass(),te=M.useProgram("sky");if(!R.mesh){let re=new s.aX;re.emplaceBack(-1,-1),re.emplaceBack(1,-1),re.emplaceBack(1,1),re.emplaceBack(-1,1);let ne=new s.aY;ne.emplaceBack(0,1,2),ne.emplaceBack(0,2,3),R.mesh=new Ol(D.createVertexBuffer(re,Qs.members),D.createIndexBuffer(ne),s.a0.simpleSegment(0,0,re.length,ne.length))}te.draw(D,F.TRIANGLES,W,Z,Y,Kt.disabled,j,void 0,"sky",R.mesh.vertexBuffer,R.mesh.indexBuffer,R.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=l.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){let M=this.style._layers[d[this.currentLayer]],R=p[M.source],D=m[M.source];this._renderTileClippingMasks(M,D),this.renderLayer(this,R,M,D)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let M=this.style._layers[d[this.currentLayer]],R=p[M.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(M))continue;let D=(M.type==="symbol"?E:S)[M.source];this._renderTileClippingMasks(M,m[M.source]),this.renderLayer(this,R,M,D)}if(this.options.showTileBoundaries){let M=function(R,D){let F=null,j=Object.values(R._layers).flatMap(te=>te.source&&!te.isHidden(D)?[R.sourceCaches[te.source]]:[]),W=j.filter(te=>te.getSource().type==="vector"),Z=j.filter(te=>te.getSource().type!=="vector"),Y=te=>{(!F||F.getSource().maxzoom<te.getSource().maxzoom)&&(F=te)};return W.forEach(te=>Y(te)),F||Z.forEach(te=>Y(te)),F}(this.style,this.transform.zoom);M&&function(R,D,F){for(let j=0;j<F.length;j++)bd(R,D,F[j])}(this,M,M.getVisibleCoordinates())}this.options.showPadding&&function(M){let R=M.transform.padding;No(M,M.transform.height-(R.top||0),3,uh),No(M,R.bottom||0,3,jt),vd(M,R.left||0,3,Fl),vd(M,M.transform.width-(R.right||0),3,Df);let D=M.transform.centerPoint;(function(F,j,W,Z){zl(F,j-1,W-10,2,20,Z),zl(F,j-10,W-1,20,2,Z)})(M,D.x,M.transform.height-D.y,xd)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;let l=this.terrainFacilitator.matrix,d=this.transform.modelViewProjectionMatrix,p=this.terrainFacilitator.dirty;p||(p=t?!s.a_(l,d):!s.a$(l,d)),p||(p=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),p&&(s.b0(l,d),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(m,S){let E=m.context,M=E.gl,R=yi.unblended,D=new At(M.LEQUAL,At.ReadWrite,[0,1]),F=S.getTerrainMesh(),j=S.sourceCache.getRenderableTiles(),W=m.useProgram("terrainDepth");E.bindFramebuffer.set(S.getFramebuffer("depth").framebuffer),E.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),E.clear({color:s.aM.transparent,depth:1});for(let Z of j){let Y=S.getTerrainData(Z.tileID),te={u_matrix:m.transform.calculatePosMatrix(Z.tileID.toUnwrapped()),u_ele_delta:S.getMeshFrameDelta(m.transform.zoom)};W.draw(E,M.TRIANGLES,D,ii.disabled,R,Kt.backCCW,te,Y,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}E.bindFramebuffer.set(null),E.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain),function(m,S){let E=m.context,M=E.gl,R=yi.unblended,D=new At(M.LEQUAL,At.ReadWrite,[0,1]),F=S.getTerrainMesh(),j=S.getCoordsTexture(),W=S.sourceCache.getRenderableTiles(),Z=m.useProgram("terrainCoords");E.bindFramebuffer.set(S.getFramebuffer("coords").framebuffer),E.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),E.clear({color:s.aM.transparent,depth:1}),S.coordsIndex=[];for(let Y of W){let te=S.getTerrainData(Y.tileID);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,j.texture);let re={u_matrix:m.transform.calculatePosMatrix(Y.tileID.toUnwrapped()),u_terrain_coords_id:(255-S.coordsIndex.length)/255,u_texture:0,u_ele_delta:S.getMeshFrameDelta(m.transform.zoom)};Z.draw(E,M.TRIANGLES,D,ii.disabled,R,Kt.backCCW,re,te,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),S.coordsIndex.push(Y.tileID.key)}E.bindFramebuffer.set(null),E.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain))}renderLayer(t,l,d,p){if(!d.isHidden(this.transform.zoom)&&(d.type==="background"||d.type==="custom"||(p||[]).length))switch(this.id=d.id,d.type){case"symbol":(function(m,S,E,M,R){if(m.renderPass!=="translucent")return;let D=ii.disabled,F=m.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(j,W,Z,Y,te,re,ne,H,ce){let ue=W.transform,ge=Js(),Te=te==="map",Le=re==="map";for(let Ue of j){let Xe=Y.getTile(Ue),Oe=Xe.getBucket(Z);if(!Oe||!Oe.text||!Oe.text.segments.get().length)continue;let ze=s.ag(Oe.textSizeData,ue.zoom),et=Dt(Xe,1,W.transform.zoom),_t=Ln(Ue.posMatrix,Le,Te,W.transform,et),Ve=Z.layout.get("icon-text-fit")!=="none"&&Oe.hasIconData();if(ze){let We=Math.pow(2,ue.zoom-Xe.tileID.overscaledZ),ft=W.style.map.terrain?(Tt,Ft)=>W.style.map.terrain.getElevation(Ue,Tt,Ft):null,si=ge.translatePosition(ue,Xe,ne,H);Fo(Oe,Te,Le,ce,ue,_t,Ue.posMatrix,We,ze,Ve,ge,si,Ue.toUnwrapped(),ft)}}}(M,m,E,S,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),R),E.paint.get("icon-opacity").constantOr(1)!==0&&lh(m,S,E,M,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),D,F),E.paint.get("text-opacity").constantOr(1)!==0&&lh(m,S,E,M,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),D,F),S.map.showCollisionBoxes&&(La(m,S,E,M,!0),La(m,S,E,M,!1))})(t,l,d,p,this.style.placement.variableOffsets);break;case"circle":(function(m,S,E,M){if(m.renderPass!=="translucent")return;let R=E.paint.get("circle-opacity"),D=E.paint.get("circle-stroke-width"),F=E.paint.get("circle-stroke-opacity"),j=!E.layout.get("circle-sort-key").isConstant();if(R.constantOr(1)===0&&(D.constantOr(1)===0||F.constantOr(1)===0))return;let W=m.context,Z=W.gl,Y=m.depthModeForSublayer(0,At.ReadOnly),te=ii.disabled,re=m.colorModeForRenderPass(),ne=[];for(let H=0;H<M.length;H++){let ce=M[H],ue=S.getTile(ce),ge=ue.getBucket(E);if(!ge)continue;let Te=ge.programConfigurations.get(E.id),Le=m.useProgram("circle",Te),Ue=ge.layoutVertexBuffer,Xe=ge.indexBuffer,Oe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ce),ze={programConfiguration:Te,program:Le,layoutVertexBuffer:Ue,indexBuffer:Xe,uniformValues:vf(m,ce,ue,E),terrainData:Oe};if(j){let et=ge.segments.get();for(let _t of et)ne.push({segments:new s.a0([_t]),sortKey:_t.sortKey,state:ze})}else ne.push({segments:ge.segments,sortKey:0,state:ze})}j&&ne.sort((H,ce)=>H.sortKey-ce.sortKey);for(let H of ne){let{programConfiguration:ce,program:ue,layoutVertexBuffer:ge,indexBuffer:Te,uniformValues:Le,terrainData:Ue}=H.state;ue.draw(W,Z.TRIANGLES,Y,te,re,Kt.disabled,Le,Ue,E.id,ge,Te,H.segments,E.paint,m.transform.zoom,ce)}})(t,l,d,p);break;case"heatmap":(function(m,S,E,M){if(E.paint.get("heatmap-opacity")===0)return;let R=m.context;if(m.style.map.terrain){for(let D of M){let F=S.getTile(D);S.hasRenderableParent(D)||(m.renderPass==="offscreen"?hh(m,F,E,D):m.renderPass==="translucent"&&oo(m,E,D))}R.viewport.set([0,0,m.width,m.height])}else m.renderPass==="offscreen"?function(D,F,j,W){let Z=D.context,Y=Z.gl,te=ii.disabled,re=new yi([Y.ONE,Y.ONE],s.aM.transparent,[!0,!0,!0,!0]);(function(ne,H,ce){let ue=ne.gl;ne.activeTexture.set(ue.TEXTURE1),ne.viewport.set([0,0,H.width/4,H.height/4]);let ge=ce.heatmapFbos.get(s.aU);ge?(ue.bindTexture(ue.TEXTURE_2D,ge.colorAttachment.get()),ne.bindFramebuffer.set(ge.framebuffer)):(ge=Fa(ne,H.width/4,H.height/4),ce.heatmapFbos.set(s.aU,ge))})(Z,D,j),Z.clear({color:s.aM.transparent});for(let ne=0;ne<W.length;ne++){let H=W[ne];if(F.hasRenderableParent(H))continue;let ce=F.getTile(H),ue=ce.getBucket(j);if(!ue)continue;let ge=ue.programConfigurations.get(j.id),Te=D.useProgram("heatmap",ge),{zoom:Le}=D.transform;Te.draw(Z,Y.TRIANGLES,At.disabled,te,re,Kt.disabled,Lr(H.posMatrix,ce,Le,j.paint.get("heatmap-intensity")),null,j.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segments,j.paint,D.transform.zoom,ge)}Z.viewport.set([0,0,D.width,D.height])}(m,S,E,M):m.renderPass==="translucent"&&function(D,F){let j=D.context,W=j.gl;j.setColorMode(D.colorModeForRenderPass());let Z=F.heatmapFbos.get(s.aU);Z&&(j.activeTexture.set(W.TEXTURE0),W.bindTexture(W.TEXTURE_2D,Z.colorAttachment.get()),j.activeTexture.set(W.TEXTURE1),za(j,F).bind(W.LINEAR,W.CLAMP_TO_EDGE),D.useProgram("heatmapTexture").draw(j,W.TRIANGLES,At.disabled,ii.disabled,D.colorModeForRenderPass(),Kt.disabled,Cl(D,F,0,1),null,F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom))}(m,E)})(t,l,d,p);break;case"line":(function(m,S,E,M){if(m.renderPass!=="translucent")return;let R=E.paint.get("line-opacity"),D=E.paint.get("line-width");if(R.constantOr(1)===0||D.constantOr(1)===0)return;let F=m.depthModeForSublayer(0,At.ReadOnly),j=m.colorModeForRenderPass(),W=E.paint.get("line-dasharray"),Z=E.paint.get("line-pattern"),Y=Z.constantOr(1),te=E.paint.get("line-gradient"),re=E.getCrossfadeParameters(),ne=Y?"linePattern":W?"lineSDF":te?"lineGradient":"line",H=m.context,ce=H.gl,ue=!0;for(let ge of M){let Te=S.getTile(ge);if(Y&&!Te.patternsLoaded())continue;let Le=Te.getBucket(E);if(!Le)continue;let Ue=Le.programConfigurations.get(E.id),Xe=m.context.program.get(),Oe=m.useProgram(ne,Ue),ze=ue||Oe.program!==Xe,et=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ge),_t=Z.constantOr(null);if(_t&&Te.imageAtlas){let ft=Te.imageAtlas,si=ft.patternPositions[_t.to.toString()],Tt=ft.patternPositions[_t.from.toString()];si&&Tt&&Ue.setConstantPatternPositions(si,Tt)}let Ve=et?ge:null,We=Y?Lo(m,Te,E,re,Ve):W?bf(m,Te,E,W,re,Ve):te?id(m,Te,E,Le.lineClipsArray.length,Ve):Tl(m,Te,E,Ve);if(Y)H.activeTexture.set(ce.TEXTURE0),Te.imageAtlasTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE),Ue.updatePaintBuffers(re);else if(W&&(ze||m.lineAtlas.dirty))H.activeTexture.set(ce.TEXTURE0),m.lineAtlas.bind(H);else if(te){let ft=Le.gradients[E.id],si=ft.texture;if(E.gradientVersion!==ft.version){let Tt=256;if(E.stepInterpolant){let Ft=S.getSource().maxzoom,oi=ge.canonical.z===Ft?Math.ceil(1<<m.transform.maxZoom-ge.canonical.z):1;Tt=s.ac(s.aV(Le.maxLineLength/s.X*1024*oi),256,H.maxTextureSize)}ft.gradient=s.aW({expression:E.gradientExpression(),evaluationKey:"lineProgress",resolution:Tt,image:ft.gradient||void 0,clips:Le.lineClipsArray}),ft.texture?ft.texture.update(ft.gradient):ft.texture=new Ae(H,ft.gradient,ce.RGBA),ft.version=E.gradientVersion,si=ft.texture}H.activeTexture.set(ce.TEXTURE0),si.bind(E.stepInterpolant?ce.NEAREST:ce.LINEAR,ce.CLAMP_TO_EDGE)}Oe.draw(H,ce.TRIANGLES,F,m.stencilModeForClipping(ge),j,Kt.disabled,We,et,E.id,Le.layoutVertexBuffer,Le.indexBuffer,Le.segments,E.paint,m.transform.zoom,Ue,Le.layoutVertexBuffer2),ue=!1}})(t,l,d,p);break;case"fill":(function(m,S,E,M){let R=E.paint.get("fill-color"),D=E.paint.get("fill-opacity");if(D.constantOr(1)===0)return;let F=m.colorModeForRenderPass(),j=E.paint.get("fill-pattern"),W=m.opaquePassEnabledForLayer()&&!j.constantOr(1)&&R.constantOr(s.aM.transparent).a===1&&D.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===W){let Z=m.depthModeForSublayer(1,m.renderPass==="opaque"?At.ReadWrite:At.ReadOnly);Oa(m,S,E,M,Z,F,!1)}if(m.renderPass==="translucent"&&E.paint.get("fill-antialias")){let Z=m.depthModeForSublayer(E.getPaintProperty("fill-outline-color")?2:0,At.ReadOnly);Oa(m,S,E,M,Z,F,!0)}})(t,l,d,p);break;case"fill-extrusion":(function(m,S,E,M){let R=E.paint.get("fill-extrusion-opacity");if(R!==0&&m.renderPass==="translucent"){let D=new At(m.context.gl.LEQUAL,At.ReadWrite,m.depthRangeFor3D);if(R!==1||E.paint.get("fill-extrusion-pattern").constantOr(1))Dl(m,S,E,M,D,ii.disabled,yi.disabled),Dl(m,S,E,M,D,m.stencilModeFor3D(),m.colorModeForRenderPass());else{let F=m.colorModeForRenderPass();Dl(m,S,E,M,D,ii.disabled,F)}}})(t,l,d,p);break;case"hillshade":(function(m,S,E,M){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;let R=m.context,D=m.depthModeForSublayer(0,At.ReadOnly),F=m.colorModeForRenderPass(),[j,W]=m.renderPass==="translucent"?m.stencilConfigForOverlap(M):[{},M];for(let Z of W){let Y=S.getTile(Z);Y.needsHillshadePrepare!==void 0&&Y.needsHillshadePrepare&&m.renderPass==="offscreen"?Bo(m,Y,E,D,ii.disabled,F):m.renderPass==="translucent"&&Oo(m,Z,Y,E,D,j[Z.overscaledZ],F)}R.viewport.set([0,0,m.width,m.height])})(t,l,d,p);break;case"raster":(function(m,S,E,M){if(m.renderPass!=="translucent"||E.paint.get("raster-opacity")===0||!M.length)return;let R=m.context,D=R.gl,F=S.getSource(),j=m.useProgram("raster"),W=m.colorModeForRenderPass(),[Z,Y]=F instanceof Ar?[{},M]:m.stencilConfigForOverlap(M),te=Y[Y.length-1].overscaledZ,re=!m.options.moving;for(let ne of Y){let H=m.depthModeForSublayer(ne.overscaledZ-te,E.paint.get("raster-opacity")===1?At.ReadWrite:At.ReadOnly,D.LESS),ce=S.getTile(ne);ce.registerFadeDuration(E.paint.get("raster-fade-duration"));let ue=S.findLoadedParent(ne,0),ge=S.findLoadedSibling(ne),Te=_d(ce,ue||ge||null,S,E,m.transform,m.style.map.terrain),Le,Ue,Xe=E.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;R.activeTexture.set(D.TEXTURE0),ce.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),R.activeTexture.set(D.TEXTURE1),ue?(ue.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),Le=Math.pow(2,ue.tileID.overscaledZ-ce.tileID.overscaledZ),Ue=[ce.tileID.canonical.x*Le%1,ce.tileID.canonical.y*Le%1]):ce.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),ce.texture.useMipmap&&R.extTextureFilterAnisotropic&&m.transform.pitch>20&&D.texParameterf(D.TEXTURE_2D,R.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,R.extTextureFilterAnisotropicMax);let Oe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ne),ze=Oe?ne:null,et=ze?ze.posMatrix:m.transform.calculatePosMatrix(ne.toUnwrapped(),re),_t=wf(et,Ue||[0,0],Le||1,Te,E);F instanceof Ar?j.draw(R,D.TRIANGLES,H,ii.disabled,W,Kt.disabled,_t,Oe,E.id,F.boundsBuffer,m.quadTriangleIndexBuffer,F.boundsSegments):j.draw(R,D.TRIANGLES,H,Z[ne.overscaledZ],W,Kt.disabled,_t,Oe,E.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}})(t,l,d,p);break;case"background":(function(m,S,E,M){let R=E.paint.get("background-color"),D=E.paint.get("background-opacity");if(D===0)return;let F=m.context,j=F.gl,W=m.transform,Z=W.tileSize,Y=E.paint.get("background-pattern");if(m.isPatternMissing(Y))return;let te=!Y&&R.a===1&&D===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==te)return;let re=ii.disabled,ne=m.depthModeForSublayer(0,te==="opaque"?At.ReadWrite:At.ReadOnly),H=m.colorModeForRenderPass(),ce=m.useProgram(Y?"backgroundPattern":"background"),ue=M||W.coveringTiles({tileSize:Z,terrain:m.style.map.terrain});Y&&(F.activeTexture.set(j.TEXTURE0),m.imageManager.bind(m.context));let ge=E.getCrossfadeParameters();for(let Te of ue){let Le=M?Te.posMatrix:m.transform.calculatePosMatrix(Te.toUnwrapped()),Ue=Y?Yc(Le,D,m,Y,{tileID:Te,tileSize:Z},ge):Ml(Le,D,R),Xe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Te);ce.draw(F,j.TRIANGLES,ne,re,H,Kt.disabled,Ue,Xe,E.id,m.tileExtentBuffer,m.quadTriangleIndexBuffer,m.tileExtentSegments)}})(t,0,d,p);break;case"custom":(function(m,S,E){let M=m.context,R=E.implementation;if(m.renderPass==="offscreen"){let D=R.prerender;D&&(m.setCustomLayerDefaults(),M.setColorMode(m.colorModeForRenderPass()),D.call(R,M.gl,m.transform.customLayerMatrix()),M.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),M.setColorMode(m.colorModeForRenderPass()),M.setStencilMode(ii.disabled);let D=R.renderingMode==="3d"?new At(m.context.gl.LEQUAL,At.ReadWrite,m.depthRangeFor3D):m.depthModeForSublayer(0,At.ReadOnly);M.setDepthMode(D),R.render(M.gl,m.transform.customLayerMatrix(),{farZ:m.transform.farZ,nearZ:m.transform.nearZ,fov:m.transform._fov,modelViewProjectionMatrix:m.transform.modelViewProjectionMatrix,projectionMatrix:m.transform.projectionMatrix}),M.setDirty(),m.setBaseState(),M.bindFramebuffer.set(null)}})(t,0,d)}}translatePosMatrix(t,l,d,p,m){if(!d[0]&&!d[1])return t;let S=m?p==="map"?this.transform.angle:0:p==="viewport"?-this.transform.angle:0;if(S){let R=Math.sin(S),D=Math.cos(S);d=[d[0]*D-d[1]*R,d[0]*R+d[1]*D]}let E=[m?d[0]:Dt(l,d[0],this.transform.zoom),m?d[1]:Dt(l,d[1],this.transform.zoom),0],M=new Float32Array(16);return s.J(M,t,E),M}saveTileTexture(t){let l=this._tileTextures[t.size[0]];l?l.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let l=this._tileTextures[t];return l&&l.length>0?l.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let l=this.imageManager.getPattern(t.from.toString()),d=this.imageManager.getPattern(t.to.toString());return!l||!d}useProgram(t,l){this.cache=this.cache||{};let d=t+(l?l.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[d]||(this.cache[d]=new Hc(this.context,ks[t],l,Jc[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[d]}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(){let 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 Ae(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:l}=this.context.gl;return this.width!==t||this.height!==l}}class Vo{constructor(t,l){this.points=t,this.planes=l}static fromInvProjectionMatrix(t,l,d){let p=Math.pow(2,d),m=[[-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(E=>{let M=1/(E=s.af([],E,t))[3]/l*p;return s.b1(E,E,[M,M,1/E[3],M])}),S=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let M=function(j,W){var Z=W[0],Y=W[1],te=W[2],re=Z*Z+Y*Y+te*te;return re>0&&(re=1/Math.sqrt(re)),j[0]=W[0]*re,j[1]=W[1]*re,j[2]=W[2]*re,j}([],function(j,W,Z){var Y=W[0],te=W[1],re=W[2],ne=Z[0],H=Z[1],ce=Z[2];return j[0]=te*ce-re*H,j[1]=re*ne-Y*ce,j[2]=Y*H-te*ne,j}([],Pe([],m[E[0]],m[E[1]]),Pe([],m[E[2]],m[E[1]]))),R=-((D=M)[0]*(F=m[E[1]])[0]+D[1]*F[1]+D[2]*F[2]);var D,F;return M.concat(R)});return new Vo(m,S)}}class jo{constructor(t,l){this.min=t,this.max=l,this.center=function(d,p,m){return d[0]=.5*p[0],d[1]=.5*p[1],d[2]=.5*p[2],d}([],function(d,p,m){return d[0]=p[0]+m[0],d[1]=p[1]+m[1],d[2]=p[2]+m[2],d}([],this.min,this.max))}quadrant(t){let l=[t%2==0,t<2],d=we(this.min),p=we(this.max);for(let m=0;m<l.length;m++)d[m]=l[m]?this.min[m]:this.center[m],p[m]=l[m]?this.center[m]:this.max[m];return p[2]=this.max[2],new jo(d,p)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){let l=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]],d=!0;for(let p=0;p<t.planes.length;p++){let m=t.planes[p],S=0;for(let E=0;E<l.length;E++)s.b2(m,l[E])>=0&&S++;if(S===0)return 0;S!==l.length&&(d=!1)}if(d)return 2;for(let p=0;p<3;p++){let m=Number.MAX_VALUE,S=-Number.MAX_VALUE;for(let E=0;E<t.points.length;E++){let M=t.points[E][p]-this.min[p];m=Math.min(m,M),S=Math.max(S,M)}if(S<0||m>this.max[p]-this.min[p])return 0}return 1}}class Go{constructor(t=0,l=0,d=0,p=0){if(isNaN(t)||t<0||isNaN(l)||l<0||isNaN(d)||d<0||isNaN(p)||p<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=l,this.left=d,this.right=p}interpolate(t,l,d){return l.top!=null&&t.top!=null&&(this.top=s.y.number(t.top,l.top,d)),l.bottom!=null&&t.bottom!=null&&(this.bottom=s.y.number(t.bottom,l.bottom,d)),l.left!=null&&t.left!=null&&(this.left=s.y.number(t.left,l.left,d)),l.right!=null&&t.right!=null&&(this.right=s.y.number(t.right,l.right,d)),this}getCenter(t,l){let d=s.ac((this.left+t-this.right)/2,0,t),p=s.ac((this.top+l-this.bottom)/2,0,l);return new s.P(d,p)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Go(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let dh=85.051129;class Uo{constructor(t,l,d,p,m){this.tileSize=512,this._renderWorldCopies=m===void 0||!!m,this._minZoom=t||0,this._maxZoom=l||22,this._minPitch=d??0,this._maxPitch=p??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new s.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Go,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){let t=new Uo(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.lngRange=t.lngRange,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 s.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){let l=-s.b3(t,-180,180)*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),this.rotationMatrix=function(){var d=new s.A(4);return s.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}(),function(d,p,m){var S=p[0],E=p[1],M=p[2],R=p[3],D=Math.sin(m),F=Math.cos(m);d[0]=S*F+M*D,d[1]=E*F+R*D,d[2]=S*-D+M*F,d[3]=E*-D+R*F}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let l=s.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==l&&(this._unmodified=!1,this._pitch=l,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){let l=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==l&&(this._unmodified=!1,this._zoom=l,this.tileZoom=Math.max(0,Math.floor(l)),this.scale=this.zoomScale(l),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,l,d){this._unmodified=!1,this._edgeInsets.interpolate(t,l,d),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){let l=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,l)}getVisibleUnwrappedCoordinates(t){let l=[new s.b4(0,t)];if(this._renderWorldCopies){let d=this.pointCoordinate(new s.P(0,0)),p=this.pointCoordinate(new s.P(this.width,0)),m=this.pointCoordinate(new s.P(this.width,this.height)),S=this.pointCoordinate(new s.P(0,this.height)),E=Math.floor(Math.min(d.x,p.x,m.x,S.x)),M=Math.floor(Math.max(d.x,p.x,m.x,S.x)),R=1;for(let D=E-R;D<=M+R;D++)D!==0&&l.push(new s.b4(D,t))}return l}coveringTiles(t){var l,d;let p=this.coveringZoomLevel(t),m=p;if(t.minzoom!==void 0&&p<t.minzoom)return[];t.maxzoom!==void 0&&p>t.maxzoom&&(p=t.maxzoom);let S=this.pointCoordinate(this.getCameraPoint()),E=s.Z.fromLngLat(this.center),M=Math.pow(2,p),R=[M*S.x,M*S.y,0],D=[M*E.x,M*E.y,0],F=Vo.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,p),j=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(j=p);let W=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,Z=H=>({aabb:new jo([H*M,0,0],[(H+1)*M,M,0]),zoom:0,x:0,y:0,wrap:H,fullyVisible:!1}),Y=[],te=[],re=p,ne=t.reparseOverscaled?m:p;if(this._renderWorldCopies)for(let H=1;H<=3;H++)Y.push(Z(-H)),Y.push(Z(H));for(Y.push(Z(0));Y.length>0;){let H=Y.pop(),ce=H.x,ue=H.y,ge=H.fullyVisible;if(!ge){let Oe=H.aabb.intersects(F);if(Oe===0)continue;ge=Oe===2}let Te=t.terrain?R:D,Le=H.aabb.distanceX(Te),Ue=H.aabb.distanceY(Te),Xe=Math.max(Math.abs(Le),Math.abs(Ue));if(H.zoom===re||Xe>W+(1<<re-H.zoom)-2&&H.zoom>=j){let Oe=re-H.zoom,ze=R[0]-.5-(ce<<Oe),et=R[1]-.5-(ue<<Oe);te.push({tileID:new s.S(H.zoom===re?ne:H.zoom,H.wrap,H.zoom,ce,ue),distanceSq:Ee([D[0]-.5-ce,D[1]-.5-ue]),tileDistanceToCamera:Math.sqrt(ze*ze+et*et)})}else for(let Oe=0;Oe<4;Oe++){let ze=(ce<<1)+Oe%2,et=(ue<<1)+(Oe>>1),_t=H.zoom+1,Ve=H.aabb.quadrant(Oe);if(t.terrain){let We=new s.S(_t,H.wrap,_t,ze,et),ft=t.terrain.getMinMaxElevation(We),si=(l=ft.minElevation)!==null&&l!==void 0?l:this.elevation,Tt=(d=ft.maxElevation)!==null&&d!==void 0?d:this.elevation;Ve=new jo([Ve.min[0],Ve.min[1],si],[Ve.max[0],Ve.max[1],Tt])}Y.push({aabb:Ve,zoom:_t,x:ze,y:et,wrap:H.wrap,fullyVisible:ge})}}return te.sort((H,ce)=>H.distanceSq-ce.distanceSq).map(H=>H.tileID)}resize(t,l){this.width=t,this.height=l,this.pixelsToGLUnits=[2/t,-2/l],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){let l=s.ac(t.lat,-85.051129,dh);return new s.P(s.O(t.lng)*this.worldSize,s.Q(l)*this.worldSize)}unproject(t){return new s.Z(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){let l=this.elevation,d=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,p=this.pointLocation(this.centerPoint,t),m=t.getElevationForLngLatZoom(p,this.tileZoom);if(!(this.elevation-m))return;let S=d+l-m,E=Math.cos(this._pitch)*this.cameraToCenterDistance/S/s.b5(1,p.lat),M=this.scaleZoom(E/this.tileSize);this._elevation=m,this._center=p,this.zoom=M}setLocationAtPoint(t,l){let d=this.pointCoordinate(l),p=this.pointCoordinate(this.centerPoint),m=this.locationCoordinate(t),S=new s.Z(m.x-(d.x-p.x),m.y-(d.y-p.y));this.center=this.coordinateLocation(S),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,l){return l?this.coordinatePoint(this.locationCoordinate(t),l.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,l){return this.coordinateLocation(this.pointCoordinate(t,l))}locationCoordinate(t){return s.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,l){if(l){let j=l.pointCoordinate(t);if(j!=null)return j}let d=[t.x,t.y,0,1],p=[t.x,t.y,1,1];s.af(d,d,this.pixelMatrixInverse),s.af(p,p,this.pixelMatrixInverse);let m=d[3],S=p[3],E=d[1]/m,M=p[1]/S,R=d[2]/m,D=p[2]/S,F=R===D?0:(0-R)/(D-R);return new s.Z(s.y.number(d[0]/m,p[0]/S,F)/this.worldSize,s.y.number(E,M,F)/this.worldSize)}coordinatePoint(t,l=0,d=this.pixelMatrix){let p=[t.x*this.worldSize,t.y*this.worldSize,l,1];return s.af(p,p,d),new s.P(p[0]/p[3],p[1]/p[3])}getBounds(){let t=Math.max(0,this.height/2-this.getHorizon());return new ve().extend(this.pointLocation(new s.P(0,t))).extend(this.pointLocation(new s.P(this.width,t))).extend(this.pointLocation(new s.P(this.width,this.height))).extend(this.pointLocation(new s.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ve([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,dh])}calculateTileMatrix(t){let l=t.canonical,d=this.worldSize/this.zoomScale(l.z),p=l.x+Math.pow(2,l.z)*t.wrap,m=s.an(new Float64Array(16));return s.J(m,m,[p*d,l.y*d,0]),s.K(m,m,[d/s.X,d/s.X,1]),m}calculatePosMatrix(t,l=!1){let d=t.key,p=l?this._alignedPosMatrixCache:this._posMatrixCache;if(p[d])return p[d];let m=this.calculateTileMatrix(t);return s.L(m,l?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,m),p[d]=new Float32Array(m),p[d]}calculateFogMatrix(t){let l=t.key,d=this._fogMatrixCache;if(d[l])return d[l];let p=this.calculateTileMatrix(t);return s.L(p,this.fogMatrix,p),d[l]=new Float32Array(p),d[l]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,l){l=s.ac(+l,this.minZoom,this.maxZoom);let d={center:new s.N(t.lng,t.lat),zoom:l},p=this.lngRange;if(!this._renderWorldCopies&&p===null){let H=179.9999999999;p=[-H,H]}let m=this.tileSize*this.zoomScale(d.zoom),S=0,E=m,M=0,R=m,D=0,F=0,{x:j,y:W}=this.size;if(this.latRange){let H=this.latRange;S=s.Q(H[1])*m,E=s.Q(H[0])*m,E-S<W&&(D=W/(E-S))}p&&(M=s.b3(s.O(p[0])*m,0,m),R=s.b3(s.O(p[1])*m,0,m),R<M&&(R+=m),R-M<j&&(F=j/(R-M)));let{x:Z,y:Y}=this.project.call({worldSize:m},t),te,re,ne=Math.max(F||0,D||0);if(ne){let H=new s.P(F?(R+M)/2:Z,D?(E+S)/2:Y);return d.center=this.unproject.call({worldSize:m},H).wrap(),d.zoom+=this.scaleZoom(ne),d}if(this.latRange){let H=W/2;Y-H<S&&(re=S+H),Y+H>E&&(re=E-H)}if(p){let H=(M+R)/2,ce=Z;this._renderWorldCopies&&(ce=s.b3(Z,H-m/2,H+m/2));let ue=j/2;ce-ue<M&&(te=M+ue),ce+ue>R&&(te=R-ue)}if(te!==void 0||re!==void 0){let H=new s.P(te??Z,re??Y);d.center=this.unproject.call({worldSize:m},H).wrap()}return d}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:l,zoom:d}=this.getConstrained(this.center,this.zoom);this.center=l,this.zoom=d,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;let t=this.centerOffset,l=this.point.x,d=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=s.b5(1,this.center.lat)*this.worldSize;let p=s.an(new Float64Array(16));s.K(p,p,[this.width/2,-this.height/2,1]),s.J(p,p,[1,-1,0]),this.labelPlaneMatrix=p,p=s.an(new Float64Array(16)),s.K(p,p,[1,-1,1]),s.J(p,p,[-1,-1,0]),s.K(p,p,[2/this.width,2/this.height,1]),this.glCoordMatrix=p;let m=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),S=Math.min(this.elevation,this.minElevationForCurrentTile),E=m-S*this._pixelPerMeter/Math.cos(this._pitch),M=S<0?E:m,R=Math.PI/2+this._pitch,D=this._fov*(.5+t.y/this.height),F=Math.sin(D)*M/Math.sin(s.ac(Math.PI-R-D,.01,Math.PI-.01)),j=this.getHorizon(),W=2*Math.atan(j/this.cameraToCenterDistance)*(.5+t.y/(2*j)),Z=Math.sin(W)*M/Math.sin(s.ac(Math.PI-R-W,.01,Math.PI-.01)),Y=Math.min(F,Z);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*Y+M),this.nearZ=this.height/50,p=new Float64Array(16),s.b6(p,this._fov,this.width/this.height,this.nearZ,this.farZ),p[8]=2*-t.x/this.width,p[9]=2*t.y/this.height,this.projectionMatrix=s.ae(p),s.K(p,p,[1,-1,1]),s.J(p,p,[0,0,-this.cameraToCenterDistance]),s.b7(p,p,this._pitch),s.ad(p,p,this.angle),s.J(p,p,[-l,-d,0]),this.mercatorMatrix=s.K([],p,[this.worldSize,this.worldSize,this.worldSize]),s.K(p,p,[1,1,this._pixelPerMeter]),this.pixelMatrix=s.L(new Float64Array(16),this.labelPlaneMatrix,p),s.J(p,p,[0,0,-this.elevation]),this.modelViewProjectionMatrix=p,this.invModelViewProjectionMatrix=s.as([],p),this.fogMatrix=new Float64Array(16),s.b6(this.fogMatrix,this._fov,this.width/this.height,m,this.farZ),this.fogMatrix[8]=2*-t.x/this.width,this.fogMatrix[9]=2*t.y/this.height,s.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),s.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),s.b7(this.fogMatrix,this.fogMatrix,this._pitch),s.ad(this.fogMatrix,this.fogMatrix,this.angle),s.J(this.fogMatrix,this.fogMatrix,[-l,-d,0]),s.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),s.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=s.L(new Float64Array(16),this.labelPlaneMatrix,p);let te=this.width%2/2,re=this.height%2/2,ne=Math.cos(this.angle),H=Math.sin(this.angle),ce=l-Math.round(l)+ne*te+H*re,ue=d-Math.round(d)+ne*re+H*te,ge=new Float64Array(p);if(s.J(ge,ge,[ce>.5?ce-1:ce,ue>.5?ue-1:ue,0]),this.alignedModelViewProjectionMatrix=ge,p=s.as(new Float64Array(16),this.pixelMatrix),!p)throw new Error("failed to invert matrix");this.pixelMatrixInverse=p,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let t=this.pointCoordinate(new s.P(0,0)),l=[t.x*this.worldSize,t.y*this.worldSize,0,1];return s.af(l,l,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.P(0,t))}getCameraQueryGeometry(t){let l=this.getCameraPoint();if(t.length===1)return[t[0],l];{let d=l.x,p=l.y,m=l.x,S=l.y;for(let E of t)d=Math.min(d,E.x),p=Math.min(p,E.y),m=Math.max(m,E.x),S=Math.max(S,E.y);return[new s.P(d,p),new s.P(m,p),new s.P(m,S),new s.P(d,S),new s.P(d,p)]}}lngLatToCameraDepth(t,l){let d=this.locationCoordinate(t),p=[d.x*this.worldSize,d.y*this.worldSize,l,1];return s.af(p,p,this.modelViewProjectionMatrix),p[2]/p[3]}}function Ba(g,t){let l,d=!1,p=null,m=null,S=()=>{p=null,d&&(g.apply(m,l),p=setTimeout(S,t),d=!1)};return(...E)=>(d=!0,m=this,l=E,p||S(),p)}class Nl{constructor(t){this._getCurrentHash=()=>{let l=window.location.hash.replace("#","");if(this._hashName){let d;return l.split("&").map(p=>p.split("=")).forEach(p=>{p[0]===this._hashName&&(d=p)}),(d&&d[1]||"").split("/")}return l.split("/")},this._onHashChange=()=>{let l=this._getCurrentHash();if(l.length>=3&&!l.some(d=>isNaN(d))){let d=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(l[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+l[2],+l[1]],zoom:+l[0],bearing:d,pitch:+(l[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let l=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,l)},this._removeHash=()=>{let l=this._getCurrentHash();if(l.length===0)return;let d=l.join("/"),p=d;p.split("&").length>0&&(p=p.split("&")[0]),this._hashName&&(p=`${this._hashName}=${d}`);let m=window.location.hash.replace(p,"");m.startsWith("#&")?m=m.slice(0,1)+m.slice(2):m==="#"&&(m="");let S=window.location.href.replace(/(#.+)?$/,m);S=S.replace("&&","&"),window.history.replaceState(window.history.state,null,S)},this._updateHash=Ba(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()),this._removeHash(),delete this._map,this}getHashString(t){let l=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,p=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,p),S=Math.round(l.lng*m)/m,E=Math.round(l.lat*m)/m,M=this._map.getBearing(),R=this._map.getPitch(),D="";if(D+=t?`/${S}/${E}/${d}`:`${d}/${E}/${S}`,(M||R)&&(D+="/"+Math.round(10*M)/10),R&&(D+=`/${Math.round(R)}`),this._hashName){let F=this._hashName,j=!1,W=window.location.hash.slice(1).split("&").map(Z=>{let Y=Z.split("=")[0];return Y===F?(j=!0,`${Y}=${D}`):Z}).filter(Z=>Z);return j||W.push(`${F}=${D}`),`#${W.join("&")}`}return`#${D}`}}let Vl={linearity:.3,easing:s.b8(0,0,.3,1)},ph=s.e({deceleration:2500,maxSpeed:1400},Vl),Ff=s.e({deceleration:20,maxSpeed:1400},Vl),Sd=s.e({deceleration:1e3,maxSpeed:360},Vl),jl=s.e({deceleration:1e3,maxSpeed:90},Vl);class fh{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,l=T.now();for(;t.length>0&&l-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let l={zoom:0,bearing:0,pitch:0,pan:new s.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:m}of this._inertiaBuffer)l.zoom+=m.zoomDelta||0,l.bearing+=m.bearingDelta||0,l.pitch+=m.pitchDelta||0,m.panDelta&&l.pan._add(m.panDelta),m.around&&(l.around=m.around),m.pinchAround&&(l.pinchAround=m.pinchAround);let d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,p={};if(l.pan.mag()){let m=Va(l.pan.mag(),d,s.e({},ph,t||{}));p.offset=l.pan.mult(m.amount/l.pan.mag()),p.center=this._map.transform.center,Na(p,m)}if(l.zoom){let m=Va(l.zoom,d,Ff);p.zoom=this._map.transform.zoom+m.amount,Na(p,m)}if(l.bearing){let m=Va(l.bearing,d,Sd);p.bearing=this._map.transform.bearing+s.ac(m.amount,-179,179),Na(p,m)}if(l.pitch){let m=Va(l.pitch,d,jl);p.pitch=this._map.transform.pitch+m.amount,Na(p,m)}if(p.zoom||p.bearing){let m=l.pinchAround===void 0?l.around:l.pinchAround;p.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),s.e(p,{noMoveStart:!0})}}function Na(g,t){(!g.duration||g.duration<t.duration)&&(g.duration=t.duration,g.easing=t.easing)}function Va(g,t,l){let{maxSpeed:d,linearity:p,deceleration:m}=l,S=s.ac(g*p/(t/1e3),-d,d),E=Math.abs(S)/(m*p);return{easing:l.easing,duration:1e3*E,amount:S*(E/2)}}class Yi extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d,p={}){let m=C.mousePos(l.getCanvas(),d),S=l.unproject(m);super(t,s.e({point:m,lngLat:S,originalEvent:d},p)),this._defaultPrevented=!1,this.target=l}}class ao extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d){let p=t==="touchend"?d.changedTouches:d.touches,m=C.touchPos(l.getCanvasContainer(),p),S=m.map(M=>l.unproject(M)),E=m.reduce((M,R,D,F)=>M.add(R.div(F.length)),new s.P(0,0));super(t,{points:m,point:E,lngLats:S,lngLat:l.unproject(E),originalEvent:d}),this._defaultPrevented=!1}}class Id extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d){super(t,{originalEvent:d}),this._defaultPrevented=!1}}class Cd{constructor(t,l){this._map=t,this._clickTolerance=l.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Id(t.type,this._map,t))}mousedown(t,l){return this._mousedownPos=l,this._firePreventable(new Yi(t.type,this._map,t))}mouseup(t){this._map.fire(new Yi(t.type,this._map,t))}click(t,l){this._mousedownPos&&this._mousedownPos.dist(l)>=this._clickTolerance||this._map.fire(new Yi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Yi(t.type,this._map,t))}mouseover(t){this._map.fire(new Yi(t.type,this._map,t))}mouseout(t){this._map.fire(new Yi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ao(t.type,this._map,t))}touchmove(t){this._map.fire(new ao(t.type,this._map,t))}touchend(t){this._map.fire(new ao(t.type,this._map,t))}touchcancel(t){this._map.fire(new ao(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _i{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Yi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Yi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Yi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class On{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(s.P.convert(t),this._map.terrain)}}class Kr{constructor(t,l){this._map=t,this._tr=new On(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=l.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,l){this.isEnabled()&&t.shiftKey&&t.button===0&&(C.disableDrag(),this._startPos=this._lastPos=l,this._active=!0)}mousemoveWindow(t,l){if(!this._active)return;let d=l;if(this._lastPos.equals(d)||!this._box&&d.dist(this._startPos)<this._clickTolerance)return;let p=this._startPos;this._lastPos=d,this._box||(this._box=C.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let m=Math.min(p.x,d.x),S=Math.max(p.x,d.x),E=Math.min(p.y,d.y),M=Math.max(p.y,d.y);C.setTransform(this._box,`translate(${m}px,${E}px)`),this._box.style.width=S-m+"px",this._box.style.height=M-E+"px"}mouseupWindow(t,l){if(!this._active||t.button!==0)return;let d=this._startPos,p=l;if(this.reset(),C.suppressClick(),d.x!==p.x||d.y!==p.y)return this._map.fire(new s.k("boxzoomend",{originalEvent:t})),{cameraAnimation:m=>m.fitScreenCoordinates(d,p,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&&(C.remove(this._box),this._box=null),C.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,l){return this._map.fire(new s.k(t,{originalEvent:l}))}}function ja(g,t){if(g.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${g.length}, points ${t.length}`);let l={};for(let d=0;d<g.length;d++)l[g[d].identifier]=t[d];return l}class mh{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,l,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),d.length===this.numTouches&&(this.centroid=function(p){let m=new s.P(0,0);for(let S of p)m._add(S);return m.div(p.length)}(l),this.touches=ja(d,l)))}touchmove(t,l,d){if(this.aborted||!this.centroid)return;let p=ja(d,l);for(let m in this.touches){let S=p[m];(!S||S.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(t,l,d){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),d.length===0){let p=!this.aborted&&this.centroid;if(this.reset(),p)return p}}}class Gl{constructor(t){this.singleTap=new mh(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,l,d){this.singleTap.touchstart(t,l,d)}touchmove(t,l,d){this.singleTap.touchmove(t,l,d)}touchend(t,l,d){let p=this.singleTap.touchend(t,l,d);if(p){let m=t.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(p)<30;if(m&&S||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=p,this.count===this.numTaps)return this.reset(),p}}}class qo{constructor(t){this._tr=new On(t),this._zoomIn=new Gl({numTouches:1,numTaps:2}),this._zoomOut=new Gl({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,l,d){this._zoomIn.touchstart(t,l,d),this._zoomOut.touchstart(t,l,d)}touchmove(t,l,d){this._zoomIn.touchmove(t,l,d),this._zoomOut.touchmove(t,l,d)}touchend(t,l,d){let p=this._zoomIn.touchend(t,l,d),m=this._zoomOut.touchend(t,l,d),S=this._tr;return p?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:S.zoom+1,around:S.unproject(p)},{originalEvent:t})}):m?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:S.zoom-1,around:S.unproject(m)},{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 ps{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){let l=this._moveFunction(...t);if(l.bearingDelta||l.pitchDelta||l.around||l.panDelta)return this._active=!0,l}dragStart(t,l){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=l.length?l[0]:l,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,l){if(!this.isEnabled())return;let d=this._lastPoint;if(!d)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let p=l.length?l[0]:l;return!this._moved&&p.dist(d)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=p,this._move(d,p))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&C.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let gh={0:1,2:2};class Ul{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){let l=C.mouseButton(t);this._eventButton=l}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(l,d){let p=gh[d];return l.buttons===void 0||(l.buttons&p)!==p}(t,this._eventButton)}isValidEndEvent(t){return C.mouseButton(t)===this._eventButton}}class yh{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}let ql=g=>{g.mousedown=g.dragStart,g.mousemoveWindow=g.dragMove,g.mouseup=g.dragEnd,g.contextmenu=t=>{t.preventDefault()}},_h=({enable:g,clickTolerance:t,bearingDegreesPerPixelMoved:l=.8})=>{let d=new Ul({checkCorrectEvent:p=>C.mouseButton(p)===0&&p.ctrlKey||C.mouseButton(p)===2});return new ps({clickTolerance:t,move:(p,m)=>({bearingDelta:(m.x-p.x)*l}),moveStateManager:d,enable:g,assignEvents:ql})},xh=({enable:g,clickTolerance:t,pitchDegreesPerPixelMoved:l=-.5})=>{let d=new Ul({checkCorrectEvent:p=>C.mouseButton(p)===0&&p.ctrlKey||C.mouseButton(p)===2});return new ps({clickTolerance:t,move:(p,m)=>({pitchDelta:(m.y-p.y)*l}),moveStateManager:d,enable:g,assignEvents:ql})};class lo{constructor(t,l){this._clickTolerance=t.clickTolerance||1,this._map=l,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new s.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,l,d){return this._calculateTransform(t,l,d)}touchmove(t,l,d){if(this._active){if(!this._shouldBePrevented(d.length))return t.preventDefault(),this._calculateTransform(t,l,d);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,l,d){this._calculateTransform(t,l,d),this._active&&this._shouldBePrevented(d.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,l,d){d.length>0&&(this._active=!0);let p=ja(d,l),m=new s.P(0,0),S=new s.P(0,0),E=0;for(let R in p){let D=p[R],F=this._touches[R];F&&(m._add(D),S._add(D.sub(F)),E++,p[R]=D)}if(this._touches=p,this._shouldBePrevented(E)||!S.mag())return;let M=S.div(E);return this._sum._add(M),this._sum.mag()<this._clickTolerance?void 0:{around:m.div(E),panDelta:M}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $l{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,l,d){this._firstTwoTouches||d.length<2||(this._firstTwoTouches=[d[0].identifier,d[1].identifier],this._start([l[0],l[1]]))}touchmove(t,l,d){if(!this._firstTwoTouches)return;t.preventDefault();let[p,m]=this._firstTwoTouches,S=Ga(d,l,p),E=Ga(d,l,m);if(!S||!E)return;let M=this._aroundCenter?null:S.add(E).div(2);return this._move([S,E],M,t)}touchend(t,l,d){if(!this._firstTwoTouches)return;let[p,m]=this._firstTwoTouches,S=Ga(d,l,p),E=Ga(d,l,m);S&&E||(this._active&&C.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ga(g,t,l){for(let d=0;d<g.length;d++)if(g[d].identifier===l)return t[d]}function vh(g,t){return Math.log(g/t)/Math.LN2}class bh extends $l{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,l){let d=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(vh(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:vh(this._distance,d),pinchAround:l}}}function wh(g,t){return 180*g.angleWith(t)/Math.PI}class Sh extends $l{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,l,d){let p=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:wh(this._vector,p),pinchAround:l}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let l=25/(Math.PI*this._minDiameter)*360,d=wh(t,this._startVector);return Math.abs(d)<l}}function Wl(g){return Math.abs(g.y)>Math.abs(g.x)}class $o extends $l{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,l,d){super.touchstart(t,l,d),this._currentTouchCount=d.length}_start(t){this._lastPoints=t,Wl(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,l,d){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let p=t[0].sub(this._lastPoints[0]),m=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(p,m,d.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(p.y+m.y)/2*-.5}):void 0}gestureBeginsVertically(t,l,d){if(this._valid!==void 0)return this._valid;let p=t.mag()>=2,m=l.mag()>=2;if(!p&&!m)return;if(!p||!m)return this._firstMove===void 0&&(this._firstMove=d),d-this._firstMove<100&&void 0;let S=t.y>0==l.y>0;return Wl(t)&&Wl(l)&&S}}let Ed={panStep:100,bearingStep:15,pitchStep:10};class un{constructor(t){this._tr=new On(t);let l=Ed;this._panStep=l.panStep,this._bearingStep=l.bearingStep,this._pitchStep=l.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let l=0,d=0,p=0,m=0,S=0;switch(t.keyCode){case 61:case 107:case 171:case 187:l=1;break;case 189:case 109:case 173:l=-1;break;case 37:t.shiftKey?d=-1:(t.preventDefault(),m=-1);break;case 39:t.shiftKey?d=1:(t.preventDefault(),m=1);break;case 38:t.shiftKey?p=1:(t.preventDefault(),S=-1);break;case 40:t.shiftKey?p=-1:(t.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(d=0,p=0),{cameraAnimation:E=>{let M=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:es,zoom:l?Math.round(M.zoom)+l*(t.shiftKey?2:1):M.zoom,bearing:M.bearing+d*this._bearingStep,pitch:M.pitch+p*this._pitchStep,offset:[-m*this._panStep,-S*this._panStep],center:M.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 es(g){return g*(2-g)}let Ih=4.000244140625;class Bn{constructor(t,l){this._onTimeout=d=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(d)},this._map=t,this._tr=new On(t),this._triggerRenderFrame=l,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)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let l=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,d=T.now(),p=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,l!==0&&l%Ih==0?this._type="wheel":l!==0&&Math.abs(l)<4?this._type="trackpad":p>400?(this._type=null,this._lastValue=l,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(p*l)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,l+=this._lastValue)),t.shiftKey&&l&&(l/=4),this._type&&(this._lastWheelEvent=t,this._delta-=l,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);let l=C.mousePos(this._map.getCanvas(),t),d=this._tr;this._around=l.y>d.transform.height/2-d.transform.getHorizon()?s.N.convert(this._aroundCenter?d.center:d.unproject(l)):s.N.convert(d.center),this._aroundPoint=d.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._tr.transform;if(this._delta!==0){let M=this._type==="wheel"&&Math.abs(this._delta)>Ih?this._wheelZoomRate:this._defaultZoomRate,R=2/(1+Math.exp(-Math.abs(this._delta*M)));this._delta<0&&R!==0&&(R=1/R);let D=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(D*R))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let l=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,d=this._startZoom,p=this._easing,m,S=!1,E=T.now()-this._lastWheelEventTime;if(this._type==="wheel"&&d&&p&&E){let M=Math.min(E/200,1),R=p(M);m=s.y.number(d,l,R),M<1?this._frameId||(this._frameId=!0):S=!0}else m=l,S=!0;return this._active=!0,S&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!S,zoomDelta:m-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let l=s.b9;if(this._prevEase){let d=this._prevEase,p=(T.now()-d.start)/d.duration,m=d.easing(p+.01)-d.easing(p),S=.27/Math.sqrt(m*m+1e-4)*.01,E=Math.sqrt(.0729-S*S);l=s.b8(S,E,.25,1)}return this._prevEase={start:T.now(),duration:t,easing:l},l}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class co{constructor(t,l){this._clickZoom=t,this._tapZoom=l}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 zf{constructor(t){this._tr=new On(t),this.reset()}reset(){this._active=!1}dblclick(t,l){return t.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(l)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Of{constructor(){this._tap=new Gl({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,l,d){if(!this._swipePoint)if(this._tapTime){let p=l[0],m=t.timeStamp-this._tapTime<500,S=this._tapPoint.dist(p)<30;m&&S?d.length>0&&(this._swipePoint=p,this._swipeTouch=d[0].identifier):this.reset()}else this._tap.touchstart(t,l,d)}touchmove(t,l,d){if(this._tapTime){if(this._swipePoint){if(d[0].identifier!==this._swipeTouch)return;let p=l[0],m=p.y-this._swipePoint.y;return this._swipePoint=p,t.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(t,l,d)}touchend(t,l,d){if(this._tapTime)this._swipePoint&&d.length===0&&this.reset();else{let p=this._tap.touchend(t,l,d);p&&(this._tapTime=t.timeStamp,this._tapPoint=p)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Td{constructor(t,l,d){this._el=t,this._mousePan=l,this._touchPan=d}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 Md{constructor(t,l,d){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=l,this._mousePitch=d}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Ch{constructor(t,l,d,p){this._el=t,this._touchZoom=l,this._touchRotate=d,this._tapDragZoom=p,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 Wo{constructor(t,l){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=l,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=C.create("div","maplibregl-cooperative-gesture-screen",t);let l=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(l=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let d=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),p=document.createElement("div");p.className="maplibregl-desktop-message",p.textContent=l,this._container.appendChild(p);let m=document.createElement("div");m.className="maplibregl-mobile-message",m.textContent=d,this._container.appendChild(m),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(C.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._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,l){this._enabled&&(this._map.fire(new s.k("cooperativegestureprevented",{gestureType:t,originalEvent:l})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let dn=g=>g.zoom||g.drag||g.pitch||g.rotate;class Ye extends s.k{}function Zl(g){return g.panDelta&&g.panDelta.mag()||g.zoomDelta||g.bearingDelta||g.pitchDelta}class Eh{constructor(t,l){this.handleWindowEvent=p=>{this.handleEvent(p,`${p.type}Window`)},this.handleEvent=(p,m)=>{if(p.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let S=p.type==="renderFrame"?void 0:p,E={needsRenderFrame:!1},M={},R={},D=p.touches,F=D?this._getMapTouches(D):void 0,j=F?C.touchPos(this._map.getCanvas(),F):C.mousePos(this._map.getCanvas(),p);for(let{handlerName:Y,handler:te,allowed:re}of this._handlers){if(!te.isEnabled())continue;let ne;this._blockedByActive(R,re,Y)?te.reset():te[m||p.type]&&(ne=te[m||p.type](p,j,F),this.mergeHandlerResult(E,M,ne,Y,S),ne&&ne.needsRenderFrame&&this._triggerRenderFrame()),(ne||te.isActive())&&(R[Y]=te)}let W={};for(let Y in this._previousActiveHandlers)R[Y]||(W[Y]=S);this._previousActiveHandlers=R,(Object.keys(W).length||Zl(E))&&(this._changes.push([E,M,W]),this._triggerRenderFrame()),(Object.keys(R).length||Zl(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:Z}=E;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new fh(t),this._bearingSnap=l.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(l);let d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[window,"blur",void 0]];for(let[p,m,S]of this._listeners)C.addEventListener(p,m,p===document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(let[t,l,d]of this._listeners)C.removeEventListener(t,l,t===document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(t){let l=this._map,d=l.getCanvasContainer();this._add("mapEvent",new Cd(l,t));let p=l.boxZoom=new Kr(l,t);this._add("boxZoom",p),t.interactive&&t.boxZoom&&p.enable();let m=l.cooperativeGestures=new Wo(l,t.cooperativeGestures);this._add("cooperativeGestures",m),t.cooperativeGestures&&m.enable();let S=new qo(l),E=new zf(l);l.doubleClickZoom=new co(E,S),this._add("tapZoom",S),this._add("clickZoom",E),t.interactive&&t.doubleClickZoom&&l.doubleClickZoom.enable();let M=new Of;this._add("tapDragZoom",M);let R=l.touchPitch=new $o(l);this._add("touchPitch",R),t.interactive&&t.touchPitch&&l.touchPitch.enable(t.touchPitch);let D=_h(t),F=xh(t);l.dragRotate=new Md(t,D,F),this._add("mouseRotate",D,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),t.interactive&&t.dragRotate&&l.dragRotate.enable();let j=(({enable:ne,clickTolerance:H})=>{let ce=new Ul({checkCorrectEvent:ue=>C.mouseButton(ue)===0&&!ue.ctrlKey});return new ps({clickTolerance:H,move:(ue,ge)=>({around:ge,panDelta:ge.sub(ue)}),activateOnStart:!0,moveStateManager:ce,enable:ne,assignEvents:ql})})(t),W=new lo(t,l);l.dragPan=new Td(d,j,W),this._add("mousePan",j),this._add("touchPan",W,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&l.dragPan.enable(t.dragPan);let Z=new Sh,Y=new bh;l.touchZoomRotate=new Ch(d,Y,Z,M),this._add("touchRotate",Z,["touchPan","touchZoom"]),this._add("touchZoom",Y,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&l.touchZoomRotate.enable(t.touchZoomRotate);let te=l.scrollZoom=new Bn(l,()=>this._triggerRenderFrame());this._add("scrollZoom",te,["mousePan"]),t.interactive&&t.scrollZoom&&l.scrollZoom.enable(t.scrollZoom);let re=l.keyboard=new un(l);this._add("keyboard",re),t.interactive&&t.keyboard&&l.keyboard.enable(),this._add("blockableMapEvent",new _i(l))}_add(t,l,d){this._handlers.push({handlerName:t,handler:l,allowed:d}),this._handlersById[t]=l}stop(t){if(!this._updatingCamera){for(let{handler:l}of this._handlers)l.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{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!!dn(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,l,d){for(let p in t)if(p!==d&&(!l||l.indexOf(p)<0))return!0;return!1}_getMapTouches(t){let l=[];for(let d of t)this._el.contains(d.target)&&l.push(d);return l}mergeHandlerResult(t,l,d,p,m){if(!d)return;s.e(t,d);let S={handlerName:p,originalEvent:d.originalEvent||m};d.zoomDelta!==void 0&&(l.zoom=S),d.panDelta!==void 0&&(l.drag=S),d.pitchDelta!==void 0&&(l.pitch=S),d.bearingDelta!==void 0&&(l.rotate=S)}_applyChanges(){let t={},l={},d={};for(let[p,m,S]of this._changes)p.panDelta&&(t.panDelta=(t.panDelta||new s.P(0,0))._add(p.panDelta)),p.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+p.zoomDelta),p.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+p.bearingDelta),p.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+p.pitchDelta),p.around!==void 0&&(t.around=p.around),p.pinchAround!==void 0&&(t.pinchAround=p.pinchAround),p.noInertia&&(t.noInertia=p.noInertia),s.e(l,m),s.e(d,S);this._updateMapTransform(t,l,d),this._changes=[]}_updateMapTransform(t,l,d){let p=this._map,m=p._getTransformForUpdate(),S=p.terrain;if(!(Zl(t)||S&&this._terrainMovement))return this._fireEvents(l,d,!0);let{panDelta:E,zoomDelta:M,bearingDelta:R,pitchDelta:D,around:F,pinchAround:j}=t;j!==void 0&&(F=j),p._stop(!0),F=F||p.transform.centerPoint;let W=m.pointLocation(E?F.sub(E):F);R&&(m.bearing+=R),D&&(m.pitch+=D),M&&(m.zoom+=M),S?this._terrainMovement||!l.drag&&!l.zoom?l.drag&&this._terrainMovement?m.center=m.pointLocation(m.centerPoint.sub(E)):m.setLocationAtPoint(W,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,m.setLocationAtPoint(W,F)):m.setLocationAtPoint(W,F),p._applyUpdatedTransform(m),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(l,d,!0)}_fireEvents(t,l,d){let p=dn(this._eventsInProgress),m=dn(t),S={};for(let F in t){let{originalEvent:j}=t[F];this._eventsInProgress[F]||(S[`${F}start`]=j),this._eventsInProgress[F]=t[F]}!p&&m&&this._fireEvent("movestart",m.originalEvent);for(let F in S)this._fireEvent(F,S[F]);m&&this._fireEvent("move",m.originalEvent);for(let F in t){let{originalEvent:j}=t[F];this._fireEvent(F,j)}let E={},M;for(let F in this._eventsInProgress){let{handlerName:j,originalEvent:W}=this._eventsInProgress[F];this._handlersById[j].isActive()||(delete this._eventsInProgress[F],M=l[j]||W,E[`${F}end`]=M)}for(let F in E)this._fireEvent(F,E[F]);let R=dn(this._eventsInProgress),D=(p||m)&&!R;if(D&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(d&&D){this._updatingCamera=!0;let F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),j=W=>W!==0&&-this._bearingSnap<W&&W<this._bearingSnap;!F||!F.essential&&T.prefersReducedMotion?(this._map.fire(new s.k("moveend",{originalEvent:M})),j(this._map.getBearing())&&this._map.resetNorth()):(j(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:M})),this._updatingCamera=!1}}_fireEvent(t,l){this._map.fire(new s.k(t,l?{originalEvent:l}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new Ye("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Pd extends s.E{constructor(t,l){super(),this._renderFrameCallback=()=>{let d=Math.min((T.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(d)),d<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=l.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new s.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,l){return this.jumpTo({center:t},l)}panBy(t,l,d){return t=s.P.convert(t).mult(-1),this.panTo(this.transform.center,s.e({offset:t},l),d)}panTo(t,l,d){return this.easeTo(s.e({center:t},l),d)}getZoom(){return this.transform.zoom}setZoom(t,l){return this.jumpTo({zoom:t},l),this}zoomTo(t,l,d){return this.easeTo(s.e({zoom:t},l),d)}zoomIn(t,l){return this.zoomTo(this.getZoom()+1,t,l),this}zoomOut(t,l){return this.zoomTo(this.getZoom()-1,t,l),this}getBearing(){return this.transform.bearing}setBearing(t,l){return this.jumpTo({bearing:t},l),this}getPadding(){return this.transform.padding}setPadding(t,l){return this.jumpTo({padding:t},l),this}rotateTo(t,l,d){return this.easeTo(s.e({bearing:t},l),d)}resetNorth(t,l){return this.rotateTo(0,s.e({duration:1e3},t),l),this}resetNorthPitch(t,l){return this.easeTo(s.e({bearing:0,pitch:0,duration:1e3},t),l),this}snapToNorth(t,l){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,l):this}getPitch(){return this.transform.pitch}setPitch(t,l){return this.jumpTo({pitch:t},l),this}cameraForBounds(t,l){t=ve.convert(t).adjustAntiMeridian();let d=l&&l.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),d,l)}_cameraForBoxAndBearing(t,l,d,p){let m={top:0,bottom:0,right:0,left:0};if(typeof(p=s.e({padding:m,offset:[0,0],maxZoom:this.transform.maxZoom},p)).padding=="number"){let Oe=p.padding;p.padding={top:Oe,bottom:Oe,right:Oe,left:Oe}}p.padding=s.e(m,p.padding);let S=this.transform,E=S.padding,M=new ve(t,l),R=S.project(M.getNorthWest()),D=S.project(M.getNorthEast()),F=S.project(M.getSouthEast()),j=S.project(M.getSouthWest()),W=s.ba(-d),Z=R.rotate(W),Y=D.rotate(W),te=F.rotate(W),re=j.rotate(W),ne=new s.P(Math.max(Z.x,Y.x,re.x,te.x),Math.max(Z.y,Y.y,re.y,te.y)),H=new s.P(Math.min(Z.x,Y.x,re.x,te.x),Math.min(Z.y,Y.y,re.y,te.y)),ce=ne.sub(H),ue=(S.width-(E.left+E.right+p.padding.left+p.padding.right))/ce.x,ge=(S.height-(E.top+E.bottom+p.padding.top+p.padding.bottom))/ce.y;if(ge<0||ue<0)return void s.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let Te=Math.min(S.scaleZoom(S.scale*Math.min(ue,ge)),p.maxZoom),Le=s.P.convert(p.offset),Ue=new s.P((p.padding.left-p.padding.right)/2,(p.padding.top-p.padding.bottom)/2).rotate(s.ba(d)),Xe=Le.add(Ue).mult(S.scale/S.zoomScale(Te));return{center:S.unproject(R.add(F).div(2).sub(Xe)),zoom:Te,bearing:d}}fitBounds(t,l,d){return this._fitInternal(this.cameraForBounds(t,l),l,d)}fitScreenCoordinates(t,l,d,p,m){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(s.P.convert(t)),this.transform.pointLocation(s.P.convert(l)),d,p),p,m)}_fitInternal(t,l,d){return t?(delete(l=s.e(t,l)).padding,l.linear?this.easeTo(l,d):this.flyTo(l,d)):this}jumpTo(t,l){this.stop();let d=this._getTransformForUpdate(),p=!1,m=!1,S=!1;return"zoom"in t&&d.zoom!==+t.zoom&&(p=!0,d.zoom=+t.zoom),t.center!==void 0&&(d.center=s.N.convert(t.center)),"bearing"in t&&d.bearing!==+t.bearing&&(m=!0,d.bearing=+t.bearing),"pitch"in t&&d.pitch!==+t.pitch&&(S=!0,d.pitch=+t.pitch),t.padding==null||d.isPaddingEqual(t.padding)||(d.padding=t.padding),this._applyUpdatedTransform(d),this.fire(new s.k("movestart",l)).fire(new s.k("move",l)),p&&this.fire(new s.k("zoomstart",l)).fire(new s.k("zoom",l)).fire(new s.k("zoomend",l)),m&&this.fire(new s.k("rotatestart",l)).fire(new s.k("rotate",l)).fire(new s.k("rotateend",l)),S&&this.fire(new s.k("pitchstart",l)).fire(new s.k("pitch",l)).fire(new s.k("pitchend",l)),this.fire(new s.k("moveend",l))}calculateCameraOptionsFromTo(t,l,d,p=0){let m=s.Z.fromLngLat(t,l),S=s.Z.fromLngLat(d,p),E=S.x-m.x,M=S.y-m.y,R=S.z-m.z,D=Math.hypot(E,M,R);if(D===0)throw new Error("Can't calculate camera options with same From and To");let F=Math.hypot(E,M),j=this.transform.scaleZoom(this.transform.cameraToCenterDistance/D/this.transform.tileSize),W=180*Math.atan2(E,-M)/Math.PI,Z=180*Math.acos(F/D)/Math.PI;return Z=R<0?90-Z:90+Z,{center:S.toLngLat(),zoom:j,pitch:Z,bearing:W}}easeTo(t,l){var d;this._stop(!1,t.easeId),((t=s.e({offset:[0,0],duration:500,easing:s.b9},t)).animate===!1||!t.essential&&T.prefersReducedMotion)&&(t.duration=0);let p=this._getTransformForUpdate(),m=p.zoom,S=p.bearing,E=p.pitch,M=p.padding,R="bearing"in t?this._normalizeBearing(t.bearing,S):S,D="pitch"in t?+t.pitch:E,F="padding"in t?t.padding:p.padding,j=s.P.convert(t.offset),W=p.centerPoint.add(j),Z=p.pointLocation(W),{center:Y,zoom:te}=p.getConstrained(s.N.convert(t.center||Z),(d=t.zoom)!==null&&d!==void 0?d:m);this._normalizeCenter(Y,p);let re=p.project(Z),ne=p.project(Y).sub(re),H=p.zoomScale(te-m),ce,ue;t.around&&(ce=s.N.convert(t.around),ue=p.locationPoint(ce));let ge={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||te!==m,this._rotating=this._rotating||S!==R,this._pitching=this._pitching||D!==E,this._padding=!p.isPaddingEqual(F),this._easeId=t.easeId,this._prepareEase(l,t.noMoveStart,ge),this.terrain&&this._prepareElevation(Y),this._ease(Te=>{if(this._zooming&&(p.zoom=s.y.number(m,te,Te)),this._rotating&&(p.bearing=s.y.number(S,R,Te)),this._pitching&&(p.pitch=s.y.number(E,D,Te)),this._padding&&(p.interpolatePadding(M,F,Te),W=p.centerPoint.add(j)),this.terrain&&!t.freezeElevation&&this._updateElevation(Te),ce)p.setLocationAtPoint(ce,ue);else{let Le=p.zoomScale(p.zoom-m),Ue=te>m?Math.min(2,H):Math.max(.5,H),Xe=Math.pow(Ue,1-Te),Oe=p.unproject(re.add(ne.mult(Te*Xe)).mult(Le));p.setLocationAtPoint(p.renderWorldCopies?Oe.wrap():Oe,W)}this._applyUpdatedTransform(p),this._fireMoveEvents(l)},Te=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(l,Te)},t),this}_prepareEase(t,l,d={}){this._moving=!0,l||d.moving||this.fire(new s.k("movestart",t)),this._zooming&&!d.zooming&&this.fire(new s.k("zoomstart",t)),this._rotating&&!d.rotating&&this.fire(new s.k("rotatestart",t)),this._pitching&&!d.pitching&&this.fire(new s.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);let l=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&l!==this._elevationTarget){let d=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(d-(l-(d*t+this._elevationStart))/(1-t)),this._elevationTarget=l}this.transform.elevation=s.y.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){let l=t.getCameraPosition(),d=this.terrain.getElevationForLngLatZoom(l.lngLat,t.zoom);if(l.altitude<d){let p=this.calculateCameraOptionsFromTo(l.lngLat,d,t.center,t.elevation);return{pitch:p.pitch,zoom:p.zoom}}return{}}_applyUpdatedTransform(t){let l=[];if(this.terrain&&l.push(p=>this._elevateCameraIfInsideTerrain(p)),this.transformCameraUpdate&&l.push(p=>this.transformCameraUpdate(p)),!l.length)return;let d=t.clone();for(let p of l){let m=d.clone(),{center:S,zoom:E,pitch:M,bearing:R,elevation:D}=p(m);S&&(m.center=S),E!==void 0&&(m.zoom=E),M!==void 0&&(m.pitch=M),R!==void 0&&(m.bearing=R),D!==void 0&&(m.elevation=D),d.apply(m)}this.transform.apply(d)}_fireMoveEvents(t){this.fire(new s.k("move",t)),this._zooming&&this.fire(new s.k("zoom",t)),this._rotating&&this.fire(new s.k("rotate",t)),this._pitching&&this.fire(new s.k("pitch",t))}_afterEase(t,l){if(this._easeId&&l&&this._easeId===l)return;delete this._easeId;let d=this._zooming,p=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new s.k("zoomend",t)),p&&this.fire(new s.k("rotateend",t)),m&&this.fire(new s.k("pitchend",t)),this.fire(new s.k("moveend",t))}flyTo(t,l){var d;if(!t.essential&&T.prefersReducedMotion){let We=s.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(We,l)}this.stop(),t=s.e({offset:[0,0],speed:1.2,curve:1.42,easing:s.b9},t);let p=this._getTransformForUpdate(),m=p.zoom,S=p.bearing,E=p.pitch,M=p.padding,R="bearing"in t?this._normalizeBearing(t.bearing,S):S,D="pitch"in t?+t.pitch:E,F="padding"in t?t.padding:p.padding,j=s.P.convert(t.offset),W=p.centerPoint.add(j),Z=p.pointLocation(W),{center:Y,zoom:te}=p.getConstrained(s.N.convert(t.center||Z),(d=t.zoom)!==null&&d!==void 0?d:m);this._normalizeCenter(Y,p);let re=p.zoomScale(te-m),ne=p.project(Z),H=p.project(Y).sub(ne),ce=t.curve,ue=Math.max(p.width,p.height),ge=ue/re,Te=H.mag();if("minZoom"in t){let We=s.ac(Math.min(t.minZoom,m,te),p.minZoom,p.maxZoom),ft=ue/p.zoomScale(We-m);ce=Math.sqrt(ft/Te*2)}let Le=ce*ce;function Ue(We){let ft=(ge*ge-ue*ue+(We?-1:1)*Le*Le*Te*Te)/(2*(We?ge:ue)*Le*Te);return Math.log(Math.sqrt(ft*ft+1)-ft)}function Xe(We){return(Math.exp(We)-Math.exp(-We))/2}function Oe(We){return(Math.exp(We)+Math.exp(-We))/2}let ze=Ue(!1),et=function(We){return Oe(ze)/Oe(ze+ce*We)},_t=function(We){return ue*((Oe(ze)*(Xe(ft=ze+ce*We)/Oe(ft))-Xe(ze))/Le)/Te;var ft},Ve=(Ue(!0)-ze)/ce;if(Math.abs(Te)<1e-6||!isFinite(Ve)){if(Math.abs(ue-ge)<1e-6)return this.easeTo(t,l);let We=ge<ue?-1:1;Ve=Math.abs(Math.log(ge/ue))/ce,_t=()=>0,et=ft=>Math.exp(We*ce*ft)}return t.duration="duration"in t?+t.duration:1e3*Ve/("screenSpeed"in t?+t.screenSpeed/ce:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=S!==R,this._pitching=D!==E,this._padding=!p.isPaddingEqual(F),this._prepareEase(l,!1),this.terrain&&this._prepareElevation(Y),this._ease(We=>{let ft=We*Ve,si=1/et(ft);p.zoom=We===1?te:m+p.scaleZoom(si),this._rotating&&(p.bearing=s.y.number(S,R,We)),this._pitching&&(p.pitch=s.y.number(E,D,We)),this._padding&&(p.interpolatePadding(M,F,We),W=p.centerPoint.add(j)),this.terrain&&!t.freezeElevation&&this._updateElevation(We);let Tt=We===1?Y:p.unproject(ne.add(H.mult(_t(ft))).mult(si));p.setLocationAtPoint(p.renderWorldCopies?Tt.wrap():Tt,W),this._applyUpdatedTransform(p),this._fireMoveEvents(l)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(l)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,l){var d;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let p=this._onEaseEnd;delete this._onEaseEnd,p.call(this,l)}return t||(d=this.handlers)===null||d===void 0||d.stop(!1),this}_ease(t,l,d){d.animate===!1||d.duration===0?(t(1),l()):(this._easeStart=T.now(),this._easeOptions=d,this._onEaseFrame=t,this._onEaseEnd=l,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,l){t=s.b3(t,-180,180);let d=Math.abs(t-l);return Math.abs(t-360-l)<d&&(t-=360),Math.abs(t+360-l)<d&&(t+=360),t}_normalizeCenter(t,l){if(!l.renderWorldCopies||l.lngRange)return;let d=t.lng-l.center.lng;t.lng+=d>180?-360:d<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(s.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}let Zo={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Xo{constructor(t=Zo){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=l=>{!l||l.sourceDataType!=="metadata"&&l.sourceDataType!=="visibility"&&l.dataType!=="style"&&l.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=C.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=C.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=C.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(){C.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,l){let d=this._map._getUIString(`AttributionControl.${l}`);t.title=d,t.setAttribute("aria-label",d)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(p=>typeof p!="string"?"":p)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let p=this._map.style.stylesheet;this.styleOwner=p.owner,this.styleId=p.id}let l=this._map.style.sourceCaches;for(let p in l){let m=l[p];if(m.used||m.usedForTerrain){let S=m.getSource();S.attribution&&t.indexOf(S.attribution)<0&&t.push(S.attribution)}}t=t.filter(p=>String(p).trim()),t.sort((p,m)=>p.length-m.length),t=t.filter((p,m)=>{for(let S=m+1;S<t.length;S++)if(t[S].indexOf(p)>=0)return!1;return!0});let d=t.join(" | ");d!==this._attribHTML&&(this._attribHTML=d,t.length?(this._innerContainer.innerHTML=d,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Th{constructor(t={}){this._updateCompact=()=>{let l=this._container.children;if(l.length){let d=l[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&d.classList.add("maplibregl-compact"):d.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=C.create("div","maplibregl-ctrl");let l=C.create("a","maplibregl-ctrl-logo");return l.target="_blank",l.rel="noopener nofollow",l.href="https://maplibre.org/",l.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),l.setAttribute("rel","noopener nofollow"),this._container.appendChild(l),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){C.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ot{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let l=++this._id;return this._queue.push({callback:t,id:l,cancelled:!1}),l}remove(t){let l=this._currentlyRunning,d=l?this._queue.concat(l):this._queue;for(let p of d)if(p.id===t)return void(p.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let l=this._currentlyRunning=this._queue;this._queue=[];for(let d of l)if(!d.cancelled&&(d.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Mh=s.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Bf extends s.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,l){this.sourceCache.update(t,l),this._renderableTilesKeys=[];let d={};for(let p of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:l}))d[p.key]=!0,this._renderableTilesKeys.push(p.key),this._tiles[p.key]||(p.posMatrix=new Float64Array(16),s.aP(p.posMatrix,0,s.X,0,s.X,0,1),this._tiles[p.key]=new Jn(p,this.tileSize));for(let p in this._tiles)d[p]||delete this._tiles[p]}freeRtt(t){for(let l in this._tiles){let d=this._tiles[l];(!t||d.tileID.equals(t)||d.tileID.isChildOf(t)||t.isChildOf(d.tileID))&&(d.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){let l={};for(let d of this._renderableTilesKeys){let p=this._tiles[d].tileID;if(p.canonical.equals(t.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16),s.aP(m.posMatrix,0,s.X,0,s.X,0,1),l[d]=m}else if(p.canonical.isChildOf(t.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16);let S=p.canonical.z-t.canonical.z,E=p.canonical.x-(p.canonical.x>>S<<S),M=p.canonical.y-(p.canonical.y>>S<<S),R=s.X>>S;s.aP(m.posMatrix,0,R,0,R,0,1),s.J(m.posMatrix,m.posMatrix,[-E*R,-M*R,0]),l[d]=m}else if(t.canonical.isChildOf(p.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16);let S=t.canonical.z-p.canonical.z,E=t.canonical.x-(t.canonical.x>>S<<S),M=t.canonical.y-(t.canonical.y>>S<<S),R=s.X>>S;s.aP(m.posMatrix,0,s.X,0,s.X,0,1),s.J(m.posMatrix,m.posMatrix,[E*R,M*R,0]),s.K(m.posMatrix,m.posMatrix,[1/2**S,1/2**S,0]),l[d]=m}}return l}getSourceTile(t,l){let d=this.sourceCache._source,p=t.overscaledZ-this.deltaZoom;if(p>d.maxzoom&&(p=d.maxzoom),p<d.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(p).key);let m=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!m||!m.dem)&&l)for(;p>=d.minzoom&&(!m||!m.dem);)m=this.sourceCache.getTileByID(t.scaledTo(p--).key);return m}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(l=>l.timeAdded>=t)}}class Ph{constructor(t,l,d){this.painter=t,this.sourceCache=new Bf(l),this.options=d,this.exaggeration=typeof d.exaggeration=="number"?d.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,l,d,p=s.X){var m;if(!(l>=0&&l<p&&d>=0&&d<p))return 0;let S=this.getTerrainData(t),E=(m=S.tile)===null||m===void 0?void 0:m.dem;if(!E)return 0;let M=function(Z,Y,te){var re=Y[0],ne=Y[1];return Z[0]=te[0]*re+te[4]*ne+te[12],Z[1]=te[1]*re+te[5]*ne+te[13],Z}([],[l/p*s.X,d/p*s.X],S.u_terrain_matrix),R=[M[0]*E.dim,M[1]*E.dim],D=Math.floor(R[0]),F=Math.floor(R[1]),j=R[0]-D,W=R[1]-F;return E.get(D,F)*(1-j)*(1-W)+E.get(D+1,F)*j*(1-W)+E.get(D,F+1)*(1-j)*W+E.get(D+1,F+1)*j*W}getElevationForLngLatZoom(t,l){if(!s.bb(l,t.wrap()))return 0;let{tileID:d,mercatorX:p,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(t,l);return this.getElevation(d,p%s.X,m%s.X,s.X)}getElevation(t,l,d,p=s.X){return this.getDEMElevation(t,l,d,p)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let p=this.painter.context,m=new s.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ae(p,m,p.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ae(p,new s.R({width:1,height:1}),p.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(p.gl.NEAREST,p.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=s.an([])}let l=this.sourceCache.getSourceTile(t,!0);if(l&&l.dem&&(!l.demTexture||l.needsTerrainPrepare)){let p=this.painter.context;l.demTexture=this.painter.getTileTexture(l.dem.stride),l.demTexture?l.demTexture.update(l.dem.getPixels(),{premultiply:!1}):l.demTexture=new Ae(p,l.dem.getPixels(),p.gl.RGBA,{premultiply:!1}),l.demTexture.bind(p.gl.NEAREST,p.gl.CLAMP_TO_EDGE),l.needsTerrainPrepare=!1}let d=l&&l+l.tileID.key+t.key;if(d&&!this._demMatrixCache[d]){let p=this.sourceCache.sourceCache._source.maxzoom,m=t.canonical.z-l.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=p?m=t.canonical.z-p:s.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let S=t.canonical.x-(t.canonical.x>>m<<m),E=t.canonical.y-(t.canonical.y>>m<<m),M=s.bc(new Float64Array(16),[1/(s.X<<m),1/(s.X<<m),0]);s.J(M,M,[S*s.X,E*s.X,0]),this._demMatrixCache[t.key]={matrix:M,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:l&&l.dem&&l.dem.dim||1,u_terrain_matrix:d?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:l&&l.dem&&l.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(l&&l.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:l}}getFramebuffer(t){let l=this.painter,d=l.width/devicePixelRatio,p=l.height/devicePixelRatio;return!this._fbo||this._fbo.width===d&&this._fbo.height===p||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ae(l.context,{width:d,height:p,data:null},l.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(l.context.gl.NEAREST,l.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ae(l.context,{width:d,height:p,data:null},l.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(l.context.gl.NEAREST,l.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=l.context.createFramebuffer(d,p,!0,!1),this._fbo.depthAttachment.set(l.context.createRenderbuffer(l.context.gl.DEPTH_COMPONENT16,d,p))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let l=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let m=0,S=0;m<this._coordsTextureSize;m++)for(let E=0;E<this._coordsTextureSize;E++,S+=4)l[S+0]=255&E,l[S+1]=255&m,l[S+2]=E>>8<<4|m>>8,l[S+3]=0;let d=new s.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(l.buffer)),p=new Ae(t,d,t.gl.RGBA,{premultiply:!1});return p.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=p,p}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);let l=new Uint8Array(4),d=this.painter.context,p=d.gl,m=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),S=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),E=Math.round(this.painter.height/devicePixelRatio);d.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),p.readPixels(m,E-S-1,1,1,p.RGBA,p.UNSIGNED_BYTE,l),d.bindFramebuffer.set(null);let M=l[0]+(l[2]>>4<<8),R=l[1]+((15&l[2])<<8),D=this.coordsIndex[255-l[3]],F=D&&this.sourceCache.getTileByID(D);if(!F)return null;let j=this._coordsTextureSize,W=(1<<F.tileID.canonical.z)*j;return new s.Z((F.tileID.canonical.x*j+M)/W+F.tileID.wrap,(F.tileID.canonical.y*j+R)/W,this.getElevation(F.tileID,M,R,j))}depthAtPoint(t){let l=new Uint8Array(4),d=this.painter.context,p=d.gl;return d.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),p.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,p.RGBA,p.UNSIGNED_BYTE,l),d.bindFramebuffer.set(null),(l[0]/16777216+l[1]/65536+l[2]/256+l[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let t=this.painter.context,l=new s.bd,d=new s.aY,p=this.meshSize,m=s.X/p,S=p*p;for(let F=0;F<=p;F++)for(let j=0;j<=p;j++)l.emplaceBack(j*m,F*m,0);for(let F=0;F<S;F+=p+1)for(let j=0;j<p;j++)d.emplaceBack(j+F,p+j+F+1,p+j+F+2),d.emplaceBack(j+F,p+j+F+2,j+F+1);let E=l.length,M=E+2*(p+1);for(let F of[0,1])for(let j=0;j<=p;j++)for(let W of[0,1])l.emplaceBack(j*m,F*s.X,W);for(let F=0;F<2*p;F+=2)d.emplaceBack(M+F,M+F+1,M+F+3),d.emplaceBack(M+F,M+F+3,M+F+2),d.emplaceBack(E+F,E+F+3,E+F+1),d.emplaceBack(E+F,E+F+2,E+F+3);let R=l.length,D=R+2*(p+1);for(let F of[0,1])for(let j=0;j<=p;j++)for(let W of[0,1])l.emplaceBack(F*s.X,j*m,W);for(let F=0;F<2*p;F+=2)d.emplaceBack(R+F,R+F+1,R+F+3),d.emplaceBack(R+F,R+F+3,R+F+2),d.emplaceBack(D+F,D+F+3,D+F+1),d.emplaceBack(D+F,D+F+2,D+F+3);return this._mesh=new Ol(t.createVertexBuffer(l,Mh.members),t.createIndexBuffer(d),s.a0.simpleSegment(0,0,l.length,d.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*s.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,l){var d;let{tileID:p}=this._getOverscaledTileIDFromLngLatZoom(t,l);return(d=this.getMinMaxElevation(p).minElevation)!==null&&d!==void 0?d:0}getMinMaxElevation(t){let l=this.getTerrainData(t).tile,d={minElevation:null,maxElevation:null};return l&&l.dem&&(d.minElevation=l.dem.min*this.exaggeration,d.maxElevation=l.dem.max*this.exaggeration),d}_getOverscaledTileIDFromLngLatZoom(t,l){let d=s.Z.fromLngLat(t.wrap()),p=(1<<l)*s.X,m=d.x*p,S=d.y*p,E=Math.floor(m/s.X),M=Math.floor(S/s.X);return{tileID:new s.S(l,0,l,E,M),mercatorX:m,mercatorY:S}}}class Nf{constructor(t,l,d){this._context=t,this._size=l,this._tileSize=d,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){let l=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),d=new Ae(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return d.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),l.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),l.colorAttachment.set(d.texture),{id:t,fbo:l,texture:d,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(l=>t.id!==l),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(let l of this._recentlyUsed)if(!this._objects[l].inUse)return this._objects[l];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(let t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(t=>!t.inUse)===!1}}let Ho={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ad{constructor(t,l){this.painter=t,this.terrain=l,this.pool=new Nf(t.context,30,l.sourceCache.tileSize*l.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,l){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(d=>!t._layers[d].isHidden(l)),this._coordsDescendingInv={};for(let d in t.sourceCaches){this._coordsDescendingInv[d]={};let p=t.sourceCaches[d].getVisibleCoordinates();for(let m of p){let S=this.terrain.sourceCache.getTerrainCoords(m);for(let E in S)this._coordsDescendingInv[d][E]||(this._coordsDescendingInv[d][E]=[]),this._coordsDescendingInv[d][E].push(S[E])}}this._coordsDescendingInvStr={};for(let d of t._order){let p=t._layers[d],m=p.source;if(Ho[p.type]&&!this._coordsDescendingInvStr[m]){this._coordsDescendingInvStr[m]={};for(let S in this._coordsDescendingInv[m])this._coordsDescendingInvStr[m][S]=this._coordsDescendingInv[m][S].map(E=>E.key).sort().join()}}for(let d of this._renderableTiles)for(let p in this._coordsDescendingInvStr){let m=this._coordsDescendingInvStr[p][d.tileID.key];m&&m!==d.rttCoords[p]&&(d.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;let l=t.type,d=this.painter,p=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Ho[l]&&(this._prevType&&Ho[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(t.id),!p))return!0;if(Ho[this._prevType]||Ho[l]&&p){this._prevType=l;let m=this._stacks.length-1,S=this._stacks[m]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(wd(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[m]){let R=this.pool.getObjectForId(E.rtt[m].id);if(R.stamp===E.rtt[m].stamp){this.pool.useObject(R);continue}}let M=this.pool.getOrCreateFreeObject();this.pool.useObject(M),this.pool.stampObject(M),E.rtt[m]={id:M.id,stamp:M.stamp},d.context.bindFramebuffer.set(M.fbo.framebuffer),d.context.clear({color:s.aM.transparent,stencil:0}),d.currentStencilSource=void 0;for(let R=0;R<S.length;R++){let D=d.style._layers[S[R]],F=D.source?this._coordsDescendingInv[D.source][E.tileID.key]:[E.tileID];d.context.viewport.set([0,0,M.fbo.width,M.fbo.height]),d._renderTileClippingMasks(D,F),d.renderLayer(d,d.style.sourceCaches[D.source],D,F),D.source&&(E.rttCoords[D.source]=this._coordsDescendingInvStr[D.source][E.tileID.key])}}return wd(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Ho[l]}return!1}}let Ah={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Rd=y,Vf={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Zo,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:s.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},Rh=g=>{g.touchstart=g.dragStart,g.touchmoveWindow=g.dragMove,g.touchend=g.dragEnd},jf={showCompass:!0,showZoom:!0,visualizePitch:!1};class Gf{constructor(t,l,d=!1){this.mousedown=S=>{this.startMouse(s.e({},S,{ctrlKey:!0,preventDefault:()=>S.preventDefault()}),C.mousePos(this.element,S)),C.addEventListener(window,"mousemove",this.mousemove),C.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=S=>{this.moveMouse(S,C.mousePos(this.element,S))},this.mouseup=S=>{this.mouseRotate.dragEnd(S),this.mousePitch&&this.mousePitch.dragEnd(S),this.offTemp()},this.touchstart=S=>{S.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=C.touchPos(this.element,S.targetTouches)[0],this.startTouch(S,this._startPos),C.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.addEventListener(window,"touchend",this.touchend))},this.touchmove=S=>{S.targetTouches.length!==1?this.reset():(this._lastPos=C.touchPos(this.element,S.targetTouches)[0],this.moveTouch(S,this._lastPos))},this.touchend=S=>{S.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{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;let p=t.dragRotate._mouseRotate.getClickTolerance(),m=t.dragRotate._mousePitch.getClickTolerance();this.element=l,this.mouseRotate=_h({clickTolerance:p,enable:!0}),this.touchRotate=(({enable:S,clickTolerance:E,bearingDegreesPerPixelMoved:M=.8})=>{let R=new yh;return new ps({clickTolerance:E,move:(D,F)=>({bearingDelta:(F.x-D.x)*M}),moveStateManager:R,enable:S,assignEvents:Rh})})({clickTolerance:p,enable:!0}),this.map=t,d&&(this.mousePitch=xh({clickTolerance:m,enable:!0}),this.touchPitch=(({enable:S,clickTolerance:E,pitchDegreesPerPixelMoved:M=-.5})=>{let R=new yh;return new ps({clickTolerance:E,move:(D,F)=>({pitchDelta:(F.y-D.y)*M}),moveStateManager:R,enable:S,assignEvents:Rh})})({clickTolerance:m,enable:!0})),C.addEventListener(l,"mousedown",this.mousedown),C.addEventListener(l,"touchstart",this.touchstart,{passive:!1}),C.addEventListener(l,"touchcancel",this.reset)}startMouse(t,l){this.mouseRotate.dragStart(t,l),this.mousePitch&&this.mousePitch.dragStart(t,l),C.disableDrag()}startTouch(t,l){this.touchRotate.dragStart(t,l),this.touchPitch&&this.touchPitch.dragStart(t,l),C.disableDrag()}moveMouse(t,l){let d=this.map,{bearingDelta:p}=this.mouseRotate.dragMove(t,l)||{};if(p&&d.setBearing(d.getBearing()+p),this.mousePitch){let{pitchDelta:m}=this.mousePitch.dragMove(t,l)||{};m&&d.setPitch(d.getPitch()+m)}}moveTouch(t,l){let d=this.map,{bearingDelta:p}=this.touchRotate.dragMove(t,l)||{};if(p&&d.setBearing(d.getBearing()+p),this.touchPitch){let{pitchDelta:m}=this.touchPitch.dragMove(t,l)||{};m&&d.setPitch(d.getPitch()+m)}}off(){let t=this.element;C.removeEventListener(t,"mousedown",this.mousedown),C.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend),C.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){C.enableDrag(),C.removeEventListener(window,"mousemove",this.mousemove),C.removeEventListener(window,"mouseup",this.mouseup),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend)}}let Yr;function ni(g,t,l){let d=new s.N(g.lng,g.lat);if(g=new s.N(g.lng,g.lat),t){let p=new s.N(g.lng-360,g.lat),m=new s.N(g.lng+360,g.lat),S=l.locationPoint(g).distSqr(t);l.locationPoint(p).distSqr(t)<S?g=p:l.locationPoint(m).distSqr(t)<S&&(g=m)}for(;Math.abs(g.lng-l.center.lng)>180;){let p=l.locationPoint(g);if(p.x>=0&&p.y>=0&&p.x<=l.width&&p.y<=l.height)break;g.lng>l.center.lng?g.lng-=360:g.lng+=360}return g.lng!==d.lng&&l.locationPoint(g).y>l.height/2-l.getHorizon()?g:d}let Ko={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 Xl(g,t,l){let d=g.classList;for(let p in Ko)d.remove(`maplibregl-${l}-anchor-${p}`);d.add(`maplibregl-${l}-anchor-${t}`)}class Hl extends s.E{constructor(t){if(super(),this._onKeyPress=l=>{let d=l.code,p=l.charCode||l.keyCode;d!=="Space"&&d!=="Enter"&&p!==32&&p!==13||this.togglePopup()},this._onMapClick=l=>{let d=l.originalEvent.target,p=this._element;this._popup&&(d===p||p.contains(d))&&this.togglePopup()},this._update=l=>{var d;if(!this._map)return;let p=this._map.loaded()&&!this._map.isMoving();(l?.type==="terrain"||l?.type==="render"&&!p)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?ni(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.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 m="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?m=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(m=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let S="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?S="rotateX(0deg)":this._pitchAlignment==="map"&&(S=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||l&&l.type!=="moveend"||(this._pos=this._pos.round()),C.setTransform(this._element,`${Ko[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${S} ${m}`),T.frameAsync(new AbortController).then(()=>{this._updateOpacity(l&&l.type==="moveend")}).catch(()=>{})},this._onMove=l=>{if(!this._isDragging){let d=this._clickTolerance||this._map._clickTolerance;this._isDragging=l.point.dist(this._pointerdownPos)>=d}this._isDragging&&(this._pos=l.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 s.k("dragstart"))),this.fire(new s.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 s.k("dragend")),this._state="inactive"},this._addDragHandler=l=>{this._element.contains(l.originalEvent.target)&&(l.preventDefault(),this._positionDelta=l.point.sub(this._pos).add(this._offset),this._pointerdownPos=l.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._subpixelPositioning=t&&t.subpixelPositioning||!1,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?.opacity,t?.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=s.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=C.create("div");let l=C.createNS("http://www.w3.org/2000/svg","svg"),d=41,p=27;l.setAttributeNS(null,"display","block"),l.setAttributeNS(null,"height",`${d}px`),l.setAttributeNS(null,"width",`${p}px`),l.setAttributeNS(null,"viewBox",`0 0 ${p} ${d}`);let m=C.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");let S=C.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"fill-rule","nonzero");let E=C.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let M=[{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(let re of M){let ne=C.createNS("http://www.w3.org/2000/svg","ellipse");ne.setAttributeNS(null,"opacity","0.04"),ne.setAttributeNS(null,"cx","10.5"),ne.setAttributeNS(null,"cy","5.80029008"),ne.setAttributeNS(null,"rx",re.rx),ne.setAttributeNS(null,"ry",re.ry),E.appendChild(ne)}let R=C.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"fill",this._color);let D=C.createNS("http://www.w3.org/2000/svg","path");D.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"),R.appendChild(D);let F=C.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");let j=C.createNS("http://www.w3.org/2000/svg","path");j.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"),F.appendChild(j);let W=C.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(6.0, 7.0)"),W.setAttributeNS(null,"fill","#FFFFFF");let Z=C.createNS("http://www.w3.org/2000/svg","g");Z.setAttributeNS(null,"transform","translate(8.0, 8.0)");let Y=C.createNS("http://www.w3.org/2000/svg","circle");Y.setAttributeNS(null,"fill","#000000"),Y.setAttributeNS(null,"opacity","0.25"),Y.setAttributeNS(null,"cx","5.5"),Y.setAttributeNS(null,"cy","5.5"),Y.setAttributeNS(null,"r","5.4999962");let te=C.createNS("http://www.w3.org/2000/svg","circle");te.setAttributeNS(null,"fill","#FFFFFF"),te.setAttributeNS(null,"cx","5.5"),te.setAttributeNS(null,"cy","5.5"),te.setAttributeNS(null,"r","5.4999962"),Z.appendChild(Y),Z.appendChild(te),S.appendChild(E),S.appendChild(R),S.appendChild(F),S.appendChild(W),S.appendChild(Z),l.appendChild(S),l.setAttributeNS(null,"height",d*this._scale+"px"),l.setAttributeNS(null,"width",p*this._scale+"px"),this._element.appendChild(l),this._offset=s.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",l=>{l.preventDefault()}),this._element.addEventListener("mousedown",l=>{l.preventDefault()}),Xl(this._element,this._anchor,"marker"),t&&t.className)for(let l of t.className.split(" "))this._element.classList.add(l);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),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("terrain",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),C.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=s.N.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)){let p=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":[p,-1*(38.1-13.5+p)],"bottom-right":[-p,-1*(38.1-13.5+p)],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}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){let 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 l,d;if(!(!((l=this._map)===null||l===void 0)&&l.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)}let p=this._map,m=p.terrain.depthAtPoint(this._pos),S=p.terrain.getElevationForLngLatZoom(this._lngLat,p.transform.tileZoom);if(p.transform.lngLatToCameraDepth(this._lngLat,S)-m<.006)return void(this._element.style.opacity=this._opacity);let E=-this._offset.y/p.transform._pixelPerMeter,M=Math.sin(p.getPitch()*Math.PI/180)*E,R=p.terrain.depthAtPoint(new s.P(this._pos.x,this._pos.y-this._offset.y)),D=p.transform.lngLatToCameraDepth(this._lngLat,S+M)-R>.006;!((d=this._popup)===null||d===void 0)&&d.isOpen()&&D&&this._popup.remove(),this._element.style.opacity=D?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=s.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,l){return t===void 0&&l===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),l!==void 0&&(this._opacityWhenCovered=l),this._map&&this._updateOpacity(!0),this}}let kd={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ua=0,qa=!1,ts={maxWidth:100,unit:"metric"};function $a(g,t,l){let d=l&&l.maxWidth||100,p=g._container.clientHeight/2,m=g.unproject([0,p]),S=g.unproject([d,p]),E=m.distanceTo(S);if(l&&l.unit==="imperial"){let M=3.2808*E;M>5280?Qe(t,d,M/5280,g._getUIString("ScaleControl.Miles")):Qe(t,d,M,g._getUIString("ScaleControl.Feet"))}else l&&l.unit==="nautical"?Qe(t,d,E/1852,g._getUIString("ScaleControl.NauticalMiles")):E>=1e3?Qe(t,d,E/1e3,g._getUIString("ScaleControl.Kilometers")):Qe(t,d,E,g._getUIString("ScaleControl.Meters"))}function Qe(g,t,l,d){let p=function(m){let S=Math.pow(10,`${Math.floor(m)}`.length-1),E=m/S;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(M){let R=Math.pow(10,Math.ceil(-Math.log(M)/Math.LN10));return Math.round(M*R)/R}(E),S*E}(l);g.style.width=t*(p/l)+"px",g.innerHTML=`${p}&nbsp;${d}`}let ut={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Kl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Yl(g){if(g){if(typeof g=="number"){let t=Math.round(Math.abs(g)/Math.SQRT2);return{center:new s.P(0,0),top:new s.P(0,g),"top-left":new s.P(t,t),"top-right":new s.P(-t,t),bottom:new s.P(0,-g),"bottom-left":new s.P(t,-t),"bottom-right":new s.P(-t,-t),left:new s.P(g,0),right:new s.P(-g,0)}}if(g instanceof s.P||Array.isArray(g)){let t=s.P.convert(g);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:s.P.convert(g.center||[0,0]),top:s.P.convert(g.top||[0,0]),"top-left":s.P.convert(g["top-left"]||[0,0]),"top-right":s.P.convert(g["top-right"]||[0,0]),bottom:s.P.convert(g.bottom||[0,0]),"bottom-left":s.P.convert(g["bottom-left"]||[0,0]),"bottom-right":s.P.convert(g["bottom-right"]||[0,0]),left:s.P.convert(g.left||[0,0]),right:s.P.convert(g.right||[0,0])}}return Yl(new s.P(0,0))}let kh=y;c.AJAXError=s.bh,c.Evented=s.E,c.LngLat=s.N,c.MercatorCoordinate=s.Z,c.Point=s.P,c.addProtocol=s.bi,c.config=s.a,c.removeProtocol=s.bj,c.AttributionControl=Xo,c.BoxZoomHandler=Kr,c.CanvasSource=fr,c.CooperativeGesturesHandler=Wo,c.DoubleClickZoomHandler=co,c.DragPanHandler=Td,c.DragRotateHandler=Md,c.EdgeInsets=Go,c.FullscreenControl=class extends s.E{constructor(g={}){super(),this._onFullscreenChange=()=>{var t;let l=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=l?.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)l=l.shadowRoot.fullscreenElement;l===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,g&&g.container&&(g.container instanceof HTMLElement?this._container=g.container:s.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(g){return this._map=g,this._container||(this._container=this._map.getContainer()),this._controlContainer=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){C.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let g=this._fullscreenButton=C.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);C.create("span","maplibregl-ctrl-icon",g).setAttribute("aria-hidden","true"),g.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let g=this._getTitle();this._fullscreenButton.setAttribute("aria-label",g),this._fullscreenButton.title=g}_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 s.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new s.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()}},c.GeoJSONSource=Rn,c.GeolocateControl=class extends s.E{constructor(g){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new s.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 s.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{let l=new s.N(t.coords.longitude,t.coords.latitude),d=t.coords.accuracy,p=this._map.getBearing(),m=s.e({bearing:p},this.options.fitBoundsOptions),S=ve.fromLngLat(l,d);this._map.fitBounds(S,m,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let l=new s.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(l).addTo(this._map),this._userLocationDotMarker.setLngLat(l).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;let l=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&qa)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new s.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=C.create("button","maplibregl-ctrl-geolocate",this._container),C.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){s.w("Geolocation support is not available so the GeolocateControl will be disabled.");let l=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l)}else{let l=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=C.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Hl({element:this._dotElement}),this._circleElement=C.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Hl({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",l=>{l.geolocateSource||this._watchState!=="ACTIVE_LOCK"||l.originalEvent&&l.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 s.k("trackuserlocationend")),this.fire(new s.k("userlocationlostfocus")))})}},this.options=s.e({},kd,g)}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return s._(this,arguments,void 0,function*(t=!1){if(Yr!==void 0&&!t)return Yr;if(window.navigator.permissions===void 0)return Yr=!!window.navigator.geolocation,Yr;try{Yr=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Yr=!!window.navigator.geolocation}return Yr})}().then(t=>this._finishSetupUI(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(),C.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ua=0,qa=!1}_isOutOfMapMaxBounds(g){let t=this._map.getMaxBounds(),l=g.coords;return t&&(l.longitude<t.getWest()||l.longitude>t.getEast()||l.latitude<t.getSouth()||l.latitude>t.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(){let g=this._map.getBounds(),t=g.getSouthEast(),l=g.getNorthEast(),d=t.distanceTo(l),p=Math.ceil(this._accuracy/(d/this._map._container.clientHeight)*2);this._circleElement.style.width=`${p}px`,this._circleElement.style.height=`${p}px`}trigger(){if(!this._setup)return s.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 s.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ua--,qa=!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 s.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 s.k("trackuserlocationstart")),this.fire(new s.k("userlocationfocus"));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 g;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ua++,Ua>1?(g={maximumAge:6e5,timeout:0},qa=!0):(g=this.options.positionOptions,qa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,g)}}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)}},c.Hash=Nl,c.ImageSource=Ar,c.KeyboardHandler=un,c.LngLatBounds=ve,c.LogoControl=Th,c.Map=class extends Pd{constructor(g){s.bf.mark(s.bg.create);let t=Object.assign(Object.assign({},Vf),g);if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Uo(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ot,this._controls=[],this._mapId=s.a4(),this._contextLost=l=>{l.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new s.k("webglcontextlost",{originalEvent:l}))},this._contextRestored=l=>{this._setupPainter(),this.resize(),this._update(),this.fire(new s.k("webglcontextrestored",{originalEvent:l}))},this._onMapScroll=l=>{if(l.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=t.preserveDrawingBuffer===!0,this._antialias=t.antialias===!0,this._trackResize=t.trackResize===!0,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ah),t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=fe.addThrottleControl(()=>this.isMoving()),this._requestManager=new ye(t.transformRequest),typeof t.container=="string"){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let l=!1,d=Ba(p=>{this._trackResize&&!this._removed&&(this.resize(p),this.redraw())},50);this._resizeObserver=new ResizeObserver(p=>{l?d(p):l=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Eh(this,t),this._hash=t.hash&&new Nl(typeof t.hash=="string"&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,s.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Xo(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new Th,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",l=>{this._update(l.dataType==="style"),this.fire(new s.k(`${l.dataType}data`,l))}),this.on("dataloading",l=>{this.fire(new s.k(`${l.dataType}dataloading`,l))}),this.on("dataabort",l=>{this.fire(new s.k("sourcedataabort",l))})}_getMapId(){return this._mapId}addControl(g,t){if(t===void 0&&(t=g.getDefaultPosition?g.getDefaultPosition():"top-right"),!g||!g.onAdd)return this.fire(new s.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let l=g.onAdd(this);this._controls.push(g);let d=this._controlPositions[t];return t.indexOf("bottom")!==-1?d.insertBefore(l,d.firstChild):d.appendChild(l),this}removeControl(g){if(!g||!g.onRemove)return this.fire(new s.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(g);return t>-1&&this._controls.splice(t,1),g.onRemove(this),this}hasControl(g){return this._controls.indexOf(g)>-1}calculateCameraOptionsFromTo(g,t,l,d){return d==null&&this.terrain&&(d=this.terrain.getElevationForLngLatZoom(l,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(g,t,l,d)}resize(g){var t;let l=this._containerDimensions(),d=l[0],p=l[1],m=this._getClampedPixelRatio(d,p);if(this._resizeCanvas(d,p,m),this.painter.resize(d,p,m),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let M=this._getClampedPixelRatio(d,p);this._resizeCanvas(d,p,M),this.painter.resize(d,p,M)}this.transform.resize(d,p),(t=this._requestedCameraState)===null||t===void 0||t.resize(d,p);let S=!this._moving;return S&&(this.stop(),this.fire(new s.k("movestart",g)).fire(new s.k("move",g))),this.fire(new s.k("resize",g)),S&&this.fire(new s.k("moveend",g)),this}_getClampedPixelRatio(g,t){let{0:l,1:d}=this._maxCanvasSize,p=this.getPixelRatio(),m=g*p,S=t*p;return Math.min(m>l?l/m:1,S>d?d/S:1)*p}getPixelRatio(){var g;return(g=this._overridePixelRatio)!==null&&g!==void 0?g:devicePixelRatio}setPixelRatio(g){this._overridePixelRatio=g,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(g){return this.transform.setMaxBounds(ve.convert(g)),this._update()}setMinZoom(g){if((g=g??-2)>=-2&&g<=this.transform.maxZoom)return this.transform.minZoom=g,this._update(),this.getZoom()<g&&this.setZoom(g),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(g){if((g=g??22)>=this.transform.minZoom)return this.transform.maxZoom=g,this._update(),this.getZoom()>g&&this.setZoom(g),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(g){if((g=g??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(g>=0&&g<=this.transform.maxPitch)return this.transform.minPitch=g,this._update(),this.getPitch()<g&&this.setPitch(g),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(g){if((g=g??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(g>=this.transform.minPitch)return this.transform.maxPitch=g,this._update(),this.getPitch()>g&&this.setPitch(g),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(g){return this.transform.renderWorldCopies=g,this._update()}project(g){return this.transform.locationPoint(s.N.convert(g),this.style&&this.terrain)}unproject(g){return this.transform.pointLocation(s.P.convert(g),this.terrain)}isMoving(){var g;return this._moving||((g=this.handlers)===null||g===void 0?void 0:g.isMoving())}isZooming(){var g;return this._zooming||((g=this.handlers)===null||g===void 0?void 0:g.isZooming())}isRotating(){var g;return this._rotating||((g=this.handlers)===null||g===void 0?void 0:g.isRotating())}_createDelegatedListener(g,t,l){if(g==="mouseenter"||g==="mouseover"){let d=!1;return{layers:t,listener:l,delegates:{mousemove:m=>{let S=t.filter(M=>this.getLayer(M)),E=S.length!==0?this.queryRenderedFeatures(m.point,{layers:S}):[];E.length?d||(d=!0,l.call(this,new Yi(g,this,m.originalEvent,{features:E}))):d=!1},mouseout:()=>{d=!1}}}}if(g==="mouseleave"||g==="mouseout"){let d=!1;return{layers:t,listener:l,delegates:{mousemove:S=>{let E=t.filter(M=>this.getLayer(M));(E.length!==0?this.queryRenderedFeatures(S.point,{layers:E}):[]).length?d=!0:d&&(d=!1,l.call(this,new Yi(g,this,S.originalEvent)))},mouseout:S=>{d&&(d=!1,l.call(this,new Yi(g,this,S.originalEvent)))}}}}{let d=p=>{let m=t.filter(E=>this.getLayer(E)),S=m.length!==0?this.queryRenderedFeatures(p.point,{layers:m}):[];S.length&&(p.features=S,l.call(this,p),delete p.features)};return{layers:t,listener:l,delegates:{[g]:d}}}}_saveDelegatedListener(g,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[g]=this._delegatedListeners[g]||[],this._delegatedListeners[g].push(t)}_removeDelegatedListener(g,t,l){if(!this._delegatedListeners||!this._delegatedListeners[g])return;let d=this._delegatedListeners[g];for(let p=0;p<d.length;p++){let m=d[p];if(m.listener===l&&m.layers.length===t.length&&m.layers.every(S=>t.includes(S))){for(let S in m.delegates)this.off(S,m.delegates[S]);return void d.splice(p,1)}}}on(g,t,l){if(l===void 0)return super.on(g,t);let d=this._createDelegatedListener(g,typeof t=="string"?[t]:t,l);this._saveDelegatedListener(g,d);for(let p in d.delegates)this.on(p,d.delegates[p]);return this}once(g,t,l){if(l===void 0)return super.once(g,t);let d=typeof t=="string"?[t]:t,p=this._createDelegatedListener(g,d,l);for(let m in p.delegates){let S=p.delegates[m];p.delegates[m]=(...E)=>{this._removeDelegatedListener(g,d,l),S(...E)}}this._saveDelegatedListener(g,p);for(let m in p.delegates)this.once(m,p.delegates[m]);return this}off(g,t,l){return l===void 0?super.off(g,t):(this._removeDelegatedListener(g,typeof t=="string"?[t]:t,l),this)}queryRenderedFeatures(g,t){if(!this.style)return[];let l,d=g instanceof s.P||Array.isArray(g),p=d?g:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(d?{}:g)||{},p instanceof s.P||typeof p[0]=="number")l=[s.P.convert(p)];else{let m=s.P.convert(p[0]),S=s.P.convert(p[1]);l=[m,new s.P(S.x,m.y),S,new s.P(m.x,S.y),m]}return this.style.queryRenderedFeatures(l,t,this.transform)}querySourceFeatures(g,t){return this.style.querySourceFeatures(g,t)}setStyle(g,t){return(t=s.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&g?(this._diffStyle(g,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(g,t))}setTransformRequest(g){return this._requestManager.setTransformRequest(g),this}_getUIString(g){let t=this._locale[g];if(t==null)throw new Error(`Missing UI string '${g}'`);return t}_updateStyle(g,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(g,t));let l=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!g)),g?(this.style=new wl(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof g=="string"?this.style.loadURL(g,t,l):this.style.loadJSON(g,t,l),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new wl(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(g,t){if(typeof g=="string"){let l=this._requestManager.transformRequest(g,"Style");s.h(l,new AbortController).then(d=>{this._updateDiff(d.data,t)}).catch(d=>{d&&this.fire(new s.j(d))})}else typeof g=="object"&&this._updateDiff(g,t)}_updateDiff(g,t){try{this.style.setState(g,t)&&this._update(!0)}catch(l){s.w(`Unable to perform style diff: ${l.message||l.error||l}. Rebuilding the style from scratch.`),this._updateStyle(g,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():s.w("There is no style added to the map.")}addSource(g,t){return this._lazyInitEmptyStyle(),this.style.addSource(g,t),this._update(!0)}isSourceLoaded(g){let t=this.style&&this.style.sourceCaches[g];if(t!==void 0)return t.loaded();this.fire(new s.j(new Error(`There is no source with ID '${g}'`)))}setTerrain(g){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),g){let t=this.style.sourceCaches[g.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${g.source}`);this.terrain===null&&t.reload();for(let l in this.style._layers){let d=this.style._layers[l];d.type==="hillshade"&&d.source===g.source&&s.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 Ph(this.painter,t,g),this.painter.renderToTexture=new Ad(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=l=>{l.dataType==="style"?this.terrain.sourceCache.freeRtt():l.dataType==="source"&&l.tile&&(l.sourceId!==g.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(l.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 s.k("terrain",{terrain:g})),this}getTerrain(){var g,t;return(t=(g=this.terrain)===null||g===void 0?void 0:g.options)!==null&&t!==void 0?t:null}areTilesLoaded(){let g=this.style&&this.style.sourceCaches;for(let t in g){let l=g[t]._tiles;for(let d in l){let p=l[d];if(p.state!=="loaded"&&p.state!=="errored")return!1}}return!0}removeSource(g){return this.style.removeSource(g),this._update(!0)}getSource(g){return this.style.getSource(g)}addImage(g,t,l={}){let{pixelRatio:d=1,sdf:p=!1,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R}=l;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||s.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new s.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`")));{let{width:D,height:F,data:j}=t,W=t;return this.style.addImage(g,{data:new s.R({width:D,height:F},new Uint8Array(j)),pixelRatio:d,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R,sdf:p,version:0,userImage:W}),W.onAdd&&W.onAdd(this,g),this}}{let{width:D,height:F,data:j}=T.getImageData(t);this.style.addImage(g,{data:new s.R({width:D,height:F},j),pixelRatio:d,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R,sdf:p,version:0})}}updateImage(g,t){let l=this.style.getImage(g);if(!l)return this.fire(new s.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=t instanceof HTMLImageElement||s.b(t)?T.getImageData(t):t,{width:p,height:m,data:S}=d;if(p===void 0||m===void 0)return this.fire(new s.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(p!==l.data.width||m!==l.data.height)return this.fire(new s.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(t instanceof HTMLImageElement||s.b(t));return l.data.replace(S,E),this.style.updateImage(g,l),this}getImage(g){return this.style.getImage(g)}hasImage(g){return g?!!this.style.getImage(g):(this.fire(new s.j(new Error("Missing required image id"))),!1)}removeImage(g){this.style.removeImage(g)}loadImage(g){return fe.getImage(this._requestManager.transformRequest(g,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(g,t){return this._lazyInitEmptyStyle(),this.style.addLayer(g,t),this._update(!0)}moveLayer(g,t){return this.style.moveLayer(g,t),this._update(!0)}removeLayer(g){return this.style.removeLayer(g),this._update(!0)}getLayer(g){return this.style.getLayer(g)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(g,t,l){return this.style.setLayerZoomRange(g,t,l),this._update(!0)}setFilter(g,t,l={}){return this.style.setFilter(g,t,l),this._update(!0)}getFilter(g){return this.style.getFilter(g)}setPaintProperty(g,t,l,d={}){return this.style.setPaintProperty(g,t,l,d),this._update(!0)}getPaintProperty(g,t){return this.style.getPaintProperty(g,t)}setLayoutProperty(g,t,l,d={}){return this.style.setLayoutProperty(g,t,l,d),this._update(!0)}getLayoutProperty(g,t){return this.style.getLayoutProperty(g,t)}setGlyphs(g,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(g,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(g,t,l={}){return this._lazyInitEmptyStyle(),this.style.addSprite(g,t,l,d=>{d||this._update(!0)}),this}removeSprite(g){return this._lazyInitEmptyStyle(),this.style.removeSprite(g),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(g,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(g,t,l=>{l||this._update(!0)}),this}setLight(g,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(g,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(g){return this._lazyInitEmptyStyle(),this.style.setSky(g),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(g,t){return this.style.setFeatureState(g,t),this._update()}removeFeatureState(g,t){return this.style.removeFeatureState(g,t),this._update()}getFeatureState(g){return this.style.getFeatureState(g)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let g=0,t=0;return this._container&&(g=this._container.clientWidth||400,t=this._container.clientHeight||300),[g,t]}_setupContainer(){let g=this._container;g.classList.add("maplibregl-map");let t=this._canvasContainer=C.create("div","maplibregl-canvas-container",g);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=C.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let l=this._containerDimensions(),d=this._getClampedPixelRatio(l[0],l[1]);this._resizeCanvas(l[0],l[1],d);let p=this._controlContainer=C.create("div","maplibregl-control-container",g),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(S=>{m[S]=C.create("div",`maplibregl-ctrl-${S} `,p)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(g,t,l){this._canvas.width=Math.floor(l*g),this._canvas.height=Math.floor(l*t),this._canvas.style.width=`${g}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let g={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},t=null;this._canvas.addEventListener("webglcontextcreationerror",d=>{t={requestedAttributes:g},d&&(t.statusMessage=d.statusMessage,t.type=d.type)},{once:!0});let l=this._canvas.getContext("webgl2",g)||this._canvas.getContext("webgl",g);if(!l){let d="Failed to initialize WebGL";throw t?(t.message=d,new Error(JSON.stringify(t))):new Error(d)}this.painter=new Bl(l,this.transform),k.testSupport(l)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(g){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||g,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(g){return this._update(),this._renderTaskQueue.add(g)}_cancelRenderFrame(g){this._renderTaskQueue.remove(g)}_render(g){let t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(g),this._removed)return;let l=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let p=this.transform.zoom,m=T.now();this.style.zoomHistory.update(p,m);let S=new s.z(p,{now:m,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=S.crossFadingFactor();E===1&&E===this._crossFadingFactor||(l=!0,this._crossFadingFactor=E),this.style.update(S)}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 s.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,s.bf.mark(s.bg.load),this.fire(new s.k("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new s.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,s.bf.mark(s.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var g;this._hash&&this._hash.remove();for(let l of this._controls)l.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),fe.removeThrottleControl(this._imageQueueHandle),(g=this._resizeObserver)===null||g===void 0||g.disconnect();let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),C.remove(this._canvasContainer),C.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),s.bf.clearMetrics(),this._removed=!0,this.fire(new s.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,T.frameAsync(this._frameRequest).then(g=>{s.bf.frame(g),this._frameRequest=null,this._render(g)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(g){this._showTileBoundaries!==g&&(this._showTileBoundaries=g,this._update())}get showPadding(){return!!this._showPadding}set showPadding(g){this._showPadding!==g&&(this._showPadding=g,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(g){this._showCollisionBoxes!==g&&(this._showCollisionBoxes=g,g?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(g){this._showOverdrawInspector!==g&&(this._showOverdrawInspector=g,this._update())}get repaint(){return!!this._repaint}set repaint(g){this._repaint!==g&&(this._repaint=g,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(g){this._vertices=g,this._update()}get version(){return Rd}getCameraTargetElevation(){return this.transform.elevation}},c.MapMouseEvent=Yi,c.MapTouchEvent=ao,c.MapWheelEvent=Id,c.Marker=Hl,c.NavigationControl=class{constructor(g){this._updateZoomButtons=()=>{let t=this._map.getZoom(),l=t===this._map.getMaxZoom(),d=t===this._map.getMinZoom();this._zoomInButton.disabled=l,this._zoomOutButton.disabled=d,this._zoomInButton.setAttribute("aria-disabled",l.toString()),this._zoomOutButton.setAttribute("aria-disabled",d.toString())},this._rotateCompassArrow=()=>{let 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,l)=>{let d=this._map._getUIString(`NavigationControl.${l}`);t.title=d,t.setAttribute("aria-label",d)},this.options=s.e({},jf,g),this._container=C.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})),C.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})),C.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=C.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(g){return this._map=g,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 Gf(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){C.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(g,t){let l=C.create("button",g,this._container);return l.type="button",l.addEventListener("click",t),l}},c.Popup=class extends s.E{constructor(g){super(),this.remove=()=>(this._content&&C.remove(this._content),this._container&&(C.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 s.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 l;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=C.create("div","maplibregl-popup",this._map.getContainer()),this._tip=C.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let E of this.options.className.split(" "))this._container.classList.add(E);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),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?ni(this._lngLat,this._flatPos,this._map.transform):(l=this._lngLat)===null||l===void 0?void 0:l.wrap(),this._trackPointer&&!t)return;let d=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 p=this.options.anchor,m=Yl(this.options.offset);if(!p){let E=this._container.offsetWidth,M=this._container.offsetHeight,R;R=d.y+m.bottom.y<M?["top"]:d.y>this._map.transform.height-M?["bottom"]:[],d.x<E/2?R.push("left"):d.x>this._map.transform.width-E/2&&R.push("right"),p=R.length===0?"bottom":R.join("-")}let S=d.add(m[p]);this.options.subpixelPositioning||(S=S.round()),C.setTransform(this._container,`${Ko[p]} translate(${S.x}px,${S.y}px)`),Xl(this._container,p,"popup")},this._onClose=()=>{this.remove()},this.options=s.e(Object.create(ut),g)}addTo(g){return this._map&&this.remove(),this._map=g,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 s.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(g){return this._lngLat=s.N.convert(g),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(g){return this.setDOMContent(document.createTextNode(g))}setHTML(g){let t=document.createDocumentFragment(),l=document.createElement("body"),d;for(l.innerHTML=g;d=l.firstChild,d;)t.appendChild(d);return this.setDOMContent(t)}getMaxWidth(){var g;return(g=this._container)===null||g===void 0?void 0:g.style.maxWidth}setMaxWidth(g){return this.options.maxWidth=g,this._update(),this}setDOMContent(g){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=C.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(g),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(g){return this._container&&this._container.classList.add(g),this}removeClassName(g){return this._container&&this._container.classList.remove(g),this}setOffset(g){return this.options.offset=g,this._update(),this}toggleClassName(g){if(this._container)return this._container.classList.toggle(g)}setSubpixelPositioning(g){this.options.subpixelPositioning=g}_createCloseButton(){this.options.closeButton&&(this._closeButton=C.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let g=this._container.querySelector(Kl);g&&g.focus()}},c.RasterDEMTileSource=Zt,c.RasterTileSource=bt,c.ScaleControl=class{constructor(g){this._onMove=()=>{$a(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,$a(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ts),g)}getDefaultPosition(){return"bottom-left"}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-scale",g.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){C.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},c.ScrollZoomHandler=Bn,c.Style=wl,c.TerrainControl=class{constructor(g){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=g}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=C.create("button","maplibregl-ctrl-terrain",this._container),C.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(){C.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},c.TwoFingersTouchPitchHandler=$o,c.TwoFingersTouchRotateHandler=Sh,c.TwoFingersTouchZoomHandler=bh,c.TwoFingersTouchZoomRotateHandler=Ch,c.VectorTileSource=pr,c.VideoSource=an,c.addSourceType=(g,t)=>s._(void 0,void 0,void 0,function*(){if(kn(g))throw new Error(`A source type called "${g}" already exists.`);((l,d)=>{Yn[l]=d})(g,t)}),c.clearPrewarmedResources=function(){let g=ci;g&&(g.isPreloaded()&&g.numActive()===1?(g.release($t),ci=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()"))},c.getMaxParallelImageRequests=function(){return s.a.MAX_PARALLEL_IMAGE_REQUESTS},c.getRTLTextPluginStatus=function(){return mr().getRTLTextPluginStatus()},c.getVersion=function(){return kh},c.getWorkerCount=function(){return fi.workerCount},c.getWorkerUrl=function(){return s.a.WORKER_URL},c.importScriptInWorkers=function(g){return rn().broadcast("IS",g)},c.prewarm=function(){ur().acquire($t)},c.setMaxParallelImageRequests=function(g){s.a.MAX_PARALLEL_IMAGE_REQUESTS=g},c.setRTLTextPlugin=function(g,t){return mr().setRTLTextPlugin(g,t)},c.setWorkerCount=function(g){fi.workerCount=g},c.setWorkerUrl=function(g){s.a.WORKER_URL=g}});var a=h;return a})});var _l=ip((B4,K1)=>{var EE="Expected a function",X1=NaN,TE="[object Symbol]",ME=/^\s+|\s+$/g,PE=/^[-+]0x[0-9a-f]+$/i,AE=/^0b[01]+$/i,RE=/^0o[0-7]+$/i,kE=parseInt,LE=typeof global=="object"&&global&&global.Object===Object&&global,DE=typeof self=="object"&&self&&self.Object===Object&&self,FE=LE||DE||Function("return this")(),zE=Object.prototype,OE=zE.toString,BE=Math.max,NE=Math.min,z_=function(){return FE.Date.now()};function VE(h,e,r){var a,c,s,y,v,b,T=0,C=!1,k=!1,O=!0;if(typeof h!="function")throw new TypeError(EE);e=H1(e)||0,O_(r)&&(C=!!r.leading,k="maxWait"in r,s=k?BE(H1(r.maxWait)||0,e):s,O="trailing"in r?!!r.trailing:O);function G(Ee){var Ge=a,Be=c;return a=c=void 0,T=Ee,y=h.apply(Be,Ge),y}function J(Ee){return T=Ee,v=setTimeout(fe,e),C?G(Ee):y}function le(Ee){var Ge=Ee-b,Be=Ee-T,Ae=e-Ge;return k?NE(Ae,s-Be):Ae}function he(Ee){var Ge=Ee-b,Be=Ee-T;return b===void 0||Ge>=e||Ge<0||k&&Be>=s}function fe(){var Ee=z_();if(he(Ee))return ye(Ee);v=setTimeout(fe,le(Ee))}function ye(Ee){return v=void 0,O&&a?G(Ee):(a=c=void 0,y)}function we(){v!==void 0&&clearTimeout(v),T=0,a=b=c=v=void 0}function Ie(){return v===void 0?y:ye(z_())}function Pe(){var Ee=z_(),Ge=he(Ee);if(a=arguments,c=this,b=Ee,Ge){if(v===void 0)return J(b);if(k)return v=setTimeout(fe,e),G(b)}return v===void 0&&(v=setTimeout(fe,e)),y}return Pe.cancel=we,Pe.flush=Ie,Pe}function O_(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function jE(h){return!!h&&typeof h=="object"}function GE(h){return typeof h=="symbol"||jE(h)&&OE.call(h)==TE}function H1(h){if(typeof h=="number")return h;if(GE(h))return X1;if(O_(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=O_(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(ME,"");var r=AE.test(h);return r||RE.test(h)?kE(h.slice(2),r?2:8):PE.test(h)?X1:+h}K1.exports=VE});var ow=ip((lN,sw)=>{var nw="Expected a function",iw=NaN,$E="[object Symbol]",WE=/^\s+|\s+$/g,ZE=/^[-+]0x[0-9a-f]+$/i,XE=/^0b[01]+$/i,HE=/^0o[0-7]+$/i,KE=parseInt,YE=typeof global=="object"&&global&&global.Object===Object&&global,JE=typeof self=="object"&&self&&self.Object===Object&&self,QE=YE||JE||Function("return this")(),eT=Object.prototype,tT=eT.toString,iT=Math.max,rT=Math.min,U_=function(){return QE.Date.now()};function nT(h,e,r){var a,c,s,y,v,b,T=0,C=!1,k=!1,O=!0;if(typeof h!="function")throw new TypeError(nw);e=rw(e)||0,lf(r)&&(C=!!r.leading,k="maxWait"in r,s=k?iT(rw(r.maxWait)||0,e):s,O="trailing"in r?!!r.trailing:O);function G(Ee){var Ge=a,Be=c;return a=c=void 0,T=Ee,y=h.apply(Be,Ge),y}function J(Ee){return T=Ee,v=setTimeout(fe,e),C?G(Ee):y}function le(Ee){var Ge=Ee-b,Be=Ee-T,Ae=e-Ge;return k?rT(Ae,s-Be):Ae}function he(Ee){var Ge=Ee-b,Be=Ee-T;return b===void 0||Ge>=e||Ge<0||k&&Be>=s}function fe(){var Ee=U_();if(he(Ee))return ye(Ee);v=setTimeout(fe,le(Ee))}function ye(Ee){return v=void 0,O&&a?G(Ee):(a=c=void 0,y)}function we(){v!==void 0&&clearTimeout(v),T=0,a=b=c=v=void 0}function Ie(){return v===void 0?y:ye(U_())}function Pe(){var Ee=U_(),Ge=he(Ee);if(a=arguments,c=this,b=Ee,Ge){if(v===void 0)return J(b);if(k)return v=setTimeout(fe,e),G(b)}return v===void 0&&(v=setTimeout(fe,e)),y}return Pe.cancel=we,Pe.flush=Ie,Pe}function sT(h,e,r){var a=!0,c=!0;if(typeof h!="function")throw new TypeError(nw);return lf(r)&&(a="leading"in r?!!r.leading:a,c="trailing"in r?!!r.trailing:c),nT(h,e,{leading:a,maxWait:e,trailing:c})}function lf(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function oT(h){return!!h&&typeof h=="object"}function aT(h){return typeof h=="symbol"||oT(h)&&tT.call(h)==$E}function rw(h){if(typeof h=="number")return h;if(aT(h))return iw;if(lf(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=lf(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(WE,"");var r=XE.test(h);return r||HE.test(h)?KE(h.slice(2),r?2:8):ZE.test(h)?iw:+h}sw.exports=sT});var df={};Lm(df,{CopyrightControl:()=>_b,Layer:()=>uf,MaplibreLayer:()=>Q1,MaplibreStyleLayer:()=>tw,RealtimeAPI:()=>Qh,RealtimeLayer:()=>hw,RealtimeModes:()=>$i,RoutingAPI:()=>eu,RoutingControl:()=>G1,StopFinderControl:()=>$1,StopsAPI:()=>tu,VECTOR_TILE_FEATURE_PROPERTY:()=>Pc,VectorLayer:()=>pw,compareDepartures:()=>Iu,createCanvas:()=>_s,createRealtimeFilters:()=>Km,debounceDeparturesMessages:()=>$g,debounceWebsocketMessages:()=>Jh,fullTrajectoryDelayStyle:()=>aw,fullTrajectoryStyle:()=>hf,getCircleCanvas:()=>Wm,getDelayBgCanvas:()=>qm,getDelayTextCanvas:()=>$m,getFeatureInfoAtCoordinate:()=>fw,getHoursAndMinutes:()=>Hx,getLayersAsFlatArray:()=>ru,getMapGlCopyrights:()=>iu,getTextCanvas:()=>Zm,getUTCDateString:()=>Zx,getUTCTimeString:()=>Xx,getUrlWithParams:()=>el,getVehiclePosition:()=>wu,pad:()=>sp,realtimeConfig:()=>Mc,realtimeDefaultStyle:()=>tl,realtimeDelayStyle:()=>Xm,realtimeSimpleStyle:()=>Hm,removeDuplicate:()=>il,renderTrajectories:()=>Su,routingStyle:()=>cw,sortAndFilterDepartures:()=>Cu,sortByDelay:()=>Ym});var k2=(h,e,r=100)=>{let a={},c={},s=[];return y=>{let{source:v,content:b}=y;a[v]&&window.clearTimeout(a[v]),e?c[e(b)]=b:s.push(b),a[v]=window.setTimeout(()=>{let T=e?Object.values(c):s;h(T)},r)}},Jh=k2;var L2=(h,e)=>h===e.SCHEMATIC?"_schematic":"",ys=L2;var Dm=class h{constructor(){this.defineProperties()}static getRequestString(e,r={}){let a=`${e} ${r.channel}`;return a+=r.args?` ${r.args}`:"",a+=r.id?` ${r.id}`:"",a.trim()}addEvents(e,r){this.websocket&&(this.websocket.addEventListener("message",e),r&&(this.websocket.addEventListener("error",r),this.websocket.addEventListener("close",r)))}close(){this.websocket&&(this.open||this.connecting)&&(this.websocket.onclose=()=>{},this.websocket.close(),this.messagesOnOpen=[])}connect(e,r=()=>{}){if(!e){this.websocket?.close();return}if(this.websocket){if(this.websocket.url===e&&(this.open||this.connecting))return;this.websocket.url!==e&&(this.open||this.connecting)&&this.websocket.close()}this.websocket=new WebSocket(e),this.open?(r(),this.subscribePreviousSubscriptions()):this.websocket.addEventListener("open",()=>{r(),this.subscribePreviousSubscriptions()})}defineProperties(){Object.defineProperties(this,{closed:{get:()=>!this.websocket||this.websocket.readyState===this.websocket.CLOSED},closing:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CLOSING)},connecting:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CONNECTING)},messagesOnOpen:{value:[],writable:!0},open:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.OPEN)},subscribed:{value:{},writable:!0},subscriptions:{value:[],writable:!0}})}get(e,r,a){let c=h.getRequestString("GET",e);this.send(c);let s=C=>(...k)=>{C(...k);let O=this.requests.findIndex(le=>c===le.requestString&&r===le.cb),{onErrorCb:G,onMessageCb:J}=this.requests[O];this.removeEvents(J,G),this.requests.splice(O,1)},{onErrorCb:y,onMessageCb:v}=this.listen(e,s(r),a&&s(a));this.requests||(this.requests=[]);let b=this.requests.findIndex(C=>c===C.requestString&&r===C.cb),T={cb:r,errorCb:a,onErrorCb:y,onMessageCb:v,params:e,requestString:c};b>-1?this.requests[b]=T:this.requests.push(T)}listen(e,r,a){this.unlisten(e,r);let c=s=>{let y;try{y=JSON.parse(s.data)}catch(T){console.error("WebSocket: unable to parse JSON data",T,s.data);return}let v=e.channel;v+=e.args?` ${e.args}`:"";let b;y.source==="buffer"?b=y.content:b=[y],b.forEach(T=>{T?.source===v&&(!e.id||e.id===y.client_reference)&&r(T)})};return this.addEvents(c,a),{onErrorCb:a,onMessageCb:c}}removeEvents(e,r){this.websocket&&(this.websocket.removeEventListener("message",e),r&&(this.websocket.removeEventListener("error",r),this.websocket.removeEventListener("close",r)))}send(e){if(!this.websocket||this.closed||this.closing)return;let r=()=>{this.websocket?.send(e)};this.open?this.messagesOnOpen.includes(e)||r():this.messagesOnOpen.includes(e)||(this.messagesOnOpen.push(e),this.websocket.addEventListener("open",()=>{this.messagesOnOpen=[],r()}),this.websocket.addEventListener("close",()=>{this.messagesOnOpen=[]}))}subscribe(e,r,a,c=!1){let{onErrorCb:s,onMessageCb:y}=this.listen(e,r,a),v=h.getRequestString("",e),b=this.subscriptions.findIndex(C=>e.channel===C.params.channel&&r===C.cb),T={cb:r,errorCb:a,onErrorCb:s,onMessageCb:y,params:e,quiet:c};b>-1?this.subscriptions[b]=T:this.subscriptions.push(T),this.subscribed[v]||(T.quiet||(this.send(`GET ${v}`),this.send(`SUB ${v}`)),this.subscribed[v]=!0)}subscribePreviousSubscriptions(){Object.keys(this.subscribed).forEach(e=>{this.subscribed[e]=!1}),[...this.subscriptions].forEach(e=>{this.subscribe(e.params,e.cb,e.errorCb,e.quiet)})}unlisten(e,r){[...this.subscriptions||[],...this.requests||[]].filter(a=>a.params.channel===e.channel&&(!r||a.cb===r)).forEach(({onErrorCb:a,onMessageCb:c})=>{this.removeEvents(c,a)})}unsubscribe(e,r){let a=this.subscriptions.filter(c=>c.params.channel===e&&(!r||c.cb===r));a.forEach(({onErrorCb:c,onMessageCb:s})=>{this.removeEvents(s,c)}),this.subscriptions=this.subscriptions.filter(c=>c.params.channel!==e||r&&c.cb!==r),e&&this.subscribed[e]&&!this.subscriptions.find(c=>c.params.channel===e)&&a.find(c=>!c.quiet)&&(this.send(`DEL ${e}`),this.subscribed[e]=!1)}},$x=Dm;var $i={RAW:"raw",SCHEMATIC:"schematic",TOPOGRAPHIC:"topographic"},Fm=class{constructor(e={}){this.version="2";let r=e;typeof e=="string"&&(r={url:e});let{apiKey:a}=r,{url:c}=r,s=new $x,y="";a&&!c?.includes("key=")&&(y=`?key=${a}`),this._url=(c||"wss://api.geops.io/tracker-ws/v1/")+y,this._buffer=r.buffer||[100,100],this._bbox=r.bbox,this.version=r.version||"2",this.pingIntervalMs=r.pingIntervalMs||1e4,this.reconnectTimeoutMs=r.reconnectTimeoutMs||100,this.wsApi=s}get bbox(){return this._bbox}set bbox(e){JSON.stringify(e)!==JSON.stringify(this._bbox)&&(this._bbox=e,this.wsApi&&this._bbox&&this.wsApi.send(`BBOX ${this._bbox.join(" ")}`))}get buffer(){return this._buffer}set buffer(e){JSON.stringify(e)!==JSON.stringify(this._buffer)&&(this._buffer=e,this.wsApi&&this._buffer&&this.wsApi.send(`BUFFER ${this._buffer.join(" ")}`))}get url(){return this._url}set url(e){this._url!==e&&(this._url=e,(this.wsApi.open||this.wsApi.connecting)&&this.open())}close(){this.wsApi.close()}get(e){let r=e;return typeof e=="string"&&(r={channel:e}),new Promise((a,c)=>{this.wsApi.get(r,a,c)})}getFullTrajectory(e,r,a){let c="";this.version==="1"&&(c=ys(r,$i));let s=[`full_trajectory${c}`];return e&&s.push(e),(!r||r===$i.TOPOGRAPHIC)&&a&&s.push(`gen${a}`),this.get(s.join("_"))}getStation(e,r){let a={args:e,channel:`station${ys(r,$i)}`};return this.get(a)}getStations(e,r=100){return new Promise(a=>{this.get(`station${ys(e,$i)}`).then(Jh(a,void 0,r))})}getStopSequence(e){return this.get(`stopsequence_${e}`)}getTrajectory(e,r){return this.get(`partial_trajectory${ys(r,$i)}_${e}`)}onClose(){window.clearTimeout(this.pingInterval),window.clearTimeout(this.reconnectTimeout),this.reconnectTimeoutMs&&(this.reconnectTimeout=window.setTimeout(()=>this.open(),this.reconnectTimeoutMs))}onOpen(){this.bbox&&this.wsApi.send(`BBOX ${this.bbox.join(" ")}`),this.buffer&&this.wsApi.send(`BUFFER ${this.buffer.join(" ")}`),this.pingIntervalMs&&(window.clearInterval(this.pingInterval),this.pingInterval=window.setInterval(()=>{this.wsApi.send("PING")},this.pingIntervalMs))}open(){this.wsApi.connect(this.url,this.onOpen.bind(this)),this.wsApi.websocket&&(this.wsApi.websocket.onclose=()=>{this.onClose()})}reset(){this.wsApi.send("RESET")}subscribe(e,r,a=()=>{},c=!1){!e||!r||this.wsApi.subscribe({channel:e},r,a,c)}subscribeDeletedVehicles(e,r,a=()=>{},c=!1){this.unsubscribeDeletedVehicles(r);let s="";this.version==="1"&&(s=ys(e,$i)),this.subscribe(`deleted_vehicles${s}`,r,a,c)}subscribeDepartures(e,r,a=()=>{},c=!1){this.subscribeTimetable(e,r,a,c)}subscribeDisruptions(e,r,a=()=>{},c=!1){this.subscribeNewsticker(e,r,a,c)}subscribeExtraGeoms(e,r=()=>{},a=!1){this.subscribe("extra_geoms",e,r,a)}subscribeFullTrajectory(e,r,a,c=()=>{},s=!1){let y="";this.version==="1"&&(y=ys(r,$i)),this.subscribe(`full_trajectory${y}_${e}`,a,c,s)}subscribeHealthCheck(e,r=()=>{},a=!1){this.subscribe("healthcheck",e,r,a)}subscribeNewsticker(e,r,a=()=>{},c=!1){this.subscribe(`${e}_newsticker`,r,a,c)}subscribeStations(e,r,a=()=>{},c=!1){this.subscribe(`station${ys(e,$i)}`,r,a,c)}subscribeStopSequence(e,r,a=()=>{},c=!1){this.subscribe(`stopsequence_${e}`,r,a,c)}subscribeTimetable(e,r,a=()=>{},c=!1){this.subscribe(`timetable_${e}`,r,a,c)}subscribeTrajectory(e,r,a=()=>{},c=!1){this.unsubscribeTrajectory(r);let s="";this.version==="1"&&(s=ys(e,$i)),this.subscribe(`trajectory${s}`,r,a,c)}unsubscribe(e,r="",a){let c=ys($i.SCHEMATIC,$i),s=ys($i.TOPOGRAPHIC,$i);this.wsApi.unsubscribe(`${e}${c}${r||""}`,a),this.wsApi.unsubscribe(`${e}${s}${r||""}`,a)}unsubscribeDeletedVehicles(e){this.unsubscribe("deleted_vehicles","",e)}unsubscribeDepartures(e,r){this.unsubscribeTimetable(e,r)}unsubscribeDisruptions(e,r){this.unsubscribeNewsticker(e,r)}unsubscribeExtraGeoms(e){this.unsubscribe("extra_geoms","",e)}unsubscribeFullTrajectory(e,r){this.unsubscribe("full_trajectory",`_${e}`,r)}unsubscribeHealthCheck(e){this.unsubscribe("healthcheck","",e)}unsubscribeNewsticker(e,r){this.unsubscribe(`${e}_newsticker`,"",r)}unsubscribeStations(e){this.unsubscribe("station","",e)}unsubscribeStopSequence(e,r){this.unsubscribe("stopsequence",`_${e}`,r)}unsubscribeTimetable(e,r){this.unsubscribe(`timetable_${e}`,"",r)}unsubscribeTrajectory(e){this.unsubscribe("trajectory","",e)}},Qh=Fm;var D2=(h,e)=>{let r=new URL(h);return Object.entries(e||{}).forEach(([c,s])=>{s!=null&&r.searchParams.set(c,s)}),r},el=D2;var zm=class{constructor(e){this.url=e.url,this.apiKey=e.apiKey}async fetch(e,r,a){if(!this.url)throw new Error(`No url defined for request to ${this.url}/${e}`);if(!this.url&&!this.apiKey&&!this.url.includes("key="))throw new Error(`No apiKey defined for request to ${this.url}`);let c=r||{},s=el(`${this.url}${e||""}`,{key:this.apiKey,...c}),v=await(await fetch(s.toString(),a)).json();if(v.error)throw new Error(v.error);return v}},rp=zm;var Om=class extends rp{constructor(e={}){super({url:"https://api.geops.io/routing/v1/",...e})}route(e,r){return this.fetch("",e,r)}},eu=Om;var Bm=class extends rp{constructor(e={}){super({...e,url:e.url||"https://api.geops.io/stops/v1/"})}search(e,r){return this.fetch("",e,r)}},tu=Bm;var F2=(h,e)=>{let r=null;return typeof window>"u"?null:(typeof document<"u"&&document?.createElement?(r=document.createElement("canvas"),r.width=h,r.height=e):OffscreenCanvas?r=new OffscreenCanvas(h,e):console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"),r)},_s=F2;var Nm={},qm=(h,e,r)=>{let a=`${h}, ${e}, ${r}`;if(!Nm[a]){let c=_s(h*2,h*2);if(c){let s=c.getContext("2d");if(!s)return null;s.beginPath(),s.arc(h,h,e,0,2*Math.PI,!1),s.fillStyle=r,s.filter="blur(1px)",s.fill(),Nm[a]=c}}return Nm[a]},Vm={},$m=(h,e,r,a,c="#000",s=1)=>{let y=`${h}, ${r}, ${a}, ${c}, ${s}`;if(!Vm[y]){let v=_s(Math.ceil(h.length*e),Math.ceil(e+8*s));if(v){let b=v.getContext("2d");if(!b)return null;b.font=r,b.textAlign="left",b.textBaseline="middle",b.font=r,b.fillStyle=a,b.strokeStyle=c,b.lineWidth=1.5*s,b.strokeText(h,0,e),b.fillText(h,0,e),Vm[y]=v}}return Vm[y]},jm={},Wm=(h,e,r,a,c,s)=>{let y=`${h}, ${e}, ${r}, ${a}, ${c}, ${s}`;if(!jm[y]){let v=_s(h*2,h*2);if(v){let b=v.getContext("2d");if(!b)return null;b.fillStyle=r,a&&(b.lineWidth=1*s,b.strokeStyle="#000000"),b.beginPath(),b.arc(h,h,e,0,2*Math.PI,!1),b.fill(),c&&b.setLineDash([5,3]),a&&b.stroke(),jm[y]=v}}return jm[y]},Gm={},Zm=(h,e,r,a,c,s,y,v)=>{let b=`${h}, ${e}, ${r}, ${a},${c}, ${s}, ${y}`;if(!Gm[b]){let T=_s(e*2,e*2);if(T){let C=T.getContext("2d");if(!C)return null;s&&(C.save(),C.textBaseline="middle",C.textAlign="center",C.font=v(r+2,h),C.strokeStyle=c,C.strokeText(h,e,e),C.restore()),C.textBaseline="middle",C.textAlign="center",C.fillStyle=a,C.font=v(r,h),C.strokeStyle=c,C.strokeText(h,e,e),C.fillText(h,e,e),Gm[b]=T}}return Gm[b]},Um={},z2=(h,e,r)=>{let{delayDisplay:a=3e5,delayOutlineColor:c="#000",getBgColor:s=()=>"#000",getDelayColor:y=()=>"#000",getDelayFont:v=$t=>`bold ${$t}px arial, sans-serif`,getDelayText:b=()=>null,getMaxRadiusForStrokeAndDelay:T=()=>7,getMaxRadiusForText:C=()=>10,getRadius:k=()=>0,getText:O=$t=>$t,getTextColor:G=()=>"#000",getTextFont:J=$t=>`bold ${$t}px arial, sans-serif`,getTextSize:le=()=>14,hoverVehicleId:he,selectedVehicleId:fe,useDelayStyle:ye}=r,{pixelRatio:we=1,zoom:Ie}=e,{type:Pe}=h.properties,{delay:Ee,line:Ge,operator_provides_realtime_journey:Be,state:Ae,train_id:st}=h.properties,{color:ct,name:rt,text_color:xt}=Ge||{};rt=O(rt);let Rt=Ae==="JOURNEY_CANCELLED";Pe||(Pe="Rail"),rt||(rt="I"),xt||(xt="#000000"),ct&&!ct.startsWith("#")&&(ct=`#${ct}`),xt.startsWith("#")||(xt=`#${xt}`);let at=Math.min(Math.floor(Ie||1),16),gt=!!(he&&he===st),ot=!!(fe&&fe===st),pt=k(Pe,at)*we,Pt=pt>=T()*we;(gt||ot)&&(pt=Pt?pt+5*we:14*we);let kt=pt>C()*we,Lt=`${pt}${gt||ot}`;if(ye?(Lt+=`${Be}${Ee}`,Pt&&(Lt+=`${Rt}`)):(Lt+=`${ct||Pe}`,Pt&&(Lt+=`${Rt}${Ee}`)),kt&&(Lt+=`${rt}${xt}`),!Um[Lt]){if(pt===0)return null;let $t=1*we,fi=pt+2*we,$e=pt*2,ci=fi*2+$t*2,di=ci/2,ur=null;Pt&&Ee!==null&&(ur=qm(di,fi,y(Ee,Rt)));let dr=null,rn=0;if(Pt&&(gt||(Ee||0)>=a||Rt)){rn=Math.max(Rt?19:14,Math.min(Rt?19:17,pt*1.2))*we;let bt=b(Ee,Rt);bt&&(dr=$m(bt,rn,v(rn,bt),y(Ee,Rt,!0),c,we))}let ji;ye?ji=y(Ee,Rt):ji=ct||s(Pe);let Pn=Wm(di,pt,ji,Pt||gt||ot,!!Pt&&!!ye&&Ee===null&&Be==="yes",we),ve=ci+(dr?.width||0)*2,pr=_s(ve,ci);if(pr){let bt=pr.getContext("2d");if(!bt)return null;let Zt=dr?.width||0;ur&&bt.drawImage(ur,Zt,0),Pn&&bt.drawImage(Pn,Zt,0);let Rn=null;if(kt){let on=Math.max(pt,10),Ar=le(bt,$e,rt,on,J),an=ye?"#000000":xt||G(Pe);Rn=Zm(rt,di,Ar,an,ji,!!ye&&Ee===null&&Be==="yes",we,J)}Rn&&bt.drawImage(Rn,Zt,0),dr&&bt.drawImage(dr,Zt+Math.ceil(di+fi)+$t,Math.ceil(di-rn)),Um[Lt]=pr}}return Um[Lt]},tl=z2;var O2=(h,e,r)=>tl(h,e,{...r,useDelayStyle:!0}),Xm=O2;var np,B2=()=>{if(!np){np=_s(15,15);let h=np?.getContext("2d");h&&(h.arc(8,8,5,0,2*Math.PI,!1),h.fillStyle="#8ED6FF",h.fill(),h.lineWidth=3,h.strokeStyle="black",h.stroke(),h.lineWidth=3)}return np},Hm=B2;var N2=h=>{let e=h.filter(s=>s!=null&&s.trim&&s.trim()),r=e.map(s=>s.toLowerCase());return[...new Set(r)].map(s=>e.find(y=>y.toLowerCase()===s))},il=N2;var V2=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,a=[];return Object.values(r).forEach(c=>{if(c.used){let s=c.getSource(),y=s.attribution||s.options?.attribution;y&&(a=a.concat(y.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),il(a)},iu=V2;var j2=(h,e,r,a)=>{let c=[];if(!h&&!e&&!r&&!a)return null;if(a){let s=typeof a=="string"?[a]:a,y=v=>{let b=v.properties.name||v.properties.line&&v.properties.line.name||"";return b?s.some(T=>new RegExp(T,"i").test(b)):!1};c.push(y)}if(h){let y=(typeof h=="string"?h.split(","):h).map(b=>b.replace(/\s+/g,"").toUpperCase()),v=b=>{let{line:T,name:C}=b.properties,k=(C||T&&T.name||"").toUpperCase();return k?y.includes(k):!1};c.push(v)}if(e){let y=(typeof e=="string"?e.split(","):e).map(b=>parseInt(b,10)),v=b=>{let T=b.properties.route_identifier||b.properties.routeIdentifier||"",C=parseInt(T.split(".")[0],10);return y.includes(C)};c.push(v)}if(r){let s=typeof r=="string"?[r]:r,y=v=>s.some(b=>{let T=v.properties.operator||v.properties.tenant||"";return new RegExp(b,"i").test(T)});c.push(y)}return c.length?s=>{for(let y=0;y<c.length;y+=1)if(!c[y](s))return!1;return!0}:null},Km=j2;var Wx=h=>{let e=h;Array.isArray(e)||(e=[h]);let r=[];return e.forEach(a=>{r.push(a);let c=a.children||a.get("children")||a.getLayers?.()?.getArray();r=r.concat(Wx(c||[]))}),r},ru=Wx;var Zx=(h=new Date)=>{let e=(h.getUTCMonth()+1).toString();e=e.length===1?`0${e}`:e;let r=h.getUTCDate().toString();return r=r.length===1?`0${r}`:r,[h.getUTCFullYear(),e,r].join("")},Xx=h=>[h.getUTCHours(),h.getUTCMinutes(),`${h.getUTCSeconds()}.${h.getUTCMilliseconds()}`].join(":"),sp=h=>h<10?`0${h}`:`${h}`,Hx=h=>{if(!h||h<=0)return"";let e=new Date(h);return`${sp(e.getHours())}:${sp(e.getMinutes())}`};var G2=(h,e)=>{let r=h.properties,a=e.properties;return r.delay===null&&a.delay!==null?1:a.delay===null&&r.delay!==null?-1:r.cancelled&&!a.cancelled?a.delay<18e4?-1:1:a.cancelled&&!r.cancelled?r.delay<18e4?1:-1:a.delay-r.delay},Ym=G2;function ui(h,e){if(!h)throw new Error(e)}var IM=new Array(6);function sr(){return[1,0,0,1,0,0]}function Yx(h,e){return h[0]=e[0],h[1]=e[1],h[2]=e[2],h[3]=e[3],h[4]=e[4],h[5]=e[5],h}function br(h,e){let r=e[0],a=e[1];return e[0]=h[0]*r+h[2]*a+h[4],e[1]=h[1]*r+h[3]*a+h[5],e}function Vr(h,e,r,a,c,s,y,v){let b=Math.sin(s),T=Math.cos(s);return h[0]=a*T,h[1]=c*b,h[2]=-a*b,h[3]=c*T,h[4]=y*a*T-v*a*b+e,h[5]=y*c*b+v*c*T+r,h}function Jx(h,e,r,a,c,s,y){return Jm(Vr(sr(),h,e,r,a,c,s,y))}function Qx(h,e){let r=U2(e);ui(r!==0,"Transformation matrix cannot be inverted");let a=e[0],c=e[1],s=e[2],y=e[3],v=e[4],b=e[5];return h[0]=y/r,h[1]=-c/r,h[2]=-s/r,h[3]=a/r,h[4]=(s*b-y*v)/r,h[5]=-(a*b-c*v)/r,h}function U2(h){return h[0]*h[3]-h[1]*h[2]}var Kx=[1e6,1e6,1e6,1e6,2,2];function Jm(h){return"matrix("+h.map((r,a)=>Math.round(r*Kx[a])/Kx[a]).join(", ")+")"}var Qm=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Si=Qm;var op={PROPERTYCHANGE:"propertychange"};var eg=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},ev=eg;function tv(h,e,r){let a,c;r=r||xs;let s=0,y=h.length,v=!1;for(;s<y;)a=s+(y-s>>1),c=+r(h[a],e),c<0?s=a+1:(y=a,v=!c);return v?s:~s}function xs(h,e){return h>e?1:h<e?-1:0}function iv(h,e){return h<e?1:h>e?-1:0}function ap(h,e,r){if(h[0]<=e)return 0;let a=h.length;if(e<=h[a-1])return a-1;if(typeof r=="function"){for(let c=1;c<a;++c){let s=h[c];if(s===e)return c;if(s<e)return r(e,h[c-1],s)>0?c-1:c}return a-1}if(r>0){for(let c=1;c<a;++c)if(h[c]<e)return c-1;return a-1}if(r<0){for(let c=1;c<a;++c)if(h[c]<=e)return c;return a-1}for(let c=1;c<a;++c){if(h[c]==e)return c;if(h[c]<e)return h[c-1]-e<e-h[c]?c-1:c}return a-1}function rv(h,e,r){for(;e<r;){let a=h[e];h[e]=h[r],h[r]=a,++e,--r}}function wr(h,e){let r=Array.isArray(e)?e:[e],a=r.length;for(let c=0;c<a;c++)h[h.length]=r[c]}function yn(h,e){let r=h.length;if(r!==e.length)return!1;for(let a=0;a<r;a++)if(h[a]!==e[a])return!1;return!0}function lp(){return!0}function vs(){}function cp(h){let e,r,a;return function(){let c=Array.prototype.slice.call(arguments);return(!r||this!==a||!yn(c,r))&&(a=this,r=c,e=h.apply(this,arguments)),e}}function mc(h){for(let e in h)delete h[e]}function Wn(h){let e;for(e in h)return!1;return!e}var tg=class extends ev{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,r){if(!e||!r)return;let a=this.listeners_||(this.listeners_={}),c=a[e]||(a[e]=[]);c.includes(r)||c.push(r)}dispatchEvent(e){let r=typeof e=="string",a=r?e:e.type,c=this.listeners_&&this.listeners_[a];if(!c)return;let s=r?new Si(e):e;s.target||(s.target=this.eventTarget_||this);let y=this.dispatching_||(this.dispatching_={}),v=this.pendingRemovals_||(this.pendingRemovals_={});a in y||(y[a]=0,v[a]=0),++y[a];let b;for(let T=0,C=c.length;T<C;++T)if("handleEvent"in c[T]?b=c[T].handleEvent(s):b=c[T].call(this,s),b===!1||s.propagationStopped){b=!1;break}if(--y[a]===0){let T=v[a];for(delete v[a];T--;)this.removeEventListener(a,vs);delete y[a]}return b}disposeInternal(){this.listeners_&&mc(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,r){if(!this.listeners_)return;let a=this.listeners_[e];if(!a)return;let c=a.indexOf(r);c!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(a[c]=vs,++this.pendingRemovals_[e]):(a.splice(c,1),a.length===0&&delete this.listeners_[e]))}},hp=tg;var pi={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function Sr(h,e,r,a,c){if(c){let y=r;r=function(){h.removeEventListener(e,r),y.apply(a??this,arguments)}}else a&&a!==h&&(r=r.bind(a));let s={target:h,type:e,listener:r};return h.addEventListener(e,r),s}function ig(h,e,r,a){return Sr(h,e,r,a,!0)}function jr(h){h&&h.target&&(h.target.removeEventListener(h.type,h.listener),mc(h))}var gc=class extends hp{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(pi.CHANGE)}getRevision(){return this.revision_}onInternal(e,r){if(Array.isArray(e)){let a=e.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Sr(this,e[s],r);return c}return Sr(this,e,r)}onceInternal(e,r){let a;if(Array.isArray(e)){let c=e.length;a=new Array(c);for(let s=0;s<c;++s)a[s]=ig(this,e[s],r)}else a=ig(this,e,r);return r.ol_key=a,a}unInternal(e,r){let a=r.ol_key;if(a)bs(a);else if(Array.isArray(e))for(let c=0,s=e.length;c<s;++c)this.removeEventListener(e[c],r);else this.removeEventListener(e,r)}};gc.prototype.on;gc.prototype.once;gc.prototype.un;function bs(h){if(Array.isArray(h))for(let e=0,r=h.length;e<r;++e)jr(h[e]);else jr(h)}var up=gc;function wt(){throw new Error("Unimplemented abstract method.")}var q2=0;function Vt(h){return h.ol_uid||(h.ol_uid=String(++q2))}var dp=class extends Si{constructor(e,r,a){super(e),this.key=r,this.oldValue=a}},rg=class extends up{constructor(e){super(),this.on,this.once,this.un,Vt(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let r;return this.values_&&this.values_.hasOwnProperty(e)&&(r=this.values_[e]),r}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,r){let a;a=`change:${e}`,this.hasListener(a)&&this.dispatchEvent(new dp(a,e,r)),a=op.PROPERTYCHANGE,this.hasListener(a)&&this.dispatchEvent(new dp(a,e,r))}addChangeListener(e,r){this.addEventListener(`change:${e}`,r)}removeChangeListener(e,r){this.removeEventListener(`change:${e}`,r)}set(e,r,a){let c=this.values_||(this.values_={});if(a)c[e]=r;else{let s=c[e];c[e]=r,s!==r&&this.notify(e,s)}}setProperties(e,r){for(let a in e)this.set(a,e[a],r)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,r){if(this.values_&&e in this.values_){let a=this.values_[e];delete this.values_[e],Wn(this.values_)&&(this.values_=null),r||this.notify(e,a)}}},or=rg;var Ni={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ss(h){let e=xn();for(let r=0,a=h.length;r<a;++r)ng(e,h[r]);return e}function $2(h,e,r){let a=Math.min.apply(null,h),c=Math.min.apply(null,e),s=Math.max.apply(null,h),y=Math.max.apply(null,e);return yo(a,c,s,y,r)}function os(h,e,r){return r?(r[0]=h[0]-e,r[1]=h[1]-e,r[2]=h[2]+e,r[3]=h[3]+e,r):[h[0]-e,h[1]-e,h[2]+e,h[3]+e]}function nv(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h.slice()}function _n(h,e,r){let a,c;return e<h[0]?a=h[0]-e:h[2]<e?a=e-h[2]:a=0,r<h[1]?c=h[1]-r:h[3]<r?c=r-h[3]:c=0,a*a+c*c}function rl(h,e){return nu(h,e[0],e[1])}function go(h,e){return h[0]<=e[0]&&e[2]<=h[2]&&h[1]<=e[1]&&e[3]<=h[3]}function nu(h,e,r){return h[0]<=e&&e<=h[2]&&h[1]<=r&&r<=h[3]}function pp(h,e){let r=h[0],a=h[1],c=h[2],s=h[3],y=e[0],v=e[1],b=Ni.UNKNOWN;return y<r?b=b|Ni.LEFT:y>c&&(b=b|Ni.RIGHT),v<a?b=b|Ni.BELOW:v>s&&(b=b|Ni.ABOVE),b===Ni.UNKNOWN&&(b=Ni.INTERSECTING),b}function xn(){return[1/0,1/0,-1/0,-1/0]}function yo(h,e,r,a,c){return c?(c[0]=h,c[1]=e,c[2]=r,c[3]=a,c):[h,e,r,a]}function yc(h){return yo(1/0,1/0,-1/0,-1/0,h)}function ca(h,e){let r=h[0],a=h[1];return yo(r,a,r,a,e)}function _c(h,e,r,a,c){let s=yc(c);return sg(s,h,e,r,a)}function fp(h,e){return h[0]==e[0]&&h[2]==e[2]&&h[1]==e[1]&&h[3]==e[3]}function sv(h,e){return e[0]<h[0]&&(h[0]=e[0]),e[2]>h[2]&&(h[2]=e[2]),e[1]<h[1]&&(h[1]=e[1]),e[3]>h[3]&&(h[3]=e[3]),h}function ng(h,e){e[0]<h[0]&&(h[0]=e[0]),e[0]>h[2]&&(h[2]=e[0]),e[1]<h[1]&&(h[1]=e[1]),e[1]>h[3]&&(h[3]=e[1])}function sg(h,e,r,a,c){for(;r<a;r+=c)W2(h,e[r],e[r+1]);return h}function W2(h,e,r){h[0]=Math.min(h[0],e),h[1]=Math.min(h[1],r),h[2]=Math.max(h[2],e),h[3]=Math.max(h[3],r)}function ov(h,e){let r;return r=e(og(h)),r||(r=e(ag(h)),r)||(r=e(cg(h)),r)||(r=e(lg(h)),r)?r:!1}function og(h){return[h[0],h[1]]}function ag(h){return[h[2],h[1]]}function as(h){return[(h[0]+h[2])/2,(h[1]+h[3])/2]}function av(h,e,r,a,c){let[s,y,v,b,T,C,k,O]=Z2(h,e,r,a);return yo(Math.min(s,v,T,k),Math.min(y,b,C,O),Math.max(s,v,T,k),Math.max(y,b,C,O),c)}function Z2(h,e,r,a){let c=e*a[0]/2,s=e*a[1]/2,y=Math.cos(r),v=Math.sin(r),b=c*y,T=c*v,C=s*y,k=s*v,O=h[0],G=h[1];return[O-b+k,G-T-C,O-b-k,G-T+C,O+b-k,G+T+C,O+b+k,G+T-C,O-b+k,G-T-C]}function Wi(h){return h[3]-h[1]}function lg(h){return[h[0],h[3]]}function cg(h){return[h[2],h[3]]}function vi(h){return h[2]-h[0]}function Vi(h,e){return h[0]<=e[2]&&h[2]>=e[0]&&h[1]<=e[3]&&h[3]>=e[1]}function su(h){return h[2]<h[0]||h[3]<h[1]}function lv(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h}function cv(h,e,r){let a=!1,c=pp(h,e),s=pp(h,r);if(c===Ni.INTERSECTING||s===Ni.INTERSECTING)a=!0;else{let y=h[0],v=h[1],b=h[2],T=h[3],C=e[0],k=e[1],O=r[0],G=r[1],J=(G-k)/(O-C),le,he;s&Ni.ABOVE&&!(c&Ni.ABOVE)&&(le=O-(G-T)/J,a=le>=y&&le<=b),!a&&s&Ni.RIGHT&&!(c&Ni.RIGHT)&&(he=G-(O-b)*J,a=he>=v&&he<=T),!a&&s&Ni.BELOW&&!(c&Ni.BELOW)&&(le=O-(G-v)/J,a=le>=y&&le<=b),!a&&s&Ni.LEFT&&!(c&Ni.LEFT)&&(he=G-(O-y)*J,a=he>=v&&he<=T)}return a}function hv(h,e,r,a){if(su(h))return yc(r);let c=[];if(a>1){let v=h[2]-h[0],b=h[3]-h[1];for(let T=0;T<a;++T)c.push(h[0]+v*T/a,h[1],h[2],h[1]+b*T/a,h[2]-v*T/a,h[3],h[0],h[3]-b*T/a)}else c=[h[0],h[1],h[2],h[1],h[2],h[3],h[0],h[3]];e(c,c,2);let s=[],y=[];for(let v=0,b=c.length;v<b;v+=2)s.push(c[v]),y.push(c[v+1]);return $2(s,y,r)}function hg(h,e){let r=e.getExtent(),a=as(h);if(e.canWrapX()&&(a[0]<r[0]||a[0]>=r[2])){let c=vi(r),y=Math.floor((a[0]-r[0])/c)*c;h[0]-=y,h[2]-=y}return h}function uv(h,e,r){if(e.canWrapX()){let a=e.getExtent();if(!isFinite(h[0])||!isFinite(h[2]))return[[a[0],h[1],a[2],h[3]]];hg(h,e);let c=vi(a);if(vi(h)>c&&!r)return[[a[0],h[1],a[2],h[3]]];if(h[0]<a[0])return[[h[0]+c,h[1],a[2],h[3]],[a[0],h[1],h[2],h[3]]];if(h[2]>a[2])return[[h[0],h[1],a[2],h[3]],[a[0],h[1],h[2]-c,h[3]]]}return[h]}var ou={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var ug=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ou[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},xc=ug;var au=6378137,vc=Math.PI*au,X2=[-vc,-vc,vc,vc],H2=[-180,-85,180,85],mp=au*Math.log(Math.tan(Math.PI/2)),ha=class extends xc{constructor(e){super({code:e,units:"m",extent:X2,global:!0,worldExtent:H2,getPointResolution:function(r,a){return r/Math.cosh(a[1]/au)}})}},dg=[new ha("EPSG:3857"),new ha("EPSG:102100"),new ha("EPSG:102113"),new ha("EPSG:900913"),new ha("http://www.opengis.net/def/crs/EPSG/0/3857"),new ha("http://www.opengis.net/gml/srs/epsg.xml#3857")];function dv(h,e,r,a){let c=h.length;r=r>1?r:2,a=a??r,e===void 0&&(r>2?e=h.slice():e=new Array(c));for(let s=0;s<c;s+=a){e[s]=vc*h[s]/180;let y=au*Math.log(Math.tan(Math.PI*(+h[s+1]+90)/360));y>mp?y=mp:y<-mp&&(y=-mp),e[s+1]=y}return e}function pv(h,e,r,a){let c=h.length;r=r>1?r:2,a=a??r,e===void 0&&(r>2?e=h.slice():e=new Array(c));for(let s=0;s<c;s+=a)e[s]=180*h[s]/vc,e[s+1]=360*Math.atan(Math.exp(h[s+1]/au))/Math.PI-90;return e}var K2=6378137,fv=[-180,-90,180,90],Y2=Math.PI*K2/180,_o=class extends xc{constructor(e,r){super({code:e,units:"degrees",extent:fv,axisOrientation:r,global:!0,metersPerUnit:Y2,worldExtent:fv})}},pg=[new _o("CRS:84"),new _o("EPSG:4326","neu"),new _o("urn:ogc:def:crs:OGC:1.3:CRS84"),new _o("urn:ogc:def:crs:OGC:2:84"),new _o("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new _o("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new _o("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var fg={};function mv(h){return fg[h]||fg[h.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function gv(h,e){fg[h]=e}var bc={};function wc(h,e,r){let a=h.getCode(),c=e.getCode();a in bc||(bc[a]={}),bc[a][c]=r}function gp(h,e){return h in bc&&e in bc[h]?bc[h][e]:null}function Ii(h,e,r){return Math.min(Math.max(h,e),r)}function yv(h,e,r,a,c,s){let y=c-r,v=s-a;if(y!==0||v!==0){let b=((h-r)*y+(e-a)*v)/(y*y+v*v);b>1?(r=c,a=s):b>0&&(r+=y*b,a+=v*b)}return ws(h,e,r,a)}function ws(h,e,r,a){let c=r-h,s=a-e;return c*c+s*s}function lu(h){return h*180/Math.PI}function nl(h){return h*Math.PI/180}function sl(h,e){let r=h%e;return r*e<0?r+e:r}function Ir(h,e,r){return h+r*(e-h)}function _v(h,e){let r=Math.pow(10,e);return Math.round(h*r)/r}function yp(h,e,r){if(h>=e&&h<r)return h;let a=r-e;return((h-e)%a+a)%a+e}function xv(h,e){return h[0]+=+e[0],h[1]+=+e[1],h}function mg(h,e){let r=h[0],a=h[1],c=e[0],s=e[1],y=c[0],v=c[1],b=s[0],T=s[1],C=b-y,k=T-v,O=C===0&&k===0?0:(C*(r-y)+k*(a-v))/(C*C+k*k||0),G,J;return O<=0?(G=y,J=v):O>=1?(G=b,J=T):(G=y+O*C,J=v+O*k),[G,J]}function Zi(h,e){let r=!0;for(let a=h.length-1;a>=0;--a)if(h[a]!=e[a]){r=!1;break}return r}function vv(h,e){let r=Math.cos(e),a=Math.sin(e),c=h[0]*r-h[1]*a,s=h[1]*r+h[0]*a;return h[0]=c,h[1]=s,h}function Sc(h,e){let r=h[0]-e[0],a=h[1]-e[1];return r*r+a*a}function gg(h,e){return Math.sqrt(Sc(h,e))}function bv(h,e){return Sc(h,mg(h,e))}function wv(h,e){if(e.canWrapX()){let r=vi(e.getExtent()),a=Sv(h,e,r);a&&(h[0]-=a*r)}return h}function Sv(h,e,r){let a=e.getExtent(),c=0;return e.canWrapX()&&(h[0]<a[0]||h[0]>a[2])&&(r=r||vi(a),c=Math.floor((h[0]-a[0])/r)),c}var _p=.9996,ls=.00669438,vp=ls*ls,bp=vp*ls,ol=ls/(1-ls),Iv=Math.sqrt(1-ls),Ic=(1-Iv)/(1+Iv),Mv=Ic*Ic,yg=Mv*Ic,_g=yg*Ic,Pv=_g*Ic,Av=1-ls/4-3*vp/64-5*bp/256,J2=3*ls/8+3*vp/32+45*bp/1024,Q2=15*vp/256+45*bp/1024,eI=35*bp/3072,tI=3/2*Ic-27/32*yg+269/512*Pv,iI=21/16*Mv-55/32*_g,rI=151/96*yg-417/128*Pv,nI=1097/512*_g,xp=6378137;function sI(h,e,r){let a=h-5e5,y=(r.north?e:e-1e7)/_p/(xp*Av),v=y+tI*Math.sin(2*y)+iI*Math.sin(4*y)+rI*Math.sin(6*y)+nI*Math.sin(8*y),b=Math.sin(v),T=b*b,C=Math.cos(v),k=b/C,O=k*k,G=O*O,J=1-ls*T,le=Math.sqrt(1-ls*T),he=xp/le,fe=(1-ls)/J,ye=ol*C**2,we=ye*ye,Ie=a/(he*_p),Pe=Ie*Ie,Ee=Pe*Ie,Ge=Ee*Ie,Be=Ge*Ie,Ae=Be*Ie,st=v-k/fe*(Pe/2-Ge/24*(5+3*O+10*ye-4*we-9*ol))+Ae/720*(61+90*O+298*ye+45*G-252*ol-3*we),ct=(Ie-Ee/6*(1+2*O+ye)+Be/120*(5-2*ye+28*O-3*we+8*ol+24*G))/C;return ct=yp(ct+nl(Rv(r.number)),-Math.PI,Math.PI),[lu(ct),lu(st)]}var Cv=-80,Ev=84,oI=-180,aI=180;function lI(h,e,r){h=yp(h,oI,aI),e<Cv?e=Cv:e>Ev&&(e=Ev);let a=nl(e),c=Math.sin(a),s=Math.cos(a),y=c/s,v=y*y,b=v*v,T=nl(h),C=Rv(r.number),k=nl(C),O=xp/Math.sqrt(1-ls*c**2),G=ol*s**2,J=s*yp(T-k,-Math.PI,Math.PI),le=J*J,he=le*J,fe=he*J,ye=fe*J,we=ye*J,Ie=xp*(Av*a-J2*Math.sin(2*a)+Q2*Math.sin(4*a)-eI*Math.sin(6*a)),Pe=_p*O*(J+he/6*(1-v+G)+ye/120*(5-18*v+b+72*G-58*ol))+5e5,Ee=_p*(Ie+O*y*(le/2+fe/24*(5-v+9*G+4*G**2)+we/720*(61-58*v+b+600*G-330*ol)));return r.north||(Ee+=1e7),[Pe,Ee]}function Rv(h){return(h-1)*6-180+3}var cI=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function kv(h){let e=0;for(let c of cI){let s=h.match(c);if(s){e=parseInt(s[1]);break}}if(!e)return null;let r=0,a=!1;return e>32700&&e<32761?r=e-32700:e>32600&&e<32661&&(a=!0,r=e-32600),r?{number:r,north:a}:null}function Tv(h,e){return function(r,a,c,s){let y=r.length;c=c>1?c:2,s=s??c,a||(c>2?a=r.slice():a=new Array(y));for(let v=0;v<y;v+=s){let b=r[v],T=r[v+1],C=h(b,T,e);a[v]=C[0],a[v+1]=C[1]}return a}}function Lv(h){return kv(h)?new xc({code:h,units:"m"}):null}function Dv(h){let e=kv(h.getCode());return e?{forward:Tv(lI,e),inverse:Tv(sI,e)}:null}var Fv={info:1,warn:2,error:3,none:4},hI=Fv.info;function zv(...h){hI>Fv.warn||console.warn(...h)}var uI=[Dv],dI=[Lv];var vg=!0;function wg(h){vg=!(h===void 0?!0:h)}function Sg(h,e){if(e!==void 0){for(let r=0,a=h.length;r<a;++r)e[r]=h[r];e=e}else e=h.slice();return e}function bg(h){gv(h.getCode(),h),wc(h,h,Sg)}function pI(h){h.forEach(bg)}function Ci(h){if(typeof h!="string")return h;let e=mv(h);if(e)return e;for(let r of dI){let a=r(h);if(a)return a}return null}function Ov(h){pI(h),h.forEach(function(e){h.forEach(function(r){e!==r&&wc(e,r,Sg)})})}function fI(h,e,r,a){h.forEach(function(c){e.forEach(function(s){wc(c,s,r),wc(s,c,a)})})}function wp(h,e){return h?typeof h=="string"?Ci(h):h:Ci(e)}function ar(h,e){return wg(),Sp(h,"EPSG:4326",e!==void 0?e:"EPSG:3857")}function al(h,e){let r=Sp(h,e!==void 0?e:"EPSG:3857","EPSG:4326"),a=r[0];return(a<-180||a>180)&&(r[0]=sl(a+180,360)-180),r}function Bv(h,e){if(h===e)return!0;let r=h.getUnits()===e.getUnits();return(h.getCode()===e.getCode()||Cc(h,e)===Sg)&&r}function Cc(h,e){let r=h.getCode(),a=e.getCode(),c=gp(r,a);if(c)return c;let s=null,y=null;for(let b of uI)s||(s=b(h)),y||(y=b(e));if(!s&&!y)return null;let v="EPSG:4326";if(y)if(s)c=xg(s.inverse,y.forward);else{let b=gp(r,v);b&&(c=xg(b,y.forward))}else{let b=gp(v,a);b&&(c=xg(s.inverse,b))}return c&&(bg(h),bg(e),wc(h,e,c)),c}function xg(h,e){return function(r,a,c,s){return a=h(r,a,c,s),e(a,a,c,s)}}function ll(h,e){let r=Ci(h),a=Ci(e);return Cc(r,a)}function Sp(h,e,r){let a=ll(e,r);if(!a){let c=Ci(e).getCode(),s=Ci(r).getCode();throw new Error(`No transform available between ${c} and ${s}`)}return a(h,void 0,h.length)}function Ig(h,e,r,a){let c=ll(e,r);return hv(h,c,void 0,a)}var Ss=null;function Zn(){return Ss}function ua(h,e){return Ss?Sp(h,e,Ss):h}function Ai(h,e){return Ss?Sp(h,Ss,e):(vg&&!Zi(h,[0,0])&&h[0]>=-180&&h[0]<=180&&h[1]>=-90&&h[1]<=90&&(vg=!1,zv("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),h)}function js(h,e){return Ss?Ig(h,e,Ss):h}function Gs(h,e){return Ss?Ig(h,Ss,e):h}function Nv(h,e){if(!Ss)return h;let r=Ci(e).getMetersPerUnit(),a=Ss.getMetersPerUnit();return r&&a?h*r/a:h}function mI(){Ov(dg),Ov(pg),fI(pg,dg,dv,pv)}mI();function vn(h,e,r,a,c,s,y){s=s||[],y=y||2;let v=0;for(let b=e;b<r;b+=a){let T=h[b],C=h[b+1];s[v++]=c[0]*T+c[2]*C+c[4],s[v++]=c[1]*T+c[3]*C+c[5];for(let k=2;k<y;k++)s[v++]=h[b+k]}return s&&s.length!=v&&(s.length=v),s}function Ip(h,e,r,a,c,s,y){y=y||[];let v=Math.cos(c),b=Math.sin(c),T=s[0],C=s[1],k=0;for(let O=e;O<r;O+=a){let G=h[O]-T,J=h[O+1]-C;y[k++]=T+G*v-J*b,y[k++]=C+G*b+J*v;for(let le=O+2;le<O+a;++le)y[k++]=h[le]}return y&&y.length!=k&&(y.length=k),y}function Vv(h,e,r,a,c,s,y,v){v=v||[];let b=y[0],T=y[1],C=0;for(let k=e;k<r;k+=a){let O=h[k]-b,G=h[k+1]-T;v[C++]=b+c*O,v[C++]=T+s*G;for(let J=k+2;J<k+a;++J)v[C++]=h[J]}return v&&v.length!=C&&(v.length=C),v}function jv(h,e,r,a,c,s,y){y=y||[];let v=0;for(let b=e;b<r;b+=a){y[v++]=h[b]+c,y[v++]=h[b+1]+s;for(let T=b+2;T<b+a;++T)y[v++]=h[T]}return y&&y.length!=v&&(y.length=v),y}var Gv=sr(),Cg=class extends or{constructor(){super(),this.extent_=xn(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=cp((e,r,a)=>{if(!a)return this.getSimplifiedGeometry(r);let c=this.clone();return c.applyTransform(a),c.getSimplifiedGeometry(r)})}simplifyTransformed(e,r){return this.simplifyTransformedInternal(this.getRevision(),e,r)}clone(){return wt()}closestPointXY(e,r,a,c){return wt()}containsXY(e,r){let a=this.getClosestPoint([e,r]);return a[0]===e&&a[1]===r}getClosestPoint(e,r){return r=r||[NaN,NaN],this.closestPointXY(e[0],e[1],r,1/0),r}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return wt()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let r=this.computeExtent(this.extent_);(isNaN(r[0])||isNaN(r[1]))&&yc(r),this.extentRevision_=this.getRevision()}return lv(this.extent_,e)}rotate(e,r){wt()}scale(e,r,a){wt()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return wt()}getType(){return wt()}applyTransform(e){wt()}intersectsExtent(e){return wt()}translate(e,r){wt()}transform(e,r){let a=Ci(e),c=a.getUnits()=="tile-pixels"?function(s,y,v){let b=a.getExtent(),T=a.getWorldExtent(),C=Wi(T)/Wi(b);Vr(Gv,T[0],T[3],C,-C,0,0,0);let k=vn(s,0,s.length,v,Gv,y),O=ll(a,r);return O?O(k,k,v):k}:ll(a,r);return this.applyTransform(c),this}},Cp=Cg;var Eg=class extends Cp{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return _c(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return wt()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=this.getSimplifiedGeometryInternal(e);return r.getFlatCoordinates().length<this.flatCoordinates.length?r:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,r){this.stride=Uv(e),this.layout=e,this.flatCoordinates=r}setCoordinates(e,r){wt()}setLayout(e,r,a){let c;if(e)c=Uv(e);else{for(let s=0;s<a;++s){if(r.length===0){this.layout="XY",this.stride=2;return}r=r[0]}c=r.length,e=da(c)}this.layout=e,this.stride=c}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,r){let a=this.getFlatCoordinates();if(a){let c=this.getStride();Ip(a,0,a.length,c,e,r,a),this.changed()}}scale(e,r,a){r===void 0&&(r=e),a||(a=as(this.getExtent()));let c=this.getFlatCoordinates();if(c){let s=this.getStride();Vv(c,0,c.length,s,e,r,a,c),this.changed()}}translate(e,r){let a=this.getFlatCoordinates();if(a){let c=this.getStride();jv(a,0,a.length,c,e,r,a),this.changed()}}};function da(h){let e;return h==2?e="XY":h==3?e="XYZ":h==4&&(e="XYZM"),e}function Uv(h){let e;return h=="XY"?e=2:h=="XYZ"||h=="XYM"?e=3:h=="XYZM"&&(e=4),e}function qv(h,e,r){let a=h.getFlatCoordinates();if(!a)return null;let c=h.getStride();return vn(a,0,a.length,c,e,r)}var Cr=Eg;function $v(h,e,r,a){for(let c=0,s=r.length;c<s;++c)h[e++]=r[c];return e}function cl(h,e,r,a){for(let c=0,s=r.length;c<s;++c){let y=r[c];for(let v=0;v<a;++v)h[e++]=y[v]}return e}function pa(h,e,r,a,c){c=c||[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=cl(h,e,r[y],a);c[s++]=b,e=b}return c.length=s,c}function Ep(h,e,r,a,c){c=c||[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=pa(h,e,r[y],a,c[s]);b.length===0&&(b[0]=e),c[s++]=b,e=b[b.length-1]}return c.length=s,c}var Mg=class h extends Cp{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(jr),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let r=0,a=e.length;r<a;++r)this.changeEventsKeys_.push(Sr(e[r],pi.CHANGE,this.changed,this))}clone(){let e=new h(Tg(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,r,a,c){if(c<_n(this.getExtent(),e,r))return c;let s=this.geometries_;for(let y=0,v=s.length;y<v;++y)c=s[y].closestPointXY(e,r,a,c);return c}containsXY(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)if(a[c].containsXY(e,r))return!0;return!1}computeExtent(e){yc(e);let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)sv(e,r[a].getExtent());return e}getGeometries(){return Tg(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],r=this.geometries_;for(let a=0,c=r.length;a<c;++a)r[a].getType()===this.getType()?e=e.concat(r[a].getGeometriesArrayRecursive()):e.push(r[a]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=[],a=this.geometries_,c=!1;for(let s=0,y=a.length;s<y;++s){let v=a[s],b=v.getSimplifiedGeometry(e);r.push(b),b!==v&&(c=!0)}return c?new h(r):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)if(r[a].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)a[c].rotate(e,r);this.changed()}scale(e,r,a){a||(a=as(this.getExtent()));let c=this.geometries_;for(let s=0,y=c.length;s<y;++s)c[s].scale(e,r,a);this.changed()}setGeometries(e){this.setGeometriesArray(Tg(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)r[a].applyTransform(e);this.changed()}translate(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)a[c].translate(e,r);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function Tg(h){return h.map(e=>e.clone())}var Pg=Mg;function Wv(h,e,r,a,c,s,y){let v=h[e],b=h[e+1],T=h[r]-v,C=h[r+1]-b,k;if(T===0&&C===0)k=e;else{let O=((c-v)*T+(s-b)*C)/(T*T+C*C);if(O>1)k=r;else if(O>0){for(let G=0;G<a;++G)y[G]=Ir(h[e+G],h[r+G],O);y.length=a;return}else k=e}for(let O=0;O<a;++O)y[O]=h[k+O];y.length=a}function cu(h,e,r,a,c){let s=h[e],y=h[e+1];for(e+=a;e<r;e+=a){let v=h[e],b=h[e+1],T=ws(s,y,v,b);T>c&&(c=T),s=v,y=b}return c}function hu(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];c=cu(h,e,v,a,c),e=v}return c}function Zv(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];c=hu(h,e,v,a,c),e=v[v.length-1]}return c}function uu(h,e,r,a,c,s,y,v,b,T,C){if(e==r)return T;let k,O;if(c===0){if(O=ws(y,v,h[e],h[e+1]),O<T){for(k=0;k<a;++k)b[k]=h[e+k];return b.length=a,O}return T}C=C||[NaN,NaN];let G=e+a;for(;G<r;)if(Wv(h,G-a,G,a,y,v,C),O=ws(y,v,C[0],C[1]),O<T){for(T=O,k=0;k<a;++k)b[k]=C[k];b.length=a,G+=a}else G+=a*Math.max((Math.sqrt(O)-Math.sqrt(T))/c|0,1);if(s&&(Wv(h,r-a,e,a,y,v,C),O=ws(y,v,C[0],C[1]),O<T)){for(T=O,k=0;k<a;++k)b[k]=C[k];b.length=a}return T}function du(h,e,r,a,c,s,y,v,b,T,C){C=C||[NaN,NaN];for(let k=0,O=r.length;k<O;++k){let G=r[k];T=uu(h,e,G,a,c,s,y,v,b,T,C),e=G}return T}function Xv(h,e,r,a,c,s,y,v,b,T,C){C=C||[NaN,NaN];for(let k=0,O=r.length;k<O;++k){let G=r[k];T=du(h,e,G,a,c,s,y,v,b,T,C),e=G[G.length-1]}return T}function hl(h,e,r,a,c,s,y){let v=(r-e)/a;if(v<3){for(;e<r;e+=a)s[y++]=h[e],s[y++]=h[e+1];return y}let b=new Array(v);b[0]=1,b[v-1]=1;let T=[e,r-a],C=0;for(;T.length>0;){let k=T.pop(),O=T.pop(),G=0,J=h[O],le=h[O+1],he=h[k],fe=h[k+1];for(let ye=O+a;ye<k;ye+=a){let we=h[ye],Ie=h[ye+1],Pe=yv(we,Ie,J,le,he,fe);Pe>G&&(C=ye,G=Pe)}G>c&&(b[(C-e)/a]=1,O+a<C&&T.push(O,C),C+a<k&&T.push(C,k))}for(let k=0;k<v;++k)b[k]&&(s[y++]=h[e+k*a],s[y++]=h[e+k*a+1]);return y}function Tp(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b];y=hl(h,e,C,a,c,s,y),v.push(y),e=C}return y}function fa(h,e){return e*Math.round(h/e)}function gI(h,e,r,a,c,s,y){if(e==r)return y;let v=fa(h[e],c),b=fa(h[e+1],c);e+=a,s[y++]=v,s[y++]=b;let T,C;do if(T=fa(h[e],c),C=fa(h[e+1],c),e+=a,e==r)return s[y++]=T,s[y++]=C,y;while(T==v&&C==b);for(;e<r;){let k=fa(h[e],c),O=fa(h[e+1],c);if(e+=a,k==T&&O==C)continue;let G=T-v,J=C-b,le=k-v,he=O-b;if(G*he==J*le&&(G<0&&le<G||G==le||G>0&&le>G)&&(J<0&&he<J||J==he||J>0&&he>J)){T=k,C=O;continue}s[y++]=T,s[y++]=C,v=T,b=C,T=k,C=O}return s[y++]=T,s[y++]=C,y}function pu(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b];y=gI(h,e,C,a,c,s,y),v.push(y),e=C}return y}function Hv(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b],k=[];y=pu(h,e,C,a,c,s,y,k),v.push(k),e=C[C.length-1]}return y}function cs(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=e;y<r;y+=a)c[s++]=h.slice(y,y+a);return c.length=s,c}function ma(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y];c[s++]=cs(h,e,b,a,c[s]),e=b}return c.length=s,c}function fu(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y];c[s++]=b.length===1&&b[0]===e?[]:ma(h,e,b,a,c[s]),e=b[b.length-1]}return c.length=s,c}function Ag(h,e,r,a){let c=0,s=h[r-a],y=h[r-a+1],v=0,b=0;for(;e<r;e+=a){let T=h[e]-s,C=h[e+1]-y;c+=b*T-v*C,v=T,b=C}return c/2}function Rg(h,e,r,a){let c=0;for(let s=0,y=r.length;s<y;++s){let v=r[s];c+=Ag(h,e,v,a),e=v}return c}function Kv(h,e,r,a){let c=0;for(let s=0,y=r.length;s<y;++s){let v=r[s];c+=Rg(h,e,v,a),e=v[v.length-1]}return c}var kg=class h extends Cr{constructor(e,r){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}clone(){return new h(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),uu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,r,a,c))}getArea(){return Ag(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){let r=[];return r.length=hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},Lg=kg;function Mp(h,e,r,a,c){let s;for(e+=a;e<r;e+=a)if(s=c(h.slice(e-a,e),h.slice(e,e+a)),s)return s;return!1}function ul(h,e,r,a,c,s,y){let v,b,T=(r-e)/a;if(T===1)v=e;else if(T===2)v=e,b=c;else if(T!==0){let C=h[e],k=h[e+1],O=0,G=[0];for(let he=e+a;he<r;he+=a){let fe=h[he],ye=h[he+1];O+=Math.sqrt((fe-C)*(fe-C)+(ye-k)*(ye-k)),G.push(O),C=fe,k=ye}let J=c*O,le=tv(G,J);le<0?(b=(J-G[-le-2])/(G[-le-1]-G[-le-2]),v=e+(-le-2)*a):v=e+le*a}y=y>1?y:2,s=s||new Array(y);for(let C=0;C<y;++C)s[C]=v===void 0?NaN:b===void 0?h[v+C]:Ir(h[v+C],h[v+a+C],b);return s}function Pp(h,e,r,a,c,s){if(r==e)return null;let y;if(c<h[e+a-1])return s?(y=h.slice(e,e+a),y[a-1]=c,y):null;if(h[r-1]<c)return s?(y=h.slice(r-a,r),y[a-1]=c,y):null;if(c==h[e+a-1])return h.slice(e,e+a);let v=e/a,b=r/a;for(;v<b;){let O=v+b>>1;c<h[(O+1)*a-1]?b=O:v=O+1}let T=h[v*a-1];if(c==T)return h.slice((v-1)*a,(v-1)*a+a);let C=h[(v+1)*a-1],k=(c-T)/(C-T);y=[];for(let O=0;O<a-1;++O)y.push(Ir(h[(v-1)*a+O],h[v*a+O],k));return y.push(c),y}function Yv(h,e,r,a,c,s,y){if(y)return Pp(h,e,r[r.length-1],a,c,s);let v;if(c<h[a-1])return s?(v=h.slice(0,a),v[a-1]=c,v):null;if(h[h.length-1]<c)return s?(v=h.slice(h.length-a),v[a-1]=c,v):null;for(let b=0,T=r.length;b<T;++b){let C=r[b];if(e!=C){if(c<h[e+a-1])return null;if(c<=h[C-1])return Pp(h,e,C,a,c,!1);e=C}}return null}function Jv(h,e,r,a,c){return!ov(c,function(y){return!ga(h,e,r,a,y[0],y[1])})}function ga(h,e,r,a,c,s){let y=0,v=h[r-a],b=h[r-a+1];for(;e<r;e+=a){let T=h[e],C=h[e+1];b<=s?C>s&&(T-v)*(s-b)-(c-v)*(C-b)>0&&y++:C<=s&&(T-v)*(s-b)-(c-v)*(C-b)<0&&y--,v=T,b=C}return y!==0}function mu(h,e,r,a,c,s){if(r.length===0||!ga(h,e,r[0],a,c,s))return!1;for(let y=1,v=r.length;y<v;++y)if(ga(h,r[y-1],r[y],a,c,s))return!1;return!0}function Qv(h,e,r,a,c,s){if(r.length===0)return!1;for(let y=0,v=r.length;y<v;++y){let b=r[y];if(mu(h,e,b,a,c,s))return!0;e=b[b.length-1]}return!1}function gu(h,e,r,a,c){let s=sg(xn(),h,e,r,a);return Vi(c,s)?go(c,s)||s[0]>=c[0]&&s[2]<=c[2]||s[1]>=c[1]&&s[3]<=c[3]?!0:Mp(h,e,r,a,function(y,v){return cv(c,y,v)}):!1}function eb(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){if(gu(h,e,r[s],a,c))return!0;e=r[s]}return!1}function yI(h,e,r,a,c){return!!(gu(h,e,r,a,c)||ga(h,e,r,a,c[0],c[1])||ga(h,e,r,a,c[0],c[3])||ga(h,e,r,a,c[2],c[1])||ga(h,e,r,a,c[2],c[3]))}function Dg(h,e,r,a,c){if(!yI(h,e,r[0],a,c))return!1;if(r.length===1)return!0;for(let s=1,y=r.length;s<y;++s)if(Jv(h,r[s-1],r[s],a,c)&&!gu(h,r[s-1],r[s],a,c))return!1;return!0}function tb(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];if(Dg(h,e,v,a,c))return!0;e=v[v.length-1]}return!1}function Ap(h,e,r,a){let c=h[e],s=h[e+1],y=0;for(let v=e+a;v<r;v+=a){let b=h[v],T=h[v+1];y+=Math.sqrt((b-c)*(b-c)+(T-s)*(T-s)),c=b,s=T}return y}var Fg=class h extends Cr{constructor(e,r){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendCoordinate(e){wr(this.flatCoordinates,e),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),uu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,r,a,c))}forEachSegment(e){return Mp(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,r){return this.layout!="XYM"&&this.layout!="XYZM"?null:(r=r!==void 0?r:!1,Pp(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r))}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,r){return ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,this.stride)}getLength(){return Ap(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){let r=[];return r.length=hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LineString"}intersectsExtent(e){return gu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},Is=Fg;var zg=class h extends Cr{constructor(e,r,a){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,r);else if(r!==void 0&&a)this.setFlatCoordinates(r,e),this.ends_=a;else{let c=e,s=[],y=[];for(let b=0,T=c.length;b<T;++b){let C=c[b];wr(s,C.getFlatCoordinates()),y.push(s.length)}let v=c.length===0?this.getLayout():c[0].getLayout();this.setFlatCoordinates(v,s),this.ends_=y}}appendLineString(e){wr(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),du(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,r,a,c))}getCoordinateAtM(e,r,a){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(r=r!==void 0?r:!1,a=a!==void 0?a:!1,Yv(this.flatCoordinates,0,this.ends_,this.stride,e,r,a))}getCoordinates(){return ma(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new Is(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){let e=this.flatCoordinates,r=this.ends_,a=this.layout,c=[],s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y],T=new Is(e.slice(s,b),a);c.push(T),s=b}return c}getFlatMidpoints(){let e=[],r=this.flatCoordinates,a=0,c=this.ends_,s=this.stride;for(let y=0,v=c.length;y<v;++y){let b=c[y],T=ul(r,a,b,s,.5);wr(e,T),a=b}return e}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=Tp(this.flatCoordinates,0,this.ends_,this.stride,e,r,0,a),new h(r,"XY",a)}getType(){return"MultiLineString"}intersectsExtent(e){return eb(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let a=pa(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=a.length===0?0:a[a.length-1],this.changed()}},Og=zg;var Bg=class h extends Cr{constructor(e,r){super(),this.setCoordinates(e,r)}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){let s=this.flatCoordinates,y=ws(e,r,s[0],s[1]);if(y<c){let v=this.stride;for(let b=0;b<v;++b)a[b]=s[b];return a.length=v,y}return c}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return ca(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return nu(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,r){this.setLayout(r,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=$v(this.flatCoordinates,0,e,this.stride),this.changed()}},lr=Bg;var Ng=class h extends Cr{constructor(e,r){super(),r&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendPoint(e){wr(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){if(c<_n(this.getExtent(),e,r))return c;let s=this.flatCoordinates,y=this.stride;for(let v=0,b=s.length;v<b;v+=y){let T=ws(e,r,s[v],s[v+1]);if(T<c){c=T;for(let C=0;C<y;++C)a[C]=s[v+C];a.length=y}}return c}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){let r=this.flatCoordinates.length/this.stride;return e<0||r<=e?null:new lr(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){let e=this.flatCoordinates,r=this.layout,a=this.stride,c=[];for(let s=0,y=e.length;s<y;s+=a){let v=new lr(e.slice(s,s+a),r);c.push(v)}return c}getType(){return"MultiPoint"}intersectsExtent(e){let r=this.flatCoordinates,a=this.stride;for(let c=0,s=r.length;c<s;c+=a){let y=r[c],v=r[c+1];if(nu(e,y,v))return!0}return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},yu=Ng;function _u(h,e,r,a,c,s,y){let v,b,T,C,k,O,G,J=c[s+1],le=[];for(let ye=0,we=r.length;ye<we;++ye){let Ie=r[ye];for(C=h[Ie-a],O=h[Ie-a+1],v=e;v<Ie;v+=a)k=h[v],G=h[v+1],(J<=O&&G<=J||O<=J&&J<=G)&&(T=(J-O)/(G-O)*(k-C)+C,le.push(T)),C=k,O=G}let he=NaN,fe=-1/0;for(le.sort(xs),C=le[0],v=1,b=le.length;v<b;++v){k=le[v];let ye=Math.abs(k-C);ye>fe&&(T=(C+k)/2,mu(h,e,r,a,T,J)&&(he=T,fe=ye)),C=k}return isNaN(he)&&(he=c[s]),y?(y.push(he,J,fe),y):[he,J,fe]}function Rp(h,e,r,a,c){let s=[];for(let y=0,v=r.length;y<v;++y){let b=r[y];s=_u(h,e,b,a,c,2*y,s),e=b[b.length-1]}return s}function ib(h,e,r,a){for(;e<r-a;){for(let c=0;c<a;++c){let s=h[e+c];h[e+c]=h[r-a+c],h[r-a+c]=s}e+=a,r-=a}}function Vg(h,e,r,a){let c=0,s=h[r-a],y=h[r-a+1];for(;e<r;e+=a){let v=h[e],b=h[e+1];c+=(v-s)*(b+y),s=v,y=b}return c===0?void 0:c>0}function xu(h,e,r,a,c){c=c!==void 0?c:!1;for(let s=0,y=r.length;s<y;++s){let v=r[s],b=Vg(h,e,v,a);if(s===0){if(c&&b||!c&&!b)return!1}else if(c&&!b||!c&&b)return!1;e=v}return!0}function kp(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];if(!xu(h,e,v,a,c))return!1;v.length&&(e=v[v.length-1])}return!0}function Ec(h,e,r,a,c){c=c!==void 0?c:!1;for(let s=0,y=r.length;s<y;++s){let v=r[s],b=Vg(h,e,v,a);(s===0?c&&b||!c&&!b:c&&!b||!c&&b)&&ib(h,e,v,a),e=v}return e}function vu(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s)e=Ec(h,e,r[s],a,c);return e}function rb(h,e){let r=[],a=0,c=0,s;for(let y=0,v=e.length;y<v;++y){let b=e[y],T=Vg(h,a,b,2);if(s===void 0&&(s=T),T===s)r.push(e.slice(c,y+1));else{if(r.length===0)continue;r[r.length-1].push(e[c])}c=y+1,a=b}return r}var bu=class h extends Cr{constructor(e,r,a){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,r!==void 0&&a?(this.setFlatCoordinates(r,e),this.ends_=a):this.setCoordinates(e,r)}appendLinearRing(e){this.flatCoordinates?wr(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),du(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,r,a,c))}containsXY(e,r){return mu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,r)}getArea(){return Rg(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),Ec(r,0,this.ends_,this.stride,e)):r=this.flatCoordinates,ma(r,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let e=as(this.getExtent());this.flatInteriorPoint_=_u(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new lr(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new Lg(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){let e=this.layout,r=this.flatCoordinates,a=this.ends_,c=[],s=0;for(let y=0,v=a.length;y<v;++y){let b=a[y],T=new Lg(r.slice(s,b),e);c.push(T),s=b}return c}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;xu(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ec(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=pu(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),r,0,a),new h(r,"XY",a)}getType(){return"Polygon"}intersectsExtent(e){return Dg(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let a=pa(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=a.length===0?0:a[a.length-1],this.changed()}},Tc=bu;function jg(h){if(su(h))throw new Error("Cannot create polygon from empty extent");let e=h[0],r=h[1],a=h[2],c=h[3],s=[e,r,e,c,a,c,a,r,e,r];return new bu(s,"XY",[s.length])}function Gg(h,e,r){e=e||32;let a=h.getStride(),c=h.getLayout(),s=h.getCenter(),y=a*(e+1),v=new Array(y);for(let C=0;C<y;C+=a){v[C]=0,v[C+1]=0;for(let k=2;k<a;k++)v[C+k]=s[k]}let b=[v.length],T=new bu(v,c,b);return _I(T,s,h.getRadius(),r),T}function _I(h,e,r,a){let c=h.getFlatCoordinates(),s=h.getStride(),y=c.length/s-1,v=a||0;for(let b=0;b<=y;++b){let T=b*s,C=v+sl(b,y)*2*Math.PI/y;c[T]=e[0]+r*Math.cos(C),c[T+1]=e[1]+r*Math.sin(C)}h.changed()}function Lp(h,e,r,a){let c=[],s=xn();for(let y=0,v=r.length;y<v;++y){let b=r[y];s=_c(h,e,b[0],a),c.push((s[0]+s[2])/2,(s[1]+s[3])/2),e=b[b.length-1]}return c}var Ug=class h extends Cr{constructor(e,r,a){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!a&&!Array.isArray(e[0])){let c=e,s=[],y=[];for(let v=0,b=c.length;v<b;++v){let T=c[v],C=s.length,k=T.getEnds();for(let O=0,G=k.length;O<G;++O)k[O]+=C;wr(s,T.getFlatCoordinates()),y.push(k)}r=c.length===0?this.getLayout():c[0].getLayout(),e=s,a=y}r!==void 0&&a?(this.setFlatCoordinates(r,e),this.endss_=a):this.setCoordinates(e,r)}appendPolygon(e){let r;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),r=e.getEnds().slice(),this.endss_.push();else{let a=this.flatCoordinates.length;wr(this.flatCoordinates,e.getFlatCoordinates()),r=e.getEnds().slice();for(let c=0,s=r.length;c<s;++c)r[c]+=a}this.endss_.push(r),this.changed()}clone(){let e=this.endss_.length,r=new Array(e);for(let c=0;c<e;++c)r[c]=this.endss_[c].slice();let a=new h(this.flatCoordinates.slice(),this.layout,r);return a.applyProperties(this),a}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Zv(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Xv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,r,a,c))}containsXY(e,r){return Qv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,r)}getArea(){return Kv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),vu(r,0,this.endss_,this.stride,e)):r=this.flatCoordinates,fu(r,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let e=Lp(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Rp(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yu(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;kp(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=vu(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=Hv(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),r,0,a),new h(r,"XY",a)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let r;if(e===0)r=0;else{let s=this.endss_[e-1];r=s[s.length-1]}let a=this.endss_[e].slice(),c=a[a.length-1];if(r!==0)for(let s=0,y=a.length;s<y;++s)a[s]-=r;return new Tc(this.flatCoordinates.slice(r,c),this.layout,a)}getPolygons(){let e=this.layout,r=this.flatCoordinates,a=this.endss_,c=[],s=0;for(let y=0,v=a.length;y<v;++y){let b=a[y].slice(),T=b[b.length-1];if(s!==0)for(let k=0,O=b.length;k<O;++k)b[k]-=s;let C=new Tc(r.slice(s,T),e,b);c.push(C),s=T}return c}getType(){return"MultiPolygon"}intersectsExtent(e){return tb(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,3),this.flatCoordinates||(this.flatCoordinates=[]);let a=Ep(this.flatCoordinates,0,e,this.stride,this.endss_);if(a.length===0)this.flatCoordinates.length=0;else{let c=a[a.length-1];this.flatCoordinates.length=c.length===0?0:c[c.length-1]}this.changed()}},qg=Ug;var xI=(h,e,r)=>{let{coordinate:a,olGeometry:c,time_intervals:s}=e.properties,{coordinates:y,type:v}=e.geometry,b=c,T,C;if(c&&(v=b.getType(),y=b.getCoordinates()),r&&a)T=a;else if(v==="Point")T=y;else if(v==="LineString"){b||(b=new Is(y));let k=s||[[]],O=k[0],G=k[k.length-1];if(h<O[0])[,,C]=O,T=b.getFirstCoordinate();else if(h>G[0])[,,C]=G,T=b.getLastCoordinate();else for(let J=0;J<k.length-1;J+=1){let[le,he]=k[J],[fe,ye]=k[J+1];if(le<=h&&h<=fe){let Ie=Math.min((h-le)/(fe-le),1)*(ye-he)+he;T=b.getCoordinateAt(Ie),[,,C]=k[J];break}}}else console.error("This geometry type is not supported. Only Point or LineString are. Current geometry: ",b);return{coord:T,rotation:C}},wu=xI;var vI=(h,e,r,a,c)=>{if(!h)return{renderedTrajectories:[]};let{center:s,pixelRatio:y=1,resolution:v,rotation:b=0,size:T=[],time:C=Date.now()}=a;if(!v||!s)return{renderedTrajectories:[]};let{filter:k,getScreenPixel:O=(Ae,st)=>(st.zoom||0)<12?Ae.map(ct=>Math.floor(ct)):Ae,hoverVehicleId:G,noInterpolate:J=!1,selectedVehicleId:le}=c,he=h.getContext("2d");he?.clearRect(0,0,h.width,h.height);let[fe,ye]=T;fe&&ye&&(h.width!==fe||h.height!==ye)&&([h.width,h.height]=[fe*y,ye*y]);let we=Vr(sr(),T[0]/2,T[1]/2,1/v,-1/v,-b,-s[0],-s[1]);h.style&&(h.style.width=`${h.width/y}px`,h.style.height=`${h.height/y}px`);let Ie,Pe,Ee,Ge,Be=[];for(let Ae=e.length-1;Ae>=0;Ae-=1){let st=e[Ae];if(k&&!k(st))continue;let{timeOffset:ct,train_id:rt}=st.properties,{coord:xt,rotation:Rt}=wu(C-(ct||0),st,J);if(e[Ae].properties.coordinate=xt,e[Ae].properties.rotation=Rt,!xt)continue;let at=br(we,[...xt]);if(!at||(at=at.map(ot=>ot*y),at[0]<0||at[0]>h.width||at[1]<0||at[1]>h.height))continue;let gt=r(st,a,c);if(gt){if(G!==rt&&le!==rt){let[ot,pt]=O([at[0]-gt.width/2,at[1]-gt.height/2],a);he?.drawImage(gt,ot,pt)}G&&G===rt&&(Ie=gt,Pe=at),le&&le===rt&&(Ee=gt,Ge=at),Be.push(st)}}return Ee&&Ge&&he?.drawImage(Ee,Math.floor(Ge[0]-Ee.width/2),Math.floor(Ge[1]-Ee.height/2)),Ie&&Pe&&he?.drawImage(Ie,Math.floor(Pe[0]-Ie.width/2),Math.floor(Pe[1]-Ie.height/2)),{renderedTrajectories:Be}},Su=vI;var bI=(h,e,r=!1)=>{let a=["HIDDEN","LEAVING","BOARDING"],c=h.has_fzo&&a.indexOf(h.state)>-1,s=e.has_fzo&&a.indexOf(e.state)>-1;if(c||s){if(c!==s)return c?-1:1;if(h.state!==e.state)return a.indexOf(h.state)-a.indexOf(e.state)}let y=null,v=null,b=Date.now();return r?(y=new Date(h.min_arrival_time||h.time).getTime()-b,v=new Date(e.min_arrival_time||e.time).getTime()-b):(y=new Date(h.time).getTime()-b,v=new Date(e.time).getTime()-b),y-v},Iu=bI;var wI=(h,e=!1,r=30)=>{let a=Object.keys(h).map(k=>h[k]);a.sort((k,O)=>Iu(k,O,e));let c=new Date;c.setMinutes(c.getMinutes()+r);let s=c.getTime(),y=new Date;y.setMinutes(y.getMinutes()-r);let v=y.getTime(),b=[],T=[],C=null;for(let k=a.length-1;k>=0;k-=1){let O={...a[k]},G=new Date(O.time).getTime();G>v&&G<s&&(O.state==="BOARDING"&&(T.includes(O.platform)?O.state="HIDDEN":T.push(O.platform)),C&&O.to[0]===C.to[0]&&Math.abs(G-C.time)<1e3&&O.line.name===C.line.name&&(O.state="HIDDEN"),/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(O.state)&&(O.cancelled=!0),C=O,C.time=G,b.unshift(O))}return b},Cu=wI;var SI=(h,e=!1,r=30,a=100)=>{let c={},s={};return y=>{let{source:v,content:b}=y;c[v]&&window.clearTimeout(c[v]),b&&(s[b.call_id]=b,c[v]=window.setTimeout(()=>{let T=Cu(s,e||!1,r);h(T)},a))}},$g=SI;var Mc={};Lm(Mc,{MOTS_ALL:()=>EI,MOTS_ONLY_RAIL:()=>Cs,MOTS_WITHOUT_CABLE:()=>Dp,MOTS_WITH_CABLE:()=>CI,bgColors:()=>sb,getBgColor:()=>MI,getDelayColor:()=>RI,getDelayText:()=>kI,getRadius:()=>TI,getTextColor:()=>PI,getTextSize:()=>AI,getTypeIndex:()=>Fp,textColors:()=>ob,types:()=>nb});var II=[[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15]],Cs=["rail"],CI=["cablecar","gondola","funicular","coach"],Dp=["tram","subway","rail","bus"],EI=["tram","subway","rail","bus","ferry","cablecar","gondola","funicular","coach"],nb=[/^Tram/i,/^Subway( \/ Metro \/ S-Bahn)?/i,/^Train/i,/^Bus/i,/^Ferry/i,/^Cable ?Car/i,/^Gondola/i,/^Funicular/i,/^(Long distance bus|coach)/i,/^Rail/i],sb=["#ffb400","#ff5400","#ff8080","#ea0000","#3000ff","#ffb400","#41a27b","#00d237","#b5b5b5","#ff8080"],ob=["#000000","#ffffff","#000000","#ffffff","#ffffff","#000000","#ffffff","#000000","#000000","#000000"],Fp=h=>typeof h=="string"?nb.findIndex(e=>e.test(h)):h,TI=(h,e)=>{try{let r=Fp(h||0);return II[r][e]}catch{return 1}},MI=h=>{try{let e=Fp(h);return sb[e]}catch{return"#ffffff"}},PI=h=>{try{let e=Fp(h);return ob[e]}catch{return"#ffffff"}},AI=(h,e,r,a,c)=>{if(!h)return 0;h.font=c(a,r);let s=h.measureText(r),y=25,v=0;for(;s.width>e-6&&v<y;)a-=.5,h.font=c(a,r),s=h.measureText(r),v+=1;return a},RI=(h,e,r)=>e?r?"#ff0000":"#a0a0a0":h===null?"#a0a0a0":h>=36e5?"#ed004c":h>=5e5?"#e80000":h>=3e5?"#ff4a00":h>=18e4?"#f7bf00":"#00a00c",kI=(h,e)=>e?String.fromCodePoint(215):h>=36e5?`+${Math.round(h/36e5)}h`:h>=6e4?`+${Math.round(h/6e4)}m`:h>=1e3?`+${Math.round(h/1e3)}s`:h>0?`+${h}ms`:"";var Pc="vectorTileFeature";var ab={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var Wg=class extends or{constructor(e){super();let r=e.element;r&&!e.target&&!r.style.pointerEvents&&(r.style.pointerEvents="auto"),this.element=r||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let r=0,a=this.listenerKeys.length;r<a;++r)jr(this.listenerKeys[r]);if(this.listenerKeys.length=0,this.map_=e,e){let r=this.target_??e.getOverlayContainerStopEvent();this.element&&r.appendChild(this.element),this.render!==vs&&this.listenerKeys.push(Sr(e,ab.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},Ac=Wg;var Qt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var Zg=class extends or{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let r=Object.assign({},e);typeof e.properties=="object"&&(delete r.properties,Object.assign(r,e.properties)),r[Qt.OPACITY]=e.opacity!==void 0?e.opacity:1,ui(typeof r[Qt.OPACITY]=="number","Layer opacity must be a number"),r[Qt.VISIBLE]=e.visible!==void 0?e.visible:!0,r[Qt.Z_INDEX]=e.zIndex,r[Qt.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,r[Qt.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,r[Qt.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,r[Qt.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=r.className!==void 0?r.className:"ol-layer",delete r.className,this.setProperties(r),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let r=this.state_||{layer:this,managed:e===void 0?!0:e},a=this.getZIndex();return r.opacity=Ii(Math.round(this.getOpacity()*100)/100,0,1),r.visible=this.getVisible(),r.extent=this.getExtent(),r.zIndex=a===void 0&&!r.managed?1/0:a,r.maxResolution=this.getMaxResolution(),r.minResolution=Math.max(this.getMinResolution(),0),r.minZoom=this.getMinZoom(),r.maxZoom=this.getMaxZoom(),this.state_=r,r}getLayersArray(e){return wt()}getLayerStatesArray(e){return wt()}getExtent(){return this.get(Qt.EXTENT)}getMaxResolution(){return this.get(Qt.MAX_RESOLUTION)}getMinResolution(){return this.get(Qt.MIN_RESOLUTION)}getMinZoom(){return this.get(Qt.MIN_ZOOM)}getMaxZoom(){return this.get(Qt.MAX_ZOOM)}getOpacity(){return this.get(Qt.OPACITY)}getSourceState(){return wt()}getVisible(){return this.get(Qt.VISIBLE)}getZIndex(){return this.get(Qt.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(Qt.EXTENT,e)}setMaxResolution(e){this.set(Qt.MAX_RESOLUTION,e)}setMinResolution(e){this.set(Qt.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(Qt.MAX_ZOOM,e)}setMinZoom(e){this.set(Qt.MIN_ZOOM,e)}setOpacity(e){ui(typeof e=="number","Layer opacity must be a number"),this.set(Qt.OPACITY,e)}setVisible(e){this.set(Qt.VISIBLE,e)}setZIndex(e){this.set(Qt.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},lb=Zg;var Us={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var bn={ANIMATING:0,INTERACTING:1};var hs={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Xg(h,e,r){return function(a,c,s,y,v){if(!a)return;if(!c&&!e)return a;let b=e?0:s[0]*c,T=e?0:s[1]*c,C=v?v[0]:0,k=v?v[1]:0,O=h[0]+b/2+C,G=h[2]-b/2+C,J=h[1]+T/2+k,le=h[3]-T/2+k;O>G&&(O=(G+O)/2,G=O),J>le&&(J=(le+J)/2,le=J);let he=Ii(a[0],O,G),fe=Ii(a[1],J,le);if(y&&r&&c){let ye=30*c;he+=-ye*Math.log(1+Math.max(0,O-a[0])/ye)+ye*Math.log(1+Math.max(0,a[0]-G)/ye),fe+=-ye*Math.log(1+Math.max(0,J-a[1])/ye)+ye*Math.log(1+Math.max(0,a[1]-le)/ye)}return[he,fe]}}function cb(h){return h}function Hg(h,e,r,a){let c=vi(e)/r[0],s=Wi(e)/r[1];return a?Math.min(h,Math.max(c,s)):Math.min(h,Math.min(c,s))}function Kg(h,e,r){let a=Math.min(h,e),c=50;return a*=Math.log(1+c*Math.max(0,h/e-1))/c+1,r&&(a=Math.max(a,r),a/=Math.log(1+c*Math.max(0,r/h-1))/c+1),Ii(a,r/2,e*2)}function hb(h,e,r,a){return e=e!==void 0?e:!0,function(c,s,y,v){if(c!==void 0){let b=h[0],T=h[h.length-1],C=r?Hg(b,r,y,a):b;if(v)return e?Kg(c,C,T):Ii(c,T,C);let k=Math.min(C,c),O=Math.floor(ap(h,k,s));return h[O]>C&&O<h.length-1?h[O+1]:h[O]}}}function ub(h,e,r,a,c,s){return a=a!==void 0?a:!0,r=r!==void 0?r:0,function(y,v,b,T){if(y!==void 0){let C=c?Hg(e,c,b,s):e;if(T)return a?Kg(y,C,r):Ii(y,r,C);let k=1e-9,O=Math.ceil(Math.log(e/C)/Math.log(h)-k),G=-v*(.5-k)+.5,J=Math.min(C,y),le=Math.floor(Math.log(e/J)/Math.log(h)+G),he=Math.max(O,le),fe=e/Math.pow(h,he);return Ii(fe,r,C)}}}function Yg(h,e,r,a,c){return r=r!==void 0?r:!0,function(s,y,v,b){if(s!==void 0){let T=a?Hg(h,a,v,c):h;return!r||!b?Ii(s,e,T):Kg(s,T,e)}}}function db(h){if(h!==void 0)return 0}function Jg(h){if(h!==void 0)return h}function pb(h){let e=2*Math.PI/h;return function(r,a){if(a)return r;if(r!==void 0)return r=Math.floor(r/e+.5)*e,r}}function fb(h){let e=h===void 0?nl(5):h;return function(r,a){return a||r===void 0?r:Math.abs(r)<=e?0:r}}function LI(h){return Math.pow(h,3)}function mb(h){return 1-LI(1-h)}function gb(h){return 3*h*h-2*h*h*h}var Qg=0,ty=class extends or{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=wp(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&wg(),e.center&&(e.center=Ai(e.center,this.projection_)),e.extent&&(e.extent=Gs(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){let r=Object.assign({},e);for(let v in hs)delete r[v];this.setProperties(r,!0);let a=FI(e);this.maxResolution_=a.maxResolution,this.minResolution_=a.minResolution,this.zoomFactor_=a.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=a.minZoom;let c=DI(e),s=a.constraint,y=zI(e);this.constraints_={center:c,resolution:s,rotation:y},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let r=this.padding_;this.padding_=e;let a=this.getCenterInternal();if(a){let c=e||[0,0,0,0];r=r||[0,0,0,0];let s=this.getResolution(),y=s/2*(c[3]-r[3]+r[1]-c[1]),v=s/2*(c[0]-r[0]+r[2]-c[2]);this.setCenterInternal([a[0]+y,a[1]-v])}}getUpdatedOptions_(e){let r=this.getProperties();return r.resolution!==void 0?r.resolution=this.getResolution():r.zoom=this.getZoom(),r.center=this.getCenterInternal(),r.rotation=this.getRotation(),Object.assign({},r,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let r=new Array(arguments.length);for(let a=0;a<r.length;++a){let c=arguments[a];c.center&&(c=Object.assign({},c),c.center=Ai(c.center,this.getProjection())),c.anchor&&(c=Object.assign({},c),c.anchor=Ai(c.anchor,this.getProjection())),r[a]=c}this.animateInternal.apply(this,r)}animateInternal(e){let r=arguments.length,a;r>1&&typeof arguments[r-1]=="function"&&(a=arguments[r-1],--r);let c=0;for(;c<r&&!this.isDef();++c){let C=arguments[c];C.center&&this.setCenterInternal(C.center),C.zoom!==void 0?this.setZoom(C.zoom):C.resolution&&this.setResolution(C.resolution),C.rotation!==void 0&&this.setRotation(C.rotation)}if(c===r){a&&zp(a,!0);return}let s=Date.now(),y=this.targetCenter_.slice(),v=this.targetResolution_,b=this.targetRotation_,T=[];for(;c<r;++c){let C=arguments[c],k={start:s,complete:!1,anchor:C.anchor,duration:C.duration!==void 0?C.duration:1e3,easing:C.easing||gb,callback:a};if(C.center&&(k.sourceCenter=y,k.targetCenter=C.center.slice(),y=k.targetCenter),C.zoom!==void 0?(k.sourceResolution=v,k.targetResolution=this.getResolutionForZoom(C.zoom),v=k.targetResolution):C.resolution&&(k.sourceResolution=v,k.targetResolution=C.resolution,v=k.targetResolution),C.rotation!==void 0){k.sourceRotation=b;let O=sl(C.rotation-b+Math.PI,2*Math.PI)-Math.PI;k.targetRotation=b+O,b=k.targetRotation}OI(k)?k.complete=!0:s+=k.duration,T.push(k)}this.animations_.push(T),this.setHint(bn.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[bn.ANIMATING]>0}getInteracting(){return this.hints_[bn.INTERACTING]>0}cancelAnimations(){this.setHint(bn.ANIMATING,-this.hints_[bn.ANIMATING]);let e;for(let r=0,a=this.animations_.length;r<a;++r){let c=this.animations_[r];if(c[0].callback&&zp(c[0].callback,!1),!e)for(let s=0,y=c.length;s<y;++s){let v=c[s];if(!v.complete){e=v.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),r=!1;for(let a=this.animations_.length-1;a>=0;--a){let c=this.animations_[a],s=!0;for(let y=0,v=c.length;y<v;++y){let b=c[y];if(b.complete)continue;let T=e-b.start,C=b.duration>0?T/b.duration:1;C>=1?(b.complete=!0,C=1):s=!1;let k=b.easing(C);if(b.sourceCenter){let O=b.sourceCenter[0],G=b.sourceCenter[1],J=b.targetCenter[0],le=b.targetCenter[1];this.nextCenter_=b.targetCenter;let he=O+k*(J-O),fe=G+k*(le-G);this.targetCenter_=[he,fe]}if(b.sourceResolution&&b.targetResolution){let O=k===1?b.targetResolution:b.sourceResolution+k*(b.targetResolution-b.sourceResolution);if(b.anchor){let G=this.getViewportSize_(this.getRotation()),J=this.constraints_.resolution(O,0,G,!0);this.targetCenter_=this.calculateCenterZoom(J,b.anchor)}this.nextResolution_=b.targetResolution,this.targetResolution_=O,this.applyTargetState_(!0)}if(b.sourceRotation!==void 0&&b.targetRotation!==void 0){let O=k===1?sl(b.targetRotation+Math.PI,2*Math.PI)-Math.PI:b.sourceRotation+k*(b.targetRotation-b.sourceRotation);if(b.anchor){let G=this.constraints_.rotation(O,!0);this.targetCenter_=this.calculateCenterRotate(G,b.anchor)}this.nextRotation_=b.targetRotation,this.targetRotation_=O}if(this.applyTargetState_(!0),r=!0,!b.complete)break}if(s){this.animations_[a]=null,this.setHint(bn.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let y=c[0].callback;y&&zp(y,!0)}}this.animations_=this.animations_.filter(Boolean),r&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,r){let a,c=this.getCenterInternal();return c!==void 0&&(a=[c[0]-r[0],c[1]-r[1]],vv(a,e-this.getRotation()),xv(a,r)),a}calculateCenterZoom(e,r){let a,c=this.getCenterInternal(),s=this.getResolution();if(c!==void 0&&s!==void 0){let y=r[0]-e*(r[0]-c[0])/s,v=r[1]-e*(r[1]-c[1])/s;a=[y,v]}return a}getViewportSize_(e){let r=this.viewportSize_;if(e){let a=r[0],c=r[1];return[Math.abs(a*Math.cos(e))+Math.abs(c*Math.sin(e)),Math.abs(a*Math.sin(e))+Math.abs(c*Math.cos(e))]}return r}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&ua(e,this.getProjection())}getCenterInternal(){return this.get(hs.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){let r=this.calculateExtentInternal(e);return js(r,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();let r=this.getCenterInternal();ui(r,"The view center is not defined");let a=this.getResolution();ui(a!==void 0,"The view resolution is not defined");let c=this.getRotation();return ui(c!==void 0,"The view rotation is not defined"),av(r,a,c,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(hs.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,r){return this.getResolutionForExtentInternal(Gs(e,this.getProjection()),r)}getResolutionForExtentInternal(e,r){r=r||this.getViewportSizeMinusPadding_();let a=vi(e)/r[0],c=Wi(e)/r[1];return Math.max(a,c)}getResolutionForValueFunction(e){e=e||2;let r=this.getConstrainedResolution(this.maxResolution_),a=this.minResolution_,c=Math.log(r/a)/Math.log(e);return function(s){return r/Math.pow(e,s*c)}}getRotation(){return this.get(hs.ROTATION)}getValueForResolutionFunction(e){let r=Math.log(e||2),a=this.getConstrainedResolution(this.maxResolution_),c=this.minResolution_,s=Math.log(a/c)/r;return function(y){return Math.log(a/y)/r/s}}getViewportSizeMinusPadding_(e){let r=this.getViewportSize_(e),a=this.padding_;return a&&(r=[r[0]-a[1]-a[3],r[1]-a[0]-a[2]]),r}getState(){let e=this.getProjection(),r=this.getResolution(),a=this.getRotation(),c=this.getCenterInternal(),s=this.padding_;if(s){let y=this.getViewportSizeMinusPadding_();c=ey(c,this.getViewportSize_(),[y[0]/2+s[3],y[1]/2+s[0]],r,a)}return{center:c.slice(0),projection:e!==void 0?e:null,resolution:r,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:a,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,r=this.getResolution();return r!==void 0&&(e=this.getZoomForResolution(r)),e}getZoomForResolution(e){let r=this.minZoom_||0,a,c;if(this.resolutions_){let s=ap(this.resolutions_,e,1);r=s,a=this.resolutions_[s],s==this.resolutions_.length-1?c=2:c=a/this.resolutions_[s+1]}else a=this.maxResolution_,c=this.zoomFactor_;return r+Math.log(a/e)/Math.log(c)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let r=Ii(Math.floor(e),0,this.resolutions_.length-2),a=this.resolutions_[r]/this.resolutions_[r+1];return this.resolutions_[r]/Math.pow(a,Ii(e-r,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,r){let a;if(ui(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){ui(!su(e),"Cannot fit empty extent provided as `geometry`");let c=Gs(e,this.getProjection());a=jg(c)}else if(e.getType()==="Circle"){let c=Gs(e.getExtent(),this.getProjection());a=jg(c),a.rotate(this.getRotation(),as(c))}else{let c=Zn();c?a=e.clone().transform(c,this.getProjection()):a=e}this.fitInternal(a,r)}rotatedExtentForGeometry(e){let r=this.getRotation(),a=Math.cos(r),c=Math.sin(-r),s=e.getFlatCoordinates(),y=e.getStride(),v=1/0,b=1/0,T=-1/0,C=-1/0;for(let k=0,O=s.length;k<O;k+=y){let G=s[k]*a-s[k+1]*c,J=s[k]*c+s[k+1]*a;v=Math.min(v,G),b=Math.min(b,J),T=Math.max(T,G),C=Math.max(C,J)}return[v,b,T,C]}fitInternal(e,r){r=r||{};let a=r.size;a||(a=this.getViewportSizeMinusPadding_());let c=r.padding!==void 0?r.padding:[0,0,0,0],s=r.nearest!==void 0?r.nearest:!1,y;r.minResolution!==void 0?y=r.minResolution:r.maxZoom!==void 0?y=this.getResolutionForZoom(r.maxZoom):y=0;let v=this.rotatedExtentForGeometry(e),b=this.getResolutionForExtentInternal(v,[a[0]-c[1]-c[3],a[1]-c[0]-c[2]]);b=isNaN(b)?y:Math.max(b,y),b=this.getConstrainedResolution(b,s?0:1);let T=this.getRotation(),C=Math.sin(T),k=Math.cos(T),O=as(v);O[0]+=(c[1]-c[3])/2*b,O[1]+=(c[0]-c[2])/2*b;let G=O[0]*k-O[1]*C,J=O[1]*k+O[0]*C,le=this.getConstrainedCenter([G,J],b),he=r.callback?r.callback:vs;r.duration!==void 0?this.animateInternal({resolution:b,center:le,duration:r.duration,easing:r.easing},he):(this.targetResolution_=b,this.targetCenter_=le,this.applyTargetState_(!1,!0),zp(he,!0))}centerOn(e,r,a){this.centerOnInternal(Ai(e,this.getProjection()),r,a)}centerOnInternal(e,r,a){this.setCenterInternal(ey(e,r,a,this.getResolution(),this.getRotation()))}calculateCenterShift(e,r,a,c){let s,y=this.padding_;if(y&&e){let v=this.getViewportSizeMinusPadding_(-a),b=ey(e,c,[v[0]/2+y[3],v[1]/2+y[0]],r,a);s=[e[0]-b[0],e[1]-b[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let r=ua(this.targetCenter_,this.getProjection());this.setCenter([r[0]+e[0],r[1]+e[1]])}adjustCenterInternal(e){let r=this.targetCenter_;this.setCenterInternal([r[0]+e[0],r[1]+e[1]])}adjustResolution(e,r){r=r&&Ai(r,this.getProjection()),this.adjustResolutionInternal(e,r)}adjustResolutionInternal(e,r){let a=this.getAnimating()||this.getInteracting(),c=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*e,0,c,a);r&&(this.targetCenter_=this.calculateCenterZoom(s,r)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,r){this.adjustResolution(Math.pow(this.zoomFactor_,-e),r)}adjustRotation(e,r){r&&(r=Ai(r,this.getProjection())),this.adjustRotationInternal(e,r)}adjustRotationInternal(e,r){let a=this.getAnimating()||this.getInteracting(),c=this.constraints_.rotation(this.targetRotation_+e,a);r&&(this.targetCenter_=this.calculateCenterRotate(c,r)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&Ai(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,r){return this.hints_[e]+=r,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,r){let a=this.getAnimating()||this.getInteracting()||r,c=this.constraints_.rotation(this.targetRotation_,a),s=this.getViewportSize_(c),y=this.constraints_.resolution(this.targetResolution_,0,s,a),v=this.constraints_.center(this.targetCenter_,y,s,a,this.calculateCenterShift(this.targetCenter_,y,c,s));this.get(hs.ROTATION)!==c&&this.set(hs.ROTATION,c),this.get(hs.RESOLUTION)!==y&&(this.set(hs.RESOLUTION,y),this.set("zoom",this.getZoom(),!0)),(!v||!this.get(hs.CENTER)||!Zi(this.get(hs.CENTER),v))&&this.set(hs.CENTER,v),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,r,a){e=e!==void 0?e:200;let c=r||0,s=this.constraints_.rotation(this.targetRotation_),y=this.getViewportSize_(s),v=this.constraints_.resolution(this.targetResolution_,c,y),b=this.constraints_.center(this.targetCenter_,v,y,!1,this.calculateCenterShift(this.targetCenter_,v,s,y));if(e===0&&!this.cancelAnchor_){this.targetResolution_=v,this.targetRotation_=s,this.targetCenter_=b,this.applyTargetState_();return}a=a||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==v||this.getRotation()!==s||!this.getCenterInternal()||!Zi(this.getCenterInternal(),b))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:b,resolution:v,duration:e,easing:mb,anchor:a}))}beginInteraction(){this.resolveConstraints(0),this.setHint(bn.INTERACTING,1)}endInteraction(e,r,a){a=a&&Ai(a,this.getProjection()),this.endInteractionInternal(e,r,a)}endInteractionInternal(e,r,a){this.getInteracting()&&(this.setHint(bn.INTERACTING,-1),this.resolveConstraints(e,r,a))}getConstrainedCenter(e,r){let a=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,r||this.getResolution(),a)}getConstrainedZoom(e,r){let a=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(a,r))}getConstrainedResolution(e,r){r=r||0;let a=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,r,a)}};function zp(h,e){setTimeout(function(){h(e)},0)}function DI(h){if(h.extent!==void 0){let r=h.smoothExtentConstraint!==void 0?h.smoothExtentConstraint:!0;return Xg(h.extent,h.constrainOnlyCenter,r)}let e=wp(h.projection,"EPSG:3857");if(h.multiWorld!==!0&&e.isGlobal()){let r=e.getExtent().slice();return r[0]=-1/0,r[2]=1/0,Xg(r,!1,!1)}return cb}function FI(h){let e,r,a,y=h.minZoom!==void 0?h.minZoom:Qg,v=h.maxZoom!==void 0?h.maxZoom:28,b=h.zoomFactor!==void 0?h.zoomFactor:2,T=h.multiWorld!==void 0?h.multiWorld:!1,C=h.smoothResolutionConstraint!==void 0?h.smoothResolutionConstraint:!0,k=h.showFullExtent!==void 0?h.showFullExtent:!1,O=wp(h.projection,"EPSG:3857"),G=O.getExtent(),J=h.constrainOnlyCenter,le=h.extent;if(!T&&!le&&O.isGlobal()&&(J=!1,le=G),h.resolutions!==void 0){let he=h.resolutions;r=he[y],a=he[v]!==void 0?he[v]:he[he.length-1],h.constrainResolution?e=hb(he,C,!J&&le,k):e=Yg(r,a,C,!J&&le,k)}else{let fe=(G?Math.max(vi(G),Wi(G)):360*ou.degrees/O.getMetersPerUnit())/256/Math.pow(2,Qg),ye=fe/Math.pow(2,28-Qg);r=h.maxResolution,r!==void 0?y=0:r=fe/Math.pow(b,y),a=h.minResolution,a===void 0&&(h.maxZoom!==void 0?h.maxResolution!==void 0?a=r/Math.pow(b,v):a=fe/Math.pow(b,v):a=ye),v=y+Math.floor(Math.log(r/a)/Math.log(b)),a=r/Math.pow(b,v-y),h.constrainResolution?e=ub(b,r,a,C,!J&&le,k):e=Yg(r,a,C,!J&&le,k)}return{constraint:e,maxResolution:r,minResolution:a,minZoom:y,zoomFactor:b}}function zI(h){if(h.enableRotation!==void 0?h.enableRotation:!0){let r=h.constrainRotation;return r===void 0||r===!0?fb():r===!1?Jg:typeof r=="number"?pb(r):Jg}return db}function OI(h){return!(h.sourceCenter&&h.targetCenter&&!Zi(h.sourceCenter,h.targetCenter)||h.sourceResolution!==h.targetResolution||h.sourceRotation!==h.targetRotation)}function ey(h,e,r,a,c){let s=Math.cos(-c),y=Math.sin(-c),v=h[0]*s-h[1]*y,b=h[1]*s+h[0]*y;v+=(e[0]/2-r[0])*a,b+=(r[1]-e[1]/2)*a,y=-y;let T=v*s-b*y,C=b*s+v*y;return[T,C]}var iy=ty;var ry=class extends lb{constructor(e){let r=Object.assign({},e);delete r.source,super(r),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(Qt.SOURCE,this.handleSourcePropertyChange_);let a=e.source?e.source:null;this.setSource(a)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(Qt.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(jr(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=Sr(e,pi.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let r,a=this.getMapInternal();!e&&a&&(e=a.getView()),e instanceof iy?r={viewState:e.getState(),extent:e.calculateExtent()}:r=e,!r.layerStatesArray&&a&&(r.layerStatesArray=a.getLayerGroup().getLayerStatesArray());let c;if(r.layerStatesArray){if(c=r.layerStatesArray.find(y=>y.layer===this),!c)return!1}else c=this.getLayerState();let s=this.getExtent();return ny(c,r.viewState)&&(!s||Vi(s,r.extent))}getAttributions(e){if(!this.isVisible(e))return[];let r=this.getSource()?.getAttributions();if(!r)return[];let a=e instanceof iy?e.getViewStateAndExtent():e,c=r(a);return Array.isArray(c)||(c=[c]),c}render(e,r){let a=this.getRenderer();return a.prepareFrame(e)?(this.rendered=!0,a.renderFrame(e,r)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,r){}renderDeferred(e){let r=this.getRenderer();r&&r.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Qt.MAP,e)}getMapInternal(){return this.get(Qt.MAP)}setMap(e){this.mapPrecomposeKey_&&(jr(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(jr(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=Sr(e,Us.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=Sr(this,pi.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){let r=e.frameState.layerStatesArray,a=this.getLayerState(!1);ui(!r.some(c=>c.layer===a.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),r.push(a)}setSource(e){this.set(Qt.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function ny(h,e){if(!h.visible)return!1;let r=e.resolution;if(r<h.minResolution||r>=h.maxResolution)return!1;let a=e.zoom;return a>h.minZoom&&a<=h.maxZoom}var Es=ry;var BI=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",bottom:0,right:0,fontSize:".8rem",padding:"0 10px"}),h},yb=BI;var sy=class extends Ac{constructor(e={}){let r=yb();r.className=e.className||"mbt-copyright",super({element:r,...e}),this.format=e.format||(a=>a?.join(" | "))}render({frameState:e}){if(!e){this.element.innerHTML="";return}let r=[];e?.layerStatesArray.forEach(c=>{let{layer:s}=c;if(e&&ny(c,e.viewState)&&(s?.getSource()?.getAttributions()&&(r=r.concat(s.getSource().getAttributions()(e))),s?.get("copyrights"))){let y=s.get("copyrights");y=Array.isArray(y)?y:[y],y?.length&&r.push(...y)}});let a=il(r)||[];this.element.innerHTML=this.format(a)}},_b=sy;var Ts={ADD:"add",REMOVE:"remove"};var xb={LENGTH:"length"},Rc=class extends Si{constructor(e,r,a){super(e),this.element=r,this.index=a}},oy=class extends or{constructor(e,r){if(super(),this.on,this.once,this.un,r=r||{},this.unique_=!!r.unique,this.array_=e||[],this.unique_)for(let a=0,c=this.array_.length;a<c;++a)this.assertUnique_(this.array_[a],a);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let r=0,a=e.length;r<a;++r)this.push(e[r]);return this}forEach(e){let r=this.array_;for(let a=0,c=r.length;a<c;++a)e(r[a],a,r)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(xb.LENGTH)}insertAt(e,r){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r),this.array_.splice(e,0,r),this.updateLength_(),this.dispatchEvent(new Rc(Ts.ADD,r,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);let r=this.getLength();return this.insertAt(r,e),this.getLength()}remove(e){let r=this.array_;for(let a=0,c=r.length;a<c;++a)if(r[a]===e)return this.removeAt(a)}removeAt(e){if(e<0||e>=this.getLength())return;let r=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Rc(Ts.REMOVE,r,e)),r}setAt(e,r){let a=this.getLength();if(e>=a){this.insertAt(e,r);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r,e);let c=this.array_[e];this.array_[e]=r,this.dispatchEvent(new Rc(Ts.REMOVE,c,e)),this.dispatchEvent(new Rc(Ts.ADD,r,e))}updateLength_(){this.set(xb.LENGTH,this.array_.length)}assertUnique_(e,r){for(let a=0,c=this.array_.length;a<c;++a)if(this.array_[a]===e&&a!==r)throw new Error("Duplicate item added to a unique collection")}},Eu=oy;var ay=class h extends or{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){let r=e;this.setGeometry(r)}else{let r=e;this.setProperties(r)}}clone(){let e=new h(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());let r=this.getGeometry();r&&e.setGeometry(r.clone());let a=this.getStyle();return a&&e.setStyle(a),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(jr(this.geometryChangeKey_),this.geometryChangeKey_=null);let e=this.getGeometry();e&&(this.geometryChangeKey_=Sr(e,pi.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?NI(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function NI(h){if(typeof h=="function")return h;let e;return Array.isArray(h)?e=h:(ui(typeof h.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[h]),function(){return e}}var us=ay;var It={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var xo={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var dl={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"]};dl.whitepoint={2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}};dl.max=dl.whitepoint[2].D65;dl.rgb=function(h,e){e=e||dl.whitepoint[2].E;var r=h[0]/e[0],a=h[1]/e[1],c=h[2]/e[2],s,y,v;return s=r*3.240969941904521+a*-1.537383177570093+c*-.498610760293,y=r*-.96924363628087+a*1.87596750150772+c*.041555057407175,v=r*.055630079696993+a*-.20397695888897+c*1.056971514242878,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=s*12.92,y=y>.0031308?1.055*Math.pow(y,1/2.4)-.055:y=y*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v=v*12.92,s=Math.min(Math.max(0,s),1),y=Math.min(Math.max(0,y),1),v=Math.min(Math.max(0,v),1),[s*255,y*255,v*255]};xo.xyz=function(h,e){var r=h[0]/255,a=h[1]/255,c=h[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,c=c>.04045?Math.pow((c+.055)/1.055,2.4):c/12.92;var s=r*.41239079926595+a*.35758433938387+c*.18048078840183,y=r*.21263900587151+a*.71516867876775+c*.072192315360733,v=r*.019330818715591+a*.11919477979462+c*.95053215224966;return e=e||dl.whitepoint[2].E,[s*e[0],y*e[1],v*e[2]]};var wn=dl;var Op={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(h,e,r){var a,c,s,y,v,b,T,C,k,O,G,J,le;if(s=h[0],y=h[1],v=h[2],s===0)return[0,0,0];var he=.0011070564598794539;return e=e||"D65",r=r||2,k=wn.whitepoint[r][e][0],O=wn.whitepoint[r][e][1],G=wn.whitepoint[r][e][2],J=4*k/(k+15*O+3*G),le=9*O/(k+15*O+3*G),a=y/(13*s)+J||0,c=v/(13*s)+le||0,T=s>8?O*Math.pow((s+16)/116,3):O*s*he,b=T*9*a/(4*c)||0,C=T*(12-3*a-20*c)/(4*c)||0,[b,T,C]}};wn.luv=function(h,e,r){var a,c,s,y,v,b,T,C,k,O,G,J,le,he=.008856451679035631,fe=903.2962962962961;e=e||"D65",r=r||2,k=wn.whitepoint[r][e][0],O=wn.whitepoint[r][e][1],G=wn.whitepoint[r][e][2],J=4*k/(k+15*O+3*G),le=9*O/(k+15*O+3*G),b=h[0],T=h[1],C=h[2],a=4*b/(b+15*T+3*C)||0,c=9*T/(b+15*T+3*C)||0;var ye=T/O;return s=ye<=he?fe*ye:116*Math.pow(ye,1/3)-16,y=13*s*(a-J),v=13*s*(c-le),[s,y,v]};var vb={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(h){var e=h[0],r=h[1],a=h[2],c,s,y;return y=a/360*2*Math.PI,c=r*Math.cos(y),s=r*Math.sin(y),[e,c,s]},xyz:function(h){return Op.xyz(vb.luv(h))}},bb=vb;Op.lchuv=function(h){var e=h[0],r=h[1],a=h[2],c=Math.sqrt(r*r+a*a),s=Math.atan2(a,r),y=s*360/2/Math.PI;return y<0&&(y+=360),[e,c,y]};wn.lchuv=function(h){return Op.lchuv(wn.luv(h))};var ly=Vs(Sb(),1),Cb=VI,Ib={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function VI(h){var e,r=[],a=1,c;if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(h=String(h).toLowerCase(),ly.default[h])r=ly.default[h].slice(),c="rgb";else if(h==="transparent")a=0,c="rgb",r=[0,0,0];else if(h[0]==="#"){var s=h.slice(1),y=s.length,v=y<=4;a=1,v?(r=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],y===4&&(a=parseInt(s[3]+s[3],16)/255)):(r=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],y===8&&(a=parseInt(s[6]+s[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),c="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(h)){var b=e[1];c=b.replace(/a$/,"");var T=c==="cmyk"?4:c==="gray"?1:3;r=e[2].trim().split(/\s*[,\/]\s*|\s+/),c==="color"&&(c=r.shift()),r=r.map(function(C,k){if(C[C.length-1]==="%")return C=parseFloat(C)/100,k===3?C:c==="rgb"?C*255:c[0]==="h"||c[0]==="l"&&!k?C*100:c==="lab"?C*125:c==="lch"?k<2?C*150:C*360:c[0]==="o"&&!k?C:c==="oklab"?C*.4:c==="oklch"?k<2?C*.4:C*360:C;if(c[k]==="h"||k===2&&c[c.length-1]==="h"){if(Ib[C]!==void 0)return Ib[C];if(C.endsWith("deg"))return parseFloat(C);if(C.endsWith("turn"))return parseFloat(C)*360;if(C.endsWith("grad"))return parseFloat(C)*360/400;if(C.endsWith("rad"))return parseFloat(C)*180/Math.PI}return C==="none"?0:parseFloat(C)}),a=r.length>T?r.pop():1}else/[0-9](?:\s|\/|,)/.test(h)&&(r=h.match(/([0-9]+)/g).map(function(C){return parseFloat(C)}),c=h.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:c,values:r,alpha:a}}var Bp={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(h){var e=h[0]/360,r=h[1]/100,a=h[2]/100,c,s,y,v,b,T=0;if(r===0)return b=a*255,[b,b,b];for(s=a<.5?a*(1+r):a+r-a*r,c=2*a-s,v=[0,0,0];T<3;)y=e+1/3*-(T-1),y<0?y++:y>1&&y--,b=6*y<1?c+(s-c)*6*y:2*y<1?s:3*y<2?c+(s-c)*(2/3-y)*6:c,v[T++]=b*255;return v}};xo.hsl=function(h){var e=h[0]/255,r=h[1]/255,a=h[2]/255,c=Math.min(e,r,a),s=Math.max(e,r,a),y=s-c,v,b,T;return s===c?v=0:e===s?v=(r-a)/y:r===s?v=2+(a-e)/y:a===s&&(v=4+(e-r)/y),v=Math.min(v*60,360),v<0&&(v+=360),T=(c+s)/2,s===c?b=0:T<=.5?b=y/(s+c):b=y/(2-s-c),[v,b*100,T*100]};function cy(h){Array.isArray(h)&&h.raw&&(h=String.raw(...arguments)),h instanceof Number&&(h=+h);var e,r,a,c=Cb(h);if(!c.space)return[];let s=c.space[0]==="h"?Bp.min:xo.min,y=c.space[0]==="h"?Bp.max:xo.max;return e=Array(3),e[0]=Math.min(Math.max(c.values[0],s[0]),y[0]),e[1]=Math.min(Math.max(c.values[1],s[1]),y[1]),e[2]=Math.min(Math.max(c.values[2],s[2]),y[2]),c.space[0]==="h"&&(e=Bp.rgb(e)),e.push(Math.min(Math.max(c.alpha,0),1)),e}var Np=[NaN,NaN,NaN,0];function Eb(h){return typeof h=="string"?h:Pu(h)}var jI=1024,Tu={},hy=0;function Tb(h){if(h.length===4)return h;let e=h.slice();return e[3]=1,e}function uy(h){let e=wn.lchuv(xo.xyz(h));return e[3]=h[3],e}function Mb(h){let e=wn.rgb(bb.xyz(h));return e[3]=h[3],e}function Mu(h){if(h==="none")return Np;if(Tu.hasOwnProperty(h))return Tu[h];if(hy>=jI){let r=0;for(let a in Tu)r++&3||(delete Tu[a],--hy)}let e=cy(h);if(e.length!==4)throw new Error('failed to parse "'+h+'" as color');for(let r of e)if(isNaN(r))throw new Error('failed to parse "'+h+'" as color');return dy(e),Tu[h]=e,++hy,e}function Ms(h){return Array.isArray(h)?h:Mu(h)}function dy(h){return h[0]=Ii(h[0]+.5|0,0,255),h[1]=Ii(h[1]+.5|0,0,255),h[2]=Ii(h[2]+.5|0,0,255),h[3]=Ii(h[3],0,1),h}function Pu(h){let e=h[0];e!=(e|0)&&(e=e+.5|0);let r=h[1];r!=(r|0)&&(r=r+.5|0);let a=h[2];a!=(a|0)&&(a=a+.5|0);let c=h[3]===void 0?1:Math.round(h[3]*1e3)/1e3;return"rgba("+e+","+r+","+a+","+c+")"}var ya=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",lD=ya.includes("firefox"),GI=ya.includes("safari")&&!ya.includes("chrom"),cD=GI&&(ya.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(ya)),hD=ya.includes("webkit")&&!ya.includes("edge"),uD=ya.includes("macintosh");var Vp=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Pb=typeof Image<"u"&&Image.prototype.decode;var dD=function(){let h=!1;try{let e=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return h}();function Ri(h,e,r,a){let c;return r&&r.length?c=r.shift():Vp?c=new OffscreenCanvas(h||300,e||300):c=document.createElement("canvas"),h&&(c.width=h),e&&(c.height=e),c.getContext("2d",a)}var py;function kc(){return py||(py=Ri(1,1)),py}function Ab(h){let e=h.canvas;e.width=1,e.height=1,h.clearRect(0,0,1,1)}function UI(h,e){return new Promise((r,a)=>{function c(){y(),r(h)}function s(){y(),a(new Error("Image load error"))}function y(){h.removeEventListener("load",c),h.removeEventListener("error",s)}h.addEventListener("load",c),h.addEventListener("error",s),e&&(h.src=e)})}function Rb(h,e){return e&&(h.src=e),h.src&&Pb?new Promise((r,a)=>h.decode().then(()=>r(h)).catch(c=>h.complete&&h.width?r(h):a(c))):UI(h)}var my=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let r in this.cache_){let a=this.cache_[r];!(e++&3)&&!a.hasListener()&&(delete this.cache_[r],delete this.patternCache_[r],--this.cacheSize_)}}}get(e,r,a){let c=fy(e,r,a);return c in this.cache_?this.cache_[c]:null}getPattern(e,r,a){let c=fy(e,r,a);return c in this.patternCache_?this.patternCache_[c]:null}set(e,r,a,c,s){let y=fy(e,r,a),v=y in this.cache_;this.cache_[y]=c,s&&(c.getImageState()===It.IDLE&&c.load(),c.getImageState()===It.LOADING?c.ready().then(()=>{this.patternCache_[y]=kc().createPattern(c.getImage(1),"repeat")}):this.patternCache_[y]=kc().createPattern(c.getImage(1),"repeat")),v||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function fy(h,e,r){let a=r?Ms(r):"null";return e+":"+h+":"+a}var Xn=new my;var Au=null,jp=class extends hp{constructor(e,r,a,c,s){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=a,this.canvas_={},this.color_=s,this.imageState_=c===void 0?It.IDLE:c,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=r,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===It.LOADED){Au||(Au=Ri(1,1,void 0,{willReadFrequently:!0})),Au.drawImage(this.image_,0,0);try{Au.getImageData(0,0,1,1),this.tainted_=!1}catch{Au=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(pi.CHANGE)}handleImageError_(){this.imageState_=It.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=It.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],r=this.size_[1],a=Ri(e,r);a.fillRect(0,0,e,r),this.hitDetectionImage_=a.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===It.IDLE){this.image_||this.initializeImage_(),this.imageState_=It.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Rb(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==It.LOADED)return;let r=this.image_,a=Ri(Math.ceil(r.width*e),Math.ceil(r.height*e)),c=a.canvas;a.scale(e,e),a.drawImage(r,0,0),a.globalCompositeOperation="multiply",a.fillStyle=Eb(this.color_),a.fillRect(0,0,c.width/e,c.height/e),a.globalCompositeOperation="destination-in",a.drawImage(r,0,0),this.canvas_[e]=c}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===It.LOADED||this.imageState_===It.ERROR)e();else{let r=()=>{(this.imageState_===It.LOADED||this.imageState_===It.ERROR)&&(this.removeEventListener(pi.CHANGE,r),e())};this.addEventListener(pi.CHANGE,r)}})),this.ready_}};function Lc(h,e,r,a,c,s){let y=e===void 0?void 0:Xn.get(e,r,c);return y||(y=new jp(h,h&&"src"in h?h.src||void 0:e,r,a,c),Xn.set(e,r,c,y,s)),s&&y&&!Xn.getPattern(e,r,c)&&Xn.set(e,r,c,y,s),y}var kb=jp;var gy=class h{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){let r=Lc(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));r.ready().then(()=>{this.patternImage_=null}),r.getImageState()===It.IDLE&&r.load(),r.getImageState()===It.LOADING&&(this.patternImage_=r)}this.color_=e}getKey(){let e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?Vt(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:Ms(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Er=gy;var yy=class h{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}},Xi=yy;function qs(h,e){return Array.isArray(h)?h:(e===void 0?e=[h,h]:(e[0]=h,e[1]=h),e)}var _y=class h{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=qs(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return wt()}getImage(e){return wt()}getHitDetectionImage(){return wt()}getPixelRatio(e){return 1}getImageState(){return wt()}getImageSize(){return wt()}getOrigin(){return wt()}getSize(){return wt()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=qs(e)}listenImageChange(e){wt()}load(){wt()}unlistenImageChange(e){wt()}ready(){return Promise.resolve()}},Gp=_y;function Sn(h){return h?Array.isArray(h)?Pu(h):typeof h=="object"&&"src"in h?qI(h):h:null}function qI(h){if(!h.offset||!h.size)return Xn.getPattern(h.src,"anonymous",h.color);let e=h.src+":"+h.offset,r=Xn.getPattern(e,void 0,h.color);if(r)return r;let a=Xn.get(h.src,"anonymous",null);if(a.getImageState()!==It.LOADED)return null;let c=Ri(h.size[0],h.size[1]);return c.drawImage(a.getImage(1),h.offset[0],h.offset[1],h.size[0],h.size[1],0,0,h.size[0],h.size[1]),Lc(c.canvas,e,void 0,It.LOADED,h.color,!0),Xn.getPattern(e,void 0,h.color)}var $I=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`].join(""),"i"),Lb=["style","variant","weight","size","lineHeight","family"],xy=function(h){let e=h.match($I);if(!e)return null;let r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let a=0,c=Lb.length;a<c;++a){let s=e[a+1];s!==void 0&&(r[Lb[a]]=s)}return r.families=r.family.split(/,\s?/),r};var qp="10px sans-serif",Hi="#000",$s="round",In=[],Cn=0,Ws="round",vo=10,bo="#000",xa="center",pl="middle",wo=[0,0,0,0],So=1,_a=new or,Dc=null,vy,by={},Db=function(){let e="32px ",r=["monospace","serif"],a=r.length,c="wmytzilWMYTZIL@#/&?$%10\uF013",s,y;function v(T,C,k){let O=!0;for(let G=0;G<a;++G){let J=r[G];if(y=Up(T+" "+C+" "+e+J,c),k!=J){let le=Up(T+" "+C+" "+e+k+","+J,c);O=O&&le!=y}}return!!O}function b(){let T=!0,C=_a.getKeys();for(let k=0,O=C.length;k<O;++k){let G=C[k];if(_a.get(G)<100){let[J,le,he]=G.split(`
577
+ `),H=E.createShader(E.FRAGMENT_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(H,re),E.compileShader(H),!E.getShaderParameter(H,E.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${E.getShaderInfoLog(H)}`);E.attachShader(this.program,H);let ce=E.createShader(E.VERTEX_SHADER);if(E.isContextLost())return void(this.failedToCreate=!0);if(E.shaderSource(ce,ne),E.compileShader(ce),!E.getShaderParameter(ce,E.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${E.getShaderInfoLog(ce)}`);E.attachShader(this.program,ce),this.attributes={};let ue={};this.numAttributes=D.length;for(let ge=0;ge<this.numAttributes;ge++)D[ge]&&(E.bindAttribLocation(this.program,ge,D[ge]),this.attributes[D[ge]]=ge);if(E.linkProgram(this.program),!E.getProgramParameter(this.program,E.LINK_STATUS))throw new Error(`Program failed to link: ${E.getProgramInfoLog(this.program)}`);E.deleteShader(ce),E.deleteShader(H);for(let ge=0;ge<Y.length;ge++){let Te=Y[ge];if(Te&&!ue[Te]){let Le=E.getUniformLocation(this.program,Te);Le&&(ue[Te]=Le)}}this.fixedUniforms=p(t,ue),this.terrainUniforms=((ge,Te)=>({u_depth:new s.aH(ge,Te.u_depth),u_terrain:new s.aH(ge,Te.u_terrain),u_terrain_dim:new s.aI(ge,Te.u_terrain_dim),u_terrain_matrix:new s.aJ(ge,Te.u_terrain_matrix),u_terrain_unpack:new s.aK(ge,Te.u_terrain_unpack),u_terrain_exaggeration:new s.aI(ge,Te.u_terrain_exaggeration)}))(t,ue),this.binderUniforms=d?d.getUniforms(t,ue):[]}draw(t,l,d,p,m,S,E,M,R,D,F,j,W,Z,Y,te,re,ne){let H=t.gl;if(this.failedToCreate)return;if(t.program.set(this.program),t.setDepthMode(d),t.setStencilMode(p),t.setColorMode(m),t.setCullFace(S),M){t.activeTexture.set(H.TEXTURE2),H.bindTexture(H.TEXTURE_2D,M.depthTexture),t.activeTexture.set(H.TEXTURE3),H.bindTexture(H.TEXTURE_2D,M.texture);for(let ue in this.terrainUniforms)this.terrainUniforms[ue].set(M[ue])}for(let ue in this.fixedUniforms)this.fixedUniforms[ue].set(E[ue]);Y&&Y.setUniforms(t,this.binderUniforms,W,{zoom:Z});let ce=0;switch(l){case H.LINES:ce=2;break;case H.TRIANGLES:ce=3;break;case H.LINE_STRIP:ce=1}for(let ue of j.get()){let ge=ue.vaos||(ue.vaos={});(ge[R]||(ge[R]=new Zc)).bind(t,this,D,Y?Y.getPaintVertexBuffers():[],F,ue.vertexOffset,te,re,ne),H.drawElements(l,ue.primitiveLength*ce,H.UNSIGNED_SHORT,ue.primitiveOffset*ce*2)}}}function Sl(g,t,l){let d=1/Dt(l,1,t.transform.tileZoom),p=Math.pow(2,l.tileID.overscaledZ),m=l.tileSize*Math.pow(2,t.transform.tileZoom)/p,S=m*(l.tileID.canonical.x+l.tileID.wrap*p),E=m*l.tileID.canonical.y;return{u_image:0,u_texsize:l.imageAtlasTexture.size,u_scale:[d,g.fromScale,g.toScale],u_fade:g.t,u_pixel_coord_upper:[S>>16,E>>16],u_pixel_coord_lower:[65535&S,65535&E]}}let Pa=(g,t,l,d)=>{let p=t.style.light,m=p.properties.get("position"),S=[m.x,m.y,m.z],E=function(){var R=new s.A(9);return s.A!=Float32Array&&(R[1]=0,R[2]=0,R[3]=0,R[5]=0,R[6]=0,R[7]=0),R[0]=1,R[4]=1,R[8]=1,R}();p.properties.get("anchor")==="viewport"&&function(R,D){var F=Math.sin(D),j=Math.cos(D);R[0]=j,R[1]=F,R[2]=0,R[3]=-F,R[4]=j,R[5]=0,R[6]=0,R[7]=0,R[8]=1}(E,-t.transform.angle),function(R,D,F){var j=D[0],W=D[1],Z=D[2];R[0]=j*F[0]+W*F[3]+Z*F[6],R[1]=j*F[1]+W*F[4]+Z*F[7],R[2]=j*F[2]+W*F[5]+Z*F[8]}(S,S,E);let M=p.properties.get("color");return{u_matrix:g,u_lightpos:S,u_lightintensity:p.properties.get("intensity"),u_lightcolor:[M.r,M.g,M.b],u_vertical_gradient:+l,u_opacity:d}},Il=(g,t,l,d,p,m,S)=>s.e(Pa(g,t,l,d),Sl(m,t,S),{u_height_factor:-Math.pow(2,p.overscaledZ)/S.tileSize/8}),ko=g=>({u_matrix:g}),ed=(g,t,l,d)=>s.e(ko(g),Sl(l,t,d)),xf=(g,t)=>({u_matrix:g,u_world:t}),td=(g,t,l,d,p)=>s.e(ed(g,t,l,d),{u_world:p}),vf=(g,t,l,d)=>{let p=g.transform,m,S;if(d.paint.get("circle-pitch-alignment")==="map"){let E=Dt(l,1,p.zoom);m=!0,S=[E,E]}else m=!1,S=p.pixelsToGLUnits;return{u_camera_to_center_distance:p.cameraToCenterDistance,u_scale_with_map:+(d.paint.get("circle-pitch-scale")==="map"),u_matrix:g.translatePosMatrix(t.posMatrix,l,d.paint.get("circle-translate"),d.paint.get("circle-translate-anchor")),u_pitch_with_map:+m,u_device_pixel_ratio:g.pixelRatio,u_extrude_scale:S}},eo=(g,t,l)=>({u_matrix:g,u_inv_matrix:t,u_camera_to_center_distance:l.cameraToCenterDistance,u_viewport_size:[l.width,l.height]}),Aa=(g,t,l=1)=>({u_matrix:g,u_color:t,u_overlay:0,u_overlay_scale:l}),kr=g=>({u_matrix:g}),Lr=(g,t,l,d)=>({u_matrix:g,u_extrude_scale:Dt(t,1,l),u_intensity:d}),Cl=(g,t,l,d)=>{let p=s.H();s.aP(p,0,g.width,g.height,0,0,1);let m=g.context.gl;return{u_matrix:p,u_world:[m.drawingBufferWidth,m.drawingBufferHeight],u_image:l,u_color_ramp:d,u_opacity:t.paint.get("heatmap-opacity")}};function El(g,t){let l=Math.pow(2,t.canonical.z),d=t.canonical.y;return[new s.Z(0,d/l).toLngLat().lat,new s.Z(0,(d+1)/l).toLngLat().lat]}let Tl=(g,t,l,d)=>{let p=g.transform;return{u_matrix:nd(g,t,l,d),u_ratio:1/Dt(t,1,p.zoom),u_device_pixel_ratio:g.pixelRatio,u_units_to_pixels:[1/p.pixelsToGLUnits[0],1/p.pixelsToGLUnits[1]]}},id=(g,t,l,d,p)=>s.e(Tl(g,t,l,p),{u_image:0,u_image_height:d}),Lo=(g,t,l,d,p)=>{let m=g.transform,S=rd(t,m);return{u_matrix:nd(g,t,l,p),u_texsize:t.imageAtlasTexture.size,u_ratio:1/Dt(t,1,m.zoom),u_device_pixel_ratio:g.pixelRatio,u_image:0,u_scale:[S,d.fromScale,d.toScale],u_fade:d.t,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},bf=(g,t,l,d,p,m)=>{let S=g.lineAtlas,E=rd(t,g.transform),M=l.layout.get("line-cap")==="round",R=S.getDash(d.from,M),D=S.getDash(d.to,M),F=R.width*p.fromScale,j=D.width*p.toScale;return s.e(Tl(g,t,l,m),{u_patternscale_a:[E/F,-R.height/2],u_patternscale_b:[E/j,-D.height/2],u_sdfgamma:S.width/(256*Math.min(F,j)*g.pixelRatio)/2,u_image:0,u_tex_y_a:R.y,u_tex_y_b:D.y,u_mix:p.t})};function rd(g,t){return 1/Dt(g,1,t.tileZoom)}function nd(g,t,l,d){return g.translatePosMatrix(d?d.posMatrix:t.tileID.posMatrix,t,l.paint.get("line-translate"),l.paint.get("line-translate-anchor"))}let wf=(g,t,l,d,p)=>{return{u_matrix:g,u_tl_parent:t,u_scale_parent:l,u_buffer_scale:1,u_fade_t:d.mix,u_opacity:d.opacity*p.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:p.paint.get("raster-brightness-min"),u_brightness_high:p.paint.get("raster-brightness-max"),u_saturation_factor:(S=p.paint.get("raster-saturation"),S>0?1-1/(1.001-S):-S),u_contrast_factor:(m=p.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:Sf(p.paint.get("raster-hue-rotate"))};var m,S};function Sf(g){g*=Math.PI/180;let t=Math.sin(g),l=Math.cos(g);return[(2*l+1)/3,(-Math.sqrt(3)*t-l+1)/3,(Math.sqrt(3)*t-l+1)/3]}let sd=(g,t,l,d,p,m,S,E,M,R,D,F,j,W)=>{let Z=S.transform;return{u_is_size_zoom_constant:+(g==="constant"||g==="source"),u_is_size_feature_constant:+(g==="constant"||g==="camera"),u_size_t:t?t.uSizeT:0,u_size:t?t.uSize:0,u_camera_to_center_distance:Z.cameraToCenterDistance,u_pitch:Z.pitch/360*2*Math.PI,u_rotate_symbol:+l,u_aspect_ratio:Z.width/Z.height,u_fade_change:S.options.fadeDuration?S.symbolFadeChange:1,u_matrix:E,u_label_plane_matrix:M,u_coord_matrix:R,u_is_text:+F,u_pitch_with_map:+d,u_is_along_line:p,u_is_variable_anchor:m,u_texsize:j,u_texture:0,u_translation:D,u_pitched_scale:W}},Ra=(g,t,l,d,p,m,S,E,M,R,D,F,j,W,Z)=>{let Y=S.transform;return s.e(sd(g,t,l,d,p,m,S,E,M,R,D,F,j,Z),{u_gamma_scale:d?Math.cos(Y._pitch)*Y.cameraToCenterDistance:1,u_device_pixel_ratio:S.pixelRatio,u_is_halo:+W})},Kc=(g,t,l,d,p,m,S,E,M,R,D,F,j,W)=>s.e(Ra(g,t,l,d,p,m,S,E,M,R,D,!0,F,!0,W),{u_texsize_icon:j,u_texture_icon:1}),Ml=(g,t,l)=>({u_matrix:g,u_opacity:t,u_color:l}),Yc=(g,t,l,d,p,m)=>s.e(function(S,E,M,R){let D=M.imageManager.getPattern(S.from.toString()),F=M.imageManager.getPattern(S.to.toString()),{width:j,height:W}=M.imageManager.getPixelSize(),Z=Math.pow(2,R.tileID.overscaledZ),Y=R.tileSize*Math.pow(2,M.transform.tileZoom)/Z,te=Y*(R.tileID.canonical.x+R.tileID.wrap*Z),re=Y*R.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:D.tl,u_pattern_br_a:D.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[j,W],u_mix:E.t,u_pattern_size_a:D.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:E.fromScale,u_scale_b:E.toScale,u_tile_units_to_pixels:1/Dt(R,1,M.transform.tileZoom),u_pixel_coord_upper:[te>>16,re>>16],u_pixel_coord_lower:[65535&te,65535&re]}}(d,m,l,p),{u_matrix:g,u_opacity:t}),Jc={fillExtrusion:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_lightpos:new s.aN(g,t.u_lightpos),u_lightintensity:new s.aI(g,t.u_lightintensity),u_lightcolor:new s.aN(g,t.u_lightcolor),u_vertical_gradient:new s.aI(g,t.u_vertical_gradient),u_opacity:new s.aI(g,t.u_opacity)}),fillExtrusionPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_lightpos:new s.aN(g,t.u_lightpos),u_lightintensity:new s.aI(g,t.u_lightintensity),u_lightcolor:new s.aN(g,t.u_lightcolor),u_vertical_gradient:new s.aI(g,t.u_vertical_gradient),u_height_factor:new s.aI(g,t.u_height_factor),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade),u_opacity:new s.aI(g,t.u_opacity)}),fill:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix)}),fillPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),fillOutline:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world)}),fillOutlinePattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world),u_image:new s.aH(g,t.u_image),u_texsize:new s.aO(g,t.u_texsize),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),circle:(g,t)=>({u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_scale_with_map:new s.aH(g,t.u_scale_with_map),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_extrude_scale:new s.aO(g,t.u_extrude_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_matrix:new s.aJ(g,t.u_matrix)}),collisionBox:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_pixel_extrude_scale:new s.aO(g,t.u_pixel_extrude_scale)}),collisionCircle:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_inv_matrix:new s.aJ(g,t.u_inv_matrix),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_viewport_size:new s.aO(g,t.u_viewport_size)}),debug:(g,t)=>({u_color:new s.aL(g,t.u_color),u_matrix:new s.aJ(g,t.u_matrix),u_overlay:new s.aH(g,t.u_overlay),u_overlay_scale:new s.aI(g,t.u_overlay_scale)}),clippingMask:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix)}),heatmap:(g,t)=>({u_extrude_scale:new s.aI(g,t.u_extrude_scale),u_intensity:new s.aI(g,t.u_intensity),u_matrix:new s.aJ(g,t.u_matrix)}),heatmapTexture:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_world:new s.aO(g,t.u_world),u_image:new s.aH(g,t.u_image),u_color_ramp:new s.aH(g,t.u_color_ramp),u_opacity:new s.aI(g,t.u_opacity)}),hillshade:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_latrange:new s.aO(g,t.u_latrange),u_light:new s.aO(g,t.u_light),u_shadow:new s.aL(g,t.u_shadow),u_highlight:new s.aL(g,t.u_highlight),u_accent:new s.aL(g,t.u_accent)}),hillshadePrepare:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_image:new s.aH(g,t.u_image),u_dimension:new s.aO(g,t.u_dimension),u_zoom:new s.aI(g,t.u_zoom),u_unpack:new s.aK(g,t.u_unpack)}),line:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels)}),lineGradient:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_image:new s.aH(g,t.u_image),u_image_height:new s.aI(g,t.u_image_height)}),linePattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texsize:new s.aO(g,t.u_texsize),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_image:new s.aH(g,t.u_image),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_scale:new s.aN(g,t.u_scale),u_fade:new s.aI(g,t.u_fade)}),lineSDF:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ratio:new s.aI(g,t.u_ratio),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_units_to_pixels:new s.aO(g,t.u_units_to_pixels),u_patternscale_a:new s.aO(g,t.u_patternscale_a),u_patternscale_b:new s.aO(g,t.u_patternscale_b),u_sdfgamma:new s.aI(g,t.u_sdfgamma),u_image:new s.aH(g,t.u_image),u_tex_y_a:new s.aI(g,t.u_tex_y_a),u_tex_y_b:new s.aI(g,t.u_tex_y_b),u_mix:new s.aI(g,t.u_mix)}),raster:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_tl_parent:new s.aO(g,t.u_tl_parent),u_scale_parent:new s.aI(g,t.u_scale_parent),u_buffer_scale:new s.aI(g,t.u_buffer_scale),u_fade_t:new s.aI(g,t.u_fade_t),u_opacity:new s.aI(g,t.u_opacity),u_image0:new s.aH(g,t.u_image0),u_image1:new s.aH(g,t.u_image1),u_brightness_low:new s.aI(g,t.u_brightness_low),u_brightness_high:new s.aI(g,t.u_brightness_high),u_saturation_factor:new s.aI(g,t.u_saturation_factor),u_contrast_factor:new s.aI(g,t.u_contrast_factor),u_spin_weights:new s.aN(g,t.u_spin_weights)}),symbolIcon:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texture:new s.aH(g,t.u_texture),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),symbolSDF:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texture:new s.aH(g,t.u_texture),u_gamma_scale:new s.aI(g,t.u_gamma_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_is_halo:new s.aH(g,t.u_is_halo),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),symbolTextAndIcon:(g,t)=>({u_is_size_zoom_constant:new s.aH(g,t.u_is_size_zoom_constant),u_is_size_feature_constant:new s.aH(g,t.u_is_size_feature_constant),u_size_t:new s.aI(g,t.u_size_t),u_size:new s.aI(g,t.u_size),u_camera_to_center_distance:new s.aI(g,t.u_camera_to_center_distance),u_pitch:new s.aI(g,t.u_pitch),u_rotate_symbol:new s.aH(g,t.u_rotate_symbol),u_aspect_ratio:new s.aI(g,t.u_aspect_ratio),u_fade_change:new s.aI(g,t.u_fade_change),u_matrix:new s.aJ(g,t.u_matrix),u_label_plane_matrix:new s.aJ(g,t.u_label_plane_matrix),u_coord_matrix:new s.aJ(g,t.u_coord_matrix),u_is_text:new s.aH(g,t.u_is_text),u_pitch_with_map:new s.aH(g,t.u_pitch_with_map),u_is_along_line:new s.aH(g,t.u_is_along_line),u_is_variable_anchor:new s.aH(g,t.u_is_variable_anchor),u_texsize:new s.aO(g,t.u_texsize),u_texsize_icon:new s.aO(g,t.u_texsize_icon),u_texture:new s.aH(g,t.u_texture),u_texture_icon:new s.aH(g,t.u_texture_icon),u_gamma_scale:new s.aI(g,t.u_gamma_scale),u_device_pixel_ratio:new s.aI(g,t.u_device_pixel_ratio),u_is_halo:new s.aH(g,t.u_is_halo),u_translation:new s.aO(g,t.u_translation),u_pitched_scale:new s.aI(g,t.u_pitched_scale)}),background:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_opacity:new s.aI(g,t.u_opacity),u_color:new s.aL(g,t.u_color)}),backgroundPattern:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_opacity:new s.aI(g,t.u_opacity),u_image:new s.aH(g,t.u_image),u_pattern_tl_a:new s.aO(g,t.u_pattern_tl_a),u_pattern_br_a:new s.aO(g,t.u_pattern_br_a),u_pattern_tl_b:new s.aO(g,t.u_pattern_tl_b),u_pattern_br_b:new s.aO(g,t.u_pattern_br_b),u_texsize:new s.aO(g,t.u_texsize),u_mix:new s.aI(g,t.u_mix),u_pattern_size_a:new s.aO(g,t.u_pattern_size_a),u_pattern_size_b:new s.aO(g,t.u_pattern_size_b),u_scale_a:new s.aI(g,t.u_scale_a),u_scale_b:new s.aI(g,t.u_scale_b),u_pixel_coord_upper:new s.aO(g,t.u_pixel_coord_upper),u_pixel_coord_lower:new s.aO(g,t.u_pixel_coord_lower),u_tile_units_to_pixels:new s.aI(g,t.u_tile_units_to_pixels)}),terrain:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texture:new s.aH(g,t.u_texture),u_ele_delta:new s.aI(g,t.u_ele_delta),u_fog_matrix:new s.aJ(g,t.u_fog_matrix),u_fog_color:new s.aL(g,t.u_fog_color),u_fog_ground_blend:new s.aI(g,t.u_fog_ground_blend),u_fog_ground_blend_opacity:new s.aI(g,t.u_fog_ground_blend_opacity),u_horizon_color:new s.aL(g,t.u_horizon_color),u_horizon_fog_blend:new s.aI(g,t.u_horizon_fog_blend)}),terrainDepth:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_ele_delta:new s.aI(g,t.u_ele_delta)}),terrainCoords:(g,t)=>({u_matrix:new s.aJ(g,t.u_matrix),u_texture:new s.aH(g,t.u_texture),u_terrain_coords_id:new s.aI(g,t.u_terrain_coords_id),u_ele_delta:new s.aI(g,t.u_ele_delta)}),sky:(g,t)=>({u_sky_color:new s.aL(g,t.u_sky_color),u_horizon_color:new s.aL(g,t.u_horizon_color),u_horizon:new s.aI(g,t.u_horizon),u_sky_horizon_blend:new s.aI(g,t.u_sky_horizon_blend)})};class Qn{constructor(t,l,d){this.context=t;let p=t.gl;this.buffer=p.createBuffer(),this.dynamicDraw=!!d,this.context.unbindVAO(),t.bindElementBuffer.set(this.buffer),p.bufferData(p.ELEMENT_ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?p.DYNAMIC_DRAW:p.STATIC_DRAW),this.dynamicDraw||delete l.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(t){let l=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),l.bufferSubData(l.ELEMENT_ARRAY_BUFFER,0,t.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let If={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Qc{constructor(t,l,d,p){this.length=l.length,this.attributes=d,this.itemSize=l.bytesPerElement,this.dynamicDraw=p,this.context=t;let m=t.gl;this.buffer=m.createBuffer(),t.bindVertexBuffer.set(this.buffer),m.bufferData(m.ARRAY_BUFFER,l.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||delete l.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}`);let l=this.context.gl;this.bind(),l.bufferSubData(l.ARRAY_BUFFER,0,t.arrayBuffer)}enableAttributes(t,l){for(let d=0;d<this.attributes.length;d++){let p=l.attributes[this.attributes[d].name];p!==void 0&&t.enableVertexAttribArray(p)}}setVertexAttribPointers(t,l,d){for(let p=0;p<this.attributes.length;p++){let m=this.attributes[p],S=l.attributes[m.name];S!==void 0&&t.vertexAttribPointer(S,m.components,t[If[m.type]],!1,this.itemSize,m.offset+this.itemSize*(d||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}let to=new WeakMap;function Ls(g){var t;if(to.has(g))return to.get(g);{let l=(t=g.getParameter(g.VERSION))===null||t===void 0?void 0:t.startsWith("WebGL 2.0");return to.set(g,l),l}}class Wt{constructor(t){this.gl=t.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(t){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class Pl extends Wt{getDefault(){return s.aM.transparent}set(t){let l=this.current;(t.r!==l.r||t.g!==l.g||t.b!==l.b||t.a!==l.a||this.dirty)&&(this.gl.clearColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class Cf extends Wt{getDefault(){return 1}set(t){(t!==this.current||this.dirty)&&(this.gl.clearDepth(t),this.current=t,this.dirty=!1)}}class Do extends Wt{getDefault(){return 0}set(t){(t!==this.current||this.dirty)&&(this.gl.clearStencil(t),this.current=t,this.dirty=!1)}}class Ef extends Wt{getDefault(){return[!0,!0,!0,!0]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||t[3]!==l[3]||this.dirty)&&(this.gl.colorMask(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class od extends Wt{getDefault(){return!0}set(t){(t!==this.current||this.dirty)&&(this.gl.depthMask(t),this.current=t,this.dirty=!1)}}class Tf extends Wt{getDefault(){return 255}set(t){(t!==this.current||this.dirty)&&(this.gl.stencilMask(t),this.current=t,this.dirty=!1)}}class ad extends Wt{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(t){let l=this.current;(t.func!==l.func||t.ref!==l.ref||t.mask!==l.mask||this.dirty)&&(this.gl.stencilFunc(t.func,t.ref,t.mask),this.current=t,this.dirty=!1)}}class eh extends Wt{getDefault(){let t=this.gl;return[t.KEEP,t.KEEP,t.KEEP]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||this.dirty)&&(this.gl.stencilOp(t[0],t[1],t[2]),this.current=t,this.dirty=!1)}}class ld extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.STENCIL_TEST):l.disable(l.STENCIL_TEST),this.current=t,this.dirty=!1}}class cd extends Wt{getDefault(){return[0,1]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||this.dirty)&&(this.gl.depthRange(t[0],t[1]),this.current=t,this.dirty=!1)}}class hd extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.DEPTH_TEST):l.disable(l.DEPTH_TEST),this.current=t,this.dirty=!1}}class ud extends Wt{getDefault(){return this.gl.LESS}set(t){(t!==this.current||this.dirty)&&(this.gl.depthFunc(t),this.current=t,this.dirty=!1)}}class io extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.BLEND):l.disable(l.BLEND),this.current=t,this.dirty=!1}}class dd extends Wt{getDefault(){let t=this.gl;return[t.ONE,t.ZERO]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||this.dirty)&&(this.gl.blendFunc(t[0],t[1]),this.current=t,this.dirty=!1)}}class Mf extends Wt{getDefault(){return s.aM.transparent}set(t){let l=this.current;(t.r!==l.r||t.g!==l.g||t.b!==l.b||t.a!==l.a||this.dirty)&&(this.gl.blendColor(t.r,t.g,t.b,t.a),this.current=t,this.dirty=!1)}}class pd extends Wt{getDefault(){return this.gl.FUNC_ADD}set(t){(t!==this.current||this.dirty)&&(this.gl.blendEquation(t),this.current=t,this.dirty=!1)}}class ka extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;t?l.enable(l.CULL_FACE):l.disable(l.CULL_FACE),this.current=t,this.dirty=!1}}class Pf extends Wt{getDefault(){return this.gl.BACK}set(t){(t!==this.current||this.dirty)&&(this.gl.cullFace(t),this.current=t,this.dirty=!1)}}class Al extends Wt{getDefault(){return this.gl.CCW}set(t){(t!==this.current||this.dirty)&&(this.gl.frontFace(t),this.current=t,this.dirty=!1)}}class Af extends Wt{getDefault(){return null}set(t){(t!==this.current||this.dirty)&&(this.gl.useProgram(t),this.current=t,this.dirty=!1)}}class Rf extends Wt{getDefault(){return this.gl.TEXTURE0}set(t){(t!==this.current||this.dirty)&&(this.gl.activeTexture(t),this.current=t,this.dirty=!1)}}class fd extends Wt{getDefault(){let t=this.gl;return[0,0,t.drawingBufferWidth,t.drawingBufferHeight]}set(t){let l=this.current;(t[0]!==l[0]||t[1]!==l[1]||t[2]!==l[2]||t[3]!==l[3]||this.dirty)&&(this.gl.viewport(t[0],t[1],t[2],t[3]),this.current=t,this.dirty=!1)}}class md extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindFramebuffer(l.FRAMEBUFFER,t),this.current=t,this.dirty=!1}}class gd extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindRenderbuffer(l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class th extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindTexture(l.TEXTURE_2D,t),this.current=t,this.dirty=!1}}class yd extends Wt{getDefault(){return null}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.bindBuffer(l.ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class Rl extends Wt{getDefault(){return null}set(t){let l=this.gl;l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,t),this.current=t,this.dirty=!1}}class ds extends Wt{getDefault(){return null}set(t){var l;if(t===this.current&&!this.dirty)return;let d=this.gl;Ls(d)?d.bindVertexArray(t):(l=d.getExtension("OES_vertex_array_object"))===null||l===void 0||l.bindVertexArrayOES(t),this.current=t,this.dirty=!1}}class ih extends Wt{getDefault(){return 4}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_ALIGNMENT,t),this.current=t,this.dirty=!1}}class rh extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_PREMULTIPLY_ALPHA_WEBGL,t),this.current=t,this.dirty=!1}}class nh extends Wt{getDefault(){return!1}set(t){if(t===this.current&&!this.dirty)return;let l=this.gl;l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,t),this.current=t,this.dirty=!1}}class kl extends Wt{constructor(t,l){super(t),this.context=t,this.parent=l}getDefault(){return null}}class sh extends kl{setDirty(){this.dirty=!0}set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,t,0),this.current=t,this.dirty=!1}}class ro extends kl{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class oh extends kl{set(t){if(t===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);let l=this.gl;l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_STENCIL_ATTACHMENT,l.RENDERBUFFER,t),this.current=t,this.dirty=!1}}class kf{constructor(t,l,d,p,m){this.context=t,this.width=l,this.height=d;let S=t.gl,E=this.framebuffer=S.createFramebuffer();if(this.colorAttachment=new sh(t,E),p)this.depthAttachment=m?new oh(t,E):new ro(t,E);else if(m)throw new Error("Stencil cannot be set without depth");if(S.checkFramebufferStatus(S.FRAMEBUFFER)!==S.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){let t=this.context.gl,l=this.colorAttachment.get();if(l&&t.deleteTexture(l),this.depthAttachment){let d=this.depthAttachment.get();d&&t.deleteRenderbuffer(d)}t.deleteFramebuffer(this.framebuffer)}}class yi{constructor(t,l,d){this.blendFunction=t,this.blendColor=l,this.mask=d}}yi.Replace=[1,0],yi.disabled=new yi(yi.Replace,s.aM.transparent,[!1,!1,!1,!1]),yi.unblended=new yi(yi.Replace,s.aM.transparent,[!0,!0,!0,!0]),yi.alphaBlended=new yi([1,771],s.aM.transparent,[!0,!0,!0,!0]);class Lf{constructor(t){var l,d;if(this.gl=t,this.clearColor=new Pl(this),this.clearDepth=new Cf(this),this.clearStencil=new Do(this),this.colorMask=new Ef(this),this.depthMask=new od(this),this.stencilMask=new Tf(this),this.stencilFunc=new ad(this),this.stencilOp=new eh(this),this.stencilTest=new ld(this),this.depthRange=new cd(this),this.depthTest=new hd(this),this.depthFunc=new ud(this),this.blend=new io(this),this.blendFunc=new dd(this),this.blendColor=new Mf(this),this.blendEquation=new pd(this),this.cullFace=new ka(this),this.cullFaceSide=new Pf(this),this.frontFace=new Al(this),this.program=new Af(this),this.activeTexture=new Rf(this),this.viewport=new fd(this),this.bindFramebuffer=new md(this),this.bindRenderbuffer=new gd(this),this.bindTexture=new th(this),this.bindVertexBuffer=new yd(this),this.bindElementBuffer=new Rl(this),this.bindVertexArray=new ds(this),this.pixelStoreUnpack=new ih(this),this.pixelStoreUnpackPremultiplyAlpha=new rh(this),this.pixelStoreUnpackFlipY=new nh(this),this.extTextureFilterAnisotropic=t.getExtension("EXT_texture_filter_anisotropic")||t.getExtension("MOZ_EXT_texture_filter_anisotropic")||t.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=t.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=t.getParameter(t.MAX_TEXTURE_SIZE),Ls(t)){this.HALF_FLOAT=t.HALF_FLOAT;let p=t.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(l=t.RGBA16F)!==null&&l!==void 0?l:p?.RGBA16F_EXT,this.RGB16F=(d=t.RGB16F)!==null&&d!==void 0?d:p?.RGB16F_EXT,t.getExtension("EXT_color_buffer_float")}else{t.getExtension("EXT_color_buffer_half_float"),t.getExtension("OES_texture_half_float_linear");let p=t.getExtension("OES_texture_half_float");this.HALF_FLOAT=p?.HALF_FLOAT_OES}}setDefault(){this.unbindVAO(),this.clearColor.setDefault(),this.clearDepth.setDefault(),this.clearStencil.setDefault(),this.colorMask.setDefault(),this.depthMask.setDefault(),this.stencilMask.setDefault(),this.stencilFunc.setDefault(),this.stencilOp.setDefault(),this.stencilTest.setDefault(),this.depthRange.setDefault(),this.depthTest.setDefault(),this.depthFunc.setDefault(),this.blend.setDefault(),this.blendFunc.setDefault(),this.blendColor.setDefault(),this.blendEquation.setDefault(),this.cullFace.setDefault(),this.cullFaceSide.setDefault(),this.frontFace.setDefault(),this.program.setDefault(),this.activeTexture.setDefault(),this.bindFramebuffer.setDefault(),this.pixelStoreUnpack.setDefault(),this.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.pixelStoreUnpackFlipY.setDefault()}setDirty(){this.clearColor.dirty=!0,this.clearDepth.dirty=!0,this.clearStencil.dirty=!0,this.colorMask.dirty=!0,this.depthMask.dirty=!0,this.stencilMask.dirty=!0,this.stencilFunc.dirty=!0,this.stencilOp.dirty=!0,this.stencilTest.dirty=!0,this.depthRange.dirty=!0,this.depthTest.dirty=!0,this.depthFunc.dirty=!0,this.blend.dirty=!0,this.blendFunc.dirty=!0,this.blendColor.dirty=!0,this.blendEquation.dirty=!0,this.cullFace.dirty=!0,this.cullFaceSide.dirty=!0,this.frontFace.dirty=!0,this.program.dirty=!0,this.activeTexture.dirty=!0,this.viewport.dirty=!0,this.bindFramebuffer.dirty=!0,this.bindRenderbuffer.dirty=!0,this.bindTexture.dirty=!0,this.bindVertexBuffer.dirty=!0,this.bindElementBuffer.dirty=!0,this.bindVertexArray.dirty=!0,this.pixelStoreUnpack.dirty=!0,this.pixelStoreUnpackPremultiplyAlpha.dirty=!0,this.pixelStoreUnpackFlipY.dirty=!0}createIndexBuffer(t,l){return new Qn(this,t,l)}createVertexBuffer(t,l,d){return new Qc(this,t,l,d)}createRenderbuffer(t,l,d){let p=this.gl,m=p.createRenderbuffer();return this.bindRenderbuffer.set(m),p.renderbufferStorage(p.RENDERBUFFER,t,l,d),this.bindRenderbuffer.set(null),m}createFramebuffer(t,l,d,p){return new kf(this,t,l,d,p)}clear({color:t,depth:l,stencil:d}){let p=this.gl,m=0;t&&(m|=p.COLOR_BUFFER_BIT,this.clearColor.set(t),this.colorMask.set([!0,!0,!0,!0])),l!==void 0&&(m|=p.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(l),this.depthMask.set(!0)),d!==void 0&&(m|=p.STENCIL_BUFFER_BIT,this.clearStencil.set(d),this.stencilMask.set(255)),p.clear(m)}setCullFace(t){t.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(t.mode),this.frontFace.set(t.frontFace))}setDepthMode(t){t.func!==this.gl.ALWAYS||t.mask?(this.depthTest.set(!0),this.depthFunc.set(t.func),this.depthMask.set(t.mask),this.depthRange.set(t.range)):this.depthTest.set(!1)}setStencilMode(t){t.test.func!==this.gl.ALWAYS||t.mask?(this.stencilTest.set(!0),this.stencilMask.set(t.mask),this.stencilOp.set([t.fail,t.depthFail,t.pass]),this.stencilFunc.set({func:t.test.func,ref:t.ref,mask:t.test.mask})):this.stencilTest.set(!1)}setColorMode(t){s.aE(t.blendFunction,yi.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(t.blendFunction),this.blendColor.set(t.blendColor)),this.colorMask.set(t.mask)}createVertexArray(){var t;return Ls(this.gl)?this.gl.createVertexArray():(t=this.gl.getExtension("OES_vertex_array_object"))===null||t===void 0?void 0:t.createVertexArrayOES()}deleteVertexArray(t){var l;return Ls(this.gl)?this.gl.deleteVertexArray(t):(l=this.gl.getExtension("OES_vertex_array_object"))===null||l===void 0?void 0:l.deleteVertexArrayOES(t)}unbindVAO(){this.bindVertexArray.set(null)}}class At{constructor(t,l,d){this.func=t,this.mask=l,this.range=d}}At.ReadOnly=!1,At.ReadWrite=!0,At.disabled=new At(519,At.ReadOnly,[0,1]);let Ll=7680;class ii{constructor(t,l,d,p,m,S){this.test=t,this.ref=l,this.mask=d,this.fail=p,this.depthFail=m,this.pass=S}}ii.disabled=new ii({func:519,mask:0},0,0,Ll,Ll,Ll);class Kt{constructor(t,l,d){this.enable=t,this.mode=l,this.frontFace=d}}let no;function La(g,t,l,d,p){let m=g.context,S=m.gl,E=g.useProgram("collisionBox"),M=[],R=0,D=0;for(let re=0;re<d.length;re++){let ne=d[re],H=t.getTile(ne).getBucket(l);if(!H)continue;let ce=p?H.textCollisionBox:H.iconCollisionBox,ue=H.collisionCircleArray;if(ue.length>0){let ge=s.H();s.aQ(ge,H.placementInvProjMatrix,g.transform.glCoordMatrix),s.aQ(ge,ge,H.placementViewportMatrix),M.push({circleArray:ue,circleOffset:D,transform:ne.posMatrix,invTransform:ge,coord:ne}),R+=ue.length/4,D=R}ce&&E.draw(m,S.LINES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,{u_matrix:ne.posMatrix,u_pixel_extrude_scale:[1/(F=g.transform).width,1/F.height]},g.style.map.terrain&&g.style.map.terrain.getTerrainData(ne),l.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,null,g.transform.zoom,null,null,ce.collisionVertexBuffer)}var F;if(!p||!M.length)return;let j=g.useProgram("collisionCircle"),W=new s.aR;W.resize(4*R),W._trim();let Z=0;for(let re of M)for(let ne=0;ne<re.circleArray.length/4;ne++){let H=4*ne,ce=re.circleArray[H+0],ue=re.circleArray[H+1],ge=re.circleArray[H+2],Te=re.circleArray[H+3];W.emplace(Z++,ce,ue,ge,Te,0),W.emplace(Z++,ce,ue,ge,Te,1),W.emplace(Z++,ce,ue,ge,Te,2),W.emplace(Z++,ce,ue,ge,Te,3)}(!no||no.length<2*R)&&(no=function(re){let ne=2*re,H=new s.aT;H.resize(ne),H._trim();for(let ce=0;ce<ne;ce++){let ue=6*ce;H.uint16[ue+0]=4*ce+0,H.uint16[ue+1]=4*ce+1,H.uint16[ue+2]=4*ce+2,H.uint16[ue+3]=4*ce+2,H.uint16[ue+4]=4*ce+3,H.uint16[ue+5]=4*ce+0}return H}(R));let Y=m.createIndexBuffer(no,!0),te=m.createVertexBuffer(W,s.aS.members,!0);for(let re of M){let ne=eo(re.transform,re.invTransform,g.transform);j.draw(m,S.TRIANGLES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,ne,g.style.map.terrain&&g.style.map.terrain.getTerrainData(re.coord),l.id,te,Y,s.a0.simpleSegment(0,2*re.circleOffset,re.circleArray.length,re.circleArray.length/2),null,g.transform.zoom,null,null,null)}te.destroy(),Y.destroy()}Kt.disabled=new Kt(!1,1029,2305),Kt.backCCW=new Kt(!0,1029,2305);let Da=s.an(new Float32Array(16));function ah(g,t,l,d,p,m){let{horizontalAlign:S,verticalAlign:E}=s.au(g);return new s.P((-(S-.5)*t/p+d[0])*m,(-(E-.5)*l/p+d[1])*m)}function so(g,t,l,d,p,m){let S=t.tileAnchorPoint.add(new s.P(t.translation[0],t.translation[1]));if(t.pitchWithMap){let E=d.mult(m);l||(E=E.rotate(-p));let M=S.add(E);return Q(M.x,M.y,t.labelPlaneMatrix,t.getElevation).point}if(l){let E=xe(t.tileAnchorPoint.x+1,t.tileAnchorPoint.y,t).point.sub(g),M=Math.atan(E.y/E.x)+(E.x<0?Math.PI:0);return g.add(d.rotate(M))}return g.add(d)}function Fo(g,t,l,d,p,m,S,E,M,R,D,F,j,W){let Z=g.text.placedSymbolArray,Y=g.text.dynamicLayoutVertexArray,te=g.icon.dynamicLayoutVertexArray,re={};Y.clear();for(let ne=0;ne<Z.length;ne++){let H=Z.get(ne),ce=H.hidden||!H.crossTileID||g.allowVerticalPlacement&&!H.placedOrientation?null:d[H.crossTileID];if(ce){let ue=new s.P(H.anchorX,H.anchorY),ge={getElevation:W,width:p.width,height:p.height,labelPlaneMatrix:m,lineVertexArray:null,pitchWithMap:l,projection:D,projectionCache:null,tileAnchorPoint:ue,translation:F,unwrappedTileID:j},Te=l?Q(ue.x,ue.y,S,W):xe(ue.x,ue.y,ge),Le=N(p.cameraToCenterDistance,Te.signedDistanceFromCamera),Ue=s.ai(g.textSizeData,M,H)*Le/s.ap;l&&(Ue*=g.tilePixelRatio/E);let{width:Xe,height:Oe,anchor:ze,textOffset:et,textBoxScale:_t}=ce,Ve=ah(ze,Xe,Oe,et,_t,Ue),We=D.getPitchedTextCorrection(p,ue.add(new s.P(F[0],F[1])),j),ft=so(Te.point,ge,t,Ve,p.angle,We),si=g.allowVerticalPlacement&&H.placedOrientation===s.ah.vertical?Math.PI/2:0;for(let Tt=0;Tt<H.numGlyphs;Tt++)s.aj(Y,ft,si);R&&H.associatedIconIndex>=0&&(re[H.associatedIconIndex]={shiftedAnchor:ft,angle:si})}else Ke(H.numGlyphs,Y)}if(R){te.clear();let ne=g.icon.placedSymbolArray;for(let H=0;H<ne.length;H++){let ce=ne.get(H);if(ce.hidden)Ke(ce.numGlyphs,te);else{let ue=re[H];if(ue)for(let ge=0;ge<ce.numGlyphs;ge++)s.aj(te,ue.shiftedAnchor,ue.angle);else Ke(ce.numGlyphs,te)}}g.icon.dynamicLayoutVertexBuffer.updateData(te)}g.text.dynamicLayoutVertexBuffer.updateData(Y)}function hn(g,t,l){return l.iconsInText&&t?"symbolTextAndIcon":g?"symbolSDF":"symbolIcon"}function lh(g,t,l,d,p,m,S,E,M,R,D,F){let j=g.context,W=j.gl,Z=g.transform,Y=Js(),te=E==="map",re=M==="map",ne=E!=="viewport"&&l.layout.get("symbol-placement")!=="point",H=te&&!re&&!ne,ce=!re&&ne,ue=!l.layout.get("symbol-sort-key").isConstant(),ge=!1,Te=g.depthModeForSublayer(0,At.ReadOnly),Le=l._unevaluatedLayout.hasValue("text-variable-anchor")||l._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ue=[],Xe=Y.getCircleRadiusCorrection(Z);for(let Oe of d){let ze=t.getTile(Oe),et=ze.getBucket(l);if(!et)continue;let _t=p?et.text:et.icon;if(!_t||!_t.segments.get().length||!_t.hasVisibleVertices)continue;let Ve=_t.programConfigurations.get(l.id),We=p||et.sdfIcons,ft=p?et.textSizeData:et.iconSizeData,si=re||Z.pitch!==0,Tt=g.useProgram(hn(We,p,et),Ve),Ft=s.ag(ft,Z.zoom),oi=g.style.map.terrain&&g.style.map.terrain.getTerrainData(Oe),Ji,Nn,ai,Dr,yr=[0,0],Qi=null;if(p)Nn=ze.glyphAtlasTexture,ai=W.LINEAR,Ji=ze.glyphAtlasTexture.size,et.iconsInText&&(yr=ze.imageAtlasTexture.size,Qi=ze.imageAtlasTexture,Dr=si||g.options.rotating||g.options.zooming||ft.kind==="composite"||ft.kind==="camera"?W.LINEAR:W.NEAREST);else{let Bt=l.layout.get("icon-size").constantOr(0)!==1||et.iconsNeedLinear;Nn=ze.imageAtlasTexture,ai=We||g.options.rotating||g.options.zooming||Bt||si?W.LINEAR:W.NEAREST,Ji=ze.imageAtlasTexture.size}let _r=Dt(ze,1,g.transform.zoom),is=ce?Oe.posMatrix:Da,Yo=Ln(is,re,te,g.transform,_r),Jl=ln(is,re,te,g.transform,_r),Jo=ln(Oe.posMatrix,re,te,g.transform,_r),pn=Y.translatePosition(g.transform,ze,m,S),Ql=Le&&et.hasTextData(),Lh=l.layout.get("icon-text-fit")!=="none"&&Ql&&et.hasIconData();if(ne){let Bt=g.style.map.terrain?(Qo,ea)=>g.style.map.terrain.getElevation(Oe,Qo,ea):null,ho=l.layout.get("text-rotation-alignment")==="map";q(et,Oe.posMatrix,g,p,Yo,Jo,re,R,ho,Y,Oe.toUnwrapped(),Z.width,Z.height,pn,Bt)}let fn=Oe.posMatrix,mn=p&&Le||Lh,Ds=ne||mn?Da:Yo,Vn=Jl,Ui=We&&l.paint.get(p?"text-halo-width":"icon-halo-width").constantOr(1)!==0,er;er=We?et.iconsInText?Kc(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,Ji,yr,Xe):Ra(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,p,Ji,!0,Xe):sd(ft.kind,Ft,H,re,ne,mn,g,fn,Ds,Vn,pn,p,Ji,Xe);let Jr={program:Tt,buffers:_t,uniformValues:er,atlasTexture:Nn,atlasTextureIcon:Qi,atlasInterpolation:ai,atlasInterpolationIcon:Dr,isSDF:We,hasHalo:Ui};if(ue&&et.canOverlap){ge=!0;let Bt=_t.segments.get();for(let ho of Bt)Ue.push({segments:new s.a0([ho]),sortKey:ho.sortKey,state:Jr,terrainData:oi})}else Ue.push({segments:_t.segments,sortKey:0,state:Jr,terrainData:oi})}ge&&Ue.sort((Oe,ze)=>Oe.sortKey-ze.sortKey);for(let Oe of Ue){let ze=Oe.state;if(j.activeTexture.set(W.TEXTURE0),ze.atlasTexture.bind(ze.atlasInterpolation,W.CLAMP_TO_EDGE),ze.atlasTextureIcon&&(j.activeTexture.set(W.TEXTURE1),ze.atlasTextureIcon&&ze.atlasTextureIcon.bind(ze.atlasInterpolationIcon,W.CLAMP_TO_EDGE)),ze.isSDF){let et=ze.uniformValues;ze.hasHalo&&(et.u_is_halo=1,ch(ze.buffers,Oe.segments,l,g,ze.program,Te,D,F,et,Oe.terrainData)),et.u_is_halo=0}ch(ze.buffers,Oe.segments,l,g,ze.program,Te,D,F,ze.uniformValues,Oe.terrainData)}}function ch(g,t,l,d,p,m,S,E,M,R){let D=d.context;p.draw(D,D.gl.TRIANGLES,m,S,E,Kt.disabled,M,R,l.id,g.layoutVertexBuffer,g.indexBuffer,t,l.paint,d.transform.zoom,g.programConfigurations.get(l.id),g.dynamicLayoutVertexBuffer,g.opacityVertexBuffer)}function hh(g,t,l,d){let p=g.context,m=p.gl,S=ii.disabled,E=new yi([m.ONE,m.ONE],s.aM.transparent,[!0,!0,!0,!0]),M=t.getBucket(l);if(!M)return;let R=d.key,D=l.heatmapFbos.get(R);D||(D=Fa(p,t.tileSize,t.tileSize),l.heatmapFbos.set(R,D)),p.bindFramebuffer.set(D.framebuffer),p.viewport.set([0,0,t.tileSize,t.tileSize]),p.clear({color:s.aM.transparent});let F=M.programConfigurations.get(l.id),j=g.useProgram("heatmap",F),W=g.style.map.terrain.getTerrainData(d);j.draw(p,m.TRIANGLES,At.disabled,S,E,Kt.disabled,Lr(d.posMatrix,t,g.transform.zoom,l.paint.get("heatmap-intensity")),W,l.id,M.layoutVertexBuffer,M.indexBuffer,M.segments,l.paint,g.transform.zoom,F)}function oo(g,t,l){let d=g.context,p=d.gl;d.setColorMode(g.colorModeForRenderPass());let m=za(d,t),S=l.key,E=t.heatmapFbos.get(S);E&&(d.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,E.colorAttachment.get()),d.activeTexture.set(p.TEXTURE1),m.bind(p.LINEAR,p.CLAMP_TO_EDGE),g.useProgram("heatmapTexture").draw(d,p.TRIANGLES,At.disabled,ii.disabled,g.colorModeForRenderPass(),Kt.disabled,Cl(g,t,0,1),null,t.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments,t.paint,g.transform.zoom),E.destroy(),t.heatmapFbos.delete(S))}function Fa(g,t,l){var d,p;let m=g.gl,S=m.createTexture();m.bindTexture(m.TEXTURE_2D,S),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_S,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_WRAP_T,m.CLAMP_TO_EDGE),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MIN_FILTER,m.LINEAR),m.texParameteri(m.TEXTURE_2D,m.TEXTURE_MAG_FILTER,m.LINEAR);let E=(d=g.HALF_FLOAT)!==null&&d!==void 0?d:m.UNSIGNED_BYTE,M=(p=g.RGBA16F)!==null&&p!==void 0?p:m.RGBA;m.texImage2D(m.TEXTURE_2D,0,M,t,l,0,m.RGBA,E,null);let R=g.createFramebuffer(t,l,!1,!1);return R.colorAttachment.set(S),R}function za(g,t){return t.colorRampTexture||(t.colorRampTexture=new Ae(g,t.colorRamp,g.gl.RGBA)),t.colorRampTexture}function zo(g,t,l,d,p){if(!l||!d||!d.imageAtlas)return;let m=d.imageAtlas.patternPositions,S=m[l.to.toString()],E=m[l.from.toString()];if(!S&&E&&(S=E),!E&&S&&(E=S),!S||!E){let M=p.getPaintProperty(t);S=m[M],E=m[M]}S&&E&&g.setConstantPatternPositions(S,E)}function Oa(g,t,l,d,p,m,S){let E=g.context.gl,M="fill-pattern",R=l.paint.get(M),D=R&&R.constantOr(1),F=l.getCrossfadeParameters(),j,W,Z,Y,te;S?(W=D&&!l.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",j=E.LINES):(W=D?"fillPattern":"fill",j=E.TRIANGLES);let re=R.constantOr(null);for(let ne of d){let H=t.getTile(ne);if(D&&!H.patternsLoaded())continue;let ce=H.getBucket(l);if(!ce)continue;let ue=ce.programConfigurations.get(l.id),ge=g.useProgram(W,ue),Te=g.style.map.terrain&&g.style.map.terrain.getTerrainData(ne);D&&(g.context.activeTexture.set(E.TEXTURE0),H.imageAtlasTexture.bind(E.LINEAR,E.CLAMP_TO_EDGE),ue.updatePaintBuffers(F)),zo(ue,M,re,H,l);let Le=Te?ne:null,Ue=g.translatePosMatrix(Le?Le.posMatrix:ne.posMatrix,H,l.paint.get("fill-translate"),l.paint.get("fill-translate-anchor"));if(S){Y=ce.indexBuffer2,te=ce.segments2;let Xe=[E.drawingBufferWidth,E.drawingBufferHeight];Z=W==="fillOutlinePattern"&&D?td(Ue,g,F,H,Xe):xf(Ue,Xe)}else Y=ce.indexBuffer,te=ce.segments,Z=D?ed(Ue,g,F,H):ko(Ue);ge.draw(g.context,j,p,g.stencilModeForClipping(ne),m,Kt.disabled,Z,Te,l.id,ce.layoutVertexBuffer,Y,te,l.paint,g.transform.zoom,ue)}}function Dl(g,t,l,d,p,m,S){let E=g.context,M=E.gl,R="fill-extrusion-pattern",D=l.paint.get(R),F=D.constantOr(1),j=l.getCrossfadeParameters(),W=l.paint.get("fill-extrusion-opacity"),Z=D.constantOr(null);for(let Y of d){let te=t.getTile(Y),re=te.getBucket(l);if(!re)continue;let ne=g.style.map.terrain&&g.style.map.terrain.getTerrainData(Y),H=re.programConfigurations.get(l.id),ce=g.useProgram(F?"fillExtrusionPattern":"fillExtrusion",H);F&&(g.context.activeTexture.set(M.TEXTURE0),te.imageAtlasTexture.bind(M.LINEAR,M.CLAMP_TO_EDGE),H.updatePaintBuffers(j)),zo(H,R,Z,te,l);let ue=g.translatePosMatrix(Y.posMatrix,te,l.paint.get("fill-extrusion-translate"),l.paint.get("fill-extrusion-translate-anchor")),ge=l.paint.get("fill-extrusion-vertical-gradient"),Te=F?Il(ue,g,ge,W,Y,j,te):Pa(ue,g,ge,W);ce.draw(E,E.gl.TRIANGLES,p,m,S,Kt.backCCW,Te,ne,l.id,re.layoutVertexBuffer,re.indexBuffer,re.segments,l.paint,g.transform.zoom,H,g.style.map.terrain&&re.centroidVertexBuffer)}}function Oo(g,t,l,d,p,m,S){let E=g.context,M=E.gl,R=l.fbo;if(!R)return;let D=g.useProgram("hillshade"),F=g.style.map.terrain&&g.style.map.terrain.getTerrainData(t);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,R.colorAttachment.get()),D.draw(E,M.TRIANGLES,p,m,S,Kt.disabled,((j,W,Z,Y)=>{let te=Z.paint.get("hillshade-shadow-color"),re=Z.paint.get("hillshade-highlight-color"),ne=Z.paint.get("hillshade-accent-color"),H=Z.paint.get("hillshade-illumination-direction")*(Math.PI/180);Z.paint.get("hillshade-illumination-anchor")==="viewport"&&(H-=j.transform.angle);let ce=!j.options.moving;return{u_matrix:Y?Y.posMatrix:j.transform.calculatePosMatrix(W.tileID.toUnwrapped(),ce),u_image:0,u_latrange:El(0,W.tileID),u_light:[Z.paint.get("hillshade-exaggeration"),H],u_shadow:te,u_highlight:re,u_accent:ne}})(g,l,d,F?t:null),F,d.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments)}function Bo(g,t,l,d,p,m){let S=g.context,E=S.gl,M=t.dem;if(M&&M.data){let R=M.dim,D=M.stride,F=M.getPixels();if(S.activeTexture.set(E.TEXTURE1),S.pixelStoreUnpackPremultiplyAlpha.set(!1),t.demTexture=t.demTexture||g.getTileTexture(D),t.demTexture){let W=t.demTexture;W.update(F,{premultiply:!1}),W.bind(E.NEAREST,E.CLAMP_TO_EDGE)}else t.demTexture=new Ae(S,F,E.RGBA,{premultiply:!1}),t.demTexture.bind(E.NEAREST,E.CLAMP_TO_EDGE);S.activeTexture.set(E.TEXTURE0);let j=t.fbo;if(!j){let W=new Ae(S,{width:R,height:R,data:null},E.RGBA);W.bind(E.LINEAR,E.CLAMP_TO_EDGE),j=t.fbo=S.createFramebuffer(R,R,!0,!1),j.colorAttachment.set(W.texture)}S.bindFramebuffer.set(j.framebuffer),S.viewport.set([0,0,R,R]),g.useProgram("hillshadePrepare").draw(S,E.TRIANGLES,d,p,m,Kt.disabled,((W,Z)=>{let Y=Z.stride,te=s.H();return s.aP(te,0,s.X,-s.X,0,0,1),s.J(te,te,[0,-s.X,0]),{u_matrix:te,u_image:1,u_dimension:[Y,Y],u_zoom:W.overscaledZ,u_unpack:Z.getUnpackVector()}})(t.tileID,M),null,l.id,g.rasterBoundsBuffer,g.quadTriangleIndexBuffer,g.rasterBoundsSegments),t.needsHillshadePrepare=!1}}function _d(g,t,l,d,p,m){let S=d.paint.get("raster-fade-duration");if(!m&&S>0){let E=T.now(),M=(E-g.timeAdded)/S,R=t?(E-t.timeAdded)/S:-1,D=l.getSource(),F=p.coveringZoomLevel({tileSize:D.tileSize,roundZoom:D.roundZoom}),j=!t||Math.abs(t.tileID.overscaledZ-F)>Math.abs(g.tileID.overscaledZ-F),W=j&&g.refreshedUponExpiration?1:s.ac(j?M:1-R,0,1);return g.refreshedUponExpiration&&M>=1&&(g.refreshedUponExpiration=!1),t?{opacity:1,mix:1-W}:{opacity:W,mix:0}}return{opacity:1,mix:0}}let uh=new s.aM(1,0,0,1),jt=new s.aM(0,1,0,1),Fl=new s.aM(0,0,1,1),Df=new s.aM(1,0,1,1),xd=new s.aM(0,1,1,1);function No(g,t,l,d){zl(g,0,t+l/2,g.transform.width,l,d)}function vd(g,t,l,d){zl(g,t-l/2,0,l,g.transform.height,d)}function zl(g,t,l,d,p,m){let S=g.context,E=S.gl;E.enable(E.SCISSOR_TEST),E.scissor(t*g.pixelRatio,l*g.pixelRatio,d*g.pixelRatio,p*g.pixelRatio),S.clear({color:m}),E.disable(E.SCISSOR_TEST)}function bd(g,t,l){let d=g.context,p=d.gl,m=l.posMatrix,S=g.useProgram("debug"),E=At.disabled,M=ii.disabled,R=g.colorModeForRenderPass(),D="$debug",F=g.style.map.terrain&&g.style.map.terrain.getTerrainData(l);d.activeTexture.set(p.TEXTURE0);let j=t.getTileByID(l.key).latestRawTileData,W=Math.floor((j&&j.byteLength||0)/1024),Z=t.getTile(l).tileSize,Y=512/Math.min(Z,512)*(l.overscaledZ/g.transform.zoom)*.5,te=l.canonical.toString();l.overscaledZ!==l.canonical.z&&(te+=` => ${l.overscaledZ}`),function(re,ne){re.initDebugOverlayCanvas();let H=re.debugOverlayCanvas,ce=re.context.gl,ue=re.debugOverlayCanvas.getContext("2d");ue.clearRect(0,0,H.width,H.height),ue.shadowColor="white",ue.shadowBlur=2,ue.lineWidth=1.5,ue.strokeStyle="white",ue.textBaseline="top",ue.font="bold 36px Open Sans, sans-serif",ue.fillText(ne,5,5),ue.strokeText(ne,5,5),re.debugOverlayTexture.update(H),re.debugOverlayTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE)}(g,`${te} ${W}kB`),S.draw(d,p.TRIANGLES,E,M,yi.alphaBlended,Kt.disabled,Aa(m,s.aM.transparent,Y),null,D,g.debugBuffer,g.quadTriangleIndexBuffer,g.debugSegments),S.draw(d,p.LINE_STRIP,E,M,R,Kt.disabled,Aa(m,s.aM.red),F,D,g.debugBuffer,g.tileBorderIndexBuffer,g.debugSegments)}function wd(g,t,l){let d=g.context,p=d.gl,m=g.colorModeForRenderPass(),S=new At(p.LEQUAL,At.ReadWrite,g.depthRangeFor3D),E=g.useProgram("terrain"),M=t.getTerrainMesh();d.bindFramebuffer.set(null),d.viewport.set([0,0,g.width,g.height]);for(let R of l){let D=g.renderToTexture.getTexture(R),F=t.getTerrainData(R.tileID);d.activeTexture.set(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,D.texture);let j=g.transform.calculatePosMatrix(R.tileID.toUnwrapped()),W=t.getMeshFrameDelta(g.transform.zoom),Z=g.transform.calculateFogMatrix(R.tileID.toUnwrapped()),Y=Xc(j,W,Z,g.style.sky,g.transform.pitch);E.draw(d,p.TRIANGLES,S,ii.disabled,m,Kt.backCCW,Y,F,"terrain",M.vertexBuffer,M.indexBuffer,M.segments)}}class Ol{constructor(t,l,d){this.vertexBuffer=t,this.indexBuffer=l,this.segments=d}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Bl{constructor(t,l){this.context=new Lf(t),this.transform=l,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:s.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ht.maxUnderzooming+ht.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Wc}resize(t,l,d){if(this.width=Math.floor(t*d),this.height=Math.floor(l*d),this.pixelRatio=d,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(let p of this.style._order)this.style._layers[p].resize()}setup(){let t=this.context,l=new s.aX;l.emplaceBack(0,0),l.emplaceBack(s.X,0),l.emplaceBack(0,s.X),l.emplaceBack(s.X,s.X),this.tileExtentBuffer=t.createVertexBuffer(l,Qs.members),this.tileExtentSegments=s.a0.simpleSegment(0,0,4,2);let d=new s.aX;d.emplaceBack(0,0),d.emplaceBack(s.X,0),d.emplaceBack(0,s.X),d.emplaceBack(s.X,s.X),this.debugBuffer=t.createVertexBuffer(d,Qs.members),this.debugSegments=s.a0.simpleSegment(0,0,4,5);let p=new s.$;p.emplaceBack(0,0,0,0),p.emplaceBack(s.X,0,s.X,0),p.emplaceBack(0,s.X,0,s.X),p.emplaceBack(s.X,s.X,s.X,s.X),this.rasterBoundsBuffer=t.createVertexBuffer(p,on.members),this.rasterBoundsSegments=s.a0.simpleSegment(0,0,4,2);let m=new s.aX;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=t.createVertexBuffer(m,Qs.members),this.viewportSegments=s.a0.simpleSegment(0,0,4,2);let S=new s.aZ;S.emplaceBack(0),S.emplaceBack(1),S.emplaceBack(3),S.emplaceBack(2),S.emplaceBack(0),this.tileBorderIndexBuffer=t.createIndexBuffer(S);let E=new s.aY;E.emplaceBack(0,1,2),E.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=t.createIndexBuffer(E);let M=this.context.gl;this.stencilClearMode=new ii({func:M.ALWAYS,mask:0},0,255,M.ZERO,M.ZERO,M.ZERO)}clearStencil(){let t=this.context,l=t.gl;this.nextStencilID=1,this.currentStencilSource=void 0;let d=s.H();s.aP(d,0,this.width,this.height,0,0,1),s.K(d,d,[l.drawingBufferWidth,l.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(t,l.TRIANGLES,At.disabled,this.stencilClearMode,yi.disabled,Kt.disabled,kr(d),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(t,l){if(this.currentStencilSource===t.source||!t.isTileClipped()||!l||!l.length)return;this.currentStencilSource=t.source;let d=this.context,p=d.gl;this.nextStencilID+l.length>256&&this.clearStencil(),d.setColorMode(yi.disabled),d.setDepthMode(At.disabled);let m=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(let S of l){let E=this._tileClippingMaskIDs[S.key]=this.nextStencilID++,M=this.style.map.terrain&&this.style.map.terrain.getTerrainData(S);m.draw(d,p.TRIANGLES,At.disabled,new ii({func:p.ALWAYS,mask:0},E,255,p.KEEP,p.KEEP,p.REPLACE),yi.disabled,Kt.disabled,kr(S.posMatrix),M,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();let t=this.nextStencilID++,l=this.context.gl;return new ii({func:l.NOTEQUAL,mask:255},t,255,l.KEEP,l.KEEP,l.REPLACE)}stencilModeForClipping(t){let l=this.context.gl;return new ii({func:l.EQUAL,mask:255},this._tileClippingMaskIDs[t.key],0,l.KEEP,l.KEEP,l.REPLACE)}stencilConfigForOverlap(t){let l=this.context.gl,d=t.sort((S,E)=>E.overscaledZ-S.overscaledZ),p=d[d.length-1].overscaledZ,m=d[0].overscaledZ-p+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();let S={};for(let E=0;E<m;E++)S[E+p]=new ii({func:l.GEQUAL,mask:255},E+this.nextStencilID,255,l.KEEP,l.KEEP,l.REPLACE);return this.nextStencilID+=m,[S,d]}return[{[p]:ii.disabled},d]}colorModeForRenderPass(){let t=this.context.gl;return this._showOverdrawInspector?new yi([t.CONSTANT_COLOR,t.ONE],new s.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?yi.unblended:yi.alphaBlended}depthModeForSublayer(t,l,d){if(!this.opaquePassEnabledForLayer())return At.disabled;let p=1-((1+this.currentLayer)*this.numSublayers+t)*this.depthEpsilon;return new At(d||this.context.gl.LEQUAL,l,[p,p])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(t,l){this.style=t,this.options=l,this.lineAtlas=t.lineAtlas,this.imageManager=t.imageManager,this.glyphManager=t.glyphManager,this.symbolFadeChange=t.placement.symbolFadeChange(T.now()),this.imageManager.beginFrame();let d=this.style._order,p=this.style.sourceCaches,m={},S={},E={};for(let M in p){let R=p[M];R.used&&R.prepare(this.context),m[M]=R.getVisibleCoordinates(),S[M]=m[M].slice().reverse(),E[M]=R.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let M=0;M<d.length;M++)if(this.style._layers[d[M]].is3D()){this.opaquePassCutoff=M;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(let M of d){let R=this.style._layers[M];if(!R.hasOffscreenPass()||R.isHidden(this.transform.zoom))continue;let D=S[R.source];(R.type==="custom"||D.length)&&this.renderLayer(this,p[R.source],R,D)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:l.showOverdrawInspector?s.aM.black:s.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(M,R){let D=M.context,F=D.gl,j=((re,ne,H)=>({u_sky_color:re.properties.get("sky-color"),u_horizon_color:re.properties.get("horizon-color"),u_horizon:(ne.height/2+ne.getHorizon())*H,u_sky_horizon_blend:re.properties.get("sky-horizon-blend")*ne.height/2*H}))(R,M.style.map.transform,M.pixelRatio),W=new At(F.LEQUAL,At.ReadWrite,[0,1]),Z=ii.disabled,Y=M.colorModeForRenderPass(),te=M.useProgram("sky");if(!R.mesh){let re=new s.aX;re.emplaceBack(-1,-1),re.emplaceBack(1,-1),re.emplaceBack(1,1),re.emplaceBack(-1,1);let ne=new s.aY;ne.emplaceBack(0,1,2),ne.emplaceBack(0,2,3),R.mesh=new Ol(D.createVertexBuffer(re,Qs.members),D.createIndexBuffer(ne),s.a0.simpleSegment(0,0,re.length,ne.length))}te.draw(D,F.TRIANGLES,W,Z,Y,Kt.disabled,j,void 0,"sky",R.mesh.vertexBuffer,R.mesh.indexBuffer,R.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=l.showOverdrawInspector,this.depthRangeFor3D=[0,1-(t._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=d.length-1;this.currentLayer>=0;this.currentLayer--){let M=this.style._layers[d[this.currentLayer]],R=p[M.source],D=m[M.source];this._renderTileClippingMasks(M,D),this.renderLayer(this,R,M,D)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<d.length;this.currentLayer++){let M=this.style._layers[d[this.currentLayer]],R=p[M.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(M))continue;let D=(M.type==="symbol"?E:S)[M.source];this._renderTileClippingMasks(M,m[M.source]),this.renderLayer(this,R,M,D)}if(this.options.showTileBoundaries){let M=function(R,D){let F=null,j=Object.values(R._layers).flatMap(te=>te.source&&!te.isHidden(D)?[R.sourceCaches[te.source]]:[]),W=j.filter(te=>te.getSource().type==="vector"),Z=j.filter(te=>te.getSource().type!=="vector"),Y=te=>{(!F||F.getSource().maxzoom<te.getSource().maxzoom)&&(F=te)};return W.forEach(te=>Y(te)),F||Z.forEach(te=>Y(te)),F}(this.style,this.transform.zoom);M&&function(R,D,F){for(let j=0;j<F.length;j++)bd(R,D,F[j])}(this,M,M.getVisibleCoordinates())}this.options.showPadding&&function(M){let R=M.transform.padding;No(M,M.transform.height-(R.top||0),3,uh),No(M,R.bottom||0,3,jt),vd(M,R.left||0,3,Fl),vd(M,M.transform.width-(R.right||0),3,Df);let D=M.transform.centerPoint;(function(F,j,W,Z){zl(F,j-1,W-10,2,20,Z),zl(F,j-10,W-1,20,2,Z)})(M,D.x,M.transform.height-D.y,xd)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(t){if(!this.style||!this.style.map||!this.style.map.terrain)return;let l=this.terrainFacilitator.matrix,d=this.transform.modelViewProjectionMatrix,p=this.terrainFacilitator.dirty;p||(p=t?!s.a_(l,d):!s.a$(l,d)),p||(p=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),p&&(s.b0(l,d),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(m,S){let E=m.context,M=E.gl,R=yi.unblended,D=new At(M.LEQUAL,At.ReadWrite,[0,1]),F=S.getTerrainMesh(),j=S.sourceCache.getRenderableTiles(),W=m.useProgram("terrainDepth");E.bindFramebuffer.set(S.getFramebuffer("depth").framebuffer),E.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),E.clear({color:s.aM.transparent,depth:1});for(let Z of j){let Y=S.getTerrainData(Z.tileID),te={u_matrix:m.transform.calculatePosMatrix(Z.tileID.toUnwrapped()),u_ele_delta:S.getMeshFrameDelta(m.transform.zoom)};W.draw(E,M.TRIANGLES,D,ii.disabled,R,Kt.backCCW,te,Y,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}E.bindFramebuffer.set(null),E.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain),function(m,S){let E=m.context,M=E.gl,R=yi.unblended,D=new At(M.LEQUAL,At.ReadWrite,[0,1]),F=S.getTerrainMesh(),j=S.getCoordsTexture(),W=S.sourceCache.getRenderableTiles(),Z=m.useProgram("terrainCoords");E.bindFramebuffer.set(S.getFramebuffer("coords").framebuffer),E.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),E.clear({color:s.aM.transparent,depth:1}),S.coordsIndex=[];for(let Y of W){let te=S.getTerrainData(Y.tileID);E.activeTexture.set(M.TEXTURE0),M.bindTexture(M.TEXTURE_2D,j.texture);let re={u_matrix:m.transform.calculatePosMatrix(Y.tileID.toUnwrapped()),u_terrain_coords_id:(255-S.coordsIndex.length)/255,u_texture:0,u_ele_delta:S.getMeshFrameDelta(m.transform.zoom)};Z.draw(E,M.TRIANGLES,D,ii.disabled,R,Kt.backCCW,re,te,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),S.coordsIndex.push(Y.tileID.key)}E.bindFramebuffer.set(null),E.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain))}renderLayer(t,l,d,p){if(!d.isHidden(this.transform.zoom)&&(d.type==="background"||d.type==="custom"||(p||[]).length))switch(this.id=d.id,d.type){case"symbol":(function(m,S,E,M,R){if(m.renderPass!=="translucent")return;let D=ii.disabled,F=m.colorModeForRenderPass();(E._unevaluatedLayout.hasValue("text-variable-anchor")||E._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(j,W,Z,Y,te,re,ne,H,ce){let ue=W.transform,ge=Js(),Te=te==="map",Le=re==="map";for(let Ue of j){let Xe=Y.getTile(Ue),Oe=Xe.getBucket(Z);if(!Oe||!Oe.text||!Oe.text.segments.get().length)continue;let ze=s.ag(Oe.textSizeData,ue.zoom),et=Dt(Xe,1,W.transform.zoom),_t=Ln(Ue.posMatrix,Le,Te,W.transform,et),Ve=Z.layout.get("icon-text-fit")!=="none"&&Oe.hasIconData();if(ze){let We=Math.pow(2,ue.zoom-Xe.tileID.overscaledZ),ft=W.style.map.terrain?(Tt,Ft)=>W.style.map.terrain.getElevation(Ue,Tt,Ft):null,si=ge.translatePosition(ue,Xe,ne,H);Fo(Oe,Te,Le,ce,ue,_t,Ue.posMatrix,We,ze,Ve,ge,si,Ue.toUnwrapped(),ft)}}}(M,m,E,S,E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),R),E.paint.get("icon-opacity").constantOr(1)!==0&&lh(m,S,E,M,!1,E.paint.get("icon-translate"),E.paint.get("icon-translate-anchor"),E.layout.get("icon-rotation-alignment"),E.layout.get("icon-pitch-alignment"),E.layout.get("icon-keep-upright"),D,F),E.paint.get("text-opacity").constantOr(1)!==0&&lh(m,S,E,M,!0,E.paint.get("text-translate"),E.paint.get("text-translate-anchor"),E.layout.get("text-rotation-alignment"),E.layout.get("text-pitch-alignment"),E.layout.get("text-keep-upright"),D,F),S.map.showCollisionBoxes&&(La(m,S,E,M,!0),La(m,S,E,M,!1))})(t,l,d,p,this.style.placement.variableOffsets);break;case"circle":(function(m,S,E,M){if(m.renderPass!=="translucent")return;let R=E.paint.get("circle-opacity"),D=E.paint.get("circle-stroke-width"),F=E.paint.get("circle-stroke-opacity"),j=!E.layout.get("circle-sort-key").isConstant();if(R.constantOr(1)===0&&(D.constantOr(1)===0||F.constantOr(1)===0))return;let W=m.context,Z=W.gl,Y=m.depthModeForSublayer(0,At.ReadOnly),te=ii.disabled,re=m.colorModeForRenderPass(),ne=[];for(let H=0;H<M.length;H++){let ce=M[H],ue=S.getTile(ce),ge=ue.getBucket(E);if(!ge)continue;let Te=ge.programConfigurations.get(E.id),Le=m.useProgram("circle",Te),Ue=ge.layoutVertexBuffer,Xe=ge.indexBuffer,Oe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ce),ze={programConfiguration:Te,program:Le,layoutVertexBuffer:Ue,indexBuffer:Xe,uniformValues:vf(m,ce,ue,E),terrainData:Oe};if(j){let et=ge.segments.get();for(let _t of et)ne.push({segments:new s.a0([_t]),sortKey:_t.sortKey,state:ze})}else ne.push({segments:ge.segments,sortKey:0,state:ze})}j&&ne.sort((H,ce)=>H.sortKey-ce.sortKey);for(let H of ne){let{programConfiguration:ce,program:ue,layoutVertexBuffer:ge,indexBuffer:Te,uniformValues:Le,terrainData:Ue}=H.state;ue.draw(W,Z.TRIANGLES,Y,te,re,Kt.disabled,Le,Ue,E.id,ge,Te,H.segments,E.paint,m.transform.zoom,ce)}})(t,l,d,p);break;case"heatmap":(function(m,S,E,M){if(E.paint.get("heatmap-opacity")===0)return;let R=m.context;if(m.style.map.terrain){for(let D of M){let F=S.getTile(D);S.hasRenderableParent(D)||(m.renderPass==="offscreen"?hh(m,F,E,D):m.renderPass==="translucent"&&oo(m,E,D))}R.viewport.set([0,0,m.width,m.height])}else m.renderPass==="offscreen"?function(D,F,j,W){let Z=D.context,Y=Z.gl,te=ii.disabled,re=new yi([Y.ONE,Y.ONE],s.aM.transparent,[!0,!0,!0,!0]);(function(ne,H,ce){let ue=ne.gl;ne.activeTexture.set(ue.TEXTURE1),ne.viewport.set([0,0,H.width/4,H.height/4]);let ge=ce.heatmapFbos.get(s.aU);ge?(ue.bindTexture(ue.TEXTURE_2D,ge.colorAttachment.get()),ne.bindFramebuffer.set(ge.framebuffer)):(ge=Fa(ne,H.width/4,H.height/4),ce.heatmapFbos.set(s.aU,ge))})(Z,D,j),Z.clear({color:s.aM.transparent});for(let ne=0;ne<W.length;ne++){let H=W[ne];if(F.hasRenderableParent(H))continue;let ce=F.getTile(H),ue=ce.getBucket(j);if(!ue)continue;let ge=ue.programConfigurations.get(j.id),Te=D.useProgram("heatmap",ge),{zoom:Le}=D.transform;Te.draw(Z,Y.TRIANGLES,At.disabled,te,re,Kt.disabled,Lr(H.posMatrix,ce,Le,j.paint.get("heatmap-intensity")),null,j.id,ue.layoutVertexBuffer,ue.indexBuffer,ue.segments,j.paint,D.transform.zoom,ge)}Z.viewport.set([0,0,D.width,D.height])}(m,S,E,M):m.renderPass==="translucent"&&function(D,F){let j=D.context,W=j.gl;j.setColorMode(D.colorModeForRenderPass());let Z=F.heatmapFbos.get(s.aU);Z&&(j.activeTexture.set(W.TEXTURE0),W.bindTexture(W.TEXTURE_2D,Z.colorAttachment.get()),j.activeTexture.set(W.TEXTURE1),za(j,F).bind(W.LINEAR,W.CLAMP_TO_EDGE),D.useProgram("heatmapTexture").draw(j,W.TRIANGLES,At.disabled,ii.disabled,D.colorModeForRenderPass(),Kt.disabled,Cl(D,F,0,1),null,F.id,D.viewportBuffer,D.quadTriangleIndexBuffer,D.viewportSegments,F.paint,D.transform.zoom))}(m,E)})(t,l,d,p);break;case"line":(function(m,S,E,M){if(m.renderPass!=="translucent")return;let R=E.paint.get("line-opacity"),D=E.paint.get("line-width");if(R.constantOr(1)===0||D.constantOr(1)===0)return;let F=m.depthModeForSublayer(0,At.ReadOnly),j=m.colorModeForRenderPass(),W=E.paint.get("line-dasharray"),Z=E.paint.get("line-pattern"),Y=Z.constantOr(1),te=E.paint.get("line-gradient"),re=E.getCrossfadeParameters(),ne=Y?"linePattern":W?"lineSDF":te?"lineGradient":"line",H=m.context,ce=H.gl,ue=!0;for(let ge of M){let Te=S.getTile(ge);if(Y&&!Te.patternsLoaded())continue;let Le=Te.getBucket(E);if(!Le)continue;let Ue=Le.programConfigurations.get(E.id),Xe=m.context.program.get(),Oe=m.useProgram(ne,Ue),ze=ue||Oe.program!==Xe,et=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ge),_t=Z.constantOr(null);if(_t&&Te.imageAtlas){let ft=Te.imageAtlas,si=ft.patternPositions[_t.to.toString()],Tt=ft.patternPositions[_t.from.toString()];si&&Tt&&Ue.setConstantPatternPositions(si,Tt)}let Ve=et?ge:null,We=Y?Lo(m,Te,E,re,Ve):W?bf(m,Te,E,W,re,Ve):te?id(m,Te,E,Le.lineClipsArray.length,Ve):Tl(m,Te,E,Ve);if(Y)H.activeTexture.set(ce.TEXTURE0),Te.imageAtlasTexture.bind(ce.LINEAR,ce.CLAMP_TO_EDGE),Ue.updatePaintBuffers(re);else if(W&&(ze||m.lineAtlas.dirty))H.activeTexture.set(ce.TEXTURE0),m.lineAtlas.bind(H);else if(te){let ft=Le.gradients[E.id],si=ft.texture;if(E.gradientVersion!==ft.version){let Tt=256;if(E.stepInterpolant){let Ft=S.getSource().maxzoom,oi=ge.canonical.z===Ft?Math.ceil(1<<m.transform.maxZoom-ge.canonical.z):1;Tt=s.ac(s.aV(Le.maxLineLength/s.X*1024*oi),256,H.maxTextureSize)}ft.gradient=s.aW({expression:E.gradientExpression(),evaluationKey:"lineProgress",resolution:Tt,image:ft.gradient||void 0,clips:Le.lineClipsArray}),ft.texture?ft.texture.update(ft.gradient):ft.texture=new Ae(H,ft.gradient,ce.RGBA),ft.version=E.gradientVersion,si=ft.texture}H.activeTexture.set(ce.TEXTURE0),si.bind(E.stepInterpolant?ce.NEAREST:ce.LINEAR,ce.CLAMP_TO_EDGE)}Oe.draw(H,ce.TRIANGLES,F,m.stencilModeForClipping(ge),j,Kt.disabled,We,et,E.id,Le.layoutVertexBuffer,Le.indexBuffer,Le.segments,E.paint,m.transform.zoom,Ue,Le.layoutVertexBuffer2),ue=!1}})(t,l,d,p);break;case"fill":(function(m,S,E,M){let R=E.paint.get("fill-color"),D=E.paint.get("fill-opacity");if(D.constantOr(1)===0)return;let F=m.colorModeForRenderPass(),j=E.paint.get("fill-pattern"),W=m.opaquePassEnabledForLayer()&&!j.constantOr(1)&&R.constantOr(s.aM.transparent).a===1&&D.constantOr(0)===1?"opaque":"translucent";if(m.renderPass===W){let Z=m.depthModeForSublayer(1,m.renderPass==="opaque"?At.ReadWrite:At.ReadOnly);Oa(m,S,E,M,Z,F,!1)}if(m.renderPass==="translucent"&&E.paint.get("fill-antialias")){let Z=m.depthModeForSublayer(E.getPaintProperty("fill-outline-color")?2:0,At.ReadOnly);Oa(m,S,E,M,Z,F,!0)}})(t,l,d,p);break;case"fill-extrusion":(function(m,S,E,M){let R=E.paint.get("fill-extrusion-opacity");if(R!==0&&m.renderPass==="translucent"){let D=new At(m.context.gl.LEQUAL,At.ReadWrite,m.depthRangeFor3D);if(R!==1||E.paint.get("fill-extrusion-pattern").constantOr(1))Dl(m,S,E,M,D,ii.disabled,yi.disabled),Dl(m,S,E,M,D,m.stencilModeFor3D(),m.colorModeForRenderPass());else{let F=m.colorModeForRenderPass();Dl(m,S,E,M,D,ii.disabled,F)}}})(t,l,d,p);break;case"hillshade":(function(m,S,E,M){if(m.renderPass!=="offscreen"&&m.renderPass!=="translucent")return;let R=m.context,D=m.depthModeForSublayer(0,At.ReadOnly),F=m.colorModeForRenderPass(),[j,W]=m.renderPass==="translucent"?m.stencilConfigForOverlap(M):[{},M];for(let Z of W){let Y=S.getTile(Z);Y.needsHillshadePrepare!==void 0&&Y.needsHillshadePrepare&&m.renderPass==="offscreen"?Bo(m,Y,E,D,ii.disabled,F):m.renderPass==="translucent"&&Oo(m,Z,Y,E,D,j[Z.overscaledZ],F)}R.viewport.set([0,0,m.width,m.height])})(t,l,d,p);break;case"raster":(function(m,S,E,M){if(m.renderPass!=="translucent"||E.paint.get("raster-opacity")===0||!M.length)return;let R=m.context,D=R.gl,F=S.getSource(),j=m.useProgram("raster"),W=m.colorModeForRenderPass(),[Z,Y]=F instanceof Ar?[{},M]:m.stencilConfigForOverlap(M),te=Y[Y.length-1].overscaledZ,re=!m.options.moving;for(let ne of Y){let H=m.depthModeForSublayer(ne.overscaledZ-te,E.paint.get("raster-opacity")===1?At.ReadWrite:At.ReadOnly,D.LESS),ce=S.getTile(ne);ce.registerFadeDuration(E.paint.get("raster-fade-duration"));let ue=S.findLoadedParent(ne,0),ge=S.findLoadedSibling(ne),Te=_d(ce,ue||ge||null,S,E,m.transform,m.style.map.terrain),Le,Ue,Xe=E.paint.get("raster-resampling")==="nearest"?D.NEAREST:D.LINEAR;R.activeTexture.set(D.TEXTURE0),ce.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),R.activeTexture.set(D.TEXTURE1),ue?(ue.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),Le=Math.pow(2,ue.tileID.overscaledZ-ce.tileID.overscaledZ),Ue=[ce.tileID.canonical.x*Le%1,ce.tileID.canonical.y*Le%1]):ce.texture.bind(Xe,D.CLAMP_TO_EDGE,D.LINEAR_MIPMAP_NEAREST),ce.texture.useMipmap&&R.extTextureFilterAnisotropic&&m.transform.pitch>20&&D.texParameterf(D.TEXTURE_2D,R.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,R.extTextureFilterAnisotropicMax);let Oe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(ne),ze=Oe?ne:null,et=ze?ze.posMatrix:m.transform.calculatePosMatrix(ne.toUnwrapped(),re),_t=wf(et,Ue||[0,0],Le||1,Te,E);F instanceof Ar?j.draw(R,D.TRIANGLES,H,ii.disabled,W,Kt.disabled,_t,Oe,E.id,F.boundsBuffer,m.quadTriangleIndexBuffer,F.boundsSegments):j.draw(R,D.TRIANGLES,H,Z[ne.overscaledZ],W,Kt.disabled,_t,Oe,E.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}})(t,l,d,p);break;case"background":(function(m,S,E,M){let R=E.paint.get("background-color"),D=E.paint.get("background-opacity");if(D===0)return;let F=m.context,j=F.gl,W=m.transform,Z=W.tileSize,Y=E.paint.get("background-pattern");if(m.isPatternMissing(Y))return;let te=!Y&&R.a===1&&D===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==te)return;let re=ii.disabled,ne=m.depthModeForSublayer(0,te==="opaque"?At.ReadWrite:At.ReadOnly),H=m.colorModeForRenderPass(),ce=m.useProgram(Y?"backgroundPattern":"background"),ue=M||W.coveringTiles({tileSize:Z,terrain:m.style.map.terrain});Y&&(F.activeTexture.set(j.TEXTURE0),m.imageManager.bind(m.context));let ge=E.getCrossfadeParameters();for(let Te of ue){let Le=M?Te.posMatrix:m.transform.calculatePosMatrix(Te.toUnwrapped()),Ue=Y?Yc(Le,D,m,Y,{tileID:Te,tileSize:Z},ge):Ml(Le,D,R),Xe=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Te);ce.draw(F,j.TRIANGLES,ne,re,H,Kt.disabled,Ue,Xe,E.id,m.tileExtentBuffer,m.quadTriangleIndexBuffer,m.tileExtentSegments)}})(t,0,d,p);break;case"custom":(function(m,S,E){let M=m.context,R=E.implementation;if(m.renderPass==="offscreen"){let D=R.prerender;D&&(m.setCustomLayerDefaults(),M.setColorMode(m.colorModeForRenderPass()),D.call(R,M.gl,m.transform.customLayerMatrix()),M.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),M.setColorMode(m.colorModeForRenderPass()),M.setStencilMode(ii.disabled);let D=R.renderingMode==="3d"?new At(m.context.gl.LEQUAL,At.ReadWrite,m.depthRangeFor3D):m.depthModeForSublayer(0,At.ReadOnly);M.setDepthMode(D),R.render(M.gl,m.transform.customLayerMatrix(),{farZ:m.transform.farZ,nearZ:m.transform.nearZ,fov:m.transform._fov,modelViewProjectionMatrix:m.transform.modelViewProjectionMatrix,projectionMatrix:m.transform.projectionMatrix}),M.setDirty(),m.setBaseState(),M.bindFramebuffer.set(null)}})(t,0,d)}}translatePosMatrix(t,l,d,p,m){if(!d[0]&&!d[1])return t;let S=m?p==="map"?this.transform.angle:0:p==="viewport"?-this.transform.angle:0;if(S){let R=Math.sin(S),D=Math.cos(S);d=[d[0]*D-d[1]*R,d[0]*R+d[1]*D]}let E=[m?d[0]:Dt(l,d[0],this.transform.zoom),m?d[1]:Dt(l,d[1],this.transform.zoom),0],M=new Float32Array(16);return s.J(M,t,E),M}saveTileTexture(t){let l=this._tileTextures[t.size[0]];l?l.push(t):this._tileTextures[t.size[0]]=[t]}getTileTexture(t){let l=this._tileTextures[t];return l&&l.length>0?l.pop():null}isPatternMissing(t){if(!t)return!1;if(!t.from||!t.to)return!0;let l=this.imageManager.getPattern(t.from.toString()),d=this.imageManager.getPattern(t.to.toString());return!l||!d}useProgram(t,l){this.cache=this.cache||{};let d=t+(l?l.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[d]||(this.cache[d]=new Hc(this.context,ks[t],l,Jc[t],this._showOverdrawInspector,this.style.map.terrain)),this.cache[d]}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(){let 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 Ae(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){let{drawingBufferWidth:t,drawingBufferHeight:l}=this.context.gl;return this.width!==t||this.height!==l}}class Vo{constructor(t,l){this.points=t,this.planes=l}static fromInvProjectionMatrix(t,l,d){let p=Math.pow(2,d),m=[[-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(E=>{let M=1/(E=s.af([],E,t))[3]/l*p;return s.b1(E,E,[M,M,1/E[3],M])}),S=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(E=>{let M=function(j,W){var Z=W[0],Y=W[1],te=W[2],re=Z*Z+Y*Y+te*te;return re>0&&(re=1/Math.sqrt(re)),j[0]=W[0]*re,j[1]=W[1]*re,j[2]=W[2]*re,j}([],function(j,W,Z){var Y=W[0],te=W[1],re=W[2],ne=Z[0],H=Z[1],ce=Z[2];return j[0]=te*ce-re*H,j[1]=re*ne-Y*ce,j[2]=Y*H-te*ne,j}([],Pe([],m[E[0]],m[E[1]]),Pe([],m[E[2]],m[E[1]]))),R=-((D=M)[0]*(F=m[E[1]])[0]+D[1]*F[1]+D[2]*F[2]);var D,F;return M.concat(R)});return new Vo(m,S)}}class jo{constructor(t,l){this.min=t,this.max=l,this.center=function(d,p,m){return d[0]=.5*p[0],d[1]=.5*p[1],d[2]=.5*p[2],d}([],function(d,p,m){return d[0]=p[0]+m[0],d[1]=p[1]+m[1],d[2]=p[2]+m[2],d}([],this.min,this.max))}quadrant(t){let l=[t%2==0,t<2],d=we(this.min),p=we(this.max);for(let m=0;m<l.length;m++)d[m]=l[m]?this.min[m]:this.center[m],p[m]=l[m]?this.center[m]:this.max[m];return p[2]=this.max[2],new jo(d,p)}distanceX(t){return Math.max(Math.min(this.max[0],t[0]),this.min[0])-t[0]}distanceY(t){return Math.max(Math.min(this.max[1],t[1]),this.min[1])-t[1]}intersects(t){let l=[[this.min[0],this.min[1],this.min[2],1],[this.max[0],this.min[1],this.min[2],1],[this.max[0],this.max[1],this.min[2],1],[this.min[0],this.max[1],this.min[2],1],[this.min[0],this.min[1],this.max[2],1],[this.max[0],this.min[1],this.max[2],1],[this.max[0],this.max[1],this.max[2],1],[this.min[0],this.max[1],this.max[2],1]],d=!0;for(let p=0;p<t.planes.length;p++){let m=t.planes[p],S=0;for(let E=0;E<l.length;E++)s.b2(m,l[E])>=0&&S++;if(S===0)return 0;S!==l.length&&(d=!1)}if(d)return 2;for(let p=0;p<3;p++){let m=Number.MAX_VALUE,S=-Number.MAX_VALUE;for(let E=0;E<t.points.length;E++){let M=t.points[E][p]-this.min[p];m=Math.min(m,M),S=Math.max(S,M)}if(S<0||m>this.max[p]-this.min[p])return 0}return 1}}class Go{constructor(t=0,l=0,d=0,p=0){if(isNaN(t)||t<0||isNaN(l)||l<0||isNaN(d)||d<0||isNaN(p)||p<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=l,this.left=d,this.right=p}interpolate(t,l,d){return l.top!=null&&t.top!=null&&(this.top=s.y.number(t.top,l.top,d)),l.bottom!=null&&t.bottom!=null&&(this.bottom=s.y.number(t.bottom,l.bottom,d)),l.left!=null&&t.left!=null&&(this.left=s.y.number(t.left,l.left,d)),l.right!=null&&t.right!=null&&(this.right=s.y.number(t.right,l.right,d)),this}getCenter(t,l){let d=s.ac((this.left+t-this.right)/2,0,t),p=s.ac((this.top+l-this.bottom)/2,0,l);return new s.P(d,p)}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Go(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}let dh=85.051129;class Uo{constructor(t,l,d,p,m){this.tileSize=512,this._renderWorldCopies=m===void 0||!!m,this._minZoom=t||0,this._maxZoom=l||22,this._minPitch=d??0,this._maxPitch=p??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new s.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new Go,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){let t=new Uo(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.lngRange=t.lngRange,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 s.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(t){let l=-s.b3(t,-180,180)*Math.PI/180;this.angle!==l&&(this._unmodified=!1,this.angle=l,this._calcMatrices(),this.rotationMatrix=function(){var d=new s.A(4);return s.A!=Float32Array&&(d[1]=0,d[2]=0),d[0]=1,d[3]=1,d}(),function(d,p,m){var S=p[0],E=p[1],M=p[2],R=p[3],D=Math.sin(m),F=Math.cos(m);d[0]=S*F+M*D,d[1]=E*F+R*D,d[2]=S*-D+M*F,d[3]=E*-D+R*F}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(t){let l=s.ac(t,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==l&&(this._unmodified=!1,this._pitch=l,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){let l=Math.min(Math.max(t,this.minZoom),this.maxZoom);this._zoom!==l&&(this._unmodified=!1,this._zoom=l,this.tileZoom=Math.max(0,Math.floor(l)),this.scale=this.zoomScale(l),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,l,d){this._unmodified=!1,this._edgeInsets.interpolate(t,l,d),this._constrain(),this._calcMatrices()}coveringZoomLevel(t){let l=(t.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/t.tileSize));return Math.max(0,l)}getVisibleUnwrappedCoordinates(t){let l=[new s.b4(0,t)];if(this._renderWorldCopies){let d=this.pointCoordinate(new s.P(0,0)),p=this.pointCoordinate(new s.P(this.width,0)),m=this.pointCoordinate(new s.P(this.width,this.height)),S=this.pointCoordinate(new s.P(0,this.height)),E=Math.floor(Math.min(d.x,p.x,m.x,S.x)),M=Math.floor(Math.max(d.x,p.x,m.x,S.x)),R=1;for(let D=E-R;D<=M+R;D++)D!==0&&l.push(new s.b4(D,t))}return l}coveringTiles(t){var l,d;let p=this.coveringZoomLevel(t),m=p;if(t.minzoom!==void 0&&p<t.minzoom)return[];t.maxzoom!==void 0&&p>t.maxzoom&&(p=t.maxzoom);let S=this.pointCoordinate(this.getCameraPoint()),E=s.Z.fromLngLat(this.center),M=Math.pow(2,p),R=[M*S.x,M*S.y,0],D=[M*E.x,M*E.y,0],F=Vo.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,p),j=t.minzoom||0;!t.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(j=p);let W=t.terrain?2/Math.min(this.tileSize,t.tileSize)*this.tileSize:3,Z=H=>({aabb:new jo([H*M,0,0],[(H+1)*M,M,0]),zoom:0,x:0,y:0,wrap:H,fullyVisible:!1}),Y=[],te=[],re=p,ne=t.reparseOverscaled?m:p;if(this._renderWorldCopies)for(let H=1;H<=3;H++)Y.push(Z(-H)),Y.push(Z(H));for(Y.push(Z(0));Y.length>0;){let H=Y.pop(),ce=H.x,ue=H.y,ge=H.fullyVisible;if(!ge){let Oe=H.aabb.intersects(F);if(Oe===0)continue;ge=Oe===2}let Te=t.terrain?R:D,Le=H.aabb.distanceX(Te),Ue=H.aabb.distanceY(Te),Xe=Math.max(Math.abs(Le),Math.abs(Ue));if(H.zoom===re||Xe>W+(1<<re-H.zoom)-2&&H.zoom>=j){let Oe=re-H.zoom,ze=R[0]-.5-(ce<<Oe),et=R[1]-.5-(ue<<Oe);te.push({tileID:new s.S(H.zoom===re?ne:H.zoom,H.wrap,H.zoom,ce,ue),distanceSq:Ee([D[0]-.5-ce,D[1]-.5-ue]),tileDistanceToCamera:Math.sqrt(ze*ze+et*et)})}else for(let Oe=0;Oe<4;Oe++){let ze=(ce<<1)+Oe%2,et=(ue<<1)+(Oe>>1),_t=H.zoom+1,Ve=H.aabb.quadrant(Oe);if(t.terrain){let We=new s.S(_t,H.wrap,_t,ze,et),ft=t.terrain.getMinMaxElevation(We),si=(l=ft.minElevation)!==null&&l!==void 0?l:this.elevation,Tt=(d=ft.maxElevation)!==null&&d!==void 0?d:this.elevation;Ve=new jo([Ve.min[0],Ve.min[1],si],[Ve.max[0],Ve.max[1],Tt])}Y.push({aabb:Ve,zoom:_t,x:ze,y:et,wrap:H.wrap,fullyVisible:ge})}}return te.sort((H,ce)=>H.distanceSq-ce.distanceSq).map(H=>H.tileID)}resize(t,l){this.width=t,this.height=l,this.pixelsToGLUnits=[2/t,-2/l],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){let l=s.ac(t.lat,-85.051129,dh);return new s.P(s.O(t.lng)*this.worldSize,s.Q(l)*this.worldSize)}unproject(t){return new s.Z(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){let l=this.elevation,d=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,p=this.pointLocation(this.centerPoint,t),m=t.getElevationForLngLatZoom(p,this.tileZoom);if(!(this.elevation-m))return;let S=d+l-m,E=Math.cos(this._pitch)*this.cameraToCenterDistance/S/s.b5(1,p.lat),M=this.scaleZoom(E/this.tileSize);this._elevation=m,this._center=p,this.zoom=M}setLocationAtPoint(t,l){let d=this.pointCoordinate(l),p=this.pointCoordinate(this.centerPoint),m=this.locationCoordinate(t),S=new s.Z(m.x-(d.x-p.x),m.y-(d.y-p.y));this.center=this.coordinateLocation(S),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(t,l){return l?this.coordinatePoint(this.locationCoordinate(t),l.getElevationForLngLatZoom(t,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(t))}pointLocation(t,l){return this.coordinateLocation(this.pointCoordinate(t,l))}locationCoordinate(t){return s.Z.fromLngLat(t)}coordinateLocation(t){return t&&t.toLngLat()}pointCoordinate(t,l){if(l){let j=l.pointCoordinate(t);if(j!=null)return j}let d=[t.x,t.y,0,1],p=[t.x,t.y,1,1];s.af(d,d,this.pixelMatrixInverse),s.af(p,p,this.pixelMatrixInverse);let m=d[3],S=p[3],E=d[1]/m,M=p[1]/S,R=d[2]/m,D=p[2]/S,F=R===D?0:(0-R)/(D-R);return new s.Z(s.y.number(d[0]/m,p[0]/S,F)/this.worldSize,s.y.number(E,M,F)/this.worldSize)}coordinatePoint(t,l=0,d=this.pixelMatrix){let p=[t.x*this.worldSize,t.y*this.worldSize,l,1];return s.af(p,p,d),new s.P(p[0]/p[3],p[1]/p[3])}getBounds(){let t=Math.max(0,this.height/2-this.getHorizon());return new ve().extend(this.pointLocation(new s.P(0,t))).extend(this.pointLocation(new s.P(this.width,t))).extend(this.pointLocation(new s.P(this.width,this.height))).extend(this.pointLocation(new s.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ve([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,dh])}calculateTileMatrix(t){let l=t.canonical,d=this.worldSize/this.zoomScale(l.z),p=l.x+Math.pow(2,l.z)*t.wrap,m=s.an(new Float64Array(16));return s.J(m,m,[p*d,l.y*d,0]),s.K(m,m,[d/s.X,d/s.X,1]),m}calculatePosMatrix(t,l=!1){let d=t.key,p=l?this._alignedPosMatrixCache:this._posMatrixCache;if(p[d])return p[d];let m=this.calculateTileMatrix(t);return s.L(m,l?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,m),p[d]=new Float32Array(m),p[d]}calculateFogMatrix(t){let l=t.key,d=this._fogMatrixCache;if(d[l])return d[l];let p=this.calculateTileMatrix(t);return s.L(p,this.fogMatrix,p),d[l]=new Float32Array(p),d[l]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(t,l){l=s.ac(+l,this.minZoom,this.maxZoom);let d={center:new s.N(t.lng,t.lat),zoom:l},p=this.lngRange;if(!this._renderWorldCopies&&p===null){let H=179.9999999999;p=[-H,H]}let m=this.tileSize*this.zoomScale(d.zoom),S=0,E=m,M=0,R=m,D=0,F=0,{x:j,y:W}=this.size;if(this.latRange){let H=this.latRange;S=s.Q(H[1])*m,E=s.Q(H[0])*m,E-S<W&&(D=W/(E-S))}p&&(M=s.b3(s.O(p[0])*m,0,m),R=s.b3(s.O(p[1])*m,0,m),R<M&&(R+=m),R-M<j&&(F=j/(R-M)));let{x:Z,y:Y}=this.project.call({worldSize:m},t),te,re,ne=Math.max(F||0,D||0);if(ne){let H=new s.P(F?(R+M)/2:Z,D?(E+S)/2:Y);return d.center=this.unproject.call({worldSize:m},H).wrap(),d.zoom+=this.scaleZoom(ne),d}if(this.latRange){let H=W/2;Y-H<S&&(re=S+H),Y+H>E&&(re=E-H)}if(p){let H=(M+R)/2,ce=Z;this._renderWorldCopies&&(ce=s.b3(Z,H-m/2,H+m/2));let ue=j/2;ce-ue<M&&(te=M+ue),ce+ue>R&&(te=R-ue)}if(te!==void 0||re!==void 0){let H=new s.P(te??Z,re??Y);d.center=this.unproject.call({worldSize:m},H).wrap()}return d}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;let t=this._unmodified,{center:l,zoom:d}=this.getConstrained(this.center,this.zoom);this.center=l,this.zoom=d,this._unmodified=t,this._constraining=!1}_calcMatrices(){if(!this.height)return;let t=this.centerOffset,l=this.point.x,d=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=s.b5(1,this.center.lat)*this.worldSize;let p=s.an(new Float64Array(16));s.K(p,p,[this.width/2,-this.height/2,1]),s.J(p,p,[1,-1,0]),this.labelPlaneMatrix=p,p=s.an(new Float64Array(16)),s.K(p,p,[1,-1,1]),s.J(p,p,[-1,-1,0]),s.K(p,p,[2/this.width,2/this.height,1]),this.glCoordMatrix=p;let m=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),S=Math.min(this.elevation,this.minElevationForCurrentTile),E=m-S*this._pixelPerMeter/Math.cos(this._pitch),M=S<0?E:m,R=Math.PI/2+this._pitch,D=this._fov*(.5+t.y/this.height),F=Math.sin(D)*M/Math.sin(s.ac(Math.PI-R-D,.01,Math.PI-.01)),j=this.getHorizon(),W=2*Math.atan(j/this.cameraToCenterDistance)*(.5+t.y/(2*j)),Z=Math.sin(W)*M/Math.sin(s.ac(Math.PI-R-W,.01,Math.PI-.01)),Y=Math.min(F,Z);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*Y+M),this.nearZ=this.height/50,p=new Float64Array(16),s.b6(p,this._fov,this.width/this.height,this.nearZ,this.farZ),p[8]=2*-t.x/this.width,p[9]=2*t.y/this.height,this.projectionMatrix=s.ae(p),s.K(p,p,[1,-1,1]),s.J(p,p,[0,0,-this.cameraToCenterDistance]),s.b7(p,p,this._pitch),s.ad(p,p,this.angle),s.J(p,p,[-l,-d,0]),this.mercatorMatrix=s.K([],p,[this.worldSize,this.worldSize,this.worldSize]),s.K(p,p,[1,1,this._pixelPerMeter]),this.pixelMatrix=s.L(new Float64Array(16),this.labelPlaneMatrix,p),s.J(p,p,[0,0,-this.elevation]),this.modelViewProjectionMatrix=p,this.invModelViewProjectionMatrix=s.as([],p),this.fogMatrix=new Float64Array(16),s.b6(this.fogMatrix,this._fov,this.width/this.height,m,this.farZ),this.fogMatrix[8]=2*-t.x/this.width,this.fogMatrix[9]=2*t.y/this.height,s.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),s.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),s.b7(this.fogMatrix,this.fogMatrix,this._pitch),s.ad(this.fogMatrix,this.fogMatrix,this.angle),s.J(this.fogMatrix,this.fogMatrix,[-l,-d,0]),s.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),s.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=s.L(new Float64Array(16),this.labelPlaneMatrix,p);let te=this.width%2/2,re=this.height%2/2,ne=Math.cos(this.angle),H=Math.sin(this.angle),ce=l-Math.round(l)+ne*te+H*re,ue=d-Math.round(d)+ne*re+H*te,ge=new Float64Array(p);if(s.J(ge,ge,[ce>.5?ce-1:ce,ue>.5?ue-1:ue,0]),this.alignedModelViewProjectionMatrix=ge,p=s.as(new Float64Array(16),this.pixelMatrix),!p)throw new Error("failed to invert matrix");this.pixelMatrixInverse=p,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;let t=this.pointCoordinate(new s.P(0,0)),l=[t.x*this.worldSize,t.y*this.worldSize,0,1];return s.af(l,l,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){let t=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new s.P(0,t))}getCameraQueryGeometry(t){let l=this.getCameraPoint();if(t.length===1)return[t[0],l];{let d=l.x,p=l.y,m=l.x,S=l.y;for(let E of t)d=Math.min(d,E.x),p=Math.min(p,E.y),m=Math.max(m,E.x),S=Math.max(S,E.y);return[new s.P(d,p),new s.P(m,p),new s.P(m,S),new s.P(d,S),new s.P(d,p)]}}lngLatToCameraDepth(t,l){let d=this.locationCoordinate(t),p=[d.x*this.worldSize,d.y*this.worldSize,l,1];return s.af(p,p,this.modelViewProjectionMatrix),p[2]/p[3]}}function Ba(g,t){let l,d=!1,p=null,m=null,S=()=>{p=null,d&&(g.apply(m,l),p=setTimeout(S,t),d=!1)};return(...E)=>(d=!0,m=this,l=E,p||S(),p)}class Nl{constructor(t){this._getCurrentHash=()=>{let l=window.location.hash.replace("#","");if(this._hashName){let d;return l.split("&").map(p=>p.split("=")).forEach(p=>{p[0]===this._hashName&&(d=p)}),(d&&d[1]||"").split("/")}return l.split("/")},this._onHashChange=()=>{let l=this._getCurrentHash();if(l.length>=3&&!l.some(d=>isNaN(d))){let d=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(l[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+l[2],+l[1]],zoom:+l[0],bearing:d,pitch:+(l[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{let l=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,l)},this._removeHash=()=>{let l=this._getCurrentHash();if(l.length===0)return;let d=l.join("/"),p=d;p.split("&").length>0&&(p=p.split("&")[0]),this._hashName&&(p=`${this._hashName}=${d}`);let m=window.location.hash.replace(p,"");m.startsWith("#&")?m=m.slice(0,1)+m.slice(2):m==="#"&&(m="");let S=window.location.href.replace(/(#.+)?$/,m);S=S.replace("&&","&"),window.history.replaceState(window.history.state,null,S)},this._updateHash=Ba(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()),this._removeHash(),delete this._map,this}getHashString(t){let l=this._map.getCenter(),d=Math.round(100*this._map.getZoom())/100,p=Math.ceil((d*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,p),S=Math.round(l.lng*m)/m,E=Math.round(l.lat*m)/m,M=this._map.getBearing(),R=this._map.getPitch(),D="";if(D+=t?`/${S}/${E}/${d}`:`${d}/${E}/${S}`,(M||R)&&(D+="/"+Math.round(10*M)/10),R&&(D+=`/${Math.round(R)}`),this._hashName){let F=this._hashName,j=!1,W=window.location.hash.slice(1).split("&").map(Z=>{let Y=Z.split("=")[0];return Y===F?(j=!0,`${Y}=${D}`):Z}).filter(Z=>Z);return j||W.push(`${F}=${D}`),`#${W.join("&")}`}return`#${D}`}}let Vl={linearity:.3,easing:s.b8(0,0,.3,1)},ph=s.e({deceleration:2500,maxSpeed:1400},Vl),Ff=s.e({deceleration:20,maxSpeed:1400},Vl),Sd=s.e({deceleration:1e3,maxSpeed:360},Vl),jl=s.e({deceleration:1e3,maxSpeed:90},Vl);class fh{constructor(t){this._map=t,this.clear()}clear(){this._inertiaBuffer=[]}record(t){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:T.now(),settings:t})}_drainInertiaBuffer(){let t=this._inertiaBuffer,l=T.now();for(;t.length>0&&l-t[0].time>160;)t.shift()}_onMoveEnd(t){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;let l={zoom:0,bearing:0,pitch:0,pan:new s.P(0,0),pinchAround:void 0,around:void 0};for(let{settings:m}of this._inertiaBuffer)l.zoom+=m.zoomDelta||0,l.bearing+=m.bearingDelta||0,l.pitch+=m.pitchDelta||0,m.panDelta&&l.pan._add(m.panDelta),m.around&&(l.around=m.around),m.pinchAround&&(l.pinchAround=m.pinchAround);let d=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,p={};if(l.pan.mag()){let m=Va(l.pan.mag(),d,s.e({},ph,t||{}));p.offset=l.pan.mult(m.amount/l.pan.mag()),p.center=this._map.transform.center,Na(p,m)}if(l.zoom){let m=Va(l.zoom,d,Ff);p.zoom=this._map.transform.zoom+m.amount,Na(p,m)}if(l.bearing){let m=Va(l.bearing,d,Sd);p.bearing=this._map.transform.bearing+s.ac(m.amount,-179,179),Na(p,m)}if(l.pitch){let m=Va(l.pitch,d,jl);p.pitch=this._map.transform.pitch+m.amount,Na(p,m)}if(p.zoom||p.bearing){let m=l.pinchAround===void 0?l.around:l.pinchAround;p.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),s.e(p,{noMoveStart:!0})}}function Na(g,t){(!g.duration||g.duration<t.duration)&&(g.duration=t.duration,g.easing=t.easing)}function Va(g,t,l){let{maxSpeed:d,linearity:p,deceleration:m}=l,S=s.ac(g*p/(t/1e3),-d,d),E=Math.abs(S)/(m*p);return{easing:l.easing,duration:1e3*E,amount:S*(E/2)}}class Yi extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d,p={}){let m=C.mousePos(l.getCanvas(),d),S=l.unproject(m);super(t,s.e({point:m,lngLat:S,originalEvent:d},p)),this._defaultPrevented=!1,this.target=l}}class ao extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d){let p=t==="touchend"?d.changedTouches:d.touches,m=C.touchPos(l.getCanvasContainer(),p),S=m.map(M=>l.unproject(M)),E=m.reduce((M,R,D,F)=>M.add(R.div(F.length)),new s.P(0,0));super(t,{points:m,point:E,lngLats:S,lngLat:l.unproject(E),originalEvent:d}),this._defaultPrevented=!1}}class Id extends s.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(t,l,d){super(t,{originalEvent:d}),this._defaultPrevented=!1}}class Cd{constructor(t,l){this._map=t,this._clickTolerance=l.clickTolerance}reset(){delete this._mousedownPos}wheel(t){return this._firePreventable(new Id(t.type,this._map,t))}mousedown(t,l){return this._mousedownPos=l,this._firePreventable(new Yi(t.type,this._map,t))}mouseup(t){this._map.fire(new Yi(t.type,this._map,t))}click(t,l){this._mousedownPos&&this._mousedownPos.dist(l)>=this._clickTolerance||this._map.fire(new Yi(t.type,this._map,t))}dblclick(t){return this._firePreventable(new Yi(t.type,this._map,t))}mouseover(t){this._map.fire(new Yi(t.type,this._map,t))}mouseout(t){this._map.fire(new Yi(t.type,this._map,t))}touchstart(t){return this._firePreventable(new ao(t.type,this._map,t))}touchmove(t){this._map.fire(new ao(t.type,this._map,t))}touchend(t){this._map.fire(new ao(t.type,this._map,t))}touchcancel(t){this._map.fire(new ao(t.type,this._map,t))}_firePreventable(t){if(this._map.fire(t),t.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class _i{constructor(t){this._map=t}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(t){this._map.fire(new Yi(t.type,this._map,t))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Yi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(t){this._delayContextMenu?this._contextMenuEvent=t:this._ignoreContextMenu||this._map.fire(new Yi(t.type,this._map,t)),this._map.listens("contextmenu")&&t.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class On{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(s.P.convert(t),this._map.terrain)}}class Kr{constructor(t,l){this._map=t,this._tr=new On(t),this._el=t.getCanvasContainer(),this._container=t.getContainer(),this._clickTolerance=l.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(t,l){this.isEnabled()&&t.shiftKey&&t.button===0&&(C.disableDrag(),this._startPos=this._lastPos=l,this._active=!0)}mousemoveWindow(t,l){if(!this._active)return;let d=l;if(this._lastPos.equals(d)||!this._box&&d.dist(this._startPos)<this._clickTolerance)return;let p=this._startPos;this._lastPos=d,this._box||(this._box=C.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",t));let m=Math.min(p.x,d.x),S=Math.max(p.x,d.x),E=Math.min(p.y,d.y),M=Math.max(p.y,d.y);C.setTransform(this._box,`translate(${m}px,${E}px)`),this._box.style.width=S-m+"px",this._box.style.height=M-E+"px"}mouseupWindow(t,l){if(!this._active||t.button!==0)return;let d=this._startPos,p=l;if(this.reset(),C.suppressClick(),d.x!==p.x||d.y!==p.y)return this._map.fire(new s.k("boxzoomend",{originalEvent:t})),{cameraAnimation:m=>m.fitScreenCoordinates(d,p,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&&(C.remove(this._box),this._box=null),C.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(t,l){return this._map.fire(new s.k(t,{originalEvent:l}))}}function ja(g,t){if(g.length!==t.length)throw new Error(`The number of touches and points are not equal - touches ${g.length}, points ${t.length}`);let l={};for(let d=0;d<g.length;d++)l[g[d].identifier]=t[d];return l}class mh{constructor(t){this.reset(),this.numTouches=t.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(t,l,d){(this.centroid||d.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=t.timeStamp),d.length===this.numTouches&&(this.centroid=function(p){let m=new s.P(0,0);for(let S of p)m._add(S);return m.div(p.length)}(l),this.touches=ja(d,l)))}touchmove(t,l,d){if(this.aborted||!this.centroid)return;let p=ja(d,l);for(let m in this.touches){let S=p[m];(!S||S.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(t,l,d){if((!this.centroid||t.timeStamp-this.startTime>500)&&(this.aborted=!0),d.length===0){let p=!this.aborted&&this.centroid;if(this.reset(),p)return p}}}class Gl{constructor(t){this.singleTap=new mh(t),this.numTaps=t.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(t,l,d){this.singleTap.touchstart(t,l,d)}touchmove(t,l,d){this.singleTap.touchmove(t,l,d)}touchend(t,l,d){let p=this.singleTap.touchend(t,l,d);if(p){let m=t.timeStamp-this.lastTime<500,S=!this.lastTap||this.lastTap.dist(p)<30;if(m&&S||this.reset(),this.count++,this.lastTime=t.timeStamp,this.lastTap=p,this.count===this.numTaps)return this.reset(),p}}}class qo{constructor(t){this._tr=new On(t),this._zoomIn=new Gl({numTouches:1,numTaps:2}),this._zoomOut=new Gl({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(t,l,d){this._zoomIn.touchstart(t,l,d),this._zoomOut.touchstart(t,l,d)}touchmove(t,l,d){this._zoomIn.touchmove(t,l,d),this._zoomOut.touchmove(t,l,d)}touchend(t,l,d){let p=this._zoomIn.touchend(t,l,d),m=this._zoomOut.touchend(t,l,d),S=this._tr;return p?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:S.zoom+1,around:S.unproject(p)},{originalEvent:t})}):m?(this._active=!0,t.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:E=>E.easeTo({duration:300,zoom:S.zoom-1,around:S.unproject(m)},{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 ps{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){let l=this._moveFunction(...t);if(l.bearingDelta||l.pitchDelta||l.around||l.panDelta)return this._active=!0,l}dragStart(t,l){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(t)&&(this._moveStateManager.startMove(t),this._lastPoint=l.length?l[0]:l,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(t,l){if(!this.isEnabled())return;let d=this._lastPoint;if(!d)return;if(t.preventDefault(),!this._moveStateManager.isValidMoveEvent(t))return void this.reset(t);let p=l.length?l[0]:l;return!this._moved&&p.dist(d)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=p,this._move(d,p))}dragEnd(t){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(t)&&(this._moved&&C.suppressClick(),this.reset(t))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}let gh={0:1,2:2};class Ul{constructor(t){this._correctEvent=t.checkCorrectEvent}startMove(t){let l=C.mouseButton(t);this._eventButton=l}endMove(t){delete this._eventButton}isValidStartEvent(t){return this._correctEvent(t)}isValidMoveEvent(t){return!function(l,d){let p=gh[d];return l.buttons===void 0||(l.buttons&p)!==p}(t,this._eventButton)}isValidEndEvent(t){return C.mouseButton(t)===this._eventButton}}class yh{constructor(){this._firstTouch=void 0}_isOneFingerTouch(t){return t.targetTouches.length===1}_isSameTouchEvent(t){return t.targetTouches[0].identifier===this._firstTouch}startMove(t){this._firstTouch=t.targetTouches[0].identifier}endMove(t){delete this._firstTouch}isValidStartEvent(t){return this._isOneFingerTouch(t)}isValidMoveEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}isValidEndEvent(t){return this._isOneFingerTouch(t)&&this._isSameTouchEvent(t)}}let ql=g=>{g.mousedown=g.dragStart,g.mousemoveWindow=g.dragMove,g.mouseup=g.dragEnd,g.contextmenu=t=>{t.preventDefault()}},_h=({enable:g,clickTolerance:t,bearingDegreesPerPixelMoved:l=.8})=>{let d=new Ul({checkCorrectEvent:p=>C.mouseButton(p)===0&&p.ctrlKey||C.mouseButton(p)===2});return new ps({clickTolerance:t,move:(p,m)=>({bearingDelta:(m.x-p.x)*l}),moveStateManager:d,enable:g,assignEvents:ql})},xh=({enable:g,clickTolerance:t,pitchDegreesPerPixelMoved:l=-.5})=>{let d=new Ul({checkCorrectEvent:p=>C.mouseButton(p)===0&&p.ctrlKey||C.mouseButton(p)===2});return new ps({clickTolerance:t,move:(p,m)=>({pitchDelta:(m.y-p.y)*l}),moveStateManager:d,enable:g,assignEvents:ql})};class lo{constructor(t,l){this._clickTolerance=t.clickTolerance||1,this._map=l,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new s.P(0,0)}_shouldBePrevented(t){return t<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(t,l,d){return this._calculateTransform(t,l,d)}touchmove(t,l,d){if(this._active){if(!this._shouldBePrevented(d.length))return t.preventDefault(),this._calculateTransform(t,l,d);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",t)}}touchend(t,l,d){this._calculateTransform(t,l,d),this._active&&this._shouldBePrevented(d.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(t,l,d){d.length>0&&(this._active=!0);let p=ja(d,l),m=new s.P(0,0),S=new s.P(0,0),E=0;for(let R in p){let D=p[R],F=this._touches[R];F&&(m._add(D),S._add(D.sub(F)),E++,p[R]=D)}if(this._touches=p,this._shouldBePrevented(E)||!S.mag())return;let M=S.div(E);return this._sum._add(M),this._sum.mag()<this._clickTolerance?void 0:{around:m.div(E),panDelta:M}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $l{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(t,l,d){this._firstTwoTouches||d.length<2||(this._firstTwoTouches=[d[0].identifier,d[1].identifier],this._start([l[0],l[1]]))}touchmove(t,l,d){if(!this._firstTwoTouches)return;t.preventDefault();let[p,m]=this._firstTwoTouches,S=Ga(d,l,p),E=Ga(d,l,m);if(!S||!E)return;let M=this._aroundCenter?null:S.add(E).div(2);return this._move([S,E],M,t)}touchend(t,l,d){if(!this._firstTwoTouches)return;let[p,m]=this._firstTwoTouches,S=Ga(d,l,p),E=Ga(d,l,m);S&&E||(this._active&&C.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(t){this._enabled=!0,this._aroundCenter=!!t&&t.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Ga(g,t,l){for(let d=0;d<g.length;d++)if(g[d].identifier===l)return t[d]}function vh(g,t){return Math.log(g/t)/Math.LN2}class bh extends $l{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(t){this._startDistance=this._distance=t[0].dist(t[1])}_move(t,l){let d=this._distance;if(this._distance=t[0].dist(t[1]),this._active||!(Math.abs(vh(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:vh(this._distance,d),pinchAround:l}}}function wh(g,t){return 180*g.angleWith(t)/Math.PI}class Sh extends $l{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(t){this._startVector=this._vector=t[0].sub(t[1]),this._minDiameter=t[0].dist(t[1])}_move(t,l,d){let p=this._vector;if(this._vector=t[0].sub(t[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:wh(this._vector,p),pinchAround:l}}_isBelowThreshold(t){this._minDiameter=Math.min(this._minDiameter,t.mag());let l=25/(Math.PI*this._minDiameter)*360,d=wh(t,this._startVector);return Math.abs(d)<l}}function Wl(g){return Math.abs(g.y)>Math.abs(g.x)}class $o extends $l{constructor(t){super(),this._currentTouchCount=0,this._map=t}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(t,l,d){super.touchstart(t,l,d),this._currentTouchCount=d.length}_start(t){this._lastPoints=t,Wl(t[0].sub(t[1]))&&(this._valid=!1)}_move(t,l,d){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;let p=t[0].sub(this._lastPoints[0]),m=t[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(p,m,d.timeStamp),this._valid?(this._lastPoints=t,this._active=!0,{pitchDelta:(p.y+m.y)/2*-.5}):void 0}gestureBeginsVertically(t,l,d){if(this._valid!==void 0)return this._valid;let p=t.mag()>=2,m=l.mag()>=2;if(!p&&!m)return;if(!p||!m)return this._firstMove===void 0&&(this._firstMove=d),d-this._firstMove<100&&void 0;let S=t.y>0==l.y>0;return Wl(t)&&Wl(l)&&S}}let Ed={panStep:100,bearingStep:15,pitchStep:10};class un{constructor(t){this._tr=new On(t);let l=Ed;this._panStep=l.panStep,this._bearingStep=l.bearingStep,this._pitchStep=l.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(t){if(t.altKey||t.ctrlKey||t.metaKey)return;let l=0,d=0,p=0,m=0,S=0;switch(t.keyCode){case 61:case 107:case 171:case 187:l=1;break;case 189:case 109:case 173:l=-1;break;case 37:t.shiftKey?d=-1:(t.preventDefault(),m=-1);break;case 39:t.shiftKey?d=1:(t.preventDefault(),m=1);break;case 38:t.shiftKey?p=1:(t.preventDefault(),S=-1);break;case 40:t.shiftKey?p=-1:(t.preventDefault(),S=1);break;default:return}return this._rotationDisabled&&(d=0,p=0),{cameraAnimation:E=>{let M=this._tr;E.easeTo({duration:300,easeId:"keyboardHandler",easing:es,zoom:l?Math.round(M.zoom)+l*(t.shiftKey?2:1):M.zoom,bearing:M.bearing+d*this._bearingStep,pitch:M.pitch+p*this._pitchStep,offset:[-m*this._panStep,-S*this._panStep],center:M.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 es(g){return g*(2-g)}let Ih=4.000244140625;class Bn{constructor(t,l){this._onTimeout=d=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(d)},this._map=t,this._tr=new On(t),this._triggerRenderFrame=l,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)}_shouldBePrevented(t){return!!this._map.cooperativeGestures.isEnabled()&&!(t.ctrlKey||this._map.cooperativeGestures.isBypassed(t))}wheel(t){if(!this.isEnabled())return;if(this._shouldBePrevented(t))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",t);let l=t.deltaMode===WheelEvent.DOM_DELTA_LINE?40*t.deltaY:t.deltaY,d=T.now(),p=d-(this._lastWheelEventTime||0);this._lastWheelEventTime=d,l!==0&&l%Ih==0?this._type="wheel":l!==0&&Math.abs(l)<4?this._type="trackpad":p>400?(this._type=null,this._lastValue=l,this._timeout=setTimeout(this._onTimeout,40,t)):this._type||(this._type=Math.abs(p*l)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,l+=this._lastValue)),t.shiftKey&&l&&(l/=4),this._type&&(this._lastWheelEvent=t,this._delta-=l,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);let l=C.mousePos(this._map.getCanvas(),t),d=this._tr;this._around=l.y>d.transform.height/2-d.transform.getHorizon()?s.N.convert(this._aroundCenter?d.center:d.unproject(l)):s.N.convert(d.center),this._aroundPoint=d.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;let t=this._tr.transform;if(this._delta!==0){let M=this._type==="wheel"&&Math.abs(this._delta)>Ih?this._wheelZoomRate:this._defaultZoomRate,R=2/(1+Math.exp(-Math.abs(this._delta*M)));this._delta<0&&R!==0&&(R=1/R);let D=typeof this._targetZoom=="number"?t.zoomScale(this._targetZoom):t.scale;this._targetZoom=Math.min(t.maxZoom,Math.max(t.minZoom,t.scaleZoom(D*R))),this._type==="wheel"&&(this._startZoom=t.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}let l=typeof this._targetZoom=="number"?this._targetZoom:t.zoom,d=this._startZoom,p=this._easing,m,S=!1,E=T.now()-this._lastWheelEventTime;if(this._type==="wheel"&&d&&p&&E){let M=Math.min(E/200,1),R=p(M);m=s.y.number(d,l,R),M<1?this._frameId||(this._frameId=!0):S=!0}else m=l,S=!0;return this._active=!0,S&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!S,zoomDelta:m-t.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(t){let l=s.b9;if(this._prevEase){let d=this._prevEase,p=(T.now()-d.start)/d.duration,m=d.easing(p+.01)-d.easing(p),S=.27/Math.sqrt(m*m+1e-4)*.01,E=Math.sqrt(.0729-S*S);l=s.b8(S,E,.25,1)}return this._prevEase={start:T.now(),duration:t,easing:l},l}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class co{constructor(t,l){this._clickZoom=t,this._tapZoom=l}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 zf{constructor(t){this._tr=new On(t),this.reset()}reset(){this._active=!1}dblclick(t,l){return t.preventDefault(),{cameraAnimation:d=>{d.easeTo({duration:300,zoom:this._tr.zoom+(t.shiftKey?-1:1),around:this._tr.unproject(l)},{originalEvent:t})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Of{constructor(){this._tap=new Gl({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,l,d){if(!this._swipePoint)if(this._tapTime){let p=l[0],m=t.timeStamp-this._tapTime<500,S=this._tapPoint.dist(p)<30;m&&S?d.length>0&&(this._swipePoint=p,this._swipeTouch=d[0].identifier):this.reset()}else this._tap.touchstart(t,l,d)}touchmove(t,l,d){if(this._tapTime){if(this._swipePoint){if(d[0].identifier!==this._swipeTouch)return;let p=l[0],m=p.y-this._swipePoint.y;return this._swipePoint=p,t.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(t,l,d)}touchend(t,l,d){if(this._tapTime)this._swipePoint&&d.length===0&&this.reset();else{let p=this._tap.touchend(t,l,d);p&&(this._tapTime=t.timeStamp,this._tapPoint=p)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Td{constructor(t,l,d){this._el=t,this._mousePan=l,this._touchPan=d}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 Md{constructor(t,l,d){this._pitchWithRotate=t.pitchWithRotate,this._mouseRotate=l,this._mousePitch=d}enable(){this._mouseRotate.enable(),this._pitchWithRotate&&this._mousePitch.enable()}disable(){this._mouseRotate.disable(),this._mousePitch.disable()}isEnabled(){return this._mouseRotate.isEnabled()&&(!this._pitchWithRotate||this._mousePitch.isEnabled())}isActive(){return this._mouseRotate.isActive()||this._mousePitch.isActive()}}class Ch{constructor(t,l,d,p){this._el=t,this._touchZoom=l,this._touchRotate=d,this._tapDragZoom=p,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 Wo{constructor(t,l){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=t,this._options=l,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;let t=this._map.getCanvasContainer();t.classList.add("maplibregl-cooperative-gestures"),this._container=C.create("div","maplibregl-cooperative-gesture-screen",t);let l=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(l=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));let d=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),p=document.createElement("div");p.className="maplibregl-desktop-message",p.textContent=l,this._container.appendChild(p);let m=document.createElement("div");m.className="maplibregl-mobile-message",m.textContent=d,this._container.appendChild(m),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(C.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._destroyUI()}isEnabled(){return this._enabled}isBypassed(t){return t[this._bypassKey]}notifyGestureBlocked(t,l){this._enabled&&(this._map.fire(new s.k("cooperativegestureprevented",{gestureType:t,originalEvent:l})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}let dn=g=>g.zoom||g.drag||g.pitch||g.rotate;class Ye extends s.k{}function Zl(g){return g.panDelta&&g.panDelta.mag()||g.zoomDelta||g.bearingDelta||g.pitchDelta}class Eh{constructor(t,l){this.handleWindowEvent=p=>{this.handleEvent(p,`${p.type}Window`)},this.handleEvent=(p,m)=>{if(p.type==="blur")return void this.stop(!0);this._updatingCamera=!0;let S=p.type==="renderFrame"?void 0:p,E={needsRenderFrame:!1},M={},R={},D=p.touches,F=D?this._getMapTouches(D):void 0,j=F?C.touchPos(this._map.getCanvas(),F):C.mousePos(this._map.getCanvas(),p);for(let{handlerName:Y,handler:te,allowed:re}of this._handlers){if(!te.isEnabled())continue;let ne;this._blockedByActive(R,re,Y)?te.reset():te[m||p.type]&&(ne=te[m||p.type](p,j,F),this.mergeHandlerResult(E,M,ne,Y,S),ne&&ne.needsRenderFrame&&this._triggerRenderFrame()),(ne||te.isActive())&&(R[Y]=te)}let W={};for(let Y in this._previousActiveHandlers)R[Y]||(W[Y]=S);this._previousActiveHandlers=R,(Object.keys(W).length||Zl(E))&&(this._changes.push([E,M,W]),this._triggerRenderFrame()),(Object.keys(R).length||Zl(E))&&this._map._stop(!0),this._updatingCamera=!1;let{cameraAnimation:Z}=E;Z&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Z(this._map))},this._map=t,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new fh(t),this._bearingSnap=l.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(l);let d=this._el;this._listeners=[[d,"touchstart",{passive:!0}],[d,"touchmove",{passive:!1}],[d,"touchend",void 0],[d,"touchcancel",void 0],[d,"mousedown",void 0],[d,"mousemove",void 0],[d,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[d,"mouseover",void 0],[d,"mouseout",void 0],[d,"dblclick",void 0],[d,"click",void 0],[d,"keydown",{capture:!1}],[d,"keyup",void 0],[d,"wheel",{passive:!1}],[d,"contextmenu",void 0],[window,"blur",void 0]];for(let[p,m,S]of this._listeners)C.addEventListener(p,m,p===document?this.handleWindowEvent:this.handleEvent,S)}destroy(){for(let[t,l,d]of this._listeners)C.removeEventListener(t,l,t===document?this.handleWindowEvent:this.handleEvent,d)}_addDefaultHandlers(t){let l=this._map,d=l.getCanvasContainer();this._add("mapEvent",new Cd(l,t));let p=l.boxZoom=new Kr(l,t);this._add("boxZoom",p),t.interactive&&t.boxZoom&&p.enable();let m=l.cooperativeGestures=new Wo(l,t.cooperativeGestures);this._add("cooperativeGestures",m),t.cooperativeGestures&&m.enable();let S=new qo(l),E=new zf(l);l.doubleClickZoom=new co(E,S),this._add("tapZoom",S),this._add("clickZoom",E),t.interactive&&t.doubleClickZoom&&l.doubleClickZoom.enable();let M=new Of;this._add("tapDragZoom",M);let R=l.touchPitch=new $o(l);this._add("touchPitch",R),t.interactive&&t.touchPitch&&l.touchPitch.enable(t.touchPitch);let D=_h(t),F=xh(t);l.dragRotate=new Md(t,D,F),this._add("mouseRotate",D,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),t.interactive&&t.dragRotate&&l.dragRotate.enable();let j=(({enable:ne,clickTolerance:H})=>{let ce=new Ul({checkCorrectEvent:ue=>C.mouseButton(ue)===0&&!ue.ctrlKey});return new ps({clickTolerance:H,move:(ue,ge)=>({around:ge,panDelta:ge.sub(ue)}),activateOnStart:!0,moveStateManager:ce,enable:ne,assignEvents:ql})})(t),W=new lo(t,l);l.dragPan=new Td(d,j,W),this._add("mousePan",j),this._add("touchPan",W,["touchZoom","touchRotate"]),t.interactive&&t.dragPan&&l.dragPan.enable(t.dragPan);let Z=new Sh,Y=new bh;l.touchZoomRotate=new Ch(d,Y,Z,M),this._add("touchRotate",Z,["touchPan","touchZoom"]),this._add("touchZoom",Y,["touchPan","touchRotate"]),t.interactive&&t.touchZoomRotate&&l.touchZoomRotate.enable(t.touchZoomRotate);let te=l.scrollZoom=new Bn(l,()=>this._triggerRenderFrame());this._add("scrollZoom",te,["mousePan"]),t.interactive&&t.scrollZoom&&l.scrollZoom.enable(t.scrollZoom);let re=l.keyboard=new un(l);this._add("keyboard",re),t.interactive&&t.keyboard&&l.keyboard.enable(),this._add("blockableMapEvent",new _i(l))}_add(t,l,d){this._handlers.push({handlerName:t,handler:l,allowed:d}),this._handlersById[t]=l}stop(t){if(!this._updatingCamera){for(let{handler:l}of this._handlers)l.reset();this._inertia.clear(),this._fireEvents({},{},t),this._changes=[]}}isActive(){for(let{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!!dn(this._eventsInProgress)||this.isZooming()}_blockedByActive(t,l,d){for(let p in t)if(p!==d&&(!l||l.indexOf(p)<0))return!0;return!1}_getMapTouches(t){let l=[];for(let d of t)this._el.contains(d.target)&&l.push(d);return l}mergeHandlerResult(t,l,d,p,m){if(!d)return;s.e(t,d);let S={handlerName:p,originalEvent:d.originalEvent||m};d.zoomDelta!==void 0&&(l.zoom=S),d.panDelta!==void 0&&(l.drag=S),d.pitchDelta!==void 0&&(l.pitch=S),d.bearingDelta!==void 0&&(l.rotate=S)}_applyChanges(){let t={},l={},d={};for(let[p,m,S]of this._changes)p.panDelta&&(t.panDelta=(t.panDelta||new s.P(0,0))._add(p.panDelta)),p.zoomDelta&&(t.zoomDelta=(t.zoomDelta||0)+p.zoomDelta),p.bearingDelta&&(t.bearingDelta=(t.bearingDelta||0)+p.bearingDelta),p.pitchDelta&&(t.pitchDelta=(t.pitchDelta||0)+p.pitchDelta),p.around!==void 0&&(t.around=p.around),p.pinchAround!==void 0&&(t.pinchAround=p.pinchAround),p.noInertia&&(t.noInertia=p.noInertia),s.e(l,m),s.e(d,S);this._updateMapTransform(t,l,d),this._changes=[]}_updateMapTransform(t,l,d){let p=this._map,m=p._getTransformForUpdate(),S=p.terrain;if(!(Zl(t)||S&&this._terrainMovement))return this._fireEvents(l,d,!0);let{panDelta:E,zoomDelta:M,bearingDelta:R,pitchDelta:D,around:F,pinchAround:j}=t;j!==void 0&&(F=j),p._stop(!0),F=F||p.transform.centerPoint;let W=m.pointLocation(E?F.sub(E):F);R&&(m.bearing+=R),D&&(m.pitch+=D),M&&(m.zoom+=M),S?this._terrainMovement||!l.drag&&!l.zoom?l.drag&&this._terrainMovement?m.center=m.pointLocation(m.centerPoint.sub(E)):m.setLocationAtPoint(W,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,m.setLocationAtPoint(W,F)):m.setLocationAtPoint(W,F),p._applyUpdatedTransform(m),this._map._update(),t.noInertia||this._inertia.record(t),this._fireEvents(l,d,!0)}_fireEvents(t,l,d){let p=dn(this._eventsInProgress),m=dn(t),S={};for(let F in t){let{originalEvent:j}=t[F];this._eventsInProgress[F]||(S[`${F}start`]=j),this._eventsInProgress[F]=t[F]}!p&&m&&this._fireEvent("movestart",m.originalEvent);for(let F in S)this._fireEvent(F,S[F]);m&&this._fireEvent("move",m.originalEvent);for(let F in t){let{originalEvent:j}=t[F];this._fireEvent(F,j)}let E={},M;for(let F in this._eventsInProgress){let{handlerName:j,originalEvent:W}=this._eventsInProgress[F];this._handlersById[j].isActive()||(delete this._eventsInProgress[F],M=l[j]||W,E[`${F}end`]=M)}for(let F in E)this._fireEvent(F,E[F]);let R=dn(this._eventsInProgress),D=(p||m)&&!R;if(D&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;let F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(d&&D){this._updatingCamera=!0;let F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),j=W=>W!==0&&-this._bearingSnap<W&&W<this._bearingSnap;!F||!F.essential&&T.prefersReducedMotion?(this._map.fire(new s.k("moveend",{originalEvent:M})),j(this._map.getBearing())&&this._map.resetNorth()):(j(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:M})),this._updatingCamera=!1}}_fireEvent(t,l){this._map.fire(new s.k(t,l?{originalEvent:l}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(t=>{delete this._frameId,this.handleEvent(new Ye("renderFrame",{timeStamp:t})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Pd extends s.E{constructor(t,l){super(),this._renderFrameCallback=()=>{let d=Math.min((T.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(d)),d<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=t,this._bearingSnap=l.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new s.N(this.transform.center.lng,this.transform.center.lat)}setCenter(t,l){return this.jumpTo({center:t},l)}panBy(t,l,d){return t=s.P.convert(t).mult(-1),this.panTo(this.transform.center,s.e({offset:t},l),d)}panTo(t,l,d){return this.easeTo(s.e({center:t},l),d)}getZoom(){return this.transform.zoom}setZoom(t,l){return this.jumpTo({zoom:t},l),this}zoomTo(t,l,d){return this.easeTo(s.e({zoom:t},l),d)}zoomIn(t,l){return this.zoomTo(this.getZoom()+1,t,l),this}zoomOut(t,l){return this.zoomTo(this.getZoom()-1,t,l),this}getBearing(){return this.transform.bearing}setBearing(t,l){return this.jumpTo({bearing:t},l),this}getPadding(){return this.transform.padding}setPadding(t,l){return this.jumpTo({padding:t},l),this}rotateTo(t,l,d){return this.easeTo(s.e({bearing:t},l),d)}resetNorth(t,l){return this.rotateTo(0,s.e({duration:1e3},t),l),this}resetNorthPitch(t,l){return this.easeTo(s.e({bearing:0,pitch:0,duration:1e3},t),l),this}snapToNorth(t,l){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(t,l):this}getPitch(){return this.transform.pitch}setPitch(t,l){return this.jumpTo({pitch:t},l),this}cameraForBounds(t,l){t=ve.convert(t).adjustAntiMeridian();let d=l&&l.bearing||0;return this._cameraForBoxAndBearing(t.getNorthWest(),t.getSouthEast(),d,l)}_cameraForBoxAndBearing(t,l,d,p){let m={top:0,bottom:0,right:0,left:0};if(typeof(p=s.e({padding:m,offset:[0,0],maxZoom:this.transform.maxZoom},p)).padding=="number"){let Oe=p.padding;p.padding={top:Oe,bottom:Oe,right:Oe,left:Oe}}p.padding=s.e(m,p.padding);let S=this.transform,E=S.padding,M=new ve(t,l),R=S.project(M.getNorthWest()),D=S.project(M.getNorthEast()),F=S.project(M.getSouthEast()),j=S.project(M.getSouthWest()),W=s.ba(-d),Z=R.rotate(W),Y=D.rotate(W),te=F.rotate(W),re=j.rotate(W),ne=new s.P(Math.max(Z.x,Y.x,re.x,te.x),Math.max(Z.y,Y.y,re.y,te.y)),H=new s.P(Math.min(Z.x,Y.x,re.x,te.x),Math.min(Z.y,Y.y,re.y,te.y)),ce=ne.sub(H),ue=(S.width-(E.left+E.right+p.padding.left+p.padding.right))/ce.x,ge=(S.height-(E.top+E.bottom+p.padding.top+p.padding.bottom))/ce.y;if(ge<0||ue<0)return void s.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");let Te=Math.min(S.scaleZoom(S.scale*Math.min(ue,ge)),p.maxZoom),Le=s.P.convert(p.offset),Ue=new s.P((p.padding.left-p.padding.right)/2,(p.padding.top-p.padding.bottom)/2).rotate(s.ba(d)),Xe=Le.add(Ue).mult(S.scale/S.zoomScale(Te));return{center:S.unproject(R.add(F).div(2).sub(Xe)),zoom:Te,bearing:d}}fitBounds(t,l,d){return this._fitInternal(this.cameraForBounds(t,l),l,d)}fitScreenCoordinates(t,l,d,p,m){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(s.P.convert(t)),this.transform.pointLocation(s.P.convert(l)),d,p),p,m)}_fitInternal(t,l,d){return t?(delete(l=s.e(t,l)).padding,l.linear?this.easeTo(l,d):this.flyTo(l,d)):this}jumpTo(t,l){this.stop();let d=this._getTransformForUpdate(),p=!1,m=!1,S=!1;return"zoom"in t&&d.zoom!==+t.zoom&&(p=!0,d.zoom=+t.zoom),t.center!==void 0&&(d.center=s.N.convert(t.center)),"bearing"in t&&d.bearing!==+t.bearing&&(m=!0,d.bearing=+t.bearing),"pitch"in t&&d.pitch!==+t.pitch&&(S=!0,d.pitch=+t.pitch),t.padding==null||d.isPaddingEqual(t.padding)||(d.padding=t.padding),this._applyUpdatedTransform(d),this.fire(new s.k("movestart",l)).fire(new s.k("move",l)),p&&this.fire(new s.k("zoomstart",l)).fire(new s.k("zoom",l)).fire(new s.k("zoomend",l)),m&&this.fire(new s.k("rotatestart",l)).fire(new s.k("rotate",l)).fire(new s.k("rotateend",l)),S&&this.fire(new s.k("pitchstart",l)).fire(new s.k("pitch",l)).fire(new s.k("pitchend",l)),this.fire(new s.k("moveend",l))}calculateCameraOptionsFromTo(t,l,d,p=0){let m=s.Z.fromLngLat(t,l),S=s.Z.fromLngLat(d,p),E=S.x-m.x,M=S.y-m.y,R=S.z-m.z,D=Math.hypot(E,M,R);if(D===0)throw new Error("Can't calculate camera options with same From and To");let F=Math.hypot(E,M),j=this.transform.scaleZoom(this.transform.cameraToCenterDistance/D/this.transform.tileSize),W=180*Math.atan2(E,-M)/Math.PI,Z=180*Math.acos(F/D)/Math.PI;return Z=R<0?90-Z:90+Z,{center:S.toLngLat(),zoom:j,pitch:Z,bearing:W}}easeTo(t,l){var d;this._stop(!1,t.easeId),((t=s.e({offset:[0,0],duration:500,easing:s.b9},t)).animate===!1||!t.essential&&T.prefersReducedMotion)&&(t.duration=0);let p=this._getTransformForUpdate(),m=p.zoom,S=p.bearing,E=p.pitch,M=p.padding,R="bearing"in t?this._normalizeBearing(t.bearing,S):S,D="pitch"in t?+t.pitch:E,F="padding"in t?t.padding:p.padding,j=s.P.convert(t.offset),W=p.centerPoint.add(j),Z=p.pointLocation(W),{center:Y,zoom:te}=p.getConstrained(s.N.convert(t.center||Z),(d=t.zoom)!==null&&d!==void 0?d:m);this._normalizeCenter(Y,p);let re=p.project(Z),ne=p.project(Y).sub(re),H=p.zoomScale(te-m),ce,ue;t.around&&(ce=s.N.convert(t.around),ue=p.locationPoint(ce));let ge={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||te!==m,this._rotating=this._rotating||S!==R,this._pitching=this._pitching||D!==E,this._padding=!p.isPaddingEqual(F),this._easeId=t.easeId,this._prepareEase(l,t.noMoveStart,ge),this.terrain&&this._prepareElevation(Y),this._ease(Te=>{if(this._zooming&&(p.zoom=s.y.number(m,te,Te)),this._rotating&&(p.bearing=s.y.number(S,R,Te)),this._pitching&&(p.pitch=s.y.number(E,D,Te)),this._padding&&(p.interpolatePadding(M,F,Te),W=p.centerPoint.add(j)),this.terrain&&!t.freezeElevation&&this._updateElevation(Te),ce)p.setLocationAtPoint(ce,ue);else{let Le=p.zoomScale(p.zoom-m),Ue=te>m?Math.min(2,H):Math.max(.5,H),Xe=Math.pow(Ue,1-Te),Oe=p.unproject(re.add(ne.mult(Te*Xe)).mult(Le));p.setLocationAtPoint(p.renderWorldCopies?Oe.wrap():Oe,W)}this._applyUpdatedTransform(p),this._fireMoveEvents(l)},Te=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(l,Te)},t),this}_prepareEase(t,l,d={}){this._moving=!0,l||d.moving||this.fire(new s.k("movestart",t)),this._zooming&&!d.zooming&&this.fire(new s.k("zoomstart",t)),this._rotating&&!d.rotating&&this.fire(new s.k("rotatestart",t)),this._pitching&&!d.pitching&&this.fire(new s.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);let l=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(t<1&&l!==this._elevationTarget){let d=this._elevationTarget-this._elevationStart;this._elevationStart+=t*(d-(l-(d*t+this._elevationStart))/(1-t)),this._elevationTarget=l}this.transform.elevation=s.y.number(this._elevationStart,this._elevationTarget,t)}_finalizeElevation(){this._elevationFreeze=!1,this.transform.recalculateZoom(this.terrain)}_getTransformForUpdate(){return this.transformCameraUpdate||this.terrain?(this._requestedCameraState||(this._requestedCameraState=this.transform.clone()),this._requestedCameraState):this.transform}_elevateCameraIfInsideTerrain(t){let l=t.getCameraPosition(),d=this.terrain.getElevationForLngLatZoom(l.lngLat,t.zoom);if(l.altitude<d){let p=this.calculateCameraOptionsFromTo(l.lngLat,d,t.center,t.elevation);return{pitch:p.pitch,zoom:p.zoom}}return{}}_applyUpdatedTransform(t){let l=[];if(this.terrain&&l.push(p=>this._elevateCameraIfInsideTerrain(p)),this.transformCameraUpdate&&l.push(p=>this.transformCameraUpdate(p)),!l.length)return;let d=t.clone();for(let p of l){let m=d.clone(),{center:S,zoom:E,pitch:M,bearing:R,elevation:D}=p(m);S&&(m.center=S),E!==void 0&&(m.zoom=E),M!==void 0&&(m.pitch=M),R!==void 0&&(m.bearing=R),D!==void 0&&(m.elevation=D),d.apply(m)}this.transform.apply(d)}_fireMoveEvents(t){this.fire(new s.k("move",t)),this._zooming&&this.fire(new s.k("zoom",t)),this._rotating&&this.fire(new s.k("rotate",t)),this._pitching&&this.fire(new s.k("pitch",t))}_afterEase(t,l){if(this._easeId&&l&&this._easeId===l)return;delete this._easeId;let d=this._zooming,p=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,d&&this.fire(new s.k("zoomend",t)),p&&this.fire(new s.k("rotateend",t)),m&&this.fire(new s.k("pitchend",t)),this.fire(new s.k("moveend",t))}flyTo(t,l){var d;if(!t.essential&&T.prefersReducedMotion){let We=s.M(t,["center","zoom","bearing","pitch","around"]);return this.jumpTo(We,l)}this.stop(),t=s.e({offset:[0,0],speed:1.2,curve:1.42,easing:s.b9},t);let p=this._getTransformForUpdate(),m=p.zoom,S=p.bearing,E=p.pitch,M=p.padding,R="bearing"in t?this._normalizeBearing(t.bearing,S):S,D="pitch"in t?+t.pitch:E,F="padding"in t?t.padding:p.padding,j=s.P.convert(t.offset),W=p.centerPoint.add(j),Z=p.pointLocation(W),{center:Y,zoom:te}=p.getConstrained(s.N.convert(t.center||Z),(d=t.zoom)!==null&&d!==void 0?d:m);this._normalizeCenter(Y,p);let re=p.zoomScale(te-m),ne=p.project(Z),H=p.project(Y).sub(ne),ce=t.curve,ue=Math.max(p.width,p.height),ge=ue/re,Te=H.mag();if("minZoom"in t){let We=s.ac(Math.min(t.minZoom,m,te),p.minZoom,p.maxZoom),ft=ue/p.zoomScale(We-m);ce=Math.sqrt(ft/Te*2)}let Le=ce*ce;function Ue(We){let ft=(ge*ge-ue*ue+(We?-1:1)*Le*Le*Te*Te)/(2*(We?ge:ue)*Le*Te);return Math.log(Math.sqrt(ft*ft+1)-ft)}function Xe(We){return(Math.exp(We)-Math.exp(-We))/2}function Oe(We){return(Math.exp(We)+Math.exp(-We))/2}let ze=Ue(!1),et=function(We){return Oe(ze)/Oe(ze+ce*We)},_t=function(We){return ue*((Oe(ze)*(Xe(ft=ze+ce*We)/Oe(ft))-Xe(ze))/Le)/Te;var ft},Ve=(Ue(!0)-ze)/ce;if(Math.abs(Te)<1e-6||!isFinite(Ve)){if(Math.abs(ue-ge)<1e-6)return this.easeTo(t,l);let We=ge<ue?-1:1;Ve=Math.abs(Math.log(ge/ue))/ce,_t=()=>0,et=ft=>Math.exp(We*ce*ft)}return t.duration="duration"in t?+t.duration:1e3*Ve/("screenSpeed"in t?+t.screenSpeed/ce:+t.speed),t.maxDuration&&t.duration>t.maxDuration&&(t.duration=0),this._zooming=!0,this._rotating=S!==R,this._pitching=D!==E,this._padding=!p.isPaddingEqual(F),this._prepareEase(l,!1),this.terrain&&this._prepareElevation(Y),this._ease(We=>{let ft=We*Ve,si=1/et(ft);p.zoom=We===1?te:m+p.scaleZoom(si),this._rotating&&(p.bearing=s.y.number(S,R,We)),this._pitching&&(p.pitch=s.y.number(E,D,We)),this._padding&&(p.interpolatePadding(M,F,We),W=p.centerPoint.add(j)),this.terrain&&!t.freezeElevation&&this._updateElevation(We);let Tt=We===1?Y:p.unproject(ne.add(H.mult(_t(ft))).mult(si));p.setLocationAtPoint(p.renderWorldCopies?Tt.wrap():Tt,W),this._applyUpdatedTransform(p),this._fireMoveEvents(l)},()=>{this.terrain&&t.freezeElevation&&this._finalizeElevation(),this._afterEase(l)},t),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(t,l){var d;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){let p=this._onEaseEnd;delete this._onEaseEnd,p.call(this,l)}return t||(d=this.handlers)===null||d===void 0||d.stop(!1),this}_ease(t,l,d){d.animate===!1||d.duration===0?(t(1),l()):(this._easeStart=T.now(),this._easeOptions=d,this._onEaseFrame=t,this._onEaseEnd=l,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(t,l){t=s.b3(t,-180,180);let d=Math.abs(t-l);return Math.abs(t-360-l)<d&&(t-=360),Math.abs(t+360-l)<d&&(t+=360),t}_normalizeCenter(t,l){if(!l.renderWorldCopies||l.lngRange)return;let d=t.lng-l.center.lng;t.lng+=d>180?-360:d<-180?360:0}queryTerrainElevation(t){return this.terrain?this.terrain.getElevationForLngLatZoom(s.N.convert(t),this.transform.tileZoom)-this.transform.elevation:null}}let Zo={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Xo{constructor(t=Zo){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=l=>{!l||l.sourceDataType!=="metadata"&&l.sourceDataType!=="visibility"&&l.dataType!=="style"&&l.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=C.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=C.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=C.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(){C.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,l){let d=this._map._getUIString(`AttributionControl.${l}`);t.title=d,t.setAttribute("aria-label",d)}_updateAttributions(){if(!this._map.style)return;let t=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?t=t.concat(this.options.customAttribution.map(p=>typeof p!="string"?"":p)):typeof this.options.customAttribution=="string"&&t.push(this.options.customAttribution)),this._map.style.stylesheet){let p=this._map.style.stylesheet;this.styleOwner=p.owner,this.styleId=p.id}let l=this._map.style.sourceCaches;for(let p in l){let m=l[p];if(m.used||m.usedForTerrain){let S=m.getSource();S.attribution&&t.indexOf(S.attribution)<0&&t.push(S.attribution)}}t=t.filter(p=>String(p).trim()),t.sort((p,m)=>p.length-m.length),t=t.filter((p,m)=>{for(let S=m+1;S<t.length;S++)if(t[S].indexOf(p)>=0)return!1;return!0});let d=t.join(" | ");d!==this._attribHTML&&(this._attribHTML=d,t.length?(this._innerContainer.innerHTML=d,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Th{constructor(t={}){this._updateCompact=()=>{let l=this._container.children;if(l.length){let d=l[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&d.classList.add("maplibregl-compact"):d.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=C.create("div","maplibregl-ctrl");let l=C.create("a","maplibregl-ctrl-logo");return l.target="_blank",l.rel="noopener nofollow",l.href="https://maplibre.org/",l.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),l.setAttribute("rel","noopener nofollow"),this._container.appendChild(l),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){C.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Ot{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(t){let l=++this._id;return this._queue.push({callback:t,id:l,cancelled:!1}),l}remove(t){let l=this._currentlyRunning,d=l?this._queue.concat(l):this._queue;for(let p of d)if(p.id===t)return void(p.cancelled=!0)}run(t=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");let l=this._currentlyRunning=this._queue;this._queue=[];for(let d of l)if(!d.cancelled&&(d.callback(t),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Mh=s.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Bf extends s.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,l){this.sourceCache.update(t,l),this._renderableTilesKeys=[];let d={};for(let p of t.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:l}))d[p.key]=!0,this._renderableTilesKeys.push(p.key),this._tiles[p.key]||(p.posMatrix=new Float64Array(16),s.aP(p.posMatrix,0,s.X,0,s.X,0,1),this._tiles[p.key]=new Jn(p,this.tileSize));for(let p in this._tiles)d[p]||delete this._tiles[p]}freeRtt(t){for(let l in this._tiles){let d=this._tiles[l];(!t||d.tileID.equals(t)||d.tileID.isChildOf(t)||t.isChildOf(d.tileID))&&(d.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(t=>this.getTileByID(t))}getTileByID(t){return this._tiles[t]}getTerrainCoords(t){let l={};for(let d of this._renderableTilesKeys){let p=this._tiles[d].tileID;if(p.canonical.equals(t.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16),s.aP(m.posMatrix,0,s.X,0,s.X,0,1),l[d]=m}else if(p.canonical.isChildOf(t.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16);let S=p.canonical.z-t.canonical.z,E=p.canonical.x-(p.canonical.x>>S<<S),M=p.canonical.y-(p.canonical.y>>S<<S),R=s.X>>S;s.aP(m.posMatrix,0,R,0,R,0,1),s.J(m.posMatrix,m.posMatrix,[-E*R,-M*R,0]),l[d]=m}else if(t.canonical.isChildOf(p.canonical)){let m=t.clone();m.posMatrix=new Float64Array(16);let S=t.canonical.z-p.canonical.z,E=t.canonical.x-(t.canonical.x>>S<<S),M=t.canonical.y-(t.canonical.y>>S<<S),R=s.X>>S;s.aP(m.posMatrix,0,s.X,0,s.X,0,1),s.J(m.posMatrix,m.posMatrix,[E*R,M*R,0]),s.K(m.posMatrix,m.posMatrix,[1/2**S,1/2**S,0]),l[d]=m}}return l}getSourceTile(t,l){let d=this.sourceCache._source,p=t.overscaledZ-this.deltaZoom;if(p>d.maxzoom&&(p=d.maxzoom),p<d.minzoom)return null;this._sourceTileCache[t.key]||(this._sourceTileCache[t.key]=t.scaledTo(p).key);let m=this.sourceCache.getTileByID(this._sourceTileCache[t.key]);if((!m||!m.dem)&&l)for(;p>=d.minzoom&&(!m||!m.dem);)m=this.sourceCache.getTileByID(t.scaledTo(p--).key);return m}tilesAfterTime(t=Date.now()){return Object.values(this._tiles).filter(l=>l.timeAdded>=t)}}class Ph{constructor(t,l,d){this.painter=t,this.sourceCache=new Bf(l),this.options=d,this.exaggeration=typeof d.exaggeration=="number"?d.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(t,l,d,p=s.X){var m;if(!(l>=0&&l<p&&d>=0&&d<p))return 0;let S=this.getTerrainData(t),E=(m=S.tile)===null||m===void 0?void 0:m.dem;if(!E)return 0;let M=function(Z,Y,te){var re=Y[0],ne=Y[1];return Z[0]=te[0]*re+te[4]*ne+te[12],Z[1]=te[1]*re+te[5]*ne+te[13],Z}([],[l/p*s.X,d/p*s.X],S.u_terrain_matrix),R=[M[0]*E.dim,M[1]*E.dim],D=Math.floor(R[0]),F=Math.floor(R[1]),j=R[0]-D,W=R[1]-F;return E.get(D,F)*(1-j)*(1-W)+E.get(D+1,F)*j*(1-W)+E.get(D,F+1)*(1-j)*W+E.get(D+1,F+1)*j*W}getElevationForLngLatZoom(t,l){if(!s.bb(l,t.wrap()))return 0;let{tileID:d,mercatorX:p,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(t,l);return this.getElevation(d,p%s.X,m%s.X,s.X)}getElevation(t,l,d,p=s.X){return this.getDEMElevation(t,l,d,p)*this.exaggeration}getTerrainData(t){if(!this._emptyDemTexture){let p=this.painter.context,m=new s.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new Ae(p,m,p.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new Ae(p,new s.R({width:1,height:1}),p.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(p.gl.NEAREST,p.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=s.an([])}let l=this.sourceCache.getSourceTile(t,!0);if(l&&l.dem&&(!l.demTexture||l.needsTerrainPrepare)){let p=this.painter.context;l.demTexture=this.painter.getTileTexture(l.dem.stride),l.demTexture?l.demTexture.update(l.dem.getPixels(),{premultiply:!1}):l.demTexture=new Ae(p,l.dem.getPixels(),p.gl.RGBA,{premultiply:!1}),l.demTexture.bind(p.gl.NEAREST,p.gl.CLAMP_TO_EDGE),l.needsTerrainPrepare=!1}let d=l&&l+l.tileID.key+t.key;if(d&&!this._demMatrixCache[d]){let p=this.sourceCache.sourceCache._source.maxzoom,m=t.canonical.z-l.tileID.canonical.z;t.overscaledZ>t.canonical.z&&(t.canonical.z>=p?m=t.canonical.z-p:s.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));let S=t.canonical.x-(t.canonical.x>>m<<m),E=t.canonical.y-(t.canonical.y>>m<<m),M=s.bc(new Float64Array(16),[1/(s.X<<m),1/(s.X<<m),0]);s.J(M,M,[S*s.X,E*s.X,0]),this._demMatrixCache[t.key]={matrix:M,coord:t}}return{u_depth:2,u_terrain:3,u_terrain_dim:l&&l.dem&&l.dem.dim||1,u_terrain_matrix:d?this._demMatrixCache[t.key].matrix:this._emptyDemMatrix,u_terrain_unpack:l&&l.dem&&l.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(l&&l.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:l}}getFramebuffer(t){let l=this.painter,d=l.width/devicePixelRatio,p=l.height/devicePixelRatio;return!this._fbo||this._fbo.width===d&&this._fbo.height===p||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new Ae(l.context,{width:d,height:p,data:null},l.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(l.context.gl.NEAREST,l.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new Ae(l.context,{width:d,height:p,data:null},l.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(l.context.gl.NEAREST,l.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=l.context.createFramebuffer(d,p,!0,!1),this._fbo.depthAttachment.set(l.context.createRenderbuffer(l.context.gl.DEPTH_COMPONENT16,d,p))),this._fbo.colorAttachment.set(t==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){let t=this.painter.context;if(this._coordsTexture)return this._coordsTexture;let l=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let m=0,S=0;m<this._coordsTextureSize;m++)for(let E=0;E<this._coordsTextureSize;E++,S+=4)l[S+0]=255&E,l[S+1]=255&m,l[S+2]=E>>8<<4|m>>8,l[S+3]=0;let d=new s.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(l.buffer)),p=new Ae(t,d,t.gl.RGBA,{premultiply:!1});return p.bind(t.gl.NEAREST,t.gl.CLAMP_TO_EDGE),this._coordsTexture=p,p}pointCoordinate(t){this.painter.maybeDrawDepthAndCoords(!0);let l=new Uint8Array(4),d=this.painter.context,p=d.gl,m=Math.round(t.x*this.painter.pixelRatio/devicePixelRatio),S=Math.round(t.y*this.painter.pixelRatio/devicePixelRatio),E=Math.round(this.painter.height/devicePixelRatio);d.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),p.readPixels(m,E-S-1,1,1,p.RGBA,p.UNSIGNED_BYTE,l),d.bindFramebuffer.set(null);let M=l[0]+(l[2]>>4<<8),R=l[1]+((15&l[2])<<8),D=this.coordsIndex[255-l[3]],F=D&&this.sourceCache.getTileByID(D);if(!F)return null;let j=this._coordsTextureSize,W=(1<<F.tileID.canonical.z)*j;return new s.Z((F.tileID.canonical.x*j+M)/W+F.tileID.wrap,(F.tileID.canonical.y*j+R)/W,this.getElevation(F.tileID,M,R,j))}depthAtPoint(t){let l=new Uint8Array(4),d=this.painter.context,p=d.gl;return d.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),p.readPixels(t.x,this.painter.height/devicePixelRatio-t.y-1,1,1,p.RGBA,p.UNSIGNED_BYTE,l),d.bindFramebuffer.set(null),(l[0]/16777216+l[1]/65536+l[2]/256+l[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;let t=this.painter.context,l=new s.bd,d=new s.aY,p=this.meshSize,m=s.X/p,S=p*p;for(let F=0;F<=p;F++)for(let j=0;j<=p;j++)l.emplaceBack(j*m,F*m,0);for(let F=0;F<S;F+=p+1)for(let j=0;j<p;j++)d.emplaceBack(j+F,p+j+F+1,p+j+F+2),d.emplaceBack(j+F,p+j+F+2,j+F+1);let E=l.length,M=E+2*(p+1);for(let F of[0,1])for(let j=0;j<=p;j++)for(let W of[0,1])l.emplaceBack(j*m,F*s.X,W);for(let F=0;F<2*p;F+=2)d.emplaceBack(M+F,M+F+1,M+F+3),d.emplaceBack(M+F,M+F+3,M+F+2),d.emplaceBack(E+F,E+F+3,E+F+1),d.emplaceBack(E+F,E+F+2,E+F+3);let R=l.length,D=R+2*(p+1);for(let F of[0,1])for(let j=0;j<=p;j++)for(let W of[0,1])l.emplaceBack(F*s.X,j*m,W);for(let F=0;F<2*p;F+=2)d.emplaceBack(R+F,R+F+1,R+F+3),d.emplaceBack(R+F,R+F+3,R+F+2),d.emplaceBack(D+F,D+F+3,D+F+1),d.emplaceBack(D+F,D+F+2,D+F+3);return this._mesh=new Ol(t.createVertexBuffer(l,Mh.members),t.createIndexBuffer(d),s.a0.simpleSegment(0,0,l.length,d.length)),this._mesh}getMeshFrameDelta(t){return 2*Math.PI*s.be/Math.pow(2,t)/5}getMinTileElevationForLngLatZoom(t,l){var d;let{tileID:p}=this._getOverscaledTileIDFromLngLatZoom(t,l);return(d=this.getMinMaxElevation(p).minElevation)!==null&&d!==void 0?d:0}getMinMaxElevation(t){let l=this.getTerrainData(t).tile,d={minElevation:null,maxElevation:null};return l&&l.dem&&(d.minElevation=l.dem.min*this.exaggeration,d.maxElevation=l.dem.max*this.exaggeration),d}_getOverscaledTileIDFromLngLatZoom(t,l){let d=s.Z.fromLngLat(t.wrap()),p=(1<<l)*s.X,m=d.x*p,S=d.y*p,E=Math.floor(m/s.X),M=Math.floor(S/s.X);return{tileID:new s.S(l,0,l,E,M),mercatorX:m,mercatorY:S}}}class Nf{constructor(t,l,d){this._context=t,this._size=l,this._tileSize=d,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(let t of this._objects)t.texture.destroy(),t.fbo.destroy()}_createObject(t){let l=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),d=new Ae(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return d.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),l.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),l.colorAttachment.set(d.texture),{id:t,fbo:l,texture:d,stamp:-1,inUse:!1}}getObjectForId(t){return this._objects[t]}useObject(t){t.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(l=>t.id!==l),this._recentlyUsed.push(t.id)}stampObject(t){t.stamp=++this._stamp}getOrCreateFreeObject(){for(let l of this._recentlyUsed)if(!this._objects[l].inUse)return this._objects[l];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");let t=this._createObject(this._objects.length);return this._objects.push(t),t}freeObject(t){t.inUse=!1}freeAllObjects(){for(let t of this._objects)this.freeObject(t)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(t=>!t.inUse)===!1}}let Ho={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Ad{constructor(t,l){this.painter=t,this.terrain=l,this.pool=new Nf(t.context,30,l.sourceCache.tileSize*l.qualityFactor)}destruct(){this.pool.destruct()}getTexture(t){return this.pool.getObjectForId(t.rtt[this._stacks.length-1].id).texture}prepareForRender(t,l){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=t._order.filter(d=>!t._layers[d].isHidden(l)),this._coordsDescendingInv={};for(let d in t.sourceCaches){this._coordsDescendingInv[d]={};let p=t.sourceCaches[d].getVisibleCoordinates();for(let m of p){let S=this.terrain.sourceCache.getTerrainCoords(m);for(let E in S)this._coordsDescendingInv[d][E]||(this._coordsDescendingInv[d][E]=[]),this._coordsDescendingInv[d][E].push(S[E])}}this._coordsDescendingInvStr={};for(let d of t._order){let p=t._layers[d],m=p.source;if(Ho[p.type]&&!this._coordsDescendingInvStr[m]){this._coordsDescendingInvStr[m]={};for(let S in this._coordsDescendingInv[m])this._coordsDescendingInvStr[m][S]=this._coordsDescendingInv[m][S].map(E=>E.key).sort().join()}}for(let d of this._renderableTiles)for(let p in this._coordsDescendingInvStr){let m=this._coordsDescendingInvStr[p][d.tileID.key];m&&m!==d.rttCoords[p]&&(d.rtt=[])}}renderLayer(t){if(t.isHidden(this.painter.transform.zoom))return!1;let l=t.type,d=this.painter,p=this._renderableLayerIds[this._renderableLayerIds.length-1]===t.id;if(Ho[l]&&(this._prevType&&Ho[this._prevType]||this._stacks.push([]),this._prevType=l,this._stacks[this._stacks.length-1].push(t.id),!p))return!0;if(Ho[this._prevType]||Ho[l]&&p){this._prevType=l;let m=this._stacks.length-1,S=this._stacks[m]||[];for(let E of this._renderableTiles){if(this.pool.isFull()&&(wd(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(E),E.rtt[m]){let R=this.pool.getObjectForId(E.rtt[m].id);if(R.stamp===E.rtt[m].stamp){this.pool.useObject(R);continue}}let M=this.pool.getOrCreateFreeObject();this.pool.useObject(M),this.pool.stampObject(M),E.rtt[m]={id:M.id,stamp:M.stamp},d.context.bindFramebuffer.set(M.fbo.framebuffer),d.context.clear({color:s.aM.transparent,stencil:0}),d.currentStencilSource=void 0;for(let R=0;R<S.length;R++){let D=d.style._layers[S[R]],F=D.source?this._coordsDescendingInv[D.source][E.tileID.key]:[E.tileID];d.context.viewport.set([0,0,M.fbo.width,M.fbo.height]),d._renderTileClippingMasks(D,F),d.renderLayer(d,d.style.sourceCaches[D.source],D,F),D.source&&(E.rttCoords[D.source]=this._coordsDescendingInvStr[D.source][E.tileID.key])}}return wd(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Ho[l]}return!1}}let Ah={"AttributionControl.ToggleAttribution":"Toggle attribution","AttributionControl.MapFeedback":"Map feedback","FullscreenControl.Enter":"Enter fullscreen","FullscreenControl.Exit":"Exit fullscreen","GeolocateControl.FindMyLocation":"Find my location","GeolocateControl.LocationNotAvailable":"Location not available","LogoControl.Title":"MapLibre logo","Map.Title":"Map","Marker.Title":"Map marker","NavigationControl.ResetBearing":"Reset bearing to north","NavigationControl.ZoomIn":"Zoom in","NavigationControl.ZoomOut":"Zoom out","Popup.Close":"Close popup","ScaleControl.Feet":"ft","ScaleControl.Meters":"m","ScaleControl.Kilometers":"km","ScaleControl.Miles":"mi","ScaleControl.NauticalMiles":"nm","TerrainControl.Enable":"Enable terrain","TerrainControl.Disable":"Disable terrain","CooperativeGesturesHandler.WindowsHelpText":"Use Ctrl + scroll to zoom the map","CooperativeGesturesHandler.MacHelpText":"Use \u2318 + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Rd=y,Vf={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Zo,maplibreLogo:!1,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:!1,refreshExpiredTiles:!0,scrollZoom:!0,minZoom:-2,maxZoom:22,minPitch:0,maxPitch:60,boxZoom:!0,dragRotate:!0,dragPan:!0,keyboard:!0,doubleClickZoom:!0,touchZoomRotate:!0,touchPitch:!0,cooperativeGestures:!1,trackResize:!0,center:[0,0],zoom:0,bearing:0,pitch:0,renderWorldCopies:!0,maxTileCacheSize:null,maxTileCacheZoomLevels:s.a.MAX_TILE_CACHE_ZOOM_LEVELS,transformRequest:null,transformCameraUpdate:null,fadeDuration:300,crossSourceCollisions:!0,clickTolerance:3,localIdeographFontFamily:"sans-serif",pitchWithRotate:!0,validateStyle:!0,maxCanvasSize:[4096,4096],cancelPendingTileRequestsWhileZooming:!0},Rh=g=>{g.touchstart=g.dragStart,g.touchmoveWindow=g.dragMove,g.touchend=g.dragEnd},jf={showCompass:!0,showZoom:!0,visualizePitch:!1};class Gf{constructor(t,l,d=!1){this.mousedown=S=>{this.startMouse(s.e({},S,{ctrlKey:!0,preventDefault:()=>S.preventDefault()}),C.mousePos(this.element,S)),C.addEventListener(window,"mousemove",this.mousemove),C.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=S=>{this.moveMouse(S,C.mousePos(this.element,S))},this.mouseup=S=>{this.mouseRotate.dragEnd(S),this.mousePitch&&this.mousePitch.dragEnd(S),this.offTemp()},this.touchstart=S=>{S.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=C.touchPos(this.element,S.targetTouches)[0],this.startTouch(S,this._startPos),C.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.addEventListener(window,"touchend",this.touchend))},this.touchmove=S=>{S.targetTouches.length!==1?this.reset():(this._lastPos=C.touchPos(this.element,S.targetTouches)[0],this.moveTouch(S,this._lastPos))},this.touchend=S=>{S.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos)<this._clickTolerance&&this.element.click(),delete this._startPos,delete this._lastPos,this.offTemp()},this.reset=()=>{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;let p=t.dragRotate._mouseRotate.getClickTolerance(),m=t.dragRotate._mousePitch.getClickTolerance();this.element=l,this.mouseRotate=_h({clickTolerance:p,enable:!0}),this.touchRotate=(({enable:S,clickTolerance:E,bearingDegreesPerPixelMoved:M=.8})=>{let R=new yh;return new ps({clickTolerance:E,move:(D,F)=>({bearingDelta:(F.x-D.x)*M}),moveStateManager:R,enable:S,assignEvents:Rh})})({clickTolerance:p,enable:!0}),this.map=t,d&&(this.mousePitch=xh({clickTolerance:m,enable:!0}),this.touchPitch=(({enable:S,clickTolerance:E,pitchDegreesPerPixelMoved:M=-.5})=>{let R=new yh;return new ps({clickTolerance:E,move:(D,F)=>({pitchDelta:(F.y-D.y)*M}),moveStateManager:R,enable:S,assignEvents:Rh})})({clickTolerance:m,enable:!0})),C.addEventListener(l,"mousedown",this.mousedown),C.addEventListener(l,"touchstart",this.touchstart,{passive:!1}),C.addEventListener(l,"touchcancel",this.reset)}startMouse(t,l){this.mouseRotate.dragStart(t,l),this.mousePitch&&this.mousePitch.dragStart(t,l),C.disableDrag()}startTouch(t,l){this.touchRotate.dragStart(t,l),this.touchPitch&&this.touchPitch.dragStart(t,l),C.disableDrag()}moveMouse(t,l){let d=this.map,{bearingDelta:p}=this.mouseRotate.dragMove(t,l)||{};if(p&&d.setBearing(d.getBearing()+p),this.mousePitch){let{pitchDelta:m}=this.mousePitch.dragMove(t,l)||{};m&&d.setPitch(d.getPitch()+m)}}moveTouch(t,l){let d=this.map,{bearingDelta:p}=this.touchRotate.dragMove(t,l)||{};if(p&&d.setBearing(d.getBearing()+p),this.touchPitch){let{pitchDelta:m}=this.touchPitch.dragMove(t,l)||{};m&&d.setPitch(d.getPitch()+m)}}off(){let t=this.element;C.removeEventListener(t,"mousedown",this.mousedown),C.removeEventListener(t,"touchstart",this.touchstart,{passive:!1}),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend),C.removeEventListener(t,"touchcancel",this.reset),this.offTemp()}offTemp(){C.enableDrag(),C.removeEventListener(window,"mousemove",this.mousemove),C.removeEventListener(window,"mouseup",this.mouseup),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend)}}let Yr;function ni(g,t,l){let d=new s.N(g.lng,g.lat);if(g=new s.N(g.lng,g.lat),t){let p=new s.N(g.lng-360,g.lat),m=new s.N(g.lng+360,g.lat),S=l.locationPoint(g).distSqr(t);l.locationPoint(p).distSqr(t)<S?g=p:l.locationPoint(m).distSqr(t)<S&&(g=m)}for(;Math.abs(g.lng-l.center.lng)>180;){let p=l.locationPoint(g);if(p.x>=0&&p.y>=0&&p.x<=l.width&&p.y<=l.height)break;g.lng>l.center.lng?g.lng-=360:g.lng+=360}return g.lng!==d.lng&&l.locationPoint(g).y>l.height/2-l.getHorizon()?g:d}let Ko={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 Xl(g,t,l){let d=g.classList;for(let p in Ko)d.remove(`maplibregl-${l}-anchor-${p}`);d.add(`maplibregl-${l}-anchor-${t}`)}class Hl extends s.E{constructor(t){if(super(),this._onKeyPress=l=>{let d=l.code,p=l.charCode||l.keyCode;d!=="Space"&&d!=="Enter"&&p!==32&&p!==13||this.togglePopup()},this._onMapClick=l=>{let d=l.originalEvent.target,p=this._element;this._popup&&(d===p||p.contains(d))&&this.togglePopup()},this._update=l=>{var d;if(!this._map)return;let p=this._map.loaded()&&!this._map.isMoving();(l?.type==="terrain"||l?.type==="render"&&!p)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?ni(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.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 m="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?m=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(m=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let S="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?S="rotateX(0deg)":this._pitchAlignment==="map"&&(S=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||l&&l.type!=="moveend"||(this._pos=this._pos.round()),C.setTransform(this._element,`${Ko[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${S} ${m}`),T.frameAsync(new AbortController).then(()=>{this._updateOpacity(l&&l.type==="moveend")}).catch(()=>{})},this._onMove=l=>{if(!this._isDragging){let d=this._clickTolerance||this._map._clickTolerance;this._isDragging=l.point.dist(this._pointerdownPos)>=d}this._isDragging&&(this._pos=l.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 s.k("dragstart"))),this.fire(new s.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 s.k("dragend")),this._state="inactive"},this._addDragHandler=l=>{this._element.contains(l.originalEvent.target)&&(l.preventDefault(),this._positionDelta=l.point.sub(this._pos).add(this._offset),this._pointerdownPos=l.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._subpixelPositioning=t&&t.subpixelPositioning||!1,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?.opacity,t?.opacityWhenCovered),t&&t.element)this._element=t.element,this._offset=s.P.convert(t&&t.offset||[0,0]);else{this._defaultMarker=!0,this._element=C.create("div");let l=C.createNS("http://www.w3.org/2000/svg","svg"),d=41,p=27;l.setAttributeNS(null,"display","block"),l.setAttributeNS(null,"height",`${d}px`),l.setAttributeNS(null,"width",`${p}px`),l.setAttributeNS(null,"viewBox",`0 0 ${p} ${d}`);let m=C.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");let S=C.createNS("http://www.w3.org/2000/svg","g");S.setAttributeNS(null,"fill-rule","nonzero");let E=C.createNS("http://www.w3.org/2000/svg","g");E.setAttributeNS(null,"transform","translate(3.0, 29.0)"),E.setAttributeNS(null,"fill","#000000");let M=[{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(let re of M){let ne=C.createNS("http://www.w3.org/2000/svg","ellipse");ne.setAttributeNS(null,"opacity","0.04"),ne.setAttributeNS(null,"cx","10.5"),ne.setAttributeNS(null,"cy","5.80029008"),ne.setAttributeNS(null,"rx",re.rx),ne.setAttributeNS(null,"ry",re.ry),E.appendChild(ne)}let R=C.createNS("http://www.w3.org/2000/svg","g");R.setAttributeNS(null,"fill",this._color);let D=C.createNS("http://www.w3.org/2000/svg","path");D.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"),R.appendChild(D);let F=C.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");let j=C.createNS("http://www.w3.org/2000/svg","path");j.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"),F.appendChild(j);let W=C.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(6.0, 7.0)"),W.setAttributeNS(null,"fill","#FFFFFF");let Z=C.createNS("http://www.w3.org/2000/svg","g");Z.setAttributeNS(null,"transform","translate(8.0, 8.0)");let Y=C.createNS("http://www.w3.org/2000/svg","circle");Y.setAttributeNS(null,"fill","#000000"),Y.setAttributeNS(null,"opacity","0.25"),Y.setAttributeNS(null,"cx","5.5"),Y.setAttributeNS(null,"cy","5.5"),Y.setAttributeNS(null,"r","5.4999962");let te=C.createNS("http://www.w3.org/2000/svg","circle");te.setAttributeNS(null,"fill","#FFFFFF"),te.setAttributeNS(null,"cx","5.5"),te.setAttributeNS(null,"cy","5.5"),te.setAttributeNS(null,"r","5.4999962"),Z.appendChild(Y),Z.appendChild(te),S.appendChild(E),S.appendChild(R),S.appendChild(F),S.appendChild(W),S.appendChild(Z),l.appendChild(S),l.setAttributeNS(null,"height",d*this._scale+"px"),l.setAttributeNS(null,"width",p*this._scale+"px"),this._element.appendChild(l),this._offset=s.P.convert(t&&t.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",l=>{l.preventDefault()}),this._element.addEventListener("mousedown",l=>{l.preventDefault()}),Xl(this._element,this._anchor,"marker"),t&&t.className)for(let l of t.className.split(" "))this._element.classList.add(l);this._popup=null}addTo(t){return this.remove(),this._map=t,this._element.setAttribute("aria-label",t._getUIString("Marker.Title")),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("terrain",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),C.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(t){return this._lngLat=s.N.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)){let p=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":[p,-1*(38.1-13.5+p)],"bottom-right":[-p,-1*(38.1-13.5+p)],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}setSubpixelPositioning(t){return this._subpixelPositioning=t,this}getPopup(){return this._popup}togglePopup(){let 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 l,d;if(!(!((l=this._map)===null||l===void 0)&&l.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)}let p=this._map,m=p.terrain.depthAtPoint(this._pos),S=p.terrain.getElevationForLngLatZoom(this._lngLat,p.transform.tileZoom);if(p.transform.lngLatToCameraDepth(this._lngLat,S)-m<.006)return void(this._element.style.opacity=this._opacity);let E=-this._offset.y/p.transform._pixelPerMeter,M=Math.sin(p.getPitch()*Math.PI/180)*E,R=p.terrain.depthAtPoint(new s.P(this._pos.x,this._pos.y-this._offset.y)),D=p.transform.lngLatToCameraDepth(this._lngLat,S+M)-R>.006;!((d=this._popup)===null||d===void 0)&&d.isOpen()&&D&&this._popup.remove(),this._element.style.opacity=D?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(t){return this._offset=s.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,l){return t===void 0&&l===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),t!==void 0&&(this._opacity=t),l!==void 0&&(this._opacityWhenCovered=l),this._map&&this._updateOpacity(!0),this}}let kd={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0},Ua=0,qa=!1,ts={maxWidth:100,unit:"metric"};function $a(g,t,l){let d=l&&l.maxWidth||100,p=g._container.clientHeight/2,m=g.unproject([0,p]),S=g.unproject([d,p]),E=m.distanceTo(S);if(l&&l.unit==="imperial"){let M=3.2808*E;M>5280?Qe(t,d,M/5280,g._getUIString("ScaleControl.Miles")):Qe(t,d,M,g._getUIString("ScaleControl.Feet"))}else l&&l.unit==="nautical"?Qe(t,d,E/1852,g._getUIString("ScaleControl.NauticalMiles")):E>=1e3?Qe(t,d,E/1e3,g._getUIString("ScaleControl.Kilometers")):Qe(t,d,E,g._getUIString("ScaleControl.Meters"))}function Qe(g,t,l,d){let p=function(m){let S=Math.pow(10,`${Math.floor(m)}`.length-1),E=m/S;return E=E>=10?10:E>=5?5:E>=3?3:E>=2?2:E>=1?1:function(M){let R=Math.pow(10,Math.ceil(-Math.log(M)/Math.LN10));return Math.round(M*R)/R}(E),S*E}(l);g.style.width=t*(p/l)+"px",g.innerHTML=`${p}&nbsp;${d}`}let ut={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Kl=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Yl(g){if(g){if(typeof g=="number"){let t=Math.round(Math.abs(g)/Math.SQRT2);return{center:new s.P(0,0),top:new s.P(0,g),"top-left":new s.P(t,t),"top-right":new s.P(-t,t),bottom:new s.P(0,-g),"bottom-left":new s.P(t,-t),"bottom-right":new s.P(-t,-t),left:new s.P(g,0),right:new s.P(-g,0)}}if(g instanceof s.P||Array.isArray(g)){let t=s.P.convert(g);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:s.P.convert(g.center||[0,0]),top:s.P.convert(g.top||[0,0]),"top-left":s.P.convert(g["top-left"]||[0,0]),"top-right":s.P.convert(g["top-right"]||[0,0]),bottom:s.P.convert(g.bottom||[0,0]),"bottom-left":s.P.convert(g["bottom-left"]||[0,0]),"bottom-right":s.P.convert(g["bottom-right"]||[0,0]),left:s.P.convert(g.left||[0,0]),right:s.P.convert(g.right||[0,0])}}return Yl(new s.P(0,0))}let kh=y;c.AJAXError=s.bh,c.Evented=s.E,c.LngLat=s.N,c.MercatorCoordinate=s.Z,c.Point=s.P,c.addProtocol=s.bi,c.config=s.a,c.removeProtocol=s.bj,c.AttributionControl=Xo,c.BoxZoomHandler=Kr,c.CanvasSource=fr,c.CooperativeGesturesHandler=Wo,c.DoubleClickZoomHandler=co,c.DragPanHandler=Td,c.DragRotateHandler=Md,c.EdgeInsets=Go,c.FullscreenControl=class extends s.E{constructor(g={}){super(),this._onFullscreenChange=()=>{var t;let l=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((t=l?.shadowRoot)===null||t===void 0)&&t.fullscreenElement;)l=l.shadowRoot.fullscreenElement;l===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,g&&g.container&&(g.container instanceof HTMLElement?this._container=g.container:s.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(g){return this._map=g,this._container||(this._container=this._map.getContainer()),this._controlContainer=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){C.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){let g=this._fullscreenButton=C.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);C.create("span","maplibregl-ctrl-icon",g).setAttribute("aria-hidden","true"),g.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){let g=this._getTitle();this._fullscreenButton.setAttribute("aria-label",g),this._fullscreenButton.title=g}_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 s.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new s.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()}},c.GeoJSONSource=Rn,c.GeolocateControl=class extends s.E{constructor(g){super(),this._onSuccess=t=>{if(this._map){if(this._isOutOfMapMaxBounds(t))return this._setErrorState(),this.fire(new s.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 s.k("geolocate",t)),this._finish()}},this._updateCamera=t=>{let l=new s.N(t.coords.longitude,t.coords.latitude),d=t.coords.accuracy,p=this._map.getBearing(),m=s.e({bearing:p},this.options.fitBoundsOptions),S=ve.fromLngLat(l,d);this._map.fitBounds(S,m,{geolocateSource:!0})},this._updateMarker=t=>{if(t){let l=new s.N(t.coords.longitude,t.coords.latitude);this._accuracyCircleMarker.setLngLat(l).addTo(this._map),this._userLocationDotMarker.setLngLat(l).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;let l=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(t.code===3&&qa)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new s.k("error",t)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",t=>t.preventDefault()),this._geolocateButton=C.create("button","maplibregl-ctrl-geolocate",this._container),C.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=t=>{if(this._map){if(t===!1){s.w("Geolocation support is not available so the GeolocateControl will be disabled.");let l=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l)}else{let l=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=l,this._geolocateButton.setAttribute("aria-label",l)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=C.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Hl({element:this._dotElement}),this._circleElement=C.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Hl({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",l=>{l.geolocateSource||this._watchState!=="ACTIVE_LOCK"||l.originalEvent&&l.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 s.k("trackuserlocationend")),this.fire(new s.k("userlocationlostfocus")))})}},this.options=s.e({},kd,g)}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return s._(this,arguments,void 0,function*(t=!1){if(Yr!==void 0&&!t)return Yr;if(window.navigator.permissions===void 0)return Yr=!!window.navigator.geolocation,Yr;try{Yr=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{Yr=!!window.navigator.geolocation}return Yr})}().then(t=>this._finishSetupUI(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(),C.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Ua=0,qa=!1}_isOutOfMapMaxBounds(g){let t=this._map.getMaxBounds(),l=g.coords;return t&&(l.longitude<t.getWest()||l.longitude>t.getEast()||l.latitude<t.getSouth()||l.latitude>t.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(){let g=this._map.getBounds(),t=g.getSouthEast(),l=g.getNorthEast(),d=t.distanceTo(l),p=Math.ceil(this._accuracy/(d/this._map._container.clientHeight)*2);this._circleElement.style.width=`${p}px`,this._circleElement.style.height=`${p}px`}trigger(){if(!this._setup)return s.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 s.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Ua--,qa=!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 s.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 s.k("trackuserlocationstart")),this.fire(new s.k("userlocationfocus"));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 g;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Ua++,Ua>1?(g={maximumAge:6e5,timeout:0},qa=!0):(g=this.options.positionOptions,qa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,g)}}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)}},c.Hash=Nl,c.ImageSource=Ar,c.KeyboardHandler=un,c.LngLatBounds=ve,c.LogoControl=Th,c.Map=class extends Pd{constructor(g){s.bf.mark(s.bg.create);let t=Object.assign(Object.assign({},Vf),g);if(t.minZoom!=null&&t.maxZoom!=null&&t.minZoom>t.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(t.minPitch!=null&&t.maxPitch!=null&&t.minPitch>t.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(t.minPitch!=null&&t.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(t.maxPitch!=null&&t.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new Uo(t.minZoom,t.maxZoom,t.minPitch,t.maxPitch,t.renderWorldCopies),{bearingSnap:t.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new Ot,this._controls=[],this._mapId=s.a4(),this._contextLost=l=>{l.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new s.k("webglcontextlost",{originalEvent:l}))},this._contextRestored=l=>{this._setupPainter(),this.resize(),this._update(),this.fire(new s.k("webglcontextrestored",{originalEvent:l}))},this._onMapScroll=l=>{if(l.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=t.interactive,this._maxTileCacheSize=t.maxTileCacheSize,this._maxTileCacheZoomLevels=t.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=t.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=t.preserveDrawingBuffer===!0,this._antialias=t.antialias===!0,this._trackResize=t.trackResize===!0,this._bearingSnap=t.bearingSnap,this._refreshExpiredTiles=t.refreshExpiredTiles===!0,this._fadeDuration=t.fadeDuration,this._crossSourceCollisions=t.crossSourceCollisions===!0,this._collectResourceTiming=t.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Ah),t.locale),this._clickTolerance=t.clickTolerance,this._overridePixelRatio=t.pixelRatio,this._maxCanvasSize=t.maxCanvasSize,this.transformCameraUpdate=t.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=t.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=fe.addThrottleControl(()=>this.isMoving()),this._requestManager=new ye(t.transformRequest),typeof t.container=="string"){if(this._container=document.getElementById(t.container),!this._container)throw new Error(`Container '${t.container}' not found.`)}else{if(!(t.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=t.container}if(t.maxBounds&&this.setMaxBounds(t.maxBounds),this._setupContainer(),this._setupPainter(),this.on("move",()=>this._update(!1)).on("moveend",()=>this._update(!1)).on("zoom",()=>this._update(!0)).on("terrain",()=>{this.painter.terrainFacilitator.dirty=!0,this._update(!0)}).once("idle",()=>{this._idleTriggered=!0}),typeof window<"u"){addEventListener("online",this._onWindowOnline,!1);let l=!1,d=Ba(p=>{this._trackResize&&!this._removed&&(this.resize(p),this.redraw())},50);this._resizeObserver=new ResizeObserver(p=>{l?d(p):l=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Eh(this,t),this._hash=t.hash&&new Nl(typeof t.hash=="string"&&t.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:t.center,zoom:t.zoom,bearing:t.bearing,pitch:t.pitch}),t.bounds&&(this.resize(),this.fitBounds(t.bounds,s.e({},t.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=t.localIdeographFontFamily,this._validateStyle=t.validateStyle,t.style&&this.setStyle(t.style,{localIdeographFontFamily:t.localIdeographFontFamily}),t.attributionControl&&this.addControl(new Xo(typeof t.attributionControl=="boolean"?void 0:t.attributionControl)),t.maplibreLogo&&this.addControl(new Th,t.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",l=>{this._update(l.dataType==="style"),this.fire(new s.k(`${l.dataType}data`,l))}),this.on("dataloading",l=>{this.fire(new s.k(`${l.dataType}dataloading`,l))}),this.on("dataabort",l=>{this.fire(new s.k("sourcedataabort",l))})}_getMapId(){return this._mapId}addControl(g,t){if(t===void 0&&(t=g.getDefaultPosition?g.getDefaultPosition():"top-right"),!g||!g.onAdd)return this.fire(new s.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));let l=g.onAdd(this);this._controls.push(g);let d=this._controlPositions[t];return t.indexOf("bottom")!==-1?d.insertBefore(l,d.firstChild):d.appendChild(l),this}removeControl(g){if(!g||!g.onRemove)return this.fire(new s.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));let t=this._controls.indexOf(g);return t>-1&&this._controls.splice(t,1),g.onRemove(this),this}hasControl(g){return this._controls.indexOf(g)>-1}calculateCameraOptionsFromTo(g,t,l,d){return d==null&&this.terrain&&(d=this.terrain.getElevationForLngLatZoom(l,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(g,t,l,d)}resize(g){var t;let l=this._containerDimensions(),d=l[0],p=l[1],m=this._getClampedPixelRatio(d,p);if(this._resizeCanvas(d,p,m),this.painter.resize(d,p,m),this.painter.overLimit()){let E=this.painter.context.gl;this._maxCanvasSize=[E.drawingBufferWidth,E.drawingBufferHeight];let M=this._getClampedPixelRatio(d,p);this._resizeCanvas(d,p,M),this.painter.resize(d,p,M)}this.transform.resize(d,p),(t=this._requestedCameraState)===null||t===void 0||t.resize(d,p);let S=!this._moving;return S&&(this.stop(),this.fire(new s.k("movestart",g)).fire(new s.k("move",g))),this.fire(new s.k("resize",g)),S&&this.fire(new s.k("moveend",g)),this}_getClampedPixelRatio(g,t){let{0:l,1:d}=this._maxCanvasSize,p=this.getPixelRatio(),m=g*p,S=t*p;return Math.min(m>l?l/m:1,S>d?d/S:1)*p}getPixelRatio(){var g;return(g=this._overridePixelRatio)!==null&&g!==void 0?g:devicePixelRatio}setPixelRatio(g){this._overridePixelRatio=g,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(g){return this.transform.setMaxBounds(ve.convert(g)),this._update()}setMinZoom(g){if((g=g??-2)>=-2&&g<=this.transform.maxZoom)return this.transform.minZoom=g,this._update(),this.getZoom()<g&&this.setZoom(g),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(g){if((g=g??22)>=this.transform.minZoom)return this.transform.maxZoom=g,this._update(),this.getZoom()>g&&this.setZoom(g),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(g){if((g=g??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(g>=0&&g<=this.transform.maxPitch)return this.transform.minPitch=g,this._update(),this.getPitch()<g&&this.setPitch(g),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(g){if((g=g??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(g>=this.transform.minPitch)return this.transform.maxPitch=g,this._update(),this.getPitch()>g&&this.setPitch(g),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(g){return this.transform.renderWorldCopies=g,this._update()}project(g){return this.transform.locationPoint(s.N.convert(g),this.style&&this.terrain)}unproject(g){return this.transform.pointLocation(s.P.convert(g),this.terrain)}isMoving(){var g;return this._moving||((g=this.handlers)===null||g===void 0?void 0:g.isMoving())}isZooming(){var g;return this._zooming||((g=this.handlers)===null||g===void 0?void 0:g.isZooming())}isRotating(){var g;return this._rotating||((g=this.handlers)===null||g===void 0?void 0:g.isRotating())}_createDelegatedListener(g,t,l){if(g==="mouseenter"||g==="mouseover"){let d=!1;return{layers:t,listener:l,delegates:{mousemove:m=>{let S=t.filter(M=>this.getLayer(M)),E=S.length!==0?this.queryRenderedFeatures(m.point,{layers:S}):[];E.length?d||(d=!0,l.call(this,new Yi(g,this,m.originalEvent,{features:E}))):d=!1},mouseout:()=>{d=!1}}}}if(g==="mouseleave"||g==="mouseout"){let d=!1;return{layers:t,listener:l,delegates:{mousemove:S=>{let E=t.filter(M=>this.getLayer(M));(E.length!==0?this.queryRenderedFeatures(S.point,{layers:E}):[]).length?d=!0:d&&(d=!1,l.call(this,new Yi(g,this,S.originalEvent)))},mouseout:S=>{d&&(d=!1,l.call(this,new Yi(g,this,S.originalEvent)))}}}}{let d=p=>{let m=t.filter(E=>this.getLayer(E)),S=m.length!==0?this.queryRenderedFeatures(p.point,{layers:m}):[];S.length&&(p.features=S,l.call(this,p),delete p.features)};return{layers:t,listener:l,delegates:{[g]:d}}}}_saveDelegatedListener(g,t){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[g]=this._delegatedListeners[g]||[],this._delegatedListeners[g].push(t)}_removeDelegatedListener(g,t,l){if(!this._delegatedListeners||!this._delegatedListeners[g])return;let d=this._delegatedListeners[g];for(let p=0;p<d.length;p++){let m=d[p];if(m.listener===l&&m.layers.length===t.length&&m.layers.every(S=>t.includes(S))){for(let S in m.delegates)this.off(S,m.delegates[S]);return void d.splice(p,1)}}}on(g,t,l){if(l===void 0)return super.on(g,t);let d=this._createDelegatedListener(g,typeof t=="string"?[t]:t,l);this._saveDelegatedListener(g,d);for(let p in d.delegates)this.on(p,d.delegates[p]);return this}once(g,t,l){if(l===void 0)return super.once(g,t);let d=typeof t=="string"?[t]:t,p=this._createDelegatedListener(g,d,l);for(let m in p.delegates){let S=p.delegates[m];p.delegates[m]=(...E)=>{this._removeDelegatedListener(g,d,l),S(...E)}}this._saveDelegatedListener(g,p);for(let m in p.delegates)this.once(m,p.delegates[m]);return this}off(g,t,l){return l===void 0?super.off(g,t):(this._removeDelegatedListener(g,typeof t=="string"?[t]:t,l),this)}queryRenderedFeatures(g,t){if(!this.style)return[];let l,d=g instanceof s.P||Array.isArray(g),p=d?g:[[0,0],[this.transform.width,this.transform.height]];if(t=t||(d?{}:g)||{},p instanceof s.P||typeof p[0]=="number")l=[s.P.convert(p)];else{let m=s.P.convert(p[0]),S=s.P.convert(p[1]);l=[m,new s.P(S.x,m.y),S,new s.P(m.x,S.y),m]}return this.style.queryRenderedFeatures(l,t,this.transform)}querySourceFeatures(g,t){return this.style.querySourceFeatures(g,t)}setStyle(g,t){return(t=s.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},t)).diff!==!1&&t.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&g?(this._diffStyle(g,t),this):(this._localIdeographFontFamily=t.localIdeographFontFamily,this._updateStyle(g,t))}setTransformRequest(g){return this._requestManager.setTransformRequest(g),this}_getUIString(g){let t=this._locale[g];if(t==null)throw new Error(`Missing UI string '${g}'`);return t}_updateStyle(g,t){if(t.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(g,t));let l=this.style&&t.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!g)),g?(this.style=new wl(this,t||{}),this.style.setEventedParent(this,{style:this.style}),typeof g=="string"?this.style.loadURL(g,t,l):this.style.loadJSON(g,t,l),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new wl(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(g,t){if(typeof g=="string"){let l=this._requestManager.transformRequest(g,"Style");s.h(l,new AbortController).then(d=>{this._updateDiff(d.data,t)}).catch(d=>{d&&this.fire(new s.j(d))})}else typeof g=="object"&&this._updateDiff(g,t)}_updateDiff(g,t){try{this.style.setState(g,t)&&this._update(!0)}catch(l){s.w(`Unable to perform style diff: ${l.message||l.error||l}. Rebuilding the style from scratch.`),this._updateStyle(g,t)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():s.w("There is no style added to the map.")}addSource(g,t){return this._lazyInitEmptyStyle(),this.style.addSource(g,t),this._update(!0)}isSourceLoaded(g){let t=this.style&&this.style.sourceCaches[g];if(t!==void 0)return t.loaded();this.fire(new s.j(new Error(`There is no source with ID '${g}'`)))}setTerrain(g){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),g){let t=this.style.sourceCaches[g.source];if(!t)throw new Error(`cannot load terrain, because there exists no source with ID: ${g.source}`);this.terrain===null&&t.reload();for(let l in this.style._layers){let d=this.style._layers[l];d.type==="hillshade"&&d.source===g.source&&s.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 Ph(this.painter,t,g),this.painter.renderToTexture=new Ad(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=l=>{l.dataType==="style"?this.terrain.sourceCache.freeRtt():l.dataType==="source"&&l.tile&&(l.sourceId!==g.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(l.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 s.k("terrain",{terrain:g})),this}getTerrain(){var g,t;return(t=(g=this.terrain)===null||g===void 0?void 0:g.options)!==null&&t!==void 0?t:null}areTilesLoaded(){let g=this.style&&this.style.sourceCaches;for(let t in g){let l=g[t]._tiles;for(let d in l){let p=l[d];if(p.state!=="loaded"&&p.state!=="errored")return!1}}return!0}removeSource(g){return this.style.removeSource(g),this._update(!0)}getSource(g){return this.style.getSource(g)}addImage(g,t,l={}){let{pixelRatio:d=1,sdf:p=!1,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R}=l;if(this._lazyInitEmptyStyle(),!(t instanceof HTMLImageElement||s.b(t))){if(t.width===void 0||t.height===void 0)return this.fire(new s.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`")));{let{width:D,height:F,data:j}=t,W=t;return this.style.addImage(g,{data:new s.R({width:D,height:F},new Uint8Array(j)),pixelRatio:d,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R,sdf:p,version:0,userImage:W}),W.onAdd&&W.onAdd(this,g),this}}{let{width:D,height:F,data:j}=T.getImageData(t);this.style.addImage(g,{data:new s.R({width:D,height:F},j),pixelRatio:d,stretchX:m,stretchY:S,content:E,textFitWidth:M,textFitHeight:R,sdf:p,version:0})}}updateImage(g,t){let l=this.style.getImage(g);if(!l)return this.fire(new s.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));let d=t instanceof HTMLImageElement||s.b(t)?T.getImageData(t):t,{width:p,height:m,data:S}=d;if(p===void 0||m===void 0)return this.fire(new s.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(p!==l.data.width||m!==l.data.height)return this.fire(new s.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));let E=!(t instanceof HTMLImageElement||s.b(t));return l.data.replace(S,E),this.style.updateImage(g,l),this}getImage(g){return this.style.getImage(g)}hasImage(g){return g?!!this.style.getImage(g):(this.fire(new s.j(new Error("Missing required image id"))),!1)}removeImage(g){this.style.removeImage(g)}loadImage(g){return fe.getImage(this._requestManager.transformRequest(g,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(g,t){return this._lazyInitEmptyStyle(),this.style.addLayer(g,t),this._update(!0)}moveLayer(g,t){return this.style.moveLayer(g,t),this._update(!0)}removeLayer(g){return this.style.removeLayer(g),this._update(!0)}getLayer(g){return this.style.getLayer(g)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(g,t,l){return this.style.setLayerZoomRange(g,t,l),this._update(!0)}setFilter(g,t,l={}){return this.style.setFilter(g,t,l),this._update(!0)}getFilter(g){return this.style.getFilter(g)}setPaintProperty(g,t,l,d={}){return this.style.setPaintProperty(g,t,l,d),this._update(!0)}getPaintProperty(g,t){return this.style.getPaintProperty(g,t)}setLayoutProperty(g,t,l,d={}){return this.style.setLayoutProperty(g,t,l,d),this._update(!0)}getLayoutProperty(g,t){return this.style.getLayoutProperty(g,t)}setGlyphs(g,t={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(g,t),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(g,t,l={}){return this._lazyInitEmptyStyle(),this.style.addSprite(g,t,l,d=>{d||this._update(!0)}),this}removeSprite(g){return this._lazyInitEmptyStyle(),this.style.removeSprite(g),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(g,t={}){return this._lazyInitEmptyStyle(),this.style.setSprite(g,t,l=>{l||this._update(!0)}),this}setLight(g,t={}){return this._lazyInitEmptyStyle(),this.style.setLight(g,t),this._update(!0)}getLight(){return this.style.getLight()}setSky(g){return this._lazyInitEmptyStyle(),this.style.setSky(g),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(g,t){return this.style.setFeatureState(g,t),this._update()}removeFeatureState(g,t){return this.style.removeFeatureState(g,t),this._update()}getFeatureState(g){return this.style.getFeatureState(g)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let g=0,t=0;return this._container&&(g=this._container.clientWidth||400,t=this._container.clientHeight||300),[g,t]}_setupContainer(){let g=this._container;g.classList.add("maplibregl-map");let t=this._canvasContainer=C.create("div","maplibregl-canvas-container",g);this._interactive&&t.classList.add("maplibregl-interactive"),this._canvas=C.create("canvas","maplibregl-canvas",t),this._canvas.addEventListener("webglcontextlost",this._contextLost,!1),this._canvas.addEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.setAttribute("tabindex",this._interactive?"0":"-1"),this._canvas.setAttribute("aria-label",this._getUIString("Map.Title")),this._canvas.setAttribute("role","region");let l=this._containerDimensions(),d=this._getClampedPixelRatio(l[0],l[1]);this._resizeCanvas(l[0],l[1],d);let p=this._controlContainer=C.create("div","maplibregl-control-container",g),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(S=>{m[S]=C.create("div",`maplibregl-ctrl-${S} `,p)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(g,t,l){this._canvas.width=Math.floor(l*g),this._canvas.height=Math.floor(l*t),this._canvas.style.width=`${g}px`,this._canvas.style.height=`${t}px`}_setupPainter(){let g={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1},t=null;this._canvas.addEventListener("webglcontextcreationerror",d=>{t={requestedAttributes:g},d&&(t.statusMessage=d.statusMessage,t.type=d.type)},{once:!0});let l=this._canvas.getContext("webgl2",g)||this._canvas.getContext("webgl",g);if(!l){let d="Failed to initialize WebGL";throw t?(t.message=d,new Error(JSON.stringify(t))):new Error(d)}this.painter=new Bl(l,this.transform),k.testSupport(l)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(g){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||g,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(g){return this._update(),this._renderTaskQueue.add(g)}_cancelRenderFrame(g){this._renderTaskQueue.remove(g)}_render(g){let t=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(g),this._removed)return;let l=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;let p=this.transform.zoom,m=T.now();this.style.zoomHistory.update(p,m);let S=new s.z(p,{now:m,fadeDuration:t,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),E=S.crossFadingFactor();E===1&&E===this._crossFadingFactor||(l=!0,this._crossFadingFactor=E),this.style.update(S)}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 s.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,s.bf.mark(s.bg.load),this.fire(new s.k("load"))),this.style&&(this.style.hasTransitions()||l)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();let d=this._sourcesDirty||this._styleDirty||this._placementDirty;return d||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new s.k("idle")),!this._loaded||this._fullyLoaded||d||(this._fullyLoaded=!0,s.bf.mark(s.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var g;this._hash&&this._hash.remove();for(let l of this._controls)l.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),fe.removeThrottleControl(this._imageQueueHandle),(g=this._resizeObserver)===null||g===void 0||g.disconnect();let t=this.painter.context.gl.getExtension("WEBGL_lose_context");t?.loseContext&&t.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),C.remove(this._canvasContainer),C.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),s.bf.clearMetrics(),this._removed=!0,this.fire(new s.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,T.frameAsync(this._frameRequest).then(g=>{s.bf.frame(g),this._frameRequest=null,this._render(g)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(g){this._showTileBoundaries!==g&&(this._showTileBoundaries=g,this._update())}get showPadding(){return!!this._showPadding}set showPadding(g){this._showPadding!==g&&(this._showPadding=g,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(g){this._showCollisionBoxes!==g&&(this._showCollisionBoxes=g,g?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(g){this._showOverdrawInspector!==g&&(this._showOverdrawInspector=g,this._update())}get repaint(){return!!this._repaint}set repaint(g){this._repaint!==g&&(this._repaint=g,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(g){this._vertices=g,this._update()}get version(){return Rd}getCameraTargetElevation(){return this.transform.elevation}},c.MapMouseEvent=Yi,c.MapTouchEvent=ao,c.MapWheelEvent=Id,c.Marker=Hl,c.NavigationControl=class{constructor(g){this._updateZoomButtons=()=>{let t=this._map.getZoom(),l=t===this._map.getMaxZoom(),d=t===this._map.getMinZoom();this._zoomInButton.disabled=l,this._zoomOutButton.disabled=d,this._zoomInButton.setAttribute("aria-disabled",l.toString()),this._zoomOutButton.setAttribute("aria-disabled",d.toString())},this._rotateCompassArrow=()=>{let 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,l)=>{let d=this._map._getUIString(`NavigationControl.${l}`);t.title=d,t.setAttribute("aria-label",d)},this.options=s.e({},jf,g),this._container=C.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})),C.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})),C.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=C.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(g){return this._map=g,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 Gf(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){C.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(g,t){let l=C.create("button",g,this._container);return l.type="button",l.addEventListener("click",t),l}},c.Popup=class extends s.E{constructor(g){super(),this.remove=()=>(this._content&&C.remove(this._content),this._container&&(C.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 s.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 l;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=C.create("div","maplibregl-popup",this._map.getContainer()),this._tip=C.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(let E of this.options.className.split(" "))this._container.classList.add(E);this._closeButton&&this._closeButton.setAttribute("aria-label",this._map._getUIString("Popup.Close")),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?ni(this._lngLat,this._flatPos,this._map.transform):(l=this._lngLat)===null||l===void 0?void 0:l.wrap(),this._trackPointer&&!t)return;let d=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 p=this.options.anchor,m=Yl(this.options.offset);if(!p){let E=this._container.offsetWidth,M=this._container.offsetHeight,R;R=d.y+m.bottom.y<M?["top"]:d.y>this._map.transform.height-M?["bottom"]:[],d.x<E/2?R.push("left"):d.x>this._map.transform.width-E/2&&R.push("right"),p=R.length===0?"bottom":R.join("-")}let S=d.add(m[p]);this.options.subpixelPositioning||(S=S.round()),C.setTransform(this._container,`${Ko[p]} translate(${S.x}px,${S.y}px)`),Xl(this._container,p,"popup")},this._onClose=()=>{this.remove()},this.options=s.e(Object.create(ut),g)}addTo(g){return this._map&&this.remove(),this._map=g,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 s.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(g){return this._lngLat=s.N.convert(g),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(g){return this.setDOMContent(document.createTextNode(g))}setHTML(g){let t=document.createDocumentFragment(),l=document.createElement("body"),d;for(l.innerHTML=g;d=l.firstChild,d;)t.appendChild(d);return this.setDOMContent(t)}getMaxWidth(){var g;return(g=this._container)===null||g===void 0?void 0:g.style.maxWidth}setMaxWidth(g){return this.options.maxWidth=g,this._update(),this}setDOMContent(g){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=C.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(g),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(g){return this._container&&this._container.classList.add(g),this}removeClassName(g){return this._container&&this._container.classList.remove(g),this}setOffset(g){return this.options.offset=g,this._update(),this}toggleClassName(g){if(this._container)return this._container.classList.toggle(g)}setSubpixelPositioning(g){this.options.subpixelPositioning=g}_createCloseButton(){this.options.closeButton&&(this._closeButton=C.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="&#215;",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;let g=this._container.querySelector(Kl);g&&g.focus()}},c.RasterDEMTileSource=Zt,c.RasterTileSource=bt,c.ScaleControl=class{constructor(g){this._onMove=()=>{$a(this._map,this._container,this.options)},this.setUnit=t=>{this.options.unit=t,$a(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},ts),g)}getDefaultPosition(){return"bottom-left"}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-scale",g.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){C.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},c.ScrollZoomHandler=Bn,c.Style=wl,c.TerrainControl=class{constructor(g){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=g}onAdd(g){return this._map=g,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=C.create("button","maplibregl-ctrl-terrain",this._container),C.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(){C.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},c.TwoFingersTouchPitchHandler=$o,c.TwoFingersTouchRotateHandler=Sh,c.TwoFingersTouchZoomHandler=bh,c.TwoFingersTouchZoomRotateHandler=Ch,c.VectorTileSource=pr,c.VideoSource=an,c.addSourceType=(g,t)=>s._(void 0,void 0,void 0,function*(){if(kn(g))throw new Error(`A source type called "${g}" already exists.`);((l,d)=>{Yn[l]=d})(g,t)}),c.clearPrewarmedResources=function(){let g=ci;g&&(g.isPreloaded()&&g.numActive()===1?(g.release($t),ci=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()"))},c.getMaxParallelImageRequests=function(){return s.a.MAX_PARALLEL_IMAGE_REQUESTS},c.getRTLTextPluginStatus=function(){return mr().getRTLTextPluginStatus()},c.getVersion=function(){return kh},c.getWorkerCount=function(){return fi.workerCount},c.getWorkerUrl=function(){return s.a.WORKER_URL},c.importScriptInWorkers=function(g){return rn().broadcast("IS",g)},c.prewarm=function(){ur().acquire($t)},c.setMaxParallelImageRequests=function(g){s.a.MAX_PARALLEL_IMAGE_REQUESTS=g},c.setRTLTextPlugin=function(g,t){return mr().setRTLTextPlugin(g,t)},c.setWorkerCount=function(g){fi.workerCount=g},c.setWorkerUrl=function(g){s.a.WORKER_URL=g}});var a=h;return a})});var _l=ip((B4,K1)=>{var EE="Expected a function",X1=NaN,TE="[object Symbol]",ME=/^\s+|\s+$/g,PE=/^[-+]0x[0-9a-f]+$/i,AE=/^0b[01]+$/i,RE=/^0o[0-7]+$/i,kE=parseInt,LE=typeof global=="object"&&global&&global.Object===Object&&global,DE=typeof self=="object"&&self&&self.Object===Object&&self,FE=LE||DE||Function("return this")(),zE=Object.prototype,OE=zE.toString,BE=Math.max,NE=Math.min,z_=function(){return FE.Date.now()};function VE(h,e,r){var a,c,s,y,v,b,T=0,C=!1,k=!1,O=!0;if(typeof h!="function")throw new TypeError(EE);e=H1(e)||0,O_(r)&&(C=!!r.leading,k="maxWait"in r,s=k?BE(H1(r.maxWait)||0,e):s,O="trailing"in r?!!r.trailing:O);function G(Ee){var Ge=a,Be=c;return a=c=void 0,T=Ee,y=h.apply(Be,Ge),y}function J(Ee){return T=Ee,v=setTimeout(fe,e),C?G(Ee):y}function le(Ee){var Ge=Ee-b,Be=Ee-T,Ae=e-Ge;return k?NE(Ae,s-Be):Ae}function he(Ee){var Ge=Ee-b,Be=Ee-T;return b===void 0||Ge>=e||Ge<0||k&&Be>=s}function fe(){var Ee=z_();if(he(Ee))return ye(Ee);v=setTimeout(fe,le(Ee))}function ye(Ee){return v=void 0,O&&a?G(Ee):(a=c=void 0,y)}function we(){v!==void 0&&clearTimeout(v),T=0,a=b=c=v=void 0}function Ie(){return v===void 0?y:ye(z_())}function Pe(){var Ee=z_(),Ge=he(Ee);if(a=arguments,c=this,b=Ee,Ge){if(v===void 0)return J(b);if(k)return v=setTimeout(fe,e),G(b)}return v===void 0&&(v=setTimeout(fe,e)),y}return Pe.cancel=we,Pe.flush=Ie,Pe}function O_(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function jE(h){return!!h&&typeof h=="object"}function GE(h){return typeof h=="symbol"||jE(h)&&OE.call(h)==TE}function H1(h){if(typeof h=="number")return h;if(GE(h))return X1;if(O_(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=O_(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(ME,"");var r=AE.test(h);return r||RE.test(h)?kE(h.slice(2),r?2:8):PE.test(h)?X1:+h}K1.exports=VE});var ow=ip((lN,sw)=>{var nw="Expected a function",iw=NaN,$E="[object Symbol]",WE=/^\s+|\s+$/g,ZE=/^[-+]0x[0-9a-f]+$/i,XE=/^0b[01]+$/i,HE=/^0o[0-7]+$/i,KE=parseInt,YE=typeof global=="object"&&global&&global.Object===Object&&global,JE=typeof self=="object"&&self&&self.Object===Object&&self,QE=YE||JE||Function("return this")(),eT=Object.prototype,tT=eT.toString,iT=Math.max,rT=Math.min,U_=function(){return QE.Date.now()};function nT(h,e,r){var a,c,s,y,v,b,T=0,C=!1,k=!1,O=!0;if(typeof h!="function")throw new TypeError(nw);e=rw(e)||0,lf(r)&&(C=!!r.leading,k="maxWait"in r,s=k?iT(rw(r.maxWait)||0,e):s,O="trailing"in r?!!r.trailing:O);function G(Ee){var Ge=a,Be=c;return a=c=void 0,T=Ee,y=h.apply(Be,Ge),y}function J(Ee){return T=Ee,v=setTimeout(fe,e),C?G(Ee):y}function le(Ee){var Ge=Ee-b,Be=Ee-T,Ae=e-Ge;return k?rT(Ae,s-Be):Ae}function he(Ee){var Ge=Ee-b,Be=Ee-T;return b===void 0||Ge>=e||Ge<0||k&&Be>=s}function fe(){var Ee=U_();if(he(Ee))return ye(Ee);v=setTimeout(fe,le(Ee))}function ye(Ee){return v=void 0,O&&a?G(Ee):(a=c=void 0,y)}function we(){v!==void 0&&clearTimeout(v),T=0,a=b=c=v=void 0}function Ie(){return v===void 0?y:ye(U_())}function Pe(){var Ee=U_(),Ge=he(Ee);if(a=arguments,c=this,b=Ee,Ge){if(v===void 0)return J(b);if(k)return v=setTimeout(fe,e),G(b)}return v===void 0&&(v=setTimeout(fe,e)),y}return Pe.cancel=we,Pe.flush=Ie,Pe}function sT(h,e,r){var a=!0,c=!0;if(typeof h!="function")throw new TypeError(nw);return lf(r)&&(a="leading"in r?!!r.leading:a,c="trailing"in r?!!r.trailing:c),nT(h,e,{leading:a,maxWait:e,trailing:c})}function lf(h){var e=typeof h;return!!h&&(e=="object"||e=="function")}function oT(h){return!!h&&typeof h=="object"}function aT(h){return typeof h=="symbol"||oT(h)&&tT.call(h)==$E}function rw(h){if(typeof h=="number")return h;if(aT(h))return iw;if(lf(h)){var e=typeof h.valueOf=="function"?h.valueOf():h;h=lf(e)?e+"":e}if(typeof h!="string")return h===0?h:+h;h=h.replace(WE,"");var r=XE.test(h);return r||HE.test(h)?KE(h.slice(2),r?2:8):ZE.test(h)?iw:+h}sw.exports=sT});var df={};Lm(df,{CopyrightControl:()=>_b,Layer:()=>uf,MaplibreLayer:()=>Q1,MaplibreStyleLayer:()=>tw,RealtimeAPI:()=>Qh,RealtimeLayer:()=>hw,RealtimeModes:()=>$i,RoutingAPI:()=>eu,RoutingControl:()=>G1,StopFinderControl:()=>$1,StopsAPI:()=>tu,VECTOR_TILE_FEATURE_PROPERTY:()=>Pc,VectorLayer:()=>pw,compareDepartures:()=>Iu,createCanvas:()=>_s,createRealtimeFilters:()=>Km,debounceDeparturesMessages:()=>$g,debounceWebsocketMessages:()=>Jh,fullTrajectoryDelayStyle:()=>aw,fullTrajectoryStyle:()=>hf,getCircleCanvas:()=>Wm,getDelayBgCanvas:()=>qm,getDelayTextCanvas:()=>$m,getFeatureInfoAtCoordinate:()=>fw,getHoursAndMinutes:()=>Hx,getLayersAsFlatArray:()=>ru,getMapGlCopyrights:()=>iu,getTextCanvas:()=>Zm,getUTCDateString:()=>Zx,getUTCTimeString:()=>Xx,getUrlWithParams:()=>el,getVehiclePosition:()=>wu,pad:()=>sp,realtimeConfig:()=>Mc,realtimeDefaultStyle:()=>tl,realtimeDelayStyle:()=>Xm,realtimeSimpleStyle:()=>Hm,removeDuplicate:()=>il,renderTrajectories:()=>Su,routingStyle:()=>cw,sortAndFilterDepartures:()=>Cu,sortByDelay:()=>Ym});var k2=(h,e,r=100)=>{let a={},c={},s=[];return y=>{let{source:v,content:b}=y;a[v]&&window.clearTimeout(a[v]),e?c[e(b)]=b:s.push(b),a[v]=window.setTimeout(()=>{let T=e?Object.values(c):s;h(T)},r)}},Jh=k2;var L2=(h,e)=>h===e.SCHEMATIC?"_schematic":"",ys=L2;var Dm=class h{constructor(){this.defineProperties()}static getRequestString(e,r={}){let a=`${e} ${r.channel}`;return a+=r.args?` ${r.args}`:"",a+=r.id?` ${r.id}`:"",a.trim()}addEvents(e,r){this.websocket&&(this.websocket.addEventListener("message",e),r&&(this.websocket.addEventListener("error",r),this.websocket.addEventListener("close",r)))}close(){this.websocket&&(this.open||this.connecting)&&(this.websocket.onclose=()=>{},this.websocket.close(),this.messagesOnOpen=[])}connect(e,r=()=>{}){if(!e){this.websocket?.close();return}if(this.websocket){if(this.websocket.url===e&&(this.open||this.connecting))return;this.websocket.url!==e&&(this.open||this.connecting)&&this.websocket.close()}this.websocket=new WebSocket(e),this.open?(r(),this.subscribePreviousSubscriptions()):this.websocket.addEventListener("open",()=>{r(),this.subscribePreviousSubscriptions()})}defineProperties(){Object.defineProperties(this,{closed:{get:()=>!this.websocket||this.websocket.readyState===this.websocket.CLOSED},closing:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CLOSING)},connecting:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.CONNECTING)},messagesOnOpen:{value:[],writable:!0},open:{get:()=>!!(this.websocket&&this.websocket.readyState===this.websocket.OPEN)},subscribed:{value:{},writable:!0},subscriptions:{value:[],writable:!0}})}get(e,r,a){let c=h.getRequestString("GET",e);this.send(c);let s=C=>(...k)=>{C(...k);let O=this.requests.findIndex(le=>c===le.requestString&&r===le.cb),{onErrorCb:G,onMessageCb:J}=this.requests[O];this.removeEvents(J,G),this.requests.splice(O,1)},{onErrorCb:y,onMessageCb:v}=this.listen(e,s(r),a&&s(a));this.requests||(this.requests=[]);let b=this.requests.findIndex(C=>c===C.requestString&&r===C.cb),T={cb:r,errorCb:a,onErrorCb:y,onMessageCb:v,params:e,requestString:c};b>-1?this.requests[b]=T:this.requests.push(T)}listen(e,r,a){this.unlisten(e,r);let c=s=>{let y;try{y=JSON.parse(s.data)}catch(T){console.error("WebSocket: unable to parse JSON data",T,s.data);return}let v=e.channel;v+=e.args?` ${e.args}`:"";let b;y.source==="buffer"?b=y.content:b=[y],b.forEach(T=>{T?.source===v&&(!e.id||e.id===y.client_reference)&&r(T)})};return this.addEvents(c,a),{onErrorCb:a,onMessageCb:c}}removeEvents(e,r){this.websocket&&(this.websocket.removeEventListener("message",e),r&&(this.websocket.removeEventListener("error",r),this.websocket.removeEventListener("close",r)))}send(e){if(!this.websocket||this.closed||this.closing)return;let r=()=>{this.websocket?.send(e)};this.open?this.messagesOnOpen.includes(e)||r():this.messagesOnOpen.includes(e)||(this.messagesOnOpen.push(e),this.websocket.addEventListener("open",()=>{this.messagesOnOpen=[],r()}),this.websocket.addEventListener("close",()=>{this.messagesOnOpen=[]}))}subscribe(e,r,a,c=!1){let{onErrorCb:s,onMessageCb:y}=this.listen(e,r,a),v=h.getRequestString("",e),b=this.subscriptions.findIndex(C=>e.channel===C.params.channel&&r===C.cb),T={cb:r,errorCb:a,onErrorCb:s,onMessageCb:y,params:e,quiet:c};b>-1?this.subscriptions[b]=T:this.subscriptions.push(T),this.subscribed[v]||(T.quiet||(this.send(`GET ${v}`),this.send(`SUB ${v}`)),this.subscribed[v]=!0)}subscribePreviousSubscriptions(){Object.keys(this.subscribed).forEach(e=>{this.subscribed[e]=!1}),[...this.subscriptions].forEach(e=>{this.subscribe(e.params,e.cb,e.errorCb,e.quiet)})}unlisten(e,r){[...this.subscriptions||[],...this.requests||[]].filter(a=>a.params.channel===e.channel&&(!r||a.cb===r)).forEach(({onErrorCb:a,onMessageCb:c})=>{this.removeEvents(c,a)})}unsubscribe(e,r){let a=this.subscriptions.filter(c=>c.params.channel===e&&(!r||c.cb===r));a.forEach(({onErrorCb:c,onMessageCb:s})=>{this.removeEvents(s,c)}),this.subscriptions=this.subscriptions.filter(c=>c.params.channel!==e||r&&c.cb!==r),e&&this.subscribed[e]&&!this.subscriptions.find(c=>c.params.channel===e)&&a.find(c=>!c.quiet)&&(this.send(`DEL ${e}`),this.subscribed[e]=!1)}},$x=Dm;var $i={RAW:"raw",SCHEMATIC:"schematic",TOPOGRAPHIC:"topographic"},Fm=class{constructor(e={}){this.version="2";let r=e;typeof e=="string"&&(r={url:e});let{apiKey:a}=r,{url:c}=r,s=new $x,y="";a&&!c?.includes("key=")&&(y=`?key=${a}`),this._url=(c||"wss://api.geops.io/tracker-ws/v1/")+y,this._buffer=r.buffer||[100,100],this._bbox=r.bbox,this.version=r.version||"2",this.pingIntervalMs=r.pingIntervalMs||1e4,this.reconnectTimeoutMs=r.reconnectTimeoutMs||100,this.wsApi=s}get bbox(){return this._bbox}set bbox(e){JSON.stringify(e)!==JSON.stringify(this._bbox)&&(this._bbox=e,this.wsApi&&this._bbox&&this.wsApi.send(`BBOX ${this._bbox.join(" ")}`))}get buffer(){return this._buffer}set buffer(e){JSON.stringify(e)!==JSON.stringify(this._buffer)&&(this._buffer=e,this.wsApi&&this._buffer&&this.wsApi.send(`BUFFER ${this._buffer.join(" ")}`))}get url(){return this._url}set url(e){this._url!==e&&(this._url=e,(this.wsApi.open||this.wsApi.connecting)&&this.open())}close(){this.wsApi.close()}get(e){let r=e;return typeof e=="string"&&(r={channel:e}),new Promise((a,c)=>{this.wsApi.get(r,a,c)})}getFullTrajectory(e,r,a){let c="";this.version==="1"&&(c=ys(r,$i));let s=[`full_trajectory${c}`];return e&&s.push(e),(!r||r===$i.TOPOGRAPHIC)&&a&&s.push(`gen${a}`),this.get(s.join("_"))}getStation(e,r){let a={args:e,channel:`station${ys(r,$i)}`};return this.get(a)}getStations(e,r=100){return new Promise(a=>{this.get(`station${ys(e,$i)}`).then(Jh(a,void 0,r))})}getStopSequence(e){return this.get(`stopsequence_${e}`)}getTrajectory(e,r){return this.get(`partial_trajectory${ys(r,$i)}_${e}`)}onClose(){window.clearTimeout(this.pingInterval),window.clearTimeout(this.reconnectTimeout),this.reconnectTimeoutMs&&(this.reconnectTimeout=window.setTimeout(()=>this.open(),this.reconnectTimeoutMs))}onOpen(){this.bbox&&this.wsApi.send(`BBOX ${this.bbox.join(" ")}`),this.buffer&&this.wsApi.send(`BUFFER ${this.buffer.join(" ")}`),this.pingIntervalMs&&(window.clearInterval(this.pingInterval),this.pingInterval=window.setInterval(()=>{this.wsApi.send("PING")},this.pingIntervalMs))}open(){this.wsApi.connect(this.url,this.onOpen.bind(this)),this.wsApi.websocket&&(this.wsApi.websocket.onclose=()=>{this.onClose()})}reset(){this.wsApi.send("RESET")}subscribe(e,r,a=()=>{},c=!1){!e||!r||this.wsApi.subscribe({channel:e},r,a,c)}subscribeDeletedVehicles(e,r,a=()=>{},c=!1){this.unsubscribeDeletedVehicles(r);let s="";this.version==="1"&&(s=ys(e,$i)),this.subscribe(`deleted_vehicles${s}`,r,a,c)}subscribeDepartures(e,r,a=()=>{},c=!1){this.subscribeTimetable(e,r,a,c)}subscribeDisruptions(e,r,a=()=>{},c=!1){this.subscribeNewsticker(e,r,a,c)}subscribeExtraGeoms(e,r=()=>{},a=!1){this.subscribe("extra_geoms",e,r,a)}subscribeFullTrajectory(e,r,a,c=()=>{},s=!1){let y="";this.version==="1"&&(y=ys(r,$i)),this.subscribe(`full_trajectory${y}_${e}`,a,c,s)}subscribeHealthCheck(e,r=()=>{},a=!1){this.subscribe("healthcheck",e,r,a)}subscribeNewsticker(e,r,a=()=>{},c=!1){this.subscribe(`${e}_newsticker`,r,a,c)}subscribeStations(e,r,a=()=>{},c=!1){this.subscribe(`station${ys(e,$i)}`,r,a,c)}subscribeStopSequence(e,r,a=()=>{},c=!1){this.subscribe(`stopsequence_${e}`,r,a,c)}subscribeTimetable(e,r,a=()=>{},c=!1){this.subscribe(`timetable_${e}`,r,a,c)}subscribeTrajectory(e,r,a=()=>{},c=!1){this.unsubscribeTrajectory(r);let s="";this.version==="1"&&(s=ys(e,$i)),this.subscribe(`trajectory${s}`,r,a,c)}unsubscribe(e,r="",a){let c=ys($i.SCHEMATIC,$i),s=ys($i.TOPOGRAPHIC,$i);this.wsApi.unsubscribe(`${e}${c}${r||""}`,a),this.wsApi.unsubscribe(`${e}${s}${r||""}`,a)}unsubscribeDeletedVehicles(e){this.unsubscribe("deleted_vehicles","",e)}unsubscribeDepartures(e,r){this.unsubscribeTimetable(e,r)}unsubscribeDisruptions(e,r){this.unsubscribeNewsticker(e,r)}unsubscribeExtraGeoms(e){this.unsubscribe("extra_geoms","",e)}unsubscribeFullTrajectory(e,r){this.unsubscribe("full_trajectory",`_${e}`,r)}unsubscribeHealthCheck(e){this.unsubscribe("healthcheck","",e)}unsubscribeNewsticker(e,r){this.unsubscribe(`${e}_newsticker`,"",r)}unsubscribeStations(e){this.unsubscribe("station","",e)}unsubscribeStopSequence(e,r){this.unsubscribe("stopsequence",`_${e}`,r)}unsubscribeTimetable(e,r){this.unsubscribe(`timetable_${e}`,"",r)}unsubscribeTrajectory(e){this.unsubscribe("trajectory","",e)}},Qh=Fm;var D2=(h,e)=>{let r=new URL(h);return Object.entries(e||{}).forEach(([c,s])=>{s!=null&&r.searchParams.set(c,s)}),r},el=D2;var zm=class{constructor(e){this.url=e.url,this.apiKey=e.apiKey}async fetch(e,r,a){if(!this.url)throw new Error(`No url defined for request to ${this.url}/${e}`);if(!this.url&&!this.apiKey&&!this.url.includes("key="))throw new Error(`No apiKey defined for request to ${this.url}`);let c=r||{},s=el(`${this.url}${e||""}`,{key:this.apiKey,...c}),v=await(await fetch(s.toString(),a)).json();if(v.error)throw new Error(v.error);return v}},rp=zm;var Om=class extends rp{constructor(e={}){super({url:"https://api.geops.io/routing/v1/",...e})}route(e,r){return this.fetch("",e,r)}},eu=Om;var Bm=class extends rp{constructor(e={}){super({...e,url:e.url||"https://api.geops.io/stops/v1/"})}search(e,r){return this.fetch("",e,r)}},tu=Bm;var F2=(h,e)=>{let r=null;return typeof window>"u"?null:(typeof document<"u"&&document?.createElement?(r=document.createElement("canvas"),r.width=h,r.height=e):OffscreenCanvas?r=new OffscreenCanvas(h,e):console.error("We didn't find a way to create a canvas element, document.createElement('canvas') and new OffscrenCanvas() are not supported"),r)},_s=F2;var Nm={},qm=(h,e,r)=>{let a=`${h}, ${e}, ${r}`;if(!Nm[a]){let c=_s(h*2,h*2);if(c){let s=c.getContext("2d");if(!s)return null;s.beginPath(),s.arc(h,h,e,0,2*Math.PI,!1),s.fillStyle=r,s.filter="blur(1px)",s.fill(),Nm[a]=c}}return Nm[a]},Vm={},$m=(h,e,r,a,c="#000",s=1)=>{let y=`${h}, ${r}, ${a}, ${c}, ${s}`;if(!Vm[y]){let v=_s(Math.ceil(h.length*e),Math.ceil(e+8*s));if(v){let b=v.getContext("2d");if(!b)return null;b.font=r,b.textAlign="left",b.textBaseline="middle",b.font=r,b.fillStyle=a,b.strokeStyle=c,b.lineWidth=1.5*s,b.strokeText(h,0,e),b.fillText(h,0,e),Vm[y]=v}}return Vm[y]},jm={},Wm=(h,e,r,a,c,s)=>{let y=`${h}, ${e}, ${r}, ${a}, ${c}, ${s}`;if(!jm[y]){let v=_s(h*2,h*2);if(v){let b=v.getContext("2d");if(!b)return null;b.fillStyle=r,a&&(b.lineWidth=1*s,b.strokeStyle="#000000"),b.beginPath(),b.arc(h,h,e,0,2*Math.PI,!1),b.fill(),c&&b.setLineDash([5,3]),a&&b.stroke(),jm[y]=v}}return jm[y]},Gm={},Zm=(h,e,r,a,c,s,y,v)=>{let b=`${h}, ${e}, ${r}, ${a},${c}, ${s}, ${y}`;if(!Gm[b]){let T=_s(e*2,e*2);if(T){let C=T.getContext("2d");if(!C)return null;s&&(C.save(),C.textBaseline="middle",C.textAlign="center",C.font=v(r+2,h),C.strokeStyle=c,C.strokeText(h,e,e),C.restore()),C.textBaseline="middle",C.textAlign="center",C.fillStyle=a,C.font=v(r,h),C.strokeStyle=c,C.strokeText(h,e,e),C.fillText(h,e,e),Gm[b]=T}}return Gm[b]},Um={},z2=(h,e,r)=>{let{delayDisplay:a=3e5,delayOutlineColor:c="#000",getBgColor:s=()=>"#000",getDelayColor:y=()=>"#000",getDelayFont:v=$t=>`bold ${$t}px arial, sans-serif`,getDelayText:b=()=>null,getMaxRadiusForStrokeAndDelay:T=()=>7,getMaxRadiusForText:C=()=>10,getRadius:k=()=>0,getText:O=$t=>$t,getTextColor:G=()=>"#000",getTextFont:J=$t=>`bold ${$t}px arial, sans-serif`,getTextSize:le=()=>14,hoverVehicleId:he,selectedVehicleId:fe,useDelayStyle:ye}=r,{pixelRatio:we=1,zoom:Ie}=e,{type:Pe}=h.properties,{delay:Ee,line:Ge,operator_provides_realtime_journey:Be,state:Ae,train_id:st}=h.properties,{color:ct,name:rt,text_color:xt}=Ge||{};rt=O(rt);let Rt=Ae==="JOURNEY_CANCELLED";Pe||(Pe="Rail"),rt||(rt="I"),xt||(xt="#000000"),ct&&!ct.startsWith("#")&&(ct=`#${ct}`),xt.startsWith("#")||(xt=`#${xt}`);let at=Math.min(Math.floor(Ie||1),16),gt=!!(he&&he===st),ot=!!(fe&&fe===st),pt=k(Pe,at)*we,Pt=pt>=T()*we;(gt||ot)&&(pt=Pt?pt+5*we:14*we);let kt=pt>C()*we,Lt=`${pt}${gt||ot}`;if(ye?(Lt+=`${Be}${Ee}`,Pt&&(Lt+=`${Rt}`)):(Lt+=`${ct||Pe}`,Pt&&(Lt+=`${Rt}${Ee}`)),kt&&(Lt+=`${rt}${xt}`),!Um[Lt]){if(pt===0)return null;let $t=1*we,fi=pt+2*we,$e=pt*2,ci=fi*2+$t*2,di=ci/2,ur=null;Pt&&Ee!==null&&(ur=qm(di,fi,y(Ee,Rt)));let dr=null,rn=0;if(Pt&&(gt||(Ee||0)>=a||Rt)){rn=Math.max(Rt?19:14,Math.min(Rt?19:17,pt*1.2))*we;let bt=b(Ee,Rt);bt&&(dr=$m(bt,rn,v(rn,bt),y(Ee,Rt,!0),c,we))}let ji;ye?ji=y(Ee,Rt):ji=ct||s(Pe);let Pn=Wm(di,pt,ji,Pt||gt||ot,!!Pt&&!!ye&&Ee===null&&Be==="yes",we),ve=ci+(dr?.width||0)*2,pr=_s(ve,ci);if(pr){let bt=pr.getContext("2d");if(!bt)return null;let Zt=dr?.width||0;ur&&bt.drawImage(ur,Zt,0),Pn&&bt.drawImage(Pn,Zt,0);let Rn=null;if(kt){let on=Math.max(pt,10),Ar=le(bt,$e,rt,on,J),an=ye?"#000000":xt||G(Pe);Rn=Zm(rt,di,Ar,an,ji,!!ye&&Ee===null&&Be==="yes",we,J)}Rn&&bt.drawImage(Rn,Zt,0),dr&&bt.drawImage(dr,Zt+Math.ceil(di+fi)+$t,Math.ceil(di-rn)),Um[Lt]=pr}}return Um[Lt]},tl=z2;var O2=(h,e,r)=>tl(h,e,{...r,useDelayStyle:!0}),Xm=O2;var np,B2=()=>{if(!np){np=_s(15,15);let h=np?.getContext("2d");h&&(h.arc(8,8,5,0,2*Math.PI,!1),h.fillStyle="#8ED6FF",h.fill(),h.lineWidth=3,h.strokeStyle="black",h.stroke(),h.lineWidth=3)}return np},Hm=B2;var N2=h=>{let e=h.filter(s=>s!=null&&s.trim&&s.trim()),r=e.map(s=>s.toLowerCase());return[...new Set(r)].map(s=>e.find(y=>y.toLowerCase()===s))},il=N2;var V2=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,a=[];return Object.values(r).forEach(c=>{if(c.used){let s=c.getSource(),y=s.attribution||s.options?.attribution;y&&(a=a.concat(y.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),il(a)},iu=V2;var j2=(h,e,r,a)=>{let c=[];if(!h&&!e&&!r&&!a)return null;if(a){let s=typeof a=="string"?[a]:a,y=v=>{let b=v.properties.name||v.properties.line&&v.properties.line.name||"";return b?s.some(T=>new RegExp(T,"i").test(b)):!1};c.push(y)}if(h){let y=(typeof h=="string"?h.split(","):h).map(b=>b.replace(/\s+/g,"").toUpperCase()),v=b=>{let{line:T,name:C}=b.properties,k=(C||T&&T.name||"").toUpperCase();return k?y.includes(k):!1};c.push(v)}if(e){let y=(typeof e=="string"?e.split(","):e).map(b=>parseInt(b,10)),v=b=>{let T=b.properties.route_identifier||b.properties.routeIdentifier||"",C=parseInt(T.split(".")[0],10);return y.includes(C)};c.push(v)}if(r){let s=typeof r=="string"?[r]:r,y=v=>s.some(b=>{let T=v.properties.operator||v.properties.tenant||"";return new RegExp(b,"i").test(T)});c.push(y)}return c.length?s=>{for(let y=0;y<c.length;y+=1)if(!c[y](s))return!1;return!0}:null},Km=j2;var Wx=h=>{let e=h;Array.isArray(e)||(e=[h]);let r=[];return e.forEach(a=>{r.push(a);let c=a.children||a.get("children")||a.getLayers?.()?.getArray();r=r.concat(Wx(c||[]))}),r},ru=Wx;var Zx=(h=new Date)=>{let e=(h.getUTCMonth()+1).toString();e=e.length===1?`0${e}`:e;let r=h.getUTCDate().toString();return r=r.length===1?`0${r}`:r,[h.getUTCFullYear(),e,r].join("")},Xx=h=>[h.getUTCHours(),h.getUTCMinutes(),`${h.getUTCSeconds()}.${h.getUTCMilliseconds()}`].join(":"),sp=h=>h<10?`0${h}`:`${h}`,Hx=h=>{if(!h||h<=0)return"";let e=new Date(h);return`${sp(e.getHours())}:${sp(e.getMinutes())}`};var G2=(h,e)=>{let r=h.properties,a=e.properties;return r.delay===null&&a.delay!==null?1:a.delay===null&&r.delay!==null?-1:r.cancelled&&!a.cancelled?a.delay<18e4?-1:1:a.cancelled&&!r.cancelled?r.delay<18e4?1:-1:a.delay-r.delay},Ym=G2;function ui(h,e){if(!h)throw new Error(e)}var IM=new Array(6);function sr(){return[1,0,0,1,0,0]}function Yx(h,e){return h[0]=e[0],h[1]=e[1],h[2]=e[2],h[3]=e[3],h[4]=e[4],h[5]=e[5],h}function br(h,e){let r=e[0],a=e[1];return e[0]=h[0]*r+h[2]*a+h[4],e[1]=h[1]*r+h[3]*a+h[5],e}function Vr(h,e,r,a,c,s,y,v){let b=Math.sin(s),T=Math.cos(s);return h[0]=a*T,h[1]=c*b,h[2]=-a*b,h[3]=c*T,h[4]=y*a*T-v*a*b+e,h[5]=y*c*b+v*c*T+r,h}function Jx(h,e,r,a,c,s,y){return Jm(Vr(sr(),h,e,r,a,c,s,y))}function Qx(h,e){let r=U2(e);ui(r!==0,"Transformation matrix cannot be inverted");let a=e[0],c=e[1],s=e[2],y=e[3],v=e[4],b=e[5];return h[0]=y/r,h[1]=-c/r,h[2]=-s/r,h[3]=a/r,h[4]=(s*b-y*v)/r,h[5]=-(a*b-c*v)/r,h}function U2(h){return h[0]*h[3]-h[1]*h[2]}var Kx=[1e6,1e6,1e6,1e6,2,2];function Jm(h){return"matrix("+h.map((r,a)=>Math.round(r*Kx[a])/Kx[a]).join(", ")+")"}var Qm=class{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}};var Si=Qm;var op={PROPERTYCHANGE:"propertychange"};var eg=class{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}},ev=eg;function tv(h,e,r){let a,c;r=r||xs;let s=0,y=h.length,v=!1;for(;s<y;)a=s+(y-s>>1),c=+r(h[a],e),c<0?s=a+1:(y=a,v=!c);return v?s:~s}function xs(h,e){return h>e?1:h<e?-1:0}function iv(h,e){return h<e?1:h>e?-1:0}function ap(h,e,r){if(h[0]<=e)return 0;let a=h.length;if(e<=h[a-1])return a-1;if(typeof r=="function"){for(let c=1;c<a;++c){let s=h[c];if(s===e)return c;if(s<e)return r(e,h[c-1],s)>0?c-1:c}return a-1}if(r>0){for(let c=1;c<a;++c)if(h[c]<e)return c-1;return a-1}if(r<0){for(let c=1;c<a;++c)if(h[c]<=e)return c;return a-1}for(let c=1;c<a;++c){if(h[c]==e)return c;if(h[c]<e)return h[c-1]-e<e-h[c]?c-1:c}return a-1}function rv(h,e,r){for(;e<r;){let a=h[e];h[e]=h[r],h[r]=a,++e,--r}}function wr(h,e){let r=Array.isArray(e)?e:[e],a=r.length;for(let c=0;c<a;c++)h[h.length]=r[c]}function yn(h,e){let r=h.length;if(r!==e.length)return!1;for(let a=0;a<r;a++)if(h[a]!==e[a])return!1;return!0}function lp(){return!0}function vs(){}function cp(h){let e,r,a;return function(){let c=Array.prototype.slice.call(arguments);return(!r||this!==a||!yn(c,r))&&(a=this,r=c,e=h.apply(this,arguments)),e}}function mc(h){for(let e in h)delete h[e]}function Wn(h){let e;for(e in h)return!1;return!e}var tg=class extends ev{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,r){if(!e||!r)return;let a=this.listeners_||(this.listeners_={}),c=a[e]||(a[e]=[]);c.includes(r)||c.push(r)}dispatchEvent(e){let r=typeof e=="string",a=r?e:e.type,c=this.listeners_&&this.listeners_[a];if(!c)return;let s=r?new Si(e):e;s.target||(s.target=this.eventTarget_||this);let y=this.dispatching_||(this.dispatching_={}),v=this.pendingRemovals_||(this.pendingRemovals_={});a in y||(y[a]=0,v[a]=0),++y[a];let b;for(let T=0,C=c.length;T<C;++T)if("handleEvent"in c[T]?b=c[T].handleEvent(s):b=c[T].call(this,s),b===!1||s.propagationStopped){b=!1;break}if(--y[a]===0){let T=v[a];for(delete v[a];T--;)this.removeEventListener(a,vs);delete y[a]}return b}disposeInternal(){this.listeners_&&mc(this.listeners_)}getListeners(e){return this.listeners_&&this.listeners_[e]||void 0}hasListener(e){return this.listeners_?e?e in this.listeners_:Object.keys(this.listeners_).length>0:!1}removeEventListener(e,r){if(!this.listeners_)return;let a=this.listeners_[e];if(!a)return;let c=a.indexOf(r);c!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(a[c]=vs,++this.pendingRemovals_[e]):(a.splice(c,1),a.length===0&&delete this.listeners_[e]))}},hp=tg;var pi={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function Sr(h,e,r,a,c){if(c){let y=r;r=function(){h.removeEventListener(e,r),y.apply(a??this,arguments)}}else a&&a!==h&&(r=r.bind(a));let s={target:h,type:e,listener:r};return h.addEventListener(e,r),s}function ig(h,e,r,a){return Sr(h,e,r,a,!0)}function jr(h){h&&h.target&&(h.target.removeEventListener(h.type,h.listener),mc(h))}var gc=class extends hp{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(pi.CHANGE)}getRevision(){return this.revision_}onInternal(e,r){if(Array.isArray(e)){let a=e.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Sr(this,e[s],r);return c}return Sr(this,e,r)}onceInternal(e,r){let a;if(Array.isArray(e)){let c=e.length;a=new Array(c);for(let s=0;s<c;++s)a[s]=ig(this,e[s],r)}else a=ig(this,e,r);return r.ol_key=a,a}unInternal(e,r){let a=r.ol_key;if(a)bs(a);else if(Array.isArray(e))for(let c=0,s=e.length;c<s;++c)this.removeEventListener(e[c],r);else this.removeEventListener(e,r)}};gc.prototype.on;gc.prototype.once;gc.prototype.un;function bs(h){if(Array.isArray(h))for(let e=0,r=h.length;e<r;++e)jr(h[e]);else jr(h)}var up=gc;function wt(){throw new Error("Unimplemented abstract method.")}var q2=0;function Vt(h){return h.ol_uid||(h.ol_uid=String(++q2))}var dp=class extends Si{constructor(e,r,a){super(e),this.key=r,this.oldValue=a}},rg=class extends up{constructor(e){super(),this.on,this.once,this.un,Vt(this),this.values_=null,e!==void 0&&this.setProperties(e)}get(e){let r;return this.values_&&this.values_.hasOwnProperty(e)&&(r=this.values_[e]),r}getKeys(){return this.values_&&Object.keys(this.values_)||[]}getProperties(){return this.values_&&Object.assign({},this.values_)||{}}getPropertiesInternal(){return this.values_}hasProperties(){return!!this.values_}notify(e,r){let a;a=`change:${e}`,this.hasListener(a)&&this.dispatchEvent(new dp(a,e,r)),a=op.PROPERTYCHANGE,this.hasListener(a)&&this.dispatchEvent(new dp(a,e,r))}addChangeListener(e,r){this.addEventListener(`change:${e}`,r)}removeChangeListener(e,r){this.removeEventListener(`change:${e}`,r)}set(e,r,a){let c=this.values_||(this.values_={});if(a)c[e]=r;else{let s=c[e];c[e]=r,s!==r&&this.notify(e,s)}}setProperties(e,r){for(let a in e)this.set(a,e[a],r)}applyProperties(e){e.values_&&Object.assign(this.values_||(this.values_={}),e.values_)}unset(e,r){if(this.values_&&e in this.values_){let a=this.values_[e];delete this.values_[e],Wn(this.values_)&&(this.values_=null),r||this.notify(e,a)}}},or=rg;var Ni={UNKNOWN:0,INTERSECTING:1,ABOVE:2,RIGHT:4,BELOW:8,LEFT:16};function ss(h){let e=xn();for(let r=0,a=h.length;r<a;++r)ng(e,h[r]);return e}function $2(h,e,r){let a=Math.min.apply(null,h),c=Math.min.apply(null,e),s=Math.max.apply(null,h),y=Math.max.apply(null,e);return yo(a,c,s,y,r)}function os(h,e,r){return r?(r[0]=h[0]-e,r[1]=h[1]-e,r[2]=h[2]+e,r[3]=h[3]+e,r):[h[0]-e,h[1]-e,h[2]+e,h[3]+e]}function nv(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h.slice()}function _n(h,e,r){let a,c;return e<h[0]?a=h[0]-e:h[2]<e?a=e-h[2]:a=0,r<h[1]?c=h[1]-r:h[3]<r?c=r-h[3]:c=0,a*a+c*c}function rl(h,e){return nu(h,e[0],e[1])}function go(h,e){return h[0]<=e[0]&&e[2]<=h[2]&&h[1]<=e[1]&&e[3]<=h[3]}function nu(h,e,r){return h[0]<=e&&e<=h[2]&&h[1]<=r&&r<=h[3]}function pp(h,e){let r=h[0],a=h[1],c=h[2],s=h[3],y=e[0],v=e[1],b=Ni.UNKNOWN;return y<r?b=b|Ni.LEFT:y>c&&(b=b|Ni.RIGHT),v<a?b=b|Ni.BELOW:v>s&&(b=b|Ni.ABOVE),b===Ni.UNKNOWN&&(b=Ni.INTERSECTING),b}function xn(){return[1/0,1/0,-1/0,-1/0]}function yo(h,e,r,a,c){return c?(c[0]=h,c[1]=e,c[2]=r,c[3]=a,c):[h,e,r,a]}function yc(h){return yo(1/0,1/0,-1/0,-1/0,h)}function ca(h,e){let r=h[0],a=h[1];return yo(r,a,r,a,e)}function _c(h,e,r,a,c){let s=yc(c);return sg(s,h,e,r,a)}function fp(h,e){return h[0]==e[0]&&h[2]==e[2]&&h[1]==e[1]&&h[3]==e[3]}function sv(h,e){return e[0]<h[0]&&(h[0]=e[0]),e[2]>h[2]&&(h[2]=e[2]),e[1]<h[1]&&(h[1]=e[1]),e[3]>h[3]&&(h[3]=e[3]),h}function ng(h,e){e[0]<h[0]&&(h[0]=e[0]),e[0]>h[2]&&(h[2]=e[0]),e[1]<h[1]&&(h[1]=e[1]),e[1]>h[3]&&(h[3]=e[1])}function sg(h,e,r,a,c){for(;r<a;r+=c)W2(h,e[r],e[r+1]);return h}function W2(h,e,r){h[0]=Math.min(h[0],e),h[1]=Math.min(h[1],r),h[2]=Math.max(h[2],e),h[3]=Math.max(h[3],r)}function ov(h,e){let r;return r=e(og(h)),r||(r=e(ag(h)),r)||(r=e(cg(h)),r)||(r=e(lg(h)),r)?r:!1}function og(h){return[h[0],h[1]]}function ag(h){return[h[2],h[1]]}function as(h){return[(h[0]+h[2])/2,(h[1]+h[3])/2]}function av(h,e,r,a,c){let[s,y,v,b,T,C,k,O]=Z2(h,e,r,a);return yo(Math.min(s,v,T,k),Math.min(y,b,C,O),Math.max(s,v,T,k),Math.max(y,b,C,O),c)}function Z2(h,e,r,a){let c=e*a[0]/2,s=e*a[1]/2,y=Math.cos(r),v=Math.sin(r),b=c*y,T=c*v,C=s*y,k=s*v,O=h[0],G=h[1];return[O-b+k,G-T-C,O-b-k,G-T+C,O+b-k,G+T+C,O+b+k,G+T-C,O-b+k,G-T-C]}function Wi(h){return h[3]-h[1]}function lg(h){return[h[0],h[3]]}function cg(h){return[h[2],h[3]]}function vi(h){return h[2]-h[0]}function Vi(h,e){return h[0]<=e[2]&&h[2]>=e[0]&&h[1]<=e[3]&&h[3]>=e[1]}function su(h){return h[2]<h[0]||h[3]<h[1]}function lv(h,e){return e?(e[0]=h[0],e[1]=h[1],e[2]=h[2],e[3]=h[3],e):h}function cv(h,e,r){let a=!1,c=pp(h,e),s=pp(h,r);if(c===Ni.INTERSECTING||s===Ni.INTERSECTING)a=!0;else{let y=h[0],v=h[1],b=h[2],T=h[3],C=e[0],k=e[1],O=r[0],G=r[1],J=(G-k)/(O-C),le,he;s&Ni.ABOVE&&!(c&Ni.ABOVE)&&(le=O-(G-T)/J,a=le>=y&&le<=b),!a&&s&Ni.RIGHT&&!(c&Ni.RIGHT)&&(he=G-(O-b)*J,a=he>=v&&he<=T),!a&&s&Ni.BELOW&&!(c&Ni.BELOW)&&(le=O-(G-v)/J,a=le>=y&&le<=b),!a&&s&Ni.LEFT&&!(c&Ni.LEFT)&&(he=G-(O-y)*J,a=he>=v&&he<=T)}return a}function hv(h,e,r,a){if(su(h))return yc(r);let c=[];if(a>1){let v=h[2]-h[0],b=h[3]-h[1];for(let T=0;T<a;++T)c.push(h[0]+v*T/a,h[1],h[2],h[1]+b*T/a,h[2]-v*T/a,h[3],h[0],h[3]-b*T/a)}else c=[h[0],h[1],h[2],h[1],h[2],h[3],h[0],h[3]];e(c,c,2);let s=[],y=[];for(let v=0,b=c.length;v<b;v+=2)s.push(c[v]),y.push(c[v+1]);return $2(s,y,r)}function hg(h,e){let r=e.getExtent(),a=as(h);if(e.canWrapX()&&(a[0]<r[0]||a[0]>=r[2])){let c=vi(r),y=Math.floor((a[0]-r[0])/c)*c;h[0]-=y,h[2]-=y}return h}function uv(h,e,r){if(e.canWrapX()){let a=e.getExtent();if(!isFinite(h[0])||!isFinite(h[2]))return[[a[0],h[1],a[2],h[3]]];hg(h,e);let c=vi(a);if(vi(h)>c&&!r)return[[a[0],h[1],a[2],h[3]]];if(h[0]<a[0])return[[h[0]+c,h[1],a[2],h[3]],[a[0],h[1],h[2],h[3]]];if(h[2]>a[2])return[[h[0],h[1],a[2],h[3]],[a[0],h[1],h[2]-c,h[3]]]}return[h]}var ou={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var ug=class{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||ou[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}},xc=ug;var au=6378137,vc=Math.PI*au,X2=[-vc,-vc,vc,vc],H2=[-180,-85,180,85],mp=au*Math.log(Math.tan(Math.PI/2)),ha=class extends xc{constructor(e){super({code:e,units:"m",extent:X2,global:!0,worldExtent:H2,getPointResolution:function(r,a){return r/Math.cosh(a[1]/au)}})}},dg=[new ha("EPSG:3857"),new ha("EPSG:102100"),new ha("EPSG:102113"),new ha("EPSG:900913"),new ha("http://www.opengis.net/def/crs/EPSG/0/3857"),new ha("http://www.opengis.net/gml/srs/epsg.xml#3857")];function dv(h,e,r,a){let c=h.length;r=r>1?r:2,a=a??r,e===void 0&&(r>2?e=h.slice():e=new Array(c));for(let s=0;s<c;s+=a){e[s]=vc*h[s]/180;let y=au*Math.log(Math.tan(Math.PI*(+h[s+1]+90)/360));y>mp?y=mp:y<-mp&&(y=-mp),e[s+1]=y}return e}function pv(h,e,r,a){let c=h.length;r=r>1?r:2,a=a??r,e===void 0&&(r>2?e=h.slice():e=new Array(c));for(let s=0;s<c;s+=a)e[s]=180*h[s]/vc,e[s+1]=360*Math.atan(Math.exp(h[s+1]/au))/Math.PI-90;return e}var K2=6378137,fv=[-180,-90,180,90],Y2=Math.PI*K2/180,_o=class extends xc{constructor(e,r){super({code:e,units:"degrees",extent:fv,axisOrientation:r,global:!0,metersPerUnit:Y2,worldExtent:fv})}},pg=[new _o("CRS:84"),new _o("EPSG:4326","neu"),new _o("urn:ogc:def:crs:OGC:1.3:CRS84"),new _o("urn:ogc:def:crs:OGC:2:84"),new _o("http://www.opengis.net/def/crs/OGC/1.3/CRS84"),new _o("http://www.opengis.net/gml/srs/epsg.xml#4326","neu"),new _o("http://www.opengis.net/def/crs/EPSG/0/4326","neu")];var fg={};function mv(h){return fg[h]||fg[h.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\w+)$/,"EPSG:$3")]||null}function gv(h,e){fg[h]=e}var bc={};function wc(h,e,r){let a=h.getCode(),c=e.getCode();a in bc||(bc[a]={}),bc[a][c]=r}function gp(h,e){return h in bc&&e in bc[h]?bc[h][e]:null}function Ii(h,e,r){return Math.min(Math.max(h,e),r)}function yv(h,e,r,a,c,s){let y=c-r,v=s-a;if(y!==0||v!==0){let b=((h-r)*y+(e-a)*v)/(y*y+v*v);b>1?(r=c,a=s):b>0&&(r+=y*b,a+=v*b)}return ws(h,e,r,a)}function ws(h,e,r,a){let c=r-h,s=a-e;return c*c+s*s}function lu(h){return h*180/Math.PI}function nl(h){return h*Math.PI/180}function sl(h,e){let r=h%e;return r*e<0?r+e:r}function Ir(h,e,r){return h+r*(e-h)}function _v(h,e){let r=Math.pow(10,e);return Math.round(h*r)/r}function yp(h,e,r){if(h>=e&&h<r)return h;let a=r-e;return((h-e)%a+a)%a+e}function xv(h,e){return h[0]+=+e[0],h[1]+=+e[1],h}function mg(h,e){let r=h[0],a=h[1],c=e[0],s=e[1],y=c[0],v=c[1],b=s[0],T=s[1],C=b-y,k=T-v,O=C===0&&k===0?0:(C*(r-y)+k*(a-v))/(C*C+k*k||0),G,J;return O<=0?(G=y,J=v):O>=1?(G=b,J=T):(G=y+O*C,J=v+O*k),[G,J]}function Zi(h,e){let r=!0;for(let a=h.length-1;a>=0;--a)if(h[a]!=e[a]){r=!1;break}return r}function vv(h,e){let r=Math.cos(e),a=Math.sin(e),c=h[0]*r-h[1]*a,s=h[1]*r+h[0]*a;return h[0]=c,h[1]=s,h}function Sc(h,e){let r=h[0]-e[0],a=h[1]-e[1];return r*r+a*a}function gg(h,e){return Math.sqrt(Sc(h,e))}function bv(h,e){return Sc(h,mg(h,e))}function wv(h,e){if(e.canWrapX()){let r=vi(e.getExtent()),a=Sv(h,e,r);a&&(h[0]-=a*r)}return h}function Sv(h,e,r){let a=e.getExtent(),c=0;return e.canWrapX()&&(h[0]<a[0]||h[0]>a[2])&&(r=r||vi(a),c=Math.floor((h[0]-a[0])/r)),c}var _p=.9996,ls=.00669438,vp=ls*ls,bp=vp*ls,ol=ls/(1-ls),Iv=Math.sqrt(1-ls),Ic=(1-Iv)/(1+Iv),Mv=Ic*Ic,yg=Mv*Ic,_g=yg*Ic,Pv=_g*Ic,Av=1-ls/4-3*vp/64-5*bp/256,J2=3*ls/8+3*vp/32+45*bp/1024,Q2=15*vp/256+45*bp/1024,eI=35*bp/3072,tI=3/2*Ic-27/32*yg+269/512*Pv,iI=21/16*Mv-55/32*_g,rI=151/96*yg-417/128*Pv,nI=1097/512*_g,xp=6378137;function sI(h,e,r){let a=h-5e5,y=(r.north?e:e-1e7)/_p/(xp*Av),v=y+tI*Math.sin(2*y)+iI*Math.sin(4*y)+rI*Math.sin(6*y)+nI*Math.sin(8*y),b=Math.sin(v),T=b*b,C=Math.cos(v),k=b/C,O=k*k,G=O*O,J=1-ls*T,le=Math.sqrt(1-ls*T),he=xp/le,fe=(1-ls)/J,ye=ol*C**2,we=ye*ye,Ie=a/(he*_p),Pe=Ie*Ie,Ee=Pe*Ie,Ge=Ee*Ie,Be=Ge*Ie,Ae=Be*Ie,st=v-k/fe*(Pe/2-Ge/24*(5+3*O+10*ye-4*we-9*ol))+Ae/720*(61+90*O+298*ye+45*G-252*ol-3*we),ct=(Ie-Ee/6*(1+2*O+ye)+Be/120*(5-2*ye+28*O-3*we+8*ol+24*G))/C;return ct=yp(ct+nl(Rv(r.number)),-Math.PI,Math.PI),[lu(ct),lu(st)]}var Cv=-80,Ev=84,oI=-180,aI=180;function lI(h,e,r){h=yp(h,oI,aI),e<Cv?e=Cv:e>Ev&&(e=Ev);let a=nl(e),c=Math.sin(a),s=Math.cos(a),y=c/s,v=y*y,b=v*v,T=nl(h),C=Rv(r.number),k=nl(C),O=xp/Math.sqrt(1-ls*c**2),G=ol*s**2,J=s*yp(T-k,-Math.PI,Math.PI),le=J*J,he=le*J,fe=he*J,ye=fe*J,we=ye*J,Ie=xp*(Av*a-J2*Math.sin(2*a)+Q2*Math.sin(4*a)-eI*Math.sin(6*a)),Pe=_p*O*(J+he/6*(1-v+G)+ye/120*(5-18*v+b+72*G-58*ol))+5e5,Ee=_p*(Ie+O*y*(le/2+fe/24*(5-v+9*G+4*G**2)+we/720*(61-58*v+b+600*G-330*ol)));return r.north||(Ee+=1e7),[Pe,Ee]}function Rv(h){return(h-1)*6-180+3}var cI=[/^EPSG:(\d+)$/,/^urn:ogc:def:crs:EPSG::(\d+)$/,/^http:\/\/www\.opengis\.net\/def\/crs\/EPSG\/0\/(\d+)$/];function kv(h){let e=0;for(let c of cI){let s=h.match(c);if(s){e=parseInt(s[1]);break}}if(!e)return null;let r=0,a=!1;return e>32700&&e<32761?r=e-32700:e>32600&&e<32661&&(a=!0,r=e-32600),r?{number:r,north:a}:null}function Tv(h,e){return function(r,a,c,s){let y=r.length;c=c>1?c:2,s=s??c,a||(c>2?a=r.slice():a=new Array(y));for(let v=0;v<y;v+=s){let b=r[v],T=r[v+1],C=h(b,T,e);a[v]=C[0],a[v+1]=C[1]}return a}}function Lv(h){return kv(h)?new xc({code:h,units:"m"}):null}function Dv(h){let e=kv(h.getCode());return e?{forward:Tv(lI,e),inverse:Tv(sI,e)}:null}var Fv={info:1,warn:2,error:3,none:4},hI=Fv.info;function zv(...h){hI>Fv.warn||console.warn(...h)}var uI=[Dv],dI=[Lv];var vg=!0;function wg(h){vg=!(h===void 0?!0:h)}function Sg(h,e){if(e!==void 0){for(let r=0,a=h.length;r<a;++r)e[r]=h[r];e=e}else e=h.slice();return e}function bg(h){gv(h.getCode(),h),wc(h,h,Sg)}function pI(h){h.forEach(bg)}function Ci(h){if(typeof h!="string")return h;let e=mv(h);if(e)return e;for(let r of dI){let a=r(h);if(a)return a}return null}function Ov(h){pI(h),h.forEach(function(e){h.forEach(function(r){e!==r&&wc(e,r,Sg)})})}function fI(h,e,r,a){h.forEach(function(c){e.forEach(function(s){wc(c,s,r),wc(s,c,a)})})}function wp(h,e){return h?typeof h=="string"?Ci(h):h:Ci(e)}function ar(h,e){return wg(),Sp(h,"EPSG:4326",e!==void 0?e:"EPSG:3857")}function al(h,e){let r=Sp(h,e!==void 0?e:"EPSG:3857","EPSG:4326"),a=r[0];return(a<-180||a>180)&&(r[0]=sl(a+180,360)-180),r}function Bv(h,e){if(h===e)return!0;let r=h.getUnits()===e.getUnits();return(h.getCode()===e.getCode()||Cc(h,e)===Sg)&&r}function Cc(h,e){let r=h.getCode(),a=e.getCode(),c=gp(r,a);if(c)return c;let s=null,y=null;for(let b of uI)s||(s=b(h)),y||(y=b(e));if(!s&&!y)return null;let v="EPSG:4326";if(y)if(s)c=xg(s.inverse,y.forward);else{let b=gp(r,v);b&&(c=xg(b,y.forward))}else{let b=gp(v,a);b&&(c=xg(s.inverse,b))}return c&&(bg(h),bg(e),wc(h,e,c)),c}function xg(h,e){return function(r,a,c,s){return a=h(r,a,c,s),e(a,a,c,s)}}function ll(h,e){let r=Ci(h),a=Ci(e);return Cc(r,a)}function Sp(h,e,r){let a=ll(e,r);if(!a){let c=Ci(e).getCode(),s=Ci(r).getCode();throw new Error(`No transform available between ${c} and ${s}`)}return a(h,void 0,h.length)}function Ig(h,e,r,a){let c=ll(e,r);return hv(h,c,void 0,a)}var Ss=null;function Zn(){return Ss}function ua(h,e){return Ss?Sp(h,e,Ss):h}function Ai(h,e){return Ss?Sp(h,Ss,e):(vg&&!Zi(h,[0,0])&&h[0]>=-180&&h[0]<=180&&h[1]>=-90&&h[1]<=90&&(vg=!1,zv("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),h)}function js(h,e){return Ss?Ig(h,e,Ss):h}function Gs(h,e){return Ss?Ig(h,Ss,e):h}function Nv(h,e){if(!Ss)return h;let r=Ci(e).getMetersPerUnit(),a=Ss.getMetersPerUnit();return r&&a?h*r/a:h}function mI(){Ov(dg),Ov(pg),fI(pg,dg,dv,pv)}mI();function vn(h,e,r,a,c,s,y){s=s||[],y=y||2;let v=0;for(let b=e;b<r;b+=a){let T=h[b],C=h[b+1];s[v++]=c[0]*T+c[2]*C+c[4],s[v++]=c[1]*T+c[3]*C+c[5];for(let k=2;k<y;k++)s[v++]=h[b+k]}return s&&s.length!=v&&(s.length=v),s}function Ip(h,e,r,a,c,s,y){y=y||[];let v=Math.cos(c),b=Math.sin(c),T=s[0],C=s[1],k=0;for(let O=e;O<r;O+=a){let G=h[O]-T,J=h[O+1]-C;y[k++]=T+G*v-J*b,y[k++]=C+G*b+J*v;for(let le=O+2;le<O+a;++le)y[k++]=h[le]}return y&&y.length!=k&&(y.length=k),y}function Vv(h,e,r,a,c,s,y,v){v=v||[];let b=y[0],T=y[1],C=0;for(let k=e;k<r;k+=a){let O=h[k]-b,G=h[k+1]-T;v[C++]=b+c*O,v[C++]=T+s*G;for(let J=k+2;J<k+a;++J)v[C++]=h[J]}return v&&v.length!=C&&(v.length=C),v}function jv(h,e,r,a,c,s,y){y=y||[];let v=0;for(let b=e;b<r;b+=a){y[v++]=h[b]+c,y[v++]=h[b+1]+s;for(let T=b+2;T<b+a;++T)y[v++]=h[T]}return y&&y.length!=v&&(y.length=v),y}var Gv=sr(),Cg=class extends or{constructor(){super(),this.extent_=xn(),this.extentRevision_=-1,this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=0,this.simplifyTransformedInternal=cp((e,r,a)=>{if(!a)return this.getSimplifiedGeometry(r);let c=this.clone();return c.applyTransform(a),c.getSimplifiedGeometry(r)})}simplifyTransformed(e,r){return this.simplifyTransformedInternal(this.getRevision(),e,r)}clone(){return wt()}closestPointXY(e,r,a,c){return wt()}containsXY(e,r){let a=this.getClosestPoint([e,r]);return a[0]===e&&a[1]===r}getClosestPoint(e,r){return r=r||[NaN,NaN],this.closestPointXY(e[0],e[1],r,1/0),r}intersectsCoordinate(e){return this.containsXY(e[0],e[1])}computeExtent(e){return wt()}getExtent(e){if(this.extentRevision_!=this.getRevision()){let r=this.computeExtent(this.extent_);(isNaN(r[0])||isNaN(r[1]))&&yc(r),this.extentRevision_=this.getRevision()}return lv(this.extent_,e)}rotate(e,r){wt()}scale(e,r,a){wt()}simplify(e){return this.getSimplifiedGeometry(e*e)}getSimplifiedGeometry(e){return wt()}getType(){return wt()}applyTransform(e){wt()}intersectsExtent(e){return wt()}translate(e,r){wt()}transform(e,r){let a=Ci(e),c=a.getUnits()=="tile-pixels"?function(s,y,v){let b=a.getExtent(),T=a.getWorldExtent(),C=Wi(T)/Wi(b);Vr(Gv,T[0],T[3],C,-C,0,0,0);let k=vn(s,0,s.length,v,Gv,y),O=ll(a,r);return O?O(k,k,v):k}:ll(a,r);return this.applyTransform(c),this}},Cp=Cg;var Eg=class extends Cp{constructor(){super(),this.layout="XY",this.stride=2,this.flatCoordinates}computeExtent(e){return _c(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinates(){return wt()}getFirstCoordinate(){return this.flatCoordinates.slice(0,this.stride)}getFlatCoordinates(){return this.flatCoordinates}getLastCoordinate(){return this.flatCoordinates.slice(this.flatCoordinates.length-this.stride)}getLayout(){return this.layout}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<=this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=this.getSimplifiedGeometryInternal(e);return r.getFlatCoordinates().length<this.flatCoordinates.length?r:(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getSimplifiedGeometryInternal(e){return this}getStride(){return this.stride}setFlatCoordinates(e,r){this.stride=Uv(e),this.layout=e,this.flatCoordinates=r}setCoordinates(e,r){wt()}setLayout(e,r,a){let c;if(e)c=Uv(e);else{for(let s=0;s<a;++s){if(r.length===0){this.layout="XY",this.stride=2;return}r=r[0]}c=r.length,e=da(c)}this.layout=e,this.stride=c}applyTransform(e){this.flatCoordinates&&(e(this.flatCoordinates,this.flatCoordinates,this.layout.startsWith("XYZ")?3:2,this.stride),this.changed())}rotate(e,r){let a=this.getFlatCoordinates();if(a){let c=this.getStride();Ip(a,0,a.length,c,e,r,a),this.changed()}}scale(e,r,a){r===void 0&&(r=e),a||(a=as(this.getExtent()));let c=this.getFlatCoordinates();if(c){let s=this.getStride();Vv(c,0,c.length,s,e,r,a,c),this.changed()}}translate(e,r){let a=this.getFlatCoordinates();if(a){let c=this.getStride();jv(a,0,a.length,c,e,r,a),this.changed()}}};function da(h){let e;return h==2?e="XY":h==3?e="XYZ":h==4&&(e="XYZM"),e}function Uv(h){let e;return h=="XY"?e=2:h=="XYZ"||h=="XYM"?e=3:h=="XYZM"&&(e=4),e}function qv(h,e,r){let a=h.getFlatCoordinates();if(!a)return null;let c=h.getStride();return vn(a,0,a.length,c,e,r)}var Cr=Eg;function $v(h,e,r,a){for(let c=0,s=r.length;c<s;++c)h[e++]=r[c];return e}function cl(h,e,r,a){for(let c=0,s=r.length;c<s;++c){let y=r[c];for(let v=0;v<a;++v)h[e++]=y[v]}return e}function pa(h,e,r,a,c){c=c||[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=cl(h,e,r[y],a);c[s++]=b,e=b}return c.length=s,c}function Ep(h,e,r,a,c){c=c||[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=pa(h,e,r[y],a,c[s]);b.length===0&&(b[0]=e),c[s++]=b,e=b[b.length-1]}return c.length=s,c}var Mg=class h extends Cp{constructor(e){super(),this.geometries_=e,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(jr),this.changeEventsKeys_.length=0}listenGeometriesChange_(){let e=this.geometries_;for(let r=0,a=e.length;r<a;++r)this.changeEventsKeys_.push(Sr(e[r],pi.CHANGE,this.changed,this))}clone(){let e=new h(Tg(this.geometries_));return e.applyProperties(this),e}closestPointXY(e,r,a,c){if(c<_n(this.getExtent(),e,r))return c;let s=this.geometries_;for(let y=0,v=s.length;y<v;++y)c=s[y].closestPointXY(e,r,a,c);return c}containsXY(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)if(a[c].containsXY(e,r))return!0;return!1}computeExtent(e){yc(e);let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)sv(e,r[a].getExtent());return e}getGeometries(){return Tg(this.geometries_)}getGeometriesArray(){return this.geometries_}getGeometriesArrayRecursive(){let e=[],r=this.geometries_;for(let a=0,c=r.length;a<c;++a)r[a].getType()===this.getType()?e=e.concat(r[a].getGeometriesArrayRecursive()):e.push(r[a]);return e}getSimplifiedGeometry(e){if(this.simplifiedGeometryRevision!==this.getRevision()&&(this.simplifiedGeometryMaxMinSquaredTolerance=0,this.simplifiedGeometryRevision=this.getRevision()),e<0||this.simplifiedGeometryMaxMinSquaredTolerance!==0&&e<this.simplifiedGeometryMaxMinSquaredTolerance)return this;let r=[],a=this.geometries_,c=!1;for(let s=0,y=a.length;s<y;++s){let v=a[s],b=v.getSimplifiedGeometry(e);r.push(b),b!==v&&(c=!0)}return c?new h(r):(this.simplifiedGeometryMaxMinSquaredTolerance=e,this)}getType(){return"GeometryCollection"}intersectsExtent(e){let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)if(r[a].intersectsExtent(e))return!0;return!1}isEmpty(){return this.geometries_.length===0}rotate(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)a[c].rotate(e,r);this.changed()}scale(e,r,a){a||(a=as(this.getExtent()));let c=this.geometries_;for(let s=0,y=c.length;s<y;++s)c[s].scale(e,r,a);this.changed()}setGeometries(e){this.setGeometriesArray(Tg(e))}setGeometriesArray(e){this.unlistenGeometriesChange_(),this.geometries_=e,this.listenGeometriesChange_(),this.changed()}applyTransform(e){let r=this.geometries_;for(let a=0,c=r.length;a<c;++a)r[a].applyTransform(e);this.changed()}translate(e,r){let a=this.geometries_;for(let c=0,s=a.length;c<s;++c)a[c].translate(e,r);this.changed()}disposeInternal(){this.unlistenGeometriesChange_(),super.disposeInternal()}};function Tg(h){return h.map(e=>e.clone())}var Pg=Mg;function Wv(h,e,r,a,c,s,y){let v=h[e],b=h[e+1],T=h[r]-v,C=h[r+1]-b,k;if(T===0&&C===0)k=e;else{let O=((c-v)*T+(s-b)*C)/(T*T+C*C);if(O>1)k=r;else if(O>0){for(let G=0;G<a;++G)y[G]=Ir(h[e+G],h[r+G],O);y.length=a;return}else k=e}for(let O=0;O<a;++O)y[O]=h[k+O];y.length=a}function cu(h,e,r,a,c){let s=h[e],y=h[e+1];for(e+=a;e<r;e+=a){let v=h[e],b=h[e+1],T=ws(s,y,v,b);T>c&&(c=T),s=v,y=b}return c}function hu(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];c=cu(h,e,v,a,c),e=v}return c}function Zv(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];c=hu(h,e,v,a,c),e=v[v.length-1]}return c}function uu(h,e,r,a,c,s,y,v,b,T,C){if(e==r)return T;let k,O;if(c===0){if(O=ws(y,v,h[e],h[e+1]),O<T){for(k=0;k<a;++k)b[k]=h[e+k];return b.length=a,O}return T}C=C||[NaN,NaN];let G=e+a;for(;G<r;)if(Wv(h,G-a,G,a,y,v,C),O=ws(y,v,C[0],C[1]),O<T){for(T=O,k=0;k<a;++k)b[k]=C[k];b.length=a,G+=a}else G+=a*Math.max((Math.sqrt(O)-Math.sqrt(T))/c|0,1);if(s&&(Wv(h,r-a,e,a,y,v,C),O=ws(y,v,C[0],C[1]),O<T)){for(T=O,k=0;k<a;++k)b[k]=C[k];b.length=a}return T}function du(h,e,r,a,c,s,y,v,b,T,C){C=C||[NaN,NaN];for(let k=0,O=r.length;k<O;++k){let G=r[k];T=uu(h,e,G,a,c,s,y,v,b,T,C),e=G}return T}function Xv(h,e,r,a,c,s,y,v,b,T,C){C=C||[NaN,NaN];for(let k=0,O=r.length;k<O;++k){let G=r[k];T=du(h,e,G,a,c,s,y,v,b,T,C),e=G[G.length-1]}return T}function hl(h,e,r,a,c,s,y){let v=(r-e)/a;if(v<3){for(;e<r;e+=a)s[y++]=h[e],s[y++]=h[e+1];return y}let b=new Array(v);b[0]=1,b[v-1]=1;let T=[e,r-a],C=0;for(;T.length>0;){let k=T.pop(),O=T.pop(),G=0,J=h[O],le=h[O+1],he=h[k],fe=h[k+1];for(let ye=O+a;ye<k;ye+=a){let we=h[ye],Ie=h[ye+1],Pe=yv(we,Ie,J,le,he,fe);Pe>G&&(C=ye,G=Pe)}G>c&&(b[(C-e)/a]=1,O+a<C&&T.push(O,C),C+a<k&&T.push(C,k))}for(let k=0;k<v;++k)b[k]&&(s[y++]=h[e+k*a],s[y++]=h[e+k*a+1]);return y}function Tp(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b];y=hl(h,e,C,a,c,s,y),v.push(y),e=C}return y}function fa(h,e){return e*Math.round(h/e)}function gI(h,e,r,a,c,s,y){if(e==r)return y;let v=fa(h[e],c),b=fa(h[e+1],c);e+=a,s[y++]=v,s[y++]=b;let T,C;do if(T=fa(h[e],c),C=fa(h[e+1],c),e+=a,e==r)return s[y++]=T,s[y++]=C,y;while(T==v&&C==b);for(;e<r;){let k=fa(h[e],c),O=fa(h[e+1],c);if(e+=a,k==T&&O==C)continue;let G=T-v,J=C-b,le=k-v,he=O-b;if(G*he==J*le&&(G<0&&le<G||G==le||G>0&&le>G)&&(J<0&&he<J||J==he||J>0&&he>J)){T=k,C=O;continue}s[y++]=T,s[y++]=C,v=T,b=C,T=k,C=O}return s[y++]=T,s[y++]=C,y}function pu(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b];y=gI(h,e,C,a,c,s,y),v.push(y),e=C}return y}function Hv(h,e,r,a,c,s,y,v){for(let b=0,T=r.length;b<T;++b){let C=r[b],k=[];y=pu(h,e,C,a,c,s,y,k),v.push(k),e=C[C.length-1]}return y}function cs(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=e;y<r;y+=a)c[s++]=h.slice(y,y+a);return c.length=s,c}function ma(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y];c[s++]=cs(h,e,b,a,c[s]),e=b}return c.length=s,c}function fu(h,e,r,a,c){c=c!==void 0?c:[];let s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y];c[s++]=b.length===1&&b[0]===e?[]:ma(h,e,b,a,c[s]),e=b[b.length-1]}return c.length=s,c}function Ag(h,e,r,a){let c=0,s=h[r-a],y=h[r-a+1],v=0,b=0;for(;e<r;e+=a){let T=h[e]-s,C=h[e+1]-y;c+=b*T-v*C,v=T,b=C}return c/2}function Rg(h,e,r,a){let c=0;for(let s=0,y=r.length;s<y;++s){let v=r[s];c+=Ag(h,e,v,a),e=v}return c}function Kv(h,e,r,a){let c=0;for(let s=0,y=r.length;s<y;++s){let v=r[s];c+=Rg(h,e,v,a),e=v[v.length-1]}return c}var kg=class h extends Cr{constructor(e,r){super(),this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}clone(){return new h(this.flatCoordinates.slice(),this.layout)}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),uu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!0,e,r,a,c))}getArea(){return Ag(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getSimplifiedGeometryInternal(e){let r=[];return r.length=hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LinearRing"}intersectsExtent(e){return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},Lg=kg;function Mp(h,e,r,a,c){let s;for(e+=a;e<r;e+=a)if(s=c(h.slice(e-a,e),h.slice(e,e+a)),s)return s;return!1}function ul(h,e,r,a,c,s,y){let v,b,T=(r-e)/a;if(T===1)v=e;else if(T===2)v=e,b=c;else if(T!==0){let C=h[e],k=h[e+1],O=0,G=[0];for(let he=e+a;he<r;he+=a){let fe=h[he],ye=h[he+1];O+=Math.sqrt((fe-C)*(fe-C)+(ye-k)*(ye-k)),G.push(O),C=fe,k=ye}let J=c*O,le=tv(G,J);le<0?(b=(J-G[-le-2])/(G[-le-1]-G[-le-2]),v=e+(-le-2)*a):v=e+le*a}y=y>1?y:2,s=s||new Array(y);for(let C=0;C<y;++C)s[C]=v===void 0?NaN:b===void 0?h[v+C]:Ir(h[v+C],h[v+a+C],b);return s}function Pp(h,e,r,a,c,s){if(r==e)return null;let y;if(c<h[e+a-1])return s?(y=h.slice(e,e+a),y[a-1]=c,y):null;if(h[r-1]<c)return s?(y=h.slice(r-a,r),y[a-1]=c,y):null;if(c==h[e+a-1])return h.slice(e,e+a);let v=e/a,b=r/a;for(;v<b;){let O=v+b>>1;c<h[(O+1)*a-1]?b=O:v=O+1}let T=h[v*a-1];if(c==T)return h.slice((v-1)*a,(v-1)*a+a);let C=h[(v+1)*a-1],k=(c-T)/(C-T);y=[];for(let O=0;O<a-1;++O)y.push(Ir(h[(v-1)*a+O],h[v*a+O],k));return y.push(c),y}function Yv(h,e,r,a,c,s,y){if(y)return Pp(h,e,r[r.length-1],a,c,s);let v;if(c<h[a-1])return s?(v=h.slice(0,a),v[a-1]=c,v):null;if(h[h.length-1]<c)return s?(v=h.slice(h.length-a),v[a-1]=c,v):null;for(let b=0,T=r.length;b<T;++b){let C=r[b];if(e!=C){if(c<h[e+a-1])return null;if(c<=h[C-1])return Pp(h,e,C,a,c,!1);e=C}}return null}function Jv(h,e,r,a,c){return!ov(c,function(y){return!ga(h,e,r,a,y[0],y[1])})}function ga(h,e,r,a,c,s){let y=0,v=h[r-a],b=h[r-a+1];for(;e<r;e+=a){let T=h[e],C=h[e+1];b<=s?C>s&&(T-v)*(s-b)-(c-v)*(C-b)>0&&y++:C<=s&&(T-v)*(s-b)-(c-v)*(C-b)<0&&y--,v=T,b=C}return y!==0}function mu(h,e,r,a,c,s){if(r.length===0||!ga(h,e,r[0],a,c,s))return!1;for(let y=1,v=r.length;y<v;++y)if(ga(h,r[y-1],r[y],a,c,s))return!1;return!0}function Qv(h,e,r,a,c,s){if(r.length===0)return!1;for(let y=0,v=r.length;y<v;++y){let b=r[y];if(mu(h,e,b,a,c,s))return!0;e=b[b.length-1]}return!1}function gu(h,e,r,a,c){let s=sg(xn(),h,e,r,a);return Vi(c,s)?go(c,s)||s[0]>=c[0]&&s[2]<=c[2]||s[1]>=c[1]&&s[3]<=c[3]?!0:Mp(h,e,r,a,function(y,v){return cv(c,y,v)}):!1}function eb(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){if(gu(h,e,r[s],a,c))return!0;e=r[s]}return!1}function yI(h,e,r,a,c){return!!(gu(h,e,r,a,c)||ga(h,e,r,a,c[0],c[1])||ga(h,e,r,a,c[0],c[3])||ga(h,e,r,a,c[2],c[1])||ga(h,e,r,a,c[2],c[3]))}function Dg(h,e,r,a,c){if(!yI(h,e,r[0],a,c))return!1;if(r.length===1)return!0;for(let s=1,y=r.length;s<y;++s)if(Jv(h,r[s-1],r[s],a,c)&&!gu(h,r[s-1],r[s],a,c))return!1;return!0}function tb(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];if(Dg(h,e,v,a,c))return!0;e=v[v.length-1]}return!1}function Ap(h,e,r,a){let c=h[e],s=h[e+1],y=0;for(let v=e+a;v<r;v+=a){let b=h[v],T=h[v+1];y+=Math.sqrt((b-c)*(b-c)+(T-s)*(T-s)),c=b,s=T}return y}var Fg=class h extends Cr{constructor(e,r){super(),this.flatMidpoint_=null,this.flatMidpointRevision_=-1,this.maxDelta_=-1,this.maxDeltaRevision_=-1,r!==void 0&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendCoordinate(e){wr(this.flatCoordinates,e),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(cu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),uu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,this.maxDelta_,!1,e,r,a,c))}forEachSegment(e){return Mp(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}getCoordinateAtM(e,r){return this.layout!="XYM"&&this.layout!="XYZM"?null:(r=r!==void 0?r:!1,Pp(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r))}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getCoordinateAt(e,r){return ul(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,this.stride)}getLength(){return Ap(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getFlatMidpoint(){return this.flatMidpointRevision_!=this.getRevision()&&(this.flatMidpoint_=this.getCoordinateAt(.5,this.flatMidpoint_??void 0),this.flatMidpointRevision_=this.getRevision()),this.flatMidpoint_}getSimplifiedGeometryInternal(e){let r=[];return r.length=hl(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e,r,0),new h(r,"XY")}getType(){return"LineString"}intersectsExtent(e){return gu(this.flatCoordinates,0,this.flatCoordinates.length,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},Is=Fg;var zg=class h extends Cr{constructor(e,r,a){if(super(),this.ends_=[],this.maxDelta_=-1,this.maxDeltaRevision_=-1,Array.isArray(e[0]))this.setCoordinates(e,r);else if(r!==void 0&&a)this.setFlatCoordinates(r,e),this.ends_=a;else{let c=e,s=[],y=[];for(let b=0,T=c.length;b<T;++b){let C=c[b];wr(s,C.getFlatCoordinates()),y.push(s.length)}let v=c.length===0?this.getLayout():c[0].getLayout();this.setFlatCoordinates(v,s),this.ends_=y}}appendLineString(e){wr(this.flatCoordinates,e.getFlatCoordinates().slice()),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),du(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!1,e,r,a,c))}getCoordinateAtM(e,r,a){return this.layout!="XYM"&&this.layout!="XYZM"||this.flatCoordinates.length===0?null:(r=r!==void 0?r:!1,a=a!==void 0?a:!1,Yv(this.flatCoordinates,0,this.ends_,this.stride,e,r,a))}getCoordinates(){return ma(this.flatCoordinates,0,this.ends_,this.stride)}getEnds(){return this.ends_}getLineString(e){return e<0||this.ends_.length<=e?null:new Is(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLineStrings(){let e=this.flatCoordinates,r=this.ends_,a=this.layout,c=[],s=0;for(let y=0,v=r.length;y<v;++y){let b=r[y],T=new Is(e.slice(s,b),a);c.push(T),s=b}return c}getFlatMidpoints(){let e=[],r=this.flatCoordinates,a=0,c=this.ends_,s=this.stride;for(let y=0,v=c.length;y<v;++y){let b=c[y],T=ul(r,a,b,s,.5);wr(e,T),a=b}return e}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=Tp(this.flatCoordinates,0,this.ends_,this.stride,e,r,0,a),new h(r,"XY",a)}getType(){return"MultiLineString"}intersectsExtent(e){return eb(this.flatCoordinates,0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let a=pa(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=a.length===0?0:a[a.length-1],this.changed()}},Og=zg;var Bg=class h extends Cr{constructor(e,r){super(),this.setCoordinates(e,r)}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){let s=this.flatCoordinates,y=ws(e,r,s[0],s[1]);if(y<c){let v=this.stride;for(let b=0;b<v;++b)a[b]=s[b];return a.length=v,y}return c}getCoordinates(){return this.flatCoordinates.slice()}computeExtent(e){return ca(this.flatCoordinates,e)}getType(){return"Point"}intersectsExtent(e){return nu(e,this.flatCoordinates[0],this.flatCoordinates[1])}setCoordinates(e,r){this.setLayout(r,e,0),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=$v(this.flatCoordinates,0,e,this.stride),this.changed()}},lr=Bg;var Ng=class h extends Cr{constructor(e,r){super(),r&&!Array.isArray(e[0])?this.setFlatCoordinates(r,e):this.setCoordinates(e,r)}appendPoint(e){wr(this.flatCoordinates,e.getFlatCoordinates()),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout);return e.applyProperties(this),e}closestPointXY(e,r,a,c){if(c<_n(this.getExtent(),e,r))return c;let s=this.flatCoordinates,y=this.stride;for(let v=0,b=s.length;v<b;v+=y){let T=ws(e,r,s[v],s[v+1]);if(T<c){c=T;for(let C=0;C<y;++C)a[C]=s[v+C];a.length=y}}return c}getCoordinates(){return cs(this.flatCoordinates,0,this.flatCoordinates.length,this.stride)}getPoint(e){let r=this.flatCoordinates.length/this.stride;return e<0||r<=e?null:new lr(this.flatCoordinates.slice(e*this.stride,(e+1)*this.stride),this.layout)}getPoints(){let e=this.flatCoordinates,r=this.layout,a=this.stride,c=[];for(let s=0,y=e.length;s<y;s+=a){let v=new lr(e.slice(s,s+a),r);c.push(v)}return c}getType(){return"MultiPoint"}intersectsExtent(e){let r=this.flatCoordinates,a=this.stride;for(let c=0,s=r.length;c<s;c+=a){let y=r[c],v=r[c+1];if(nu(e,y,v))return!0}return!1}setCoordinates(e,r){this.setLayout(r,e,1),this.flatCoordinates||(this.flatCoordinates=[]),this.flatCoordinates.length=cl(this.flatCoordinates,0,e,this.stride),this.changed()}},yu=Ng;function _u(h,e,r,a,c,s,y){let v,b,T,C,k,O,G,J=c[s+1],le=[];for(let ye=0,we=r.length;ye<we;++ye){let Ie=r[ye];for(C=h[Ie-a],O=h[Ie-a+1],v=e;v<Ie;v+=a)k=h[v],G=h[v+1],(J<=O&&G<=J||O<=J&&J<=G)&&(T=(J-O)/(G-O)*(k-C)+C,le.push(T)),C=k,O=G}let he=NaN,fe=-1/0;for(le.sort(xs),C=le[0],v=1,b=le.length;v<b;++v){k=le[v];let ye=Math.abs(k-C);ye>fe&&(T=(C+k)/2,mu(h,e,r,a,T,J)&&(he=T,fe=ye)),C=k}return isNaN(he)&&(he=c[s]),y?(y.push(he,J,fe),y):[he,J,fe]}function Rp(h,e,r,a,c){let s=[];for(let y=0,v=r.length;y<v;++y){let b=r[y];s=_u(h,e,b,a,c,2*y,s),e=b[b.length-1]}return s}function ib(h,e,r,a){for(;e<r-a;){for(let c=0;c<a;++c){let s=h[e+c];h[e+c]=h[r-a+c],h[r-a+c]=s}e+=a,r-=a}}function Vg(h,e,r,a){let c=0,s=h[r-a],y=h[r-a+1];for(;e<r;e+=a){let v=h[e],b=h[e+1];c+=(v-s)*(b+y),s=v,y=b}return c===0?void 0:c>0}function xu(h,e,r,a,c){c=c!==void 0?c:!1;for(let s=0,y=r.length;s<y;++s){let v=r[s],b=Vg(h,e,v,a);if(s===0){if(c&&b||!c&&!b)return!1}else if(c&&!b||!c&&b)return!1;e=v}return!0}function kp(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s){let v=r[s];if(!xu(h,e,v,a,c))return!1;v.length&&(e=v[v.length-1])}return!0}function Ec(h,e,r,a,c){c=c!==void 0?c:!1;for(let s=0,y=r.length;s<y;++s){let v=r[s],b=Vg(h,e,v,a);(s===0?c&&b||!c&&!b:c&&!b||!c&&b)&&ib(h,e,v,a),e=v}return e}function vu(h,e,r,a,c){for(let s=0,y=r.length;s<y;++s)e=Ec(h,e,r[s],a,c);return e}function rb(h,e){let r=[],a=0,c=0,s;for(let y=0,v=e.length;y<v;++y){let b=e[y],T=Vg(h,a,b,2);if(s===void 0&&(s=T),T===s)r.push(e.slice(c,y+1));else{if(r.length===0)continue;r[r.length-1].push(e[c])}c=y+1,a=b}return r}var bu=class h extends Cr{constructor(e,r,a){super(),this.ends_=[],this.flatInteriorPointRevision_=-1,this.flatInteriorPoint_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,r!==void 0&&a?(this.setFlatCoordinates(r,e),this.ends_=a):this.setCoordinates(e,r)}appendLinearRing(e){this.flatCoordinates?wr(this.flatCoordinates,e.getFlatCoordinates()):this.flatCoordinates=e.getFlatCoordinates().slice(),this.ends_.push(this.flatCoordinates.length),this.changed()}clone(){let e=new h(this.flatCoordinates.slice(),this.layout,this.ends_.slice());return e.applyProperties(this),e}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(hu(this.flatCoordinates,0,this.ends_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),du(this.flatCoordinates,0,this.ends_,this.stride,this.maxDelta_,!0,e,r,a,c))}containsXY(e,r){return mu(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,r)}getArea(){return Rg(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),Ec(r,0,this.ends_,this.stride,e)):r=this.flatCoordinates,ma(r,0,this.ends_,this.stride)}getEnds(){return this.ends_}getFlatInteriorPoint(){if(this.flatInteriorPointRevision_!=this.getRevision()){let e=as(this.getExtent());this.flatInteriorPoint_=_u(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e,0),this.flatInteriorPointRevision_=this.getRevision()}return this.flatInteriorPoint_}getInteriorPoint(){return new lr(this.getFlatInteriorPoint(),"XYM")}getLinearRingCount(){return this.ends_.length}getLinearRing(e){return e<0||this.ends_.length<=e?null:new Lg(this.flatCoordinates.slice(e===0?0:this.ends_[e-1],this.ends_[e]),this.layout)}getLinearRings(){let e=this.layout,r=this.flatCoordinates,a=this.ends_,c=[],s=0;for(let y=0,v=a.length;y<v;++y){let b=a[y],T=new Lg(r.slice(s,b),e);c.push(T),s=b}return c}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;xu(e,0,this.ends_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=Ec(this.orientedFlatCoordinates_,0,this.ends_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=pu(this.flatCoordinates,0,this.ends_,this.stride,Math.sqrt(e),r,0,a),new h(r,"XY",a)}getType(){return"Polygon"}intersectsExtent(e){return Dg(this.getOrientedFlatCoordinates(),0,this.ends_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,2),this.flatCoordinates||(this.flatCoordinates=[]);let a=pa(this.flatCoordinates,0,e,this.stride,this.ends_);this.flatCoordinates.length=a.length===0?0:a[a.length-1],this.changed()}},Tc=bu;function jg(h){if(su(h))throw new Error("Cannot create polygon from empty extent");let e=h[0],r=h[1],a=h[2],c=h[3],s=[e,r,e,c,a,c,a,r,e,r];return new bu(s,"XY",[s.length])}function Gg(h,e,r){e=e||32;let a=h.getStride(),c=h.getLayout(),s=h.getCenter(),y=a*(e+1),v=new Array(y);for(let C=0;C<y;C+=a){v[C]=0,v[C+1]=0;for(let k=2;k<a;k++)v[C+k]=s[k]}let b=[v.length],T=new bu(v,c,b);return _I(T,s,h.getRadius(),r),T}function _I(h,e,r,a){let c=h.getFlatCoordinates(),s=h.getStride(),y=c.length/s-1,v=a||0;for(let b=0;b<=y;++b){let T=b*s,C=v+sl(b,y)*2*Math.PI/y;c[T]=e[0]+r*Math.cos(C),c[T+1]=e[1]+r*Math.sin(C)}h.changed()}function Lp(h,e,r,a){let c=[],s=xn();for(let y=0,v=r.length;y<v;++y){let b=r[y];s=_c(h,e,b[0],a),c.push((s[0]+s[2])/2,(s[1]+s[3])/2),e=b[b.length-1]}return c}var Ug=class h extends Cr{constructor(e,r,a){if(super(),this.endss_=[],this.flatInteriorPointsRevision_=-1,this.flatInteriorPoints_=null,this.maxDelta_=-1,this.maxDeltaRevision_=-1,this.orientedRevision_=-1,this.orientedFlatCoordinates_=null,!a&&!Array.isArray(e[0])){let c=e,s=[],y=[];for(let v=0,b=c.length;v<b;++v){let T=c[v],C=s.length,k=T.getEnds();for(let O=0,G=k.length;O<G;++O)k[O]+=C;wr(s,T.getFlatCoordinates()),y.push(k)}r=c.length===0?this.getLayout():c[0].getLayout(),e=s,a=y}r!==void 0&&a?(this.setFlatCoordinates(r,e),this.endss_=a):this.setCoordinates(e,r)}appendPolygon(e){let r;if(!this.flatCoordinates)this.flatCoordinates=e.getFlatCoordinates().slice(),r=e.getEnds().slice(),this.endss_.push();else{let a=this.flatCoordinates.length;wr(this.flatCoordinates,e.getFlatCoordinates()),r=e.getEnds().slice();for(let c=0,s=r.length;c<s;++c)r[c]+=a}this.endss_.push(r),this.changed()}clone(){let e=this.endss_.length,r=new Array(e);for(let c=0;c<e;++c)r[c]=this.endss_[c].slice();let a=new h(this.flatCoordinates.slice(),this.layout,r);return a.applyProperties(this),a}closestPointXY(e,r,a,c){return c<_n(this.getExtent(),e,r)?c:(this.maxDeltaRevision_!=this.getRevision()&&(this.maxDelta_=Math.sqrt(Zv(this.flatCoordinates,0,this.endss_,this.stride,0)),this.maxDeltaRevision_=this.getRevision()),Xv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,this.maxDelta_,!0,e,r,a,c))}containsXY(e,r){return Qv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e,r)}getArea(){return Kv(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride)}getCoordinates(e){let r;return e!==void 0?(r=this.getOrientedFlatCoordinates().slice(),vu(r,0,this.endss_,this.stride,e)):r=this.flatCoordinates,fu(r,0,this.endss_,this.stride)}getEndss(){return this.endss_}getFlatInteriorPoints(){if(this.flatInteriorPointsRevision_!=this.getRevision()){let e=Lp(this.flatCoordinates,0,this.endss_,this.stride);this.flatInteriorPoints_=Rp(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e),this.flatInteriorPointsRevision_=this.getRevision()}return this.flatInteriorPoints_}getInteriorPoints(){return new yu(this.getFlatInteriorPoints().slice(),"XYM")}getOrientedFlatCoordinates(){if(this.orientedRevision_!=this.getRevision()){let e=this.flatCoordinates;kp(e,0,this.endss_,this.stride)?this.orientedFlatCoordinates_=e:(this.orientedFlatCoordinates_=e.slice(),this.orientedFlatCoordinates_.length=vu(this.orientedFlatCoordinates_,0,this.endss_,this.stride)),this.orientedRevision_=this.getRevision()}return this.orientedFlatCoordinates_}getSimplifiedGeometryInternal(e){let r=[],a=[];return r.length=Hv(this.flatCoordinates,0,this.endss_,this.stride,Math.sqrt(e),r,0,a),new h(r,"XY",a)}getPolygon(e){if(e<0||this.endss_.length<=e)return null;let r;if(e===0)r=0;else{let s=this.endss_[e-1];r=s[s.length-1]}let a=this.endss_[e].slice(),c=a[a.length-1];if(r!==0)for(let s=0,y=a.length;s<y;++s)a[s]-=r;return new Tc(this.flatCoordinates.slice(r,c),this.layout,a)}getPolygons(){let e=this.layout,r=this.flatCoordinates,a=this.endss_,c=[],s=0;for(let y=0,v=a.length;y<v;++y){let b=a[y].slice(),T=b[b.length-1];if(s!==0)for(let k=0,O=b.length;k<O;++k)b[k]-=s;let C=new Tc(r.slice(s,T),e,b);c.push(C),s=T}return c}getType(){return"MultiPolygon"}intersectsExtent(e){return tb(this.getOrientedFlatCoordinates(),0,this.endss_,this.stride,e)}setCoordinates(e,r){this.setLayout(r,e,3),this.flatCoordinates||(this.flatCoordinates=[]);let a=Ep(this.flatCoordinates,0,e,this.stride,this.endss_);if(a.length===0)this.flatCoordinates.length=0;else{let c=a[a.length-1];this.flatCoordinates.length=c.length===0?0:c[c.length-1]}this.changed()}},qg=Ug;var xI=(h,e,r)=>{let{coordinate:a,olGeometry:c,time_intervals:s}=e.properties,{coordinates:y,type:v}=e.geometry,b=c,T,C;if(c&&(v=b.getType(),y=b.getCoordinates()),r&&a)T=a;else if(v==="Point")T=y;else if(v==="LineString"){b||(b=new Is(y));let k=s||[[]],O=k[0],G=k[k.length-1];if(h<O[0])[,,C]=O,T=b.getFirstCoordinate();else if(h>G[0])[,,C]=G,T=b.getLastCoordinate();else for(let J=0;J<k.length-1;J+=1){let[le,he]=k[J],[fe,ye]=k[J+1];if(le<=h&&h<=fe){let Ie=Math.min((h-le)/(fe-le),1)*(ye-he)+he;T=b.getCoordinateAt(Ie),[,,C]=k[J];break}}}else console.error("This geometry type is not supported. Only Point or LineString are. Current geometry: ",b);return{coord:T,rotation:C}},wu=xI;var vI=(h,e,r,a,c)=>{if(!h)return{renderedTrajectories:[]};let{center:s,pixelRatio:y=1,resolution:v,rotation:b=0,size:T=[],time:C=Date.now()}=a;if(!v||!s)return{renderedTrajectories:[]};let{filter:k,getScreenPixel:O=(Ae,st)=>(st.zoom||0)<12?Ae.map(ct=>Math.floor(ct)):Ae,hoverVehicleId:G,noInterpolate:J=!1,selectedVehicleId:le}=c,he=h.getContext("2d");he?.clearRect(0,0,h.width,h.height);let[fe,ye]=T;fe&&ye&&(h.width!==fe*y||h.height!==ye*y)&&([h.width,h.height]=[fe*y,ye*y]);let we=Vr(sr(),T[0]/2,T[1]/2,1/v,-1/v,-b,-s[0],-s[1]);h.style&&(h.style.width=`${h.width/y}px`,h.style.height=`${h.height/y}px`);let Ie,Pe,Ee,Ge,Be=[];for(let Ae=e.length-1;Ae>=0;Ae-=1){let st=e[Ae];if(k&&!k(st))continue;let{timeOffset:ct,train_id:rt}=st.properties,{coord:xt,rotation:Rt}=wu(C-(ct||0),st,J);if(e[Ae].properties.coordinate=xt,e[Ae].properties.rotation=Rt,!xt)continue;let at=br(we,[...xt]);if(!at||(at=at.map(ot=>ot*y),at[0]<0||at[0]>h.width||at[1]<0||at[1]>h.height))continue;let gt=r(st,a,c);if(gt){if(G!==rt&&le!==rt){let[ot,pt]=O([at[0]-gt.width/2,at[1]-gt.height/2],a);he?.drawImage(gt,ot,pt)}G&&G===rt&&(Ie=gt,Pe=at),le&&le===rt&&(Ee=gt,Ge=at),Be.push(st)}}return Ee&&Ge&&he?.drawImage(Ee,Math.floor(Ge[0]-Ee.width/2),Math.floor(Ge[1]-Ee.height/2)),Ie&&Pe&&he?.drawImage(Ie,Math.floor(Pe[0]-Ie.width/2),Math.floor(Pe[1]-Ie.height/2)),{renderedTrajectories:Be}},Su=vI;var bI=(h,e,r=!1)=>{let a=["HIDDEN","LEAVING","BOARDING"],c=h.has_fzo&&a.indexOf(h.state)>-1,s=e.has_fzo&&a.indexOf(e.state)>-1;if(c||s){if(c!==s)return c?-1:1;if(h.state!==e.state)return a.indexOf(h.state)-a.indexOf(e.state)}let y=null,v=null,b=Date.now();return r?(y=new Date(h.min_arrival_time||h.time).getTime()-b,v=new Date(e.min_arrival_time||e.time).getTime()-b):(y=new Date(h.time).getTime()-b,v=new Date(e.time).getTime()-b),y-v},Iu=bI;var wI=(h,e=!1,r=30)=>{let a=Object.keys(h).map(k=>h[k]);a.sort((k,O)=>Iu(k,O,e));let c=new Date;c.setMinutes(c.getMinutes()+r);let s=c.getTime(),y=new Date;y.setMinutes(y.getMinutes()-r);let v=y.getTime(),b=[],T=[],C=null;for(let k=a.length-1;k>=0;k-=1){let O={...a[k]},G=new Date(O.time).getTime();G>v&&G<s&&(O.state==="BOARDING"&&(T.includes(O.platform)?O.state="HIDDEN":T.push(O.platform)),C&&O.to[0]===C.to[0]&&Math.abs(G-C.time)<1e3&&O.line.name===C.line.name&&(O.state="HIDDEN"),/(STOP_CANCELLED|JOURNEY_CANCELLED)/.test(O.state)&&(O.cancelled=!0),C=O,C.time=G,b.unshift(O))}return b},Cu=wI;var SI=(h,e=!1,r=30,a=100)=>{let c={},s={};return y=>{let{source:v,content:b}=y;c[v]&&window.clearTimeout(c[v]),b&&(s[b.call_id]=b,c[v]=window.setTimeout(()=>{let T=Cu(s,e||!1,r);h(T)},a))}},$g=SI;var Mc={};Lm(Mc,{MOTS_ALL:()=>EI,MOTS_ONLY_RAIL:()=>Cs,MOTS_WITHOUT_CABLE:()=>Dp,MOTS_WITH_CABLE:()=>CI,bgColors:()=>sb,getBgColor:()=>MI,getDelayColor:()=>RI,getDelayText:()=>kI,getRadius:()=>TI,getTextColor:()=>PI,getTextSize:()=>AI,getTypeIndex:()=>Fp,textColors:()=>ob,types:()=>nb});var II=[[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,7,7,7,7,7,7,7,7,7,7,7,7],[0,0,0,0,0,2,2,3,7,7,7,12,15,15,15,15,15]],Cs=["rail"],CI=["cablecar","gondola","funicular","coach"],Dp=["tram","subway","rail","bus"],EI=["tram","subway","rail","bus","ferry","cablecar","gondola","funicular","coach"],nb=[/^Tram/i,/^Subway( \/ Metro \/ S-Bahn)?/i,/^Train/i,/^Bus/i,/^Ferry/i,/^Cable ?Car/i,/^Gondola/i,/^Funicular/i,/^(Long distance bus|coach)/i,/^Rail/i],sb=["#ffb400","#ff5400","#ff8080","#ea0000","#3000ff","#ffb400","#41a27b","#00d237","#b5b5b5","#ff8080"],ob=["#000000","#ffffff","#000000","#ffffff","#ffffff","#000000","#ffffff","#000000","#000000","#000000"],Fp=h=>typeof h=="string"?nb.findIndex(e=>e.test(h)):h,TI=(h,e)=>{try{let r=Fp(h||0);return II[r][e]}catch{return 1}},MI=h=>{try{let e=Fp(h);return sb[e]}catch{return"#ffffff"}},PI=h=>{try{let e=Fp(h);return ob[e]}catch{return"#ffffff"}},AI=(h,e,r,a,c)=>{if(!h)return 0;h.font=c(a,r);let s=h.measureText(r),y=25,v=0;for(;s.width>e-6&&v<y;)a-=.5,h.font=c(a,r),s=h.measureText(r),v+=1;return a},RI=(h,e,r)=>e?r?"#ff0000":"#a0a0a0":h===null?"#a0a0a0":h>=36e5?"#ed004c":h>=5e5?"#e80000":h>=3e5?"#ff4a00":h>=18e4?"#f7bf00":"#00a00c",kI=(h,e)=>e?String.fromCodePoint(215):h>=36e5?`+${Math.round(h/36e5)}h`:h>=6e4?`+${Math.round(h/6e4)}m`:h>=1e3?`+${Math.round(h/1e3)}s`:h>0?`+${h}ms`:"";var Pc="vectorTileFeature";var ab={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"};var Wg=class extends or{constructor(e){super();let r=e.element;r&&!e.target&&!r.style.pointerEvents&&(r.style.pointerEvents="auto"),this.element=r||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){this.element?.remove(),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&this.element?.remove();for(let r=0,a=this.listenerKeys.length;r<a;++r)jr(this.listenerKeys[r]);if(this.listenerKeys.length=0,this.map_=e,e){let r=this.target_??e.getOverlayContainerStopEvent();this.element&&r.appendChild(this.element),this.render!==vs&&this.listenerKeys.push(Sr(e,ab.POSTRENDER,this.render,this)),e.render()}}render(e){}setTarget(e){this.target_=typeof e=="string"?document.getElementById(e):e}},Ac=Wg;var Qt={OPACITY:"opacity",VISIBLE:"visible",EXTENT:"extent",Z_INDEX:"zIndex",MAX_RESOLUTION:"maxResolution",MIN_RESOLUTION:"minResolution",MAX_ZOOM:"maxZoom",MIN_ZOOM:"minZoom",SOURCE:"source",MAP:"map"};var Zg=class extends or{constructor(e){super(),this.on,this.once,this.un,this.background_=e.background;let r=Object.assign({},e);typeof e.properties=="object"&&(delete r.properties,Object.assign(r,e.properties)),r[Qt.OPACITY]=e.opacity!==void 0?e.opacity:1,ui(typeof r[Qt.OPACITY]=="number","Layer opacity must be a number"),r[Qt.VISIBLE]=e.visible!==void 0?e.visible:!0,r[Qt.Z_INDEX]=e.zIndex,r[Qt.MAX_RESOLUTION]=e.maxResolution!==void 0?e.maxResolution:1/0,r[Qt.MIN_RESOLUTION]=e.minResolution!==void 0?e.minResolution:0,r[Qt.MIN_ZOOM]=e.minZoom!==void 0?e.minZoom:-1/0,r[Qt.MAX_ZOOM]=e.maxZoom!==void 0?e.maxZoom:1/0,this.className_=r.className!==void 0?r.className:"ol-layer",delete r.className,this.setProperties(r),this.state_=null}getBackground(){return this.background_}getClassName(){return this.className_}getLayerState(e){let r=this.state_||{layer:this,managed:e===void 0?!0:e},a=this.getZIndex();return r.opacity=Ii(Math.round(this.getOpacity()*100)/100,0,1),r.visible=this.getVisible(),r.extent=this.getExtent(),r.zIndex=a===void 0&&!r.managed?1/0:a,r.maxResolution=this.getMaxResolution(),r.minResolution=Math.max(this.getMinResolution(),0),r.minZoom=this.getMinZoom(),r.maxZoom=this.getMaxZoom(),this.state_=r,r}getLayersArray(e){return wt()}getLayerStatesArray(e){return wt()}getExtent(){return this.get(Qt.EXTENT)}getMaxResolution(){return this.get(Qt.MAX_RESOLUTION)}getMinResolution(){return this.get(Qt.MIN_RESOLUTION)}getMinZoom(){return this.get(Qt.MIN_ZOOM)}getMaxZoom(){return this.get(Qt.MAX_ZOOM)}getOpacity(){return this.get(Qt.OPACITY)}getSourceState(){return wt()}getVisible(){return this.get(Qt.VISIBLE)}getZIndex(){return this.get(Qt.Z_INDEX)}setBackground(e){this.background_=e,this.changed()}setExtent(e){this.set(Qt.EXTENT,e)}setMaxResolution(e){this.set(Qt.MAX_RESOLUTION,e)}setMinResolution(e){this.set(Qt.MIN_RESOLUTION,e)}setMaxZoom(e){this.set(Qt.MAX_ZOOM,e)}setMinZoom(e){this.set(Qt.MIN_ZOOM,e)}setOpacity(e){ui(typeof e=="number","Layer opacity must be a number"),this.set(Qt.OPACITY,e)}setVisible(e){this.set(Qt.VISIBLE,e)}setZIndex(e){this.set(Qt.Z_INDEX,e)}disposeInternal(){this.state_&&(this.state_.layer=null,this.state_=null),super.disposeInternal()}},lb=Zg;var Us={PRERENDER:"prerender",POSTRENDER:"postrender",PRECOMPOSE:"precompose",POSTCOMPOSE:"postcompose",RENDERCOMPLETE:"rendercomplete"};var bn={ANIMATING:0,INTERACTING:1};var hs={CENTER:"center",RESOLUTION:"resolution",ROTATION:"rotation"};function Xg(h,e,r){return function(a,c,s,y,v){if(!a)return;if(!c&&!e)return a;let b=e?0:s[0]*c,T=e?0:s[1]*c,C=v?v[0]:0,k=v?v[1]:0,O=h[0]+b/2+C,G=h[2]-b/2+C,J=h[1]+T/2+k,le=h[3]-T/2+k;O>G&&(O=(G+O)/2,G=O),J>le&&(J=(le+J)/2,le=J);let he=Ii(a[0],O,G),fe=Ii(a[1],J,le);if(y&&r&&c){let ye=30*c;he+=-ye*Math.log(1+Math.max(0,O-a[0])/ye)+ye*Math.log(1+Math.max(0,a[0]-G)/ye),fe+=-ye*Math.log(1+Math.max(0,J-a[1])/ye)+ye*Math.log(1+Math.max(0,a[1]-le)/ye)}return[he,fe]}}function cb(h){return h}function Hg(h,e,r,a){let c=vi(e)/r[0],s=Wi(e)/r[1];return a?Math.min(h,Math.max(c,s)):Math.min(h,Math.min(c,s))}function Kg(h,e,r){let a=Math.min(h,e),c=50;return a*=Math.log(1+c*Math.max(0,h/e-1))/c+1,r&&(a=Math.max(a,r),a/=Math.log(1+c*Math.max(0,r/h-1))/c+1),Ii(a,r/2,e*2)}function hb(h,e,r,a){return e=e!==void 0?e:!0,function(c,s,y,v){if(c!==void 0){let b=h[0],T=h[h.length-1],C=r?Hg(b,r,y,a):b;if(v)return e?Kg(c,C,T):Ii(c,T,C);let k=Math.min(C,c),O=Math.floor(ap(h,k,s));return h[O]>C&&O<h.length-1?h[O+1]:h[O]}}}function ub(h,e,r,a,c,s){return a=a!==void 0?a:!0,r=r!==void 0?r:0,function(y,v,b,T){if(y!==void 0){let C=c?Hg(e,c,b,s):e;if(T)return a?Kg(y,C,r):Ii(y,r,C);let k=1e-9,O=Math.ceil(Math.log(e/C)/Math.log(h)-k),G=-v*(.5-k)+.5,J=Math.min(C,y),le=Math.floor(Math.log(e/J)/Math.log(h)+G),he=Math.max(O,le),fe=e/Math.pow(h,he);return Ii(fe,r,C)}}}function Yg(h,e,r,a,c){return r=r!==void 0?r:!0,function(s,y,v,b){if(s!==void 0){let T=a?Hg(h,a,v,c):h;return!r||!b?Ii(s,e,T):Kg(s,T,e)}}}function db(h){if(h!==void 0)return 0}function Jg(h){if(h!==void 0)return h}function pb(h){let e=2*Math.PI/h;return function(r,a){if(a)return r;if(r!==void 0)return r=Math.floor(r/e+.5)*e,r}}function fb(h){let e=h===void 0?nl(5):h;return function(r,a){return a||r===void 0?r:Math.abs(r)<=e?0:r}}function LI(h){return Math.pow(h,3)}function mb(h){return 1-LI(1-h)}function gb(h){return 3*h*h-2*h*h*h}var Qg=0,ty=class extends or{constructor(e){super(),this.on,this.once,this.un,e=Object.assign({},e),this.hints_=[0,0],this.animations_=[],this.updateAnimationKey_,this.projection_=wp(e.projection,"EPSG:3857"),this.viewportSize_=[100,100],this.targetCenter_=null,this.targetResolution_,this.targetRotation_,this.nextCenter_=null,this.nextResolution_,this.nextRotation_,this.cancelAnchor_=void 0,e.projection&&wg(),e.center&&(e.center=Ai(e.center,this.projection_)),e.extent&&(e.extent=Gs(e.extent,this.projection_)),this.applyOptions_(e)}applyOptions_(e){let r=Object.assign({},e);for(let v in hs)delete r[v];this.setProperties(r,!0);let a=FI(e);this.maxResolution_=a.maxResolution,this.minResolution_=a.minResolution,this.zoomFactor_=a.zoomFactor,this.resolutions_=e.resolutions,this.padding_=e.padding,this.minZoom_=a.minZoom;let c=DI(e),s=a.constraint,y=zI(e);this.constraints_={center:c,resolution:s,rotation:y},this.setRotation(e.rotation!==void 0?e.rotation:0),this.setCenterInternal(e.center!==void 0?e.center:null),e.resolution!==void 0?this.setResolution(e.resolution):e.zoom!==void 0&&this.setZoom(e.zoom)}get padding(){return this.padding_}set padding(e){let r=this.padding_;this.padding_=e;let a=this.getCenterInternal();if(a){let c=e||[0,0,0,0];r=r||[0,0,0,0];let s=this.getResolution(),y=s/2*(c[3]-r[3]+r[1]-c[1]),v=s/2*(c[0]-r[0]+r[2]-c[2]);this.setCenterInternal([a[0]+y,a[1]-v])}}getUpdatedOptions_(e){let r=this.getProperties();return r.resolution!==void 0?r.resolution=this.getResolution():r.zoom=this.getZoom(),r.center=this.getCenterInternal(),r.rotation=this.getRotation(),Object.assign({},r,e)}animate(e){this.isDef()&&!this.getAnimating()&&this.resolveConstraints(0);let r=new Array(arguments.length);for(let a=0;a<r.length;++a){let c=arguments[a];c.center&&(c=Object.assign({},c),c.center=Ai(c.center,this.getProjection())),c.anchor&&(c=Object.assign({},c),c.anchor=Ai(c.anchor,this.getProjection())),r[a]=c}this.animateInternal.apply(this,r)}animateInternal(e){let r=arguments.length,a;r>1&&typeof arguments[r-1]=="function"&&(a=arguments[r-1],--r);let c=0;for(;c<r&&!this.isDef();++c){let C=arguments[c];C.center&&this.setCenterInternal(C.center),C.zoom!==void 0?this.setZoom(C.zoom):C.resolution&&this.setResolution(C.resolution),C.rotation!==void 0&&this.setRotation(C.rotation)}if(c===r){a&&zp(a,!0);return}let s=Date.now(),y=this.targetCenter_.slice(),v=this.targetResolution_,b=this.targetRotation_,T=[];for(;c<r;++c){let C=arguments[c],k={start:s,complete:!1,anchor:C.anchor,duration:C.duration!==void 0?C.duration:1e3,easing:C.easing||gb,callback:a};if(C.center&&(k.sourceCenter=y,k.targetCenter=C.center.slice(),y=k.targetCenter),C.zoom!==void 0?(k.sourceResolution=v,k.targetResolution=this.getResolutionForZoom(C.zoom),v=k.targetResolution):C.resolution&&(k.sourceResolution=v,k.targetResolution=C.resolution,v=k.targetResolution),C.rotation!==void 0){k.sourceRotation=b;let O=sl(C.rotation-b+Math.PI,2*Math.PI)-Math.PI;k.targetRotation=b+O,b=k.targetRotation}OI(k)?k.complete=!0:s+=k.duration,T.push(k)}this.animations_.push(T),this.setHint(bn.ANIMATING,1),this.updateAnimations_()}getAnimating(){return this.hints_[bn.ANIMATING]>0}getInteracting(){return this.hints_[bn.INTERACTING]>0}cancelAnimations(){this.setHint(bn.ANIMATING,-this.hints_[bn.ANIMATING]);let e;for(let r=0,a=this.animations_.length;r<a;++r){let c=this.animations_[r];if(c[0].callback&&zp(c[0].callback,!1),!e)for(let s=0,y=c.length;s<y;++s){let v=c[s];if(!v.complete){e=v.anchor;break}}}this.animations_.length=0,this.cancelAnchor_=e,this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN}updateAnimations_(){if(this.updateAnimationKey_!==void 0&&(cancelAnimationFrame(this.updateAnimationKey_),this.updateAnimationKey_=void 0),!this.getAnimating())return;let e=Date.now(),r=!1;for(let a=this.animations_.length-1;a>=0;--a){let c=this.animations_[a],s=!0;for(let y=0,v=c.length;y<v;++y){let b=c[y];if(b.complete)continue;let T=e-b.start,C=b.duration>0?T/b.duration:1;C>=1?(b.complete=!0,C=1):s=!1;let k=b.easing(C);if(b.sourceCenter){let O=b.sourceCenter[0],G=b.sourceCenter[1],J=b.targetCenter[0],le=b.targetCenter[1];this.nextCenter_=b.targetCenter;let he=O+k*(J-O),fe=G+k*(le-G);this.targetCenter_=[he,fe]}if(b.sourceResolution&&b.targetResolution){let O=k===1?b.targetResolution:b.sourceResolution+k*(b.targetResolution-b.sourceResolution);if(b.anchor){let G=this.getViewportSize_(this.getRotation()),J=this.constraints_.resolution(O,0,G,!0);this.targetCenter_=this.calculateCenterZoom(J,b.anchor)}this.nextResolution_=b.targetResolution,this.targetResolution_=O,this.applyTargetState_(!0)}if(b.sourceRotation!==void 0&&b.targetRotation!==void 0){let O=k===1?sl(b.targetRotation+Math.PI,2*Math.PI)-Math.PI:b.sourceRotation+k*(b.targetRotation-b.sourceRotation);if(b.anchor){let G=this.constraints_.rotation(O,!0);this.targetCenter_=this.calculateCenterRotate(G,b.anchor)}this.nextRotation_=b.targetRotation,this.targetRotation_=O}if(this.applyTargetState_(!0),r=!0,!b.complete)break}if(s){this.animations_[a]=null,this.setHint(bn.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;let y=c[0].callback;y&&zp(y,!0)}}this.animations_=this.animations_.filter(Boolean),r&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,r){let a,c=this.getCenterInternal();return c!==void 0&&(a=[c[0]-r[0],c[1]-r[1]],vv(a,e-this.getRotation()),xv(a,r)),a}calculateCenterZoom(e,r){let a,c=this.getCenterInternal(),s=this.getResolution();if(c!==void 0&&s!==void 0){let y=r[0]-e*(r[0]-c[0])/s,v=r[1]-e*(r[1]-c[1])/s;a=[y,v]}return a}getViewportSize_(e){let r=this.viewportSize_;if(e){let a=r[0],c=r[1];return[Math.abs(a*Math.cos(e))+Math.abs(c*Math.sin(e)),Math.abs(a*Math.sin(e))+Math.abs(c*Math.cos(e))]}return r}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){let e=this.getCenterInternal();return e&&ua(e,this.getProjection())}getCenterInternal(){return this.get(hs.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){let r=this.calculateExtentInternal(e);return js(r,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();let r=this.getCenterInternal();ui(r,"The view center is not defined");let a=this.getResolution();ui(a!==void 0,"The view resolution is not defined");let c=this.getRotation();return ui(c!==void 0,"The view rotation is not defined"),av(r,a,c,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(hs.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,r){return this.getResolutionForExtentInternal(Gs(e,this.getProjection()),r)}getResolutionForExtentInternal(e,r){r=r||this.getViewportSizeMinusPadding_();let a=vi(e)/r[0],c=Wi(e)/r[1];return Math.max(a,c)}getResolutionForValueFunction(e){e=e||2;let r=this.getConstrainedResolution(this.maxResolution_),a=this.minResolution_,c=Math.log(r/a)/Math.log(e);return function(s){return r/Math.pow(e,s*c)}}getRotation(){return this.get(hs.ROTATION)}getValueForResolutionFunction(e){let r=Math.log(e||2),a=this.getConstrainedResolution(this.maxResolution_),c=this.minResolution_,s=Math.log(a/c)/r;return function(y){return Math.log(a/y)/r/s}}getViewportSizeMinusPadding_(e){let r=this.getViewportSize_(e),a=this.padding_;return a&&(r=[r[0]-a[1]-a[3],r[1]-a[0]-a[2]]),r}getState(){let e=this.getProjection(),r=this.getResolution(),a=this.getRotation(),c=this.getCenterInternal(),s=this.padding_;if(s){let y=this.getViewportSizeMinusPadding_();c=ey(c,this.getViewportSize_(),[y[0]/2+s[3],y[1]/2+s[0]],r,a)}return{center:c.slice(0),projection:e!==void 0?e:null,resolution:r,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:a,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e,r=this.getResolution();return r!==void 0&&(e=this.getZoomForResolution(r)),e}getZoomForResolution(e){let r=this.minZoom_||0,a,c;if(this.resolutions_){let s=ap(this.resolutions_,e,1);r=s,a=this.resolutions_[s],s==this.resolutions_.length-1?c=2:c=a/this.resolutions_[s+1]}else a=this.maxResolution_,c=this.zoomFactor_;return r+Math.log(a/e)/Math.log(c)}getResolutionForZoom(e){if(this.resolutions_?.length){if(this.resolutions_.length===1)return this.resolutions_[0];let r=Ii(Math.floor(e),0,this.resolutions_.length-2),a=this.resolutions_[r]/this.resolutions_[r+1];return this.resolutions_[r]/Math.pow(a,Ii(e-r,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,r){let a;if(ui(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){ui(!su(e),"Cannot fit empty extent provided as `geometry`");let c=Gs(e,this.getProjection());a=jg(c)}else if(e.getType()==="Circle"){let c=Gs(e.getExtent(),this.getProjection());a=jg(c),a.rotate(this.getRotation(),as(c))}else{let c=Zn();c?a=e.clone().transform(c,this.getProjection()):a=e}this.fitInternal(a,r)}rotatedExtentForGeometry(e){let r=this.getRotation(),a=Math.cos(r),c=Math.sin(-r),s=e.getFlatCoordinates(),y=e.getStride(),v=1/0,b=1/0,T=-1/0,C=-1/0;for(let k=0,O=s.length;k<O;k+=y){let G=s[k]*a-s[k+1]*c,J=s[k]*c+s[k+1]*a;v=Math.min(v,G),b=Math.min(b,J),T=Math.max(T,G),C=Math.max(C,J)}return[v,b,T,C]}fitInternal(e,r){r=r||{};let a=r.size;a||(a=this.getViewportSizeMinusPadding_());let c=r.padding!==void 0?r.padding:[0,0,0,0],s=r.nearest!==void 0?r.nearest:!1,y;r.minResolution!==void 0?y=r.minResolution:r.maxZoom!==void 0?y=this.getResolutionForZoom(r.maxZoom):y=0;let v=this.rotatedExtentForGeometry(e),b=this.getResolutionForExtentInternal(v,[a[0]-c[1]-c[3],a[1]-c[0]-c[2]]);b=isNaN(b)?y:Math.max(b,y),b=this.getConstrainedResolution(b,s?0:1);let T=this.getRotation(),C=Math.sin(T),k=Math.cos(T),O=as(v);O[0]+=(c[1]-c[3])/2*b,O[1]+=(c[0]-c[2])/2*b;let G=O[0]*k-O[1]*C,J=O[1]*k+O[0]*C,le=this.getConstrainedCenter([G,J],b),he=r.callback?r.callback:vs;r.duration!==void 0?this.animateInternal({resolution:b,center:le,duration:r.duration,easing:r.easing},he):(this.targetResolution_=b,this.targetCenter_=le,this.applyTargetState_(!1,!0),zp(he,!0))}centerOn(e,r,a){this.centerOnInternal(Ai(e,this.getProjection()),r,a)}centerOnInternal(e,r,a){this.setCenterInternal(ey(e,r,a,this.getResolution(),this.getRotation()))}calculateCenterShift(e,r,a,c){let s,y=this.padding_;if(y&&e){let v=this.getViewportSizeMinusPadding_(-a),b=ey(e,c,[v[0]/2+y[3],v[1]/2+y[0]],r,a);s=[e[0]-b[0],e[1]-b[1]]}return s}isDef(){return!!this.getCenterInternal()&&this.getResolution()!==void 0}adjustCenter(e){let r=ua(this.targetCenter_,this.getProjection());this.setCenter([r[0]+e[0],r[1]+e[1]])}adjustCenterInternal(e){let r=this.targetCenter_;this.setCenterInternal([r[0]+e[0],r[1]+e[1]])}adjustResolution(e,r){r=r&&Ai(r,this.getProjection()),this.adjustResolutionInternal(e,r)}adjustResolutionInternal(e,r){let a=this.getAnimating()||this.getInteracting(),c=this.getViewportSize_(this.getRotation()),s=this.constraints_.resolution(this.targetResolution_*e,0,c,a);r&&(this.targetCenter_=this.calculateCenterZoom(s,r)),this.targetResolution_*=e,this.applyTargetState_()}adjustZoom(e,r){this.adjustResolution(Math.pow(this.zoomFactor_,-e),r)}adjustRotation(e,r){r&&(r=Ai(r,this.getProjection())),this.adjustRotationInternal(e,r)}adjustRotationInternal(e,r){let a=this.getAnimating()||this.getInteracting(),c=this.constraints_.rotation(this.targetRotation_+e,a);r&&(this.targetCenter_=this.calculateCenterRotate(c,r)),this.targetRotation_+=e,this.applyTargetState_()}setCenter(e){this.setCenterInternal(e&&Ai(e,this.getProjection()))}setCenterInternal(e){this.targetCenter_=e,this.applyTargetState_()}setHint(e,r){return this.hints_[e]+=r,this.changed(),this.hints_[e]}setResolution(e){this.targetResolution_=e,this.applyTargetState_()}setRotation(e){this.targetRotation_=e,this.applyTargetState_()}setZoom(e){this.setResolution(this.getResolutionForZoom(e))}applyTargetState_(e,r){let a=this.getAnimating()||this.getInteracting()||r,c=this.constraints_.rotation(this.targetRotation_,a),s=this.getViewportSize_(c),y=this.constraints_.resolution(this.targetResolution_,0,s,a),v=this.constraints_.center(this.targetCenter_,y,s,a,this.calculateCenterShift(this.targetCenter_,y,c,s));this.get(hs.ROTATION)!==c&&this.set(hs.ROTATION,c),this.get(hs.RESOLUTION)!==y&&(this.set(hs.RESOLUTION,y),this.set("zoom",this.getZoom(),!0)),(!v||!this.get(hs.CENTER)||!Zi(this.get(hs.CENTER),v))&&this.set(hs.CENTER,v),this.getAnimating()&&!e&&this.cancelAnimations(),this.cancelAnchor_=void 0}resolveConstraints(e,r,a){e=e!==void 0?e:200;let c=r||0,s=this.constraints_.rotation(this.targetRotation_),y=this.getViewportSize_(s),v=this.constraints_.resolution(this.targetResolution_,c,y),b=this.constraints_.center(this.targetCenter_,v,y,!1,this.calculateCenterShift(this.targetCenter_,v,s,y));if(e===0&&!this.cancelAnchor_){this.targetResolution_=v,this.targetRotation_=s,this.targetCenter_=b,this.applyTargetState_();return}a=a||(e===0?this.cancelAnchor_:void 0),this.cancelAnchor_=void 0,(this.getResolution()!==v||this.getRotation()!==s||!this.getCenterInternal()||!Zi(this.getCenterInternal(),b))&&(this.getAnimating()&&this.cancelAnimations(),this.animateInternal({rotation:s,center:b,resolution:v,duration:e,easing:mb,anchor:a}))}beginInteraction(){this.resolveConstraints(0),this.setHint(bn.INTERACTING,1)}endInteraction(e,r,a){a=a&&Ai(a,this.getProjection()),this.endInteractionInternal(e,r,a)}endInteractionInternal(e,r,a){this.getInteracting()&&(this.setHint(bn.INTERACTING,-1),this.resolveConstraints(e,r,a))}getConstrainedCenter(e,r){let a=this.getViewportSize_(this.getRotation());return this.constraints_.center(e,r||this.getResolution(),a)}getConstrainedZoom(e,r){let a=this.getResolutionForZoom(e);return this.getZoomForResolution(this.getConstrainedResolution(a,r))}getConstrainedResolution(e,r){r=r||0;let a=this.getViewportSize_(this.getRotation());return this.constraints_.resolution(e,r,a)}};function zp(h,e){setTimeout(function(){h(e)},0)}function DI(h){if(h.extent!==void 0){let r=h.smoothExtentConstraint!==void 0?h.smoothExtentConstraint:!0;return Xg(h.extent,h.constrainOnlyCenter,r)}let e=wp(h.projection,"EPSG:3857");if(h.multiWorld!==!0&&e.isGlobal()){let r=e.getExtent().slice();return r[0]=-1/0,r[2]=1/0,Xg(r,!1,!1)}return cb}function FI(h){let e,r,a,y=h.minZoom!==void 0?h.minZoom:Qg,v=h.maxZoom!==void 0?h.maxZoom:28,b=h.zoomFactor!==void 0?h.zoomFactor:2,T=h.multiWorld!==void 0?h.multiWorld:!1,C=h.smoothResolutionConstraint!==void 0?h.smoothResolutionConstraint:!0,k=h.showFullExtent!==void 0?h.showFullExtent:!1,O=wp(h.projection,"EPSG:3857"),G=O.getExtent(),J=h.constrainOnlyCenter,le=h.extent;if(!T&&!le&&O.isGlobal()&&(J=!1,le=G),h.resolutions!==void 0){let he=h.resolutions;r=he[y],a=he[v]!==void 0?he[v]:he[he.length-1],h.constrainResolution?e=hb(he,C,!J&&le,k):e=Yg(r,a,C,!J&&le,k)}else{let fe=(G?Math.max(vi(G),Wi(G)):360*ou.degrees/O.getMetersPerUnit())/256/Math.pow(2,Qg),ye=fe/Math.pow(2,28-Qg);r=h.maxResolution,r!==void 0?y=0:r=fe/Math.pow(b,y),a=h.minResolution,a===void 0&&(h.maxZoom!==void 0?h.maxResolution!==void 0?a=r/Math.pow(b,v):a=fe/Math.pow(b,v):a=ye),v=y+Math.floor(Math.log(r/a)/Math.log(b)),a=r/Math.pow(b,v-y),h.constrainResolution?e=ub(b,r,a,C,!J&&le,k):e=Yg(r,a,C,!J&&le,k)}return{constraint:e,maxResolution:r,minResolution:a,minZoom:y,zoomFactor:b}}function zI(h){if(h.enableRotation!==void 0?h.enableRotation:!0){let r=h.constrainRotation;return r===void 0||r===!0?fb():r===!1?Jg:typeof r=="number"?pb(r):Jg}return db}function OI(h){return!(h.sourceCenter&&h.targetCenter&&!Zi(h.sourceCenter,h.targetCenter)||h.sourceResolution!==h.targetResolution||h.sourceRotation!==h.targetRotation)}function ey(h,e,r,a,c){let s=Math.cos(-c),y=Math.sin(-c),v=h[0]*s-h[1]*y,b=h[1]*s+h[0]*y;v+=(e[0]/2-r[0])*a,b+=(r[1]-e[1]/2)*a,y=-y;let T=v*s-b*y,C=b*s+v*y;return[T,C]}var iy=ty;var ry=class extends lb{constructor(e){let r=Object.assign({},e);delete r.source,super(r),this.on,this.once,this.un,this.mapPrecomposeKey_=null,this.mapRenderKey_=null,this.sourceChangeKey_=null,this.renderer_=null,this.sourceReady_=!1,this.rendered=!1,e.render&&(this.render=e.render),e.map&&this.setMap(e.map),this.addChangeListener(Qt.SOURCE,this.handleSourcePropertyChange_);let a=e.source?e.source:null;this.setSource(a)}getLayersArray(e){return e=e||[],e.push(this),e}getLayerStatesArray(e){return e=e||[],e.push(this.getLayerState()),e}getSource(){return this.get(Qt.SOURCE)||null}getRenderSource(){return this.getSource()}getSourceState(){let e=this.getSource();return e?e.getState():"undefined"}handleSourceChange_(){this.changed(),!(this.sourceReady_||this.getSource().getState()!=="ready")&&(this.sourceReady_=!0,this.dispatchEvent("sourceready"))}handleSourcePropertyChange_(){this.sourceChangeKey_&&(jr(this.sourceChangeKey_),this.sourceChangeKey_=null),this.sourceReady_=!1;let e=this.getSource();e&&(this.sourceChangeKey_=Sr(e,pi.CHANGE,this.handleSourceChange_,this),e.getState()==="ready"&&(this.sourceReady_=!0,setTimeout(()=>{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let r,a=this.getMapInternal();!e&&a&&(e=a.getView()),e instanceof iy?r={viewState:e.getState(),extent:e.calculateExtent()}:r=e,!r.layerStatesArray&&a&&(r.layerStatesArray=a.getLayerGroup().getLayerStatesArray());let c;if(r.layerStatesArray){if(c=r.layerStatesArray.find(y=>y.layer===this),!c)return!1}else c=this.getLayerState();let s=this.getExtent();return ny(c,r.viewState)&&(!s||Vi(s,r.extent))}getAttributions(e){if(!this.isVisible(e))return[];let r=this.getSource()?.getAttributions();if(!r)return[];let a=e instanceof iy?e.getViewStateAndExtent():e,c=r(a);return Array.isArray(c)||(c=[c]),c}render(e,r){let a=this.getRenderer();return a.prepareFrame(e)?(this.rendered=!0,a.renderFrame(e,r)):null}unrender(){this.rendered=!1}getDeclutter(){}renderDeclutter(e,r){}renderDeferred(e){let r=this.getRenderer();r&&r.renderDeferred(e)}setMapInternal(e){e||this.unrender(),this.set(Qt.MAP,e)}getMapInternal(){return this.get(Qt.MAP)}setMap(e){this.mapPrecomposeKey_&&(jr(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(jr(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=Sr(e,Us.PRECOMPOSE,this.handlePrecompose_,this),this.mapRenderKey_=Sr(this,pi.CHANGE,e.render,e),this.changed())}handlePrecompose_(e){let r=e.frameState.layerStatesArray,a=this.getLayerState(!1);ui(!r.some(c=>c.layer===a.layer),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),r.push(a)}setSource(e){this.set(Qt.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}clearRenderer(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_)}disposeInternal(){this.clearRenderer(),this.setSource(null),super.disposeInternal()}};function ny(h,e){if(!h.visible)return!1;let r=e.resolution;if(r<h.minResolution||r>=h.maxResolution)return!1;let a=e.zoom;return a>h.minZoom&&a<=h.maxZoom}var Es=ry;var BI=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",bottom:0,right:0,fontSize:".8rem",padding:"0 10px"}),h},yb=BI;var sy=class extends Ac{constructor(e={}){let r=yb();r.className=e.className||"mbt-copyright",super({element:r,...e}),this.format=e.format||(a=>a?.join(" | "))}render({frameState:e}){if(!e){this.element.innerHTML="";return}let r=[];e?.layerStatesArray.forEach(c=>{let{layer:s}=c;if(e&&ny(c,e.viewState)&&(s?.getSource()?.getAttributions()&&(r=r.concat(s.getSource().getAttributions()(e))),s?.get("copyrights"))){let y=s.get("copyrights");y=Array.isArray(y)?y:[y],y?.length&&r.push(...y)}});let a=il(r)||[];this.element.innerHTML=this.format(a)}},_b=sy;var Ts={ADD:"add",REMOVE:"remove"};var xb={LENGTH:"length"},Rc=class extends Si{constructor(e,r,a){super(e),this.element=r,this.index=a}},oy=class extends or{constructor(e,r){if(super(),this.on,this.once,this.un,r=r||{},this.unique_=!!r.unique,this.array_=e||[],this.unique_)for(let a=0,c=this.array_.length;a<c;++a)this.assertUnique_(this.array_[a],a);this.updateLength_()}clear(){for(;this.getLength()>0;)this.pop()}extend(e){for(let r=0,a=e.length;r<a;++r)this.push(e[r]);return this}forEach(e){let r=this.array_;for(let a=0,c=r.length;a<c;++a)e(r[a],a,r)}getArray(){return this.array_}item(e){return this.array_[e]}getLength(){return this.get(xb.LENGTH)}insertAt(e,r){if(e<0||e>this.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r),this.array_.splice(e,0,r),this.updateLength_(),this.dispatchEvent(new Rc(Ts.ADD,r,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);let r=this.getLength();return this.insertAt(r,e),this.getLength()}remove(e){let r=this.array_;for(let a=0,c=r.length;a<c;++a)if(r[a]===e)return this.removeAt(a)}removeAt(e){if(e<0||e>=this.getLength())return;let r=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new Rc(Ts.REMOVE,r,e)),r}setAt(e,r){let a=this.getLength();if(e>=a){this.insertAt(e,r);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(r,e);let c=this.array_[e];this.array_[e]=r,this.dispatchEvent(new Rc(Ts.REMOVE,c,e)),this.dispatchEvent(new Rc(Ts.ADD,r,e))}updateLength_(){this.set(xb.LENGTH,this.array_.length)}assertUnique_(e,r){for(let a=0,c=this.array_.length;a<c;++a)if(this.array_[a]===e&&a!==r)throw new Error("Duplicate item added to a unique collection")}},Eu=oy;var ay=class h extends or{constructor(e){if(super(),this.on,this.once,this.un,this.id_=void 0,this.geometryName_="geometry",this.style_=null,this.styleFunction_=void 0,this.geometryChangeKey_=null,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),e)if(typeof e.getSimplifiedGeometry=="function"){let r=e;this.setGeometry(r)}else{let r=e;this.setProperties(r)}}clone(){let e=new h(this.hasProperties()?this.getProperties():null);e.setGeometryName(this.getGeometryName());let r=this.getGeometry();r&&e.setGeometry(r.clone());let a=this.getStyle();return a&&e.setStyle(a),e}getGeometry(){return this.get(this.geometryName_)}getId(){return this.id_}getGeometryName(){return this.geometryName_}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}handleGeometryChange_(){this.changed()}handleGeometryChanged_(){this.geometryChangeKey_&&(jr(this.geometryChangeKey_),this.geometryChangeKey_=null);let e=this.getGeometry();e&&(this.geometryChangeKey_=Sr(e,pi.CHANGE,this.handleGeometryChange_,this)),this.changed()}setGeometry(e){this.set(this.geometryName_,e)}setStyle(e){this.style_=e,this.styleFunction_=e?NI(e):void 0,this.changed()}setId(e){this.id_=e,this.changed()}setGeometryName(e){this.removeChangeListener(this.geometryName_,this.handleGeometryChanged_),this.geometryName_=e,this.addChangeListener(this.geometryName_,this.handleGeometryChanged_),this.handleGeometryChanged_()}};function NI(h){if(typeof h=="function")return h;let e;return Array.isArray(h)?e=h:(ui(typeof h.getZIndex=="function","Expected an `ol/style/Style` or an array of `ol/style/Style.js`"),e=[h]),function(){return e}}var us=ay;var It={IDLE:0,LOADING:1,LOADED:2,ERROR:3,EMPTY:4};var xo={name:"rgb",min:[0,0,0],max:[255,255,255],channel:["red","green","blue"],alias:["RGB"]};var dl={name:"xyz",min:[0,0,0],channel:["X","Y","Z"],alias:["XYZ","ciexyz","cie1931"]};dl.whitepoint={2:{A:[109.85,100,35.585],C:[98.074,100,118.232],D50:[96.422,100,82.521],D55:[95.682,100,92.149],D65:[95.045592705167,100,108.9057750759878],D75:[94.972,100,122.638],F2:[99.187,100,67.395],F7:[95.044,100,108.755],F11:[100.966,100,64.37],E:[100,100,100]},10:{A:[111.144,100,35.2],C:[97.285,100,116.145],D50:[96.72,100,81.427],D55:[95.799,100,90.926],D65:[94.811,100,107.304],D75:[94.416,100,120.641],F2:[103.28,100,69.026],F7:[95.792,100,107.687],F11:[103.866,100,65.627],E:[100,100,100]}};dl.max=dl.whitepoint[2].D65;dl.rgb=function(h,e){e=e||dl.whitepoint[2].E;var r=h[0]/e[0],a=h[1]/e[1],c=h[2]/e[2],s,y,v;return s=r*3.240969941904521+a*-1.537383177570093+c*-.498610760293,y=r*-.96924363628087+a*1.87596750150772+c*.041555057407175,v=r*.055630079696993+a*-.20397695888897+c*1.056971514242878,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s=s*12.92,y=y>.0031308?1.055*Math.pow(y,1/2.4)-.055:y=y*12.92,v=v>.0031308?1.055*Math.pow(v,1/2.4)-.055:v=v*12.92,s=Math.min(Math.max(0,s),1),y=Math.min(Math.max(0,y),1),v=Math.min(Math.max(0,v),1),[s*255,y*255,v*255]};xo.xyz=function(h,e){var r=h[0]/255,a=h[1]/255,c=h[2]/255;r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,a=a>.04045?Math.pow((a+.055)/1.055,2.4):a/12.92,c=c>.04045?Math.pow((c+.055)/1.055,2.4):c/12.92;var s=r*.41239079926595+a*.35758433938387+c*.18048078840183,y=r*.21263900587151+a*.71516867876775+c*.072192315360733,v=r*.019330818715591+a*.11919477979462+c*.95053215224966;return e=e||dl.whitepoint[2].E,[s*e[0],y*e[1],v*e[2]]};var wn=dl;var Op={name:"luv",min:[0,-134,-140],max:[100,224,122],channel:["lightness","u","v"],alias:["LUV","cieluv","cie1976"],xyz:function(h,e,r){var a,c,s,y,v,b,T,C,k,O,G,J,le;if(s=h[0],y=h[1],v=h[2],s===0)return[0,0,0];var he=.0011070564598794539;return e=e||"D65",r=r||2,k=wn.whitepoint[r][e][0],O=wn.whitepoint[r][e][1],G=wn.whitepoint[r][e][2],J=4*k/(k+15*O+3*G),le=9*O/(k+15*O+3*G),a=y/(13*s)+J||0,c=v/(13*s)+le||0,T=s>8?O*Math.pow((s+16)/116,3):O*s*he,b=T*9*a/(4*c)||0,C=T*(12-3*a-20*c)/(4*c)||0,[b,T,C]}};wn.luv=function(h,e,r){var a,c,s,y,v,b,T,C,k,O,G,J,le,he=.008856451679035631,fe=903.2962962962961;e=e||"D65",r=r||2,k=wn.whitepoint[r][e][0],O=wn.whitepoint[r][e][1],G=wn.whitepoint[r][e][2],J=4*k/(k+15*O+3*G),le=9*O/(k+15*O+3*G),b=h[0],T=h[1],C=h[2],a=4*b/(b+15*T+3*C)||0,c=9*T/(b+15*T+3*C)||0;var ye=T/O;return s=ye<=he?fe*ye:116*Math.pow(ye,1/3)-16,y=13*s*(a-J),v=13*s*(c-le),[s,y,v]};var vb={name:"lchuv",channel:["lightness","chroma","hue"],alias:["LCHuv","cielchuv"],min:[0,0,0],max:[100,100,360],luv:function(h){var e=h[0],r=h[1],a=h[2],c,s,y;return y=a/360*2*Math.PI,c=r*Math.cos(y),s=r*Math.sin(y),[e,c,s]},xyz:function(h){return Op.xyz(vb.luv(h))}},bb=vb;Op.lchuv=function(h){var e=h[0],r=h[1],a=h[2],c=Math.sqrt(r*r+a*a),s=Math.atan2(a,r),y=s*360/2/Math.PI;return y<0&&(y+=360),[e,c,y]};wn.lchuv=function(h){return Op.lchuv(wn.luv(h))};var ly=Vs(Sb(),1),Cb=VI,Ib={red:0,orange:60,yellow:120,green:180,blue:240,purple:300};function VI(h){var e,r=[],a=1,c;if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(typeof h=="number")return{space:"rgb",values:[h>>>16,(h&65280)>>>8,h&255],alpha:1};if(h=String(h).toLowerCase(),ly.default[h])r=ly.default[h].slice(),c="rgb";else if(h==="transparent")a=0,c="rgb",r=[0,0,0];else if(h[0]==="#"){var s=h.slice(1),y=s.length,v=y<=4;a=1,v?(r=[parseInt(s[0]+s[0],16),parseInt(s[1]+s[1],16),parseInt(s[2]+s[2],16)],y===4&&(a=parseInt(s[3]+s[3],16)/255)):(r=[parseInt(s[0]+s[1],16),parseInt(s[2]+s[3],16),parseInt(s[4]+s[5],16)],y===8&&(a=parseInt(s[6]+s[7],16)/255)),r[0]||(r[0]=0),r[1]||(r[1]=0),r[2]||(r[2]=0),c="rgb"}else if(e=/^((?:rgba?|hs[lvb]a?|hwba?|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms|oklch|oklab|color))\s*\(([^\)]*)\)/.exec(h)){var b=e[1];c=b.replace(/a$/,"");var T=c==="cmyk"?4:c==="gray"?1:3;r=e[2].trim().split(/\s*[,\/]\s*|\s+/),c==="color"&&(c=r.shift()),r=r.map(function(C,k){if(C[C.length-1]==="%")return C=parseFloat(C)/100,k===3?C:c==="rgb"?C*255:c[0]==="h"||c[0]==="l"&&!k?C*100:c==="lab"?C*125:c==="lch"?k<2?C*150:C*360:c[0]==="o"&&!k?C:c==="oklab"?C*.4:c==="oklch"?k<2?C*.4:C*360:C;if(c[k]==="h"||k===2&&c[c.length-1]==="h"){if(Ib[C]!==void 0)return Ib[C];if(C.endsWith("deg"))return parseFloat(C);if(C.endsWith("turn"))return parseFloat(C)*360;if(C.endsWith("grad"))return parseFloat(C)*360/400;if(C.endsWith("rad"))return parseFloat(C)*180/Math.PI}return C==="none"?0:parseFloat(C)}),a=r.length>T?r.pop():1}else/[0-9](?:\s|\/|,)/.test(h)&&(r=h.match(/([0-9]+)/g).map(function(C){return parseFloat(C)}),c=h.match(/([a-z])/ig)?.join("")?.toLowerCase()||"rgb");return{space:c,values:r,alpha:a}}var Bp={name:"hsl",min:[0,0,0],max:[360,100,100],channel:["hue","saturation","lightness"],alias:["HSL"],rgb:function(h){var e=h[0]/360,r=h[1]/100,a=h[2]/100,c,s,y,v,b,T=0;if(r===0)return b=a*255,[b,b,b];for(s=a<.5?a*(1+r):a+r-a*r,c=2*a-s,v=[0,0,0];T<3;)y=e+1/3*-(T-1),y<0?y++:y>1&&y--,b=6*y<1?c+(s-c)*6*y:2*y<1?s:3*y<2?c+(s-c)*(2/3-y)*6:c,v[T++]=b*255;return v}};xo.hsl=function(h){var e=h[0]/255,r=h[1]/255,a=h[2]/255,c=Math.min(e,r,a),s=Math.max(e,r,a),y=s-c,v,b,T;return s===c?v=0:e===s?v=(r-a)/y:r===s?v=2+(a-e)/y:a===s&&(v=4+(e-r)/y),v=Math.min(v*60,360),v<0&&(v+=360),T=(c+s)/2,s===c?b=0:T<=.5?b=y/(s+c):b=y/(2-s-c),[v,b*100,T*100]};function cy(h){Array.isArray(h)&&h.raw&&(h=String.raw(...arguments)),h instanceof Number&&(h=+h);var e,r,a,c=Cb(h);if(!c.space)return[];let s=c.space[0]==="h"?Bp.min:xo.min,y=c.space[0]==="h"?Bp.max:xo.max;return e=Array(3),e[0]=Math.min(Math.max(c.values[0],s[0]),y[0]),e[1]=Math.min(Math.max(c.values[1],s[1]),y[1]),e[2]=Math.min(Math.max(c.values[2],s[2]),y[2]),c.space[0]==="h"&&(e=Bp.rgb(e)),e.push(Math.min(Math.max(c.alpha,0),1)),e}var Np=[NaN,NaN,NaN,0];function Eb(h){return typeof h=="string"?h:Pu(h)}var jI=1024,Tu={},hy=0;function Tb(h){if(h.length===4)return h;let e=h.slice();return e[3]=1,e}function uy(h){let e=wn.lchuv(xo.xyz(h));return e[3]=h[3],e}function Mb(h){let e=wn.rgb(bb.xyz(h));return e[3]=h[3],e}function Mu(h){if(h==="none")return Np;if(Tu.hasOwnProperty(h))return Tu[h];if(hy>=jI){let r=0;for(let a in Tu)r++&3||(delete Tu[a],--hy)}let e=cy(h);if(e.length!==4)throw new Error('failed to parse "'+h+'" as color');for(let r of e)if(isNaN(r))throw new Error('failed to parse "'+h+'" as color');return dy(e),Tu[h]=e,++hy,e}function Ms(h){return Array.isArray(h)?h:Mu(h)}function dy(h){return h[0]=Ii(h[0]+.5|0,0,255),h[1]=Ii(h[1]+.5|0,0,255),h[2]=Ii(h[2]+.5|0,0,255),h[3]=Ii(h[3],0,1),h}function Pu(h){let e=h[0];e!=(e|0)&&(e=e+.5|0);let r=h[1];r!=(r|0)&&(r=r+.5|0);let a=h[2];a!=(a|0)&&(a=a+.5|0);let c=h[3]===void 0?1:Math.round(h[3]*1e3)/1e3;return"rgba("+e+","+r+","+a+","+c+")"}var ya=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",lD=ya.includes("firefox"),GI=ya.includes("safari")&&!ya.includes("chrom"),cD=GI&&(ya.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(ya)),hD=ya.includes("webkit")&&!ya.includes("edge"),uD=ya.includes("macintosh");var Vp=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,Pb=typeof Image<"u"&&Image.prototype.decode;var dD=function(){let h=!1;try{let e=Object.defineProperty({},"passive",{get:function(){h=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return h}();function Ri(h,e,r,a){let c;return r&&r.length?c=r.shift():Vp?c=new OffscreenCanvas(h||300,e||300):c=document.createElement("canvas"),h&&(c.width=h),e&&(c.height=e),c.getContext("2d",a)}var py;function kc(){return py||(py=Ri(1,1)),py}function Ab(h){let e=h.canvas;e.width=1,e.height=1,h.clearRect(0,0,1,1)}function UI(h,e){return new Promise((r,a)=>{function c(){y(),r(h)}function s(){y(),a(new Error("Image load error"))}function y(){h.removeEventListener("load",c),h.removeEventListener("error",s)}h.addEventListener("load",c),h.addEventListener("error",s),e&&(h.src=e)})}function Rb(h,e){return e&&(h.src=e),h.src&&Pb?new Promise((r,a)=>h.decode().then(()=>r(h)).catch(c=>h.complete&&h.width?r(h):a(c))):UI(h)}var my=class{constructor(){this.cache_={},this.patternCache_={},this.cacheSize_=0,this.maxCacheSize_=1024}clear(){this.cache_={},this.patternCache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(let r in this.cache_){let a=this.cache_[r];!(e++&3)&&!a.hasListener()&&(delete this.cache_[r],delete this.patternCache_[r],--this.cacheSize_)}}}get(e,r,a){let c=fy(e,r,a);return c in this.cache_?this.cache_[c]:null}getPattern(e,r,a){let c=fy(e,r,a);return c in this.patternCache_?this.patternCache_[c]:null}set(e,r,a,c,s){let y=fy(e,r,a),v=y in this.cache_;this.cache_[y]=c,s&&(c.getImageState()===It.IDLE&&c.load(),c.getImageState()===It.LOADING?c.ready().then(()=>{this.patternCache_[y]=kc().createPattern(c.getImage(1),"repeat")}):this.patternCache_[y]=kc().createPattern(c.getImage(1),"repeat")),v||++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}};function fy(h,e,r){let a=r?Ms(r):"null";return e+":"+h+":"+a}var Xn=new my;var Au=null,jp=class extends hp{constructor(e,r,a,c,s){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=a,this.canvas_={},this.color_=s,this.imageState_=c===void 0?It.IDLE:c,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=r,this.tainted_,this.ready_=null}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===It.LOADED){Au||(Au=Ri(1,1,void 0,{willReadFrequently:!0})),Au.drawImage(this.image_,0,0);try{Au.getImageData(0,0,1,1),this.tainted_=!1}catch{Au=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(pi.CHANGE)}handleImageError_(){this.imageState_=It.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=It.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){let e=this.size_[0],r=this.size_[1],a=Ri(e,r);a.fillRect(0,0,e,r),this.hitDetectionImage_=a.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===It.IDLE){this.image_||this.initializeImage_(),this.imageState_=It.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&Rb(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==It.LOADED)return;let r=this.image_,a=Ri(Math.ceil(r.width*e),Math.ceil(r.height*e)),c=a.canvas;a.scale(e,e),a.drawImage(r,0,0),a.globalCompositeOperation="multiply",a.fillStyle=Eb(this.color_),a.fillRect(0,0,c.width/e,c.height/e),a.globalCompositeOperation="destination-in",a.drawImage(r,0,0),this.canvas_[e]=c}ready(){return this.ready_||(this.ready_=new Promise(e=>{if(this.imageState_===It.LOADED||this.imageState_===It.ERROR)e();else{let r=()=>{(this.imageState_===It.LOADED||this.imageState_===It.ERROR)&&(this.removeEventListener(pi.CHANGE,r),e())};this.addEventListener(pi.CHANGE,r)}})),this.ready_}};function Lc(h,e,r,a,c,s){let y=e===void 0?void 0:Xn.get(e,r,c);return y||(y=new jp(h,h&&"src"in h?h.src||void 0:e,r,a,c),Xn.set(e,r,c,y,s)),s&&y&&!Xn.getPattern(e,r,c)&&Xn.set(e,r,c,y,s),y}var kb=jp;var gy=class h{constructor(e){e=e||{},this.patternImage_=null,this.color_=null,e.color!==void 0&&this.setColor(e.color)}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0})}getColor(){return this.color_}setColor(e){if(e!==null&&typeof e=="object"&&"src"in e){let r=Lc(null,e.src,"anonymous",void 0,e.offset?null:e.color?e.color:null,!(e.offset&&e.size));r.ready().then(()=>{this.patternImage_=null}),r.getImageState()===It.IDLE&&r.load(),r.getImageState()===It.LOADING&&(this.patternImage_=r)}this.color_=e}getKey(){let e=this.getColor();return e?e instanceof CanvasPattern||e instanceof CanvasGradient?Vt(e):typeof e=="object"&&"src"in e?e.src+":"+e.offset:Ms(e).toString():""}loading(){return!!this.patternImage_}ready(){return this.patternImage_?this.patternImage_.ready():Promise.resolve()}},Er=gy;var yy=class h{constructor(e){e=e||{},this.color_=e.color!==void 0?e.color:null,this.lineCap_=e.lineCap,this.lineDash_=e.lineDash!==void 0?e.lineDash:null,this.lineDashOffset_=e.lineDashOffset,this.lineJoin_=e.lineJoin,this.miterLimit_=e.miterLimit,this.width_=e.width}clone(){let e=this.getColor();return new h({color:Array.isArray(e)?e.slice():e||void 0,lineCap:this.getLineCap(),lineDash:this.getLineDash()?this.getLineDash().slice():void 0,lineDashOffset:this.getLineDashOffset(),lineJoin:this.getLineJoin(),miterLimit:this.getMiterLimit(),width:this.getWidth()})}getColor(){return this.color_}getLineCap(){return this.lineCap_}getLineDash(){return this.lineDash_}getLineDashOffset(){return this.lineDashOffset_}getLineJoin(){return this.lineJoin_}getMiterLimit(){return this.miterLimit_}getWidth(){return this.width_}setColor(e){this.color_=e}setLineCap(e){this.lineCap_=e}setLineDash(e){this.lineDash_=e}setLineDashOffset(e){this.lineDashOffset_=e}setLineJoin(e){this.lineJoin_=e}setMiterLimit(e){this.miterLimit_=e}setWidth(e){this.width_=e}},Xi=yy;function qs(h,e){return Array.isArray(h)?h:(e===void 0?e=[h,h]:(e[0]=h,e[1]=h),e)}var _y=class h{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=qs(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return wt()}getImage(e){return wt()}getHitDetectionImage(){return wt()}getPixelRatio(e){return 1}getImageState(){return wt()}getImageSize(){return wt()}getOrigin(){return wt()}getSize(){return wt()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=qs(e)}listenImageChange(e){wt()}load(){wt()}unlistenImageChange(e){wt()}ready(){return Promise.resolve()}},Gp=_y;function Sn(h){return h?Array.isArray(h)?Pu(h):typeof h=="object"&&"src"in h?qI(h):h:null}function qI(h){if(!h.offset||!h.size)return Xn.getPattern(h.src,"anonymous",h.color);let e=h.src+":"+h.offset,r=Xn.getPattern(e,void 0,h.color);if(r)return r;let a=Xn.get(h.src,"anonymous",null);if(a.getImageState()!==It.LOADED)return null;let c=Ri(h.size[0],h.size[1]);return c.drawImage(a.getImage(1),h.offset[0],h.offset[1],h.size[0],h.size[1],0,0,h.size[0],h.size[1]),Lc(c.canvas,e,void 0,It.LOADED,h.color,!0),Xn.getPattern(e,void 0,h.color)}var $I=new RegExp(["^\\s*(?=(?:(?:[-a-z]+\\s*){0,2}(italic|oblique))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(small-caps))?)","(?=(?:(?:[-a-z]+\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)","(?:(?:normal|\\1|\\2|\\3)\\s*){0,3}((?:xx?-)?","(?:small|large)|medium|smaller|larger|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx]))","(?:\\s*\\/\\s*(normal|[\\.\\d]+(?:\\%|in|[cem]m|ex|p[ctx])?))",`?\\s*([-,\\"\\'\\sa-z]+?)\\s*$`].join(""),"i"),Lb=["style","variant","weight","size","lineHeight","family"],xy=function(h){let e=h.match($I);if(!e)return null;let r={lineHeight:"normal",size:"1.2em",style:"normal",weight:"normal",variant:"normal"};for(let a=0,c=Lb.length;a<c;++a){let s=e[a+1];s!==void 0&&(r[Lb[a]]=s)}return r.families=r.family.split(/,\s?/),r};var qp="10px sans-serif",Hi="#000",$s="round",In=[],Cn=0,Ws="round",vo=10,bo="#000",xa="center",pl="middle",wo=[0,0,0,0],So=1,_a=new or,Dc=null,vy,by={},Db=function(){let e="32px ",r=["monospace","serif"],a=r.length,c="wmytzilWMYTZIL@#/&?$%10\uF013",s,y;function v(T,C,k){let O=!0;for(let G=0;G<a;++G){let J=r[G];if(y=Up(T+" "+C+" "+e+J,c),k!=J){let le=Up(T+" "+C+" "+e+k+","+J,c);O=O&&le!=y}}return!!O}function b(){let T=!0,C=_a.getKeys();for(let k=0,O=C.length;k<O;++k){let G=C[k];if(_a.get(G)<100){let[J,le,he]=G.split(`
578
578
  `);v(J,le,he)?(mc(by),Dc=null,vy=void 0,_a.set(G,100)):(_a.set(G,_a.get(G)+1,!0),T=!1)}}T&&(clearInterval(s),s=void 0)}return function(T){let C=xy(T);if(!C)return;let k=C.families;for(let O=0,G=k.length;O<G;++O){let J=k[O],le=C.style+`
579
579
  `+C.weight+`
580
580
  `+J;_a.get(le)===void 0&&(_a.set(le,100,!0),v(C.style,C.weight,J)||(_a.set(le,0,!0),s===void 0&&(s=setInterval(b,32))))}}}(),WI=function(){let h;return function(e){let r=by[e];if(r==null){if(Vp){let a=xy(e),c=Fb(e,"\u017Dg");r=(isNaN(Number(a.lineHeight))?1.2:Number(a.lineHeight))*(c.actualBoundingBoxAscent+c.actualBoundingBoxDescent)}else h||(h=document.createElement("div"),h.innerHTML="M",h.style.minHeight="0",h.style.maxHeight="none",h.style.height="auto",h.style.padding="0",h.style.border="none",h.style.position="absolute",h.style.display="block",h.style.left="-99999px"),h.style.font=e,document.body.appendChild(h),r=h.offsetHeight,document.body.removeChild(h);by[e]=r}return r}}();function Fb(h,e){return Dc||(Dc=Ri(1,1)),h!=vy&&(Dc.font=h,vy=Dc.font),Dc.measureText(e)}function Up(h,e){return Fb(h,e).width}function wy(h,e,r){if(e in r)return r[e];let a=e.split(`
@@ -582,7 +582,7 @@ uniform ${D} ${F} u_${j};
582
582
  `||T===C){s=Math.max(s,y),c.push(y),y=0,v+=b,b=0;continue}let O=e[T+1]||h.font,G=Up(O,k);r.push(G),y+=G;let J=WI(O);a.push(J),b=Math.max(b,J)}return{width:s,height:v,widths:r,heights:a,lineWidths:c}}function Ob(h,e,r,a,c,s,y,v,b,T,C){h.save(),r!==1&&(h.globalAlpha===void 0?h.globalAlpha=k=>k.globalAlpha*=r:h.globalAlpha*=r),e&&h.transform.apply(h,e),a.contextInstructions?(h.translate(b,T),h.scale(C[0],C[1]),ZI(a,h)):C[0]<0||C[1]<0?(h.translate(b,T),h.scale(C[0],C[1]),h.drawImage(a,c,s,y,v,0,0,y,v)):h.drawImage(a,c,s,y,v,b,T,y*C[0],v*C[1]),h.restore()}function ZI(h,e){let r=h.contextInstructions;for(let a=0,c=r.length;a<c;a+=2)Array.isArray(r[a+1])?e[r[a]].apply(e,r[a+1]):e[r[a]]=r[a+1]}var Sy=class h extends Gp{constructor(e){super({opacity:1,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,rotation:e.rotation!==void 0?e.rotation:0,scale:e.scale!==void 0?e.scale:1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode}),this.hitDetectionCanvas_=null,this.fill_=e.fill!==void 0?e.fill:null,this.origin_=[0,0],this.points_=e.points,this.radius=e.radius,this.radius2_=e.radius2,this.angle_=e.angle!==void 0?e.angle:0,this.stroke_=e.stroke!==void 0?e.stroke:null,this.size_,this.renderOptions_,this.imageState_=this.fill_&&this.fill_.loading()?It.LOADING:It.LOADED,this.imageState_===It.LOADING&&this.ready().then(()=>this.imageState_=It.LOADED),this.render()}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,points:this.getPoints(),radius:this.getRadius(),radius2:this.getRadius2(),angle:this.getAngle(),stroke:this.getStroke()?this.getStroke().clone():void 0,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),scale:Array.isArray(e)?e.slice():e,displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}getAnchor(){let e=this.size_,r=this.getDisplacement(),a=this.getScaleArray();return[e[0]/2-r[0]/a[0],e[1]/2+r[1]/a[1]]}getAngle(){return this.angle_}getFill(){return this.fill_}setFill(e){this.fill_=e,this.render()}getHitDetectionImage(){return this.hitDetectionCanvas_||(this.hitDetectionCanvas_=this.createHitDetectionCanvas_(this.renderOptions_)),this.hitDetectionCanvas_}getImage(e){let r=this.fill_?.getKey(),a=`${e},${this.angle_},${this.radius},${this.radius2_},${this.points_},${r}`+Object.values(this.renderOptions_).join(","),c=Xn.get(a,null,null)?.getImage(1);if(!c){let s=this.renderOptions_,y=Math.ceil(s.size*e),v=Ri(y,y);this.draw_(s,v,e),c=v.canvas,Xn.set(a,null,null,new kb(c,void 0,null,It.LOADED,null))}return c}getPixelRatio(e){return e}getImageSize(){return this.size_}getImageState(){return this.imageState_}getOrigin(){return this.origin_}getPoints(){return this.points_}getRadius(){return this.radius}getRadius2(){return this.radius2_}getSize(){return this.size_}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e,this.render()}listenImageChange(e){}load(){}unlistenImageChange(e){}calculateLineJoinSize_(e,r,a){if(r===0||this.points_===1/0||e!=="bevel"&&e!=="miter")return r;let c=this.radius,s=this.radius2_===void 0?c:this.radius2_;if(c<s){let Ee=c;c=s,s=Ee}let y=this.radius2_===void 0?this.points_:this.points_*2,v=2*Math.PI/y,b=s*Math.sin(v),T=Math.sqrt(s*s-b*b),C=c-T,k=Math.sqrt(b*b+C*C),O=k/b;if(e==="miter"&&O<=a)return O*r;let G=r/2/O,J=r/2*(C/k),he=Math.sqrt((c+G)*(c+G)+J*J)-c;if(this.radius2_===void 0||e==="bevel")return he*2;let fe=c*Math.sin(v),ye=Math.sqrt(c*c-fe*fe),we=s-ye,Pe=Math.sqrt(fe*fe+we*we)/fe;if(Pe<=a){let Ee=Pe*r/2-s-c;return 2*Math.max(he,Ee)}return he*2}createRenderOptions(){let e=$s,r=Ws,a=0,c=null,s=0,y,v=0;this.stroke_&&(y=Sn(this.stroke_.getColor()??bo),v=this.stroke_.getWidth()??So,c=this.stroke_.getLineDash(),s=this.stroke_.getLineDashOffset()??0,r=this.stroke_.getLineJoin()??Ws,e=this.stroke_.getLineCap()??$s,a=this.stroke_.getMiterLimit()??vo);let b=this.calculateLineJoinSize_(r,v,a),T=Math.max(this.radius,this.radius2_||0),C=Math.ceil(2*T+b);return{strokeStyle:y,strokeWidth:v,size:C,lineCap:e,lineDash:c,lineDashOffset:s,lineJoin:r,miterLimit:a}}render(){this.renderOptions_=this.createRenderOptions();let e=this.renderOptions_.size;this.hitDetectionCanvas_=null,this.size_=[e,e]}draw_(e,r,a){if(r.scale(a,a),r.translate(e.size/2,e.size/2),this.createPath_(r),this.fill_){let c=this.fill_.getColor();c===null&&(c=Hi),r.fillStyle=Sn(c),r.fill()}e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineCap=e.lineCap,r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}createHitDetectionCanvas_(e){let r;if(this.fill_){let a=this.fill_.getColor(),c=0;typeof a=="string"&&(a=Ms(a)),a===null?c=1:Array.isArray(a)&&(c=a.length===4?a[3]:1),c===0&&(r=Ri(e.size,e.size),this.drawHitDetectionCanvas_(e,r))}return r?r.canvas:this.getImage(1)}createPath_(e){let r=this.points_,a=this.radius;if(r===1/0)e.arc(0,0,a,0,2*Math.PI);else{let c=this.radius2_===void 0?a:this.radius2_;this.radius2_!==void 0&&(r*=2);let s=this.angle_-Math.PI/2,y=2*Math.PI/r;for(let v=0;v<r;v++){let b=s+v*y,T=v%2===0?a:c;e.lineTo(T*Math.cos(b),T*Math.sin(b))}e.closePath()}}drawHitDetectionCanvas_(e,r){r.translate(e.size/2,e.size/2),this.createPath_(r),r.fillStyle=Hi,r.fill(),e.strokeStyle&&(r.strokeStyle=e.strokeStyle,r.lineWidth=e.strokeWidth,e.lineDash&&(r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset),r.lineJoin=e.lineJoin,r.miterLimit=e.miterLimit,r.stroke())}ready(){return this.fill_?this.fill_.ready():Promise.resolve()}},$p=Sy;var Iy=class h extends $p{constructor(e){e=e||{radius:5},super({points:1/0,fill:e.fill,radius:e.radius,stroke:e.stroke,scale:e.scale!==void 0?e.scale:1,rotation:e.rotation!==void 0?e.rotation:0,rotateWithView:e.rotateWithView!==void 0?e.rotateWithView:!1,displacement:e.displacement!==void 0?e.displacement:[0,0],declutterMode:e.declutterMode})}clone(){let e=this.getScale(),r=new h({fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,radius:this.getRadius(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()});return r.setOpacity(this.getOpacity()),r}setRadius(e){this.radius=e,this.render()}},En=Iy;var va=class h{constructor(e){e=e||{},this.geometry_=null,this.geometryFunction_=Bb,e.geometry!==void 0&&this.setGeometry(e.geometry),this.fill_=e.fill!==void 0?e.fill:null,this.image_=e.image!==void 0?e.image:null,this.renderer_=e.renderer!==void 0?e.renderer:null,this.hitDetectionRenderer_=e.hitDetectionRenderer!==void 0?e.hitDetectionRenderer:null,this.stroke_=e.stroke!==void 0?e.stroke:null,this.text_=e.text!==void 0?e.text:null,this.zIndex_=e.zIndex}clone(){let e=this.getGeometry();return e&&typeof e=="object"&&(e=e.clone()),new h({geometry:e??void 0,fill:this.getFill()?this.getFill().clone():void 0,image:this.getImage()?this.getImage().clone():void 0,renderer:this.getRenderer()??void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,text:this.getText()?this.getText().clone():void 0,zIndex:this.getZIndex()})}getRenderer(){return this.renderer_}setRenderer(e){this.renderer_=e}setHitDetectionRenderer(e){this.hitDetectionRenderer_=e}getHitDetectionRenderer(){return this.hitDetectionRenderer_}getGeometry(){return this.geometry_}getGeometryFunction(){return this.geometryFunction_}getFill(){return this.fill_}setFill(e){this.fill_=e}getImage(){return this.image_}setImage(e){this.image_=e}getStroke(){return this.stroke_}setStroke(e){this.stroke_=e}getText(){return this.text_}setText(e){this.text_=e}getZIndex(){return this.zIndex_}setGeometry(e){typeof e=="function"?this.geometryFunction_=e:typeof e=="string"?this.geometryFunction_=function(r){return r.get(e)}:e?e!==void 0&&(this.geometryFunction_=function(){return e}):this.geometryFunction_=Bb,this.geometry_=e}setZIndex(e){this.zIndex_=e}};function Nb(h){let e;if(typeof h=="function")e=h;else{let r;Array.isArray(h)?r=h:(ui(typeof h.getZIndex=="function","Expected an `Style` or an array of `Style`"),r=[h]),e=function(){return r}}return e}var Cy=null;function Ey(h,e){if(!Cy){let r=new Er({color:"rgba(255,255,255,0.4)"}),a=new Xi({color:"#3399CC",width:1.25});Cy=[new va({image:new En({fill:r,stroke:a,radius:5}),fill:r,stroke:a})]}return Cy}function Vb(){let h={},e=[255,255,255,1],r=[0,153,255,1],a=3;return h.Polygon=[new va({fill:new Er({color:[255,255,255,.5]})})],h.MultiPolygon=h.Polygon,h.LineString=[new va({stroke:new Xi({color:e,width:a+2})}),new va({stroke:new Xi({color:r,width:a})})],h.MultiLineString=h.LineString,h.Circle=h.Polygon.concat(h.LineString),h.Point=[new va({image:new En({radius:a*2,fill:new Er({color:r}),stroke:new Xi({color:e,width:a/2})}),zIndex:1/0})],h.MultiPoint=h.Point,h.GeometryCollection=h.Polygon.concat(h.LineString,h.Point),h}function Bb(h){return h.getGeometry()}var Tr=va;var XI="#333",Ty=class h{constructor(e){e=e||{},this.font_=e.font,this.rotation_=e.rotation,this.rotateWithView_=e.rotateWithView,this.keepUpright_=e.keepUpright,this.scale_=e.scale,this.scaleArray_=qs(e.scale!==void 0?e.scale:1),this.text_=e.text,this.textAlign_=e.textAlign,this.justify_=e.justify,this.repeat_=e.repeat,this.textBaseline_=e.textBaseline,this.fill_=e.fill!==void 0?e.fill:new Er({color:XI}),this.maxAngle_=e.maxAngle!==void 0?e.maxAngle:Math.PI/4,this.placement_=e.placement!==void 0?e.placement:"point",this.overflow_=!!e.overflow,this.stroke_=e.stroke!==void 0?e.stroke:null,this.offsetX_=e.offsetX!==void 0?e.offsetX:0,this.offsetY_=e.offsetY!==void 0?e.offsetY:0,this.backgroundFill_=e.backgroundFill?e.backgroundFill:null,this.backgroundStroke_=e.backgroundStroke?e.backgroundStroke:null,this.padding_=e.padding===void 0?null:e.padding,this.declutterMode_=e.declutterMode}clone(){let e=this.getScale();return new h({font:this.getFont(),placement:this.getPlacement(),repeat:this.getRepeat(),maxAngle:this.getMaxAngle(),overflow:this.getOverflow(),rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),keepUpright:this.getKeepUpright(),scale:Array.isArray(e)?e.slice():e,text:this.getText(),textAlign:this.getTextAlign(),justify:this.getJustify(),textBaseline:this.getTextBaseline(),fill:this.getFill()?this.getFill().clone():void 0,stroke:this.getStroke()?this.getStroke().clone():void 0,offsetX:this.getOffsetX(),offsetY:this.getOffsetY(),backgroundFill:this.getBackgroundFill()?this.getBackgroundFill().clone():void 0,backgroundStroke:this.getBackgroundStroke()?this.getBackgroundStroke().clone():void 0,padding:this.getPadding()||void 0,declutterMode:this.getDeclutterMode()})}getOverflow(){return this.overflow_}getFont(){return this.font_}getMaxAngle(){return this.maxAngle_}getPlacement(){return this.placement_}getRepeat(){return this.repeat_}getOffsetX(){return this.offsetX_}getOffsetY(){return this.offsetY_}getFill(){return this.fill_}getRotateWithView(){return this.rotateWithView_}getKeepUpright(){return this.keepUpright_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getStroke(){return this.stroke_}getText(){return this.text_}getTextAlign(){return this.textAlign_}getJustify(){return this.justify_}getTextBaseline(){return this.textBaseline_}getBackgroundFill(){return this.backgroundFill_}getBackgroundStroke(){return this.backgroundStroke_}getPadding(){return this.padding_}getDeclutterMode(){return this.declutterMode_}setOverflow(e){this.overflow_=e}setFont(e){this.font_=e}setMaxAngle(e){this.maxAngle_=e}setOffsetX(e){this.offsetX_=e}setOffsetY(e){this.offsetY_=e}setPlacement(e){this.placement_=e}setRepeat(e){this.repeat_=e}setRotateWithView(e){this.rotateWithView_=e}setKeepUpright(e){this.keepUpright_=e}setFill(e){this.fill_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=qs(e!==void 0?e:1)}setStroke(e){this.stroke_=e}setText(e){this.text_=e}setTextAlign(e){this.textAlign_=e}setJustify(e){this.justify_=e}setTextBaseline(e){this.textBaseline_=e}setBackgroundFill(e){this.backgroundFill_=e}setBackgroundStroke(e){this.backgroundStroke_=e}setPadding(e){this.padding_=e}},jb=Ty;function Wp(h,e,r=0,a=h.length-1,c=HI){for(;a>r;){if(a-r>600){let b=a-r+1,T=e-r+1,C=Math.log(b),k=.5*Math.exp(2*C/3),O=.5*Math.sqrt(C*k*(b-k)/b)*(T-b/2<0?-1:1),G=Math.max(r,Math.floor(e-T*k/b+O)),J=Math.min(a,Math.floor(e+(b-T)*k/b+O));Wp(h,e,G,J,c)}let s=h[e],y=r,v=a;for(Ru(h,r,e),c(h[a],s)>0&&Ru(h,r,a);y<v;){for(Ru(h,y,v),y++,v--;c(h[y],s)<0;)y++;for(;c(h[v],s)>0;)v--}c(h[r],s)===0?Ru(h,r,v):(v++,Ru(h,v,a)),v<=e&&(r=v+1),e<=v&&(a=v-1)}}function Ru(h,e,r){let a=h[e];h[e]=h[r],h[r]=a}function HI(h,e){return h<e?-1:h>e?1:0}var fl=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let r=this.data,a=[];if(!Xp(e,r))return a;let c=this.toBBox,s=[];for(;r;){for(let y=0;y<r.children.length;y++){let v=r.children[y],b=r.leaf?c(v):v;Xp(e,b)&&(r.leaf?a.push(v):Py(e,b)?this._all(v,a):s.push(v))}r=s.pop()}return a}collides(e){let r=this.data;if(!Xp(e,r))return!1;let a=[];for(;r;){for(let c=0;c<r.children.length;c++){let s=r.children[c],y=r.leaf?this.toBBox(s):s;if(Xp(e,y)){if(r.leaf||Py(e,y))return!0;a.push(s)}}r=a.pop()}return!1}load(e){if(!(e&&e.length))return this;if(e.length<this._minEntries){for(let a=0;a<e.length;a++)this.insert(e[a]);return this}let r=this._build(e.slice(),0,e.length-1,0);if(!this.data.children.length)this.data=r;else if(this.data.height===r.height)this._splitRoot(this.data,r);else{if(this.data.height<r.height){let a=this.data;this.data=r,r=a}this._insert(r,this.data.height-r.height-1,!0)}return this}insert(e){return e&&this._insert(e,this.data.height-1),this}clear(){return this.data=zc([]),this}remove(e,r){if(!e)return this;let a=this.data,c=this.toBBox(e),s=[],y=[],v,b,T;for(;a||s.length;){if(a||(a=s.pop(),b=s[s.length-1],v=y.pop(),T=!0),a.leaf){let C=KI(e,a.children,r);if(C!==-1)return a.children.splice(C,1),s.push(a),this._condense(s),this}!T&&!a.leaf&&Py(a,c)?(s.push(a),y.push(v),v=0,b=a,a=a.children[0]):b?(v++,a=b.children[v],T=!1):a=null}return this}toBBox(e){return e}compareMinX(e,r){return e.minX-r.minX}compareMinY(e,r){return e.minY-r.minY}toJSON(){return this.data}fromJSON(e){return this.data=e,this}_all(e,r){let a=[];for(;e;)e.leaf?r.push(...e.children):a.push(...e.children),e=a.pop();return r}_build(e,r,a,c){let s=a-r+1,y=this._maxEntries,v;if(s<=y)return v=zc(e.slice(r,a+1)),Fc(v,this.toBBox),v;c||(c=Math.ceil(Math.log(s)/Math.log(y)),y=Math.ceil(s/Math.pow(y,c-1))),v=zc([]),v.leaf=!1,v.height=c;let b=Math.ceil(s/y),T=b*Math.ceil(Math.sqrt(y));Gb(e,r,a,T,this.compareMinX);for(let C=r;C<=a;C+=T){let k=Math.min(C+T-1,a);Gb(e,C,k,b,this.compareMinY);for(let O=C;O<=k;O+=b){let G=Math.min(O+b-1,k);v.children.push(this._build(e,O,G,c-1))}}return Fc(v,this.toBBox),v}_chooseSubtree(e,r,a,c){for(;c.push(r),!(r.leaf||c.length-1===a);){let s=1/0,y=1/0,v;for(let b=0;b<r.children.length;b++){let T=r.children[b],C=My(T),k=QI(e,T)-C;k<y?(y=k,s=C<s?C:s,v=T):k===y&&C<s&&(s=C,v=T)}r=v||r.children[0]}return r}_insert(e,r,a){let c=a?e:this.toBBox(e),s=[],y=this._chooseSubtree(c,this.data,r,s);for(y.children.push(e),Lu(y,c);r>=0&&s[r].children.length>this._maxEntries;)this._split(s,r),r--;this._adjustParentBBoxes(c,s,r)}_split(e,r){let a=e[r],c=a.children.length,s=this._minEntries;this._chooseSplitAxis(a,s,c);let y=this._chooseSplitIndex(a,s,c),v=zc(a.children.splice(y,a.children.length-y));v.height=a.height,v.leaf=a.leaf,Fc(a,this.toBBox),Fc(v,this.toBBox),r?e[r-1].children.push(v):this._splitRoot(a,v)}_splitRoot(e,r){this.data=zc([e,r]),this.data.height=e.height+1,this.data.leaf=!1,Fc(this.data,this.toBBox)}_chooseSplitIndex(e,r,a){let c,s=1/0,y=1/0;for(let v=r;v<=a-r;v++){let b=ku(e,0,v,this.toBBox),T=ku(e,v,a,this.toBBox),C=eC(b,T),k=My(b)+My(T);C<s?(s=C,c=v,y=k<y?k:y):C===s&&k<y&&(y=k,c=v)}return c||a-r}_chooseSplitAxis(e,r,a){let c=e.leaf?this.compareMinX:YI,s=e.leaf?this.compareMinY:JI,y=this._allDistMargin(e,r,a,c),v=this._allDistMargin(e,r,a,s);y<v&&e.children.sort(c)}_allDistMargin(e,r,a,c){e.children.sort(c);let s=this.toBBox,y=ku(e,0,r,s),v=ku(e,a-r,a,s),b=Zp(y)+Zp(v);for(let T=r;T<a-r;T++){let C=e.children[T];Lu(y,e.leaf?s(C):C),b+=Zp(y)}for(let T=a-r-1;T>=r;T--){let C=e.children[T];Lu(v,e.leaf?s(C):C),b+=Zp(v)}return b}_adjustParentBBoxes(e,r,a){for(let c=a;c>=0;c--)Lu(r[c],e)}_condense(e){for(let r=e.length-1,a;r>=0;r--)e[r].children.length===0?r>0?(a=e[r-1].children,a.splice(a.indexOf(e[r]),1)):this.clear():Fc(e[r],this.toBBox)}};function KI(h,e,r){if(!r)return e.indexOf(h);for(let a=0;a<e.length;a++)if(r(h,e[a]))return a;return-1}function Fc(h,e){ku(h,0,h.children.length,e,h)}function ku(h,e,r,a,c){c||(c=zc(null)),c.minX=1/0,c.minY=1/0,c.maxX=-1/0,c.maxY=-1/0;for(let s=e;s<r;s++){let y=h.children[s];Lu(c,h.leaf?a(y):y)}return c}function Lu(h,e){return h.minX=Math.min(h.minX,e.minX),h.minY=Math.min(h.minY,e.minY),h.maxX=Math.max(h.maxX,e.maxX),h.maxY=Math.max(h.maxY,e.maxY),h}function YI(h,e){return h.minX-e.minX}function JI(h,e){return h.minY-e.minY}function My(h){return(h.maxX-h.minX)*(h.maxY-h.minY)}function Zp(h){return h.maxX-h.minX+(h.maxY-h.minY)}function QI(h,e){return(Math.max(e.maxX,h.maxX)-Math.min(e.minX,h.minX))*(Math.max(e.maxY,h.maxY)-Math.min(e.minY,h.minY))}function eC(h,e){let r=Math.max(h.minX,e.minX),a=Math.max(h.minY,e.minY),c=Math.min(h.maxX,e.maxX),s=Math.min(h.maxY,e.maxY);return Math.max(0,c-r)*Math.max(0,s-a)}function Py(h,e){return h.minX<=e.minX&&h.minY<=e.minY&&e.maxX<=h.maxX&&e.maxY<=h.maxY}function Xp(h,e){return e.minX<=h.maxX&&e.minY<=h.maxY&&e.maxX>=h.minX&&e.maxY>=h.minY}function zc(h){return{children:h,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Gb(h,e,r,a,c){let s=[e,r];for(;s.length;){if(r=s.pop(),e=s.pop(),r-e<=a)continue;let y=e+Math.ceil((r-e)/a/2)*a;Wp(h,y,e,r,c),s.push(e,y,y,r)}}function Ub(h,e,r,a){return r!==void 0&&a!==void 0?[r/h,a/e]:r!==void 0?r/h:a!==void 0?a/e:1}var Ay=class h extends Gp{constructor(e){e=e||{};let r=e.opacity!==void 0?e.opacity:1,a=e.rotation!==void 0?e.rotation:0,c=e.scale!==void 0?e.scale:1,s=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:r,rotation:a,scale:c,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:s,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;let y=e.img!==void 0?e.img:null,v=e.src;ui(!(v!==void 0&&y),"`image` and `src` cannot be provided at the same time"),(v===void 0||v.length===0)&&y&&(v=y.src||Vt(y)),ui(v!==void 0&&v.length>0,"A defined and non-empty `src` or `image` must be provided"),ui(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let b;if(e.src!==void 0?b=It.IDLE:y!==void 0&&("complete"in y?y.complete?b=y.src?It.LOADED:It.IDLE:b=It.LOADING:b=It.LOADED),this.color_=e.color!==void 0?Ms(e.color):null,this.iconImage_=Lc(y,v,this.crossOrigin_,b,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,this.initialOptions_,e.width!==void 0||e.height!==void 0){let T,C;if(e.size)[T,C]=e.size;else{let k=this.getImage(1);if(k.width&&k.height)T=k.width,C=k.height;else if(k instanceof HTMLImageElement){this.initialOptions_=e;let O=()=>{if(this.unlistenImageChange(O),!this.initialOptions_)return;let G=this.iconImage_.getSize();this.setScale(Ub(G[0],G[1],e.width,e.height))};this.listenImageChange(O);return}}T!==void 0&&this.setScale(Ub(T,C,e.width,e.height))}}clone(){let e,r,a;return this.initialOptions_?(r=this.initialOptions_.width,a=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new h({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:r,height:a,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;let c=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!c)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=c[0]),this.anchorYUnits_=="fraction"&&(e[1]*=c[1])}if(this.anchorOrigin_!="top-left"){if(!c)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+c[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+c[1])}this.normalizedAnchor_=e}let r=this.getDisplacement(),a=this.getScaleArray();return[e[0]-r[0]/a[0],e[1]+r[1]/a[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){let r=this.getSize(),a=this.iconImage_.getSize();if(!r||!a)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=a[0]-r[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=a[1]-r[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){let e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==It.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){let e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==It.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(pi.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(pi.CHANGE,e)}ready(){return this.iconImage_.ready()}},Du=Ay;var ml=0;var Gr=1<<ml++,Ut=1<<ml++,tn=1<<ml++,Hn=1<<ml++,wa=1<<ml++,Fu=1<<ml++,Hp=Math.pow(2,ml)-1,ky={[Gr]:"boolean",[Ut]:"number",[tn]:"string",[Hn]:"color",[wa]:"number[]",[Fu]:"size"},tC=Object.keys(ky).map(Number).sort(xs);function iC(h){return h in ky}function zu(h){let e=[];for(let r of tC)Ou(h,r)&&e.push(ky[r]);return e.length===0?"untyped":e.length<3?e.join(" or "):e.slice(0,-1).join(", ")+", or "+e[e.length-1]}function Ou(h,e){return(h&e)===e}function ba(h,e){return h===e}var ki=class{constructor(e,r){if(!iC(e))throw new Error(`literal expressions must have a specific type, got ${zu(e)}`);this.type=e,this.value=r}},Ry=class{constructor(e,r,...a){this.type=e,this.operator=r,this.args=a}};function Ly(){return{variables:new Set,properties:new Set,featureId:!1,geometryType:!1}}function cr(h,e,r){switch(typeof h){case"boolean":{if(ba(e,tn))return new ki(tn,h?"true":"false");if(!Ou(e,Gr))throw new Error(`got a boolean, but expected ${zu(e)}`);return new ki(Gr,h)}case"number":{if(ba(e,Fu))return new ki(Fu,qs(h));if(ba(e,Gr))return new ki(Gr,!!h);if(ba(e,tn))return new ki(tn,h.toString());if(!Ou(e,Ut))throw new Error(`got a number, but expected ${zu(e)}`);return new ki(Ut,h)}case"string":{if(ba(e,Hn))return new ki(Hn,Mu(h));if(ba(e,Gr))return new ki(Gr,!!h);if(!Ou(e,tn))throw new Error(`got a string, but expected ${zu(e)}`);return new ki(tn,h)}default:}if(!Array.isArray(h))throw new Error("expression must be an array or a primitive value");if(h.length===0)throw new Error("empty expression");if(typeof h[0]=="string")return pC(h,e,r);for(let a of h)if(typeof a!="number")throw new Error("expected an array of numbers");if(ba(e,Fu)){if(h.length!==2)throw new Error(`expected an array of two values for a size, got ${h.length}`);return new ki(Fu,h)}if(ba(e,Hn)){if(h.length===3)return new ki(Hn,[...h,1]);if(h.length===4)return new ki(Hn,h);throw new Error(`expected an array of 3 or 4 values for a color, got ${h.length}`)}if(!Ou(e,wa))throw new Error(`got an array of numbers, but expected ${zu(e)}`);return new ki(wa,h)}var Me={Get:"get",Var:"var",Concat:"concat",GeometryType:"geometry-type",LineMetric:"line-metric",Any:"any",All:"all",Not:"!",Resolution:"resolution",Zoom:"zoom",Time:"time",Equal:"==",NotEqual:"!=",GreaterThan:">",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match",Between:"between",Interpolate:"interpolate",Coalesce:"coalesce",Case:"case",In:"in",Number:"number",String:"string",Array:"array",Color:"color",Id:"id",Band:"band",Palette:"palette",ToString:"to-string",Has:"has"},rC={[Me.Get]:Et(zt(1,1/0),qb),[Me.Var]:Et(zt(1,1),nC),[Me.Has]:Et(zt(1,1/0),qb),[Me.Id]:Et(sC,Oc),[Me.Concat]:Et(zt(2,1/0),ei(tn)),[Me.GeometryType]:Et(oC,Oc),[Me.LineMetric]:Et(Oc),[Me.Resolution]:Et(Oc),[Me.Zoom]:Et(Oc),[Me.Time]:Et(Oc),[Me.Any]:Et(zt(2,1/0),ei(Gr)),[Me.All]:Et(zt(2,1/0),ei(Gr)),[Me.Not]:Et(zt(1,1),ei(Gr)),[Me.Equal]:Et(zt(2,2),ei(Hp)),[Me.NotEqual]:Et(zt(2,2),ei(Hp)),[Me.GreaterThan]:Et(zt(2,2),ei(Ut)),[Me.GreaterThanOrEqualTo]:Et(zt(2,2),ei(Ut)),[Me.LessThan]:Et(zt(2,2),ei(Ut)),[Me.LessThanOrEqualTo]:Et(zt(2,2),ei(Ut)),[Me.Multiply]:Et(zt(2,1/0),$b),[Me.Coalesce]:Et(zt(2,1/0),$b),[Me.Divide]:Et(zt(2,2),ei(Ut)),[Me.Add]:Et(zt(2,1/0),ei(Ut)),[Me.Subtract]:Et(zt(2,2),ei(Ut)),[Me.Clamp]:Et(zt(3,3),ei(Ut)),[Me.Mod]:Et(zt(2,2),ei(Ut)),[Me.Pow]:Et(zt(2,2),ei(Ut)),[Me.Abs]:Et(zt(1,1),ei(Ut)),[Me.Floor]:Et(zt(1,1),ei(Ut)),[Me.Ceil]:Et(zt(1,1),ei(Ut)),[Me.Round]:Et(zt(1,1),ei(Ut)),[Me.Sin]:Et(zt(1,1),ei(Ut)),[Me.Cos]:Et(zt(1,1),ei(Ut)),[Me.Atan]:Et(zt(1,2),ei(Ut)),[Me.Sqrt]:Et(zt(1,1),ei(Ut)),[Me.Match]:Et(zt(4,1/0),Wb,lC),[Me.Between]:Et(zt(3,3),ei(Ut)),[Me.Interpolate]:Et(zt(6,1/0),Wb,cC),[Me.Case]:Et(zt(3,1/0),aC,hC),[Me.In]:Et(zt(2,2),uC),[Me.Number]:Et(zt(1,1/0),ei(Hp)),[Me.String]:Et(zt(1,1/0),ei(Hp)),[Me.Array]:Et(zt(1,1/0),ei(Ut)),[Me.Color]:Et(zt(1,4),ei(Ut)),[Me.Band]:Et(zt(1,3),ei(Ut)),[Me.Palette]:Et(zt(2,2),dC),[Me.ToString]:Et(zt(1,1),ei(Gr|Ut|tn|Hn))};function qb(h,e,r){let a=h.length-1,c=new Array(a);for(let s=0;s<a;++s){let y=h[s+1];switch(typeof y){case"number":{c[s]=new ki(Ut,y);break}case"string":{c[s]=new ki(tn,y);break}default:throw new Error(`expected a string key or numeric array index for a get operation, got ${y}`)}s===0&&r.properties.add(String(y))}return c}function nC(h,e,r){let a=h[1];if(typeof a!="string")throw new Error("expected a string argument for var operation");return r.variables.add(a),[new ki(tn,a)]}function sC(h,e,r){r.featureId=!0}function oC(h,e,r){r.geometryType=!0}function Oc(h,e,r){let a=h[0];if(h.length!==1)throw new Error(`expected no arguments for ${a} operation`);return[]}function zt(h,e){return function(r,a,c){let s=r[0],y=r.length-1;if(h===e){if(y!==h){let v=h===1?"":"s";throw new Error(`expected ${h} argument${v} for ${s}, got ${y}`)}}else if(y<h||y>e){let v=e===1/0?`${h} or more`:`${h} to ${e}`;throw new Error(`expected ${v} arguments for ${s}, got ${y}`)}}}function $b(h,e,r){let a=h.length-1,c=new Array(a);for(let s=0;s<a;++s){let y=cr(h[s+1],e,r);c[s]=y}return c}function ei(h){return function(e,r,a){let c=e.length-1,s=new Array(c);for(let y=0;y<c;++y){let v=cr(e[y+1],h,a);s[y]=v}return s}}function aC(h,e,r){let a=h[0],c=h.length-1;if(c%2===0)throw new Error(`expected an odd number of arguments for ${a}, got ${c} instead`)}function Wb(h,e,r){let a=h[0],c=h.length-1;if(c%2===1)throw new Error(`expected an even number of arguments for operation ${a}, got ${c} instead`)}function lC(h,e,r){let a=h.length-1,c=tn|Ut|Gr,s=cr(h[1],c,r),y=cr(h[h.length-1],e,r),v=new Array(a-2);for(let b=0;b<a-2;b+=2){try{let T=cr(h[b+2],s.type,r);v[b]=T}catch(T){throw new Error(`failed to parse argument ${b+1} of match expression: ${T.message}`)}try{let T=cr(h[b+3],y.type,r);v[b+1]=T}catch(T){throw new Error(`failed to parse argument ${b+2} of match expression: ${T.message}`)}}return[s,...v,y]}function cC(h,e,r){let a=h[1],c;switch(a[0]){case"linear":c=1;break;case"exponential":let b=a[1];if(typeof b!="number"||b<=0)throw new Error(`expected a number base for exponential interpolation, got ${JSON.stringify(b)} instead`);c=b;break;default:throw new Error(`invalid interpolation type: ${JSON.stringify(a)}`)}let s=new ki(Ut,c),y;try{y=cr(h[2],Ut,r)}catch(b){throw new Error(`failed to parse argument 1 in interpolate expression: ${b.message}`)}let v=new Array(h.length-3);for(let b=0;b<v.length;b+=2){try{let T=cr(h[b+3],Ut,r);v[b]=T}catch(T){throw new Error(`failed to parse argument ${b+2} for interpolate expression: ${T.message}`)}try{let T=cr(h[b+4],e,r);v[b+1]=T}catch(T){throw new Error(`failed to parse argument ${b+3} for interpolate expression: ${T.message}`)}}return[s,y,...v]}function hC(h,e,r){let a=cr(h[h.length-1],e,r),c=new Array(h.length-1);for(let s=0;s<c.length-1;s+=2){try{let y=cr(h[s+1],Gr,r);c[s]=y}catch(y){throw new Error(`failed to parse argument ${s} of case expression: ${y.message}`)}try{let y=cr(h[s+2],a.type,r);c[s+1]=y}catch(y){throw new Error(`failed to parse argument ${s+1} of case expression: ${y.message}`)}}return c[c.length-1]=a,c}function uC(h,e,r){let a=h[2];if(!Array.isArray(a))throw new Error('the second argument for the "in" operator must be an array');let c;if(typeof a[0]=="string"){if(a[0]!=="literal")throw new Error('for the "in" operator, a string array should be wrapped in a "literal" operator to disambiguate from expressions');if(!Array.isArray(a[1]))throw new Error('failed to parse "in" expression: the literal operator must be followed by an array');a=a[1],c=tn}else c=Ut;let s=new Array(a.length);for(let v=0;v<s.length;v++)try{let b=cr(a[v],c,r);s[v]=b}catch(b){throw new Error(`failed to parse haystack item ${v} for "in" expression: ${b.message}`)}return[cr(h[1],c,r),...s]}function dC(h,e,r){let a;try{a=cr(h[1],Ut,r)}catch(y){throw new Error(`failed to parse first argument in palette expression: ${y.message}`)}let c=h[2];if(!Array.isArray(c))throw new Error("the second argument of palette must be an array");let s=new Array(c.length);for(let y=0;y<s.length;y++){let v;try{v=cr(c[y],Hn,r)}catch(b){throw new Error(`failed to parse color at index ${y} in palette expression: ${b.message}`)}if(!(v instanceof ki))throw new Error(`the palette color at index ${y} must be a literal value`);s[y]=v}return[a,...s]}function Et(...h){return function(e,r,a){let c=e[0],s;for(let y=0;y<h.length;y++){let v=h[y](e,r,a);if(y==h.length-1){if(!v)throw new Error("expected last argument validator to return the parsed args");s=v}}return new Ry(r,c,...s)}}function pC(h,e,r){let a=h[0],c=rC[a];if(!c)throw new Error(`unknown operator: ${a}`);return c(h,e,r)}function Dy(h){if(!h)return"";let e=h.getType();switch(e){case"Point":case"LineString":case"Polygon":return e;case"MultiPoint":case"MultiLineString":case"MultiPolygon":return e.substring(5);case"Circle":return"Polygon";case"GeometryCollection":return Dy(h.getGeometries()[0]);default:return""}}function Fy(){return{variables:{},properties:{},resolution:NaN,featureId:null,geometryType:""}}function Zs(h,e,r){let a=cr(h,e,r);return Ps(a,r)}function Ps(h,e){if(h instanceof ki){if(h.type===Hn&&typeof h.value=="string"){let a=Mu(h.value);return function(){return a}}return function(){return h.value}}let r=h.operator;switch(r){case Me.Number:case Me.String:case Me.Coalesce:return fC(h,e);case Me.Get:case Me.Var:case Me.Has:return mC(h,e);case Me.Id:return a=>a.featureId;case Me.GeometryType:return a=>a.geometryType;case Me.Concat:{let a=h.args.map(c=>Ps(c,e));return c=>"".concat(...a.map(s=>s(c).toString()))}case Me.Resolution:return a=>a.resolution;case Me.Any:case Me.All:case Me.Between:case Me.In:case Me.Not:return yC(h,e);case Me.Equal:case Me.NotEqual:case Me.LessThan:case Me.LessThanOrEqualTo:case Me.GreaterThan:case Me.GreaterThanOrEqualTo:return gC(h,e);case Me.Multiply:case Me.Divide:case Me.Add:case Me.Subtract:case Me.Clamp:case Me.Mod:case Me.Pow:case Me.Abs:case Me.Floor:case Me.Ceil:case Me.Round:case Me.Sin:case Me.Cos:case Me.Atan:case Me.Sqrt:return _C(h,e);case Me.Case:return xC(h,e);case Me.Match:return vC(h,e);case Me.Interpolate:return bC(h,e);case Me.ToString:return wC(h,e);default:throw new Error(`Unsupported operator ${r}`)}}function fC(h,e){let r=h.operator,a=h.args.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Ps(h.args[s],e);switch(r){case Me.Coalesce:return s=>{for(let y=0;y<a;++y){let v=c[y](s);if(typeof v<"u"&&v!==null)return v}throw new Error("Expected one of the values to be non-null")};case Me.Number:case Me.String:return s=>{for(let y=0;y<a;++y){let v=c[y](s);if(typeof v===r)return v}throw new Error(`Expected one of the values to be a ${r}`)};default:throw new Error(`Unsupported assertion operator ${r}`)}}function mC(h,e){let a=h.args[0].value;switch(h.operator){case Me.Get:return c=>{let s=h.args,y=c.properties[a];for(let v=1,b=s.length;v<b;++v){let C=s[v].value;y=y[C]}return y};case Me.Var:return c=>c.variables[a];case Me.Has:return c=>{let s=h.args;if(!(a in c.properties))return!1;let y=c.properties[a];for(let v=1,b=s.length;v<b;++v){let C=s[v].value;if(!y||!Object.hasOwn(y,C))return!1;y=y[C]}return!0};default:throw new Error(`Unsupported accessor operator ${h.operator}`)}}function gC(h,e){let r=h.operator,a=Ps(h.args[0],e),c=Ps(h.args[1],e);switch(r){case Me.Equal:return s=>a(s)===c(s);case Me.NotEqual:return s=>a(s)!==c(s);case Me.LessThan:return s=>a(s)<c(s);case Me.LessThanOrEqualTo:return s=>a(s)<=c(s);case Me.GreaterThan:return s=>a(s)>c(s);case Me.GreaterThanOrEqualTo:return s=>a(s)>=c(s);default:throw new Error(`Unsupported comparison operator ${r}`)}}function yC(h,e){let r=h.operator,a=h.args.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Ps(h.args[s],e);switch(r){case Me.Any:return s=>{for(let y=0;y<a;++y)if(c[y](s))return!0;return!1};case Me.All:return s=>{for(let y=0;y<a;++y)if(!c[y](s))return!1;return!0};case Me.Between:return s=>{let y=c[0](s),v=c[1](s),b=c[2](s);return y>=v&&y<=b};case Me.In:return s=>{let y=c[0](s);for(let v=1;v<a;++v)if(y===c[v](s))return!0;return!1};case Me.Not:return s=>!c[0](s);default:throw new Error(`Unsupported logical operator ${r}`)}}function _C(h,e){let r=h.operator,a=h.args.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Ps(h.args[s],e);switch(r){case Me.Multiply:return s=>{let y=1;for(let v=0;v<a;++v)y*=c[v](s);return y};case Me.Divide:return s=>c[0](s)/c[1](s);case Me.Add:return s=>{let y=0;for(let v=0;v<a;++v)y+=c[v](s);return y};case Me.Subtract:return s=>c[0](s)-c[1](s);case Me.Clamp:return s=>{let y=c[0](s),v=c[1](s);if(y<v)return v;let b=c[2](s);return y>b?b:y};case Me.Mod:return s=>c[0](s)%c[1](s);case Me.Pow:return s=>Math.pow(c[0](s),c[1](s));case Me.Abs:return s=>Math.abs(c[0](s));case Me.Floor:return s=>Math.floor(c[0](s));case Me.Ceil:return s=>Math.ceil(c[0](s));case Me.Round:return s=>Math.round(c[0](s));case Me.Sin:return s=>Math.sin(c[0](s));case Me.Cos:return s=>Math.cos(c[0](s));case Me.Atan:return a===2?s=>Math.atan2(c[0](s),c[1](s)):s=>Math.atan(c[0](s));case Me.Sqrt:return s=>Math.sqrt(c[0](s));default:throw new Error(`Unsupported numeric operator ${r}`)}}function xC(h,e){let r=h.args.length,a=new Array(r);for(let c=0;c<r;++c)a[c]=Ps(h.args[c],e);return c=>{for(let s=0;s<r-1;s+=2)if(a[s](c))return a[s+1](c);return a[r-1](c)}}function vC(h,e){let r=h.args.length,a=new Array(r);for(let c=0;c<r;++c)a[c]=Ps(h.args[c],e);return c=>{let s=a[0](c);for(let y=1;y<r;y+=2)if(s===a[y](c))return a[y+1](c);return a[r-1](c)}}function bC(h,e){let r=h.args.length,a=new Array(r);for(let c=0;c<r;++c)a[c]=Ps(h.args[c],e);return c=>{let s=a[0](c),y=a[1](c),v,b;for(let T=2;T<r;T+=2){let C=a[T](c),k=a[T+1](c),O=Array.isArray(k);if(O&&(k=Tb(k)),C>=y)return T===2?k:O?SC(s,y,v,b,C,k):Bu(s,y,v,b,C,k);v=C,b=k}return b}}function wC(h,e){let r=h.operator,a=h.args.length,c=new Array(a);for(let s=0;s<a;++s)c[s]=Ps(h.args[s],e);switch(r){case Me.ToString:return s=>{let y=c[0](s);return h.args[0].type===Hn?Pu(y):y.toString()};default:throw new Error(`Unsupported convert operator ${r}`)}}function Bu(h,e,r,a,c,s){let y=c-r;if(y===0)return a;let v=e-r,b=h===1?v/y:(Math.pow(h,v)-1)/(Math.pow(h,y)-1);return a+b*(s-a)}function SC(h,e,r,a,c,s){if(c-r===0)return a;let v=uy(a),b=uy(s),T=b[2]-v[2];T>180?T-=360:T<-180&&(T+=360);let C=[Bu(h,e,r,v[0],c,b[0]),Bu(h,e,r,v[1],c,b[1]),v[2]+Bu(h,e,r,0,c,T),Bu(h,e,r,a[3],c,s[3])];return dy(Mb(C))}function IC(h){return!0}function Kb(h){let e=Ly(),r=CC(h,e),a=Fy();return function(c,s){if(a.properties=c.getPropertiesInternal(),a.resolution=s,e.featureId){let y=c.getId();y!==void 0?a.featureId=y:a.featureId=null}return e.geometryType&&(a.geometryType=Dy(c.getGeometry())),r(a)}}function By(h){let e=Ly(),r=h.length,a=new Array(r);for(let y=0;y<r;++y)a[y]=zy(h[y],e);let c=Fy(),s=new Array(r);return function(y,v){if(c.properties=y.getPropertiesInternal(),c.resolution=v,e.featureId){let T=y.getId();T!==void 0?c.featureId=T:c.featureId=null}let b=0;for(let T=0;T<r;++T){let C=a[T](c);C&&(s[b]=C,b+=1)}return s.length=b,s}}function CC(h,e){let r=h.length,a=new Array(r);for(let c=0;c<r;++c){let s=h[c],y="filter"in s?Zs(s.filter,Gr,e):IC,v;if(Array.isArray(s.style)){let b=s.style.length;v=new Array(b);for(let T=0;T<b;++T)v[T]=zy(s.style[T],e)}else v=[zy(s.style,e)];a[c]={filter:y,styles:v}}return function(c){let s=[],y=!1;for(let v=0;v<r;++v){let b=a[v].filter;if(b(c)&&!(h[v].else&&y)){y=!0;for(let T of a[v].styles){let C=T(c);C&&s.push(C)}}}return s}}function zy(h,e){let r=Nu(h,"",e),a=Vu(h,"",e),c=EC(h,e),s=TC(h,e),y=Tn(h,"z-index",e);if(!r&&!a&&!c&&!s&&!Wn(h))throw new Error("No fill, stroke, point, or text symbolizer properties in style: "+JSON.stringify(h));let v=new Tr;return function(b){let T=!0;if(r){let C=r(b);C&&(T=!1),v.setFill(C)}if(a){let C=a(b);C&&(T=!1),v.setStroke(C)}if(c){let C=c(b);C&&(T=!1),v.setText(C)}if(s){let C=s(b);C&&(T=!1),v.setImage(C)}return y&&v.setZIndex(y(b)),T?null:v}}function Nu(h,e,r){let a;if(e+"fill-pattern-src"in h)a=RC(h,e+"fill-",r);else{if(h[e+"fill-color"]==="none")return s=>null;a=Ny(h,e+"fill-color",r)}if(!a)return null;let c=new Er;return function(s){let y=a(s);return y===Np?null:(c.setColor(y),c)}}function Vu(h,e,r){let a=Tn(h,e+"stroke-width",r),c=Ny(h,e+"stroke-color",r);if(!a&&!c)return null;let s=Io(h,e+"stroke-line-cap",r),y=Io(h,e+"stroke-line-join",r),v=Yb(h,e+"stroke-line-dash",r),b=Tn(h,e+"stroke-line-dash-offset",r),T=Tn(h,e+"stroke-miter-limit",r),C=new Xi;return function(k){if(c){let O=c(k);if(O===Np)return null;C.setColor(O)}if(a&&C.setWidth(a(k)),s){let O=s(k);if(O!=="butt"&&O!=="round"&&O!=="square")throw new Error("Expected butt, round, or square line cap");C.setLineCap(O)}if(y){let O=y(k);if(O!=="bevel"&&O!=="round"&&O!=="miter")throw new Error("Expected bevel, round, or miter line join");C.setLineJoin(O)}return v&&C.setLineDash(v(k)),b&&C.setLineDashOffset(b(k)),T&&C.setMiterLimit(T(k)),C}}function EC(h,e){let r="text-",a=Io(h,r+"value",e);if(!a)return null;let c=Nu(h,r,e),s=Nu(h,r+"background-",e),y=Vu(h,r,e),v=Vu(h,r+"background-",e),b=Io(h,r+"font",e),T=Tn(h,r+"max-angle",e),C=Tn(h,r+"offset-x",e),k=Tn(h,r+"offset-y",e),O=Bc(h,r+"overflow",e),G=Io(h,r+"placement",e),J=Tn(h,r+"repeat",e),le=Jp(h,r+"scale",e),he=Bc(h,r+"rotate-with-view",e),fe=Tn(h,r+"rotation",e),ye=Io(h,r+"align",e),we=Io(h,r+"justify",e),Ie=Io(h,r+"baseline",e),Pe=Bc(h,r+"keep-upright",e),Ee=Yb(h,r+"padding",e),Ge=Qp(h,r+"declutter-mode"),Be=new jb({declutterMode:Ge});return function(Ae){if(Be.setText(a(Ae)),c&&Be.setFill(c(Ae)),s&&Be.setBackgroundFill(s(Ae)),y&&Be.setStroke(y(Ae)),v&&Be.setBackgroundStroke(v(Ae)),b&&Be.setFont(b(Ae)),T&&Be.setMaxAngle(T(Ae)),C&&Be.setOffsetX(C(Ae)),k&&Be.setOffsetY(k(Ae)),O&&Be.setOverflow(O(Ae)),G){let st=G(Ae);if(st!=="point"&&st!=="line")throw new Error("Expected point or line for text-placement");Be.setPlacement(st)}if(J&&Be.setRepeat(J(Ae)),le&&Be.setScale(le(Ae)),he&&Be.setRotateWithView(he(Ae)),fe&&Be.setRotation(fe(Ae)),ye){let st=ye(Ae);if(st!=="left"&&st!=="center"&&st!=="right"&&st!=="end"&&st!=="start")throw new Error("Expected left, right, center, start, or end for text-align");Be.setTextAlign(st)}if(we){let st=we(Ae);if(st!=="left"&&st!=="right"&&st!=="center")throw new Error("Expected left, right, or center for text-justify");Be.setJustify(st)}if(Ie){let st=Ie(Ae);if(st!=="bottom"&&st!=="top"&&st!=="middle"&&st!=="alphabetic"&&st!=="hanging")throw new Error("Expected bottom, top, middle, alphabetic, or hanging for text-baseline");Be.setTextBaseline(st)}return Ee&&Be.setPadding(Ee(Ae)),Pe&&Be.setKeepUpright(Pe(Ae)),Be}}function TC(h,e){return"icon-src"in h?MC(h,e):"shape-points"in h?PC(h,e):"circle-radius"in h?AC(h,e):null}function MC(h,e){let r="icon-",a=r+"src",c=Jb(h[a],a),s=Kp(h,r+"anchor",e),y=Jp(h,r+"scale",e),v=Tn(h,r+"opacity",e),b=Kp(h,r+"displacement",e),T=Tn(h,r+"rotation",e),C=Bc(h,r+"rotate-with-view",e),k=Xb(h,r+"anchor-origin"),O=Hb(h,r+"anchor-x-units"),G=Hb(h,r+"anchor-y-units"),J=FC(h,r+"color"),le=LC(h,r+"cross-origin"),he=DC(h,r+"offset"),fe=Xb(h,r+"offset-origin"),ye=Yp(h,r+"width"),we=Yp(h,r+"height"),Ie=kC(h,r+"size"),Pe=Qp(h,r+"declutter-mode"),Ee=new Du({src:c,anchorOrigin:k,anchorXUnits:O,anchorYUnits:G,color:J,crossOrigin:le,offset:he,offsetOrigin:fe,height:we,width:ye,size:Ie,declutterMode:Pe});return function(Ge){return v&&Ee.setOpacity(v(Ge)),b&&Ee.setDisplacement(b(Ge)),T&&Ee.setRotation(T(Ge)),C&&Ee.setRotateWithView(C(Ge)),y&&Ee.setScale(y(Ge)),s&&Ee.setAnchor(s(Ge)),Ee}}function PC(h,e){let r="shape-",a=r+"points",c=r+"radius",s=Oy(h[a],a),y=Oy(h[c],c),v=Nu(h,r,e),b=Vu(h,r,e),T=Jp(h,r+"scale",e),C=Kp(h,r+"displacement",e),k=Tn(h,r+"rotation",e),O=Bc(h,r+"rotate-with-view",e),G=Yp(h,r+"radius2"),J=Yp(h,r+"angle"),le=Qp(h,r+"declutter-mode"),he=new $p({points:s,radius:y,radius2:G,angle:J,declutterMode:le});return function(fe){return v&&he.setFill(v(fe)),b&&he.setStroke(b(fe)),C&&he.setDisplacement(C(fe)),k&&he.setRotation(k(fe)),O&&he.setRotateWithView(O(fe)),T&&he.setScale(T(fe)),he}}function AC(h,e){let r="circle-",a=Nu(h,r,e),c=Vu(h,r,e),s=Tn(h,r+"radius",e),y=Jp(h,r+"scale",e),v=Kp(h,r+"displacement",e),b=Tn(h,r+"rotation",e),T=Bc(h,r+"rotate-with-view",e),C=Qp(h,r+"declutter-mode"),k=new En({radius:5,declutterMode:C});return function(O){return s&&k.setRadius(s(O)),a&&k.setFill(a(O)),c&&k.setStroke(c(O)),v&&k.setDisplacement(v(O)),b&&k.setRotation(b(O)),T&&k.setRotateWithView(T(O)),y&&k.setScale(y(O)),k}}function Tn(h,e,r){if(!(e in h))return;let a=Zs(h[e],Ut,r);return function(c){return Oy(a(c),e)}}function Io(h,e,r){if(!(e in h))return null;let a=Zs(h[e],tn,r);return function(c){return Jb(a(c),e)}}function RC(h,e,r){let a=Io(h,e+"pattern-src",r),c=Zb(h,e+"pattern-offset",r),s=Zb(h,e+"pattern-size",r),y=Ny(h,e+"color",r);return function(v){return{src:a(v),offset:c&&c(v),size:s&&s(v),color:y&&y(v)}}}function Bc(h,e,r){if(!(e in h))return null;let a=Zs(h[e],Gr,r);return function(c){let s=a(c);if(typeof s!="boolean")throw new Error(`Expected a boolean for ${e}`);return s}}function Ny(h,e,r){if(!(e in h))return null;let a=Zs(h[e],Hn,r);return function(c){return Qb(a(c),e)}}function Yb(h,e,r){if(!(e in h))return null;let a=Zs(h[e],wa,r);return function(c){return ju(a(c),e)}}function Kp(h,e,r){if(!(e in h))return null;let a=Zs(h[e],wa,r);return function(c){let s=ju(a(c),e);if(s.length!==2)throw new Error(`Expected two numbers for ${e}`);return s}}function Zb(h,e,r){if(!(e in h))return null;let a=Zs(h[e],wa,r);return function(c){return e1(a(c),e)}}function Jp(h,e,r){if(!(e in h))return null;let a=Zs(h[e],wa|Ut,r);return function(c){return zC(a(c),e)}}function Yp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="number")throw new Error(`Expected a number for ${e}`);return r}}function kC(h,e){let r=h[e];if(r!==void 0){if(typeof r=="number")return qs(r);if(!Array.isArray(r))throw new Error(`Expected a number or size array for ${e}`);if(r.length!==2||typeof r[0]!="number"||typeof r[1]!="number")throw new Error(`Expected a number or size array for ${e}`);return r}}function LC(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);return r}}function Xb(h,e){let r=h[e];if(r!==void 0){if(r!=="bottom-left"&&r!=="bottom-right"&&r!=="top-left"&&r!=="top-right")throw new Error(`Expected bottom-left, bottom-right, top-left, or top-right for ${e}`);return r}}function Hb(h,e){let r=h[e];if(r!==void 0){if(r!=="pixels"&&r!=="fraction")throw new Error(`Expected pixels or fraction for ${e}`);return r}}function DC(h,e){let r=h[e];if(r!==void 0)return ju(r,e)}function Qp(h,e){let r=h[e];if(r!==void 0){if(typeof r!="string")throw new Error(`Expected a string for ${e}`);if(r!=="declutter"&&r!=="obstacle"&&r!=="none")throw new Error(`Expected declutter, obstacle, or none for ${e}`);return r}}function FC(h,e){let r=h[e];if(r!==void 0)return Qb(r,e)}function ju(h,e){if(!Array.isArray(h))throw new Error(`Expected an array for ${e}`);let r=h.length;for(let a=0;a<r;++a)if(typeof h[a]!="number")throw new Error(`Expected an array of numbers for ${e}`);return h}function Jb(h,e){if(typeof h!="string")throw new Error(`Expected a string for ${e}`);return h}function Oy(h,e){if(typeof h!="number")throw new Error(`Expected a number for ${e}`);return h}function Qb(h,e){if(typeof h=="string")return h;let r=ju(h,e),a=r.length;if(a<3||a>4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return r}function e1(h,e){let r=ju(h,e);if(r.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return r}function zC(h,e){return typeof h=="number"?h:e1(h,e)}var t1={RENDER_ORDER:"renderOrder"},Vy=class extends Es{constructor(e){e=e||{};let r=Object.assign({},e);delete r.style,delete r.renderBuffer,delete r.updateWhileAnimating,delete r.updateWhileInteracting,super(r),this.declutter_=e.declutter?String(e.declutter):void 0,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(t1.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e,r){let a=this.getDeclutter();a in e.declutter||(e.declutter[a]=new fl(9)),this.getRenderer().renderDeclutter(e,r)}setRenderOrder(e){this.set(t1.RENDER_ORDER,e)}setStyle(e){this.style_=e===void 0?Ey:e;let r=OC(e);this.styleFunction_=e===null?void 0:Nb(r),this.changed()}setDeclutter(e){this.declutter_=e?String(e):void 0,this.changed()}};function OC(h){if(h===void 0)return Ey;if(!h)return null;if(typeof h=="function"||h instanceof Tr)return h;if(!Array.isArray(h))return By([h]);if(h.length===0)return[];let e=h.length,r=h[0];if(r instanceof Tr){let c=new Array(e);for(let s=0;s<e;++s){let y=h[s];if(!(y instanceof Tr))throw new Error("Expected a list of style instances");c[s]=y}return c}if("style"in r){let c=new Array(e);for(let s=0;s<e;++s){let y=h[s];if(!("style"in y))throw new Error("Expected a list of rules with a style property");c[s]=y}return Kb(c)}return By(h)}var i1=Vy;var Gu={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Uu=[Gu.FILL],Xs=[Gu.STROKE],Co=[Gu.BEGIN_PATH],jy=[Gu.CLOSE_PATH],dt=Gu;var Gy=class{drawCustom(e,r,a,c,s){}drawGeometry(e){}setStyle(e){}drawCircle(e,r,a){}drawFeature(e,r,a){}drawGeometryCollection(e,r,a){}drawLineString(e,r,a){}drawMultiLineString(e,r,a){}drawMultiPoint(e,r,a){}drawMultiPolygon(e,r,a){}drawPoint(e,r,a){}drawPolygon(e,r,a){}drawText(e,r,a){}setFillStrokeStyle(e,r){}setImageStyle(e,r){}setTextStyle(e,r){}},ef=Gy;var Uy=class extends ef{constructor(e,r,a,c){super(),this.tolerance=e,this.maxExtent=r,this.pixelRatio=c,this.maxLineWidth=0,this.resolution=a,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){let r=this.pixelRatio;return r==1?e:e.map(function(a){return a*r})}appendFlatPointCoordinates(e,r){let a=this.getBufferedMaxExtent(),c=this.tmpCoordinate_,s=this.coordinates,y=s.length;for(let v=0,b=e.length;v<b;v+=r)c[0]=e[v],c[1]=e[v+1],rl(a,c)&&(s[y++]=c[0],s[y++]=c[1]);return y}appendFlatLineCoordinates(e,r,a,c,s,y){let v=this.coordinates,b=v.length,T=this.getBufferedMaxExtent();y&&(r+=c);let C=e[r],k=e[r+1],O=this.tmpCoordinate_,G=!0,J,le,he;for(J=r+c;J<a;J+=c)O[0]=e[J],O[1]=e[J+1],he=pp(T,O),he!==le?(G&&(v[b++]=C,v[b++]=k,G=!1),v[b++]=O[0],v[b++]=O[1]):he===Ni.INTERSECTING?(v[b++]=O[0],v[b++]=O[1],G=!1):G=!0,C=O[0],k=O[1],le=he;return(s&&G||J===r+c)&&(v[b++]=C,v[b++]=k),b}drawCustomCoordinates_(e,r,a,c,s){for(let y=0,v=a.length;y<v;++y){let b=a[y],T=this.appendFlatLineCoordinates(e,r,b,c,!1,!1);s.push(T),r=b}return r}drawCustom(e,r,a,c,s){this.beginGeometry(e,r,s);let y=e.getType(),v=e.getStride(),b=this.coordinates.length,T,C,k,O,G;switch(y){case"MultiPolygon":T=e.getOrientedFlatCoordinates(),O=[];let J=e.getEndss();G=0;for(let le=0,he=J.length;le<he;++le){let fe=[];G=this.drawCustomCoordinates_(T,G,J[le],v,fe),O.push(fe)}this.instructions.push([dt.CUSTOM,b,O,e,a,fu,s]),this.hitDetectionInstructions.push([dt.CUSTOM,b,O,e,c||a,fu,s]);break;case"Polygon":case"MultiLineString":k=[],T=y=="Polygon"?e.getOrientedFlatCoordinates():e.getFlatCoordinates(),G=this.drawCustomCoordinates_(T,0,e.getEnds(),v,k),this.instructions.push([dt.CUSTOM,b,k,e,a,ma,s]),this.hitDetectionInstructions.push([dt.CUSTOM,b,k,e,c||a,ma,s]);break;case"LineString":case"Circle":T=e.getFlatCoordinates(),C=this.appendFlatLineCoordinates(T,0,T.length,v,!1,!1),this.instructions.push([dt.CUSTOM,b,C,e,a,cs,s]),this.hitDetectionInstructions.push([dt.CUSTOM,b,C,e,c||a,cs,s]);break;case"MultiPoint":T=e.getFlatCoordinates(),C=this.appendFlatPointCoordinates(T,v),C>b&&(this.instructions.push([dt.CUSTOM,b,C,e,a,cs,s]),this.hitDetectionInstructions.push([dt.CUSTOM,b,C,e,c||a,cs,s]));break;case"Point":T=e.getFlatCoordinates(),this.coordinates.push(T[0],T[1]),C=this.coordinates.length,this.instructions.push([dt.CUSTOM,b,C,e,a,void 0,s]),this.hitDetectionInstructions.push([dt.CUSTOM,b,C,e,c||a,void 0,s]);break;default:}this.endGeometry(r)}beginGeometry(e,r,a){this.beginGeometryInstruction1_=[dt.BEGIN_GEOMETRY,r,0,e,a],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[dt.BEGIN_GEOMETRY,r,0,e,a],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){let e=this.hitDetectionInstructions;e.reverse();let r,a=e.length,c,s,y=-1;for(r=0;r<a;++r)c=e[r],s=c[0],s==dt.END_GEOMETRY?y=r:s==dt.BEGIN_GEOMETRY&&(c[2]=r,rv(this.hitDetectionInstructions,y,r),y=-1)}setFillStrokeStyle(e,r){let a=this.state;if(e){let c=e.getColor();a.fillPatternScale=c&&typeof c=="object"&&"src"in c?this.pixelRatio:1,a.fillStyle=Sn(c||Hi)}else a.fillStyle=void 0;if(r){let c=r.getColor();a.strokeStyle=Sn(c||bo);let s=r.getLineCap();a.lineCap=s!==void 0?s:$s;let y=r.getLineDash();a.lineDash=y?y.slice():In;let v=r.getLineDashOffset();a.lineDashOffset=v||Cn;let b=r.getLineJoin();a.lineJoin=b!==void 0?b:Ws;let T=r.getWidth();a.lineWidth=T!==void 0?T:So;let C=r.getMiterLimit();a.miterLimit=C!==void 0?C:vo,a.lineWidth>this.maxLineWidth&&(this.maxLineWidth=a.lineWidth,this.bufferedMaxExtent_=null)}else a.strokeStyle=void 0,a.lineCap=void 0,a.lineDash=null,a.lineDashOffset=void 0,a.lineJoin=void 0,a.lineWidth=void 0,a.miterLimit=void 0}createFill(e){let r=e.fillStyle,a=[dt.SET_FILL_STYLE,r];return typeof r!="string"&&a.push(e.fillPatternScale),a}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[dt.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,r){let a=e.fillStyle;(typeof a!="string"||e.currentFillStyle!=a)&&(a!==void 0&&this.instructions.push(r.call(this,e)),e.currentFillStyle=a)}updateStrokeStyle(e,r){let a=e.strokeStyle,c=e.lineCap,s=e.lineDash,y=e.lineDashOffset,v=e.lineJoin,b=e.lineWidth,T=e.miterLimit;(e.currentStrokeStyle!=a||e.currentLineCap!=c||s!=e.currentLineDash&&!yn(e.currentLineDash,s)||e.currentLineDashOffset!=y||e.currentLineJoin!=v||e.currentLineWidth!=b||e.currentMiterLimit!=T)&&(a!==void 0&&r.call(this,e),e.currentStrokeStyle=a,e.currentLineCap=c,e.currentLineDash=s,e.currentLineDashOffset=y,e.currentLineJoin=v,e.currentLineWidth=b,e.currentMiterLimit=T)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;let r=[dt.END_GEOMETRY,e];this.instructions.push(r),this.hitDetectionInstructions.push(r)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=nv(this.maxExtent),this.maxLineWidth>0)){let e=this.resolution*(this.maxLineWidth+1)/2;os(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}},Hs=Uy;var qy=class extends Hs{constructor(e,r,a,c){super(e,r,a,c),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,r,a){if(!this.image_||this.maxExtent&&!rl(this.maxExtent,e.getFlatCoordinates()))return;this.beginGeometry(e,r,a);let c=e.getFlatCoordinates(),s=e.getStride(),y=this.coordinates.length,v=this.appendFlatPointCoordinates(c,s);this.instructions.push([dt.DRAW_IMAGE,y,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,y,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}drawMultiPoint(e,r,a){if(!this.image_)return;this.beginGeometry(e,r,a);let c=e.getFlatCoordinates(),s=[];for(let b=0,T=c.length;b<T;b+=e.getStride())(!this.maxExtent||rl(this.maxExtent,c.slice(b,b+2)))&&s.push(c[b],c[b+1]);let y=this.coordinates.length,v=this.appendFlatPointCoordinates(s,2);this.instructions.push([dt.DRAW_IMAGE,y,v,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,y,v,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(r)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,r){let a=e.getAnchor(),c=e.getSize(),s=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=a[0],this.anchorY_=a[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=c[1],this.opacity_=e.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=c[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},r1=qy;var $y=class extends Hs{constructor(e,r,a,c){super(e,r,a,c)}drawFlatCoordinates_(e,r,a,c){let s=this.coordinates.length,y=this.appendFlatLineCoordinates(e,r,a,c,!1,!1),v=[dt.MOVE_TO_LINE_TO,s,y];return this.instructions.push(v),this.hitDetectionInstructions.push(v),a}drawLineString(e,r,a){let c=this.state,s=c.strokeStyle,y=c.lineWidth;if(s===void 0||y===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(e,r,a),this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn],Co);let v=e.getFlatCoordinates(),b=e.getStride();this.drawFlatCoordinates_(v,0,v.length,b),this.hitDetectionInstructions.push(Xs),this.endGeometry(r)}drawMultiLineString(e,r,a){let c=this.state,s=c.strokeStyle,y=c.lineWidth;if(s===void 0||y===void 0)return;this.updateStrokeStyle(c,this.applyStroke),this.beginGeometry(e,r,a),this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn],Co);let v=e.getEnds(),b=e.getFlatCoordinates(),T=e.getStride(),C=0;for(let k=0,O=v.length;k<O;++k)C=this.drawFlatCoordinates_(b,C,v[k],T);this.hitDetectionInstructions.push(Xs),this.endGeometry(r)}finish(){let e=this.state;return e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&this.instructions.push(Xs),this.reverseHitDetectionInstructions(),this.state=null,super.finish()}applyStroke(e){e.lastStroke!=null&&e.lastStroke!=this.coordinates.length&&(this.instructions.push(Xs),e.lastStroke=this.coordinates.length),e.lastStroke=0,super.applyStroke(e),this.instructions.push(Co)}},n1=$y;var Wy=class extends Hs{constructor(e,r,a,c){super(e,r,a,c)}drawFlatCoordinatess_(e,r,a,c){let s=this.state,y=s.fillStyle!==void 0,v=s.strokeStyle!==void 0,b=a.length;this.instructions.push(Co),this.hitDetectionInstructions.push(Co);for(let T=0;T<b;++T){let C=a[T],k=this.coordinates.length,O=this.appendFlatLineCoordinates(e,r,C,c,!0,!v),G=[dt.MOVE_TO_LINE_TO,k,O];this.instructions.push(G),this.hitDetectionInstructions.push(G),v&&(this.instructions.push(jy),this.hitDetectionInstructions.push(jy)),r=C}return y&&(this.instructions.push(Uu),this.hitDetectionInstructions.push(Uu)),v&&(this.instructions.push(Xs),this.hitDetectionInstructions.push(Xs)),r}drawCircle(e,r,a){let c=this.state,s=c.fillStyle,y=c.strokeStyle;if(s===void 0&&y===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,a),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Hi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getFlatCoordinates(),b=e.getStride(),T=this.coordinates.length;this.appendFlatLineCoordinates(v,0,v.length,b,!1,!1);let C=[dt.CIRCLE,T];this.instructions.push(Co,C),this.hitDetectionInstructions.push(Co,C),c.fillStyle!==void 0&&(this.instructions.push(Uu),this.hitDetectionInstructions.push(Uu)),c.strokeStyle!==void 0&&(this.instructions.push(Xs),this.hitDetectionInstructions.push(Xs)),this.endGeometry(r)}drawPolygon(e,r,a){let c=this.state,s=c.fillStyle,y=c.strokeStyle;if(s===void 0&&y===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,a),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Hi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getEnds(),b=e.getOrientedFlatCoordinates(),T=e.getStride();this.drawFlatCoordinatess_(b,0,v,T),this.endGeometry(r)}drawMultiPolygon(e,r,a){let c=this.state,s=c.fillStyle,y=c.strokeStyle;if(s===void 0&&y===void 0)return;this.setFillStrokeStyles_(),this.beginGeometry(e,r,a),c.fillStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_FILL_STYLE,Hi]),c.strokeStyle!==void 0&&this.hitDetectionInstructions.push([dt.SET_STROKE_STYLE,c.strokeStyle,c.lineWidth,c.lineCap,c.lineJoin,c.miterLimit,In,Cn]);let v=e.getEndss(),b=e.getOrientedFlatCoordinates(),T=e.getStride(),C=0;for(let k=0,O=v.length;k<O;++k)C=this.drawFlatCoordinatess_(b,C,v[k],T);this.endGeometry(r)}finish(){this.reverseHitDetectionInstructions(),this.state=null;let e=this.tolerance;if(e!==0){let r=this.coordinates;for(let a=0,c=r.length;a<c;++a)r[a]=fa(r[a],e)}return super.finish()}setFillStrokeStyles_(){let e=this.state;e.fillStyle!==void 0&&this.updateFillStyle(e,this.createFill),e.strokeStyle!==void 0&&this.updateStrokeStyle(e,this.applyStroke)}},Zy=Wy;function s1(h,e,r,a,c){let s=[],y=r,v=0,b=e.slice(r,2);for(;v<h&&y+c<a;){let[T,C]=b.slice(-2),k=e[y+c],O=e[y+c+1],G=Math.sqrt((k-T)*(k-T)+(O-C)*(O-C));if(v+=G,v>=h){let J=(h-v+G)/G,le=Ir(T,k,J),he=Ir(C,O,J);b.push(le,he),s.push(b),b=[le,he],v==h&&(y+=c),v=0}else if(v<h)b.push(e[y+c],e[y+c+1]),y+=c;else{let J=G-v,le=Ir(T,k,J/G),he=Ir(C,O,J/G);b.push(le,he),s.push(b),b=[le,he],v=0,y+=c}}return v>0&&s.push(b),s}function o1(h,e,r,a,c){let s=r,y=r,v=0,b=0,T=r,C,k,O,G,J,le,he,fe,ye,we;for(k=r;k<a;k+=c){let Ie=e[k],Pe=e[k+1];J!==void 0&&(ye=Ie-J,we=Pe-le,G=Math.sqrt(ye*ye+we*we),he!==void 0&&(b+=O,C=Math.acos((he*ye+fe*we)/(O*G)),C>h&&(b>v&&(v=b,s=T,y=k),b=0,T=k-c)),O=G,he=ye,fe=we),J=Ie,le=Pe}return b+=G,b>v?[T,k]:[s,y]}var qu={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1},Xy=class extends Hs{constructor(e,r,a,c){super(e,r,a,c),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textKeepUpright_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Hi]={fillStyle:Hi},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterMode_=void 0,this.declutterImageWithText_=void 0}finish(){let e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,r,a){let c=this.textFillState_,s=this.textStrokeState_,y=this.textState_;if(this.text_===""||!y||!c&&!s)return;let v=this.coordinates,b=v.length,T=e.getType(),C=null,k=e.getStride();if(y.placement==="line"&&(T=="LineString"||T=="MultiLineString"||T=="Polygon"||T=="MultiPolygon")){if(!Vi(this.maxExtent,e.getExtent()))return;let O;if(C=e.getFlatCoordinates(),T=="LineString")O=[C.length];else if(T=="MultiLineString")O=e.getEnds();else if(T=="Polygon")O=e.getEnds().slice(0,1);else if(T=="MultiPolygon"){let he=e.getEndss();O=[];for(let fe=0,ye=he.length;fe<ye;++fe)O.push(he[fe][0])}this.beginGeometry(e,r,a);let G=y.repeat,J=G?void 0:y.textAlign,le=0;for(let he=0,fe=O.length;he<fe;++he){let ye;G?ye=s1(G*this.resolution,C,le,O[he],k):ye=[C.slice(le,O[he])];for(let we=0,Ie=ye.length;we<Ie;++we){let Pe=ye[we],Ee=0,Ge=Pe.length;if(J==null){let Ae=o1(y.maxAngle,Pe,0,Pe.length,2);Ee=Ae[0],Ge=Ae[1]}for(let Ae=Ee;Ae<Ge;Ae+=k)v.push(Pe[Ae],Pe[Ae+1]);let Be=v.length;le=O[he],this.drawChars_(b,Be),b=Be}}this.endGeometry(r)}else{let O=y.overflow?null:[];switch(T){case"Point":case"MultiPoint":C=e.getFlatCoordinates();break;case"LineString":C=e.getFlatMidpoint();break;case"Circle":C=e.getCenter();break;case"MultiLineString":C=e.getFlatMidpoints(),k=2;break;case"Polygon":C=e.getFlatInteriorPoint(),y.overflow||O.push(C[2]/this.resolution),k=3;break;case"MultiPolygon":let ye=e.getFlatInteriorPoints();C=[];for(let we=0,Ie=ye.length;we<Ie;we+=3)y.overflow||O.push(ye[we+2]/this.resolution),C.push(ye[we],ye[we+1]);if(C.length===0)return;k=2;break;default:}let G=this.appendFlatPointCoordinates(C,k);if(G===b)return;if(O&&(G-b)/2!==C.length/k){let ye=b/2;O=O.filter((we,Ie)=>{let Pe=v[(ye+Ie)*2]===C[Ie*k]&&v[(ye+Ie)*2+1]===C[Ie*k+1];return Pe||--ye,Pe})}this.saveTextStates_(),(y.backgroundFill||y.backgroundStroke)&&(this.setFillStrokeStyle(y.backgroundFill,y.backgroundStroke),y.backgroundFill&&this.updateFillStyle(this.state,this.createFill),y.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,r,a);let J=y.padding;if(J!=wo&&(y.scale[0]<0||y.scale[1]<0)){let ye=y.padding[0],we=y.padding[1],Ie=y.padding[2],Pe=y.padding[3];y.scale[0]<0&&(we=-we,Pe=-Pe),y.scale[1]<0&&(ye=-ye,Ie=-Ie),J=[ye,we,Ie,Pe]}let le=this.pixelRatio;this.instructions.push([dt.DRAW_IMAGE,b,G,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,this.declutterMode_,this.declutterImageWithText_,J==wo?wo:J.map(function(ye){return ye*le}),!!y.backgroundFill,!!y.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,O]);let he=1/le,fe=this.state.fillStyle;y.backgroundFill&&(this.state.fillStyle=Hi,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([dt.DRAW_IMAGE,b,G,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[he,he],NaN,this.declutterMode_,this.declutterImageWithText_,J,!!y.backgroundFill,!!y.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Hi:this.fillKey_,this.textOffsetX_,this.textOffsetY_,O]),y.backgroundFill&&(this.state.fillStyle=fe,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(r)}}saveTextStates_(){let e=this.textStrokeState_,r=this.textState_,a=this.textFillState_,c=this.strokeKey_;e&&(c in this.strokeStates||(this.strokeStates[c]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));let s=this.textKey_;s in this.textStates||(this.textStates[s]={font:r.font,textAlign:r.textAlign||xa,justify:r.justify,textBaseline:r.textBaseline||pl,scale:r.scale});let y=this.fillKey_;a&&(y in this.fillStates||(this.fillStates[y]={fillStyle:a.fillStyle}))}drawChars_(e,r){let a=this.textStrokeState_,c=this.textState_,s=this.strokeKey_,y=this.textKey_,v=this.fillKey_;this.saveTextStates_();let b=this.pixelRatio,T=qu[c.textBaseline],C=this.textOffsetY_*b,k=this.text_,O=a?a.lineWidth*Math.abs(c.scale[0])/2:0;this.instructions.push([dt.DRAW_CHARS,e,r,T,c.overflow,v,c.maxAngle,b,C,s,O*b,k,y,1,this.declutterMode_,this.textKeepUpright_]),this.hitDetectionInstructions.push([dt.DRAW_CHARS,e,r,T,c.overflow,v&&Hi,c.maxAngle,b,C,s,O*b,k,y,1/b,this.declutterMode_,this.textKeepUpright_])}setTextStyle(e,r){let a,c,s;if(!e)this.text_="";else{let y=e.getFill();y?(c=this.textFillState_,c||(c={},this.textFillState_=c),c.fillStyle=Sn(y.getColor()||Hi)):(c=null,this.textFillState_=c);let v=e.getStroke();if(!v)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);let le=v.getLineDash(),he=v.getLineDashOffset(),fe=v.getWidth(),ye=v.getMiterLimit();s.lineCap=v.getLineCap()||$s,s.lineDash=le?le.slice():In,s.lineDashOffset=he===void 0?Cn:he,s.lineJoin=v.getLineJoin()||Ws,s.lineWidth=fe===void 0?So:fe,s.miterLimit=ye===void 0?vo:ye,s.strokeStyle=Sn(v.getColor()||bo)}a=this.textState_;let b=e.getFont()||qp;Db(b);let T=e.getScaleArray();a.overflow=e.getOverflow(),a.font=b,a.maxAngle=e.getMaxAngle(),a.placement=e.getPlacement(),a.textAlign=e.getTextAlign(),a.repeat=e.getRepeat(),a.justify=e.getJustify(),a.textBaseline=e.getTextBaseline()||pl,a.backgroundFill=e.getBackgroundFill(),a.backgroundStroke=e.getBackgroundStroke(),a.padding=e.getPadding()||wo,a.scale=T===void 0?[1,1]:T;let C=e.getOffsetX(),k=e.getOffsetY(),O=e.getRotateWithView(),G=e.getKeepUpright(),J=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=C===void 0?0:C,this.textOffsetY_=k===void 0?0:k,this.textRotateWithView_=O===void 0?!1:O,this.textKeepUpright_=G===void 0?!0:G,this.textRotation_=J===void 0?0:J,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:Vt(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=a.font+a.scale+(a.textAlign||"?")+(a.repeat||"?")+(a.justify||"?")+(a.textBaseline||"?"),this.fillKey_=c&&c.fillStyle?typeof c.fillStyle=="string"?c.fillStyle:"|"+Vt(c.fillStyle):""}this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=r}},a1=Xy;var BC={Circle:Zy,Default:Hs,Image:r1,LineString:n1,Polygon:Zy,Text:a1},Hy=class{constructor(e,r,a,c){this.tolerance_=e,this.maxExtent_=r,this.pixelRatio_=c,this.resolution_=a,this.buildersByZIndex_={}}finish(){let e={};for(let r in this.buildersByZIndex_){e[r]=e[r]||{};let a=this.buildersByZIndex_[r];for(let c in a){let s=a[c].finish();e[r][c]=s}}return e}getBuilder(e,r){let a=e!==void 0?e.toString():"0",c=this.buildersByZIndex_[a];c===void 0&&(c={},this.buildersByZIndex_[a]=c);let s=c[r];if(s===void 0){let y=BC[r];s=new y(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),c[r]=s}return s}},l1=Hy;var NC=5,Ky=class extends up{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.staleKeys_=new Array,this.maxStaleKeys=NC}getStaleKeys(){return this.staleKeys_}prependStaleKey(e){this.staleKeys_.unshift(e),this.staleKeys_.length>this.maxStaleKeys&&(this.staleKeys_.length=this.maxStaleKeys)}getFeatures(e){return wt()}getData(e){return null}prepareFrame(e){return wt()}renderFrame(e,r){return wt()}forEachFeatureAtCoordinate(e,r,a,c,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){let r=e.target;(r.getState()===It.LOADED||r.getState()===It.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let r=e.getState();return r!=It.LOADED&&r!=It.ERROR&&e.addEventListener(pi.CHANGE,this.boundHandleImageChange_),r==It.IDLE&&(e.load(),r=e.getState()),r==It.LOADED}renderIfReadyAndVisible(){let e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}renderDeferred(e){}disposeInternal(){delete this.layer_,super.disposeInternal()}},Sa=Ky;var Yy=class extends Si{constructor(e,r,a,c){super(e),this.inversePixelTransform=r,this.frameState=a,this.context=c}},c1=Yy;var Jy=class{constructor(){this.instructions_=[],this.zIndex=0,this.offset_=0,this.context_=new Proxy(kc(),{get:(e,r)=>{if(typeof kc()[r]=="function")return this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r),this.pushMethodArgs_},set:(e,r,a)=>(this.instructions_[this.zIndex+this.offset_]||(this.instructions_[this.zIndex+this.offset_]=[]),this.instructions_[this.zIndex+this.offset_].push(r,a),!0)})}pushMethodArgs_=(...e)=>(this.instructions_[this.zIndex+this.offset_].push(e),this);pushFunction(e){this.instructions_[this.zIndex+this.offset_].push(e)}getContext(){return this.context_}draw(e){this.instructions_.forEach(r=>{for(let a=0,c=r.length;a<c;++a){let s=r[a];if(typeof s=="function"){s(e);continue}let y=r[++a];if(typeof e[s]=="function")e[s](...y);else{if(typeof y=="function"){e[s]=y(e);continue}e[s]=y}}})}clear(){this.instructions_.length=0,this.zIndex=0,this.offset_=0}offset(){this.offset_=this.instructions_.length,this.zIndex=0}},tf=Jy;var e_=[],Nc=null;function VC(){Nc=Ri(1,1,void 0,{willReadFrequently:!0})}var Qy=class extends Sa{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=sr(),this.pixelTransform=sr(),this.inversePixelTransform=sr(),this.context=null,this.deferredContext_=null,this.containerReused=!1,this.frameState=null}getImageData(e,r,a){Nc||VC(),Nc.clearRect(0,0,1,1);let c;try{Nc.drawImage(e,r,a,1,1,0,0,1,1),c=Nc.getImageData(0,0,1,1).data}catch{return Nc=null,null}return c}getBackground(e){let a=this.getLayer().getBackground();return typeof a=="function"&&(a=a(e.viewState.resolution)),a||void 0}useContainer(e,r,a){let c=this.getLayer().getClassName(),s,y;if(e&&e.className===c&&(!a||e&&e.style.backgroundColor&&yn(Ms(e.style.backgroundColor),Ms(a)))){let v=e.firstElementChild;v instanceof HTMLCanvasElement&&(y=v.getContext("2d"))}if(y&&y.canvas.style.transform===r?(this.container=e,this.context=y,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){s=document.createElement("div"),s.className=c;let v=s.style;v.position="absolute",v.width="100%",v.height="100%",y=Ri();let b=y.canvas;s.appendChild(b),v=b.style,v.position="absolute",v.left="0",v.transformOrigin="top left",this.container=s,this.context=y}!this.containerReused&&a&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=a)}clipUnrotated(e,r,a){let c=lg(a),s=cg(a),y=ag(a),v=og(a);br(r.coordinateToPixelTransform,c),br(r.coordinateToPixelTransform,s),br(r.coordinateToPixelTransform,y),br(r.coordinateToPixelTransform,v);let b=this.inversePixelTransform;br(b,c),br(b,s),br(b,y),br(b,v),e.save(),e.beginPath(),e.moveTo(Math.round(c[0]),Math.round(c[1])),e.lineTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(y[0]),Math.round(y[1])),e.lineTo(Math.round(v[0]),Math.round(v[1])),e.clip()}prepareContainer(e,r){let a=e.extent,c=e.viewState.resolution,s=e.viewState.rotation,y=e.pixelRatio,v=Math.round(vi(a)/c*y),b=Math.round(Wi(a)/c*y);Vr(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/y,1/y,s,-v/2,-b/2),Qx(this.inversePixelTransform,this.pixelTransform);let T=Jm(this.pixelTransform);if(this.useContainer(r,T,this.getBackground(e)),!this.containerReused){let C=this.context.canvas;C.width!=v||C.height!=b?(C.width=v,C.height=b):this.context.clearRect(0,0,v,b),T!==C.style.transform&&(C.style.transform=T)}}dispatchRenderEvent_(e,r,a){let c=this.getLayer();if(c.hasListener(e)){let s=new c1(e,this.inversePixelTransform,a,r);c.dispatchEvent(s)}}preRender(e,r){this.frameState=r,!r.declutter&&this.dispatchRenderEvent_(Us.PRERENDER,e,r)}postRender(e,r){r.declutter||this.dispatchRenderEvent_(Us.POSTRENDER,e,r)}renderDeferredInternal(e){}getRenderContext(e){return e.declutter&&!this.deferredContext_&&(this.deferredContext_=new tf),e.declutter?this.deferredContext_.getContext():this.context}renderDeferred(e){e.declutter&&(this.dispatchRenderEvent_(Us.PRERENDER,this.context,e),e.declutter&&this.deferredContext_&&(this.deferredContext_.draw(this.context),this.deferredContext_.clear()),this.renderDeferredInternal(e),this.dispatchRenderEvent_(Us.POSTRENDER,this.context,e))}getRenderTransform(e,r,a,c,s,y,v){let b=s/2,T=y/2,C=c/r,k=-C,O=-e[0]+v,G=-e[1];return Vr(this.tempTransform,b,T,C,k,-a,O,G)}disposeInternal(){delete this.frameState,super.disposeInternal()}},rf=Qy;function h1(h,e,r,a,c,s,y,v,b,T,C,k,O=!0){let G=h[e],J=h[e+1],le=0,he=0,fe=0,ye=0;function we(){le=G,he=J,e+=a,G=h[e],J=h[e+1],ye+=fe,fe=Math.sqrt((G-le)*(G-le)+(J-he)*(J-he))}do we();while(e<r-a&&ye+fe<s);let Ie=fe===0?0:(s-ye)/fe,Pe=Ir(le,G,Ie),Ee=Ir(he,J,Ie),Ge=e-a,Be=ye,Ae=s+v*b(T,c,C);for(;e<r-a&&ye+fe<Ae;)we();Ie=fe===0?0:(Ae-ye)/fe;let st=Ir(le,G,Ie),ct=Ir(he,J,Ie),rt=!1;if(O)if(k){let ot=[Pe,Ee,st,ct];Ip(ot,0,4,2,k,ot,ot),rt=ot[0]>ot[2]}else rt=Pe>st;let xt=Math.PI,Rt=[],at=Ge+a===e;e=Ge,fe=0,ye=Be,G=h[e],J=h[e+1];let gt;if(at){we(),gt=Math.atan2(J-he,G-le),rt&&(gt+=gt>0?-xt:xt);let ot=(st+Pe)/2,pt=(ct+Ee)/2;return Rt[0]=[ot,pt,(Ae-s)/2,gt,c],Rt}c=c.replace(/\n/g," ");for(let ot=0,pt=c.length;ot<pt;){we();let Pt=Math.atan2(J-he,G-le);if(rt&&(Pt+=Pt>0?-xt:xt),gt!==void 0){let ci=Pt-gt;if(ci+=ci>xt?-2*xt:ci<-xt?2*xt:0,Math.abs(ci)>y)return null}gt=Pt;let kt=ot,Lt=0;for(;ot<pt;++ot){let ci=rt?pt-ot-1:ot,di=v*b(T,c[ci],C);if(e+a<r&&ye+fe<s+Lt+di/2)break;Lt+=di}if(ot===kt)continue;let $t=rt?c.substring(pt-kt,pt-ot):c.substring(kt,ot);Ie=fe===0?0:(s+Lt/2-ye)/fe;let fi=Ir(le,G,Ie),$e=Ir(he,J,Ie);Rt.push([fi,$e,Lt/2,Pt,$t]),s+=Lt}return Rt}var Vc=xn(),Ia=[],Eo=[],To=[],Ca=[];function u1(h){return h[3].declutterBox}var d1=new RegExp("[\u0591-\u08FF\uFB1D-\uFDFF\uFE70-\uFEFC\u0800-\u0FFF\uE800-\uEFFF]");function t_(h,e){return e==="start"?e=d1.test(h)?"right":"left":e==="end"&&(e=d1.test(h)?"left":"right"),qu[e]}function jC(h,e,r){return r>0&&h.push(`
583
583
  `,""),h.push(e,""),h}var i_=class{constructor(e,r,a,c,s){this.overlaps=a,this.pixelRatio=r,this.resolution=e,this.alignAndScaleFill_,this.instructions=c.instructions,this.coordinates=c.coordinates,this.coordinateCache_={},this.renderedTransform_=sr(),this.hitDetectionInstructions=c.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=c.fillStates||{},this.strokeStates=c.strokeStates||{},this.textStates=c.textStates||{},this.widths_={},this.labels_={},this.zIndexContext_=s?new tf:null}getZIndexContext(){return this.zIndexContext_}createLabel(e,r,a,c){let s=e+r+a+c;if(this.labels_[s])return this.labels_[s];let y=c?this.strokeStates[c]:null,v=a?this.fillStates[a]:null,b=this.textStates[r],T=this.pixelRatio,C=[b.scale[0]*T,b.scale[1]*T],k=b.justify?qu[b.justify]:t_(Array.isArray(e)?e[0]:e,b.textAlign||xa),O=c&&y.lineWidth?y.lineWidth:0,G=Array.isArray(e)?e:String(e).split(`
584
584
  `).reduce(jC,[]),{width:J,height:le,widths:he,heights:fe,lineWidths:ye}=zb(b,G),we=J+O,Ie=[],Pe=(we+2)*C[0],Ee=(le+O)*C[1],Ge={width:Pe<0?Math.floor(Pe):Math.ceil(Pe),height:Ee<0?Math.floor(Ee):Math.ceil(Ee),contextInstructions:Ie};(C[0]!=1||C[1]!=1)&&Ie.push("scale",C),c&&(Ie.push("strokeStyle",y.strokeStyle),Ie.push("lineWidth",O),Ie.push("lineCap",y.lineCap),Ie.push("lineJoin",y.lineJoin),Ie.push("miterLimit",y.miterLimit),Ie.push("setLineDash",[y.lineDash]),Ie.push("lineDashOffset",y.lineDashOffset)),a&&Ie.push("fillStyle",v.fillStyle),Ie.push("textBaseline","middle"),Ie.push("textAlign","center");let Be=.5-k,Ae=k*we+Be*O,st=[],ct=[],rt=0,xt=0,Rt=0,at=0,gt;for(let ot=0,pt=G.length;ot<pt;ot+=2){let Pt=G[ot];if(Pt===`
585
- `){xt+=rt,rt=0,Ae=k*we+Be*O,++at;continue}let kt=G[ot+1]||b.font;kt!==gt&&(c&&st.push("font",kt),a&&ct.push("font",kt),gt=kt),rt=Math.max(rt,fe[Rt]);let Lt=[Pt,Ae+Be*he[Rt]+k*(he[Rt]-ye[at]),.5*(O+rt)+xt];Ae+=he[Rt],c&&st.push("strokeText",Lt),a&&ct.push("fillText",Lt),++Rt}return Array.prototype.push.apply(Ie,st),Array.prototype.push.apply(Ie,ct),this.labels_[s]=Ge,Ge}replayTextBackground_(e,r,a,c,s,y,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,a),e.lineTo.apply(e,c),e.lineTo.apply(e,s),e.lineTo.apply(e,r),y&&(this.alignAndScaleFill_=y[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,a,c,s,y,v,b,T,C,k,O,G,J,le,he){v*=O[0],b*=O[1];let fe=a-v,ye=c-b,we=s+T>e?e-T:s,Ie=y+C>r?r-C:y,Pe=J[3]+we*O[0]+J[1],Ee=J[0]+Ie*O[1]+J[2],Ge=fe-J[3],Be=ye-J[0];(le||k!==0)&&(Ia[0]=Ge,Ca[0]=Ge,Ia[1]=Be,Eo[1]=Be,Eo[0]=Ge+Pe,To[0]=Eo[0],To[1]=Be+Ee,Ca[1]=To[1]);let Ae;return k!==0?(Ae=Vr(sr(),a,c,1,1,k,-a,-c),br(Ae,Ia),br(Ae,Eo),br(Ae,To),br(Ae,Ca),yo(Math.min(Ia[0],Eo[0],To[0],Ca[0]),Math.min(Ia[1],Eo[1],To[1],Ca[1]),Math.max(Ia[0],Eo[0],To[0],Ca[0]),Math.max(Ia[1],Eo[1],To[1],Ca[1]),Vc)):yo(Math.min(Ge,Ge+Pe),Math.min(Be,Be+Ee),Math.max(Ge,Ge+Pe),Math.max(Be,Be+Ee),Vc),G&&(fe=Math.round(fe),ye=Math.round(ye)),{drawImageX:fe,drawImageY:ye,drawImageW:we,drawImageH:Ie,originX:T,originY:C,declutterBox:{minX:Vc[0],minY:Vc[1],maxX:Vc[2],maxY:Vc[3],value:he},canvasTransform:Ae,scale:O}}replayImageOrLabel_(e,r,a,c,s,y,v){let b=!!(y||v),T=c.declutterBox,C=v?v[2]*c.scale[0]/2:0;return T.minX-C<=r[0]&&T.maxX+C>=0&&T.minY-C<=r[1]&&T.maxY+C>=0&&(b&&this.replayTextBackground_(e,Ia,Eo,To,Ca,y,v),Ob(e,c.canvasTransform,s,a,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let a=br(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;e.save(),e.translate(a[0]%c,a[1]%c),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,a,c){let s=this.textStates[r],y=this.createLabel(e,r,c,a),v=this.strokeStates[a],b=this.pixelRatio,T=t_(Array.isArray(e)?e[0]:e,s.textAlign||xa),C=qu[s.textBaseline||pl],k=v&&v.lineWidth?v.lineWidth:0,O=y.width/b-2*s.scale[0],G=T*O+2*(.5-T)*k,J=C*y.height/b+2*(.5-C)*k;return{label:y,anchorX:G,anchorY:J}}execute_(e,r,a,c,s,y,v,b){let T=this.zIndexContext_,C;this.pixelCoordinates_&&yn(a,this.renderedTransform_)?C=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),C=vn(this.coordinates,0,this.coordinates.length,2,a,this.pixelCoordinates_),Yx(this.renderedTransform_,a));let k=0,O=c.length,G=0,J,le,he,fe,ye,we,Ie,Pe,Ee,Ge,Be,Ae,st,ct=0,rt=0,xt=null,Rt=null,at=this.coordinateCache_,gt=this.viewRotation_,ot=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,pt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:gt},Pt=this.instructions!=c||this.overlaps?0:200,kt,Lt,$t,fi;for(;k<O;){let $e=c[k];switch($e[0]){case dt.BEGIN_GEOMETRY:kt=$e[1],fi=$e[3],kt.getGeometry()?v!==void 0&&!Vi(v,fi.getExtent())?k=$e[2]+1:++k:k=$e[2],T&&(T.zIndex=$e[4]);break;case dt.BEGIN_PATH:ct>Pt&&(this.fill_(e),ct=0),rt>Pt&&(e.stroke(),rt=0),!ct&&!rt&&(e.beginPath(),ye=NaN,we=NaN),++k;break;case dt.CIRCLE:G=$e[1];let di=C[G],ur=C[G+1],dr=C[G+2],rn=C[G+3],ji=dr-di,nn=rn-ur,sn=Math.sqrt(ji*ji+nn*nn);e.moveTo(di+sn,ur),e.arc(di,ur,sn,0,2*Math.PI,!0),++k;break;case dt.CLOSE_PATH:e.closePath(),++k;break;case dt.CUSTOM:G=$e[1],J=$e[2];let Pn=$e[3],ve=$e[4],An=$e[5];pt.geometry=Pn,pt.feature=kt,k in at||(at[k]=[]);let pr=at[k];An?An(C,G,J,2,pr):(pr[0]=C[G],pr[1]=C[G+1],pr.length=2),T&&(T.zIndex=$e[6]),ve(pr,pt),++k;break;case dt.DRAW_IMAGE:G=$e[1],J=$e[2],Ee=$e[3],le=$e[4],he=$e[5];let bt=$e[6],Zt=$e[7],Rn=$e[8],on=$e[9],Ar=$e[10],an=$e[11],fr=$e[12],Yn=$e[13];fe=$e[14]||"declutter";let kn=$e[15];if(!Ee&&$e.length>=20){Ge=$e[19],Be=$e[20],Ae=$e[21],st=$e[22];let ae=this.drawLabelWithPointPlacement_(Ge,Be,Ae,st);Ee=ae.label,$e[3]=Ee;let de=$e[23];le=(ae.anchorX-de)*this.pixelRatio,$e[4]=le;let ie=$e[24];he=(ae.anchorY-ie)*this.pixelRatio,$e[5]=he,bt=Ee.height,$e[6]=bt,Yn=Ee.width,$e[13]=Yn}let De;$e.length>25&&(De=$e[25]);let Rr,Ei,mr;$e.length>17?(Rr=$e[16],Ei=$e[17],mr=$e[18]):(Rr=wo,Ei=!1,mr=!1),Ar&&ot?an+=gt:!Ar&&!ot&&(an-=gt);let Jn=0;for(;G<J;G+=2){if(De&&De[Jn++]<Yn/this.pixelRatio)continue;let ae=this.calculateImageOrLabelDimensions_(Ee.width,Ee.height,C[G],C[G+1],Yn,bt,le,he,Rn,on,an,fr,s,Rr,Ei||mr,kt),de=[e,r,Ee,ae,Zt,Ei?xt:null,mr?Rt:null];if(b){let ie,xe,Se;if(kn){let Ne=J-G;if(!kn[Ne]){kn[Ne]={args:de,declutterMode:fe};continue}let Ke=kn[Ne];ie=Ke.args,xe=Ke.declutterMode,delete kn[Ne],Se=u1(ie)}let _e,ke;if(ie&&(xe!=="declutter"||!b.collides(Se))&&(_e=!0),(fe!=="declutter"||!b.collides(ae.declutterBox))&&(ke=!0),xe==="declutter"&&fe==="declutter"){let Ne=_e&&ke;_e=Ne,ke=Ne}_e&&(xe!=="none"&&b.insert(Se),this.replayImageOrLabel_.apply(this,ie)),ke&&(fe!=="none"&&b.insert(ae.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++k;break;case dt.DRAW_CHARS:let Fe=$e[1],St=$e[2],ht=$e[3],Ki=$e[4];st=$e[5];let qr=$e[6],yt=$e[7],$r=$e[8];Ae=$e[9];let Wr=$e[10];Ge=$e[11],Be=$e[12];let Ln=[$e[13],$e[13]];fe=$e[14]||"declutter";let ln=$e[15],Q=this.textStates[Be],N=Q.font,B=[Q.scale[0]*yt,Q.scale[1]*yt],q;N in this.widths_?q=this.widths_[N]:(q={},this.widths_[N]=q);let X=Ap(C,Fe,St,2),se=Math.abs(B[0])*wy(N,Ge,q);if(Ki||se<=X){let ae=this.textStates[Be].textAlign,de=(X-se)*t_(Ge,ae),ie=h1(C,Fe,St,2,Ge,de,qr,Math.abs(B[0]),wy,N,q,ot?0:this.viewRotation_,ln);e:if(ie){let xe=[],Se,_e,ke,Ne,Ke;if(Ae)for(Se=0,_e=ie.length;Se<_e;++Se){Ke=ie[Se],ke=Ke[4],Ne=this.createLabel(ke,Be,"",Ae),le=Ke[2]+(B[0]<0?-Wr:Wr),he=ht*Ne.height+(.5-ht)*2*Wr*B[1]/B[0]-$r;let Ct=this.calculateImageOrLabelDimensions_(Ne.width,Ne.height,Ke[0],Ke[1],Ne.width,Ne.height,le,he,0,0,Ke[3],Ln,!1,wo,!1,kt);if(b&&fe==="declutter"&&b.collides(Ct.declutterBox))break e;xe.push([e,r,Ne,Ct,1,null,null])}if(st)for(Se=0,_e=ie.length;Se<_e;++Se){Ke=ie[Se],ke=Ke[4],Ne=this.createLabel(ke,Be,st,""),le=Ke[2],he=ht*Ne.height-$r;let Ct=this.calculateImageOrLabelDimensions_(Ne.width,Ne.height,Ke[0],Ke[1],Ne.width,Ne.height,le,he,0,0,Ke[3],Ln,!1,wo,!1,kt);if(b&&fe==="declutter"&&b.collides(Ct.declutterBox))break e;xe.push([e,r,Ne,Ct,1,null,null])}b&&fe!=="none"&&b.load(xe.map(u1));for(let Ct=0,vt=xe.length;Ct<vt;++Ct)this.replayImageOrLabel_.apply(this,xe[Ct])}}++k;break;case dt.END_GEOMETRY:if(y!==void 0){kt=$e[1];let ae=y(kt,fi,fe);if(ae)return ae}++k;break;case dt.FILL:Pt?ct++:this.fill_(e),++k;break;case dt.MOVE_TO_LINE_TO:for(G=$e[1],J=$e[2],Lt=C[G],$t=C[G+1],e.moveTo(Lt,$t),ye=Lt+.5|0,we=$t+.5|0,G+=2;G<J;G+=2)Lt=C[G],$t=C[G+1],Ie=Lt+.5|0,Pe=$t+.5|0,(G==J-2||Ie!==ye||Pe!==we)&&(e.lineTo(Lt,$t),ye=Ie,we=Pe);++k;break;case dt.SET_FILL_STYLE:xt=$e,this.alignAndScaleFill_=$e[2],ct&&(this.fill_(e),ct=0,rt&&(e.stroke(),rt=0)),e.fillStyle=$e[1],++k;break;case dt.SET_STROKE_STYLE:Rt=$e,rt&&(e.stroke(),rt=0),this.setStrokeStyle_(e,$e),++k;break;case dt.STROKE:Pt?rt++:e.stroke(),++k;break;default:++k;break}}ct&&this.fill_(e),rt&&e.stroke()}execute(e,r,a,c,s,y){this.viewRotation_=c,this.execute_(e,r,a,this.instructions,s,void 0,void 0,y)}executeHitDetection(e,r,a,c,s){return this.viewRotation_=a,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,c,s)}},p1=i_;var gl=["Polygon","Circle","LineString","Image","Text","Default"],s_=["Image","Text"],f1=gl.filter(h=>!s_.includes(h)),n_=class{constructor(e,r,a,c,s,y,v){this.maxExtent_=e,this.overlaps_=c,this.pixelRatio_=a,this.resolution_=r,this.renderBuffer_=y,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=sr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,v)}clip(e,r){let a=this.getClipCoords(r);e.beginPath(),e.moveTo(a[0],a[1]),e.lineTo(a[2],a[3]),e.lineTo(a[4],a[5]),e.lineTo(a[6],a[7]),e.clip()}createExecutors_(e,r){for(let a in e){let c=this.executorsByZIndex_[a];c===void 0&&(c={},this.executorsByZIndex_[a]=c);let s=e[a];for(let y in s){let v=s[y];c[y]=new p1(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let a=this.executorsByZIndex_[r];for(let c=0,s=e.length;c<s;++c)if(e[c]in a)return!0}return!1}forEachFeatureAtCoordinate(e,r,a,c,s,y){c=Math.round(c);let v=c*2+1,b=Vr(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-a,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Ri(v,v,void 0,{willReadFrequently:!0}));let C=this.hitDetectionContext_;C.canvas.width!==v||C.canvas.height!==v?(C.canvas.width=v,C.canvas.height=v):T||C.clearRect(0,0,v,v);let k;this.renderBuffer_!==void 0&&(k=xn(),ng(k,e),os(k,r*(this.renderBuffer_+c),k));let O=GC(c),G;function J(Pe,Ee,Ge){let Be=C.getImageData(0,0,v,v).data;for(let Ae=0,st=O.length;Ae<st;Ae++)if(Be[O[Ae]]>0){if(!y||Ge==="none"||G!=="Image"&&G!=="Text"||y.includes(Pe)){let ct=(O[Ae]-3)/4,rt=c-ct%v,xt=c-(ct/v|0),Rt=s(Pe,Ee,rt*rt+xt*xt);if(Rt)return Rt}C.clearRect(0,0,v,v);break}}let le=Object.keys(this.executorsByZIndex_).map(Number);le.sort(xs);let he,fe,ye,we,Ie;for(he=le.length-1;he>=0;--he){let Pe=le[he].toString();for(ye=this.executorsByZIndex_[Pe],fe=gl.length-1;fe>=0;--fe)if(G=gl[fe],we=ye[G],we!==void 0&&(Ie=we.executeHitDetection(C,b,a,J,k),Ie))return Ie}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let a=r[0],c=r[1],s=r[2],y=r[3],v=[a,c,a,y,s,y,s,c];return vn(v,0,8,2,e,v),v}isEmpty(){return Wn(this.executorsByZIndex_)}execute(e,r,a,c,s,y,v){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(v?iv:xs),y=y||gl;let T=gl.length;for(let C=0,k=b.length;C<k;++C){let O=b[C].toString(),G=this.executorsByZIndex_[O];for(let J=0,le=y.length;J<le;++J){let he=y[J],fe=G[he];if(fe!==void 0){let ye=v===null?void 0:fe.getZIndexContext(),we=ye?ye.getContext():e,Ie=this.maxExtent_&&he!=="Image"&&he!=="Text";if(Ie&&(we.save(),this.clip(we,a)),!ye||he==="Text"||he==="Image"?fe.execute(we,r,a,c,s,v):ye.pushFunction(Pe=>fe.execute(Pe,r,a,c,s,v)),Ie&&we.restore(),ye){ye.offset();let Pe=b[C]*T+J;this.deferredZIndexContexts_[Pe]||(this.deferredZIndexContexts_[Pe]=[]),this.deferredZIndexContexts_[Pe].push(ye)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,r=Object.keys(e).map(Number).sort(xs);for(let a=0,c=r.length;a<c;++a)e[r[a]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),e[r[a]].length=0}},r_={};function GC(h){if(r_[h]!==void 0)return r_[h];let e=h*2+1,r=h*h,a=new Array(r+1);for(let s=0;s<=h;++s)for(let y=0;y<=h;++y){let v=s*s+y*y;if(v>r)break;let b=a[v];b||(b=[],a[v]=b),b.push(((h+s)*e+(h+y))*4+3),s>0&&b.push(((h-s)*e+(h+y))*4+3),y>0&&(b.push(((h+s)*e+(h-y))*4+3),s>0&&b.push(((h-s)*e+(h-y))*4+3))}let c=[];for(let s=0,y=a.length;s<y;++s)a[s]&&c.push(...a[s]);return r_[h]=c,c}var m1=n_;var o_=class extends ef{constructor(e,r,a,c,s,y,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=a,this.transform_=c,this.transformRotation_=c?_v(Math.atan2(c[1],c[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=y,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=sr()}drawImages_(e,r,a,c){if(!this.image_)return;let s=vn(e,r,a,c,this.transform_,this.pixelCoordinates_),y=this.context_,v=this.tmpLocalTransform_,b=y.globalAlpha;this.imageOpacity_!=1&&(y.globalAlpha=b*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let C=0,k=s.length;C<k;C+=2){let O=s[C]-this.imageAnchorX_,G=s[C+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=O+this.imageAnchorX_,le=G+this.imageAnchorY_;Vr(v,J,le,1,1,T,-J,-le),y.save(),y.transform.apply(y,v),y.translate(J,le),y.scale(this.imageScale_[0],this.imageScale_[1]),y.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),y.restore()}else y.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,O,G,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(y.globalAlpha=b)}drawText_(e,r,a,c){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=vn(e,r,a,c,this.transform_,this.pixelCoordinates_),y=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<a;r+=c){let b=s[r]+this.textOffsetX_,T=s[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(y.save(),y.translate(b-this.textOffsetX_,T-this.textOffsetY_),y.rotate(v),y.translate(this.textOffsetX_,this.textOffsetY_),y.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&y.strokeText(this.text_,0,0),this.textFillState_&&y.fillText(this.text_,0,0),y.restore()):(this.textStrokeState_&&y.strokeText(this.text_,b,T),this.textFillState_&&y.fillText(this.text_,b,T))}}moveToLineTo_(e,r,a,c,s){let y=this.context_,v=vn(e,r,a,c,this.transform_,this.pixelCoordinates_);y.moveTo(v[0],v[1]);let b=v.length;s&&(b-=2);for(let T=2;T<b;T+=2)y.lineTo(v[T],v[T+1]);return s&&y.closePath(),a}drawRings_(e,r,a,c){for(let s=0,y=a.length;s<y;++s)r=this.moveToLineTo_(e,r,a[s],c,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=qv(e,this.transform_,this.pixelCoordinates_),a=r[2]-r[0],c=r[3]-r[1],s=Math.sqrt(a*a+c*c),y=this.context_;y.beginPath(),y.arc(r[0],r[1],s,0,2*Math.PI),this.fillState_&&y.fill(),this.strokeState_&&y.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let a=r.getGeometryFunction()(e);a&&(this.setStyle(r),this.drawGeometry(a))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let a=0,c=r.length;a<c;++a)this.drawGeometry(r[a])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(r,0,r.length,a),this.text_!==""&&this.drawText_(r,0,r.length,a)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(r,0,r.length,a),this.text_!==""&&this.drawText_(r,0,r.length,a)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,a=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(a,0,a.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Vi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let a=this.context_,c=e.getFlatCoordinates(),s=0,y=e.getEnds(),v=e.getStride();a.beginPath();for(let b=0,T=y.length;b<T;++b)s=this.moveToLineTo_(c,s,y[b],v,!1);a.stroke()}if(this.text_!==""){let a=e.getFlatMidpoints();this.drawText_(a,0,a.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,a=e.getOrientedFlatCoordinates(),c=0,s=e.getEndss(),y=e.getStride();r.beginPath();for(let v=0,b=s.length;v<b;++v){let T=s[v];c=this.drawRings_(a,c,T,y)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,a=this.contextFillState_;a?a.fillStyle!=e.fillStyle&&(a.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,a=this.contextStrokeState_;a?(a.lineCap!=e.lineCap&&(a.lineCap=e.lineCap,r.lineCap=e.lineCap),yn(a.lineDash,e.lineDash)||r.setLineDash(a.lineDash=e.lineDash),a.lineDashOffset!=e.lineDashOffset&&(a.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),a.lineJoin!=e.lineJoin&&(a.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),a.lineWidth!=e.lineWidth&&(a.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),a.miterLimit!=e.miterLimit&&(a.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),a.strokeStyle!=e.strokeStyle&&(a.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,a=this.contextTextState_,c=e.textAlign?e.textAlign:xa;a?(a.font!=e.font&&(a.font=e.font,r.font=e.font),a.textAlign!=c&&(a.textAlign=c,r.textAlign=c),a.textBaseline!=e.textBaseline&&(a.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=c,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:c,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let a=e.getColor();this.fillState_={fillStyle:Sn(a||Hi)}}if(!r)this.strokeState_=null;else{let a=r.getColor(),c=r.getLineCap(),s=r.getLineDash(),y=r.getLineDashOffset(),v=r.getLineJoin(),b=r.getWidth(),T=r.getMiterLimit(),C=s||In;this.strokeState_={lineCap:c!==void 0?c:$s,lineDash:this.pixelRatio_===1?C:C.map(k=>k*this.pixelRatio_),lineDashOffset:(y||Cn)*this.pixelRatio_,lineJoin:v!==void 0?v:Ws,lineWidth:(b!==void 0?b:So)*this.pixelRatio_,miterLimit:T!==void 0?T:vo,strokeStyle:Sn(a||bo)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let a=e.getPixelRatio(this.pixelRatio_),c=e.getAnchor(),s=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=c[0]*a,this.imageAnchorY_=c[1]*a,this.imageHeight_=r[1]*a,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let y=e.getScaleArray();this.imageScale_=[y[0]*this.pixelRatio_/a,y[1]*this.pixelRatio_/a],this.imageWidth_=r[0]*a}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let G=r.getColor();this.textFillState_={fillStyle:Sn(G||Hi)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let G=a.getColor(),J=a.getLineCap(),le=a.getLineDash(),he=a.getLineDashOffset(),fe=a.getLineJoin(),ye=a.getWidth(),we=a.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:$s,lineDash:le||In,lineDashOffset:he||Cn,lineJoin:fe!==void 0?fe:Ws,lineWidth:ye!==void 0?ye:So,miterLimit:we!==void 0?we:vo,strokeStyle:Sn(G||bo)}}let c=e.getFont(),s=e.getOffsetX(),y=e.getOffsetY(),v=e.getRotateWithView(),b=e.getRotation(),T=e.getScaleArray(),C=e.getText(),k=e.getTextAlign(),O=e.getTextBaseline();this.textState_={font:c!==void 0?c:qp,textAlign:k!==void 0?k:xa,textBaseline:O!==void 0?O:pl},this.text_=C!==void 0?Array.isArray(C)?C.reduce((G,J,le)=>G+=le%2?" ":J,""):C:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=y!==void 0?this.pixelRatio_*y:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=b!==void 0?b:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},g1=o_;var As=.5;function y1(h,e,r,a,c,s,y,v,b){let T=b?js(c,b):c,C=h[0]*As,k=h[1]*As,O=Ri(C,k);O.imageSmoothingEnabled=!1;let G=O.canvas,J=new g1(O,As,c,null,y,v,b?Cc(Zn(),b):null),le=r.length,he=Math.floor((256*256*256-1)/le),fe={};for(let we=1;we<=le;++we){let Ie=r[we-1],Pe=Ie.getStyleFunction()||a;if(!Pe)continue;let Ee=Pe(Ie,s);if(!Ee)continue;Array.isArray(Ee)||(Ee=[Ee]);let Be=(we*he).toString(16).padStart(7,"#00000");for(let Ae=0,st=Ee.length;Ae<st;++Ae){let ct=Ee[Ae],rt=ct.getGeometryFunction()(Ie);if(!rt||!Vi(T,rt.getExtent()))continue;let xt=ct.clone(),Rt=xt.getFill();Rt&&Rt.setColor(Be);let at=xt.getStroke();at&&(at.setColor(Be),at.setLineDash(null)),xt.setText(void 0);let gt=ct.getImage();if(gt){let kt=gt.getImageSize();if(!kt)continue;let Lt=Ri(kt[0],kt[1],void 0,{alpha:!1}),$t=Lt.canvas;Lt.fillStyle=Be,Lt.fillRect(0,0,$t.width,$t.height),xt.setImage(new Du({img:$t,anchor:gt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:gt.getOrigin(),opacity:1,size:gt.getSize(),scale:gt.getScale(),rotation:gt.getRotation(),rotateWithView:gt.getRotateWithView()}))}let ot=xt.getZIndex()||0,pt=fe[ot];pt||(pt={},fe[ot]=pt,pt.Polygon=[],pt.Circle=[],pt.LineString=[],pt.Point=[]);let Pt=rt.getType();if(Pt==="GeometryCollection"){let kt=rt.getGeometriesArrayRecursive();for(let Lt=0,$t=kt.length;Lt<$t;++Lt){let fi=kt[Lt];pt[fi.getType().replace("Multi","")].push(fi,xt)}}else pt[Pt.replace("Multi","")].push(rt,xt)}}let ye=Object.keys(fe).map(Number).sort(xs);for(let we=0,Ie=ye.length;we<Ie;++we){let Pe=fe[ye[we]];for(let Ee in Pe){let Ge=Pe[Ee];for(let Be=0,Ae=Ge.length;Be<Ae;Be+=2){J.setStyle(Ge[Be+1]);for(let st=0,ct=e.length;st<ct;++st)J.setTransform(e[st]),J.drawGeometry(Ge[Be])}}}return O.getImageData(0,0,G.width,G.height)}function _1(h,e,r){let a=[];if(r){let c=Math.floor(Math.round(h[0])*As),s=Math.floor(Math.round(h[1])*As),y=(Ii(c,0,r.width-1)+Ii(s,0,r.height-1)*r.width)*4,v=r.data[y],b=r.data[y+1],C=r.data[y+2]+256*(b+256*v),k=Math.floor((256*256*256-1)/e.length);C&&C%k===0&&a.push(e[C/k-1])}return a}var UC=.5,x1={Point:KC,LineString:ZC,Polygon:JC,MultiPoint:YC,MultiLineString:XC,MultiPolygon:HC,GeometryCollection:WC,Circle:qC};function v1(h,e){return parseInt(Vt(h),10)-parseInt(Vt(e),10)}function a_(h,e){let r=l_(h,e);return r*r}function l_(h,e){return UC*h/e}function qC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(s||y){let b=h.getBuilder(r.getZIndex(),"Circle");b.setFillStrokeStyle(s,y),b.drawCircle(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a)}}function c_(h,e,r,a,c,s,y,v){let b=[],T=r.getImage();if(T){let O=!0,G=T.getImageState();G==It.LOADED||G==It.ERROR?O=!1:G==It.IDLE&&T.load(),O&&b.push(T.ready())}let C=r.getFill();C&&C.loading()&&b.push(C.ready());let k=b.length>0;return k&&Promise.all(b).then(()=>c(null)),$C(h,e,r,a,s,y,v),k}function $C(h,e,r,a,c,s,y){let v=r.getGeometryFunction()(e);if(!v)return;let b=v.simplifyTransformed(a,c);if(r.getRenderer())b1(h,b,r,e,y);else{let C=x1[b.getType()];C(h,b,r,e,y,s)}}function b1(h,e,r,a,c){if(e.getType()=="GeometryCollection"){let y=e.getGeometries();for(let v=0,b=y.length;v<b;++v)b1(h,y[v],r,a,c);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,a,r.getRenderer(),r.getHitDetectionRenderer(),c)}function WC(h,e,r,a,c,s){let y=e.getGeometriesArray(),v,b;for(v=0,b=y.length;v<b;++v){let T=x1[y[v].getType()];T(h,y[v],r,a,c,s)}}function ZC(h,e,r,a,c){let s=r.getStroke();if(s){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,s),v.drawLineString(e,a,c)}let y=r.getText();if(y&&y.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(y),v.drawText(e,a,c)}}function XC(h,e,r,a,c){let s=r.getStroke();if(s){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,s),v.drawMultiLineString(e,a,c)}let y=r.getText();if(y&&y.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(y),v.drawText(e,a,c)}}function HC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(y||s){let b=h.getBuilder(r.getZIndex(),"Polygon");b.setFillStrokeStyle(s,y),b.drawMultiPolygon(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a,c)}}function KC(h,e,r,a,c,s){let y=r.getImage(),v=r.getText(),b=v&&v.getText(),T=s&&y&&b?{}:void 0;if(y){if(y.getImageState()!=It.LOADED)return;let C=h.getBuilder(r.getZIndex(),"Image");C.setImageStyle(y,T),C.drawPoint(e,a,c)}if(b){let C=h.getBuilder(r.getZIndex(),"Text");C.setTextStyle(v,T),C.drawText(e,a,c)}}function YC(h,e,r,a,c,s){let y=r.getImage(),v=y&&y.getOpacity()!==0,b=r.getText(),T=b&&b.getText(),C=s&&v&&T?{}:void 0;if(v){if(y.getImageState()!=It.LOADED)return;let k=h.getBuilder(r.getZIndex(),"Image");k.setImageStyle(y,C),k.drawMultiPoint(e,a,c)}if(T){let k=h.getBuilder(r.getZIndex(),"Text");k.setTextStyle(b,C),k.drawText(e,a,c)}}function JC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(s||y){let b=h.getBuilder(r.getZIndex(),"Polygon");b.setFillStrokeStyle(s,y),b.drawPolygon(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a,c)}}var h_=class extends rf{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=xn(),this.wrappedRenderedExtent_=xn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,r,a){let c=r.extent,s=r.viewState,y=s.center,v=s.resolution,b=s.projection,T=s.rotation,C=b.getExtent(),k=this.getLayer().getSource(),O=this.getLayer().getDeclutter(),G=r.pixelRatio,J=r.viewHints,le=!(J[bn.ANIMATING]||J[bn.INTERACTING]),he=this.context,fe=Math.round(vi(c)/v*G),ye=Math.round(Wi(c)/v*G),we=k.getWrapX()&&b.canWrapX(),Ie=we?vi(C):null,Pe=we?Math.ceil((c[2]-C[2])/Ie)+1:1,Ee=we?Math.floor((c[0]-C[0])/Ie):0;do{let Ge=this.getRenderTransform(y,v,0,G,fe,ye,Ee*Ie);r.declutter&&(Ge=Ge.slice(0)),e.execute(he,[he.canvas.width,he.canvas.height],Ge,T,le,a===void 0?gl:a?s_:f1,a?O&&r.declutter[O]:void 0)}while(++Ee<Pe)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Ri(this.context.canvas.width,this.context.canvas.height,e_))}resetDrawContext_(){if(this.opacity_!==1){let e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,Ab(this.context),e_.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,r){let a=e.layerStatesArray[e.layerIndex];this.opacity_=a.opacity;let c=e.viewState;this.prepareContainer(e,r);let s=this.context,y=this.replayGroup_,v=y&&!y.isEmpty();if(!v&&!(this.getLayer().hasListener(Us.PRERENDER)||this.getLayer().hasListener(Us.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(s,e);let b=c.projection;if(this.clipped_=!1,v&&a.extent&&this.clipping){let T=Gs(a.extent,b);v=Vi(T,e.extent),this.clipped_=v&&!go(T,e.extent),this.clipped_&&this.clipUnrotated(s,e,T)}return v&&this.renderWorlds(y,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&s.restore(),this.postRender(s,e),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let a=this.frameState.size.slice(),c=this.renderedCenter_,s=this.renderedResolution_,y=this.renderedRotation_,v=this.renderedProjection_,b=this.wrappedRenderedExtent_,T=this.getLayer(),C=[],k=a[0]*As,O=a[1]*As;C.push(this.getRenderTransform(c,s,y,As,k,O,0).slice());let G=T.getSource(),J=v.getExtent();if(G.getWrapX()&&v.canWrapX()&&!go(J,b)){let he=b[0],fe=vi(J),ye=0,we;for(;he<J[0];)--ye,we=fe*ye,C.push(this.getRenderTransform(c,s,y,As,k,O,we).slice()),he+=fe;for(ye=0,he=b[2];he>J[2];)++ye,we=fe*ye,C.push(this.getRenderTransform(c,s,y,As,k,O,we).slice()),he-=fe}let le=Zn();this.hitDetectionImageData_=y1(a,C,this.renderedFeatures_,T.getStyleFunction(),b,s,y,a_(s,this.renderedPixelRatio_),le?v:null)}r(_1(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,a,c,s){if(!this.replayGroup_)return;let y=r.viewState.resolution,v=r.viewState.rotation,b=this.getLayer(),T={},C=function(O,G,J){let le=Vt(O),he=T[le];if(he){if(he!==!0&&J<he.distanceSq){if(J===0)return T[le]=!0,s.splice(s.lastIndexOf(he),1),c(O,b,G);he.geometry=G,he.distanceSq=J}}else{if(J===0)return T[le]=!0,c(O,b,G);s.push(T[le]={feature:O,layer:b,geometry:G,distanceSq:J,callback:c})}},k=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,y,v,a,C,k?r.declutter[k].all().map(O=>O.value):null)}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),a=r.getSource();if(!a)return!1;let c=e.viewHints[bn.ANIMATING],s=e.viewHints[bn.INTERACTING],y=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!y&&c||!v&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let b=e.extent,T=e.viewState,C=T.projection,k=T.resolution,O=e.pixelRatio,G=r.getRevision(),J=r.getRenderBuffer(),le=r.getRenderOrder();le===void 0&&(le=v1);let he=T.center.slice(),fe=os(b,J*k),ye=fe.slice(),we=[fe.slice()],Ie=C.getExtent();if(a.getWrapX()&&C.canWrapX()&&!go(Ie,e.extent)){let at=vi(Ie),gt=Math.max(vi(fe)/2,at);fe[0]=Ie[0]-gt,fe[2]=Ie[2]+gt,wv(he,C);let ot=hg(we[0],C);ot[0]<Ie[0]&&ot[2]<Ie[2]?we.push([ot[0]+at,ot[1],ot[2]+at,ot[3]]):ot[0]>Ie[0]&&ot[2]>Ie[2]&&we.push([ot[0]-at,ot[1],ot[2]-at,ot[3]])}if(this.ready&&this.renderedResolution_==k&&this.renderedRevision_==G&&this.renderedRenderOrder_==le&&this.renderedFrameDeclutter_===!!e.declutter&&go(this.wrappedRenderedExtent_,fe))return yn(this.renderedExtent_,ye)||(this.hitDetectionImageData_=null,this.renderedExtent_=ye),this.renderedCenter_=he,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let Pe=new l1(l_(k,O),fe,k,O),Ee=Zn(),Ge;if(Ee){for(let at=0,gt=we.length;at<gt;++at){let ot=we[at],pt=js(ot,C);a.loadFeatures(pt,Nv(k,C),Ee)}Ge=Cc(Ee,C)}else for(let at=0,gt=we.length;at<gt;++at)a.loadFeatures(we[at],k,C);let Be=a_(k,O),Ae=!0,st=(at,gt)=>{let ot,pt=at.getStyleFunction()||r.getStyleFunction();if(pt&&(ot=pt(at,k)),ot){let Pt=this.renderFeature(at,Be,ot,Pe,Ge,this.getLayer().getDeclutter(),gt);Ae=Ae&&!Pt}},ct=js(fe,C),rt=a.getFeaturesInExtent(ct);le&&rt.sort(le);for(let at=0,gt=rt.length;at<gt;++at)st(rt[at],at);this.renderedFeatures_=rt,this.ready=Ae;let xt=Pe.finish(),Rt=new m1(fe,k,O,a.getOverlaps(),xt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=k,this.renderedRevision_=G,this.renderedRenderOrder_=le,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ye,this.wrappedRenderedExtent_=fe,this.renderedCenter_=he,this.renderedProjection_=C,this.renderedPixelRatio_=O,this.replayGroup_=Rt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,a,c,s,y,v){if(!a)return!1;let b=!1;if(Array.isArray(a))for(let T=0,C=a.length;T<C;++T)b=c_(c,e,a[T],r,this.boundHandleStyleImageChange_,s,y,v)||b;else b=c_(c,e,a,r,this.boundHandleStyleImageChange_,s,y,v);return b}},w1=h_;var u_=class extends i1{constructor(e){super(e)}createRenderer(){return new w1(this)}},jc=u_;var d_=class{constructor(e){this.rbush_=new fl(e),this.items_={}}insert(e,r){let a={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(a),this.items_[Vt(r)]=a}load(e,r){let a=new Array(r.length);for(let c=0,s=r.length;c<s;c++){let y=e[c],v=r[c],b={minX:y[0],minY:y[1],maxX:y[2],maxY:y[3],value:v};a[c]=b,this.items_[Vt(v)]=b}this.rbush_.load(a)}remove(e){let r=Vt(e),a=this.items_[r];return delete this.items_[r],this.rbush_.remove(a)!==null}update(e,r){let a=this.items_[Vt(r)],c=[a.minX,a.minY,a.maxX,a.maxY];fp(c,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(c){return c.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let a;for(let c=0,s=e.length;c<s;c++)if(a=r(e[c]),a)return a;return a}isEmpty(){return Wn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return yo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},$u=d_;var S1=sr(),Wu=class h{constructor(e,r,a,c,s,y){this.styleFunction,this.extent_,this.id_=y,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=a||null,this.properties_=s,this.squaredTolerance_,this.stride_=c,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ca(this.flatCoordinates_):_c(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=as(this.getExtent());this.flatInteriorPoints_=_u(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=rb(this.flatCoordinates_,this.ends_),r=Lp(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Rp(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=ul(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,a=this.ends_;for(let c=0,s=a.length;c<s;++c){let y=a[c],v=ul(e,r,y,2,.5);wr(this.flatMidpoints_,v),r=y}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=Ci(e);let r=e.getExtent(),a=e.getWorldExtent();if(r&&a){let c=Wi(a)/Wi(r);Vr(S1,a[0],a[3],c,-c,0,0,0),vn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,S1,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=cp((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let a=this.simplifiedGeometry_.getFlatCoordinates(),c;switch(this.type_){case"LineString":a.length=hl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),c=[a.length];break;case"MultiLineString":c=[],a.length=Tp(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,c);break;case"Polygon":c=[],a.length=pu(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),a,0,c);break;default:}return c&&(this.simplifiedGeometry_=new h(this.type_,a,c,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};Wu.prototype.getFlatCoordinates=Wu.prototype.getOrientedFlatCoordinates;var Rs=Wu;var p_=class extends or{constructor(e){super(),this.projection=Ci(e.projection),this.attributions_=I1(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(a,c){r.viewResolver=a,r.viewRejector=c})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=I1(e),this.changed()}setState(e){this.state_=e,this.changed()}};function I1(h){return h?typeof h=="function"?h:(Array.isArray(h)||(h=[h]),e=>h):null}var Mo=p_;var Ur={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function C1(h,e){return[[-1/0,-1/0,1/0,1/0]]}var QC=!1;function eE(h,e,r,a,c,s,y){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,a,c):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=QC,v.onload=function(b){if(!v.status||v.status>=200&&v.status<300){let T=e.getType();try{let C;T=="text"||T=="json"?C=v.responseText:T=="xml"?C=v.responseXML||v.responseText:T=="arraybuffer"&&(C=v.response),C?s(e.readFeatures(C,{extent:r,featureProjection:c}),e.readProjection(C)):y()}catch{y()}}else y()},v.onerror=y,v.send()}function f_(h,e){return function(r,a,c,s,y){let v=this;eE(h,e,r,a,c,function(b,T){v.addFeatures(b),s!==void 0&&s(b)},y||vs)}}var Ks=class extends Si{constructor(e,r,a){super(e),this.feature=r,this.features=a}},m_=class extends Mo{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=vs,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(ui(this.format_,"`format` must be set when `url` is set"),this.loader_=f_(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:C1;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new $u:null,this.loadedExtentsRtree_=new $u,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let a,c;Array.isArray(e.features)?c=e.features:e.features&&(a=e.features,c=a.getArray()),!r&&a===void 0&&(a=new Eu(c)),c!==void 0&&this.addFeaturesInternal(c),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Vt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let a=e.getGeometry();if(a){let c=a.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(c,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Ks(Ur.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof Rs||(this.featureChangeKeys_[e]=[Sr(r,pi.CHANGE,this.handleFeatureChange_,this),Sr(r,op.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let a=!0;if(r.getId()!==void 0){let c=String(r.getId());if(!(c in this.idIndex_))this.idIndex_[c]=r;else if(r instanceof Rs){let s=this.idIndex_[c];s instanceof Rs?Array.isArray(s)?s.push(r):this.idIndex_[c]=[s,r]:a=!1}else a=!1}return a&&(ui(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),a}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],a=[],c=[];for(let s=0,y=e.length;s<y;s++){let v=e[s],b=Vt(v);this.addToIndex_(b,v)&&a.push(v)}for(let s=0,y=a.length;s<y;s++){let v=a[s],b=Vt(v);this.setupChangeEvents_(b,v);let T=v.getGeometry();if(T){let C=T.getExtent();r.push(C),c.push(v)}else this.nullGeometryFeatures_[b]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,c),this.hasListener(Ur.ADDFEATURE))for(let s=0,y=a.length;s<y;s++)this.dispatchEvent(new Ks(Ur.ADDFEATURE,a[s]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(Ur.ADDFEATURE,function(a){r||(r=!0,e.push(a.feature),r=!1)}),this.addEventListener(Ur.REMOVEFEATURE,function(a){r||(r=!0,e.remove(a.feature),r=!1)}),e.addEventListener(Ts.ADD,a=>{r||(r=!0,this.addFeature(a.element),r=!1)}),e.addEventListener(Ts.REMOVE,a=>{r||(r=!0,this.removeFeature(a.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let a in this.featureChangeKeys_)this.featureChangeKeys_[a].forEach(jr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(a=>{this.removeFeatureInternal(a)});for(let a in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[a])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Ks(Ur.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let a=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(a,function(c){let s=c.getGeometry();if(s instanceof Rs||s.intersectsCoordinate(e))return r(c)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(a){let c=a.getGeometry();if(c instanceof Rs||c.intersectsExtent(e)){let s=r(a);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Wn(this.nullGeometryFeatures_)||wr(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(a){r.push(a)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let c=uv(e,r);return[].concat(...c.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let a=e[0],c=e[1],s=null,y=[NaN,NaN],v=1/0,b=[-1/0,-1/0,1/0,1/0];return r=r||lp,this.featuresRtree_.forEachInExtent(b,function(T){if(r(T)){let C=T.getGeometry(),k=v;if(v=C instanceof Rs?0:C.closestPointXY(a,c,y,v),v<k){s=T;let O=Math.sqrt(v);b[0]=a-O,b[1]=c-O,b[2]=a+O,b[3]=c+O}}}),s}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,a=Vt(r),c=r.getGeometry();if(!c)a in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[a]=r);else{let y=c.getExtent();a in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[a],this.featuresRtree_&&this.featuresRtree_.insert(y,r)):this.featuresRtree_&&this.featuresRtree_.update(y,r)}let s=r.getId();if(s!==void 0){let y=s.toString();this.idIndex_[y]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[y]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[a]=r;this.changed(),this.dispatchEvent(new Ks(Ur.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Vt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,a){let c=this.loadedExtentsRtree_,s=this.strategy_(e,r,a);for(let y=0,v=s.length;y<v;++y){let b=s[y];c.forEachInExtent(b,function(C){return go(C.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADSTART)),this.loader_.call(this,b,r,a,C=>{--this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADEND,void 0,C))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADERROR))}),c.insert(b,{extent:b.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,a=r.forEachInExtent(e,function(c){if(fp(c.extent,e))return c});a&&r.remove(a)}removeFeatures(e){let r=!1;for(let a=0,c=e.length;a<c;++a)r=this.removeFeatureInternal(e[a])||r;r&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Vt(e);if(!(r in this.uidIndex_))return!1;r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[r]?.forEach(jr),delete this.featureChangeKeys_[r];let c=e.getId();if(c!==void 0){let s=c.toString(),y=this.idIndex_[s];y===e?delete this.idIndex_[s]:Array.isArray(y)&&(y.splice(y.indexOf(e),1),y.length===1&&(this.idIndex_[s]=y[0]))}return delete this.uidIndex_[r],this.hasListener(Ur.REMOVEFEATURE)&&this.dispatchEvent(new Ks(Ur.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(let r in this.idIndex_)if(this.idIndex_[r]===e){delete this.idIndex_[r];break}}setLoader(e){this.loader_=e}setUrl(e){ui(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(f_(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}},yl=m_;var Kn={SINGLECLICK:"singleclick",CLICK:pi.CLICK,DBLCLICK:pi.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var g_={ACTIVE:"active"};var y_=class extends or{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(g_.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(g_.ACTIVE,e)}setMap(e){this.map_=e}};var E1=y_;var __=class extends E1{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Kn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Kn.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==Kn.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,r=this.stopDown(a)}else e.type==Kn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var T1=__;var M1=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var P1=lp,A1=function(h){return h.type==Kn.CLICK};var R1=function(h){return h.type==Kn.SINGLECLICK};var k1=function(h){let e=h.originalEvent;return ui(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var x_=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=us,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let a=r.dataProjection?Ci(r.dataProjection):this.readProjection(e);r.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Ci(a),a.setWorldExtent(r.extent)),r={dataProjection:a,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return wt()}readFeature(e,r){return wt()}readFeatures(e,r){return wt()}readGeometry(e,r){return wt()}readProjection(e){return wt()}writeFeature(e,r){return wt()}writeFeatures(e,r){return wt()}writeGeometry(e,r){return wt()}},L1=x_;function nf(h,e,r){let a=r?Ci(r.featureProjection):null,c=r?Ci(r.dataProjection):null,s=h;if(a&&c&&!Bv(a,c)){e&&(s=h.clone());let y=e?a:c,v=e?c:a;y.getUnits()==="tile-pixels"?s.transform(y,v):s.applyTransform(ll(y,v))}if(e&&r&&r.decimals!==void 0){let y=Math.pow(10,r.decimals),v=function(b){for(let T=0,C=b.length;T<C;++T)b[T]=Math.round(b[T]*y)/y;return b};s===h&&(s=h.clone()),s.applyTransform(v)}return s}var tE={Point:lr,LineString:Is,Polygon:Tc,MultiPoint:yu,MultiLineString:Og,MultiPolygon:qg};function iE(h,e,r){return Array.isArray(e[0])?(kp(h,0,e,r)||(h=h.slice(),vu(h,0,e,r)),h):(xu(h,0,e,r)||(h=h.slice(),Ec(h,0,e,r)),h)}function v_(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(s=>v_({...h,geometry:s})).flat();let a=r.type==="MultiPolygon"?"Polygon":r.type;if(a==="GeometryCollection"||a==="Circle")throw new Error("Unsupported geometry type: "+a);let c=r.layout.length;return nf(new Rs(a,a==="Polygon"?iE(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function sf(h,e){if(!h)return null;if(Array.isArray(h)){let a=h.map(c=>sf(c,e));return new Pg(a)}let r=tE[h.type];return nf(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var b_=class extends L1{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(of(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(of(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return wt()}readFeaturesFromObject(e,r){return wt()}readGeometry(e,r){return this.readGeometryFromObject(of(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return wt()}readProjection(e){return this.readProjectionFromObject(of(e))}readProjectionFromObject(e){return wt()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return wt()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return wt()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return wt()}};function of(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var D1=b_;var w_=class extends D1{constructor(e){e=e||{},super(),this.dataProjection=Ci(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Ci(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let a=null;e.type==="Feature"?a=e:a={type:"Feature",geometry:e,properties:null};let c=I_(a.geometry,r);if(this.featureClass===Rs)return v_({geometry:c,id:a.id,properties:a.properties},r);let s=new us;return this.geometryName_?s.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&s.setGeometryName(a.geometry_name),s.setGeometry(sf(c,r)),"id"in a&&s.setId(a.id),a.properties&&s.setProperties(a.properties,!0),s}readFeaturesFromObject(e,r){let a=e,c=null;if(a.type==="FeatureCollection"){let s=e;c=[];let y=s.features;for(let v=0,b=y.length;v<b;++v){let T=this.readFeatureFromObject(y[v],r);T&&c.push(T)}}else c=[this.readFeatureFromObject(e,r)];return c.flat()}readGeometryFromObject(e,r){return rE(e,r)}readProjectionFromObject(e){let r=e.crs,a;if(r)if(r.type=="name")a=Ci(r.properties.name);else if(r.type==="EPSG")a=Ci("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else a=this.dataProjection;return a}writeFeatureObject(e,r){r=this.adaptOptions(r);let a={type:"Feature",geometry:null,properties:null},c=e.getId();if(c!==void 0&&(a.id=c),!e.hasProperties())return a;let s=e.getProperties(),y=e.getGeometry();return y&&(a.geometry=S_(y,r),delete s[e.getGeometryName()]),Wn(s)||(a.properties=s),a}writeFeaturesObject(e,r){r=this.adaptOptions(r);let a=[];for(let c=0,s=e.length;c<s;++c)a.push(this.writeFeatureObject(e[c],r));return{type:"FeatureCollection",features:a}}writeGeometryObject(e,r){return S_(e,this.adaptOptions(r))}};function I_(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=sE(h);break}case"LineString":{r=oE(h);break}case"Polygon":{r=hE(h);break}case"MultiPoint":{r=lE(h);break}case"MultiLineString":{r=aE(h);break}case"MultiPolygon":{r=cE(h);break}case"GeometryCollection":{r=nE(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function rE(h,e){let r=I_(h,e);return sf(r,e)}function nE(h,e){return h.geometries.map(function(a){return I_(a,e)})}function sE(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:da(e.length)}}function oE(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:da(e[0]?.length||2)}}function aE(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,a=[],c=pa(a,0,e,r);return{type:"MultiLineString",flatCoordinates:a,ends:c,layout:da(r)}}function lE(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:da(e[0]?.length||2)}}function cE(h){let e=h.coordinates,r=[],a=e[0]?.[0]?.[0].length||2,c=Ep(r,0,e,a);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:da(a)}}function hE(h){let e=h.coordinates,r=[],a=e[0]?.[0]?.length,c=pa(r,0,e,a);return{type:"Polygon",flatCoordinates:r,ends:c,layout:da(a)}}function S_(h,e){h=nf(h,!0,e);let r=h.getType(),a;switch(r){case"Point":{a=gE(h,e);break}case"LineString":{a=dE(h,e);break}case"Polygon":{a=yE(h,e);break}case"MultiPoint":{a=fE(h,e);break}case"MultiLineString":{a=pE(h,e);break}case"MultiPolygon":{a=mE(h,e);break}case"GeometryCollection":{a=uE(h,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return a}function uE(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(a){return S_(a,e)})}}function dE(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function pE(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function fE(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function mE(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function gE(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function yE(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var hr=w_;var F1=0,Zu=1,z1=[0,0,0,0],Gc=[],C_={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Xu=class extends Si{constructor(e,r,a){super(e),this.features=r,this.mapBrowserEvent=a}},E_=class extends T1{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:k1,this.defaultDeleteCondition_=function(a){return M1(a)&&R1(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:P1,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new $u,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new jc({source:new yl({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:xE(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new Eu(this.source_.getFeatures()),this.source_.addEventListener(Ur.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Ur.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Ts.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Ts.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(e,r)}let a=this.getMap();a&&a.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(a.getCoordinateFromPixel(this.lastPixel_)),e.addEventListener(pi.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Eu;let a=this.featuresBeingModified_.getArray();for(let c=0,s=r.length;c<s;++c){let y=r[c].feature;y&&!a.includes(y)&&this.featuresBeingModified_.push(y)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Xu(C_.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(pi.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,a=[];r.forEach(function(c){e===c.feature&&a.push(c)});for(let c=a.length-1;c>=0;--c){let s=a[c];for(let y=this.dragSegments_.length-1;y>=0;--y)this.dragSegments_[y][0]===s&&this.dragSegments_.splice(y,1);r.remove(s)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let a=r.getCoordinates(),c={feature:e,geometry:r,segment:[a,a]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c],v={feature:e,geometry:r,depth:[c],index:c,segment:[y,y]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length-1;c<s;++c){let y=a.slice(c,c+2),v={feature:e,geometry:r,index:c,segment:y};this.rBush_.insert(ss(y),v)}}writeMultiLineStringGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length-1;v<b;++v){let T=y.slice(v,v+2),C={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(ss(T),C)}}}writePolygonGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length-1;v<b;++v){let T=y.slice(v,v+2),C={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(ss(T),C)}}}writeMultiPolygonGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length;v<b;++v){let T=y[v];for(let C=0,k=T.length-1;C<k;++C){let O=T.slice(C,C+2),G={feature:e,geometry:r,depth:[v,c],index:C,segment:O};this.rBush_.insert(ss(O),G)}}}}writeCircleGeometry_(e,r){let a=r.getCenter(),c={feature:e,geometry:r,index:F1,segment:[a,a]},s={feature:e,geometry:r,index:Zu,segment:[a,a]},y=[c,s];c.featureSegments=y,s.featureSegments=y,this.rBush_.insert(ca(a),c);let v=r,b=Zn();if(b&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(b,T),v=Gg(v).transform(T,b)}this.rBush_.insert(v.getExtent(),s)}writeGeometryCollectionGeometry_(e,r){let a=r.getGeometriesArray();for(let c=0;c<a.length;++c){let s=a[c],y=this.SEGMENT_WRITERS_[s.getType()];y(e,s)}}createOrUpdateVertexFeature_(e,r,a,c){let s=this.vertexFeature_;return s?s.getGeometry().setCoordinates(e):(s=new us(new lr(e)),this.vertexFeature_=s,this.overlay_.getSource().addFeature(s)),s.set("features",r),s.set("geometries",a),s.set("existing",c),s}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Kn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Kn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Kn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}findInsertVerticesAndUpdateDragSegments_(e){this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null;let r=this.vertexFeature_;if(!r)return;let a=this.getMap().getView().getProjection(),c=[],s=r.getGeometry().getCoordinates(),y=ss([s]),v=this.rBush_.getInExtent(y),b={};v.sort(_E);for(let T=0,C=v.length;T<C;++T){let k=v[T],O=k.segment,G=Vt(k.geometry),J=k.depth;if(J&&(G+="-"+J.join("-")),b[G]||(b[G]=new Array(2)),k.geometry.getType()==="Circle"&&k.index===Zu){let le=B1(e,k,a);Zi(le,s)&&!b[G][0]&&(this.dragSegments_.push([k,0]),b[G][0]=k);continue}if(Zi(O[0],s)&&!b[G][0]){this.dragSegments_.push([k,0]),b[G][0]=k;continue}if(Zi(O[1],s)&&!b[G][1]){if(b[G][0]&&b[G][0].index===0){let le=k.geometry.getCoordinates();switch(k.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":le=le[J[1]];case"Polygon":if(k.index!==le[J[0]].length-2)continue;break;default:}}this.dragSegments_.push([k,1]),b[G][1]=k;continue}Vt(O)in this.vertexSegments_&&!b[G][0]&&!b[G][1]&&c.push(k)}return c}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([s])=>s));let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],a=[],c=[];for(let s=0,y=this.dragSegments_.length;s<y;++s){let v=this.dragSegments_[s],b=v[0],T=b.feature;a.includes(T)||a.push(T);let C=b.geometry;c.includes(C)||c.push(C);let k=b.depth,O,G=b.segment,J=v[1];for(;r.length<C.getStride();)r.push(G[J][r.length]);switch(C.getType()){case"Point":O=r,G[0]=r,G[1]=r;break;case"MultiPoint":O=C.getCoordinates(),O[b.index]=r,G[0]=r,G[1]=r;break;case"LineString":O=C.getCoordinates(),O[b.index+J]=r,G[J]=r;break;case"MultiLineString":O=C.getCoordinates(),O[k[0]][b.index+J]=r,G[J]=r;break;case"Polygon":O=C.getCoordinates(),O[k[0]][b.index+J]=r,G[J]=r;break;case"MultiPolygon":O=C.getCoordinates(),O[k[1]][k[0]][b.index+J]=r,G[J]=r;break;case"Circle":let le=C;if(G[0]=r,G[1]=r,b.index===F1)this.changingFeature_=!0,le.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let he=e.map.getView().getProjection(),fe=gg(Ai(le.getCenter(),he),Ai(r,he)),ye=Zn();if(ye){let we=le.clone().transform(ye,he);we.setRadius(fe),fe=we.transform(he,ye).getRadius()}le.setRadius(fe),this.changingFeature_=!1}break;default:}O&&this.setGeometryCoordinates_(C,O)}this.createOrUpdateVertexFeature_(r,a,c,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate,a=this.findInsertVerticesAndUpdateDragSegments_(r);if(a?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,a),this.vertexFeature_)){let c=this.vertexFeature_.getGeometry().getCoordinates();for(let s=a.length-1;s>=0;--s)this.insertVertex_(a[s],c);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let a=this.dragSegments_[r][0],c=a.geometry;if(c.getType()==="Circle"){let s=c,y=s.getCenter(),v=a.featureSegments[0],b=a.featureSegments[1];v.segment[0]=y,v.segment[1]=y,b.segment[0]=y,b.segment[1]=y,this.rBush_.update(ca(y),v);let T=s,C=Zn();if(C){let k=e.map.getView().getProjection();T=T.clone().transform(C,k),T=Gg(T).transform(k,C)}this.rBush_.update(T.getExtent(),b)}else this.rBush_.update(ss(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Xu(C_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.coordinate)}handlePointerAtPixel_(e){let r=this.getMap(),a=r.getPixelFromCoordinate(e),c=r.getView().getProjection(),s=function(b,T){return O1(e,b,c)-O1(e,T,c)},y,v;if(this.hitDetection_){let b=typeof this.hitDetection_=="object"?T=>T===this.hitDetection_:void 0;r.forEachFeatureAtPixel(a,(T,C,k)=>{k&&k.getType()==="Point"&&(k=new lr(ua(k.getCoordinates(),c)));let O=k||T.getGeometry();if(O&&O.getType()==="Point"&&T instanceof us&&this.features_.getArray().includes(T)){v=O;let G=T.getGeometry().getFlatCoordinates().slice(0,2);y=[{feature:T,geometry:v,segment:[G,G]}]}return!0},{layerFilter:b})}if(!y){let b=Gs(ca(e,z1),c),T=r.getView().getResolution()*this.pixelTolerance_,C=js(os(b,T,z1),c);y=this.rBush_.getInExtent(C)}if(y&&y.length>0){let b=y.sort(s)[0],T=b.segment,C=B1(e,b,c),k=r.getPixelFromCoordinate(C),O=gg(a,k);if(v||O<=this.pixelTolerance_){let G={};if(G[Vt(T)]=!0,this.snapToPointer_||(this.delta_[0]=C[0]-e[0],this.delta_[1]=C[1]-e[1]),b.geometry.getType()==="Circle"&&b.index===Zu)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(C,[b.feature],[b.geometry],this.snappedToVertex_);else{let J=r.getPixelFromCoordinate(T[0]),le=r.getPixelFromCoordinate(T[1]),he=Sc(k,J),fe=Sc(k,le);O=Math.sqrt(Math.min(he,fe)),this.snappedToVertex_=O<=this.pixelTolerance_,this.snappedToVertex_&&(C=he>fe?T[1]:T[0]),this.createOrUpdateVertexFeature_(C,[b.feature],[b.geometry],this.snappedToVertex_);let ye={};ye[Vt(b.geometry)]=!0;for(let we=1,Ie=y.length;we<Ie;++we){let Pe=y[we].segment;if(Zi(T[0],Pe[0])&&Zi(T[1],Pe[1])||Zi(T[0],Pe[1])&&Zi(T[1],Pe[0])){let Ee=Vt(y[we].geometry);Ee in ye||(ye[Ee]=!0,G[Vt(Pe)]=!0)}else break}}this.vertexSegments_=G;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let a=e.segment,c=e.feature,s=e.geometry,y=e.depth,v=e.index,b;for(;r.length<s.getStride();)r.push(0);switch(s.getType()){case"MultiLineString":b=s.getCoordinates(),b[y[0]].splice(v+1,0,r);break;case"Polygon":b=s.getCoordinates(),b[y[0]].splice(v+1,0,r);break;case"MultiPolygon":b=s.getCoordinates(),b[y[1]][y[0]].splice(v+1,0,r);break;case"LineString":b=s.getCoordinates(),b.splice(v+1,0,r);break;default:return!1}this.setGeometryCoordinates_(s,b);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(s,v,y,1);let C={segment:[a[0],r],feature:c,geometry:s,depth:y,index:v};T.insert(ss(C.segment),C),this.dragSegments_.push([C,1]);let k={segment:[r,a[1]],feature:c,geometry:s,depth:y,index:v+1};return T.insert(ss(k.segment),k),this.dragSegments_.push([k,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){let e=this.vertexFeature_?.getGeometry().getCoordinates();return e?ua(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(a=>a.getType()==="Circle"||a.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ss([e])).some(({segment:a})=>Zi(a[0],e)||Zi(a[1],e))}removePoint(e){if(e&&(e=Ai(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Kn.POINTERDRAG){let r=this.lastPointerEvent_;this.willModifyFeatures_(r,this.dragSegments_.map(([c])=>c));let a=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Xu(C_.MODIFYEND,this.featuresBeingModified_,r)),this.featuresBeingModified_=null,a}return!1}removeVertex_(){let e=this.dragSegments_,r={},a=!1,c,s,y,v,b,T,C,k,O,G,J;for(b=e.length-1;b>=0;--b)y=e[b],G=y[0],J=Vt(G.feature),G.depth&&(J+="-"+G.depth.join("-")),J in r||(r[J]={}),y[1]===0?(r[J].right=G,r[J].index=G.index):y[1]==1&&(r[J].left=G,r[J].index=G.index+1);for(J in r){switch(O=r[J].right,C=r[J].left,T=r[J].index,k=T-1,C!==void 0?G=C:G=O,k<0&&(k=0),v=G.geometry,s=v.getCoordinates(),c=s,a=!1,v.getType()){case"MultiLineString":s[G.depth[0]].length>2&&(s[G.depth[0]].splice(T,1),a=!0);break;case"LineString":s.length>2&&(s.splice(T,1),a=!0);break;case"MultiPolygon":c=c[G.depth[1]];case"Polygon":c=c[G.depth[0]],c.length>4&&(T==c.length-1&&(T=0),c.splice(T,1),a=!0,T===0&&(c.pop(),c.push(c[0]),k=c.length-1));break;default:}if(a){this.setGeometryCoordinates_(v,s);let le=[];if(C!==void 0&&(this.rBush_.remove(C),le.push(C.segment[0])),O!==void 0&&(this.rBush_.remove(O),le.push(O.segment[1])),C!==void 0&&O!==void 0){let he={depth:G.depth,feature:G.feature,geometry:G.geometry,index:k,segment:le};this.rBush_.insert(ss(he.segment),he)}this.updateSegmentIndices_(v,T,G.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return a}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(a=>a.getType()==="Circle"||a.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ss([e])).some(({segment:a})=>!(Zi(a[0],e)||Zi(a[1],e)))}insertPoint(e){let r=e?Ai(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return r?this.findInsertVerticesAndUpdateDragSegments_(r).reduce((c,s)=>c||this.insertVertex_(s,r),!1):!1}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,a,c){this.rBush_.forEachInExtent(e.getExtent(),function(s){s.geometry===e&&(a===void 0||s.depth===void 0||yn(s.depth,a))&&s.index>r&&(s.index+=c)})}};function _E(h,e){return h.index-e.index}function O1(h,e,r){let a=e.geometry;if(a.getType()==="Circle"){let s=a;if(e.index===Zu){let y=Zn();y&&(s=s.clone().transform(y,r));let v=Sc(s.getCenter(),Ai(h,r)),b=Math.sqrt(v)-s.getRadius();return b*b}}let c=Ai(h,r);return Gc[0]=Ai(e.segment[0],r),Gc[1]=Ai(e.segment[1],r),bv(c,Gc)}function B1(h,e,r){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Zu){let s=a,y=Zn();return y&&(s=s.clone().transform(y,r)),ua(s.getClosestPoint(Ai(h,r)),r)}let c=Ai(h,r);return Gc[0]=Ai(e.segment[0],r),Gc[1]=Ai(e.segment[1],r),ua(mg(c,Gc),r)}function xE(){let h=Vb();return function(e,r){return h.Point}}var T_=E_;var vE=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,N1=/^([\d.]+),([\d.]+)$/,V1=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,af="stop-fetch",j1=h=>{let e=[];return h.forEach(r=>{let a=r.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},M_=class h extends Ac{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new hr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new eu({...r}),this.routingLayer=r.routingLayer||new jc({source:new yl,style:r.style}),this.onRouteError=r.onRouteError||(a=>{this.dispatchEvent(new Si("change:route")),this.reset(),console.error(a)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",a=>{a.key==="active"&&this.onActiveChange(),a.key==="mot"&&this.viaPoints&&this.drawRoute()})}static getGraphsResolutions(r,a){let c=a.getView();return r.map(([,s,y])=>[c.getResolutionForZoom(s),c.getResolutionForZoom(y||s+1)])}abortRequests(){this.graphs.forEach(r=>{let a=r[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[af]?.abort(),this.abortControllers[af]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new hr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,a=-1,c=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,c,r),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new T_({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(s=>s.getGeometry()?.getType()==="Point"&&s.get("index"));return A1(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[af]);let r=this.viaPoints.map(a=>{if(Array.isArray(a)){let c=this.getMap()?.getView().getProjection(),[s,y]=al(a,c);return this.snapToClosestStation?[`@${y}`,s]:[y,s]}return this.useRawViaPoints?a:`!${a}`});return this.loading=!0,this.viaPoints.forEach((a,c)=>{this.drawViaPoint(a,c,this.abortControllers[af])}),Promise.all(this.graphs.map(([a],c)=>{let{signal:s}=this.abortControllers[a];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:a,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:s}).then(y=>{if(this.segments=this.format.readFeatures(y),this.mot==="foot"){let T=this.segments.reduce((C,k)=>{let O=k.get("trg");return C.find(G=>G[0]===O[0]&&G[1]===O[1])?C:[...C,O]},[]);this.segments=T.map(C=>{let k=this.segments.filter(G=>{let J=G.get("trg");return J[0]===C[0]&&J[1]===C[1]}),O=j1(k);return new us({geometry:new Is(O)})})}let v=j1(this.segments),b=new us({geometry:new Is(v)});b.set("graph",a),b.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(b.set("minResolution",this.graphsResolutions[c][0]),b.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(b),this.loading=!1}).catch(y=>{/AbortError/.test(y.name)||(this.segments=[],this.dispatchEvent(new Si("error")),this.onRouteError(y,this),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,a,c){let s=new us;if(s.set("viaPointIdx",a),Array.isArray(r))return s.setGeometry(new lr(r)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s);if(!this.useRawViaPoints||V1.test(r)){let C,k;return this.useRawViaPoints?[,C,,k]=V1.exec(r)||[]:[C,k]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${C}?key=${this.stopsApiKey}`,{signal:c.signal}).then(O=>O.json()).then(O=>{let{coordinates:G}=O?.features?.[0]?.geometry||{};return G||console.log("No coordinates found for station "+C,O),this.cacheStationData[r]=ar(G),s.set("viaPointTrack",k),s.setGeometry(new lr(ar(G))),this.routingLayer?.getSource()?.addFeature(s),s}).catch(O=>{/AbortError/.test(O.message)||(this.dispatchEvent(new Si("error")),this.onRouteError(O,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)})}if(this.useRawViaPoints&&N1.test(r)){let[C,k]=N1.exec(r)||[];if(k&&C){let O=parseFloat(k),G=parseFloat(C),J=ar([O,G],this.getMap()?.getView().getProjection());return s.setGeometry(new lr(J)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s)}}let[,y,,v,b,,T]=vE.exec(r)||[];if(b&&v){let C=ar([parseFloat(b),parseFloat(v)],this.getMap()?.getView().getProjection());return s.set("viaPointTrack",T),s.setGeometry(new lr(C)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s)}return y?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${y}&limit=1`,{signal:c.signal}).then(C=>C.json()).then(C=>{let{coordinates:k}=C.features[0].geometry;return this.cacheStationData[r]=ar(k),s.set("viaPointTrack",T),s.setGeometry(new lr(ar(k))),this.routingLayer?.getSource()?.addFeature(s),s}).catch(C=>(this.dispatchEvent(new Si("error")),this.onRouteError(C,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:s=>s===this.routingLayer}).find(s=>s.getGeometry()?.getType()==="Point"&&s.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let a=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:s,viaPoint:y}=this.initialRouteDrag||{};return y?this.addViaPoint(a,y.get("viaPointIdx"),1):c?s===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(s||0)+1):this.addViaPoint(a,0,1)}onModifyStart(r){let a=-1,c=r.features.getArray().find(y=>y.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let y=os(new lr(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);a=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(y))}let s=(r.features.getArray().filter(y=>y.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:a,viaPoint:s}}removeListeners(){this.onMapClickKey&&bs(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Si("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Si("change:route"))}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}},G1=M_;var P_=class{constructor(e){let{apiKey:r,apiParams:a,placeholder:c,url:s}=e||{};this.apiParams={limit:20,...a||{}},this.placeholder=c||"Search for a stop...";let y={apiKey:r};s&&(y.url=s),this.api=new tu(y),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(a=>{let c=document.createElement("div");c.innerHTML=a?.properties?.name,c.onclick=s=>{this.options?.onSuggestionClick?.(a,s)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(a=>{this.render(a)}).catch(()=>{this.render()})}},U1=P_;var bE=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},q1=bE;var A_=class extends Ac{constructor(e){let r=q1();r.className=e?.className||"mbt-stop-finder";let a={element:r,...e||{}};super(a),this.controller=new U1({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let r=ar(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(e,r){return this.controller.search(e,r)}},$1=A_;var Z1=Vs(L_(),1);var wE="vectorTileFeature",D_={"EPSG:3857":new hr({featureProjection:"EPSG:3857"})},Ea=class extends Sa{getFeaturesAtCoordinate(e,r=5){let a=this.getMapLibrePixels(e,r);if(!a)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(a,c).map(y=>this.toOlFeature(y))||[]}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{mapLibreMap:a}=r,c=r.getMapInternal();if(!r||!c||!a)return null;let s=a.getCanvas(),{viewState:y}=e;a.jumpTo({center:al(y.center),zoom:y.zoom-1,bearing:lu(-y.rotation)});let v=r.getOpacity().toString();return s&&v!==s.style.opacity&&(s.style.opacity=v),s.isConnected?SE(s,e)||a.resize():c.render(),a.redraw(),a.getContainer()}getFeatures(e){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{let v=y.getGeometry();v instanceof Cr&&c(y,this.getLayer(),v)}),s?.[0]}getMapLibrePixels(e,r){if(!e)return;let a=this.getLayer().mapLibreMap?.project(al(e));if(a?.x===void 0||a?.y===void 0)return;let c=[a.x,a.y];if(r){let[s,y]=c;c=[[s-r,y-r],[s+r,y+r]]}return c}toOlFeature(e){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";D_[c]||(D_[c]=new hr({featureProjection:c}));let s=D_[c].readFeature(e);return s&&s.set(wE,e,!0),s}};function SE(h,e){return h.width===Math.floor(e.size[0]*e.pixelRatio)&&h.height===Math.floor(e.size[1]*e.pixelRatio)}var IE=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,a=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:s}=c.getSource();s&&(a=a.concat(s.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),CE(a)},CE=h=>{let e=h.filter(c=>c!=null&&c.trim&&c.trim()),r=e.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>e.find(s=>s.toLowerCase()===c))},F_=IE;var Uc=class extends Es{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new Mo({attributions:()=>F_(this.mapLibreMap)}),...e})}disposeInternal(){bs(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(e){super.setMapInternal(e),e?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let e=this.getMapInternal();if(e&&this.olListenersKeys.push(e.on("change:target",this.loadMapLibreMap.bind(this))),!e?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let a=this.get("mapLibreOptions");this.mapLibreMap=new Z1.Map(Object.assign({},a,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Si("load"))})}createRenderer(){return new Ea(this)}};var V_=Vs(_l());var Hu=class extends Ea{constructor(r){super(r);this.ignoreNextRender=!1;this.setIsReady=this.setIsReady.bind(this),this.ignoreNextRender=!1}renderFrame(r){let a=this.getLayer(),{mapLibreMap:c}=a,s=a.getMapInternal();if(this.getLayer()?.mapLibreMap?.off("idle",this.setIsReady),!a||!s||!c)return null;if(this.ignoreNextRender)return this.ignoreNextRender=!1,c?.getContainer();this.ready=!1;let y=super.renderFrame(r);return c?.once("idle",this.setIsReady),y}setIsReady(){this.ready||(this.ready=!0,this.ignoreNextRender=!0,this.getLayer().changed())}};var Y1=Vs(_l()),Li=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Li=(0,Y1.default)(h=>{console.warn(h)},1e3));var UE=(h,e)=>{(e||[]).forEach(r=>{r.set("parent",void 0)}),(h.get("children")||[]).forEach(r=>{r.set("parent",void 0)})},qE=(h,e)=>{e.properties&&(Li("Deprecated. Don't use properties options. Pass the values directly in options object."),h.setProperties(e.properties)),h.on("propertychange",r=>{if(r.key==="children"&&UE(r.target,r.oldValue),r.key==="map"){let a=r.target.get(r.key);a?(r.target.get("children")||[]).forEach(c=>{a.addLayer(c)}):r.oldValue&&(r.target.get("children")||[]).forEach(c=>{r.oldValue.removeLayer(c)})}}),h.set("options",e),h.set("children",e.children||[]),Object.defineProperties(h,{children:{get:()=>(Li("Layer.children is deprecated. Use the Layer.get('children') method instead."),h.get("children")||[]),set:r=>{Li("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),h.set("children",r||[])}},copyrights:{get:()=>(Li("Layer.copyrights is deprecated. Get the attributions from the source object"),h.get("copyrights")),set:r=>{Li("Layer.copyrights is deprecated. Set the attributions to the source object.");let a=r&&!Array.isArray(r)?[r]:r;h.set("copyrights",a||[])}},disabled:{get(){return Li("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),h.get("disabled")},set(r){Li("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),h.set("disabled",r)}},group:{get(){return Li("Layer.group is deprecated. Use the Layer.get('group') method instead."),h.get("group")}},hitTolerance:{get(){return Li("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.get("hitTolerance")||5},set(r){Li("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.set("hitTolerance",r)}},key:{get(){return Li('Layer.key is deprecated. Use the Layer.get("key") method instead.'),h.get("key")||h.get("name")}},map:{get(){return Li('Layer.map is deprecated. Use the Layer.get("map") method instead.'),h.getMapInternal()}},name:{get(){return Li("Layer.name is deprecated. Use the Layer.get('name') method instead."),h.get("name")}},olLayer:{get(){return Li("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."),h},set(){Li("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect.")}},options:{get(){return Li('Layer.options is deprecated. Use the Layer.get("options") method instead.'),h.get("options")},set(r){return Li('Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'),h.set("options",r)}},parent:{get(){return Li("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),h.get("parent")},set(r){Li("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),h.set("parent",r)}},visible:{get(){return Li("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),h.getVisible()},set(r){Li("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),h.setVisible(r)}}})},Ta=qE;var J1=(h,e,r,a)=>el(`${h}/styles/${e}/style.json`,{[a]:r}).toString(),B_=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(B_=(0,V_.default)(h=>{console.warn(h)},1e3));var N_=class h extends Uc{constructor(r){let a={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...r||{},mapLibreOptions:{...r.mapLibreOptions||{}}};!a.mapLibreOptions.style&&a.url?.includes("style.json")?a.mapLibreOptions.style=a.url:!a.mapLibreOptions.style&&a.apiKey&&a.style&&typeof a.style=="string"&&(a.mapLibreOptions.style=J1(a.url,a.style,a.apiKey,a.apiKeyName));super(a);this.olEventsKeys=[];Ta(this,r),this.set("options",r)}set apiKey(r){this.set("apiKey",r)}get apiKey(){return this.get("apiKey")}set apiKeyName(r){this.set("apiKeyName",r)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return B_("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return B_("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(r){this.set("style",r)}get url(){return this.get("url")}set url(r){this.set("url",r)}attachToMap(){let r=(0,V_.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style|apiKey|apiKeyName)/.test(a.key)&&r()}))}clone(r){return new h({...this.get("options")||{},...r||{}})}createRenderer(){return new Hu(this)}detachFromMap(){bs(this.olEventsKeys)}disposeInternal(){let r=this.getSource();super.disposeInternal(),this.setSource(r)}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:this.get("options")?.mapLibreOptions?.style?this.get("options").mapLibreOptions.style:J1(this.url,this.style,this.apiKey,this.apiKeyName)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(r){console.error("Error while updating MaplibreMap",r)}}},Q1=N_;var ew=Vs(_l());var j_={"EPSG:3857":new hr({featureProjection:"EPSG:3857"})},Ku=class extends Sa{forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{c(y,this.layer_,y.getGeometry())}),s?.[0]}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let a=this.getLayer(),c=a.getMapInternal(),s=a.maplibreLayer.mapLibreMap,y=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(j_[y]||(j_[y]=new hr({featureProjection:y})),s?.isStyleLoaded()){let b=e&&s.project(al(e));if(b?.x&&b?.y){let T=[b.x,b.y];if(r){let[k,O]=T;T=[[k-r,O-r],[k+r,O+r]]}let C=a.layers||[];a.layersFilter&&(C=s.getStyle().layers.filter(a.layersFilter)),a.queryRenderedLayersFilter&&(C=s.getStyle().layers.filter(a.queryRenderedLayersFilter)),v=s.queryRenderedFeatures(T,{layers:C.map(k=>k.id),validate:!1}).map(k=>{let O=j_[y].readFeature(k);return O&&O.set(Pc,k),O})}}return v}prepareFrame(){return!0}renderFrame(){return null}};var Mn=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Mn=(0,ew.default)((...h)=>{console.warn(...h)},1e3));var G_=class h extends Es{constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(Mn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(Mn("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(Mn("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new Mo({}),...r});this.highlightedFeatures=[];this.olEventsKeys=[];this.selectedFeatures=[];Ta(this,r),this.set("options",r),this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=a=>!!this.layers.find(c=>a.id===c.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return Mn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return Mn("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){Mn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(a=>{let{id:c,source:s}=a;(!s||s&&r.getSource(s))&&c&&!r.getLayer(c)&&r.addLayer(a,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([a,c])=>{r.getSource(a)||r.addSource(a,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:a}=this.maplibreLayer,c=a.getStyle(),s=this.getVisible()?"visible":"none",y=c.layers||[];for(let v=0;v<y.length;v+=1){let b=y[v];if(this.layersFilter(b)){let{id:T}=b;a.getLayer(T)&&(a.setLayoutProperty(T,"visibility",s),(this.getMinZoom()||this.getMaxZoom())&&a.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(!this.getMapInternal()||!this.maplibreLayer)return;let{mapLibreMap:c}=this.maplibreLayer;c&&(c.loaded()?this.onLoad():c.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",s=>{this.applyLayoutVisibility(s)}),this.on("propertychange",s=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(s.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",s=>{s.key==="style"&&s.target.maplibreMap.once("styledata",()=>{s.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new Ku(this)}detachFromMap(){bs(this.olEventsKeys),this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources())}getFeatureInfoAtCoordinate(r){if(Mn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:a}=this.maplibreLayer;if(!a.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=a.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=a.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let a=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(s=>s.getId()).includes(c.getId()))||[];this.setHoverState(a,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,a=r.getStyle();if(a?.layers&&this.layersFilter){let c=a.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(a=>{let{id:c}=a;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(a=>{r.getSource(a)&&r.removeSource(a)})}select(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,a){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let c=this.maplibreLayer.mapLibreMap;r.forEach(s=>{let{source:y,sourceLayer:v}=s.get(Pc)||{};if(!y&&!v||!s.getId()){s.getId()||Mn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",s.getProperties());return}c.setFeatureState({id:s.getId(),source:y,sourceLayer:v},a)})}setHoverState(r,a){Mn(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(r,{hover:a})}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap(r)):(this.detachFromMap(),super.setMapInternal(r))}},tw=G_;var Z_=Vs(_l());var q_=Vs(_l()),$_=Vs(ow());var W_=class{constructor(e){this.isIdle=!1;this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=e.mode||$i.TOPOGRAPHIC,this._speed=e.speed||1,this._style=e.style||tl,this._time=e.time||new Date,this.api=e.api||new Qh(e),this.bboxParameters=e.bboxParameters,this.canvas=e.canvas||document.createElement("canvas"),this.debug=e.debug||!1,this.filter=e.filter,this.hoverVehicleId=e.hoverVehicleId,this.live=e.live!==!1,this.minZoomInterpolation=e.minZoomInterpolation||8,this.pixelRatio=e.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=e.selectedVehicleId,this.sort=e.sort,this.styleOptions={...Mc,...e.styleOptions||{}},this.tenant=e.tenant||"",this.trajectories={},this.useDebounce=e.useDebounce||!1,this.useRequestAnimationFrame=e.useRequestAnimationFrame||!1,this.useThrottle=e.useThrottle!==!1,this.getViewState=e.getViewState||(()=>({})),this.shouldRender=e.shouldRender||(()=>!0),this.onRender=e.onRender,this.onIdle=e.onIdle,this.onStart=e.onStart,this.onStop=e.onStop,this.format=new hr,this.motsByZoom=e.motsByZoom||[Cs,Cs,Cs,Cs,Cs,Cs,Cs,Cs,Cs,Dp,Dp],this.getMotsByZoom=r=>e.getMotsByZoom?e.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=e.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>e.getGeneralizationLevelByZoom?e.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=e.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>e.getRenderTimeIntervalByZoom?e.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=e.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,$_.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,q_.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}get mode(){return this._mode}set mode(e){e!==this._mode&&(this._mode=e,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(e){this._speed=e,this.start()}get style(){return this._style}set style(e){this._style=e,this.renderTrajectories()}get time(){return this._time}set time(e){this._time=e?.getTime?e:new Date(e),this.renderTrajectories()}addTrajectory(e){this.trajectories||(this.trajectories={});let r=e.properties.train_id;r!==void 0&&(this.trajectories[r]=e),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let e=this.canvas.getContext("2d");e&&e.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,a=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(a)||25,s=Math.max(25,c/(this.speed||1)),y=Math.min(s,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,$_.default)(this.renderTrajectoriesInternal,y,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,q_.default)(this.renderTrajectoriesInternal,y,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[y,v]}return s}getVehicles(e){return this.trajectories&&Object.values(this.trajectories).filter(e)||[]}getVehiclesAtCoordinate(e,r){let{resolution:a}=this.getViewState(),{hitTolerance:c,nb:s}=r||{},y=os([...e,...e],(c||5)*(a||1)),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let b=[];for(let T=0;T<v.length;T+=1){let{coordinate:C}=v[T].properties;if(C&&rl(y,C)&&b.push(v[T]),b.length===s)break}return{features:b,type:"FeatureCollection"}}onDeleteTrajectoryMessage(e){e.content&&this.removeTrajectory(e.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(e){if(this.updateIdleState(),!e.content)return;let r=e.content,{geometry:a,properties:{raw_coordinates:c,time_since_update:s}}=r;s<0||this.purgeTrajectory(r)||(this.debug&&this.mode===$i.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:ar(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(a),r.properties.timeOffset=Date.now()-e.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([e,r])=>{let a=r?.properties?.time_intervals;this.time&&a?.length&&a[a.length-1][0]<this.time.getTime()&&this.removeTrajectory(e)})}purgeTrajectory(e){let a=this.getViewState().extent,{bounds:c,type:s}=e.properties;return this.isUpdateBboxOnMoveEnd&&a&&!Vi(a,c)||this.mots&&!this.mots.includes(s)?(this.removeTrajectory(e),!0):!1}removeTrajectory(e){let r;typeof e!="string"?r=e?.properties?.train_id:r=e,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(e){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!e&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,e)}):!e&&this.useDebounce?this.debounceRenderTrajectories(r,e):!e&&this.useThrottle?this.throttleRenderTrajectories(r,e):this.renderTrajectoriesInternal(r,e))}renderTrajectoriesInternal(e,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let a=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=Su(this.canvas,c,this.style,{...e,pixelRatio:this.pixelRatio||1,time:a},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(e.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,e)),!0}setBbox(){this.updateIdleState();let e=this.getViewState(),r=e.extent,a=e.zoom||0;if(!r||Number.isNaN(a))return;if(this.trajectories&&r&&a){let C=Object.keys(this.trajectories);for(let k=C.length-1;k>=0;k-=1)this.purgeTrajectory(this.trajectories[C[k]])}let c=Math.floor(a);if(!r||Number.isNaN(c))return;let[s,y,v,b]=r,T=[Math.floor(s),Math.floor(y),Math.ceil(v),Math.ceil(b),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&T.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([C,k])=>{T.push(`${C}=${k}`)}),this.api.bbox=T}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}updateIdleState(){this.isIdle=!1,clearTimeout(this._idleTimeout),this._idleTimeout=window.setTimeout(()=>{this.isIdle=!0,this.onIdle?.(this)},1e3)}},cf=W_;var lT=new hr,Yu=class extends rf{forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{c(y,this.layer_,y.getGeometry())}),s?.[0]}getData(e){let r;try{let{pixelRatio:a}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(a||1),e[1]*(a||1),1,1).data||null,r}catch(a){console.error("error getting data",a)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let a=this.getLayer(),c=a.engine.getVehiclesAtCoordinate(e,{hitTolerance:r,nb:a.maxNbFeaturesRequested});return lT.readFeatures(c)}prepareFrame(){return!0}renderFrame(e){let{canvas:r,engine:a,renderedViewState:c}=this.getLayer();if(this.getLayer().engine.pixelRatio=e.pixelRatio,this.ready=!!a.renderState?.renderedTrajectories&&a.isIdle,this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),c){let{center:s,resolution:y,rotation:v}=e.viewState,{center:b,resolution:T,rotation:C}=c;if(T/y>=3){let k=r?.getContext("2d");r?.width&&r?.height&&k?.clearRect(0,0,r.width,r.height)}else{let k=this.getLayer().getMapInternal(),O=k?.getPixelFromCoordinate(b),G=k?.getPixelFromCoordinate(s);O&&G&&(this.container.style.transform=Jx(O[0]-G[0],O[1]-G[1],T/y,T/y,v-C,0,0))}}return this.container}};var cT=new Tr({image:new En({fill:new Er({color:"#000000"}),radius:5}),stroke:new Xi({color:"#000000",width:6}),zIndex:2}),hT=(h,e,r)=>{let a="#ffffff",c=h.get("type"),s=h.get("stroke");return s&&s[0]!=="#"&&(s=`#${s}`),a=s||r?.getBgColor(c),a=/#ffffff/i.test(a)?"#ff0000":a,[cT,new Tr({image:new En({fill:new Er({color:a}),radius:4}),stroke:new Xi({color:a,width:4}),zIndex:3})]},hf=hT;var uT=new Tr({image:new En({fill:new Er({color:"#000000"}),radius:5}),stroke:new Xi({color:"#000000",width:6}),zIndex:2}),dT=new Tr({image:new En({fill:new Er({color:"#a0a0a0"}),radius:4}),stroke:new Xi({color:"#a0a0a0",width:4}),zIndex:3}),pT=()=>[uT,dT],aw=pT;var lw=new En({fill:new Er({color:[255,0,0,1]}),radius:6,stroke:new Xi({color:[0,0,0,1],width:1})}),fT=new Tr({stroke:new Xi({color:[0,0,0,1],width:5})}),mT=new Tr({image:lw,stroke:new Xi({color:[255,0,0,1],width:3})}),gT=new Tr({image:lw,stroke:new Xi({color:[255,0,0,1],lineDash:[1,10],width:3})}),yT=(h,e)=>{let r=h.get("minResolution"),a=h.get("maxResolution"),c=e<=r&&e>a;if(r&&a&&!c)return[];let s=h?.getGeometry()?.getType()==="Point"?100:0,y=[fT,mT];return h.get("mot")==="foot"&&(y=[gT]),y=y.map(b=>{let T=b.clone();return T.setZIndex(s),T}),y},cw=yT;var _T=new hr,X_=class h extends Es{constructor(r){super({source:new Mo({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.olEventsKeys=[];Ta(this,r),this.engine=new cf({getViewState:this.getViewState.bind(this),onIdle:this.onRealtimeEngineIdle.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new jc({source:new yl({features:[]}),style:(a,c)=>(r.fullTrajectoryStyle||hf)(a,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,Z_.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,Z_.default)(this.onMoveEnd,100)}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}set filter(r){this.engine.filter=r}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}set sort(r){this.engine.sort=r}get trajectories(){return this.engine.trajectories}attachToMap(){this.engine.attachToMap();let r=this.getMapInternal();r&&(this.getVisible()&&this.engine.start(),this.olEventsKeys.push(r.on("movestart",()=>{this.engine.isUpdateBboxOnMoveEnd&&this.engine.updateIdleState()}),...r.on(["moveend","change:target"],a=>{let c=(a.map||a.target).getView();if(!c||c?.getAnimating()||c?.getInteracting())return;let s=c.getZoom();this.currentZoom!==s&&this.onZoomEndDebounced(a),this.currentZoom=s,this.onMoveEndDebounced(a)}),this.on("change:visible",a=>{a.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",a=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(a.key)&&this.vectorLayer.set(a.key,a.target.get(a.key))})))}cleanVectorLayer(){this.vectorLayer?.getSource()?.clear(!0),this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer)}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new Yu(this)}detachFromMap(){bs(this.olEventsKeys),this.getMapInternal()?.removeLayer(this.vectorLayer),this.engine.detachFromMap()}async getFullTrajectory(r){let a=await this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.getMapInternal()?.getView()?.getZoom()||0)));return a?.content?.features?.length?_T.readFeatures(a?.content):[]}async getStopSequences(r){return(await this.engine.api.getStopSequence(r))?.content}async getTrajectoryInfos(r){let a=[this.getStopSequences(r),this.getFullTrajectory(r)],[c,s]=await Promise.all(a);return{fullTrajectory:s,stopSequences:c}}getVehicles(r){return this.engine.getVehicles(r)}getViewState(){let r=this.getMapInternal();if(!r?.getView())return{};let a=r.getView();return{center:a.getCenter(),extent:a.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:a.getResolution(),rotation:a.getRotation(),size:r.getSize(),visible:this.getVisible(),zoom:a.getZoom()}}highlight(r){let a=r?.get("train_id");this.hoverVehicleId!==a&&(this.hoverVehicleId=a,this.engine.renderTrajectories(!0))}async highlightTrajectory(r){if(!r){this.cleanVectorLayer();return}let a=await this.getFullTrajectory(r);if(!a?.length){this.cleanVectorLayer();return}a.length&&this.vectorLayer?.getSource()?.addFeatures(a),this.vectorLayer.getMapInternal()&&this.vectorLayer.getMapInternal()!==this.getMapInternal()&&this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);let c=this.getZIndex();if(c!==void 0)this.vectorLayer.setZIndex(c-1),this.vectorLayer.getMapInternal()||this.getMapInternal()?.addLayer(this.vectorLayer);else if(!this.vectorLayer.getMapInternal()){let s=this.getMapInternal()?.getLayers().getArray().indexOf(this)||0;s&&this.getMapInternal()?.getLayers().insertAt(s,this.vectorLayer)}return a}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineIdle(){this.changed()}onRealtimeEngineRender(r,a){this.renderedViewState={...a};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let a=r?.get("train_id");this.selectedVehicleId!==a&&(this.selectedVehicleId=a,this.engine.renderTrajectories(!0)),this.highlightTrajectory(a)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}shouldRender(){return this.allowRenderWhenAnimating?!1:this.getMapInternal()?.getView().getAnimating()||this.getMapInternal()?.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}},hw=X_;var uw=Vs(_l());var dw=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(dw=(0,uw.default)(h=>{console.warn(h)},1e3));var H_=class extends Sa{prepareFrame(){return!0}renderFrame(){return null}},K_=class h extends Es{constructor(e){super(e),Ta(this,e),dw("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new h({...this.get("options")||{},...e||{}})}createRenderer(){return new H_(this)}},uf=K_;var Y_=class h extends uf{clone(e){return new h({...this.get("options"),...e})}getFeatureInfoAtCoordinate(e){let r=[],a=this.getMapInternal();if(a){let c=a.getPixelFromCoordinate(e);r=a.getFeaturesAtPixel(c,{hitTolerance:this.get("hitTolerance")||5,layerFilter:s=>s===this})||[]}return Promise.resolve({coordinate:e,features:r,layer:this})}},pw=Y_;var xT=new hr,vT=(h,e,r)=>{let a,{coordinate:c,params:s,projection:y,resolution:v}=e;return h&&v&&y&&(a=h.getFeatureInfoUrl(c,v,y,{info_format:"application/json",query_layers:h.getParams().layers,...s})),fetch(a,{signal:r.signal}).then(b=>b.json()).then(b=>xT.readFeatures(b)).catch(()=>[])},Ju={},bT=async(h,e,r=5)=>{Object.values(Ju).forEach(s=>{s?.abort()}),Ju={};let c=ru(e).map(s=>{let y=s.getMapInternal(),v=y?.getView()?.getProjection()?.getCode(),b={coordinate:h,features:[],layer:s};if(!v)return Promise.resolve(b);if(s.getFeatureInfoAtCoordinate)return s.getFeatureInfoAtCoordinate(h);let T=s?.getSource();if(T?.getFeatureInfoUrl){let O=Vt(s);Ju[O]?.abort(),Ju[O]=new AbortController;let G=y?.getView()?.getResolution();return vT(T,{coordinate:h,params:{info_format:"application/json",query_layers:T.getParams().layers},projection:v,resolution:G},Ju[O]).then(J=>({coordinate:h,features:J,layer:s})).catch(()=>({coordinate:h,features:[],layer:s}))}let C=y?.getPixelFromCoordinate(h);if(!C)return Promise.resolve(b);let k=y?.getFeaturesAtPixel(C,{hitTolerance:s.get("hitTolerance")||r||5,layerFilter:O=>O===s});return Promise.resolve({coordinate:h,features:k,layer:s})});return Promise.all(c)},fw=bT;var gf={};Lm(gf,{CopyrightControl:()=>mw,Layer:()=>pf,RealtimeAPI:()=>Qh,RealtimeLayer:()=>Lw,RealtimeModes:()=>$i,RoutingAPI:()=>eu,StopsAPI:()=>tu,VECTOR_TILE_FEATURE_PROPERTY:()=>Pc,compareDepartures:()=>Iu,createCanvas:()=>_s,createRealtimeFilters:()=>Km,debounceDeparturesMessages:()=>$g,debounceWebsocketMessages:()=>Jh,getCircleCanvas:()=>Wm,getDelayBgCanvas:()=>qm,getDelayTextCanvas:()=>$m,getHoursAndMinutes:()=>Hx,getLayersAsFlatArray:()=>ru,getMapGlCopyrights:()=>iu,getMercatorResolution:()=>kw,getSourceCoordinates:()=>mf,getTextCanvas:()=>Zm,getUTCDateString:()=>Zx,getUTCTimeString:()=>Xx,getUrlWithParams:()=>el,getVehiclePosition:()=>wu,pad:()=>sp,realtimeConfig:()=>Mc,realtimeDefaultStyle:()=>tl,realtimeDelayStyle:()=>Xm,realtimeSimpleStyle:()=>Hm,removeDuplicate:()=>il,renderTrajectories:()=>Su,sortAndFilterDepartures:()=>Cu,sortByDelay:()=>Ym});var wT=" | ",J_=class{constructor(e={}){this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let e=this.options?.separator||wT,r=this.options?.customAttribution||iu(this.map),a=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},mw=J_;var yw=Vs(L_());var Mr=[];for(let h=0;h<256;++h)Mr.push((h+256).toString(16).slice(1));function gw(h,e=0){return(Mr[h[e+0]]+Mr[h[e+1]]+Mr[h[e+2]]+Mr[h[e+3]]+"-"+Mr[h[e+4]]+Mr[h[e+5]]+"-"+Mr[h[e+6]]+Mr[h[e+7]]+"-"+Mr[h[e+8]]+Mr[h[e+9]]+"-"+Mr[h[e+10]]+Mr[h[e+11]]+Mr[h[e+12]]+Mr[h[e+13]]+Mr[h[e+14]]+Mr[h[e+15]]).toLowerCase()}var Q_,ST=new Uint8Array(16);function e0(){if(!Q_){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Q_=crypto.getRandomValues.bind(crypto)}return Q_(ST)}var IT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),t0={randomUUID:IT};function CT(h,e,r){if(t0.randomUUID&&!e&&!h)return t0.randomUUID();h=h||{};let a=h.random||(h.rng||e0)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){r=r||0;for(let c=0;c<16;++c)e[r+c]=a[c];return e}return gw(a)}var i0=CT;var r0=class extends yw.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||i0()}onAdd(r,a){this.map=r}onRemove(r,a){this.map=void 0}render(r){}},pf=r0;var Pr=63710088e-1,xw={centimeters:Pr*100,centimetres:Pr*100,degrees:360/(2*Math.PI),feet:Pr*3.28084,inches:Pr*39.37,kilometers:Pr/1e3,kilometres:Pr/1e3,meters:Pr,metres:Pr,miles:Pr/1609.344,millimeters:Pr*1e3,millimetres:Pr*1e3,nauticalmiles:Pr/1852,radians:1,yards:Pr*1.0936};function ET(h,e,r={}){let a={type:"Feature"};return(r.id===0||r.id)&&(a.id=r.id),r.bbox&&(a.bbox=r.bbox),a.properties=e||{},a.geometry=h,a}function xl(h,e,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_w(h[0])||!_w(h[1]))throw new Error("coordinates must contain numbers");return ET({type:"Point",coordinates:h},e,r)}function TT(h,e="kilometers"){let r=xw[e];if(!r)throw new Error(e+" units is invalid");return h*r}function MT(h,e="kilometers"){let r=xw[e];if(!r)throw new Error(e+" units is invalid");return h/r}function vw(h){return h%(2*Math.PI)*180/Math.PI}function vl(h){return h%360*Math.PI/180}function ff(h,e="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return TT(MT(h,e),r)}function _w(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function bw(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function Qu(h,e,r){if(h!==null)for(var a,c,s,y,v,b,T,C=0,k=0,O,G=h.type,J=G==="FeatureCollection",le=G==="Feature",he=J?h.features.length:1,fe=0;fe<he;fe++){T=J?h.features[fe].geometry:le?h.geometry:h,O=T?T.type==="GeometryCollection":!1,v=O?T.geometries.length:1;for(var ye=0;ye<v;ye++){var we=0,Ie=0;if(y=O?T.geometries[ye]:T,y!==null){b=y.coordinates;var Pe=y.type;switch(C=r&&(Pe==="Polygon"||Pe==="MultiPolygon")?1:0,Pe){case null:break;case"Point":if(e(b,k,fe,we,Ie)===!1)return!1;k++,we++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],k,fe,we,Ie)===!1)return!1;k++,Pe==="MultiPoint"&&we++}Pe==="LineString"&&we++;break;case"Polygon":case"MultiLineString":for(a=0;a<b.length;a++){for(c=0;c<b[a].length-C;c++){if(e(b[a][c],k,fe,we,Ie)===!1)return!1;k++}Pe==="MultiLineString"&&we++,Pe==="Polygon"&&Ie++}Pe==="Polygon"&&we++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(Ie=0,c=0;c<b[a].length;c++){for(s=0;s<b[a][c].length-C;s++){if(e(b[a][c][s],k,fe,we,Ie)===!1)return!1;k++}Ie++}we++}break;case"GeometryCollection":for(a=0;a<y.geometries.length;a++)if(Qu(y.geometries[a],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ww(h,e={}){let r=0,a=0,c=0;return Qu(h,function(s){r+=s[0],a+=s[1],c++},!0),xl([r/c,a/c],e.properties)}function Ys(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Sw(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Cw(h,e,r={}){let a;return r.final?a=Iw(Ys(e),Ys(h)):a=Iw(Ys(h),Ys(e)),a>180?-(360-a):a}function Iw(h,e){let r=vl(h[1]),a=vl(e[1]),c=vl(e[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let s=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),y=Math.atan2(c,s);return(vw(y)+360)%360}function Ew(h,e,r={}){let a=Ys(h),c=Ys(e);c[0]+=c[0]-a[0]>180?-360:a[0]-c[0]>180?360:0;let s=PT(a,c);return ff(s,"meters",r.units)}function PT(h,e,r){r=r===void 0?Pr:Number(r);let a=r,c=h[1]*Math.PI/180,s=e[1]*Math.PI/180,y=s-c,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);let b=Math.log(Math.tan(s/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),T=Math.abs(b)>1e-11?y/b:Math.cos(c);return Math.sqrt(y*y+T*T*v*v)*a}function Tw(h,e,r,a={}){let c=e<0,s=ff(Math.abs(e),a.units,"meters");c&&(s=-Math.abs(s));let y=Ys(h),v=AT(y,s,r);return v[0]+=v[0]-y[0]>180?-360:y[0]-v[0]>180?360:0,xl(v,a.properties)}function AT(h,e,r,a){a=a===void 0?Pr:Number(a);let c=e/a,s=h[0]*Math.PI/180,y=vl(h[1]),v=vl(r),b=c*Math.cos(v),T=y+b;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);let C=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(y/2+Math.PI/4)),k=Math.abs(C)>1e-11?b/C:Math.cos(y),O=c*Math.sin(v)/k;return[((s+O)*180/Math.PI+540)%360-180,T*180/Math.PI]}function Mw(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return Pw(h);case"FeatureCollection":return RT(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return n0(h);default:throw new Error("unknown GeoJSON type")}}function Pw(h){let e={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=Aw(h.properties),h.geometry==null?e.geometry=null:e.geometry=n0(h.geometry),e}function Aw(h){let e={};return h&&Object.keys(h).forEach(r=>{let a=h[r];typeof a=="object"?a===null?e[r]=null:Array.isArray(a)?e[r]=a.map(c=>c):e[r]=Aw(a):e[r]=a}),e}function RT(h){let e={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(r=>Pw(r)),e}function n0(h){let e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(r=>n0(r)),e):(e.coordinates=Rw(h.coordinates),e)}function Rw(h){let e=h;return typeof e[0]!="object"?e.slice():e.map(r=>Rw(r))}function kT(h,e,r){if(r=r||{},!bw(r))throw new Error("options is invalid");let a=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");if(e===0)return h;let s=a??ww(h);return(c===!1||c===void 0)&&(h=Mw(h)),Qu(h,function(y){let b=Cw(s,y)+e,T=Ew(s,y),C=Sw(Tw(s,T,b));y[0]=C[0],y[1]=C[1]}),h}var s0=kT;var LT=(h,e=1)=>{let{height:r,width:a}=h.getCanvas(),c=h.unproject({x:0,y:0}),s=h.unproject({x:0,y:r/e}),y=h.unproject({x:a/e,y:r/e}),v=h.unproject({x:a/e,y:0});return[[c.lng,c.lat],[v.lng,v.lat],[y.lng,y.lat],[s.lng,s.lat]]},mf=LT;var DT=h=>{let e=h.getBounds().toArray(),r=ar(e[0]),a=ar(e[1]),c=[...r,...a],{width:s,height:y}=h.getCanvas(),v=vi(c)/s,b=Wi(c)/y;return Math.max(v,b)},kw=DT;var o0=class extends pf{get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(e){this.engine.pixelRatio=e||1}#e;constructor(e={}){let r=e?.id||"realtime";super({...e,id:"realtime-custom-"+r}),this.#e=r,this.engine=new cf({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...e}),this.sourceId=this.#e,this.source={animate:!0,attribution:e.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:e,width:r}=this.map.getCanvas(),a=this.map.getCenter(),c=this.map.unproject({x:0,y:e/this.pixelRatio}),s=this.map.unproject({x:r/this.pixelRatio,y:0}),y=s0(xl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,v=s0(xl([s.lng,s.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,b=[...ar(y),...ar(v)],T=vi(b)/(r/this.pixelRatio),C=Wi(b)/(e/this.pixelRatio),k=Math.max(T,C);return{center:ar([a.lng,a.lat]),extent:b,pixelRatio:this.pixelRatio,resolution:k,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,e/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(e,r){super.onAdd(e,r),this.engine.attachToMap(),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let e=mf(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(e)}}onRemove(e,r){this.engine.detachFromMap(),this.stop(),e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.sourceId)&&e.removeSource(this.sourceId),super.onRemove(e,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}},Lw=o0;var a0={ol:df,maplibre:gf};typeof window<"u"&&(window.mbt=a0);var AV=a0;})();
585
+ `){xt+=rt,rt=0,Ae=k*we+Be*O,++at;continue}let kt=G[ot+1]||b.font;kt!==gt&&(c&&st.push("font",kt),a&&ct.push("font",kt),gt=kt),rt=Math.max(rt,fe[Rt]);let Lt=[Pt,Ae+Be*he[Rt]+k*(he[Rt]-ye[at]),.5*(O+rt)+xt];Ae+=he[Rt],c&&st.push("strokeText",Lt),a&&ct.push("fillText",Lt),++Rt}return Array.prototype.push.apply(Ie,st),Array.prototype.push.apply(Ie,ct),this.labels_[s]=Ge,Ge}replayTextBackground_(e,r,a,c,s,y,v){e.beginPath(),e.moveTo.apply(e,r),e.lineTo.apply(e,a),e.lineTo.apply(e,c),e.lineTo.apply(e,s),e.lineTo.apply(e,r),y&&(this.alignAndScaleFill_=y[2],this.fill_(e)),v&&(this.setStrokeStyle_(e,v),e.stroke())}calculateImageOrLabelDimensions_(e,r,a,c,s,y,v,b,T,C,k,O,G,J,le,he){v*=O[0],b*=O[1];let fe=a-v,ye=c-b,we=s+T>e?e-T:s,Ie=y+C>r?r-C:y,Pe=J[3]+we*O[0]+J[1],Ee=J[0]+Ie*O[1]+J[2],Ge=fe-J[3],Be=ye-J[0];(le||k!==0)&&(Ia[0]=Ge,Ca[0]=Ge,Ia[1]=Be,Eo[1]=Be,Eo[0]=Ge+Pe,To[0]=Eo[0],To[1]=Be+Ee,Ca[1]=To[1]);let Ae;return k!==0?(Ae=Vr(sr(),a,c,1,1,k,-a,-c),br(Ae,Ia),br(Ae,Eo),br(Ae,To),br(Ae,Ca),yo(Math.min(Ia[0],Eo[0],To[0],Ca[0]),Math.min(Ia[1],Eo[1],To[1],Ca[1]),Math.max(Ia[0],Eo[0],To[0],Ca[0]),Math.max(Ia[1],Eo[1],To[1],Ca[1]),Vc)):yo(Math.min(Ge,Ge+Pe),Math.min(Be,Be+Ee),Math.max(Ge,Ge+Pe),Math.max(Be,Be+Ee),Vc),G&&(fe=Math.round(fe),ye=Math.round(ye)),{drawImageX:fe,drawImageY:ye,drawImageW:we,drawImageH:Ie,originX:T,originY:C,declutterBox:{minX:Vc[0],minY:Vc[1],maxX:Vc[2],maxY:Vc[3],value:he},canvasTransform:Ae,scale:O}}replayImageOrLabel_(e,r,a,c,s,y,v){let b=!!(y||v),T=c.declutterBox,C=v?v[2]*c.scale[0]/2:0;return T.minX-C<=r[0]&&T.maxX+C>=0&&T.minY-C<=r[1]&&T.maxY+C>=0&&(b&&this.replayTextBackground_(e,Ia,Eo,To,Ca,y,v),Ob(e,c.canvasTransform,s,a,c.originX,c.originY,c.drawImageW,c.drawImageH,c.drawImageX,c.drawImageY,c.scale)),!0}fill_(e){let r=this.alignAndScaleFill_;if(r){let a=br(this.renderedTransform_,[0,0]),c=512*this.pixelRatio;e.save(),e.translate(a[0]%c,a[1]%c),r!==1&&e.scale(r,r),e.rotate(this.viewRotation_)}e.fill(),r&&e.restore()}setStrokeStyle_(e,r){e.strokeStyle=r[1],e.lineWidth=r[2],e.lineCap=r[3],e.lineJoin=r[4],e.miterLimit=r[5],e.lineDashOffset=r[7],e.setLineDash(r[6])}drawLabelWithPointPlacement_(e,r,a,c){let s=this.textStates[r],y=this.createLabel(e,r,c,a),v=this.strokeStates[a],b=this.pixelRatio,T=t_(Array.isArray(e)?e[0]:e,s.textAlign||xa),C=qu[s.textBaseline||pl],k=v&&v.lineWidth?v.lineWidth:0,O=y.width/b-2*s.scale[0],G=T*O+2*(.5-T)*k,J=C*y.height/b+2*(.5-C)*k;return{label:y,anchorX:G,anchorY:J}}execute_(e,r,a,c,s,y,v,b){let T=this.zIndexContext_,C;this.pixelCoordinates_&&yn(a,this.renderedTransform_)?C=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),C=vn(this.coordinates,0,this.coordinates.length,2,a,this.pixelCoordinates_),Yx(this.renderedTransform_,a));let k=0,O=c.length,G=0,J,le,he,fe,ye,we,Ie,Pe,Ee,Ge,Be,Ae,st,ct=0,rt=0,xt=null,Rt=null,at=this.coordinateCache_,gt=this.viewRotation_,ot=Math.round(Math.atan2(-a[1],a[0])*1e12)/1e12,pt={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:gt},Pt=this.instructions!=c||this.overlaps?0:200,kt,Lt,$t,fi;for(;k<O;){let $e=c[k];switch($e[0]){case dt.BEGIN_GEOMETRY:kt=$e[1],fi=$e[3],kt.getGeometry()?v!==void 0&&!Vi(v,fi.getExtent())?k=$e[2]+1:++k:k=$e[2],T&&(T.zIndex=$e[4]);break;case dt.BEGIN_PATH:ct>Pt&&(this.fill_(e),ct=0),rt>Pt&&(e.stroke(),rt=0),!ct&&!rt&&(e.beginPath(),ye=NaN,we=NaN),++k;break;case dt.CIRCLE:G=$e[1];let di=C[G],ur=C[G+1],dr=C[G+2],rn=C[G+3],ji=dr-di,nn=rn-ur,sn=Math.sqrt(ji*ji+nn*nn);e.moveTo(di+sn,ur),e.arc(di,ur,sn,0,2*Math.PI,!0),++k;break;case dt.CLOSE_PATH:e.closePath(),++k;break;case dt.CUSTOM:G=$e[1],J=$e[2];let Pn=$e[3],ve=$e[4],An=$e[5];pt.geometry=Pn,pt.feature=kt,k in at||(at[k]=[]);let pr=at[k];An?An(C,G,J,2,pr):(pr[0]=C[G],pr[1]=C[G+1],pr.length=2),T&&(T.zIndex=$e[6]),ve(pr,pt),++k;break;case dt.DRAW_IMAGE:G=$e[1],J=$e[2],Ee=$e[3],le=$e[4],he=$e[5];let bt=$e[6],Zt=$e[7],Rn=$e[8],on=$e[9],Ar=$e[10],an=$e[11],fr=$e[12],Yn=$e[13];fe=$e[14]||"declutter";let kn=$e[15];if(!Ee&&$e.length>=20){Ge=$e[19],Be=$e[20],Ae=$e[21],st=$e[22];let ae=this.drawLabelWithPointPlacement_(Ge,Be,Ae,st);Ee=ae.label,$e[3]=Ee;let de=$e[23];le=(ae.anchorX-de)*this.pixelRatio,$e[4]=le;let ie=$e[24];he=(ae.anchorY-ie)*this.pixelRatio,$e[5]=he,bt=Ee.height,$e[6]=bt,Yn=Ee.width,$e[13]=Yn}let De;$e.length>25&&(De=$e[25]);let Rr,Ei,mr;$e.length>17?(Rr=$e[16],Ei=$e[17],mr=$e[18]):(Rr=wo,Ei=!1,mr=!1),Ar&&ot?an+=gt:!Ar&&!ot&&(an-=gt);let Jn=0;for(;G<J;G+=2){if(De&&De[Jn++]<Yn/this.pixelRatio)continue;let ae=this.calculateImageOrLabelDimensions_(Ee.width,Ee.height,C[G],C[G+1],Yn,bt,le,he,Rn,on,an,fr,s,Rr,Ei||mr,kt),de=[e,r,Ee,ae,Zt,Ei?xt:null,mr?Rt:null];if(b){let ie,xe,Se;if(kn){let Ne=J-G;if(!kn[Ne]){kn[Ne]={args:de,declutterMode:fe};continue}let Ke=kn[Ne];ie=Ke.args,xe=Ke.declutterMode,delete kn[Ne],Se=u1(ie)}let _e,ke;if(ie&&(xe!=="declutter"||!b.collides(Se))&&(_e=!0),(fe!=="declutter"||!b.collides(ae.declutterBox))&&(ke=!0),xe==="declutter"&&fe==="declutter"){let Ne=_e&&ke;_e=Ne,ke=Ne}_e&&(xe!=="none"&&b.insert(Se),this.replayImageOrLabel_.apply(this,ie)),ke&&(fe!=="none"&&b.insert(ae.declutterBox),this.replayImageOrLabel_.apply(this,de))}else this.replayImageOrLabel_.apply(this,de)}++k;break;case dt.DRAW_CHARS:let Fe=$e[1],St=$e[2],ht=$e[3],Ki=$e[4];st=$e[5];let qr=$e[6],yt=$e[7],$r=$e[8];Ae=$e[9];let Wr=$e[10];Ge=$e[11],Be=$e[12];let Ln=[$e[13],$e[13]];fe=$e[14]||"declutter";let ln=$e[15],Q=this.textStates[Be],N=Q.font,B=[Q.scale[0]*yt,Q.scale[1]*yt],q;N in this.widths_?q=this.widths_[N]:(q={},this.widths_[N]=q);let X=Ap(C,Fe,St,2),se=Math.abs(B[0])*wy(N,Ge,q);if(Ki||se<=X){let ae=this.textStates[Be].textAlign,de=(X-se)*t_(Ge,ae),ie=h1(C,Fe,St,2,Ge,de,qr,Math.abs(B[0]),wy,N,q,ot?0:this.viewRotation_,ln);e:if(ie){let xe=[],Se,_e,ke,Ne,Ke;if(Ae)for(Se=0,_e=ie.length;Se<_e;++Se){Ke=ie[Se],ke=Ke[4],Ne=this.createLabel(ke,Be,"",Ae),le=Ke[2]+(B[0]<0?-Wr:Wr),he=ht*Ne.height+(.5-ht)*2*Wr*B[1]/B[0]-$r;let Ct=this.calculateImageOrLabelDimensions_(Ne.width,Ne.height,Ke[0],Ke[1],Ne.width,Ne.height,le,he,0,0,Ke[3],Ln,!1,wo,!1,kt);if(b&&fe==="declutter"&&b.collides(Ct.declutterBox))break e;xe.push([e,r,Ne,Ct,1,null,null])}if(st)for(Se=0,_e=ie.length;Se<_e;++Se){Ke=ie[Se],ke=Ke[4],Ne=this.createLabel(ke,Be,st,""),le=Ke[2],he=ht*Ne.height-$r;let Ct=this.calculateImageOrLabelDimensions_(Ne.width,Ne.height,Ke[0],Ke[1],Ne.width,Ne.height,le,he,0,0,Ke[3],Ln,!1,wo,!1,kt);if(b&&fe==="declutter"&&b.collides(Ct.declutterBox))break e;xe.push([e,r,Ne,Ct,1,null,null])}b&&fe!=="none"&&b.load(xe.map(u1));for(let Ct=0,vt=xe.length;Ct<vt;++Ct)this.replayImageOrLabel_.apply(this,xe[Ct])}}++k;break;case dt.END_GEOMETRY:if(y!==void 0){kt=$e[1];let ae=y(kt,fi,fe);if(ae)return ae}++k;break;case dt.FILL:Pt?ct++:this.fill_(e),++k;break;case dt.MOVE_TO_LINE_TO:for(G=$e[1],J=$e[2],Lt=C[G],$t=C[G+1],e.moveTo(Lt,$t),ye=Lt+.5|0,we=$t+.5|0,G+=2;G<J;G+=2)Lt=C[G],$t=C[G+1],Ie=Lt+.5|0,Pe=$t+.5|0,(G==J-2||Ie!==ye||Pe!==we)&&(e.lineTo(Lt,$t),ye=Ie,we=Pe);++k;break;case dt.SET_FILL_STYLE:xt=$e,this.alignAndScaleFill_=$e[2],ct&&(this.fill_(e),ct=0,rt&&(e.stroke(),rt=0)),e.fillStyle=$e[1],++k;break;case dt.SET_STROKE_STYLE:Rt=$e,rt&&(e.stroke(),rt=0),this.setStrokeStyle_(e,$e),++k;break;case dt.STROKE:Pt?rt++:e.stroke(),++k;break;default:++k;break}}ct&&this.fill_(e),rt&&e.stroke()}execute(e,r,a,c,s,y){this.viewRotation_=c,this.execute_(e,r,a,this.instructions,s,void 0,void 0,y)}executeHitDetection(e,r,a,c,s){return this.viewRotation_=a,this.execute_(e,[e.canvas.width,e.canvas.height],r,this.hitDetectionInstructions,!0,c,s)}},p1=i_;var gl=["Polygon","Circle","LineString","Image","Text","Default"],s_=["Image","Text"],f1=gl.filter(h=>!s_.includes(h)),n_=class{constructor(e,r,a,c,s,y,v){this.maxExtent_=e,this.overlaps_=c,this.pixelRatio_=a,this.resolution_=r,this.renderBuffer_=y,this.executorsByZIndex_={},this.hitDetectionContext_=null,this.hitDetectionTransform_=sr(),this.renderedContext_=null,this.deferredZIndexContexts_={},this.createExecutors_(s,v)}clip(e,r){let a=this.getClipCoords(r);e.beginPath(),e.moveTo(a[0],a[1]),e.lineTo(a[2],a[3]),e.lineTo(a[4],a[5]),e.lineTo(a[6],a[7]),e.clip()}createExecutors_(e,r){for(let a in e){let c=this.executorsByZIndex_[a];c===void 0&&(c={},this.executorsByZIndex_[a]=c);let s=e[a];for(let y in s){let v=s[y];c[y]=new p1(this.resolution_,this.pixelRatio_,this.overlaps_,v,r)}}}hasExecutors(e){for(let r in this.executorsByZIndex_){let a=this.executorsByZIndex_[r];for(let c=0,s=e.length;c<s;++c)if(e[c]in a)return!0}return!1}forEachFeatureAtCoordinate(e,r,a,c,s,y){c=Math.round(c);let v=c*2+1,b=Vr(this.hitDetectionTransform_,c+.5,c+.5,1/r,-1/r,-a,-e[0],-e[1]),T=!this.hitDetectionContext_;T&&(this.hitDetectionContext_=Ri(v,v,void 0,{willReadFrequently:!0}));let C=this.hitDetectionContext_;C.canvas.width!==v||C.canvas.height!==v?(C.canvas.width=v,C.canvas.height=v):T||C.clearRect(0,0,v,v);let k;this.renderBuffer_!==void 0&&(k=xn(),ng(k,e),os(k,r*(this.renderBuffer_+c),k));let O=GC(c),G;function J(Pe,Ee,Ge){let Be=C.getImageData(0,0,v,v).data;for(let Ae=0,st=O.length;Ae<st;Ae++)if(Be[O[Ae]]>0){if(!y||Ge==="none"||G!=="Image"&&G!=="Text"||y.includes(Pe)){let ct=(O[Ae]-3)/4,rt=c-ct%v,xt=c-(ct/v|0),Rt=s(Pe,Ee,rt*rt+xt*xt);if(Rt)return Rt}C.clearRect(0,0,v,v);break}}let le=Object.keys(this.executorsByZIndex_).map(Number);le.sort(xs);let he,fe,ye,we,Ie;for(he=le.length-1;he>=0;--he){let Pe=le[he].toString();for(ye=this.executorsByZIndex_[Pe],fe=gl.length-1;fe>=0;--fe)if(G=gl[fe],we=ye[G],we!==void 0&&(Ie=we.executeHitDetection(C,b,a,J,k),Ie))return Ie}}getClipCoords(e){let r=this.maxExtent_;if(!r)return null;let a=r[0],c=r[1],s=r[2],y=r[3],v=[a,c,a,y,s,y,s,c];return vn(v,0,8,2,e,v),v}isEmpty(){return Wn(this.executorsByZIndex_)}execute(e,r,a,c,s,y,v){let b=Object.keys(this.executorsByZIndex_).map(Number);b.sort(v?iv:xs),y=y||gl;let T=gl.length;for(let C=0,k=b.length;C<k;++C){let O=b[C].toString(),G=this.executorsByZIndex_[O];for(let J=0,le=y.length;J<le;++J){let he=y[J],fe=G[he];if(fe!==void 0){let ye=v===null?void 0:fe.getZIndexContext(),we=ye?ye.getContext():e,Ie=this.maxExtent_&&he!=="Image"&&he!=="Text";if(Ie&&(we.save(),this.clip(we,a)),!ye||he==="Text"||he==="Image"?fe.execute(we,r,a,c,s,v):ye.pushFunction(Pe=>fe.execute(Pe,r,a,c,s,v)),Ie&&we.restore(),ye){ye.offset();let Pe=b[C]*T+J;this.deferredZIndexContexts_[Pe]||(this.deferredZIndexContexts_[Pe]=[]),this.deferredZIndexContexts_[Pe].push(ye)}}}}this.renderedContext_=e}getDeferredZIndexContexts(){return this.deferredZIndexContexts_}getRenderedContext(){return this.renderedContext_}renderDeferred(){let e=this.deferredZIndexContexts_,r=Object.keys(e).map(Number).sort(xs);for(let a=0,c=r.length;a<c;++a)e[r[a]].forEach(s=>{s.draw(this.renderedContext_),s.clear()}),e[r[a]].length=0}},r_={};function GC(h){if(r_[h]!==void 0)return r_[h];let e=h*2+1,r=h*h,a=new Array(r+1);for(let s=0;s<=h;++s)for(let y=0;y<=h;++y){let v=s*s+y*y;if(v>r)break;let b=a[v];b||(b=[],a[v]=b),b.push(((h+s)*e+(h+y))*4+3),s>0&&b.push(((h-s)*e+(h+y))*4+3),y>0&&(b.push(((h+s)*e+(h-y))*4+3),s>0&&b.push(((h-s)*e+(h-y))*4+3))}let c=[];for(let s=0,y=a.length;s<y;++s)a[s]&&c.push(...a[s]);return r_[h]=c,c}var m1=n_;var o_=class extends ef{constructor(e,r,a,c,s,y,v){super(),this.context_=e,this.pixelRatio_=r,this.extent_=a,this.transform_=c,this.transformRotation_=c?_v(Math.atan2(c[1],c[0]),10):0,this.viewRotation_=s,this.squaredTolerance_=y,this.userTransform_=v,this.contextFillState_=null,this.contextStrokeState_=null,this.contextTextState_=null,this.fillState_=null,this.strokeState_=null,this.image_=null,this.imageAnchorX_=0,this.imageAnchorY_=0,this.imageHeight_=0,this.imageOpacity_=0,this.imageOriginX_=0,this.imageOriginY_=0,this.imageRotateWithView_=!1,this.imageRotation_=0,this.imageScale_=[0,0],this.imageWidth_=0,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=!1,this.textRotation_=0,this.textScale_=[0,0],this.textFillState_=null,this.textStrokeState_=null,this.textState_=null,this.pixelCoordinates_=[],this.tmpLocalTransform_=sr()}drawImages_(e,r,a,c){if(!this.image_)return;let s=vn(e,r,a,c,this.transform_,this.pixelCoordinates_),y=this.context_,v=this.tmpLocalTransform_,b=y.globalAlpha;this.imageOpacity_!=1&&(y.globalAlpha=b*this.imageOpacity_);let T=this.imageRotation_;this.transformRotation_===0&&(T-=this.viewRotation_),this.imageRotateWithView_&&(T+=this.viewRotation_);for(let C=0,k=s.length;C<k;C+=2){let O=s[C]-this.imageAnchorX_,G=s[C+1]-this.imageAnchorY_;if(T!==0||this.imageScale_[0]!=1||this.imageScale_[1]!=1){let J=O+this.imageAnchorX_,le=G+this.imageAnchorY_;Vr(v,J,le,1,1,T,-J,-le),y.save(),y.transform.apply(y,v),y.translate(J,le),y.scale(this.imageScale_[0],this.imageScale_[1]),y.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,-this.imageAnchorX_,-this.imageAnchorY_,this.imageWidth_,this.imageHeight_),y.restore()}else y.drawImage(this.image_,this.imageOriginX_,this.imageOriginY_,this.imageWidth_,this.imageHeight_,O,G,this.imageWidth_,this.imageHeight_)}this.imageOpacity_!=1&&(y.globalAlpha=b)}drawText_(e,r,a,c){if(!this.textState_||this.text_==="")return;this.textFillState_&&this.setContextFillState_(this.textFillState_),this.textStrokeState_&&this.setContextStrokeState_(this.textStrokeState_),this.setContextTextState_(this.textState_);let s=vn(e,r,a,c,this.transform_,this.pixelCoordinates_),y=this.context_,v=this.textRotation_;for(this.transformRotation_===0&&(v-=this.viewRotation_),this.textRotateWithView_&&(v+=this.viewRotation_);r<a;r+=c){let b=s[r]+this.textOffsetX_,T=s[r+1]+this.textOffsetY_;v!==0||this.textScale_[0]!=1||this.textScale_[1]!=1?(y.save(),y.translate(b-this.textOffsetX_,T-this.textOffsetY_),y.rotate(v),y.translate(this.textOffsetX_,this.textOffsetY_),y.scale(this.textScale_[0],this.textScale_[1]),this.textStrokeState_&&y.strokeText(this.text_,0,0),this.textFillState_&&y.fillText(this.text_,0,0),y.restore()):(this.textStrokeState_&&y.strokeText(this.text_,b,T),this.textFillState_&&y.fillText(this.text_,b,T))}}moveToLineTo_(e,r,a,c,s){let y=this.context_,v=vn(e,r,a,c,this.transform_,this.pixelCoordinates_);y.moveTo(v[0],v[1]);let b=v.length;s&&(b-=2);for(let T=2;T<b;T+=2)y.lineTo(v[T],v[T+1]);return s&&y.closePath(),a}drawRings_(e,r,a,c){for(let s=0,y=a.length;s<y;++s)r=this.moveToLineTo_(e,r,a[s],c,!0);return r}drawCircle(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.fillState_||this.strokeState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=qv(e,this.transform_,this.pixelCoordinates_),a=r[2]-r[0],c=r[3]-r[1],s=Math.sqrt(a*a+c*c),y=this.context_;y.beginPath(),y.arc(r[0],r[1],s,0,2*Math.PI),this.fillState_&&y.fill(),this.strokeState_&&y.stroke()}this.text_!==""&&this.drawText_(e.getCenter(),0,2,2)}}setStyle(e){this.setFillStrokeStyle(e.getFill(),e.getStroke()),this.setImageStyle(e.getImage()),this.setTextStyle(e.getText())}setTransform(e){this.transform_=e}drawGeometry(e){switch(e.getType()){case"Point":this.drawPoint(e);break;case"LineString":this.drawLineString(e);break;case"Polygon":this.drawPolygon(e);break;case"MultiPoint":this.drawMultiPoint(e);break;case"MultiLineString":this.drawMultiLineString(e);break;case"MultiPolygon":this.drawMultiPolygon(e);break;case"GeometryCollection":this.drawGeometryCollection(e);break;case"Circle":this.drawCircle(e);break;default:}}drawFeature(e,r){let a=r.getGeometryFunction()(e);a&&(this.setStyle(r),this.drawGeometry(a))}drawGeometryCollection(e){let r=e.getGeometriesArray();for(let a=0,c=r.length;a<c;++a)this.drawGeometry(r[a])}drawPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(r,0,r.length,a),this.text_!==""&&this.drawText_(r,0,r.length,a)}drawMultiPoint(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getFlatCoordinates(),a=e.getStride();this.image_&&this.drawImages_(r,0,r.length,a),this.text_!==""&&this.drawText_(r,0,r.length,a)}drawLineString(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let r=this.context_,a=e.getFlatCoordinates();r.beginPath(),this.moveToLineTo_(a,0,a.length,e.getStride(),!1),r.stroke()}if(this.text_!==""){let r=e.getFlatMidpoint();this.drawText_(r,0,2,2)}}}drawMultiLineString(e){this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_));let r=e.getExtent();if(Vi(this.extent_,r)){if(this.strokeState_){this.setContextStrokeState_(this.strokeState_);let a=this.context_,c=e.getFlatCoordinates(),s=0,y=e.getEnds(),v=e.getStride();a.beginPath();for(let b=0,T=y.length;b<T;++b)s=this.moveToLineTo_(c,s,y[b],v,!1);a.stroke()}if(this.text_!==""){let a=e.getFlatMidpoints();this.drawText_(a,0,a.length,2)}}}drawPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_;r.beginPath(),this.drawRings_(e.getOrientedFlatCoordinates(),0,e.getEnds(),e.getStride()),this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoint();this.drawText_(r,0,2,2)}}}drawMultiPolygon(e){if(this.squaredTolerance_&&(e=e.simplifyTransformed(this.squaredTolerance_,this.userTransform_)),!!Vi(this.extent_,e.getExtent())){if(this.strokeState_||this.fillState_){this.fillState_&&this.setContextFillState_(this.fillState_),this.strokeState_&&this.setContextStrokeState_(this.strokeState_);let r=this.context_,a=e.getOrientedFlatCoordinates(),c=0,s=e.getEndss(),y=e.getStride();r.beginPath();for(let v=0,b=s.length;v<b;++v){let T=s[v];c=this.drawRings_(a,c,T,y)}this.fillState_&&r.fill(),this.strokeState_&&r.stroke()}if(this.text_!==""){let r=e.getFlatInteriorPoints();this.drawText_(r,0,r.length,2)}}}setContextFillState_(e){let r=this.context_,a=this.contextFillState_;a?a.fillStyle!=e.fillStyle&&(a.fillStyle=e.fillStyle,r.fillStyle=e.fillStyle):(r.fillStyle=e.fillStyle,this.contextFillState_={fillStyle:e.fillStyle})}setContextStrokeState_(e){let r=this.context_,a=this.contextStrokeState_;a?(a.lineCap!=e.lineCap&&(a.lineCap=e.lineCap,r.lineCap=e.lineCap),yn(a.lineDash,e.lineDash)||r.setLineDash(a.lineDash=e.lineDash),a.lineDashOffset!=e.lineDashOffset&&(a.lineDashOffset=e.lineDashOffset,r.lineDashOffset=e.lineDashOffset),a.lineJoin!=e.lineJoin&&(a.lineJoin=e.lineJoin,r.lineJoin=e.lineJoin),a.lineWidth!=e.lineWidth&&(a.lineWidth=e.lineWidth,r.lineWidth=e.lineWidth),a.miterLimit!=e.miterLimit&&(a.miterLimit=e.miterLimit,r.miterLimit=e.miterLimit),a.strokeStyle!=e.strokeStyle&&(a.strokeStyle=e.strokeStyle,r.strokeStyle=e.strokeStyle)):(r.lineCap=e.lineCap,r.setLineDash(e.lineDash),r.lineDashOffset=e.lineDashOffset,r.lineJoin=e.lineJoin,r.lineWidth=e.lineWidth,r.miterLimit=e.miterLimit,r.strokeStyle=e.strokeStyle,this.contextStrokeState_={lineCap:e.lineCap,lineDash:e.lineDash,lineDashOffset:e.lineDashOffset,lineJoin:e.lineJoin,lineWidth:e.lineWidth,miterLimit:e.miterLimit,strokeStyle:e.strokeStyle})}setContextTextState_(e){let r=this.context_,a=this.contextTextState_,c=e.textAlign?e.textAlign:xa;a?(a.font!=e.font&&(a.font=e.font,r.font=e.font),a.textAlign!=c&&(a.textAlign=c,r.textAlign=c),a.textBaseline!=e.textBaseline&&(a.textBaseline=e.textBaseline,r.textBaseline=e.textBaseline)):(r.font=e.font,r.textAlign=c,r.textBaseline=e.textBaseline,this.contextTextState_={font:e.font,textAlign:c,textBaseline:e.textBaseline})}setFillStrokeStyle(e,r){if(!e)this.fillState_=null;else{let a=e.getColor();this.fillState_={fillStyle:Sn(a||Hi)}}if(!r)this.strokeState_=null;else{let a=r.getColor(),c=r.getLineCap(),s=r.getLineDash(),y=r.getLineDashOffset(),v=r.getLineJoin(),b=r.getWidth(),T=r.getMiterLimit(),C=s||In;this.strokeState_={lineCap:c!==void 0?c:$s,lineDash:this.pixelRatio_===1?C:C.map(k=>k*this.pixelRatio_),lineDashOffset:(y||Cn)*this.pixelRatio_,lineJoin:v!==void 0?v:Ws,lineWidth:(b!==void 0?b:So)*this.pixelRatio_,miterLimit:T!==void 0?T:vo,strokeStyle:Sn(a||bo)}}}setImageStyle(e){let r;if(!e||!(r=e.getSize())){this.image_=null;return}let a=e.getPixelRatio(this.pixelRatio_),c=e.getAnchor(),s=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=c[0]*a,this.imageAnchorY_=c[1]*a,this.imageHeight_=r[1]*a,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();let y=e.getScaleArray();this.imageScale_=[y[0]*this.pixelRatio_/a,y[1]*this.pixelRatio_/a],this.imageWidth_=r[0]*a}setTextStyle(e){if(!e)this.text_="";else{let r=e.getFill();if(!r)this.textFillState_=null;else{let G=r.getColor();this.textFillState_={fillStyle:Sn(G||Hi)}}let a=e.getStroke();if(!a)this.textStrokeState_=null;else{let G=a.getColor(),J=a.getLineCap(),le=a.getLineDash(),he=a.getLineDashOffset(),fe=a.getLineJoin(),ye=a.getWidth(),we=a.getMiterLimit();this.textStrokeState_={lineCap:J!==void 0?J:$s,lineDash:le||In,lineDashOffset:he||Cn,lineJoin:fe!==void 0?fe:Ws,lineWidth:ye!==void 0?ye:So,miterLimit:we!==void 0?we:vo,strokeStyle:Sn(G||bo)}}let c=e.getFont(),s=e.getOffsetX(),y=e.getOffsetY(),v=e.getRotateWithView(),b=e.getRotation(),T=e.getScaleArray(),C=e.getText(),k=e.getTextAlign(),O=e.getTextBaseline();this.textState_={font:c!==void 0?c:qp,textAlign:k!==void 0?k:xa,textBaseline:O!==void 0?O:pl},this.text_=C!==void 0?Array.isArray(C)?C.reduce((G,J,le)=>G+=le%2?" ":J,""):C:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=y!==void 0?this.pixelRatio_*y:0,this.textRotateWithView_=v!==void 0?v:!1,this.textRotation_=b!==void 0?b:0,this.textScale_=[this.pixelRatio_*T[0],this.pixelRatio_*T[1]]}}},g1=o_;var As=.5;function y1(h,e,r,a,c,s,y,v,b){let T=b?js(c,b):c,C=h[0]*As,k=h[1]*As,O=Ri(C,k);O.imageSmoothingEnabled=!1;let G=O.canvas,J=new g1(O,As,c,null,y,v,b?Cc(Zn(),b):null),le=r.length,he=Math.floor((256*256*256-1)/le),fe={};for(let we=1;we<=le;++we){let Ie=r[we-1],Pe=Ie.getStyleFunction()||a;if(!Pe)continue;let Ee=Pe(Ie,s);if(!Ee)continue;Array.isArray(Ee)||(Ee=[Ee]);let Be=(we*he).toString(16).padStart(7,"#00000");for(let Ae=0,st=Ee.length;Ae<st;++Ae){let ct=Ee[Ae],rt=ct.getGeometryFunction()(Ie);if(!rt||!Vi(T,rt.getExtent()))continue;let xt=ct.clone(),Rt=xt.getFill();Rt&&Rt.setColor(Be);let at=xt.getStroke();at&&(at.setColor(Be),at.setLineDash(null)),xt.setText(void 0);let gt=ct.getImage();if(gt){let kt=gt.getImageSize();if(!kt)continue;let Lt=Ri(kt[0],kt[1],void 0,{alpha:!1}),$t=Lt.canvas;Lt.fillStyle=Be,Lt.fillRect(0,0,$t.width,$t.height),xt.setImage(new Du({img:$t,anchor:gt.getAnchor(),anchorXUnits:"pixels",anchorYUnits:"pixels",offset:gt.getOrigin(),opacity:1,size:gt.getSize(),scale:gt.getScale(),rotation:gt.getRotation(),rotateWithView:gt.getRotateWithView()}))}let ot=xt.getZIndex()||0,pt=fe[ot];pt||(pt={},fe[ot]=pt,pt.Polygon=[],pt.Circle=[],pt.LineString=[],pt.Point=[]);let Pt=rt.getType();if(Pt==="GeometryCollection"){let kt=rt.getGeometriesArrayRecursive();for(let Lt=0,$t=kt.length;Lt<$t;++Lt){let fi=kt[Lt];pt[fi.getType().replace("Multi","")].push(fi,xt)}}else pt[Pt.replace("Multi","")].push(rt,xt)}}let ye=Object.keys(fe).map(Number).sort(xs);for(let we=0,Ie=ye.length;we<Ie;++we){let Pe=fe[ye[we]];for(let Ee in Pe){let Ge=Pe[Ee];for(let Be=0,Ae=Ge.length;Be<Ae;Be+=2){J.setStyle(Ge[Be+1]);for(let st=0,ct=e.length;st<ct;++st)J.setTransform(e[st]),J.drawGeometry(Ge[Be])}}}return O.getImageData(0,0,G.width,G.height)}function _1(h,e,r){let a=[];if(r){let c=Math.floor(Math.round(h[0])*As),s=Math.floor(Math.round(h[1])*As),y=(Ii(c,0,r.width-1)+Ii(s,0,r.height-1)*r.width)*4,v=r.data[y],b=r.data[y+1],C=r.data[y+2]+256*(b+256*v),k=Math.floor((256*256*256-1)/e.length);C&&C%k===0&&a.push(e[C/k-1])}return a}var UC=.5,x1={Point:KC,LineString:ZC,Polygon:JC,MultiPoint:YC,MultiLineString:XC,MultiPolygon:HC,GeometryCollection:WC,Circle:qC};function v1(h,e){return parseInt(Vt(h),10)-parseInt(Vt(e),10)}function a_(h,e){let r=l_(h,e);return r*r}function l_(h,e){return UC*h/e}function qC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(s||y){let b=h.getBuilder(r.getZIndex(),"Circle");b.setFillStrokeStyle(s,y),b.drawCircle(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a)}}function c_(h,e,r,a,c,s,y,v){let b=[],T=r.getImage();if(T){let O=!0,G=T.getImageState();G==It.LOADED||G==It.ERROR?O=!1:G==It.IDLE&&T.load(),O&&b.push(T.ready())}let C=r.getFill();C&&C.loading()&&b.push(C.ready());let k=b.length>0;return k&&Promise.all(b).then(()=>c(null)),$C(h,e,r,a,s,y,v),k}function $C(h,e,r,a,c,s,y){let v=r.getGeometryFunction()(e);if(!v)return;let b=v.simplifyTransformed(a,c);if(r.getRenderer())b1(h,b,r,e,y);else{let C=x1[b.getType()];C(h,b,r,e,y,s)}}function b1(h,e,r,a,c){if(e.getType()=="GeometryCollection"){let y=e.getGeometries();for(let v=0,b=y.length;v<b;++v)b1(h,y[v],r,a,c);return}h.getBuilder(r.getZIndex(),"Default").drawCustom(e,a,r.getRenderer(),r.getHitDetectionRenderer(),c)}function WC(h,e,r,a,c,s){let y=e.getGeometriesArray(),v,b;for(v=0,b=y.length;v<b;++v){let T=x1[y[v].getType()];T(h,y[v],r,a,c,s)}}function ZC(h,e,r,a,c){let s=r.getStroke();if(s){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,s),v.drawLineString(e,a,c)}let y=r.getText();if(y&&y.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(y),v.drawText(e,a,c)}}function XC(h,e,r,a,c){let s=r.getStroke();if(s){let v=h.getBuilder(r.getZIndex(),"LineString");v.setFillStrokeStyle(null,s),v.drawMultiLineString(e,a,c)}let y=r.getText();if(y&&y.getText()){let v=h.getBuilder(r.getZIndex(),"Text");v.setTextStyle(y),v.drawText(e,a,c)}}function HC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(y||s){let b=h.getBuilder(r.getZIndex(),"Polygon");b.setFillStrokeStyle(s,y),b.drawMultiPolygon(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a,c)}}function KC(h,e,r,a,c,s){let y=r.getImage(),v=r.getText(),b=v&&v.getText(),T=s&&y&&b?{}:void 0;if(y){if(y.getImageState()!=It.LOADED)return;let C=h.getBuilder(r.getZIndex(),"Image");C.setImageStyle(y,T),C.drawPoint(e,a,c)}if(b){let C=h.getBuilder(r.getZIndex(),"Text");C.setTextStyle(v,T),C.drawText(e,a,c)}}function YC(h,e,r,a,c,s){let y=r.getImage(),v=y&&y.getOpacity()!==0,b=r.getText(),T=b&&b.getText(),C=s&&v&&T?{}:void 0;if(v){if(y.getImageState()!=It.LOADED)return;let k=h.getBuilder(r.getZIndex(),"Image");k.setImageStyle(y,C),k.drawMultiPoint(e,a,c)}if(T){let k=h.getBuilder(r.getZIndex(),"Text");k.setTextStyle(b,C),k.drawText(e,a,c)}}function JC(h,e,r,a,c){let s=r.getFill(),y=r.getStroke();if(s||y){let b=h.getBuilder(r.getZIndex(),"Polygon");b.setFillStrokeStyle(s,y),b.drawPolygon(e,a,c)}let v=r.getText();if(v&&v.getText()){let b=h.getBuilder(r.getZIndex(),"Text");b.setTextStyle(v),b.drawText(e,a,c)}}var h_=class extends rf{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.animatingOrInteracting_,this.hitDetectionImageData_=null,this.clipped_=!1,this.renderedFeatures_=null,this.renderedRevision_=-1,this.renderedResolution_=NaN,this.renderedExtent_=xn(),this.wrappedRenderedExtent_=xn(),this.renderedRotation_,this.renderedCenter_=null,this.renderedProjection_=null,this.renderedPixelRatio_=1,this.renderedRenderOrder_=null,this.renderedFrameDeclutter_,this.replayGroup_=null,this.replayGroupChanged=!0,this.clipping=!0,this.targetContext_=null,this.opacity_=1}renderWorlds(e,r,a){let c=r.extent,s=r.viewState,y=s.center,v=s.resolution,b=s.projection,T=s.rotation,C=b.getExtent(),k=this.getLayer().getSource(),O=this.getLayer().getDeclutter(),G=r.pixelRatio,J=r.viewHints,le=!(J[bn.ANIMATING]||J[bn.INTERACTING]),he=this.context,fe=Math.round(vi(c)/v*G),ye=Math.round(Wi(c)/v*G),we=k.getWrapX()&&b.canWrapX(),Ie=we?vi(C):null,Pe=we?Math.ceil((c[2]-C[2])/Ie)+1:1,Ee=we?Math.floor((c[0]-C[0])/Ie):0;do{let Ge=this.getRenderTransform(y,v,0,G,fe,ye,Ee*Ie);r.declutter&&(Ge=Ge.slice(0)),e.execute(he,[he.canvas.width,he.canvas.height],Ge,T,le,a===void 0?gl:a?s_:f1,a?O&&r.declutter[O]:void 0)}while(++Ee<Pe)}setDrawContext_(){this.opacity_!==1&&(this.targetContext_=this.context,this.context=Ri(this.context.canvas.width,this.context.canvas.height,e_))}resetDrawContext_(){if(this.opacity_!==1){let e=this.targetContext_.globalAlpha;this.targetContext_.globalAlpha=this.opacity_,this.targetContext_.drawImage(this.context.canvas,0,0),this.targetContext_.globalAlpha=e,Ab(this.context),e_.push(this.context.canvas),this.context=this.targetContext_,this.targetContext_=null}}renderDeclutter(e){!this.replayGroup_||!this.getLayer().getDeclutter()||this.renderWorlds(this.replayGroup_,e,!0)}renderDeferredInternal(e){this.replayGroup_&&(this.replayGroup_.renderDeferred(),this.clipped_&&this.context.restore(),this.resetDrawContext_())}renderFrame(e,r){let a=e.layerStatesArray[e.layerIndex];this.opacity_=a.opacity;let c=e.viewState;this.prepareContainer(e,r);let s=this.context,y=this.replayGroup_,v=y&&!y.isEmpty();if(!v&&!(this.getLayer().hasListener(Us.PRERENDER)||this.getLayer().hasListener(Us.POSTRENDER)))return null;this.setDrawContext_(),this.preRender(s,e);let b=c.projection;if(this.clipped_=!1,v&&a.extent&&this.clipping){let T=Gs(a.extent,b);v=Vi(T,e.extent),this.clipped_=v&&!go(T,e.extent),this.clipped_&&this.clipUnrotated(s,e,T)}return v&&this.renderWorlds(y,e,this.getLayer().getDeclutter()?!1:void 0),!e.declutter&&this.clipped_&&s.restore(),this.postRender(s,e),this.renderedRotation_!==c.rotation&&(this.renderedRotation_=c.rotation,this.hitDetectionImageData_=null),e.declutter||this.resetDrawContext_(),this.container}getFeatures(e){return new Promise(r=>{if(this.frameState&&!this.hitDetectionImageData_&&!this.animatingOrInteracting_){let a=this.frameState.size.slice(),c=this.renderedCenter_,s=this.renderedResolution_,y=this.renderedRotation_,v=this.renderedProjection_,b=this.wrappedRenderedExtent_,T=this.getLayer(),C=[],k=a[0]*As,O=a[1]*As;C.push(this.getRenderTransform(c,s,y,As,k,O,0).slice());let G=T.getSource(),J=v.getExtent();if(G.getWrapX()&&v.canWrapX()&&!go(J,b)){let he=b[0],fe=vi(J),ye=0,we;for(;he<J[0];)--ye,we=fe*ye,C.push(this.getRenderTransform(c,s,y,As,k,O,we).slice()),he+=fe;for(ye=0,he=b[2];he>J[2];)++ye,we=fe*ye,C.push(this.getRenderTransform(c,s,y,As,k,O,we).slice()),he-=fe}let le=Zn();this.hitDetectionImageData_=y1(a,C,this.renderedFeatures_,T.getStyleFunction(),b,s,y,a_(s,this.renderedPixelRatio_),le?v:null)}r(_1(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,r,a,c,s){if(!this.replayGroup_)return;let y=r.viewState.resolution,v=r.viewState.rotation,b=this.getLayer(),T={},C=function(O,G,J){let le=Vt(O),he=T[le];if(he){if(he!==!0&&J<he.distanceSq){if(J===0)return T[le]=!0,s.splice(s.lastIndexOf(he),1),c(O,b,G);he.geometry=G,he.distanceSq=J}}else{if(J===0)return T[le]=!0,c(O,b,G);s.push(T[le]={feature:O,layer:b,geometry:G,distanceSq:J,callback:c})}},k=this.getLayer().getDeclutter();return this.replayGroup_.forEachFeatureAtCoordinate(e,y,v,a,C,k?r.declutter[k].all().map(O=>O.value):null)}handleFontsChanged(){let e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){let r=this.getLayer(),a=r.getSource();if(!a)return!1;let c=e.viewHints[bn.ANIMATING],s=e.viewHints[bn.INTERACTING],y=r.getUpdateWhileAnimating(),v=r.getUpdateWhileInteracting();if(this.ready&&!y&&c||!v&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;let b=e.extent,T=e.viewState,C=T.projection,k=T.resolution,O=e.pixelRatio,G=r.getRevision(),J=r.getRenderBuffer(),le=r.getRenderOrder();le===void 0&&(le=v1);let he=T.center.slice(),fe=os(b,J*k),ye=fe.slice(),we=[fe.slice()],Ie=C.getExtent();if(a.getWrapX()&&C.canWrapX()&&!go(Ie,e.extent)){let at=vi(Ie),gt=Math.max(vi(fe)/2,at);fe[0]=Ie[0]-gt,fe[2]=Ie[2]+gt,wv(he,C);let ot=hg(we[0],C);ot[0]<Ie[0]&&ot[2]<Ie[2]?we.push([ot[0]+at,ot[1],ot[2]+at,ot[3]]):ot[0]>Ie[0]&&ot[2]>Ie[2]&&we.push([ot[0]-at,ot[1],ot[2]-at,ot[3]])}if(this.ready&&this.renderedResolution_==k&&this.renderedRevision_==G&&this.renderedRenderOrder_==le&&this.renderedFrameDeclutter_===!!e.declutter&&go(this.wrappedRenderedExtent_,fe))return yn(this.renderedExtent_,ye)||(this.hitDetectionImageData_=null,this.renderedExtent_=ye),this.renderedCenter_=he,this.replayGroupChanged=!1,!0;this.replayGroup_=null;let Pe=new l1(l_(k,O),fe,k,O),Ee=Zn(),Ge;if(Ee){for(let at=0,gt=we.length;at<gt;++at){let ot=we[at],pt=js(ot,C);a.loadFeatures(pt,Nv(k,C),Ee)}Ge=Cc(Ee,C)}else for(let at=0,gt=we.length;at<gt;++at)a.loadFeatures(we[at],k,C);let Be=a_(k,O),Ae=!0,st=(at,gt)=>{let ot,pt=at.getStyleFunction()||r.getStyleFunction();if(pt&&(ot=pt(at,k)),ot){let Pt=this.renderFeature(at,Be,ot,Pe,Ge,this.getLayer().getDeclutter(),gt);Ae=Ae&&!Pt}},ct=js(fe,C),rt=a.getFeaturesInExtent(ct);le&&rt.sort(le);for(let at=0,gt=rt.length;at<gt;++at)st(rt[at],at);this.renderedFeatures_=rt,this.ready=Ae;let xt=Pe.finish(),Rt=new m1(fe,k,O,a.getOverlaps(),xt,r.getRenderBuffer(),!!e.declutter);return this.renderedResolution_=k,this.renderedRevision_=G,this.renderedRenderOrder_=le,this.renderedFrameDeclutter_=!!e.declutter,this.renderedExtent_=ye,this.wrappedRenderedExtent_=fe,this.renderedCenter_=he,this.renderedProjection_=C,this.renderedPixelRatio_=O,this.replayGroup_=Rt,this.hitDetectionImageData_=null,this.replayGroupChanged=!0,!0}renderFeature(e,r,a,c,s,y,v){if(!a)return!1;let b=!1;if(Array.isArray(a))for(let T=0,C=a.length;T<C;++T)b=c_(c,e,a[T],r,this.boundHandleStyleImageChange_,s,y,v)||b;else b=c_(c,e,a,r,this.boundHandleStyleImageChange_,s,y,v);return b}},w1=h_;var u_=class extends i1{constructor(e){super(e)}createRenderer(){return new w1(this)}},jc=u_;var d_=class{constructor(e){this.rbush_=new fl(e),this.items_={}}insert(e,r){let a={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3],value:r};this.rbush_.insert(a),this.items_[Vt(r)]=a}load(e,r){let a=new Array(r.length);for(let c=0,s=r.length;c<s;c++){let y=e[c],v=r[c],b={minX:y[0],minY:y[1],maxX:y[2],maxY:y[3],value:v};a[c]=b,this.items_[Vt(v)]=b}this.rbush_.load(a)}remove(e){let r=Vt(e),a=this.items_[r];return delete this.items_[r],this.rbush_.remove(a)!==null}update(e,r){let a=this.items_[Vt(r)],c=[a.minX,a.minY,a.maxX,a.maxY];fp(c,e)||(this.remove(r),this.insert(e,r))}getAll(){return this.rbush_.all().map(function(r){return r.value})}getInExtent(e){let r={minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]};return this.rbush_.search(r).map(function(c){return c.value})}forEach(e){return this.forEach_(this.getAll(),e)}forEachInExtent(e,r){return this.forEach_(this.getInExtent(e),r)}forEach_(e,r){let a;for(let c=0,s=e.length;c<s;c++)if(a=r(e[c]),a)return a;return a}isEmpty(){return Wn(this.items_)}clear(){this.rbush_.clear(),this.items_={}}getExtent(e){let r=this.rbush_.toJSON();return yo(r.minX,r.minY,r.maxX,r.maxY,e)}concat(e){this.rbush_.load(e.rbush_.all());for(let r in e.items_)this.items_[r]=e.items_[r]}},$u=d_;var S1=sr(),Wu=class h{constructor(e,r,a,c,s,y){this.styleFunction,this.extent_,this.id_=y,this.type_=e,this.flatCoordinates_=r,this.flatInteriorPoints_=null,this.flatMidpoints_=null,this.ends_=a||null,this.properties_=s,this.squaredTolerance_,this.stride_=c,this.simplifiedGeometry_}get(e){return this.properties_[e]}getExtent(){return this.extent_||(this.extent_=this.type_==="Point"?ca(this.flatCoordinates_):_c(this.flatCoordinates_,0,this.flatCoordinates_.length,2)),this.extent_}getFlatInteriorPoint(){if(!this.flatInteriorPoints_){let e=as(this.getExtent());this.flatInteriorPoints_=_u(this.flatCoordinates_,0,this.ends_,2,e,0)}return this.flatInteriorPoints_}getFlatInteriorPoints(){if(!this.flatInteriorPoints_){let e=rb(this.flatCoordinates_,this.ends_),r=Lp(this.flatCoordinates_,0,e,2);this.flatInteriorPoints_=Rp(this.flatCoordinates_,0,e,2,r)}return this.flatInteriorPoints_}getFlatMidpoint(){return this.flatMidpoints_||(this.flatMidpoints_=ul(this.flatCoordinates_,0,this.flatCoordinates_.length,2,.5)),this.flatMidpoints_}getFlatMidpoints(){if(!this.flatMidpoints_){this.flatMidpoints_=[];let e=this.flatCoordinates_,r=0,a=this.ends_;for(let c=0,s=a.length;c<s;++c){let y=a[c],v=ul(e,r,y,2,.5);wr(this.flatMidpoints_,v),r=y}}return this.flatMidpoints_}getId(){return this.id_}getOrientedFlatCoordinates(){return this.flatCoordinates_}getGeometry(){return this}getSimplifiedGeometry(e){return this}simplifyTransformed(e,r){return this}getProperties(){return this.properties_}getPropertiesInternal(){return this.properties_}getStride(){return this.stride_}getStyleFunction(){return this.styleFunction}getType(){return this.type_}transform(e){e=Ci(e);let r=e.getExtent(),a=e.getWorldExtent();if(r&&a){let c=Wi(a)/Wi(r);Vr(S1,a[0],a[3],c,-c,0,0,0),vn(this.flatCoordinates_,0,this.flatCoordinates_.length,2,S1,this.flatCoordinates_)}}applyTransform(e){e(this.flatCoordinates_,this.flatCoordinates_,this.stride_)}clone(){return new h(this.type_,this.flatCoordinates_.slice(),this.ends_?.slice(),this.stride_,Object.assign({},this.properties_),this.id_)}getEnds(){return this.ends_}enableSimplifyTransformed(){return this.simplifyTransformed=cp((e,r)=>{if(e===this.squaredTolerance_)return this.simplifiedGeometry_;this.simplifiedGeometry_=this.clone(),r&&this.simplifiedGeometry_.applyTransform(r);let a=this.simplifiedGeometry_.getFlatCoordinates(),c;switch(this.type_){case"LineString":a.length=hl(a,0,this.simplifiedGeometry_.flatCoordinates_.length,this.simplifiedGeometry_.stride_,e,a,0),c=[a.length];break;case"MultiLineString":c=[],a.length=Tp(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,e,a,0,c);break;case"Polygon":c=[],a.length=pu(a,0,this.simplifiedGeometry_.ends_,this.simplifiedGeometry_.stride_,Math.sqrt(e),a,0,c);break;default:}return c&&(this.simplifiedGeometry_=new h(this.type_,a,c,2,this.properties_,this.id_)),this.squaredTolerance_=e,this.simplifiedGeometry_}),this}};Wu.prototype.getFlatCoordinates=Wu.prototype.getOrientedFlatCoordinates;var Rs=Wu;var p_=class extends or{constructor(e){super(),this.projection=Ci(e.projection),this.attributions_=I1(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible??!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;let r=this;this.viewPromise_=new Promise(function(a,c){r.viewResolver=a,r.viewRejector=c})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=I1(e),this.changed()}setState(e){this.state_=e,this.changed()}};function I1(h){return h?typeof h=="function"?h:(Array.isArray(h)||(h=[h]),e=>h):null}var Mo=p_;var Ur={ADDFEATURE:"addfeature",CHANGEFEATURE:"changefeature",CLEAR:"clear",REMOVEFEATURE:"removefeature",FEATURESLOADSTART:"featuresloadstart",FEATURESLOADEND:"featuresloadend",FEATURESLOADERROR:"featuresloaderror"};function C1(h,e){return[[-1/0,-1/0,1/0,1/0]]}var QC=!1;function eE(h,e,r,a,c,s,y){let v=new XMLHttpRequest;v.open("GET",typeof h=="function"?h(r,a,c):h,!0),e.getType()=="arraybuffer"&&(v.responseType="arraybuffer"),v.withCredentials=QC,v.onload=function(b){if(!v.status||v.status>=200&&v.status<300){let T=e.getType();try{let C;T=="text"||T=="json"?C=v.responseText:T=="xml"?C=v.responseXML||v.responseText:T=="arraybuffer"&&(C=v.response),C?s(e.readFeatures(C,{extent:r,featureProjection:c}),e.readProjection(C)):y()}catch{y()}}else y()},v.onerror=y,v.send()}function f_(h,e){return function(r,a,c,s,y){let v=this;eE(h,e,r,a,c,function(b,T){v.addFeatures(b),s!==void 0&&s(b)},y||vs)}}var Ks=class extends Si{constructor(e,r,a){super(e),this.feature=r,this.features=a}},m_=class extends Mo{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=vs,this.format_=e.format||null,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(ui(this.format_,"`format` must be set when `url` is set"),this.loader_=f_(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:C1;let r=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=r?new $u:null,this.loadedExtentsRtree_=new $u,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let a,c;Array.isArray(e.features)?c=e.features:e.features&&(a=e.features,c=a.getArray()),!r&&a===void 0&&(a=new Eu(c)),c!==void 0&&this.addFeaturesInternal(c),a!==void 0&&this.bindFeaturesCollection_(a)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){let r=Vt(e);if(!this.addToIndex_(r,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(r,e);let a=e.getGeometry();if(a){let c=a.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(c,e)}else this.nullGeometryFeatures_[r]=e;this.dispatchEvent(new Ks(Ur.ADDFEATURE,e))}setupChangeEvents_(e,r){r instanceof Rs||(this.featureChangeKeys_[e]=[Sr(r,pi.CHANGE,this.handleFeatureChange_,this),Sr(r,op.PROPERTYCHANGE,this.handleFeatureChange_,this)])}addToIndex_(e,r){let a=!0;if(r.getId()!==void 0){let c=String(r.getId());if(!(c in this.idIndex_))this.idIndex_[c]=r;else if(r instanceof Rs){let s=this.idIndex_[c];s instanceof Rs?Array.isArray(s)?s.push(r):this.idIndex_[c]=[s,r]:a=!1}else a=!1}return a&&(ui(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=r),a}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){let r=[],a=[],c=[];for(let s=0,y=e.length;s<y;s++){let v=e[s],b=Vt(v);this.addToIndex_(b,v)&&a.push(v)}for(let s=0,y=a.length;s<y;s++){let v=a[s],b=Vt(v);this.setupChangeEvents_(b,v);let T=v.getGeometry();if(T){let C=T.getExtent();r.push(C),c.push(v)}else this.nullGeometryFeatures_[b]=v}if(this.featuresRtree_&&this.featuresRtree_.load(r,c),this.hasListener(Ur.ADDFEATURE))for(let s=0,y=a.length;s<y;s++)this.dispatchEvent(new Ks(Ur.ADDFEATURE,a[s]))}bindFeaturesCollection_(e){let r=!1;this.addEventListener(Ur.ADDFEATURE,function(a){r||(r=!0,e.push(a.feature),r=!1)}),this.addEventListener(Ur.REMOVEFEATURE,function(a){r||(r=!0,e.remove(a.feature),r=!1)}),e.addEventListener(Ts.ADD,a=>{r||(r=!0,this.addFeature(a.element),r=!1)}),e.addEventListener(Ts.REMOVE,a=>{r||(r=!0,this.removeFeature(a.element),r=!1)}),this.featuresCollection_=e}clear(e){if(e){for(let a in this.featureChangeKeys_)this.featureChangeKeys_[a].forEach(jr);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){this.featuresRtree_.forEach(a=>{this.removeFeatureInternal(a)});for(let a in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[a])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};let r=new Ks(Ur.CLEAR);this.dispatchEvent(r),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,r){let a=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(a,function(c){let s=c.getGeometry();if(s instanceof Rs||s.intersectsCoordinate(e))return r(c)})}forEachFeatureInExtent(e,r){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,r);this.featuresCollection_&&this.featuresCollection_.forEach(r)}forEachFeatureIntersectingExtent(e,r){return this.forEachFeatureInExtent(e,function(a){let c=a.getGeometry();if(c instanceof Rs||c.intersectsExtent(e)){let s=r(a);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),Wn(this.nullGeometryFeatures_)||wr(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){let r=[];return this.forEachFeatureAtCoordinateDirect(e,function(a){r.push(a)}),r}getFeaturesInExtent(e,r){if(this.featuresRtree_){if(!(r&&r.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);let c=uv(e,r);return[].concat(...c.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,r){let a=e[0],c=e[1],s=null,y=[NaN,NaN],v=1/0,b=[-1/0,-1/0,1/0,1/0];return r=r||lp,this.featuresRtree_.forEachInExtent(b,function(T){if(r(T)){let C=T.getGeometry(),k=v;if(v=C instanceof Rs?0:C.closestPointXY(a,c,y,v),v<k){s=T;let O=Math.sqrt(v);b[0]=a-O,b[1]=c-O,b[2]=a+O,b[3]=c+O}}}),s}getExtent(e){return this.featuresRtree_.getExtent(e)}getFeatureById(e){let r=this.idIndex_[e.toString()];return r!==void 0?r:null}getFeatureByUid(e){let r=this.uidIndex_[e];return r!==void 0?r:null}getFormat(){return this.format_}getOverlaps(){return this.overlaps_}getUrl(){return this.url_}handleFeatureChange_(e){let r=e.target,a=Vt(r),c=r.getGeometry();if(!c)a in this.nullGeometryFeatures_||(this.featuresRtree_&&this.featuresRtree_.remove(r),this.nullGeometryFeatures_[a]=r);else{let y=c.getExtent();a in this.nullGeometryFeatures_?(delete this.nullGeometryFeatures_[a],this.featuresRtree_&&this.featuresRtree_.insert(y,r)):this.featuresRtree_&&this.featuresRtree_.update(y,r)}let s=r.getId();if(s!==void 0){let y=s.toString();this.idIndex_[y]!==r&&(this.removeFromIdIndex_(r),this.idIndex_[y]=r)}else this.removeFromIdIndex_(r),this.uidIndex_[a]=r;this.changed(),this.dispatchEvent(new Ks(Ur.CHANGEFEATURE,r))}hasFeature(e){let r=e.getId();return r!==void 0?r in this.idIndex_:Vt(e)in this.uidIndex_}isEmpty(){return this.featuresRtree_?this.featuresRtree_.isEmpty()&&Wn(this.nullGeometryFeatures_):this.featuresCollection_?this.featuresCollection_.getLength()===0:!0}loadFeatures(e,r,a){let c=this.loadedExtentsRtree_,s=this.strategy_(e,r,a);for(let y=0,v=s.length;y<v;++y){let b=s[y];c.forEachInExtent(b,function(C){return go(C.extent,b)})||(++this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADSTART)),this.loader_.call(this,b,r,a,C=>{--this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADEND,void 0,C))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new Ks(Ur.FEATURESLOADERROR))}),c.insert(b,{extent:b.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){let r=this.loadedExtentsRtree_,a=r.forEachInExtent(e,function(c){if(fp(c.extent,e))return c});a&&r.remove(a)}removeFeatures(e){let r=!1;for(let a=0,c=e.length;a<c;++a)r=this.removeFeatureInternal(e[a])||r;r&&this.changed()}removeFeature(e){if(!e)return;this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){let r=Vt(e);if(!(r in this.uidIndex_))return!1;r in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[r]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.featureChangeKeys_[r]?.forEach(jr),delete this.featureChangeKeys_[r];let c=e.getId();if(c!==void 0){let s=c.toString(),y=this.idIndex_[s];y===e?delete this.idIndex_[s]:Array.isArray(y)&&(y.splice(y.indexOf(e),1),y.length===1&&(this.idIndex_[s]=y[0]))}return delete this.uidIndex_[r],this.hasListener(Ur.REMOVEFEATURE)&&this.dispatchEvent(new Ks(Ur.REMOVEFEATURE,e)),!0}removeFromIdIndex_(e){for(let r in this.idIndex_)if(this.idIndex_[r]===e){delete this.idIndex_[r];break}}setLoader(e){this.loader_=e}setUrl(e){ui(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(f_(e,this.format_))}setOverlaps(e){this.overlaps_=e,this.changed()}},yl=m_;var Kn={SINGLECLICK:"singleclick",CLICK:pi.CLICK,DBLCLICK:pi.DBLCLICK,POINTERDRAG:"pointerdrag",POINTERMOVE:"pointermove",POINTERDOWN:"pointerdown",POINTERUP:"pointerup",POINTEROVER:"pointerover",POINTEROUT:"pointerout",POINTERENTER:"pointerenter",POINTERLEAVE:"pointerleave",POINTERCANCEL:"pointercancel"};var g_={ACTIVE:"active"};var y_=class extends or{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(g_.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(g_.ACTIVE,e)}setMap(e){this.map_=e}};var E1=y_;var __=class extends E1{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let r=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==Kn.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==Kn.POINTERUP){let a=this.handleUpEvent(e);this.handlingDownUpSequence=a&&this.targetPointers.length>0}}else if(e.type==Kn.POINTERDOWN){let a=this.handleDownEvent(e);this.handlingDownUpSequence=a,r=this.stopDown(a)}else e.type==Kn.POINTERMOVE&&this.handleMoveEvent(e);return!r}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}};var T1=__;var M1=function(h){let e=h.originalEvent;return e.altKey&&!(e.metaKey||e.ctrlKey)&&!e.shiftKey};var P1=lp,A1=function(h){return h.type==Kn.CLICK};var R1=function(h){return h.type==Kn.SINGLECLICK};var k1=function(h){let e=h.originalEvent;return ui(e!==void 0,"mapBrowserEvent must originate from a pointer event"),e.isPrimary&&e.button===0};var x_=class{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.featureClass=us,this.supportedMediaTypes=null}getReadOptions(e,r){if(r){let a=r.dataProjection?Ci(r.dataProjection):this.readProjection(e);r.extent&&a&&a.getUnits()==="tile-pixels"&&(a=Ci(a),a.setWorldExtent(r.extent)),r={dataProjection:a,featureProjection:r.featureProjection}}return this.adaptOptions(r)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection,featureClass:this.featureClass},e)}getType(){return wt()}readFeature(e,r){return wt()}readFeatures(e,r){return wt()}readGeometry(e,r){return wt()}readProjection(e){return wt()}writeFeature(e,r){return wt()}writeFeatures(e,r){return wt()}writeGeometry(e,r){return wt()}},L1=x_;function nf(h,e,r){let a=r?Ci(r.featureProjection):null,c=r?Ci(r.dataProjection):null,s=h;if(a&&c&&!Bv(a,c)){e&&(s=h.clone());let y=e?a:c,v=e?c:a;y.getUnits()==="tile-pixels"?s.transform(y,v):s.applyTransform(ll(y,v))}if(e&&r&&r.decimals!==void 0){let y=Math.pow(10,r.decimals),v=function(b){for(let T=0,C=b.length;T<C;++T)b[T]=Math.round(b[T]*y)/y;return b};s===h&&(s=h.clone()),s.applyTransform(v)}return s}var tE={Point:lr,LineString:Is,Polygon:Tc,MultiPoint:yu,MultiLineString:Og,MultiPolygon:qg};function iE(h,e,r){return Array.isArray(e[0])?(kp(h,0,e,r)||(h=h.slice(),vu(h,0,e,r)),h):(xu(h,0,e,r)||(h=h.slice(),Ec(h,0,e,r)),h)}function v_(h,e){let r=h.geometry;if(!r)return[];if(Array.isArray(r))return r.map(s=>v_({...h,geometry:s})).flat();let a=r.type==="MultiPolygon"?"Polygon":r.type;if(a==="GeometryCollection"||a==="Circle")throw new Error("Unsupported geometry type: "+a);let c=r.layout.length;return nf(new Rs(a,a==="Polygon"?iE(r.flatCoordinates,r.ends,c):r.flatCoordinates,r.ends?.flat(),c,h.properties||{},h.id).enableSimplifyTransformed(),!1,e)}function sf(h,e){if(!h)return null;if(Array.isArray(h)){let a=h.map(c=>sf(c,e));return new Pg(a)}let r=tE[h.type];return nf(new r(h.flatCoordinates,h.layout,h.ends),!1,e)}var b_=class extends L1{constructor(){super()}getType(){return"json"}readFeature(e,r){return this.readFeatureFromObject(of(e),this.getReadOptions(e,r))}readFeatures(e,r){return this.readFeaturesFromObject(of(e),this.getReadOptions(e,r))}readFeatureFromObject(e,r){return wt()}readFeaturesFromObject(e,r){return wt()}readGeometry(e,r){return this.readGeometryFromObject(of(e),this.getReadOptions(e,r))}readGeometryFromObject(e,r){return wt()}readProjection(e){return this.readProjectionFromObject(of(e))}readProjectionFromObject(e){return wt()}writeFeature(e,r){return JSON.stringify(this.writeFeatureObject(e,r))}writeFeatureObject(e,r){return wt()}writeFeatures(e,r){return JSON.stringify(this.writeFeaturesObject(e,r))}writeFeaturesObject(e,r){return wt()}writeGeometry(e,r){return JSON.stringify(this.writeGeometryObject(e,r))}writeGeometryObject(e,r){return wt()}};function of(h){if(typeof h=="string"){let e=JSON.parse(h);return e||null}return h!==null?h:null}var D1=b_;var w_=class extends D1{constructor(e){e=e||{},super(),this.dataProjection=Ci(e.dataProjection?e.dataProjection:"EPSG:4326"),e.featureProjection&&(this.defaultFeatureProjection=Ci(e.featureProjection)),e.featureClass&&(this.featureClass=e.featureClass),this.geometryName_=e.geometryName,this.extractGeometryName_=e.extractGeometryName,this.supportedMediaTypes=["application/geo+json","application/vnd.geo+json"]}readFeatureFromObject(e,r){let a=null;e.type==="Feature"?a=e:a={type:"Feature",geometry:e,properties:null};let c=I_(a.geometry,r);if(this.featureClass===Rs)return v_({geometry:c,id:a.id,properties:a.properties},r);let s=new us;return this.geometryName_?s.setGeometryName(this.geometryName_):this.extractGeometryName_&&a.geometry_name&&s.setGeometryName(a.geometry_name),s.setGeometry(sf(c,r)),"id"in a&&s.setId(a.id),a.properties&&s.setProperties(a.properties,!0),s}readFeaturesFromObject(e,r){let a=e,c=null;if(a.type==="FeatureCollection"){let s=e;c=[];let y=s.features;for(let v=0,b=y.length;v<b;++v){let T=this.readFeatureFromObject(y[v],r);T&&c.push(T)}}else c=[this.readFeatureFromObject(e,r)];return c.flat()}readGeometryFromObject(e,r){return rE(e,r)}readProjectionFromObject(e){let r=e.crs,a;if(r)if(r.type=="name")a=Ci(r.properties.name);else if(r.type==="EPSG")a=Ci("EPSG:"+r.properties.code);else throw new Error("Unknown SRS type");else a=this.dataProjection;return a}writeFeatureObject(e,r){r=this.adaptOptions(r);let a={type:"Feature",geometry:null,properties:null},c=e.getId();if(c!==void 0&&(a.id=c),!e.hasProperties())return a;let s=e.getProperties(),y=e.getGeometry();return y&&(a.geometry=S_(y,r),delete s[e.getGeometryName()]),Wn(s)||(a.properties=s),a}writeFeaturesObject(e,r){r=this.adaptOptions(r);let a=[];for(let c=0,s=e.length;c<s;++c)a.push(this.writeFeatureObject(e[c],r));return{type:"FeatureCollection",features:a}}writeGeometryObject(e,r){return S_(e,this.adaptOptions(r))}};function I_(h,e){if(!h)return null;let r;switch(h.type){case"Point":{r=sE(h);break}case"LineString":{r=oE(h);break}case"Polygon":{r=hE(h);break}case"MultiPoint":{r=lE(h);break}case"MultiLineString":{r=aE(h);break}case"MultiPolygon":{r=cE(h);break}case"GeometryCollection":{r=nE(h);break}default:throw new Error("Unsupported GeoJSON type: "+h.type)}return r}function rE(h,e){let r=I_(h,e);return sf(r,e)}function nE(h,e){return h.geometries.map(function(a){return I_(a,e)})}function sE(h){let e=h.coordinates;return{type:"Point",flatCoordinates:e,layout:da(e.length)}}function oE(h){let e=h.coordinates,r=e.flat();return{type:"LineString",flatCoordinates:r,ends:[r.length],layout:da(e[0]?.length||2)}}function aE(h){let e=h.coordinates,r=e[0]?.[0]?.length||2,a=[],c=pa(a,0,e,r);return{type:"MultiLineString",flatCoordinates:a,ends:c,layout:da(r)}}function lE(h){let e=h.coordinates;return{type:"MultiPoint",flatCoordinates:e.flat(),layout:da(e[0]?.length||2)}}function cE(h){let e=h.coordinates,r=[],a=e[0]?.[0]?.[0].length||2,c=Ep(r,0,e,a);return{type:"MultiPolygon",flatCoordinates:r,ends:c,layout:da(a)}}function hE(h){let e=h.coordinates,r=[],a=e[0]?.[0]?.length,c=pa(r,0,e,a);return{type:"Polygon",flatCoordinates:r,ends:c,layout:da(a)}}function S_(h,e){h=nf(h,!0,e);let r=h.getType(),a;switch(r){case"Point":{a=gE(h,e);break}case"LineString":{a=dE(h,e);break}case"Polygon":{a=yE(h,e);break}case"MultiPoint":{a=fE(h,e);break}case"MultiLineString":{a=pE(h,e);break}case"MultiPolygon":{a=mE(h,e);break}case"GeometryCollection":{a=uE(h,e);break}case"Circle":{a={type:"GeometryCollection",geometries:[]};break}default:throw new Error("Unsupported geometry type: "+r)}return a}function uE(h,e){return e=Object.assign({},e),delete e.featureProjection,{type:"GeometryCollection",geometries:h.getGeometriesArray().map(function(a){return S_(a,e)})}}function dE(h,e){return{type:"LineString",coordinates:h.getCoordinates()}}function pE(h,e){return{type:"MultiLineString",coordinates:h.getCoordinates()}}function fE(h,e){return{type:"MultiPoint",coordinates:h.getCoordinates()}}function mE(h,e){let r;return e&&(r=e.rightHanded),{type:"MultiPolygon",coordinates:h.getCoordinates(r)}}function gE(h,e){return{type:"Point",coordinates:h.getCoordinates()}}function yE(h,e){let r;return e&&(r=e.rightHanded),{type:"Polygon",coordinates:h.getCoordinates(r)}}var hr=w_;var F1=0,Zu=1,z1=[0,0,0,0],Gc=[],C_={MODIFYSTART:"modifystart",MODIFYEND:"modifyend"},Xu=class extends Si{constructor(e,r,a){super(e),this.features=r,this.mapBrowserEvent=a}},E_=class extends T1{constructor(e){super(e),this.on,this.once,this.un,this.boundHandleFeatureChange_=this.handleFeatureChange_.bind(this),this.condition_=e.condition?e.condition:k1,this.defaultDeleteCondition_=function(a){return M1(a)&&R1(a)},this.deleteCondition_=e.deleteCondition?e.deleteCondition:this.defaultDeleteCondition_,this.insertVertexCondition_=e.insertVertexCondition?e.insertVertexCondition:P1,this.vertexFeature_=null,this.vertexSegments_=null,this.lastPixel_=[0,0],this.ignoreNextSingleClick_=!1,this.featuresBeingModified_=null,this.rBush_=new $u,this.pixelTolerance_=e.pixelTolerance!==void 0?e.pixelTolerance:10,this.snappedToVertex_=!1,this.changingFeature_=!1,this.dragSegments_=[],this.overlay_=new jc({source:new yl({useSpatialIndex:!1,wrapX:!!e.wrapX}),style:e.style?e.style:xE(),updateWhileAnimating:!0,updateWhileInteracting:!0}),this.SEGMENT_WRITERS_={Point:this.writePointGeometry_.bind(this),LineString:this.writeLineStringGeometry_.bind(this),LinearRing:this.writeLineStringGeometry_.bind(this),Polygon:this.writePolygonGeometry_.bind(this),MultiPoint:this.writeMultiPointGeometry_.bind(this),MultiLineString:this.writeMultiLineStringGeometry_.bind(this),MultiPolygon:this.writeMultiPolygonGeometry_.bind(this),Circle:this.writeCircleGeometry_.bind(this),GeometryCollection:this.writeGeometryCollectionGeometry_.bind(this)},this.source_=null,this.hitDetection_=null;let r;if(e.features?r=e.features:e.source&&(this.source_=e.source,r=new Eu(this.source_.getFeatures()),this.source_.addEventListener(Ur.ADDFEATURE,this.handleSourceAdd_.bind(this)),this.source_.addEventListener(Ur.REMOVEFEATURE,this.handleSourceRemove_.bind(this))),!r)throw new Error("The modify interaction requires features, a source or a layer");e.hitDetection&&(this.hitDetection_=e.hitDetection),this.features_=r,this.features_.forEach(this.addFeature_.bind(this)),this.features_.addEventListener(Ts.ADD,this.handleFeatureAdd_.bind(this)),this.features_.addEventListener(Ts.REMOVE,this.handleFeatureRemove_.bind(this)),this.lastPointerEvent_=null,this.delta_=[0,0],this.snapToPointer_=e.snapToPointer===void 0?!this.hitDetection_:e.snapToPointer}addFeature_(e){let r=e.getGeometry();if(r){let c=this.SEGMENT_WRITERS_[r.getType()];c&&c(e,r)}let a=this.getMap();a&&a.isRendered()&&this.getActive()&&this.handlePointerAtPixel_(a.getCoordinateFromPixel(this.lastPixel_)),e.addEventListener(pi.CHANGE,this.boundHandleFeatureChange_)}willModifyFeatures_(e,r){if(!this.featuresBeingModified_){this.featuresBeingModified_=new Eu;let a=this.featuresBeingModified_.getArray();for(let c=0,s=r.length;c<s;++c){let y=r[c].feature;y&&!a.includes(y)&&this.featuresBeingModified_.push(y)}this.featuresBeingModified_.getLength()===0?this.featuresBeingModified_=null:this.dispatchEvent(new Xu(C_.MODIFYSTART,this.featuresBeingModified_,e))}}removeFeature_(e){this.removeFeatureSegmentData_(e),this.vertexFeature_&&this.features_.getLength()===0&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.removeEventListener(pi.CHANGE,this.boundHandleFeatureChange_)}removeFeatureSegmentData_(e){let r=this.rBush_,a=[];r.forEach(function(c){e===c.feature&&a.push(c)});for(let c=a.length-1;c>=0;--c){let s=a[c];for(let y=this.dragSegments_.length-1;y>=0;--y)this.dragSegments_[y][0]===s&&this.dragSegments_.splice(y,1);r.remove(s)}}setActive(e){this.vertexFeature_&&!e&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),super.setActive(e)}setMap(e){this.overlay_.setMap(e),super.setMap(e)}getOverlay(){return this.overlay_}handleSourceAdd_(e){e.feature&&this.features_.push(e.feature)}handleSourceRemove_(e){e.feature&&this.features_.remove(e.feature)}handleFeatureAdd_(e){this.addFeature_(e.element)}handleFeatureChange_(e){if(!this.changingFeature_){let r=e.target;this.removeFeature_(r),this.addFeature_(r)}}handleFeatureRemove_(e){this.removeFeature_(e.element)}writePointGeometry_(e,r){let a=r.getCoordinates(),c={feature:e,geometry:r,segment:[a,a]};this.rBush_.insert(r.getExtent(),c)}writeMultiPointGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c],v={feature:e,geometry:r,depth:[c],index:c,segment:[y,y]};this.rBush_.insert(r.getExtent(),v)}}writeLineStringGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length-1;c<s;++c){let y=a.slice(c,c+2),v={feature:e,geometry:r,index:c,segment:y};this.rBush_.insert(ss(y),v)}}writeMultiLineStringGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length-1;v<b;++v){let T=y.slice(v,v+2),C={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(ss(T),C)}}}writePolygonGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length-1;v<b;++v){let T=y.slice(v,v+2),C={feature:e,geometry:r,depth:[c],index:v,segment:T};this.rBush_.insert(ss(T),C)}}}writeMultiPolygonGeometry_(e,r){let a=r.getCoordinates();for(let c=0,s=a.length;c<s;++c){let y=a[c];for(let v=0,b=y.length;v<b;++v){let T=y[v];for(let C=0,k=T.length-1;C<k;++C){let O=T.slice(C,C+2),G={feature:e,geometry:r,depth:[v,c],index:C,segment:O};this.rBush_.insert(ss(O),G)}}}}writeCircleGeometry_(e,r){let a=r.getCenter(),c={feature:e,geometry:r,index:F1,segment:[a,a]},s={feature:e,geometry:r,index:Zu,segment:[a,a]},y=[c,s];c.featureSegments=y,s.featureSegments=y,this.rBush_.insert(ca(a),c);let v=r,b=Zn();if(b&&this.getMap()){let T=this.getMap().getView().getProjection();v=v.clone().transform(b,T),v=Gg(v).transform(T,b)}this.rBush_.insert(v.getExtent(),s)}writeGeometryCollectionGeometry_(e,r){let a=r.getGeometriesArray();for(let c=0;c<a.length;++c){let s=a[c],y=this.SEGMENT_WRITERS_[s.getType()];y(e,s)}}createOrUpdateVertexFeature_(e,r,a,c){let s=this.vertexFeature_;return s?s.getGeometry().setCoordinates(e):(s=new us(new lr(e)),this.vertexFeature_=s,this.overlay_.getSource().addFeature(s)),s.set("features",r),s.set("geometries",a),s.set("existing",c),s}handleEvent(e){if(!e.originalEvent)return!0;this.lastPointerEvent_=e;let r;return!e.map.getView().getInteracting()&&e.type==Kn.POINTERMOVE&&!this.handlingDownUpSequence&&this.handlePointerMove_(e),this.vertexFeature_&&this.deleteCondition_(e)&&(e.type!=Kn.SINGLECLICK||!this.ignoreNextSingleClick_?r=this.removePoint():r=!0),e.type==Kn.SINGLECLICK&&(this.ignoreNextSingleClick_=!1),super.handleEvent(e)&&!r}findInsertVerticesAndUpdateDragSegments_(e){this.handlePointerAtPixel_(e),this.dragSegments_.length=0,this.featuresBeingModified_=null;let r=this.vertexFeature_;if(!r)return;let a=this.getMap().getView().getProjection(),c=[],s=r.getGeometry().getCoordinates(),y=ss([s]),v=this.rBush_.getInExtent(y),b={};v.sort(_E);for(let T=0,C=v.length;T<C;++T){let k=v[T],O=k.segment,G=Vt(k.geometry),J=k.depth;if(J&&(G+="-"+J.join("-")),b[G]||(b[G]=new Array(2)),k.geometry.getType()==="Circle"&&k.index===Zu){let le=B1(e,k,a);Zi(le,s)&&!b[G][0]&&(this.dragSegments_.push([k,0]),b[G][0]=k);continue}if(Zi(O[0],s)&&!b[G][0]){this.dragSegments_.push([k,0]),b[G][0]=k;continue}if(Zi(O[1],s)&&!b[G][1]){if(b[G][0]&&b[G][0].index===0){let le=k.geometry.getCoordinates();switch(k.geometry.getType()){case"LineString":case"MultiLineString":continue;case"MultiPolygon":le=le[J[1]];case"Polygon":if(k.index!==le[J[0]].length-2)continue;break;default:}}this.dragSegments_.push([k,1]),b[G][1]=k;continue}Vt(O)in this.vertexSegments_&&!b[G][0]&&!b[G][1]&&c.push(k)}return c}handleDragEvent(e){this.ignoreNextSingleClick_=!1,this.willModifyFeatures_(e,this.dragSegments_.map(([s])=>s));let r=[e.coordinate[0]+this.delta_[0],e.coordinate[1]+this.delta_[1]],a=[],c=[];for(let s=0,y=this.dragSegments_.length;s<y;++s){let v=this.dragSegments_[s],b=v[0],T=b.feature;a.includes(T)||a.push(T);let C=b.geometry;c.includes(C)||c.push(C);let k=b.depth,O,G=b.segment,J=v[1];for(;r.length<C.getStride();)r.push(G[J][r.length]);switch(C.getType()){case"Point":O=r,G[0]=r,G[1]=r;break;case"MultiPoint":O=C.getCoordinates(),O[b.index]=r,G[0]=r,G[1]=r;break;case"LineString":O=C.getCoordinates(),O[b.index+J]=r,G[J]=r;break;case"MultiLineString":O=C.getCoordinates(),O[k[0]][b.index+J]=r,G[J]=r;break;case"Polygon":O=C.getCoordinates(),O[k[0]][b.index+J]=r,G[J]=r;break;case"MultiPolygon":O=C.getCoordinates(),O[k[1]][k[0]][b.index+J]=r,G[J]=r;break;case"Circle":let le=C;if(G[0]=r,G[1]=r,b.index===F1)this.changingFeature_=!0,le.setCenter(r),this.changingFeature_=!1;else{this.changingFeature_=!0;let he=e.map.getView().getProjection(),fe=gg(Ai(le.getCenter(),he),Ai(r,he)),ye=Zn();if(ye){let we=le.clone().transform(ye,he);we.setRadius(fe),fe=we.transform(he,ye).getRadius()}le.setRadius(fe),this.changingFeature_=!1}break;default:}O&&this.setGeometryCoordinates_(C,O)}this.createOrUpdateVertexFeature_(r,a,c,!0)}handleDownEvent(e){if(!this.condition_(e))return!1;let r=e.coordinate,a=this.findInsertVerticesAndUpdateDragSegments_(r);if(a?.length&&this.insertVertexCondition_(e)&&(this.willModifyFeatures_(e,a),this.vertexFeature_)){let c=this.vertexFeature_.getGeometry().getCoordinates();for(let s=a.length-1;s>=0;--s)this.insertVertex_(a[s],c);this.ignoreNextSingleClick_=!0}return!!this.vertexFeature_}handleUpEvent(e){for(let r=this.dragSegments_.length-1;r>=0;--r){let a=this.dragSegments_[r][0],c=a.geometry;if(c.getType()==="Circle"){let s=c,y=s.getCenter(),v=a.featureSegments[0],b=a.featureSegments[1];v.segment[0]=y,v.segment[1]=y,b.segment[0]=y,b.segment[1]=y,this.rBush_.update(ca(y),v);let T=s,C=Zn();if(C){let k=e.map.getView().getProjection();T=T.clone().transform(C,k),T=Gg(T).transform(k,C)}this.rBush_.update(T.getExtent(),b)}else this.rBush_.update(ss(a.segment),a)}return this.featuresBeingModified_&&(this.dispatchEvent(new Xu(C_.MODIFYEND,this.featuresBeingModified_,e)),this.featuresBeingModified_=null),!1}handlePointerMove_(e){this.lastPixel_=e.pixel,this.handlePointerAtPixel_(e.coordinate)}handlePointerAtPixel_(e){let r=this.getMap(),a=r.getPixelFromCoordinate(e),c=r.getView().getProjection(),s=function(b,T){return O1(e,b,c)-O1(e,T,c)},y,v;if(this.hitDetection_){let b=typeof this.hitDetection_=="object"?T=>T===this.hitDetection_:void 0;r.forEachFeatureAtPixel(a,(T,C,k)=>{k&&k.getType()==="Point"&&(k=new lr(ua(k.getCoordinates(),c)));let O=k||T.getGeometry();if(O&&O.getType()==="Point"&&T instanceof us&&this.features_.getArray().includes(T)){v=O;let G=T.getGeometry().getFlatCoordinates().slice(0,2);y=[{feature:T,geometry:v,segment:[G,G]}]}return!0},{layerFilter:b})}if(!y){let b=Gs(ca(e,z1),c),T=r.getView().getResolution()*this.pixelTolerance_,C=js(os(b,T,z1),c);y=this.rBush_.getInExtent(C)}if(y&&y.length>0){let b=y.sort(s)[0],T=b.segment,C=B1(e,b,c),k=r.getPixelFromCoordinate(C),O=gg(a,k);if(v||O<=this.pixelTolerance_){let G={};if(G[Vt(T)]=!0,this.snapToPointer_||(this.delta_[0]=C[0]-e[0],this.delta_[1]=C[1]-e[1]),b.geometry.getType()==="Circle"&&b.index===Zu)this.snappedToVertex_=!0,this.createOrUpdateVertexFeature_(C,[b.feature],[b.geometry],this.snappedToVertex_);else{let J=r.getPixelFromCoordinate(T[0]),le=r.getPixelFromCoordinate(T[1]),he=Sc(k,J),fe=Sc(k,le);O=Math.sqrt(Math.min(he,fe)),this.snappedToVertex_=O<=this.pixelTolerance_,this.snappedToVertex_&&(C=he>fe?T[1]:T[0]),this.createOrUpdateVertexFeature_(C,[b.feature],[b.geometry],this.snappedToVertex_);let ye={};ye[Vt(b.geometry)]=!0;for(let we=1,Ie=y.length;we<Ie;++we){let Pe=y[we].segment;if(Zi(T[0],Pe[0])&&Zi(T[1],Pe[1])||Zi(T[0],Pe[1])&&Zi(T[1],Pe[0])){let Ee=Vt(y[we].geometry);Ee in ye||(ye[Ee]=!0,G[Vt(Pe)]=!0)}else break}}this.vertexSegments_=G;return}}this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null)}insertVertex_(e,r){let a=e.segment,c=e.feature,s=e.geometry,y=e.depth,v=e.index,b;for(;r.length<s.getStride();)r.push(0);switch(s.getType()){case"MultiLineString":b=s.getCoordinates(),b[y[0]].splice(v+1,0,r);break;case"Polygon":b=s.getCoordinates(),b[y[0]].splice(v+1,0,r);break;case"MultiPolygon":b=s.getCoordinates(),b[y[1]][y[0]].splice(v+1,0,r);break;case"LineString":b=s.getCoordinates(),b.splice(v+1,0,r);break;default:return!1}this.setGeometryCoordinates_(s,b);let T=this.rBush_;T.remove(e),this.updateSegmentIndices_(s,v,y,1);let C={segment:[a[0],r],feature:c,geometry:s,depth:y,index:v};T.insert(ss(C.segment),C),this.dragSegments_.push([C,1]);let k={segment:[r,a[1]],feature:c,geometry:s,depth:y,index:v+1};return T.insert(ss(k.segment),k),this.dragSegments_.push([k,0]),!0}updatePointer_(e){return e&&this.findInsertVerticesAndUpdateDragSegments_(e),this.vertexFeature_?.getGeometry().getCoordinates()}getPoint(){let e=this.vertexFeature_?.getGeometry().getCoordinates();return e?ua(e,this.getMap().getView().getProjection()):null}canRemovePoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(a=>a.getType()==="Circle"||a.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ss([e])).some(({segment:a})=>Zi(a[0],e)||Zi(a[1],e))}removePoint(e){if(e&&(e=Ai(e,this.getMap().getView().getProjection()),this.updatePointer_(e)),!this.lastPointerEvent_||this.lastPointerEvent_&&this.lastPointerEvent_.type!=Kn.POINTERDRAG){let r=this.lastPointerEvent_;this.willModifyFeatures_(r,this.dragSegments_.map(([c])=>c));let a=this.removeVertex_();return this.featuresBeingModified_&&this.dispatchEvent(new Xu(C_.MODIFYEND,this.featuresBeingModified_,r)),this.featuresBeingModified_=null,a}return!1}removeVertex_(){let e=this.dragSegments_,r={},a=!1,c,s,y,v,b,T,C,k,O,G,J;for(b=e.length-1;b>=0;--b)y=e[b],G=y[0],J=Vt(G.feature),G.depth&&(J+="-"+G.depth.join("-")),J in r||(r[J]={}),y[1]===0?(r[J].right=G,r[J].index=G.index):y[1]==1&&(r[J].left=G,r[J].index=G.index+1);for(J in r){switch(O=r[J].right,C=r[J].left,T=r[J].index,k=T-1,C!==void 0?G=C:G=O,k<0&&(k=0),v=G.geometry,s=v.getCoordinates(),c=s,a=!1,v.getType()){case"MultiLineString":s[G.depth[0]].length>2&&(s[G.depth[0]].splice(T,1),a=!0);break;case"LineString":s.length>2&&(s.splice(T,1),a=!0);break;case"MultiPolygon":c=c[G.depth[1]];case"Polygon":c=c[G.depth[0]],c.length>4&&(T==c.length-1&&(T=0),c.splice(T,1),a=!0,T===0&&(c.pop(),c.push(c[0]),k=c.length-1));break;default:}if(a){this.setGeometryCoordinates_(v,s);let le=[];if(C!==void 0&&(this.rBush_.remove(C),le.push(C.segment[0])),O!==void 0&&(this.rBush_.remove(O),le.push(O.segment[1])),C!==void 0&&O!==void 0){let he={depth:G.depth,feature:G.feature,geometry:G.geometry,index:k,segment:le};this.rBush_.insert(ss(he.segment),he)}this.updateSegmentIndices_(v,T,G.depth,-1),this.vertexFeature_&&(this.overlay_.getSource().removeFeature(this.vertexFeature_),this.vertexFeature_=null),e.length=0}}return a}canInsertPoint(){if(!this.vertexFeature_||this.vertexFeature_.get("geometries").every(a=>a.getType()==="Circle"||a.getType().endsWith("Point")))return!1;let e=this.vertexFeature_.getGeometry().getCoordinates();return this.rBush_.getInExtent(ss([e])).some(({segment:a})=>!(Zi(a[0],e)||Zi(a[1],e)))}insertPoint(e){let r=e?Ai(e,this.getMap().getView().getProjection()):this.vertexFeature_?.getGeometry().getCoordinates();return r?this.findInsertVerticesAndUpdateDragSegments_(r).reduce((c,s)=>c||this.insertVertex_(s,r),!1):!1}setGeometryCoordinates_(e,r){this.changingFeature_=!0,e.setCoordinates(r),this.changingFeature_=!1}updateSegmentIndices_(e,r,a,c){this.rBush_.forEachInExtent(e.getExtent(),function(s){s.geometry===e&&(a===void 0||s.depth===void 0||yn(s.depth,a))&&s.index>r&&(s.index+=c)})}};function _E(h,e){return h.index-e.index}function O1(h,e,r){let a=e.geometry;if(a.getType()==="Circle"){let s=a;if(e.index===Zu){let y=Zn();y&&(s=s.clone().transform(y,r));let v=Sc(s.getCenter(),Ai(h,r)),b=Math.sqrt(v)-s.getRadius();return b*b}}let c=Ai(h,r);return Gc[0]=Ai(e.segment[0],r),Gc[1]=Ai(e.segment[1],r),bv(c,Gc)}function B1(h,e,r){let a=e.geometry;if(a.getType()==="Circle"&&e.index===Zu){let s=a,y=Zn();return y&&(s=s.clone().transform(y,r)),ua(s.getClosestPoint(Ai(h,r)),r)}let c=Ai(h,r);return Gc[0]=Ai(e.segment[0],r),Gc[1]=Ai(e.segment[1],r),ua(mg(c,Gc),r)}function xE(){let h=Vb();return function(e,r){return h.Point}}var T_=E_;var vE=/^([^@$!\n]*)(@?([\d.]+),([\d.]+))?(\$?([a-zA-Z0-9]{0,2}))$/,N1=/^([\d.]+),([\d.]+)$/,V1=/^!([^$]*)(\$?([a-zA-Z0-9]{0,2}))$/,af="stop-fetch",j1=h=>{let e=[];return h.forEach(r=>{let a=r.getGeometry()?.getCoordinates();a?.length&&e.push(...a)}),e},M_=class h extends Ac{constructor(r={}){super(r);this.abortControllers={};this.cacheStationData={};this.format=new hr({featureProjection:"EPSG:3857"});this.graphs=[];this.initialRouteDrag={};this.segments=[];this.snapToClosestStation=!1;this.useRawViaPoints=!1;this.viaPoints=[];this.element||this.createDefaultElement(),this.loading=!1,this.active=r.active||!0,this.graphs=r.graphs||[["osm",0,99]],this.mot=r.mot||"bus",this.modify=r.modify!==!1,this.apiParams=r.apiParams,this.useRawViaPoints=r.useRawViaPoints||!1,this.snapToClosestStation=r.snapToClosestStation||!1,this.apiKey=r.apiKey,this.stopsApiKey=r.stopsApiKey||this.apiKey,this.stopsApiUrl=r.stopsApiUrl||"https://api.geops.io/stops/v1/",this.api=new eu({...r}),this.routingLayer=r.routingLayer||new jc({source:new yl,style:r.style}),this.onRouteError=r.onRouteError||(a=>{this.dispatchEvent(new Si("change:route")),this.reset(),console.error(a)}),this.onMapClick=this.onMapClick.bind(this),this.onModifyEnd=this.onModifyEnd.bind(this),this.onModifyStart=this.onModifyStart.bind(this),this.createModifyInteraction(),this.on("propertychange",a=>{a.key==="active"&&this.onActiveChange(),a.key==="mot"&&this.viaPoints&&this.drawRoute()})}static getGraphsResolutions(r,a){let c=a.getView();return r.map(([,s,y])=>[c.getResolutionForZoom(s),c.getResolutionForZoom(y||s+1)])}abortRequests(){this.graphs.forEach(r=>{let a=r[0];this.abortControllers[a]&&this.abortControllers[a].abort(),this.abortControllers[a]=new AbortController}),this.abortControllers[af]?.abort(),this.abortControllers[af]=new AbortController,this.loading=!1}activate(){let r=this.getMap();r&&(this.format=new hr({featureProjection:r.getView().getProjection()}),this.graphsResolutions=h.getGraphsResolutions(this.graphs,r),this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.modifyInteraction&&r.addInteraction(this.modifyInteraction),this.modifyInteraction?.setActive(this.modify),this.addListeners())}addListeners(){this.modify&&(this.removeListeners(),this.onMapClickKey=this.getMap()?.on("singleclick",this.onMapClick))}addViaPoint(r,a=-1,c=0){this.viaPoints.splice(a===-1?this.viaPoints.length:a,c,r),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}createDefaultElement(){this.element=document.createElement("button"),this.element.id="ol-toggle-routing",this.element.innerHTML="Toggle Route Control",this.element.onclick=()=>this.active?this.deactivate():this.activate(),Object.assign(this.element.style,{position:"absolute",right:"10px",top:"10px"})}createModifyInteraction(){this.modifyInteraction=new T_({deleteCondition:r=>{let c=(r.target?.getFeaturesAtPixel(r.pixel,{hitTolerance:5})||[]).find(s=>s.getGeometry()?.getType()==="Point"&&s.get("index"));return A1(r)&&c?(this.removeViaPoint(c.get("index")),!0):!1},pixelTolerance:6,source:this.routingLayer?.getSource()||void 0}),this.modifyInteraction.on("modifystart",this.onModifyStart),this.modifyInteraction.on("modifyend",this.onModifyEnd),this.modifyInteraction.setActive(!1)}deactivate(){let r=this.getMap();r&&(this.modifyInteraction&&r.removeInteraction(this.modifyInteraction),this.removeListeners(),this.reset())}drawRoute(){if(this.abortRequests(),this.routingLayer?.getSource()?.clear(),!this.viaPoints.length)return null;if(this.viaPoints.length===1)return this.drawViaPoint(this.viaPoints[0],0,this.abortControllers[af]);let r=this.viaPoints.map(a=>{if(Array.isArray(a)){let c=this.getMap()?.getView().getProjection(),[s,y]=al(a,c);return this.snapToClosestStation?[`@${y}`,s]:[y,s]}return this.useRawViaPoints?a:`!${a}`});return this.loading=!0,this.viaPoints.forEach((a,c)=>{this.drawViaPoint(a,c,this.abortControllers[af])}),Promise.all(this.graphs.map(([a],c)=>{let{signal:s}=this.abortControllers[a];return this.api?this.api.route({"coord-punish":1e3,"coord-radius":100,elevation:!1,graph:a,mot:this.mot,"resolve-hops":!1,via:`${r.join("|")}`,...this.apiParams||{}},{signal:s}).then(y=>{if(this.segments=this.format.readFeatures(y),this.mot==="foot"){let T=this.segments.reduce((C,k)=>{let O=k.get("trg");return C.find(G=>G[0]===O[0]&&G[1]===O[1])?C:[...C,O]},[]);this.segments=T.map(C=>{let k=this.segments.filter(G=>{let J=G.get("trg");return J[0]===C[0]&&J[1]===C[1]}),O=j1(k);return new us({geometry:new Is(O)})})}let v=j1(this.segments),b=new us({geometry:new Is(v)});b.set("graph",a),b.set("mot",this.mot),this.graphsResolutions&&this.graphsResolutions[c]?.length>=2&&(b.set("minResolution",this.graphsResolutions[c][0]),b.set("maxResolution",this.graphsResolutions[c][1])),this.routingLayer?.getSource()?.addFeature(b),this.loading=!1}).catch(y=>{/AbortError/.test(y.name)||(this.segments=[],this.dispatchEvent(new Si("error")),this.onRouteError(y,this),this.loading=!1)}):Promise.resolve([])}))}drawViaPoint(r,a,c){let s=new us;if(s.set("viaPointIdx",a),Array.isArray(r))return s.setGeometry(new lr(r)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s);if(!this.useRawViaPoints||V1.test(r)){let C,k;return this.useRawViaPoints?[,C,,k]=V1.exec(r)||[]:[C,k]=r.split("$"),fetch(`${this.stopsApiUrl}lookup/${C}?key=${this.stopsApiKey}`,{signal:c.signal}).then(O=>O.json()).then(O=>{let{coordinates:G}=O?.features?.[0]?.geometry||{};return G||console.log("No coordinates found for station "+C,O),this.cacheStationData[r]=ar(G),s.set("viaPointTrack",k),s.setGeometry(new lr(ar(G))),this.routingLayer?.getSource()?.addFeature(s),s}).catch(O=>{/AbortError/.test(O.message)||(this.dispatchEvent(new Si("error")),this.onRouteError(O,this),this.routingLayer?.getSource()?.clear(),this.loading=!1)})}if(this.useRawViaPoints&&N1.test(r)){let[C,k]=N1.exec(r)||[];if(k&&C){let O=parseFloat(k),G=parseFloat(C),J=ar([O,G],this.getMap()?.getView().getProjection());return s.setGeometry(new lr(J)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s)}}let[,y,,v,b,,T]=vE.exec(r)||[];if(b&&v){let C=ar([parseFloat(b),parseFloat(v)],this.getMap()?.getView().getProjection());return s.set("viaPointTrack",T),s.setGeometry(new lr(C)),this.routingLayer?.getSource()?.addFeature(s),Promise.resolve(s)}return y?fetch(`${this.stopsApiUrl}?key=${this.stopsApiKey}&q=${y}&limit=1`,{signal:c.signal}).then(C=>C.json()).then(C=>{let{coordinates:k}=C.features[0].geometry;return this.cacheStationData[r]=ar(k),s.set("viaPointTrack",T),s.setGeometry(new lr(ar(k))),this.routingLayer?.getSource()?.addFeature(s),s}).catch(C=>(this.dispatchEvent(new Si("error")),this.onRouteError(C,this),this.loading=!1,null)):Promise.resolve(null)}onActiveChange(){this.get("active")?this.activate():this.deactivate(),this.render()}onMapClick(r){let c=r.target.getFeaturesAtPixel(r.pixel,{hitTolerance:5,layerFilter:s=>s===this.routingLayer}).find(s=>s.getGeometry()?.getType()==="Point"&&s.get("viaPointIdx")!==void 0);if(c){this.removeViaPoint(c.get("viaPointIdx"));return}this.addViaPoint(r.coordinate)}onModifyEnd(r){let a=r.mapBrowserEvent.coordinate,{oldRoute:c,segmentIndex:s,viaPoint:y}=this.initialRouteDrag||{};return y?this.addViaPoint(a,y.get("viaPointIdx"),1):c?s===-1?Promise.reject(new Error("No segment found")):this.addViaPoint(a,(s||0)+1):this.addViaPoint(a,0,1)}onModifyStart(r){let a=-1,c=r.features.getArray().find(y=>y.getGeometry()?.getType()==="LineString");if(c?.getGeometry()&&r.mapBrowserEvent.coordinate){let y=os(new lr(c.getGeometry()?.getClosestPoint(r.mapBrowserEvent.coordinate)).getExtent(),.001);a=this.segments.findIndex(v=>v.getGeometry()?.intersectsExtent(y))}let s=(r.features.getArray().filter(y=>y.getGeometry()?.getType()==="Point")||[])[0];this.initialRouteDrag={oldRoute:c?.clone(),segmentIndex:a,viaPoint:s}}removeListeners(){this.onMapClickKey&&bs(this.onMapClickKey)}removeViaPoint(r=(this.viaPoints||[]).length-1){this.viaPoints.length&&this.viaPoints[r]&&this.viaPoints.splice(r,1),this.drawRoute(),this.dispatchEvent(new Si("change:route"))}render(){}reset(){this.abortRequests(),this.viaPoints=[],this.routingLayer?.getSource()?.clear(),this.dispatchEvent(new Si("change:route"))}setMap(r){super.setMap(r),r&&this.active?this.activate():r||(this.active=!1)}setViaPoints(r){this.viaPoints=[...r],this.drawRoute(),this.dispatchEvent(new Si("change:route"))}get active(){return this.get("active")}set active(r){this.set("active",r)}get loading(){return this.get("loading")}set loading(r){this.set("loading",r)}get modify(){return this.get("modify")}set modify(r){this.set("modify",r)}get mot(){return this.get("mot")}set mot(r){this.set("mot",r)}},G1=M_;var P_=class{constructor(e){let{apiKey:r,apiParams:a,placeholder:c,url:s}=e||{};this.apiParams={limit:20,...a||{}},this.placeholder=c||"Search for a stop...";let y={apiKey:r};s&&(y.url=s),this.api=new tu(y),this.abortController=new AbortController,this.createElement(e),this.options=e}clear(){!this.suggestionsElt||!this.inputElt||!this.clearElt||(this.inputElt.value="",this.suggestionsElt.innerHTML="",this.clearElt.style.display="none")}createElement({element:e}){this.inputElt=document.createElement("input"),this.inputElt.type="text",this.inputElt.placeholder=this.placeholder,this.inputElt.autocomplete="off",this.inputElt.onkeyup=r=>{this.abortController?.abort(),this.abortController=new AbortController,this.search(r.target.value,this.abortController)},Object.assign(this.inputElt.style,{padding:"10px 30px 10px 10px"}),e.appendChild(this.inputElt),this.suggestionsElt=document.createElement("div"),Object.assign(this.suggestionsElt.style,{backgroundColor:"white",cursor:"pointer",overflowY:"auto"}),e.appendChild(this.suggestionsElt),this.clearElt=document.createElement("div"),Object.assign(this.clearElt.style,{cursor:"pointer",display:"none",fontSize:"200%",padding:"0 10px",position:"absolute",right:"0"}),this.clearElt.innerHTML="\xD7",this.clearElt.onclick=()=>this.clear(),e.appendChild(this.clearElt)}render(e){let r=e?.features||[];this.suggestionsElt&&(this.suggestionsElt.style.display=r.length?"block":"none",this.suggestionsElt.innerHTML="",r.forEach(a=>{let c=document.createElement("div");c.innerHTML=a?.properties?.name,c.onclick=s=>{this.options?.onSuggestionClick?.(a,s)},Object.assign(c.style,{padding:"5px 12px"}),this.suggestionsElt?.appendChild(c)}))}search(e,r){return(e!==void 0||e!==null)&&(this.apiParams.q=e),this.clearElt&&(this.clearElt.style.display="block"),this.api.search(this.apiParams,r&&{signal:r.signal}).then(a=>{this.render(a)}).catch(()=>{this.render()})}},U1=P_;var bE=()=>{let h=document.createElement("div");return Object.assign(h.style,{position:"absolute",top:0,left:"50px",margin:"10px",display:"flex",flexDirection:"column",width:"320px",maxHeight:"90%"}),h},q1=bE;var A_=class extends Ac{constructor(e){let r=q1();r.className=e?.className||"mbt-stop-finder";let a={element:r,...e||{}};super(a),this.controller=new U1({onSuggestionClick:this.onSuggestionClick.bind(this),...a})}onSuggestionClick(e){let r=ar(e.geometry.coordinates);this.getMap()?.getView().setCenter(r)}search(e,r){return this.controller.search(e,r)}},$1=A_;var Z1=Vs(L_(),1);var wE="vectorTileFeature",D_={"EPSG:3857":new hr({featureProjection:"EPSG:3857"})},Ea=class extends Sa{getFeaturesAtCoordinate(e,r=5){let a=this.getMapLibrePixels(e,r);if(!a)return[];let c=this.getLayer().get("queryRenderedFeaturesOptions")||{};return this.getLayer().mapLibreMap?.queryRenderedFeatures(a,c).map(y=>this.toOlFeature(y))||[]}prepareFrame(){return!0}renderFrame(e){let r=this.getLayer(),{mapLibreMap:a}=r,c=r.getMapInternal();if(!r||!c||!a)return null;let s=a.getCanvas(),{viewState:y}=e;a.jumpTo({center:al(y.center),zoom:y.zoom-1,bearing:lu(-y.rotation)});let v=r.getOpacity().toString();return s&&v!==s.style.opacity&&(s.style.opacity=v),s.isConnected?SE(s,e)||a.resize():c.render(),a.redraw(),a.getContainer()}getFeatures(e){let r=this.getLayer().getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{let v=y.getGeometry();v instanceof Cr&&c(y,this.getLayer(),v)}),s?.[0]}getMapLibrePixels(e,r){if(!e)return;let a=this.getLayer().mapLibreMap?.project(al(e));if(a?.x===void 0||a?.y===void 0)return;let c=[a.x,a.y];if(r){let[s,y]=c;c=[[s-r,y-r],[s+r,y+r]]}return c}toOlFeature(e){let c=this.getLayer().getMapInternal()?.getView()?.getProjection()?.getCode()||"EPSG:3857";D_[c]||(D_[c]=new hr({featureProjection:c}));let s=D_[c].readFeature(e);return s&&s.set(wE,e,!0),s}};function SE(h,e){return h.width===Math.floor(e.size[0]*e.pixelRatio)&&h.height===Math.floor(e.size[1]*e.pixelRatio)}var IE=h=>{if(!h)return[];let{style:e}=h;if(!e)return[];let{sourceCaches:r}=e,a=[];return Object.values(r).forEach(c=>{if(c.used){let{attribution:s}=c.getSource();s&&(a=a.concat(s.replace(/&copy;/g,"\xA9").split(/(<a.*?<\/a>)/)))}}),CE(a)},CE=h=>{let e=h.filter(c=>c!=null&&c.trim&&c.trim()),r=e.map(c=>c.toLowerCase());return[...new Set(r)].map(c=>e.find(s=>s.toLowerCase()===c))},F_=IE;var Uc=class extends Es{mapLibreMap;loaded=!1;olListenersKeys=[];constructor(e){super({source:new Mo({attributions:()=>F_(this.mapLibreMap)}),...e})}disposeInternal(){bs(this.olListenersKeys),this.loaded=!1,this.mapLibreMap&&(this.mapLibreMap.triggerRepaint=()=>{},this.mapLibreMap.remove()),super.disposeInternal()}setMapInternal(e){super.setMapInternal(e),e?this.loadMapLibreMap():this.dispose()}loadMapLibreMap(){this.loaded=!1;let e=this.getMapInternal();if(e&&this.olListenersKeys.push(e.on("change:target",this.loadMapLibreMap.bind(this))),!e?.getTargetElement())return;if(!this.getVisible()){this.olListenersKeys.push(this.once("change:visible",this.loadMapLibreMap.bind(this)));return}let r=document.createElement("div");r.style.position="absolute",r.style.width="100%",r.style.height="100%";let a=this.get("mapLibreOptions");this.mapLibreMap=new Z1.Map(Object.assign({},a,{container:r,attributionControl:!1,interactive:!1,trackResize:!1})),this.mapLibreMap.on("sourcedata",()=>{this.getSource()?.refresh()}),this.mapLibreMap.once("load",()=>{this.loaded=!0,this.dispatchEvent(new Si("load"))})}createRenderer(){return new Ea(this)}};var V_=Vs(_l());var Hu=class extends Ea{constructor(r){super(r);this.ignoreNextRender=!1;this.setIsReady=this.setIsReady.bind(this),this.ignoreNextRender=!1}renderFrame(r){let a=this.getLayer(),{mapLibreMap:c}=a,s=a.getMapInternal();if(!a||!s||!c)return null;if(this.ready&&this.ignoreNextRender)return this.ignoreNextRender=!1,c?.getContainer();this.ready=!1,this.ignoreNextRender=!1,this.updateReadyState();let y=super.renderFrame(r);return c?.once("idle",this.setIsReady),y}setIsReady(){this.ready||(this.ready=!0,this.ignoreNextRender=!0,this.getLayer().changed())}updateReadyState(){this.getLayer()?.mapLibreMap?.off("idle",this.setIsReady),this.getLayer()?.mapLibreMap?.once("idle",this.setIsReady)}};var Y1=Vs(_l()),Li=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Li=(0,Y1.default)(h=>{console.warn(h)},1e3));var UE=(h,e)=>{(e||[]).forEach(r=>{r.set("parent",void 0)}),(h.get("children")||[]).forEach(r=>{r.set("parent",void 0)})},qE=(h,e)=>{e.properties&&(Li("Deprecated. Don't use properties options. Pass the values directly in options object."),h.setProperties(e.properties)),h.on("propertychange",r=>{if(r.key==="children"&&UE(r.target,r.oldValue),r.key==="map"){let a=r.target.get(r.key);a?(r.target.get("children")||[]).forEach(c=>{a.addLayer(c)}):r.oldValue&&(r.target.get("children")||[]).forEach(c=>{r.oldValue.removeLayer(c)})}}),h.set("options",e),h.set("children",e.children||[]),Object.defineProperties(h,{children:{get:()=>(Li("Layer.children is deprecated. Use the Layer.get('children') method instead."),h.get("children")||[]),set:r=>{Li("Layer.children is deprecated. Use the Layer.set('children', children) method instead."),h.set("children",r||[])}},copyrights:{get:()=>(Li("Layer.copyrights is deprecated. Get the attributions from the source object"),h.get("copyrights")),set:r=>{Li("Layer.copyrights is deprecated. Set the attributions to the source object.");let a=r&&!Array.isArray(r)?[r]:r;h.set("copyrights",a||[])}},disabled:{get(){return Li("Layer.disabled is deprecated. Use the Layer.get('disabled') method instead."),h.get("disabled")},set(r){Li("Layer.disabled is deprecated. Use the Layer.set('disabled', newValue) method instead."),h.set("disabled",r)}},group:{get(){return Li("Layer.group is deprecated. Use the Layer.get('group') method instead."),h.get("group")}},hitTolerance:{get(){return Li("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.get("hitTolerance")||5},set(r){Li("Layer.hitTolerance is deprecated. Pass the hitTolerance when you request the features."),h.set("hitTolerance",r)}},key:{get(){return Li('Layer.key is deprecated. Use the Layer.get("key") method instead.'),h.get("key")||h.get("name")}},map:{get(){return Li('Layer.map is deprecated. Use the Layer.get("map") method instead.'),h.getMapInternal()}},name:{get(){return Li("Layer.name is deprecated. Use the Layer.get('name') method instead."),h.get("name")}},olLayer:{get(){return Li("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj getter is only a redirect to the current 'this' object."),h},set(){Li("Layer.olLayer is deprecated. mobility-toolbox-js/ol layers inherits now from ol/layer/Layer class. obj setter has no effect.")}},options:{get(){return Li('Layer.options is deprecated. Use the Layer.get("options") method instead.'),h.get("options")},set(r){return Li('Layer.options is deprecated. Use the Layer.set("options", newValue) method instead.'),h.set("options",r)}},parent:{get(){return Li("Layer.parent is deprecated. Use the Layer.get('parent') method instead."),h.get("parent")},set(r){Li("Layer.parent is deprecated. Use the Layer.set('parent', parent) method instead."),h.set("parent",r)}},visible:{get(){return Li("Layer.visible is deprecated. Use the Layer.getVisible() method instead."),h.getVisible()},set(r){Li("Layer.visible is deprecated. Use the Layer.setVisible(newValue) method instead."),h.setVisible(r)}}})},Ta=qE;var J1=(h,e,r,a)=>el(`${h}/styles/${e}/style.json`,{[a]:r}).toString(),B_=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(B_=(0,V_.default)(h=>{console.warn(h)},1e3));var N_=class h extends Uc{constructor(r){let a={apiKeyName:"key",style:"travic_v2",url:"https://maps.geops.io",...r||{},mapLibreOptions:{...r.mapLibreOptions||{}}};!a.mapLibreOptions.style&&a.url?.includes("style.json")?a.mapLibreOptions.style=a.url:!a.mapLibreOptions.style&&a.apiKey&&a.style&&typeof a.style=="string"&&(a.mapLibreOptions.style=J1(a.url,a.style,a.apiKey,a.apiKeyName));super(a);this.olEventsKeys=[];Ta(this,r),this.set("options",r)}set apiKey(r){this.set("apiKey",r)}get apiKey(){return this.get("apiKey")}set apiKeyName(r){this.set("apiKeyName",r)}get apiKeyName(){return this.get("apiKeyName")}get maplibreMap(){return B_("MaplibreLayer.maplibreMap is deprecated. Use layer.mapLibreMap."),this.mapLibreMap}get mbMap(){return B_("MaplibreLayer.mbMap is deprecated. Use layer.maplibreMap."),this.maplibreMap}get style(){return this.get("style")}set style(r){this.set("style",r)}get url(){return this.get("url")}set url(r){this.set("url",r)}attachToMap(){let r=(0,V_.default)(this.updateMaplibreMap.bind(this),150);r(),this.olEventsKeys.push(this.on("propertychange",a=>{/(url|style|apiKey|apiKeyName)/.test(a.key)&&r()}))}clone(r){return new h({...this.get("options")||{},...r||{}})}createRenderer(){return new Hu(this)}detachFromMap(){bs(this.olEventsKeys)}disposeInternal(){let r=this.getSource();super.disposeInternal(),this.setSource(r)}getStyle(){return this.style&&typeof this.style=="object"&&this.style.name&&this.style.version?this.style:this.url.includes("style.json")?this.url:this.get("options")?.mapLibreOptions?.style?this.get("options").mapLibreOptions.style:J1(this.url,this.style,this.apiKey,this.apiKeyName)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}updateMaplibreMap(){try{this.mapLibreMap?.setStyle(this.getStyle(),{diff:!1})}catch(r){console.error("Error while updating MaplibreMap",r)}}},Q1=N_;var ew=Vs(_l());var j_={"EPSG:3857":new hr({featureProjection:"EPSG:3857"})},Ku=class extends Sa{forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{c(y,this.layer_,y.getGeometry())}),s?.[0]}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let a=this.getLayer(),c=a.getMapInternal(),s=a.maplibreLayer.mapLibreMap,y=c?.getView()?.getProjection()?.getCode()||"EPSG:3857",v=[];if(j_[y]||(j_[y]=new hr({featureProjection:y})),s?.isStyleLoaded()){let b=e&&s.project(al(e));if(b?.x&&b?.y){let T=[b.x,b.y];if(r){let[k,O]=T;T=[[k-r,O-r],[k+r,O+r]]}let C=a.layers||[];a.layersFilter&&(C=s.getStyle().layers.filter(a.layersFilter)),a.queryRenderedLayersFilter&&(C=s.getStyle().layers.filter(a.queryRenderedLayersFilter)),v=s.queryRenderedFeatures(T,{layers:C.map(k=>k.id),validate:!1}).map(k=>{let O=j_[y].readFeature(k);return O&&O.set(Pc,k),O})}}return v}prepareFrame(){return!0}renderFrame(){return null}};var Mn=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(Mn=(0,ew.default)((...h)=>{console.warn(...h)},1e3));var G_=class h extends Es{constructor(r={mapLibreOptions:{style:{layers:[],sources:{},version:8}}}){r.mapboxLayer&&(Mn("options.mapboxLayer is deprecated. Use options.maplibreLayer instead."),r.maplibreLayer=r.mapboxLayer,delete r.mapboxLayer),r.styleLayers&&(Mn("options.styleLayers is deprecated. Use options.layers instead."),r.layers=r.styleLayers,delete r.styleLayers),r.styleLayersFilter&&(Mn("options.styleLayersFilter is deprecated. Use options.layersFilter instead."),r.layersFilter=r.styleLayersFilter,delete r.styleLayersFilter);super({source:new Mo({}),...r});this.highlightedFeatures=[];this.olEventsKeys=[];this.selectedFeatures=[];Ta(this,r),this.set("options",r),this.beforeId=r.beforeId,this.onLoad=this.onLoad.bind(this),!this.layersFilter&&this.layers&&(this.layersFilter=a=>!!this.layers.find(c=>a.id===c.id))}get beforeId(){return this.get("beforeId")}set beforeId(r){this.set("beforeId",r)}get layers(){return this.get("layers")}set layers(r){this.set("layers",r)}get layersFilter(){return this.get("layersFilter")}set layersFilter(r){this.set("layersFilter",r)}get mapboxLayer(){return Mn("Deprecated. Use maplibreLayer instead."),this.get("maplibreLayer")}get maplibreLayer(){return this.get("maplibreLayer")}set maplibreLayer(r){this.set("maplibreLayer",r)}get queryRenderedLayersFilter(){return this.get("queryRenderedLayersFilter")}set queryRenderedLayersFilter(r){this.set("queryRenderedLayersFilter",r)}get sources(){return this.get("sources")}set sources(r){this.set("sources",r)}get styleLayer(){return Mn("Deprecated. Use MaplibreStyleLayer.layer instead."),this.layers[0]}set styleLayer(r){Mn("MaplibreStyleLayer.styleLayer is deprecated. Use MaplibreStyleLayer.layer instead."),this.layers=[r]}get styleLayers(){return Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers}set styleLayers(r){Mn("MaplibreStyleLayer.styleLayers is deprecated. Use MaplibreStyleLayer.layers instead."),this.layers=r}addLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&(this.layers.forEach(a=>{let{id:c,source:s}=a;(!s||s&&r.getSource(s))&&c&&!r.getLayer(c)&&r.addLayer(a,this.beforeId)}),this.applyLayoutVisibility())}addSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.entries(this.sources).forEach(([a,c])=>{r.getSource(a)||r.addSource(a,c)})}applyLayoutVisibility(r){if(!this.maplibreLayer?.mapLibreMap?.getStyle()||!this.layersFilter)return;let{mapLibreMap:a}=this.maplibreLayer,c=a.getStyle(),s=this.getVisible()?"visible":"none",y=c.layers||[];for(let v=0;v<y.length;v+=1){let b=y[v];if(this.layersFilter(b)){let{id:T}=b;a.getLayer(T)&&(a.setLayoutProperty(T,"visibility",s),(this.getMinZoom()||this.getMaxZoom())&&a.setLayerZoomRange(T,this.getMinZoom()?this.getMinZoom()-1:0,this.getMaxZoom()?this.getMaxZoom()-1:24))}}}attachToMap(r){if(!this.getMapInternal()||!this.maplibreLayer)return;let{mapLibreMap:c}=this.maplibreLayer;c&&(c.loaded()?this.onLoad():c.once("load",this.onLoad)),this.olEventsKeys.push(this.maplibreLayer.on("load",this.onLoad.bind(this)),this.on("change:visible",s=>{this.applyLayoutVisibility(s)}),this.on("propertychange",s=>{/(sources|layers|layersFilter|maplibreLayer|beforeId)/.test(s.key)&&(this.detachFromMap(),this.attachToMap(r))}),this.maplibreLayer.on("propertychange",s=>{s.key==="style"&&s.target.maplibreMap.once("styledata",()=>{s.target.maplibreMap.once("idle",()=>{this.onLoad()})})}))}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new Ku(this)}detachFromMap(){bs(this.olEventsKeys),this.maplibreLayer?.mapLibreMap&&(this.maplibreLayer.mapLibreMap.off("load",this.onLoad),this.removeLayers(),this.removeSources())}getFeatureInfoAtCoordinate(r){if(Mn("Deprecated. getFeatureInfoAtCoordinate([layer], coordinate) from ol package instead."),!this.maplibreLayer?.mapLibreMap)return Promise.resolve({coordinate:r,features:[],layer:this});let{mapLibreMap:a}=this.maplibreLayer;if(!a.isStyleLoaded())return Promise.resolve({coordinate:r,features:[],layer:this});let c=this.layers||[];return this.layersFilter&&(c=a.getStyle().layers.filter(this.layersFilter),console.log(c)),this.queryRenderedLayersFilter&&(c=a.getStyle().layers.filter(this.queryRenderedLayersFilter)),Promise.resolve({coordinate:r,features:[],layer:this})}highlight(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {hover: true}) instead.");let a=this.highlightedFeatures?.filter(c=>!(this.selectedFeatures||[]).map(s=>s.getId()).includes(c.getId()))||[];this.setHoverState(a,!1),this.highlightedFeatures=r,this.setHoverState(this.highlightedFeatures,!0)}onLoad(){if(!this.maplibreLayer?.mapLibreMap)return;this.addSources(),this.addLayers();let{mapLibreMap:r}=this.maplibreLayer,a=r.getStyle();if(a?.layers&&this.layersFilter){let c=a.layers.filter(this.layersFilter);this.set("disabled",!c.length)}this.applyLayoutVisibility()}removeLayers(){if(!this.maplibreLayer?.mapLibreMap||!Array.isArray(this.layers))return;let{mapLibreMap:r}=this.maplibreLayer;r&&this.layers.forEach(a=>{let{id:c}=a;c&&r.getLayer(c)&&r.removeLayer(c)})}removeSources(){if(!this.maplibreLayer?.mapLibreMap||!this.sources)return;let{mapLibreMap:r}=this.maplibreLayer;r&&Object.keys(this.sources).forEach(a=>{r.getSource(a)&&r.removeSource(a)})}select(r=[]){Mn("Deprecated. Use layer.setFeatureState(features, {selected: true}) instead."),this.setHoverState(this.selectedFeatures||[],!1),this.selectedFeatures=r,this.setHoverState(this.selectedFeatures||[],!0)}setFeatureState(r,a){if(!this.maplibreLayer?.mapLibreMap||!r.length)return;let c=this.maplibreLayer.mapLibreMap;r.forEach(s=>{let{source:y,sourceLayer:v}=s.get(Pc)||{};if(!y&&!v||!s.getId()){s.getId()||Mn("No feature's id found. To use the feature state functionnality, tiles must be generated with --generate-ids. See https://github.com/Maplibre/tippecanoe#adding-calculated-attributes.",s.getProperties());return}c.setFeatureState({id:s.getId(),source:y,sourceLayer:v},a)})}setHoverState(r,a){Mn(`Deprecated. Use layer.setFeatureState(features, {hover: ${a}}) instead.`),this.setFeatureState(r,{hover:a})}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap(r)):(this.detachFromMap(),super.setMapInternal(r))}},tw=G_;var Z_=Vs(_l());var q_=Vs(_l()),$_=Vs(ow());var W_=class{constructor(e){this.isIdle=!1;this.getViewState=()=>({});this.shouldRender=()=>!0;this._mode=e.mode||$i.TOPOGRAPHIC,this._speed=e.speed||1,this._style=e.style||tl,this._time=e.time||new Date,this.api=e.api||new Qh(e),this.bboxParameters=e.bboxParameters,this.canvas=e.canvas||document.createElement("canvas"),this.debug=e.debug||!1,this.filter=e.filter,this.hoverVehicleId=e.hoverVehicleId,this.live=e.live!==!1,this.minZoomInterpolation=e.minZoomInterpolation||8,this.pixelRatio=e.pixelRatio||(typeof window<"u"?window.devicePixelRatio:1),this.selectedVehicleId=e.selectedVehicleId,this.sort=e.sort,this.styleOptions={...Mc,...e.styleOptions||{}},this.tenant=e.tenant||"",this.trajectories={},this.useDebounce=e.useDebounce||!1,this.useRequestAnimationFrame=e.useRequestAnimationFrame||!1,this.useThrottle=e.useThrottle!==!1,this.getViewState=e.getViewState||(()=>({})),this.shouldRender=e.shouldRender||(()=>!0),this.onRender=e.onRender,this.onIdle=e.onIdle,this.onStart=e.onStart,this.onStop=e.onStop,this.format=new hr,this.motsByZoom=e.motsByZoom||[Cs,Cs,Cs,Cs,Cs,Cs,Cs,Cs,Cs,Dp,Dp],this.getMotsByZoom=r=>e.getMotsByZoom?e.getMotsByZoom(r,this.motsByZoom):this.motsByZoom[r],this.generalizationLevelByZoom=e.generalizationLevelByZoom||[],this.getGeneralizationLevelByZoom=r=>e.getGeneralizationLevelByZoom?e.getGeneralizationLevelByZoom(r,this.generalizationLevelByZoom):this.generalizationLevelByZoom[r],this.renderTimeIntervalByZoom=e.renderTimeIntervalByZoom||[1e5,5e4,4e4,3e4,2e4,15e3,1e4,5e3,2e3,1e3,400,300,250,180,90,60,50,50,50,50,50],this.getRenderTimeIntervalByZoom=r=>e.getRenderTimeIntervalByZoom?e.getRenderTimeIntervalByZoom(r,this.renderTimeIntervalByZoom):this.renderTimeIntervalByZoom[r],this.isUpdateBboxOnMoveEnd=e.isUpdateBboxOnMoveEnd!==!1,this.throttleRenderTrajectories=(0,$_.default)(this.renderTrajectoriesInternal,50,{leading:!1,trailing:!0}),this.debounceRenderTrajectories=(0,q_.default)(this.renderTrajectoriesInternal,50,{leading:!0,maxWait:5e3,trailing:!0}),this.renderState={center:[0,0],rotation:0,zoom:void 0},this.onTrajectoryMessage=this.onTrajectoryMessage.bind(this),this.onDeleteTrajectoryMessage=this.onDeleteTrajectoryMessage.bind(this),this.onDocumentVisibilityChange=this.onDocumentVisibilityChange.bind(this)}get mode(){return this._mode}set mode(e){e!==this._mode&&(this._mode=e,this.api?.wsApi?.open&&(this.stop(),this.start()))}get speed(){return this._speed}set speed(e){this._speed=e,this.start()}get style(){return this._style}set style(e){this._style=e,this.renderTrajectories()}get time(){return this._time}set time(e){this._time=e?.getTime?e:new Date(e),this.renderTrajectories()}addTrajectory(e){this.trajectories||(this.trajectories={});let r=e.properties.train_id;r!==void 0&&(this.trajectories[r]=e),this.renderTrajectories()}attachToMap(){document.addEventListener("visibilitychange",this.onDocumentVisibilityChange)}detachFromMap(){if(document.removeEventListener("visibilitychange",this.onDocumentVisibilityChange),this.stop(),this.canvas){let e=this.canvas.getContext("2d");e&&e.clearRect(0,0,this.canvas.width,this.canvas.height)}}getRefreshTimeInMs(){let r=this.getViewState().zoom||0,a=r!==void 0?Math.round(r):-1,c=this.getRenderTimeIntervalByZoom(a)||25,s=Math.max(25,c/(this.speed||1)),y=Math.min(s,500);if(this.useThrottle?this.throttleRenderTrajectories=(0,$_.default)(this.renderTrajectoriesInternal,y,{leading:!0,trailing:!0}):this.useDebounce&&(this.debounceRenderTrajectories=(0,q_.default)(this.renderTrajectoriesInternal,y,{leading:!0,maxWait:5e3,trailing:!0})),this.api?.buffer){let[,v]=this.api.buffer;this.api.buffer=[y,v]}return s}getVehicles(e){return this.trajectories&&Object.values(this.trajectories).filter(e)||[]}getVehiclesAtCoordinate(e,r){let{resolution:a}=this.getViewState(),{hitTolerance:c,nb:s}=r||{},y=os([...e,...e],(c||5)*(a||1)),v=Object.values(this.trajectories||{});this.sort&&(v=v.sort(this.sort));let b=[];for(let T=0;T<v.length;T+=1){let{coordinate:C}=v[T].properties;if(C&&rl(y,C)&&b.push(v[T]),b.length===s)break}return{features:b,type:"FeatureCollection"}}onDeleteTrajectoryMessage(e){e.content&&this.removeTrajectory(e.content)}onDocumentVisibilityChange(){if(document.hidden)this.stop(),this.trajectories={};else{if(!this.getViewState().visible)return;this.start()}}onTrajectoryMessage(e){if(this.updateIdleState(),!e.content)return;let r=e.content,{geometry:a,properties:{raw_coordinates:c,time_since_update:s}}=r;s<0||this.purgeTrajectory(r)||(this.debug&&this.mode===$i.TOPOGRAPHIC&&c?r.properties.olGeometry=this.format.readGeometry({coordinates:ar(c),type:"Point"}):r.properties.olGeometry=this.format.readGeometry(a),r.properties.timeOffset=Date.now()-e.timestamp,this.addTrajectory(r))}onZoomEnd(){this.startUpdateTime()}purgeOutOfDateTrajectories(){Object.entries(this.trajectories||{}).forEach(([e,r])=>{let a=r?.properties?.time_intervals;this.time&&a?.length&&a[a.length-1][0]<this.time.getTime()&&this.removeTrajectory(e)})}purgeTrajectory(e){let a=this.getViewState().extent,{bounds:c,type:s}=e.properties;return this.isUpdateBboxOnMoveEnd&&a&&!Vi(a,c)||this.mots&&!this.mots.includes(s)?(this.removeTrajectory(e),!0):!1}removeTrajectory(e){let r;typeof e!="string"?r=e?.properties?.train_id:r=e,r!==void 0&&this.trajectories&&delete this.trajectories[r]}renderTrajectories(e){let r=this.getViewState();this.requestId&&(cancelAnimationFrame(this.requestId),this.requestId=void 0),!(!r?.center||!r?.extent||!r?.size)&&(!e&&this.useRequestAnimationFrame?this.requestId=requestAnimationFrame(()=>{this.renderTrajectoriesInternal(r,e)}):!e&&this.useDebounce?this.debounceRenderTrajectories(r,e):!e&&this.useThrottle?this.throttleRenderTrajectories(r,e):this.renderTrajectoriesInternal(r,e))}renderTrajectoriesInternal(e,r=!1){if(!this.trajectories||!this.shouldRender())return!1;let a=this.live?Date.now():this.time?.getTime(),c=Object.values(this.trajectories);return this.sort&&c.sort(this.sort),!this.canvas||!this.style||(this.renderState=Su(this.canvas,c,this.style,{...e,pixelRatio:this.pixelRatio||1,time:a},{filter:this.filter,hoverVehicleId:this.hoverVehicleId,noInterpolate:(e.zoom||0)<this.minZoomInterpolation?!0:r,selectedVehicleId:this.selectedVehicleId,...this.styleOptions}),this.onRender?.(this.renderState,e)),!0}setBbox(){this.updateIdleState();let e=this.getViewState(),r=e.extent,a=e.zoom||0;if(!r||Number.isNaN(a))return;if(this.trajectories&&r&&a){let C=Object.keys(this.trajectories);for(let k=C.length-1;k>=0;k-=1)this.purgeTrajectory(this.trajectories[C[k]])}let c=Math.floor(a);if(!r||Number.isNaN(c))return;let[s,y,v,b]=r,T=[Math.floor(s),Math.floor(y),Math.ceil(v),Math.ceil(b),c];this.generalizationLevel=this.getGeneralizationLevelByZoom(c),this.generalizationLevel&&T.push(`gen=${this.generalizationLevel}`),this.mots=this.getMotsByZoom(c),this.mots&&T.push(`mots=${this.mots}`),this.tenant&&T.push(`tenant=${this.tenant}`),this.mode!=="topographic"&&T.push(`channel_prefix=${this.mode}`),this.bboxParameters&&Object.entries(this.bboxParameters).forEach(([C,k])=>{T.push(`${C}=${k}`)}),this.api.bbox=T}start(){this.stop(),this.purgeOutOfDateTrajectories(),this.renderTrajectories(),this.startUpdateTime(),this.api.open(),this.api.subscribeTrajectory(this.mode,this.onTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.api.subscribeDeletedVehicles(this.mode,this.onDeleteTrajectoryMessage,void 0,this.isUpdateBboxOnMoveEnd),this.isUpdateBboxOnMoveEnd&&this.setBbox(),this.onStart&&this.onStart(this)}startUpdateTime(){this.stopUpdateTime(),this.updateTimeDelay=this.getRefreshTimeInMs()||0,this.updateTimeInterval=window.setInterval(()=>{this.live?this.time=new Date:this.time&&this.updateTimeDelay&&this.speed&&(this.time=new Date(this.time.getTime()+this.updateTimeDelay*this.speed))},this.updateTimeDelay)}stop(){this.api.unsubscribeTrajectory(this.onTrajectoryMessage),this.api.unsubscribeDeletedVehicles(this.onDeleteTrajectoryMessage),this.api.close(),this.onStop&&this.onStop(this)}stopUpdateTime(){this.updateTimeInterval&&(clearInterval(this.updateTimeInterval),this.updateTimeInterval=void 0)}updateIdleState(){this.isIdle=!1,clearTimeout(this._idleTimeout),this._idleTimeout=window.setTimeout(()=>{this.isIdle=!0,this.onIdle?.(this)},1e3)}},cf=W_;var lT=new hr,Yu=class extends rf{forEachFeatureAtCoordinate(e,r,a,c){let s=this.getFeaturesAtCoordinate(e,a);return s.forEach(y=>{c(y,this.layer_,y.getGeometry())}),s?.[0]}getData(e){let r;try{let{pixelRatio:a}=this.getLayer();return r=this.canvas?.getContext("2d",{willReadFrequently:!0})?.getImageData(e[0]*(a||1),e[1]*(a||1),1,1).data||null,r}catch(a){console.error("error getting data",a)}return null}getFeatures(e){let r=this.getLayer()?.getMapInternal()?.getCoordinateFromPixel(e);return Promise.resolve(this.getFeaturesAtCoordinate(r))}getFeaturesAtCoordinate(e,r=5){if(!e)return[];let a=this.getLayer(),c=a.engine.getVehiclesAtCoordinate(e,{hitTolerance:r,nb:a.maxNbFeaturesRequested});return lT.readFeatures(c)}prepareFrame(){return!0}renderFrame(e){let{canvas:r,engine:a,renderedViewState:c}=this.getLayer();if(this.getLayer().engine.pixelRatio=e.pixelRatio,this.ready=!!a.renderState?.renderedTrajectories&&a.isIdle,this.container||(this.container=document.createElement("div"),this.container.className=this.getLayer().getClassName(),this.container.style.position="absolute",this.container.style.width="100%",this.container.style.height="100%",r instanceof HTMLCanvasElement&&(r.style.position="absolute",r.style.top="0",r.style.left="0",r.style.transformOrigin="top left",this.container.appendChild(r))),c){let{center:s,resolution:y,rotation:v}=e.viewState,{center:b,resolution:T,rotation:C}=c;if(T/y>=3){let k=r?.getContext("2d");r?.width&&r?.height&&k?.clearRect(0,0,r.width,r.height)}else{let k=this.getLayer().getMapInternal(),O=k?.getPixelFromCoordinate(b),G=k?.getPixelFromCoordinate(s);O&&G&&(this.container.style.transform=Jx(O[0]-G[0],O[1]-G[1],T/y,T/y,v-C,0,0))}}return this.container}};var cT=new Tr({image:new En({fill:new Er({color:"#000000"}),radius:5}),stroke:new Xi({color:"#000000",width:6}),zIndex:2}),hT=(h,e,r)=>{let a="#ffffff",c=h.get("type"),s=h.get("stroke");return s&&s[0]!=="#"&&(s=`#${s}`),a=s||r?.getBgColor(c),a=/#ffffff/i.test(a)?"#ff0000":a,[cT,new Tr({image:new En({fill:new Er({color:a}),radius:4}),stroke:new Xi({color:a,width:4}),zIndex:3})]},hf=hT;var uT=new Tr({image:new En({fill:new Er({color:"#000000"}),radius:5}),stroke:new Xi({color:"#000000",width:6}),zIndex:2}),dT=new Tr({image:new En({fill:new Er({color:"#a0a0a0"}),radius:4}),stroke:new Xi({color:"#a0a0a0",width:4}),zIndex:3}),pT=()=>[uT,dT],aw=pT;var lw=new En({fill:new Er({color:[255,0,0,1]}),radius:6,stroke:new Xi({color:[0,0,0,1],width:1})}),fT=new Tr({stroke:new Xi({color:[0,0,0,1],width:5})}),mT=new Tr({image:lw,stroke:new Xi({color:[255,0,0,1],width:3})}),gT=new Tr({image:lw,stroke:new Xi({color:[255,0,0,1],lineDash:[1,10],width:3})}),yT=(h,e)=>{let r=h.get("minResolution"),a=h.get("maxResolution"),c=e<=r&&e>a;if(r&&a&&!c)return[];let s=h?.getGeometry()?.getType()==="Point"?100:0,y=[fT,mT];return h.get("mot")==="foot"&&(y=[gT]),y=y.map(b=>{let T=b.clone();return T.setZIndex(s),T}),y},cw=yT;var _T=new hr,X_=class h extends Es{constructor(r){super({source:new Mo({}),...r});this.allowRenderWhenAnimating=!1;this.maxNbFeaturesRequested=100;this.olEventsKeys=[];Ta(this,r),this.engine=new cf({getViewState:this.getViewState.bind(this),onIdle:this.onRealtimeEngineIdle.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...r}),this.allowRenderWhenAnimating=!!r.allowRenderWhenAnimating,this.vectorLayer=new jc({source:new yl({features:[]}),style:(a,c)=>(r.fullTrajectoryStyle||hf)(a,c,this.engine.styleOptions),updateWhileAnimating:this.allowRenderWhenAnimating,updateWhileInteracting:!0}),this.onZoomEndDebounced=(0,Z_.default)(this.onZoomEnd,100),this.onMoveEndDebounced=(0,Z_.default)(this.onMoveEnd,100)}get api(){return this.engine.api}set api(r){this.engine.api=r}get canvas(){return this.engine.canvas}get filter(){return this.engine.filter}set filter(r){this.engine.filter=r}get hoverVehicleId(){return this.engine.hoverVehicleId}set hoverVehicleId(r){this.engine.hoverVehicleId=r}get mode(){return this.engine.mode}set mode(r){this.engine.mode=r}get pixelRatio(){return this.engine.pixelRatio}get selectedVehicleId(){return this.engine.selectedVehicleId}set selectedVehicleId(r){this.engine.selectedVehicleId=r}get sort(){return this.engine.sort}set sort(r){this.engine.sort=r}get trajectories(){return this.engine.trajectories}attachToMap(){this.engine.attachToMap();let r=this.getMapInternal();r&&(this.getVisible()&&this.engine.start(),this.olEventsKeys.push(r.on("movestart",()=>{this.engine.isUpdateBboxOnMoveEnd&&this.engine.updateIdleState()}),...r.on(["moveend","change:target"],a=>{let c=(a.map||a.target).getView();if(!c||c?.getAnimating()||c?.getInteracting())return;let s=c.getZoom();this.currentZoom!==s&&this.onZoomEndDebounced(a),this.currentZoom=s,this.onMoveEndDebounced(a)}),this.on("change:visible",a=>{a.target.getVisible()?this.engine.start():this.engine.stop()}),this.on("propertychange",a=>{/(opacity|visible|zIndex|minResolution|maxResolution|minZoom|maxZoom)/.test(a.key)&&this.vectorLayer.set(a.key,a.target.get(a.key))})))}cleanVectorLayer(){this.vectorLayer?.getSource()?.clear(!0),this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer)}clone(r){return new h({...this.get("options"),...r})}createRenderer(){return new Yu(this)}detachFromMap(){bs(this.olEventsKeys),this.getMapInternal()?.removeLayer(this.vectorLayer),this.engine.detachFromMap()}async getFullTrajectory(r){let a=await this.engine.api.getFullTrajectory(r,this.engine.mode,this.engine.getGeneralizationLevelByZoom(Math.floor(this.getMapInternal()?.getView()?.getZoom()||0)));return a?.content?.features?.length?_T.readFeatures(a?.content):[]}async getStopSequences(r){return(await this.engine.api.getStopSequence(r))?.content}async getTrajectoryInfos(r){let a=[this.getStopSequences(r),this.getFullTrajectory(r)],[c,s]=await Promise.all(a);return{fullTrajectory:s,stopSequences:c}}getVehicles(r){return this.engine.getVehicles(r)}getViewState(){let r=this.getMapInternal();if(!r?.getView())return{};let a=r.getView();return{center:a.getCenter(),extent:a.calculateExtent(),pixelRatio:this.engine.pixelRatio,resolution:a.getResolution(),rotation:a.getRotation(),size:r.getSize(),visible:this.getVisible(),zoom:a.getZoom()}}highlight(r){let a=r?.get("train_id");this.hoverVehicleId!==a&&(this.hoverVehicleId=a,this.engine.renderTrajectories(!0))}async highlightTrajectory(r){if(!r){this.cleanVectorLayer();return}let a=await this.getFullTrajectory(r);if(!a?.length){this.cleanVectorLayer();return}a.length&&this.vectorLayer?.getSource()?.addFeatures(a),this.vectorLayer.getMapInternal()&&this.vectorLayer.getMapInternal()!==this.getMapInternal()&&this.vectorLayer.getMapInternal()?.removeLayer(this.vectorLayer);let c=this.getZIndex();if(c!==void 0)this.vectorLayer.setZIndex(c-1),this.vectorLayer.getMapInternal()||this.getMapInternal()?.addLayer(this.vectorLayer);else if(!this.vectorLayer.getMapInternal()){let s=this.getMapInternal()?.getLayers().getArray().indexOf(this)||0;s&&this.getMapInternal()?.getLayers().insertAt(s,this.vectorLayer)}return a}onMoveEnd(){!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible()||this.engine.setBbox()}onRealtimeEngineIdle(){this.changed()}onRealtimeEngineRender(r,a){this.renderedViewState={...a};let{container:c}=this.getRenderer();c&&(c.style.transform="")}onZoomEnd(){this.engine.onZoomEnd(),!(!this.engine.isUpdateBboxOnMoveEnd||!this.getVisible())&&this.selectedVehicleId&&this.highlightTrajectory(this.selectedVehicleId)}select(r){let a=r?.get("train_id");this.selectedVehicleId!==a&&(this.selectedVehicleId=a,this.engine.renderTrajectories(!0)),this.highlightTrajectory(a)}setMapInternal(r){r?(super.setMapInternal(r),this.attachToMap()):(this.detachFromMap(),super.setMapInternal(r))}shouldRender(){return this.allowRenderWhenAnimating?!1:this.getMapInternal()?.getView().getAnimating()||this.getMapInternal()?.getView().getInteracting()}start(){this.engine.start()}stop(){this.engine.stop()}},hw=X_;var uw=Vs(_l());var dw=()=>{};typeof window<"u"&&new URLSearchParams(window.location.search).get("deprecated")&&(dw=(0,uw.default)(h=>{console.warn(h)},1e3));var H_=class extends Sa{prepareFrame(){return!0}renderFrame(){return null}},K_=class h extends Es{constructor(e){super(e),Ta(this,e),dw("Layer is deprecated. Use an OpenLayers Layer instead.")}clone(e){return new h({...this.get("options")||{},...e||{}})}createRenderer(){return new H_(this)}},uf=K_;var Y_=class h extends uf{clone(e){return new h({...this.get("options"),...e})}getFeatureInfoAtCoordinate(e){let r=[],a=this.getMapInternal();if(a){let c=a.getPixelFromCoordinate(e);r=a.getFeaturesAtPixel(c,{hitTolerance:this.get("hitTolerance")||5,layerFilter:s=>s===this})||[]}return Promise.resolve({coordinate:e,features:r,layer:this})}},pw=Y_;var xT=new hr,vT=(h,e,r)=>{let a,{coordinate:c,params:s,projection:y,resolution:v}=e;return h&&v&&y&&(a=h.getFeatureInfoUrl(c,v,y,{info_format:"application/json",query_layers:h.getParams().layers,...s})),fetch(a,{signal:r.signal}).then(b=>b.json()).then(b=>xT.readFeatures(b)).catch(()=>[])},Ju={},bT=async(h,e,r=5)=>{Object.values(Ju).forEach(s=>{s?.abort()}),Ju={};let c=ru(e).map(s=>{let y=s.getMapInternal(),v=y?.getView()?.getProjection()?.getCode(),b={coordinate:h,features:[],layer:s};if(!v)return Promise.resolve(b);if(s.getFeatureInfoAtCoordinate)return s.getFeatureInfoAtCoordinate(h);let T=s?.getSource();if(T?.getFeatureInfoUrl){let O=Vt(s);Ju[O]?.abort(),Ju[O]=new AbortController;let G=y?.getView()?.getResolution();return vT(T,{coordinate:h,params:{info_format:"application/json",query_layers:T.getParams().layers},projection:v,resolution:G},Ju[O]).then(J=>({coordinate:h,features:J,layer:s})).catch(()=>({coordinate:h,features:[],layer:s}))}let C=y?.getPixelFromCoordinate(h);if(!C)return Promise.resolve(b);let k=y?.getFeaturesAtPixel(C,{hitTolerance:s.get("hitTolerance")||r||5,layerFilter:O=>O===s});return Promise.resolve({coordinate:h,features:k,layer:s})});return Promise.all(c)},fw=bT;var gf={};Lm(gf,{CopyrightControl:()=>mw,Layer:()=>pf,RealtimeAPI:()=>Qh,RealtimeLayer:()=>Lw,RealtimeModes:()=>$i,RoutingAPI:()=>eu,StopsAPI:()=>tu,VECTOR_TILE_FEATURE_PROPERTY:()=>Pc,compareDepartures:()=>Iu,createCanvas:()=>_s,createRealtimeFilters:()=>Km,debounceDeparturesMessages:()=>$g,debounceWebsocketMessages:()=>Jh,getCircleCanvas:()=>Wm,getDelayBgCanvas:()=>qm,getDelayTextCanvas:()=>$m,getHoursAndMinutes:()=>Hx,getLayersAsFlatArray:()=>ru,getMapGlCopyrights:()=>iu,getMercatorResolution:()=>kw,getSourceCoordinates:()=>mf,getTextCanvas:()=>Zm,getUTCDateString:()=>Zx,getUTCTimeString:()=>Xx,getUrlWithParams:()=>el,getVehiclePosition:()=>wu,pad:()=>sp,realtimeConfig:()=>Mc,realtimeDefaultStyle:()=>tl,realtimeDelayStyle:()=>Xm,realtimeSimpleStyle:()=>Hm,removeDuplicate:()=>il,renderTrajectories:()=>Su,sortAndFilterDepartures:()=>Cu,sortByDelay:()=>Ym});var wT=" | ",J_=class{constructor(e={}){this.options=e}getDefaultPosition(){return"bottom-right"}onAdd(e){return this.map=e,this.container||(this.container=document.createElement("div")),this.render=this.render.bind(this),this.map.on("idle",this.render),this.map.on("sourcedata",this.render),this.map.on("styledata",this.render),this.render(),this.container}onRemove(){return this.container?.parentElement&&this.container.parentElement?.removeChild(this.container),this.map&&(this.map.off("sourcedata",this.render),this.map.off("styledata",this.render),this.map.off("idle",this.render)),this.map=void 0,this.container}render(){if(this.map&&this.container){let e=this.options?.separator||wT,r=this.options?.customAttribution||iu(this.map),a=(Array.isArray(r)?r:[r]).join(e);this.container.innerHTML!==a&&(this.content=a,this.container.innerHTML=this.content)}}},mw=J_;var yw=Vs(L_());var Mr=[];for(let h=0;h<256;++h)Mr.push((h+256).toString(16).slice(1));function gw(h,e=0){return(Mr[h[e+0]]+Mr[h[e+1]]+Mr[h[e+2]]+Mr[h[e+3]]+"-"+Mr[h[e+4]]+Mr[h[e+5]]+"-"+Mr[h[e+6]]+Mr[h[e+7]]+"-"+Mr[h[e+8]]+Mr[h[e+9]]+"-"+Mr[h[e+10]]+Mr[h[e+11]]+Mr[h[e+12]]+Mr[h[e+13]]+Mr[h[e+14]]+Mr[h[e+15]]).toLowerCase()}var Q_,ST=new Uint8Array(16);function e0(){if(!Q_){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");Q_=crypto.getRandomValues.bind(crypto)}return Q_(ST)}var IT=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),t0={randomUUID:IT};function CT(h,e,r){if(t0.randomUUID&&!e&&!h)return t0.randomUUID();h=h||{};let a=h.random||(h.rng||e0)();if(a[6]=a[6]&15|64,a[8]=a[8]&63|128,e){r=r||0;for(let c=0;c<16;++c)e[r+c]=a[c];return e}return gw(a)}var i0=CT;var r0=class extends yw.Evented{constructor(r={}){super();this.options={};this.type="custom";this.options=r,this.id=r.id||i0()}onAdd(r,a){this.map=r}onRemove(r,a){this.map=void 0}render(r){}},pf=r0;var Pr=63710088e-1,xw={centimeters:Pr*100,centimetres:Pr*100,degrees:360/(2*Math.PI),feet:Pr*3.28084,inches:Pr*39.37,kilometers:Pr/1e3,kilometres:Pr/1e3,meters:Pr,metres:Pr,miles:Pr/1609.344,millimeters:Pr*1e3,millimetres:Pr*1e3,nauticalmiles:Pr/1852,radians:1,yards:Pr*1.0936};function ET(h,e,r={}){let a={type:"Feature"};return(r.id===0||r.id)&&(a.id=r.id),r.bbox&&(a.bbox=r.bbox),a.properties=e||{},a.geometry=h,a}function xl(h,e,r={}){if(!h)throw new Error("coordinates is required");if(!Array.isArray(h))throw new Error("coordinates must be an Array");if(h.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!_w(h[0])||!_w(h[1]))throw new Error("coordinates must contain numbers");return ET({type:"Point",coordinates:h},e,r)}function TT(h,e="kilometers"){let r=xw[e];if(!r)throw new Error(e+" units is invalid");return h*r}function MT(h,e="kilometers"){let r=xw[e];if(!r)throw new Error(e+" units is invalid");return h/r}function vw(h){return h%(2*Math.PI)*180/Math.PI}function vl(h){return h%360*Math.PI/180}function ff(h,e="kilometers",r="kilometers"){if(!(h>=0))throw new Error("length must be a positive number");return TT(MT(h,e),r)}function _w(h){return!isNaN(h)&&h!==null&&!Array.isArray(h)}function bw(h){return h!==null&&typeof h=="object"&&!Array.isArray(h)}function Qu(h,e,r){if(h!==null)for(var a,c,s,y,v,b,T,C=0,k=0,O,G=h.type,J=G==="FeatureCollection",le=G==="Feature",he=J?h.features.length:1,fe=0;fe<he;fe++){T=J?h.features[fe].geometry:le?h.geometry:h,O=T?T.type==="GeometryCollection":!1,v=O?T.geometries.length:1;for(var ye=0;ye<v;ye++){var we=0,Ie=0;if(y=O?T.geometries[ye]:T,y!==null){b=y.coordinates;var Pe=y.type;switch(C=r&&(Pe==="Polygon"||Pe==="MultiPolygon")?1:0,Pe){case null:break;case"Point":if(e(b,k,fe,we,Ie)===!1)return!1;k++,we++;break;case"LineString":case"MultiPoint":for(a=0;a<b.length;a++){if(e(b[a],k,fe,we,Ie)===!1)return!1;k++,Pe==="MultiPoint"&&we++}Pe==="LineString"&&we++;break;case"Polygon":case"MultiLineString":for(a=0;a<b.length;a++){for(c=0;c<b[a].length-C;c++){if(e(b[a][c],k,fe,we,Ie)===!1)return!1;k++}Pe==="MultiLineString"&&we++,Pe==="Polygon"&&Ie++}Pe==="Polygon"&&we++;break;case"MultiPolygon":for(a=0;a<b.length;a++){for(Ie=0,c=0;c<b[a].length;c++){for(s=0;s<b[a][c].length-C;s++){if(e(b[a][c][s],k,fe,we,Ie)===!1)return!1;k++}Ie++}we++}break;case"GeometryCollection":for(a=0;a<y.geometries.length;a++)if(Qu(y.geometries[a],e,r)===!1)return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ww(h,e={}){let r=0,a=0,c=0;return Qu(h,function(s){r+=s[0],a+=s[1],c++},!0),xl([r/c,a/c],e.properties)}function Ys(h){if(!h)throw new Error("coord is required");if(!Array.isArray(h)){if(h.type==="Feature"&&h.geometry!==null&&h.geometry.type==="Point")return[...h.geometry.coordinates];if(h.type==="Point")return[...h.coordinates]}if(Array.isArray(h)&&h.length>=2&&!Array.isArray(h[0])&&!Array.isArray(h[1]))return[...h];throw new Error("coord must be GeoJSON Point or an Array of numbers")}function Sw(h){if(Array.isArray(h))return h;if(h.type==="Feature"){if(h.geometry!==null)return h.geometry.coordinates}else if(h.coordinates)return h.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Cw(h,e,r={}){let a;return r.final?a=Iw(Ys(e),Ys(h)):a=Iw(Ys(h),Ys(e)),a>180?-(360-a):a}function Iw(h,e){let r=vl(h[1]),a=vl(e[1]),c=vl(e[0]-h[0]);c>Math.PI&&(c-=2*Math.PI),c<-Math.PI&&(c+=2*Math.PI);let s=Math.log(Math.tan(a/2+Math.PI/4)/Math.tan(r/2+Math.PI/4)),y=Math.atan2(c,s);return(vw(y)+360)%360}function Ew(h,e,r={}){let a=Ys(h),c=Ys(e);c[0]+=c[0]-a[0]>180?-360:a[0]-c[0]>180?360:0;let s=PT(a,c);return ff(s,"meters",r.units)}function PT(h,e,r){r=r===void 0?Pr:Number(r);let a=r,c=h[1]*Math.PI/180,s=e[1]*Math.PI/180,y=s-c,v=Math.abs(e[0]-h[0])*Math.PI/180;v>Math.PI&&(v-=2*Math.PI);let b=Math.log(Math.tan(s/2+Math.PI/4)/Math.tan(c/2+Math.PI/4)),T=Math.abs(b)>1e-11?y/b:Math.cos(c);return Math.sqrt(y*y+T*T*v*v)*a}function Tw(h,e,r,a={}){let c=e<0,s=ff(Math.abs(e),a.units,"meters");c&&(s=-Math.abs(s));let y=Ys(h),v=AT(y,s,r);return v[0]+=v[0]-y[0]>180?-360:y[0]-v[0]>180?360:0,xl(v,a.properties)}function AT(h,e,r,a){a=a===void 0?Pr:Number(a);let c=e/a,s=h[0]*Math.PI/180,y=vl(h[1]),v=vl(r),b=c*Math.cos(v),T=y+b;Math.abs(T)>Math.PI/2&&(T=T>0?Math.PI-T:-Math.PI-T);let C=Math.log(Math.tan(T/2+Math.PI/4)/Math.tan(y/2+Math.PI/4)),k=Math.abs(C)>1e-11?b/C:Math.cos(y),O=c*Math.sin(v)/k;return[((s+O)*180/Math.PI+540)%360-180,T*180/Math.PI]}function Mw(h){if(!h)throw new Error("geojson is required");switch(h.type){case"Feature":return Pw(h);case"FeatureCollection":return RT(h);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return n0(h);default:throw new Error("unknown GeoJSON type")}}function Pw(h){let e={type:"Feature"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"properties":case"geometry":return;default:e[r]=h[r]}}),e.properties=Aw(h.properties),h.geometry==null?e.geometry=null:e.geometry=n0(h.geometry),e}function Aw(h){let e={};return h&&Object.keys(h).forEach(r=>{let a=h[r];typeof a=="object"?a===null?e[r]=null:Array.isArray(a)?e[r]=a.map(c=>c):e[r]=Aw(a):e[r]=a}),e}function RT(h){let e={type:"FeatureCollection"};return Object.keys(h).forEach(r=>{switch(r){case"type":case"features":return;default:e[r]=h[r]}}),e.features=h.features.map(r=>Pw(r)),e}function n0(h){let e={type:h.type};return h.bbox&&(e.bbox=h.bbox),h.type==="GeometryCollection"?(e.geometries=h.geometries.map(r=>n0(r)),e):(e.coordinates=Rw(h.coordinates),e)}function Rw(h){let e=h;return typeof e[0]!="object"?e.slice():e.map(r=>Rw(r))}function kT(h,e,r){if(r=r||{},!bw(r))throw new Error("options is invalid");let a=r.pivot,c=r.mutate;if(!h)throw new Error("geojson is required");if(e==null||isNaN(e))throw new Error("angle is required");if(e===0)return h;let s=a??ww(h);return(c===!1||c===void 0)&&(h=Mw(h)),Qu(h,function(y){let b=Cw(s,y)+e,T=Ew(s,y),C=Sw(Tw(s,T,b));y[0]=C[0],y[1]=C[1]}),h}var s0=kT;var LT=(h,e=1)=>{let{height:r,width:a}=h.getCanvas(),c=h.unproject({x:0,y:0}),s=h.unproject({x:0,y:r/e}),y=h.unproject({x:a/e,y:r/e}),v=h.unproject({x:a/e,y:0});return[[c.lng,c.lat],[v.lng,v.lat],[y.lng,y.lat],[s.lng,s.lat]]},mf=LT;var DT=h=>{let e=h.getBounds().toArray(),r=ar(e[0]),a=ar(e[1]),c=[...r,...a],{width:s,height:y}=h.getCanvas(),v=vi(c)/s,b=Wi(c)/y;return Math.max(v,b)},kw=DT;var o0=class extends pf{get canvas(){return this.engine.canvas}get pixelRatio(){return this.engine.pixelRatio||1}set pixelRatio(e){this.engine.pixelRatio=e||1}#e;constructor(e={}){let r=e?.id||"realtime";super({...e,id:"realtime-custom-"+r}),this.#e=r,this.engine=new cf({getViewState:this.getViewState.bind(this),onRender:this.onRealtimeEngineRender.bind(this),...e}),this.sourceId=this.#e,this.source={animate:!0,attribution:e.attribution?.join(", "),canvas:this.canvas,coordinates:[[0,0],[1,1],[2,2],[0,0]],loaded:!0,type:"canvas"},this.layer={id:this.#e,layout:{visibility:"visible"},paint:{"raster-fade-duration":0,"raster-opacity":1,"raster-resampling":"nearest"},source:this.sourceId,type:"raster"},this.onLoad=this.onLoad.bind(this),this.onMove=this.onMove.bind(this),this.onMoveEnd=this.onMoveEnd.bind(this),this.onZoomEnd=this.onZoomEnd.bind(this)}getViewState(){if(!this.map)return{};this.pixelRatio||(this.pixelRatio=1);let{height:e,width:r}=this.map.getCanvas(),a=this.map.getCenter(),c=this.map.unproject({x:0,y:e/this.pixelRatio}),s=this.map.unproject({x:r/this.pixelRatio,y:0}),y=s0(xl([c.lng,c.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,v=s0(xl([s.lng,s.lat]),-this.map.getBearing(),{pivot:[a.lng,a.lat]}).geometry.coordinates,b=[...ar(y),...ar(v)],T=vi(b)/(r/this.pixelRatio),C=Wi(b)/(e/this.pixelRatio),k=Math.max(T,C);return{center:ar([a.lng,a.lat]),extent:b,pixelRatio:this.pixelRatio,resolution:k,rotation:-(this.map.getBearing()*Math.PI)/180,size:[r/this.pixelRatio,e/this.pixelRatio],visible:!0,zoom:this.map.getZoom()-1}}onAdd(e,r){super.onAdd(e,r),this.engine.attachToMap(),e.isStyleLoaded()&&this.onLoad(),e.on("load",this.onLoad)}onLoad(){this.map?.getSource(this.sourceId)||this.map?.addSource(this.sourceId,this.source),this.map?.getLayer(this.layer.id)||this.map?.addLayer(this.layer,this.id),this.start()}onMove(){this.engine.renderTrajectories()}onMoveEnd(){this.engine.renderTrajectories(),this.engine.isUpdateBboxOnMoveEnd&&this.engine.setBbox()}onRealtimeEngineRender(){if(this.map?.style){let e=mf(this.map,this.pixelRatio),r=this.map.getSource(this.sourceId);r&&r.setCoordinates(e)}}onRemove(e,r){this.engine.detachFromMap(),this.stop(),e.off("load",this.onLoad),e.getLayer(this.layer.id)&&e.removeLayer(this.layer.id),e.getSource(this.sourceId)&&e.removeSource(this.sourceId),super.onRemove(e,r)}onZoomEnd(){this.engine.onZoomEnd()}start(){this.engine.start(),this.map?.on("move",this.onMove),this.map?.on("moveend",this.onMoveEnd),this.map?.on("zoomend",this.onZoomEnd)}stop(){this.engine.stop(),this.map?.off("move",this.onMove),this.map?.off("moveend",this.onMoveEnd),this.map?.off("zoomend",this.onZoomEnd)}},Lw=o0;var a0={ol:df,maplibre:gf};typeof window<"u"&&(window.mbt=a0);var AV=a0;})();
586
586
  /*! Bundled license information:
587
587
 
588
588
  maplibre-gl/dist/maplibre-gl.js: