@opengis/admin 0.2.18 → 0.2.19

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.
@@ -621,7 +621,7 @@ uniform ${V} ${F} u_${W};
621
621
  #endif
622
622
  `}),staticAttributes:m,staticUniforms:M}}class Kh{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(s,d,m,y,x,M,P,O,z){this.context=s;let V=this.boundPaintVertexBuffers.length!==y.length;for(let F=0;!V&&F<y.length;F++)this.boundPaintVertexBuffers[F]!==y[F]&&(V=!0);!this.vao||this.boundProgram!==d||this.boundLayoutVertexBuffer!==m||V||this.boundIndexBuffer!==x||this.boundVertexOffset!==M||this.boundDynamicVertexBuffer!==P||this.boundDynamicVertexBuffer2!==O||this.boundDynamicVertexBuffer3!==z?this.freshBind(d,m,y,x,M,P,O,z):(s.bindVertexArray.set(this.vao),P&&P.bind(),x&&x.dynamicDraw&&x.bind(),O&&O.bind(),z&&z.bind())}freshBind(s,d,m,y,x,M,P,O){const z=s.numAttributes,V=this.context,F=V.gl;this.vao&&this.destroy(),this.vao=V.createVertexArray(),V.bindVertexArray.set(this.vao),this.boundProgram=s,this.boundLayoutVertexBuffer=d,this.boundPaintVertexBuffers=m,this.boundIndexBuffer=y,this.boundVertexOffset=x,this.boundDynamicVertexBuffer=M,this.boundDynamicVertexBuffer2=P,this.boundDynamicVertexBuffer3=O,d.enableAttributes(F,s);for(const W of m)W.enableAttributes(F,s);M&&M.enableAttributes(F,s),P&&P.enableAttributes(F,s),O&&O.enableAttributes(F,s),d.bind(),d.setVertexAttribPointers(F,s,x);for(const W of m)W.bind(),W.setVertexAttribPointers(F,s,x);M&&(M.bind(),M.setVertexAttribPointers(F,s,x)),y&&y.bind(),P&&(P.bind(),P.setVertexAttribPointers(F,s,x)),O&&(O.bind(),O.setVertexAttribPointers(F,s,x)),V.currentNumAttributes=z}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Jh=(v,s,d,m,y)=>({u_matrix:v,u_texture:0,u_ele_delta:s,u_fog_matrix:d,u_fog_color:m?m.properties.get("fog-color"):l.aM.white,u_fog_ground_blend:m?m.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:m?m.calculateFogBlendOpacity(y):0,u_horizon_color:m?m.properties.get("horizon-color"):l.aM.white,u_horizon_fog_blend:m?m.properties.get("horizon-fog-blend"):1});function Pa(v){const s=[];for(let d=0;d<v.length;d++){if(v[d]===null)continue;const m=v[d].split(" ");s.push(m.pop())}return s}class Qh{constructor(s,d,m,y,x,M){const P=s.gl;this.program=P.createProgram();const O=Pa(d.staticAttributes),z=m?m.getBinderAttributes():[],V=O.concat(z),F=uo.prelude.staticUniforms?Pa(uo.prelude.staticUniforms):[],W=d.staticUniforms?Pa(d.staticUniforms):[],J=m?m.getBinderUniforms():[],ee=F.concat(W).concat(J),se=[];for(const xe of ee)se.indexOf(xe)<0&&se.push(xe);const le=m?m.defines():[];x&&le.push("#define OVERDRAW_INSPECTOR;"),M&&le.push("#define TERRAIN3D;");const ce=le.concat(uo.prelude.fragmentSource,d.fragmentSource).join(`
623
623
  `),he=le.concat(uo.prelude.vertexSource,d.vertexSource).join(`
624
- `),ne=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ne,ce),P.compileShader(ne),!P.getShaderParameter(ne,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ne)}`);P.attachShader(this.program,ne);const me=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(me,he),P.compileShader(me),!P.getShaderParameter(me,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(me)}`);P.attachShader(this.program,me),this.attributes={};const ge={};this.numAttributes=V.length;for(let xe=0;xe<this.numAttributes;xe++)V[xe]&&(P.bindAttribLocation(this.program,xe,V[xe]),this.attributes[V[xe]]=xe);if(P.linkProgram(this.program),!P.getProgramParameter(this.program,P.LINK_STATUS))throw new Error(`Program failed to link: ${P.getProgramInfoLog(this.program)}`);P.deleteShader(me),P.deleteShader(ne);for(let xe=0;xe<se.length;xe++){const De=se[xe];if(De&&!ge[De]){const Ve=P.getUniformLocation(this.program,De);Ve&&(ge[De]=Ve)}}this.fixedUniforms=y(s,ge),this.terrainUniforms=((xe,De)=>({u_depth:new l.aH(xe,De.u_depth),u_terrain:new l.aH(xe,De.u_terrain),u_terrain_dim:new l.aI(xe,De.u_terrain_dim),u_terrain_matrix:new l.aJ(xe,De.u_terrain_matrix),u_terrain_unpack:new l.aK(xe,De.u_terrain_unpack),u_terrain_exaggeration:new l.aI(xe,De.u_terrain_exaggeration)}))(s,ge),this.binderUniforms=m?m.getUniforms(s,ge):[]}draw(s,d,m,y,x,M,P,O,z,V,F,W,J,ee,se,le,ce,he){const ne=s.gl;if(this.failedToCreate)return;if(s.program.set(this.program),s.setDepthMode(m),s.setStencilMode(y),s.setColorMode(x),s.setCullFace(M),O){s.activeTexture.set(ne.TEXTURE2),ne.bindTexture(ne.TEXTURE_2D,O.depthTexture),s.activeTexture.set(ne.TEXTURE3),ne.bindTexture(ne.TEXTURE_2D,O.texture);for(const ge in this.terrainUniforms)this.terrainUniforms[ge].set(O[ge])}for(const ge in this.fixedUniforms)this.fixedUniforms[ge].set(P[ge]);se&&se.setUniforms(s,this.binderUniforms,J,{zoom:ee});let me=0;switch(d){case ne.LINES:me=2;break;case ne.TRIANGLES:me=3;break;case ne.LINE_STRIP:me=1}for(const ge of W.get()){const xe=ge.vaos||(ge.vaos={});(xe[z]||(xe[z]=new Kh)).bind(s,this,V,se?se.getPaintVertexBuffers():[],F,ge.vertexOffset,le,ce,he),ne.drawElements(d,ge.primitiveLength*me,ne.UNSIGNED_SHORT,ge.primitiveOffset*me*2)}}}function nu(v,s,d){const m=1/Kt(d,1,s.transform.tileZoom),y=Math.pow(2,d.tileID.overscaledZ),x=d.tileSize*Math.pow(2,s.transform.tileZoom)/y,M=x*(d.tileID.canonical.x+d.tileID.wrap*y),P=x*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[m,v.fromScale,v.toScale],u_fade:v.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Ll=(v,s,d,m)=>{const y=s.style.light,x=y.properties.get("position"),M=[x.x,x.y,x.z],P=function(){var z=new l.A(9);return l.A!=Float32Array&&(z[1]=0,z[2]=0,z[3]=0,z[5]=0,z[6]=0,z[7]=0),z[0]=1,z[4]=1,z[8]=1,z}();y.properties.get("anchor")==="viewport"&&function(z,V){var F=Math.sin(V),W=Math.cos(V);z[0]=W,z[1]=F,z[2]=0,z[3]=-F,z[4]=W,z[5]=0,z[6]=0,z[7]=0,z[8]=1}(P,-s.transform.angle),function(z,V,F){var W=V[0],J=V[1],ee=V[2];z[0]=W*F[0]+J*F[3]+ee*F[6],z[1]=W*F[1]+J*F[4]+ee*F[7],z[2]=W*F[2]+J*F[5]+ee*F[8]}(M,M,P);const O=y.properties.get("color");return{u_matrix:v,u_lightpos:M,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[O.r,O.g,O.b],u_vertical_gradient:+d,u_opacity:m}},iu=(v,s,d,m,y,x,M)=>l.e(Ll(v,s,d,m),nu(x,s,M),{u_height_factor:-Math.pow(2,y.overscaledZ)/M.tileSize/8}),Ia=v=>({u_matrix:v}),Yf=(v,s,d,m)=>l.e(Ia(v),nu(d,s,m)),o_=(v,s)=>({u_matrix:v,u_world:s}),Xf=(v,s,d,m,y)=>l.e(Yf(v,s,d,m),{u_world:y}),a_=(v,s,d,m)=>{const y=v.transform;let x,M;if(m.paint.get("circle-pitch-alignment")==="map"){const P=Kt(d,1,y.zoom);x=!0,M=[P,P]}else x=!1,M=y.pixelsToGLUnits;return{u_camera_to_center_distance:y.cameraToCenterDistance,u_scale_with_map:+(m.paint.get("circle-pitch-scale")==="map"),u_matrix:v.translatePosMatrix(s.posMatrix,d,m.paint.get("circle-translate"),m.paint.get("circle-translate-anchor")),u_pitch_with_map:+x,u_device_pixel_ratio:v.pixelRatio,u_extrude_scale:M}},$o=(v,s,d)=>({u_matrix:v,u_inv_matrix:s,u_camera_to_center_distance:d.cameraToCenterDistance,u_viewport_size:[d.width,d.height]}),Vl=(v,s,d=1)=>({u_matrix:v,u_color:s,u_overlay:0,u_overlay_scale:d}),nr=v=>({u_matrix:v}),ir=(v,s,d,m)=>({u_matrix:v,u_extrude_scale:Kt(s,1,d),u_intensity:m}),ru=(v,s,d,m)=>{const y=l.H();l.aP(y,0,v.width,v.height,0,0,1);const x=v.context.gl;return{u_matrix:y,u_world:[x.drawingBufferWidth,x.drawingBufferHeight],u_image:d,u_color_ramp:m,u_opacity:s.paint.get("heatmap-opacity")}};function su(v,s){const d=Math.pow(2,s.canonical.z),m=s.canonical.y;return[new l.Z(0,m/d).toLngLat().lat,new l.Z(0,(m+1)/d).toLngLat().lat]}const ou=(v,s,d,m)=>{const y=v.transform;return{u_matrix:Qf(v,s,d,m),u_ratio:1/Kt(s,1,y.zoom),u_device_pixel_ratio:v.pixelRatio,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]]}},Kf=(v,s,d,m,y)=>l.e(ou(v,s,d,y),{u_image:0,u_image_height:m}),Da=(v,s,d,m,y)=>{const x=v.transform,M=Jf(s,x);return{u_matrix:Qf(v,s,d,y),u_texsize:s.imageAtlasTexture.size,u_ratio:1/Kt(s,1,x.zoom),u_device_pixel_ratio:v.pixelRatio,u_image:0,u_scale:[M,m.fromScale,m.toScale],u_fade:m.t,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]]}},l_=(v,s,d,m,y,x)=>{const M=v.lineAtlas,P=Jf(s,v.transform),O=d.layout.get("line-cap")==="round",z=M.getDash(m.from,O),V=M.getDash(m.to,O),F=z.width*y.fromScale,W=V.width*y.toScale;return l.e(ou(v,s,d,x),{u_patternscale_a:[P/F,-z.height/2],u_patternscale_b:[P/W,-V.height/2],u_sdfgamma:M.width/(256*Math.min(F,W)*v.pixelRatio)/2,u_image:0,u_tex_y_a:z.y,u_tex_y_b:V.y,u_mix:y.t})};function Jf(v,s){return 1/Kt(v,1,s.tileZoom)}function Qf(v,s,d,m){return v.translatePosMatrix(m?m.posMatrix:s.tileID.posMatrix,s,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}const c_=(v,s,d,m,y)=>{return{u_matrix:v,u_tl_parent:s,u_scale_parent:d,u_buffer_scale:1,u_fade_t:m.mix,u_opacity:m.opacity*y.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:y.paint.get("raster-brightness-min"),u_brightness_high:y.paint.get("raster-brightness-max"),u_saturation_factor:(M=y.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(x=y.paint.get("raster-contrast"),x>0?1/(1-x):1+x),u_spin_weights:u_(y.paint.get("raster-hue-rotate"))};var x,M};function u_(v){v*=Math.PI/180;const s=Math.sin(v),d=Math.cos(v);return[(2*d+1)/3,(-Math.sqrt(3)*s-d+1)/3,(Math.sqrt(3)*s-d+1)/3]}const em=(v,s,d,m,y,x,M,P,O,z,V,F,W,J)=>{const ee=M.transform;return{u_is_size_zoom_constant:+(v==="constant"||v==="source"),u_is_size_feature_constant:+(v==="constant"||v==="camera"),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:ee.cameraToCenterDistance,u_pitch:ee.pitch/360*2*Math.PI,u_rotate_symbol:+d,u_aspect_ratio:ee.width/ee.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:O,u_coord_matrix:z,u_is_text:+F,u_pitch_with_map:+m,u_is_along_line:y,u_is_variable_anchor:x,u_texsize:W,u_texture:0,u_translation:V,u_pitched_scale:J}},Fl=(v,s,d,m,y,x,M,P,O,z,V,F,W,J,ee)=>{const se=M.transform;return l.e(em(v,s,d,m,y,x,M,P,O,z,V,F,W,ee),{u_gamma_scale:m?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:+J})},ed=(v,s,d,m,y,x,M,P,O,z,V,F,W,J)=>l.e(Fl(v,s,d,m,y,x,M,P,O,z,V,!0,F,!0,J),{u_texsize_icon:W,u_texture_icon:1}),au=(v,s,d)=>({u_matrix:v,u_opacity:s,u_color:d}),td=(v,s,d,m,y,x)=>l.e(function(M,P,O,z){const V=O.imageManager.getPattern(M.from.toString()),F=O.imageManager.getPattern(M.to.toString()),{width:W,height:J}=O.imageManager.getPixelSize(),ee=Math.pow(2,z.tileID.overscaledZ),se=z.tileSize*Math.pow(2,O.transform.tileZoom)/ee,le=se*(z.tileID.canonical.x+z.tileID.wrap*ee),ce=se*z.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:V.tl,u_pattern_br_a:V.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[W,J],u_mix:P.t,u_pattern_size_a:V.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Kt(z,1,O.transform.tileZoom),u_pixel_coord_upper:[le>>16,ce>>16],u_pixel_coord_lower:[65535&le,65535&ce]}}(m,x,d,y),{u_matrix:v,u_opacity:s}),nd={fillExtrusion:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_lightpos:new l.aN(v,s.u_lightpos),u_lightintensity:new l.aI(v,s.u_lightintensity),u_lightcolor:new l.aN(v,s.u_lightcolor),u_vertical_gradient:new l.aI(v,s.u_vertical_gradient),u_opacity:new l.aI(v,s.u_opacity)}),fillExtrusionPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_lightpos:new l.aN(v,s.u_lightpos),u_lightintensity:new l.aI(v,s.u_lightintensity),u_lightcolor:new l.aN(v,s.u_lightcolor),u_vertical_gradient:new l.aI(v,s.u_vertical_gradient),u_height_factor:new l.aI(v,s.u_height_factor),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade),u_opacity:new l.aI(v,s.u_opacity)}),fill:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix)}),fillPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),fillOutline:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world)}),fillOutlinePattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),circle:(v,s)=>({u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_scale_with_map:new l.aH(v,s.u_scale_with_map),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_extrude_scale:new l.aO(v,s.u_extrude_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_matrix:new l.aJ(v,s.u_matrix)}),collisionBox:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_pixel_extrude_scale:new l.aO(v,s.u_pixel_extrude_scale)}),collisionCircle:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_inv_matrix:new l.aJ(v,s.u_inv_matrix),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_viewport_size:new l.aO(v,s.u_viewport_size)}),debug:(v,s)=>({u_color:new l.aL(v,s.u_color),u_matrix:new l.aJ(v,s.u_matrix),u_overlay:new l.aH(v,s.u_overlay),u_overlay_scale:new l.aI(v,s.u_overlay_scale)}),clippingMask:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix)}),heatmap:(v,s)=>({u_extrude_scale:new l.aI(v,s.u_extrude_scale),u_intensity:new l.aI(v,s.u_intensity),u_matrix:new l.aJ(v,s.u_matrix)}),heatmapTexture:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world),u_image:new l.aH(v,s.u_image),u_color_ramp:new l.aH(v,s.u_color_ramp),u_opacity:new l.aI(v,s.u_opacity)}),hillshade:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_latrange:new l.aO(v,s.u_latrange),u_light:new l.aO(v,s.u_light),u_shadow:new l.aL(v,s.u_shadow),u_highlight:new l.aL(v,s.u_highlight),u_accent:new l.aL(v,s.u_accent)}),hillshadePrepare:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_dimension:new l.aO(v,s.u_dimension),u_zoom:new l.aI(v,s.u_zoom),u_unpack:new l.aK(v,s.u_unpack)}),line:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels)}),lineGradient:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_image:new l.aH(v,s.u_image),u_image_height:new l.aI(v,s.u_image_height)}),linePattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texsize:new l.aO(v,s.u_texsize),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_image:new l.aH(v,s.u_image),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),lineSDF:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_patternscale_a:new l.aO(v,s.u_patternscale_a),u_patternscale_b:new l.aO(v,s.u_patternscale_b),u_sdfgamma:new l.aI(v,s.u_sdfgamma),u_image:new l.aH(v,s.u_image),u_tex_y_a:new l.aI(v,s.u_tex_y_a),u_tex_y_b:new l.aI(v,s.u_tex_y_b),u_mix:new l.aI(v,s.u_mix)}),raster:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_tl_parent:new l.aO(v,s.u_tl_parent),u_scale_parent:new l.aI(v,s.u_scale_parent),u_buffer_scale:new l.aI(v,s.u_buffer_scale),u_fade_t:new l.aI(v,s.u_fade_t),u_opacity:new l.aI(v,s.u_opacity),u_image0:new l.aH(v,s.u_image0),u_image1:new l.aH(v,s.u_image1),u_brightness_low:new l.aI(v,s.u_brightness_low),u_brightness_high:new l.aI(v,s.u_brightness_high),u_saturation_factor:new l.aI(v,s.u_saturation_factor),u_contrast_factor:new l.aI(v,s.u_contrast_factor),u_spin_weights:new l.aN(v,s.u_spin_weights)}),symbolIcon:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texture:new l.aH(v,s.u_texture),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),symbolSDF:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texture:new l.aH(v,s.u_texture),u_gamma_scale:new l.aI(v,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_is_halo:new l.aH(v,s.u_is_halo),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),symbolTextAndIcon:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texsize_icon:new l.aO(v,s.u_texsize_icon),u_texture:new l.aH(v,s.u_texture),u_texture_icon:new l.aH(v,s.u_texture_icon),u_gamma_scale:new l.aI(v,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_is_halo:new l.aH(v,s.u_is_halo),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),background:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_opacity:new l.aI(v,s.u_opacity),u_color:new l.aL(v,s.u_color)}),backgroundPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_opacity:new l.aI(v,s.u_opacity),u_image:new l.aH(v,s.u_image),u_pattern_tl_a:new l.aO(v,s.u_pattern_tl_a),u_pattern_br_a:new l.aO(v,s.u_pattern_br_a),u_pattern_tl_b:new l.aO(v,s.u_pattern_tl_b),u_pattern_br_b:new l.aO(v,s.u_pattern_br_b),u_texsize:new l.aO(v,s.u_texsize),u_mix:new l.aI(v,s.u_mix),u_pattern_size_a:new l.aO(v,s.u_pattern_size_a),u_pattern_size_b:new l.aO(v,s.u_pattern_size_b),u_scale_a:new l.aI(v,s.u_scale_a),u_scale_b:new l.aI(v,s.u_scale_b),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.aI(v,s.u_tile_units_to_pixels)}),terrain:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texture:new l.aH(v,s.u_texture),u_ele_delta:new l.aI(v,s.u_ele_delta),u_fog_matrix:new l.aJ(v,s.u_fog_matrix),u_fog_color:new l.aL(v,s.u_fog_color),u_fog_ground_blend:new l.aI(v,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.aI(v,s.u_fog_ground_blend_opacity),u_horizon_color:new l.aL(v,s.u_horizon_color),u_horizon_fog_blend:new l.aI(v,s.u_horizon_fog_blend)}),terrainDepth:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ele_delta:new l.aI(v,s.u_ele_delta)}),terrainCoords:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texture:new l.aH(v,s.u_texture),u_terrain_coords_id:new l.aI(v,s.u_terrain_coords_id),u_ele_delta:new l.aI(v,s.u_ele_delta)}),sky:(v,s)=>({u_sky_color:new l.aL(v,s.u_sky_color),u_horizon_color:new l.aL(v,s.u_horizon_color),u_horizon:new l.aI(v,s.u_horizon),u_sky_horizon_blend:new l.aI(v,s.u_sky_horizon_blend)})};class Ms{constructor(s,d,m){this.context=s;const y=s.gl;this.buffer=y.createBuffer(),this.dynamicDraw=!!m,this.context.unbindVAO(),s.bindElementBuffer.set(this.buffer),y.bufferData(y.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||delete d.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(s){const d=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),d.bufferSubData(d.ELEMENT_ARRAY_BUFFER,0,s.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const h_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class id{constructor(s,d,m,y){this.length=d.length,this.attributes=m,this.itemSize=d.bytesPerElement,this.dynamicDraw=y,this.context=s;const x=s.gl;this.buffer=x.createBuffer(),s.bindVertexBuffer.set(this.buffer),x.bufferData(x.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||delete d.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(s){if(s.length!==this.length)throw new Error(`Length of new data is ${s.length}, which doesn't match current length of ${this.length}`);const d=this.context.gl;this.bind(),d.bufferSubData(d.ARRAY_BUFFER,0,s.arrayBuffer)}enableAttributes(s,d){for(let m=0;m<this.attributes.length;m++){const y=d.attributes[this.attributes[m].name];y!==void 0&&s.enableVertexAttribArray(y)}}setVertexAttribPointers(s,d,m){for(let y=0;y<this.attributes.length;y++){const x=this.attributes[y],M=d.attributes[x.name];M!==void 0&&s.vertexAttribPointer(M,x.components,s[h_[x.type]],!1,this.itemSize,x.offset+this.itemSize*(m||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const jo=new WeakMap;function ho(v){var s;if(jo.has(v))return jo.get(v);{const d=(s=v.getParameter(v.VERSION))===null||s===void 0?void 0:s.startsWith("WebGL 2.0");return jo.set(v,d),d}}class _n{constructor(s){this.gl=s.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(s){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class lu extends _n{getDefault(){return l.aM.transparent}set(s){const d=this.current;(s.r!==d.r||s.g!==d.g||s.b!==d.b||s.a!==d.a||this.dirty)&&(this.gl.clearColor(s.r,s.g,s.b,s.a),this.current=s,this.dirty=!1)}}class d_ extends _n{getDefault(){return 1}set(s){(s!==this.current||this.dirty)&&(this.gl.clearDepth(s),this.current=s,this.dirty=!1)}}class Oa extends _n{getDefault(){return 0}set(s){(s!==this.current||this.dirty)&&(this.gl.clearStencil(s),this.current=s,this.dirty=!1)}}class p_ extends _n{getDefault(){return[!0,!0,!0,!0]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||s[3]!==d[3]||this.dirty)&&(this.gl.colorMask(s[0],s[1],s[2],s[3]),this.current=s,this.dirty=!1)}}class tm extends _n{getDefault(){return!0}set(s){(s!==this.current||this.dirty)&&(this.gl.depthMask(s),this.current=s,this.dirty=!1)}}class f_ extends _n{getDefault(){return 255}set(s){(s!==this.current||this.dirty)&&(this.gl.stencilMask(s),this.current=s,this.dirty=!1)}}class nm extends _n{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(s){const d=this.current;(s.func!==d.func||s.ref!==d.ref||s.mask!==d.mask||this.dirty)&&(this.gl.stencilFunc(s.func,s.ref,s.mask),this.current=s,this.dirty=!1)}}class rd extends _n{getDefault(){const s=this.gl;return[s.KEEP,s.KEEP,s.KEEP]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||this.dirty)&&(this.gl.stencilOp(s[0],s[1],s[2]),this.current=s,this.dirty=!1)}}class im extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.STENCIL_TEST):d.disable(d.STENCIL_TEST),this.current=s,this.dirty=!1}}class rm extends _n{getDefault(){return[0,1]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||this.dirty)&&(this.gl.depthRange(s[0],s[1]),this.current=s,this.dirty=!1)}}class sm extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),this.current=s,this.dirty=!1}}class om extends _n{getDefault(){return this.gl.LESS}set(s){(s!==this.current||this.dirty)&&(this.gl.depthFunc(s),this.current=s,this.dirty=!1)}}class Uo extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.BLEND):d.disable(d.BLEND),this.current=s,this.dirty=!1}}class am extends _n{getDefault(){const s=this.gl;return[s.ONE,s.ZERO]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||this.dirty)&&(this.gl.blendFunc(s[0],s[1]),this.current=s,this.dirty=!1)}}class m_ extends _n{getDefault(){return l.aM.transparent}set(s){const d=this.current;(s.r!==d.r||s.g!==d.g||s.b!==d.b||s.a!==d.a||this.dirty)&&(this.gl.blendColor(s.r,s.g,s.b,s.a),this.current=s,this.dirty=!1)}}class lm extends _n{getDefault(){return this.gl.FUNC_ADD}set(s){(s!==this.current||this.dirty)&&(this.gl.blendEquation(s),this.current=s,this.dirty=!1)}}class $l extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.CULL_FACE):d.disable(d.CULL_FACE),this.current=s,this.dirty=!1}}class g_ extends _n{getDefault(){return this.gl.BACK}set(s){(s!==this.current||this.dirty)&&(this.gl.cullFace(s),this.current=s,this.dirty=!1)}}class cu extends _n{getDefault(){return this.gl.CCW}set(s){(s!==this.current||this.dirty)&&(this.gl.frontFace(s),this.current=s,this.dirty=!1)}}class y_ extends _n{getDefault(){return null}set(s){(s!==this.current||this.dirty)&&(this.gl.useProgram(s),this.current=s,this.dirty=!1)}}class __ extends _n{getDefault(){return this.gl.TEXTURE0}set(s){(s!==this.current||this.dirty)&&(this.gl.activeTexture(s),this.current=s,this.dirty=!1)}}class cm extends _n{getDefault(){const s=this.gl;return[0,0,s.drawingBufferWidth,s.drawingBufferHeight]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||s[3]!==d[3]||this.dirty)&&(this.gl.viewport(s[0],s[1],s[2],s[3]),this.current=s,this.dirty=!1)}}class um extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindFramebuffer(d.FRAMEBUFFER,s),this.current=s,this.dirty=!1}}class hm extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindRenderbuffer(d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class sd extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindTexture(d.TEXTURE_2D,s),this.current=s,this.dirty=!1}}class dm extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindBuffer(d.ARRAY_BUFFER,s),this.current=s,this.dirty=!1}}class uu extends _n{getDefault(){return null}set(s){const d=this.gl;d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),this.current=s,this.dirty=!1}}class Hs extends _n{getDefault(){return null}set(s){var d;if(s===this.current&&!this.dirty)return;const m=this.gl;ho(m)?m.bindVertexArray(s):(d=m.getExtension("OES_vertex_array_object"))===null||d===void 0||d.bindVertexArrayOES(s),this.current=s,this.dirty=!1}}class od extends _n{getDefault(){return 4}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_ALIGNMENT,s),this.current=s,this.dirty=!1}}class ad extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s),this.current=s,this.dirty=!1}}class ld extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,s),this.current=s,this.dirty=!1}}class hu extends _n{constructor(s,d){super(s),this.context=s,this.parent=d}getDefault(){return null}}class cd extends hu{setDirty(){this.dirty=!0}set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,s,0),this.current=s,this.dirty=!1}}class Ho extends hu{set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class ud extends hu{set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class b_{constructor(s,d,m,y,x){this.context=s,this.width=d,this.height=m;const M=s.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new cd(s,P),y)this.depthAttachment=x?new ud(s,P):new Ho(s,P);else if(x)throw new Error("Stencil cannot be set without depth");if(M.checkFramebufferStatus(M.FRAMEBUFFER)!==M.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const s=this.context.gl,d=this.colorAttachment.get();if(d&&s.deleteTexture(d),this.depthAttachment){const m=this.depthAttachment.get();m&&s.deleteRenderbuffer(m)}s.deleteFramebuffer(this.framebuffer)}}class Jn{constructor(s,d,m){this.blendFunction=s,this.blendColor=d,this.mask=m}}Jn.Replace=[1,0],Jn.disabled=new Jn(Jn.Replace,l.aM.transparent,[!1,!1,!1,!1]),Jn.unblended=new Jn(Jn.Replace,l.aM.transparent,[!0,!0,!0,!0]),Jn.alphaBlended=new Jn([1,771],l.aM.transparent,[!0,!0,!0,!0]);class x_{constructor(s){var d,m;if(this.gl=s,this.clearColor=new lu(this),this.clearDepth=new d_(this),this.clearStencil=new Oa(this),this.colorMask=new p_(this),this.depthMask=new tm(this),this.stencilMask=new f_(this),this.stencilFunc=new nm(this),this.stencilOp=new rd(this),this.stencilTest=new im(this),this.depthRange=new rm(this),this.depthTest=new sm(this),this.depthFunc=new om(this),this.blend=new Uo(this),this.blendFunc=new am(this),this.blendColor=new m_(this),this.blendEquation=new lm(this),this.cullFace=new $l(this),this.cullFaceSide=new g_(this),this.frontFace=new cu(this),this.program=new y_(this),this.activeTexture=new __(this),this.viewport=new cm(this),this.bindFramebuffer=new um(this),this.bindRenderbuffer=new hm(this),this.bindTexture=new sd(this),this.bindVertexBuffer=new dm(this),this.bindElementBuffer=new uu(this),this.bindVertexArray=new Hs(this),this.pixelStoreUnpack=new od(this),this.pixelStoreUnpackPremultiplyAlpha=new ad(this),this.pixelStoreUnpackFlipY=new ld(this),this.extTextureFilterAnisotropic=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=s.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=s.getParameter(s.MAX_TEXTURE_SIZE),ho(s)){this.HALF_FLOAT=s.HALF_FLOAT;const y=s.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(d=s.RGBA16F)!==null&&d!==void 0?d:y==null?void 0:y.RGBA16F_EXT,this.RGB16F=(m=s.RGB16F)!==null&&m!==void 0?m:y==null?void 0:y.RGB16F_EXT,s.getExtension("EXT_color_buffer_float")}else{s.getExtension("EXT_color_buffer_half_float"),s.getExtension("OES_texture_half_float_linear");const y=s.getExtension("OES_texture_half_float");this.HALF_FLOAT=y==null?void 0:y.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(s,d){return new Ms(this,s,d)}createVertexBuffer(s,d,m){return new id(this,s,d,m)}createRenderbuffer(s,d,m){const y=this.gl,x=y.createRenderbuffer();return this.bindRenderbuffer.set(x),y.renderbufferStorage(y.RENDERBUFFER,s,d,m),this.bindRenderbuffer.set(null),x}createFramebuffer(s,d,m,y){return new b_(this,s,d,m,y)}clear({color:s,depth:d,stencil:m}){const y=this.gl;let x=0;s&&(x|=y.COLOR_BUFFER_BIT,this.clearColor.set(s),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(x|=y.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),m!==void 0&&(x|=y.STENCIL_BUFFER_BIT,this.clearStencil.set(m),this.stencilMask.set(255)),y.clear(x)}setCullFace(s){s.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(s.mode),this.frontFace.set(s.frontFace))}setDepthMode(s){s.func!==this.gl.ALWAYS||s.mask?(this.depthTest.set(!0),this.depthFunc.set(s.func),this.depthMask.set(s.mask),this.depthRange.set(s.range)):this.depthTest.set(!1)}setStencilMode(s){s.test.func!==this.gl.ALWAYS||s.mask?(this.stencilTest.set(!0),this.stencilMask.set(s.mask),this.stencilOp.set([s.fail,s.depthFail,s.pass]),this.stencilFunc.set({func:s.test.func,ref:s.ref,mask:s.test.mask})):this.stencilTest.set(!1)}setColorMode(s){l.aE(s.blendFunction,Jn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(s.blendFunction),this.blendColor.set(s.blendColor)),this.colorMask.set(s.mask)}createVertexArray(){var s;return ho(this.gl)?this.gl.createVertexArray():(s=this.gl.getExtension("OES_vertex_array_object"))===null||s===void 0?void 0:s.createVertexArrayOES()}deleteVertexArray(s){var d;return ho(this.gl)?this.gl.deleteVertexArray(s):(d=this.gl.getExtension("OES_vertex_array_object"))===null||d===void 0?void 0:d.deleteVertexArrayOES(s)}unbindVAO(){this.bindVertexArray.set(null)}}class Gt{constructor(s,d,m){this.func=s,this.mask=d,this.range=m}}Gt.ReadOnly=!1,Gt.ReadWrite=!0,Gt.disabled=new Gt(519,Gt.ReadOnly,[0,1]);const du=7680;class On{constructor(s,d,m,y,x,M){this.test=s,this.ref=d,this.mask=m,this.fail=y,this.depthFail=x,this.pass=M}}On.disabled=new On({func:519,mask:0},0,0,du,du,du);class Tn{constructor(s,d,m){this.enable=s,this.mode=d,this.frontFace=m}}let qo;function jl(v,s,d,m,y){const x=v.context,M=x.gl,P=v.useProgram("collisionBox"),O=[];let z=0,V=0;for(let ce=0;ce<m.length;ce++){const he=m[ce],ne=s.getTile(he).getBucket(d);if(!ne)continue;const me=y?ne.textCollisionBox:ne.iconCollisionBox,ge=ne.collisionCircleArray;if(ge.length>0){const xe=l.H();l.aQ(xe,ne.placementInvProjMatrix,v.transform.glCoordMatrix),l.aQ(xe,xe,ne.placementViewportMatrix),O.push({circleArray:ge,circleOffset:V,transform:he.posMatrix,invTransform:xe,coord:he}),z+=ge.length/4,V=z}me&&P.draw(x,M.LINES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,{u_matrix:he.posMatrix,u_pixel_extrude_scale:[1/(F=v.transform).width,1/F.height]},v.style.map.terrain&&v.style.map.terrain.getTerrainData(he),d.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,v.transform.zoom,null,null,me.collisionVertexBuffer)}var F;if(!y||!O.length)return;const W=v.useProgram("collisionCircle"),J=new l.aR;J.resize(4*z),J._trim();let ee=0;for(const ce of O)for(let he=0;he<ce.circleArray.length/4;he++){const ne=4*he,me=ce.circleArray[ne+0],ge=ce.circleArray[ne+1],xe=ce.circleArray[ne+2],De=ce.circleArray[ne+3];J.emplace(ee++,me,ge,xe,De,0),J.emplace(ee++,me,ge,xe,De,1),J.emplace(ee++,me,ge,xe,De,2),J.emplace(ee++,me,ge,xe,De,3)}(!qo||qo.length<2*z)&&(qo=function(ce){const he=2*ce,ne=new l.aT;ne.resize(he),ne._trim();for(let me=0;me<he;me++){const ge=6*me;ne.uint16[ge+0]=4*me+0,ne.uint16[ge+1]=4*me+1,ne.uint16[ge+2]=4*me+2,ne.uint16[ge+3]=4*me+2,ne.uint16[ge+4]=4*me+3,ne.uint16[ge+5]=4*me+0}return ne}(z));const se=x.createIndexBuffer(qo,!0),le=x.createVertexBuffer(J,l.aS.members,!0);for(const ce of O){const he=$o(ce.transform,ce.invTransform,v.transform);W.draw(x,M.TRIANGLES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,he,v.style.map.terrain&&v.style.map.terrain.getTerrainData(ce.coord),d.id,le,se,l.a0.simpleSegment(0,2*ce.circleOffset,ce.circleArray.length,ce.circleArray.length/2),null,v.transform.zoom,null,null,null)}le.destroy(),se.destroy()}Tn.disabled=new Tn(!1,1029,2305),Tn.backCCW=new Tn(!0,1029,2305);const Ul=l.an(new Float32Array(16));function hd(v,s,d,m,y,x){const{horizontalAlign:M,verticalAlign:P}=l.au(v);return new l.P((-(M-.5)*s/y+m[0])*x,(-(P-.5)*d/y+m[1])*x)}function Wo(v,s,d,m,y,x){const M=s.tileAnchorPoint.add(new l.P(s.translation[0],s.translation[1]));if(s.pitchWithMap){let P=m.mult(x);d||(P=P.rotate(-y));const O=M.add(P);return oe(O.x,O.y,s.labelPlaneMatrix,s.getElevation).point}if(d){const P=Te(s.tileAnchorPoint.x+1,s.tileAnchorPoint.y,s).point.sub(v),O=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return v.add(m.rotate(O))}return v.add(m)}function Ba(v,s,d,m,y,x,M,P,O,z,V,F,W,J){const ee=v.text.placedSymbolArray,se=v.text.dynamicLayoutVertexArray,le=v.icon.dynamicLayoutVertexArray,ce={};se.clear();for(let he=0;he<ee.length;he++){const ne=ee.get(he),me=ne.hidden||!ne.crossTileID||v.allowVerticalPlacement&&!ne.placedOrientation?null:m[ne.crossTileID];if(me){const ge=new l.P(ne.anchorX,ne.anchorY),xe={getElevation:J,width:y.width,height:y.height,labelPlaneMatrix:x,lineVertexArray:null,pitchWithMap:d,projection:V,projectionCache:null,tileAnchorPoint:ge,translation:F,unwrappedTileID:W},De=d?oe(ge.x,ge.y,M,J):Te(ge.x,ge.y,xe),Ve=H(y.cameraToCenterDistance,De.signedDistanceFromCamera);let Je=l.ai(v.textSizeData,O,ne)*Ve/l.ap;d&&(Je*=v.tilePixelRatio/P);const{width:st,height:Ze,anchor:We,textOffset:mt,textBoxScale:Ot}=me,Xe=hd(We,st,Ze,mt,Ot,Je),nt=V.getPitchedTextCorrection(y,ge.add(new l.P(F[0],F[1])),W),It=Wo(De.point,xe,s,Xe,y.angle,nt),Fn=v.allowVerticalPlacement&&ne.placedOrientation===l.ah.vertical?Math.PI/2:0;for(let $t=0;$t<ne.numGlyphs;$t++)l.aj(se,It,Fn);z&&ne.associatedIconIndex>=0&&(ce[ne.associatedIconIndex]={shiftedAnchor:It,angle:Fn})}else kt(ne.numGlyphs,se)}if(z){le.clear();const he=v.icon.placedSymbolArray;for(let ne=0;ne<he.length;ne++){const me=he.get(ne);if(me.hidden)kt(me.numGlyphs,le);else{const ge=ce[ne];if(ge)for(let xe=0;xe<me.numGlyphs;xe++)l.aj(le,ge.shiftedAnchor,ge.angle);else kt(me.numGlyphs,le)}}v.icon.dynamicLayoutVertexBuffer.updateData(le)}v.text.dynamicLayoutVertexBuffer.updateData(se)}function Rr(v,s,d){return d.iconsInText&&s?"symbolTextAndIcon":v?"symbolSDF":"symbolIcon"}function dd(v,s,d,m,y,x,M,P,O,z,V,F){const W=v.context,J=W.gl,ee=v.transform,se=Vo(),le=P==="map",ce=O==="map",he=P!=="viewport"&&d.layout.get("symbol-placement")!=="point",ne=le&&!ce&&!he,me=!ce&&he,ge=!d.layout.get("symbol-sort-key").isConstant();let xe=!1;const De=v.depthModeForSublayer(0,Gt.ReadOnly),Ve=d._unevaluatedLayout.hasValue("text-variable-anchor")||d._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Je=[],st=se.getCircleRadiusCorrection(ee);for(const Ze of m){const We=s.getTile(Ze),mt=We.getBucket(d);if(!mt)continue;const Ot=y?mt.text:mt.icon;if(!Ot||!Ot.segments.get().length||!Ot.hasVisibleVertices)continue;const Xe=Ot.programConfigurations.get(d.id),nt=y||mt.sdfIcons,It=y?mt.textSizeData:mt.iconSizeData,Fn=ce||ee.pitch!==0,$t=v.useProgram(Rr(nt,y,mt),Xe),Jt=l.ag(It,ee.zoom),$n=v.style.map.terrain&&v.style.map.terrain.getTerrainData(Ze);let Bi,is,jn,rr,Gi=[0,0],Ni=null;if(y)is=We.glyphAtlasTexture,jn=J.LINEAR,Bi=We.glyphAtlasTexture.size,mt.iconsInText&&(Gi=We.imageAtlasTexture.size,Ni=We.imageAtlasTexture,rr=Fn||v.options.rotating||v.options.zooming||It.kind==="composite"||It.kind==="camera"?J.LINEAR:J.NEAREST);else{const tn=d.layout.get("icon-size").constantOr(0)!==1||mt.iconsNeedLinear;is=We.imageAtlasTexture,jn=nt||v.options.rotating||v.options.zooming||tn||Fn?J.LINEAR:J.NEAREST,Bi=We.imageAtlasTexture.size}const Zi=Kt(We,1,v.transform.zoom),Is=me?Ze.posMatrix:Ul,Xa=qi(Is,ce,le,v.transform,Zi),Iu=fr(Is,ce,le,v.transform,Zi),Ka=fr(Ze.posMatrix,ce,le,v.transform,Zi),Fr=se.translatePosition(v.transform,We,x,M),Du=Ve&&mt.hasTextData(),Rd=d.layout.get("icon-text-fit")!=="none"&&Du&&mt.hasIconData();if(he){const tn=v.style.map.terrain?(Ja,Qa)=>v.style.map.terrain.getElevation(Ze,Ja,Qa):null,Ko=d.layout.get("text-rotation-alignment")==="map";X(mt,Ze.posMatrix,v,y,Xa,Ka,ce,z,Ko,se,Ze.toUnwrapped(),ee.width,ee.height,Fr,tn)}const $r=Ze.posMatrix,jr=y&&Ve||Rd,po=he||jr?Ul:Xa,rs=Iu,Ei=nt&&d.paint.get(y?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let zi;zi=nt?mt.iconsInText?ed(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,Bi,Gi,st):Fl(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,y,Bi,!0,st):em(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,y,Bi,st);const xr={program:$t,buffers:Ot,uniformValues:zi,atlasTexture:is,atlasTextureIcon:Ni,atlasInterpolation:jn,atlasInterpolationIcon:rr,isSDF:nt,hasHalo:Ei};if(ge&&mt.canOverlap){xe=!0;const tn=Ot.segments.get();for(const Ko of tn)Je.push({segments:new l.a0([Ko]),sortKey:Ko.sortKey,state:xr,terrainData:$n})}else Je.push({segments:Ot.segments,sortKey:0,state:xr,terrainData:$n})}xe&&Je.sort((Ze,We)=>Ze.sortKey-We.sortKey);for(const Ze of Je){const We=Ze.state;if(W.activeTexture.set(J.TEXTURE0),We.atlasTexture.bind(We.atlasInterpolation,J.CLAMP_TO_EDGE),We.atlasTextureIcon&&(W.activeTexture.set(J.TEXTURE1),We.atlasTextureIcon&&We.atlasTextureIcon.bind(We.atlasInterpolationIcon,J.CLAMP_TO_EDGE)),We.isSDF){const mt=We.uniformValues;We.hasHalo&&(mt.u_is_halo=1,pd(We.buffers,Ze.segments,d,v,We.program,De,V,F,mt,Ze.terrainData)),mt.u_is_halo=0}pd(We.buffers,Ze.segments,d,v,We.program,De,V,F,We.uniformValues,Ze.terrainData)}}function pd(v,s,d,m,y,x,M,P,O,z){const V=m.context;y.draw(V,V.gl.TRIANGLES,x,M,P,Tn.disabled,O,z,d.id,v.layoutVertexBuffer,v.indexBuffer,s,d.paint,m.transform.zoom,v.programConfigurations.get(d.id),v.dynamicLayoutVertexBuffer,v.opacityVertexBuffer)}function fd(v,s,d,m){const y=v.context,x=y.gl,M=On.disabled,P=new Jn([x.ONE,x.ONE],l.aM.transparent,[!0,!0,!0,!0]),O=s.getBucket(d);if(!O)return;const z=m.key;let V=d.heatmapFbos.get(z);V||(V=Hl(y,s.tileSize,s.tileSize),d.heatmapFbos.set(z,V)),y.bindFramebuffer.set(V.framebuffer),y.viewport.set([0,0,s.tileSize,s.tileSize]),y.clear({color:l.aM.transparent});const F=O.programConfigurations.get(d.id),W=v.useProgram("heatmap",F),J=v.style.map.terrain.getTerrainData(m);W.draw(y,x.TRIANGLES,Gt.disabled,M,P,Tn.disabled,ir(m.posMatrix,s,v.transform.zoom,d.paint.get("heatmap-intensity")),J,d.id,O.layoutVertexBuffer,O.indexBuffer,O.segments,d.paint,v.transform.zoom,F)}function Go(v,s,d){const m=v.context,y=m.gl;m.setColorMode(v.colorModeForRenderPass());const x=ql(m,s),M=d.key,P=s.heatmapFbos.get(M);P&&(m.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,P.colorAttachment.get()),m.activeTexture.set(y.TEXTURE1),x.bind(y.LINEAR,y.CLAMP_TO_EDGE),v.useProgram("heatmapTexture").draw(m,y.TRIANGLES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,ru(v,s,0,1),null,s.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments,s.paint,v.transform.zoom),P.destroy(),s.heatmapFbos.delete(M))}function Hl(v,s,d){var m,y;const x=v.gl,M=x.createTexture();x.bindTexture(x.TEXTURE_2D,M),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.LINEAR),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.LINEAR);const P=(m=v.HALF_FLOAT)!==null&&m!==void 0?m:x.UNSIGNED_BYTE,O=(y=v.RGBA16F)!==null&&y!==void 0?y:x.RGBA;x.texImage2D(x.TEXTURE_2D,0,O,s,d,0,x.RGBA,P,null);const z=v.createFramebuffer(s,d,!1,!1);return z.colorAttachment.set(M),z}function ql(v,s){return s.colorRampTexture||(s.colorRampTexture=new tt(v,s.colorRamp,v.gl.RGBA)),s.colorRampTexture}function Na(v,s,d,m,y){if(!d||!m||!m.imageAtlas)return;const x=m.imageAtlas.patternPositions;let M=x[d.to.toString()],P=x[d.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const O=y.getPaintProperty(s);M=x[O],P=x[O]}M&&P&&v.setConstantPatternPositions(M,P)}function Wl(v,s,d,m,y,x,M){const P=v.context.gl,O="fill-pattern",z=d.paint.get(O),V=z&&z.constantOr(1),F=d.getCrossfadeParameters();let W,J,ee,se,le;M?(J=V&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",W=P.LINES):(J=V?"fillPattern":"fill",W=P.TRIANGLES);const ce=z.constantOr(null);for(const he of m){const ne=s.getTile(he);if(V&&!ne.patternsLoaded())continue;const me=ne.getBucket(d);if(!me)continue;const ge=me.programConfigurations.get(d.id),xe=v.useProgram(J,ge),De=v.style.map.terrain&&v.style.map.terrain.getTerrainData(he);V&&(v.context.activeTexture.set(P.TEXTURE0),ne.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ge.updatePaintBuffers(F)),Na(ge,O,ce,ne,d);const Ve=De?he:null,Je=v.translatePosMatrix(Ve?Ve.posMatrix:he.posMatrix,ne,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(M){se=me.indexBuffer2,le=me.segments2;const st=[P.drawingBufferWidth,P.drawingBufferHeight];ee=J==="fillOutlinePattern"&&V?Xf(Je,v,F,ne,st):o_(Je,st)}else se=me.indexBuffer,le=me.segments,ee=V?Yf(Je,v,F,ne):Ia(Je);xe.draw(v.context,W,y,v.stencilModeForClipping(he),x,Tn.disabled,ee,De,d.id,me.layoutVertexBuffer,se,le,d.paint,v.transform.zoom,ge)}}function pu(v,s,d,m,y,x,M){const P=v.context,O=P.gl,z="fill-extrusion-pattern",V=d.paint.get(z),F=V.constantOr(1),W=d.getCrossfadeParameters(),J=d.paint.get("fill-extrusion-opacity"),ee=V.constantOr(null);for(const se of m){const le=s.getTile(se),ce=le.getBucket(d);if(!ce)continue;const he=v.style.map.terrain&&v.style.map.terrain.getTerrainData(se),ne=ce.programConfigurations.get(d.id),me=v.useProgram(F?"fillExtrusionPattern":"fillExtrusion",ne);F&&(v.context.activeTexture.set(O.TEXTURE0),le.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),ne.updatePaintBuffers(W)),Na(ne,z,ee,le,d);const ge=v.translatePosMatrix(se.posMatrix,le,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),xe=d.paint.get("fill-extrusion-vertical-gradient"),De=F?iu(ge,v,xe,J,se,W,le):Ll(ge,v,xe,J);me.draw(P,P.gl.TRIANGLES,y,x,M,Tn.backCCW,De,he,d.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,d.paint,v.transform.zoom,ne,v.style.map.terrain&&ce.centroidVertexBuffer)}}function za(v,s,d,m,y,x,M){const P=v.context,O=P.gl,z=d.fbo;if(!z)return;const V=v.useProgram("hillshade"),F=v.style.map.terrain&&v.style.map.terrain.getTerrainData(s);P.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,z.colorAttachment.get()),V.draw(P,O.TRIANGLES,y,x,M,Tn.disabled,((W,J,ee,se)=>{const le=ee.paint.get("hillshade-shadow-color"),ce=ee.paint.get("hillshade-highlight-color"),he=ee.paint.get("hillshade-accent-color");let ne=ee.paint.get("hillshade-illumination-direction")*(Math.PI/180);ee.paint.get("hillshade-illumination-anchor")==="viewport"&&(ne-=W.transform.angle);const me=!W.options.moving;return{u_matrix:se?se.posMatrix:W.transform.calculatePosMatrix(J.tileID.toUnwrapped(),me),u_image:0,u_latrange:su(0,J.tileID),u_light:[ee.paint.get("hillshade-exaggeration"),ne],u_shadow:le,u_highlight:ce,u_accent:he}})(v,d,m,F?s:null),F,m.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments)}function Ra(v,s,d,m,y,x){const M=v.context,P=M.gl,O=s.dem;if(O&&O.data){const z=O.dim,V=O.stride,F=O.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),s.demTexture=s.demTexture||v.getTileTexture(V),s.demTexture){const J=s.demTexture;J.update(F,{premultiply:!1}),J.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else s.demTexture=new tt(M,F,P.RGBA,{premultiply:!1}),s.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);M.activeTexture.set(P.TEXTURE0);let W=s.fbo;if(!W){const J=new tt(M,{width:z,height:z,data:null},P.RGBA);J.bind(P.LINEAR,P.CLAMP_TO_EDGE),W=s.fbo=M.createFramebuffer(z,z,!0,!1),W.colorAttachment.set(J.texture)}M.bindFramebuffer.set(W.framebuffer),M.viewport.set([0,0,z,z]),v.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,m,y,x,Tn.disabled,((J,ee)=>{const se=ee.stride,le=l.H();return l.aP(le,0,l.X,-l.X,0,0,1),l.J(le,le,[0,-l.X,0]),{u_matrix:le,u_image:1,u_dimension:[se,se],u_zoom:J.overscaledZ,u_unpack:ee.getUnpackVector()}})(s.tileID,O),null,d.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments),s.needsHillshadePrepare=!1}}function pm(v,s,d,m,y,x){const M=m.paint.get("raster-fade-duration");if(!x&&M>0){const P=E.now(),O=(P-v.timeAdded)/M,z=s?(P-s.timeAdded)/M:-1,V=d.getSource(),F=y.coveringZoomLevel({tileSize:V.tileSize,roundZoom:V.roundZoom}),W=!s||Math.abs(s.tileID.overscaledZ-F)>Math.abs(v.tileID.overscaledZ-F),J=W&&v.refreshedUponExpiration?1:l.ac(W?O:1-z,0,1);return v.refreshedUponExpiration&&O>=1&&(v.refreshedUponExpiration=!1),s?{opacity:1,mix:1-J}:{opacity:J,mix:0}}return{opacity:1,mix:0}}const md=new l.aM(1,0,0,1),un=new l.aM(0,1,0,1),fu=new l.aM(0,0,1,1),v_=new l.aM(1,0,1,1),fm=new l.aM(0,1,1,1);function La(v,s,d,m){mu(v,0,s+d/2,v.transform.width,d,m)}function mm(v,s,d,m){mu(v,s-d/2,0,d,v.transform.height,m)}function mu(v,s,d,m,y,x){const M=v.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(s*v.pixelRatio,d*v.pixelRatio,m*v.pixelRatio,y*v.pixelRatio),M.clear({color:x}),P.disable(P.SCISSOR_TEST)}function gm(v,s,d){const m=v.context,y=m.gl,x=d.posMatrix,M=v.useProgram("debug"),P=Gt.disabled,O=On.disabled,z=v.colorModeForRenderPass(),V="$debug",F=v.style.map.terrain&&v.style.map.terrain.getTerrainData(d);m.activeTexture.set(y.TEXTURE0);const W=s.getTileByID(d.key).latestRawTileData,J=Math.floor((W&&W.byteLength||0)/1024),ee=s.getTile(d).tileSize,se=512/Math.min(ee,512)*(d.overscaledZ/v.transform.zoom)*.5;let le=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(le+=` => ${d.overscaledZ}`),function(ce,he){ce.initDebugOverlayCanvas();const ne=ce.debugOverlayCanvas,me=ce.context.gl,ge=ce.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,ne.width,ne.height),ge.shadowColor="white",ge.shadowBlur=2,ge.lineWidth=1.5,ge.strokeStyle="white",ge.textBaseline="top",ge.font="bold 36px Open Sans, sans-serif",ge.fillText(he,5,5),ge.strokeText(he,5,5),ce.debugOverlayTexture.update(ne),ce.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(v,`${le} ${J}kB`),M.draw(m,y.TRIANGLES,P,O,Jn.alphaBlended,Tn.disabled,Vl(x,l.aM.transparent,se),null,V,v.debugBuffer,v.quadTriangleIndexBuffer,v.debugSegments),M.draw(m,y.LINE_STRIP,P,O,z,Tn.disabled,Vl(x,l.aM.red),F,V,v.debugBuffer,v.tileBorderIndexBuffer,v.debugSegments)}function ym(v,s,d){const m=v.context,y=m.gl,x=v.colorModeForRenderPass(),M=new Gt(y.LEQUAL,Gt.ReadWrite,v.depthRangeFor3D),P=v.useProgram("terrain"),O=s.getTerrainMesh();m.bindFramebuffer.set(null),m.viewport.set([0,0,v.width,v.height]);for(const z of d){const V=v.renderToTexture.getTexture(z),F=s.getTerrainData(z.tileID);m.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,V.texture);const W=v.transform.calculatePosMatrix(z.tileID.toUnwrapped()),J=s.getMeshFrameDelta(v.transform.zoom),ee=v.transform.calculateFogMatrix(z.tileID.toUnwrapped()),se=Jh(W,J,ee,v.style.sky,v.transform.pitch);P.draw(m,y.TRIANGLES,M,On.disabled,x,Tn.backCCW,se,F,"terrain",O.vertexBuffer,O.indexBuffer,O.segments)}}class gu{constructor(s,d,m){this.vertexBuffer=s,this.indexBuffer=d,this.segments=m}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class yu{constructor(s,d){this.context=new x_(s),this.transform=d,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ze.maxUnderzooming+ze.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Xh}resize(s,d,m){if(this.width=Math.floor(s*m),this.height=Math.floor(d*m),this.pixelRatio=m,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const y of this.style._order)this.style._layers[y].resize()}setup(){const s=this.context,d=new l.aX;d.emplaceBack(0,0),d.emplaceBack(l.X,0),d.emplaceBack(0,l.X),d.emplaceBack(l.X,l.X),this.tileExtentBuffer=s.createVertexBuffer(d,Fo.members),this.tileExtentSegments=l.a0.simpleSegment(0,0,4,2);const m=new l.aX;m.emplaceBack(0,0),m.emplaceBack(l.X,0),m.emplaceBack(0,l.X),m.emplaceBack(l.X,l.X),this.debugBuffer=s.createVertexBuffer(m,Fo.members),this.debugSegments=l.a0.simpleSegment(0,0,4,5);const y=new l.$;y.emplaceBack(0,0,0,0),y.emplaceBack(l.X,0,l.X,0),y.emplaceBack(0,l.X,0,l.X),y.emplaceBack(l.X,l.X,l.X,l.X),this.rasterBoundsBuffer=s.createVertexBuffer(y,ui.members),this.rasterBoundsSegments=l.a0.simpleSegment(0,0,4,2);const x=new l.aX;x.emplaceBack(0,0),x.emplaceBack(1,0),x.emplaceBack(0,1),x.emplaceBack(1,1),this.viewportBuffer=s.createVertexBuffer(x,Fo.members),this.viewportSegments=l.a0.simpleSegment(0,0,4,2);const M=new l.aZ;M.emplaceBack(0),M.emplaceBack(1),M.emplaceBack(3),M.emplaceBack(2),M.emplaceBack(0),this.tileBorderIndexBuffer=s.createIndexBuffer(M);const P=new l.aY;P.emplaceBack(0,1,2),P.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=s.createIndexBuffer(P);const O=this.context.gl;this.stencilClearMode=new On({func:O.ALWAYS,mask:0},0,255,O.ZERO,O.ZERO,O.ZERO)}clearStencil(){const s=this.context,d=s.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const m=l.H();l.aP(m,0,this.width,this.height,0,0,1),l.K(m,m,[d.drawingBufferWidth,d.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(s,d.TRIANGLES,Gt.disabled,this.stencilClearMode,Jn.disabled,Tn.disabled,nr(m),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(s,d){if(this.currentStencilSource===s.source||!s.isTileClipped()||!d||!d.length)return;this.currentStencilSource=s.source;const m=this.context,y=m.gl;this.nextStencilID+d.length>256&&this.clearStencil(),m.setColorMode(Jn.disabled),m.setDepthMode(Gt.disabled);const x=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of d){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,O=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);x.draw(m,y.TRIANGLES,Gt.disabled,new On({func:y.ALWAYS,mask:0},P,255,y.KEEP,y.KEEP,y.REPLACE),Jn.disabled,Tn.disabled,nr(M.posMatrix),O,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const s=this.nextStencilID++,d=this.context.gl;return new On({func:d.NOTEQUAL,mask:255},s,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(s){const d=this.context.gl;return new On({func:d.EQUAL,mask:255},this._tileClippingMaskIDs[s.key],0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(s){const d=this.context.gl,m=s.sort((M,P)=>P.overscaledZ-M.overscaledZ),y=m[m.length-1].overscaledZ,x=m[0].overscaledZ-y+1;if(x>1){this.currentStencilSource=void 0,this.nextStencilID+x>256&&this.clearStencil();const M={};for(let P=0;P<x;P++)M[P+y]=new On({func:d.GEQUAL,mask:255},P+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=x,[M,m]}return[{[y]:On.disabled},m]}colorModeForRenderPass(){const s=this.context.gl;return this._showOverdrawInspector?new Jn([s.CONSTANT_COLOR,s.ONE],new l.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Jn.unblended:Jn.alphaBlended}depthModeForSublayer(s,d,m){if(!this.opaquePassEnabledForLayer())return Gt.disabled;const y=1-((1+this.currentLayer)*this.numSublayers+s)*this.depthEpsilon;return new Gt(m||this.context.gl.LEQUAL,d,[y,y])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(s,d){this.style=s,this.options=d,this.lineAtlas=s.lineAtlas,this.imageManager=s.imageManager,this.glyphManager=s.glyphManager,this.symbolFadeChange=s.placement.symbolFadeChange(E.now()),this.imageManager.beginFrame();const m=this.style._order,y=this.style.sourceCaches,x={},M={},P={};for(const O in y){const z=y[O];z.used&&z.prepare(this.context),x[O]=z.getVisibleCoordinates(),M[O]=x[O].slice().reverse(),P[O]=z.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let O=0;O<m.length;O++)if(this.style._layers[m[O]].is3D()){this.opaquePassCutoff=O;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const O of m){const z=this.style._layers[O];if(!z.hasOffscreenPass()||z.isHidden(this.transform.zoom))continue;const V=M[z.source];(z.type==="custom"||V.length)&&this.renderLayer(this,y[z.source],z,V)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:d.showOverdrawInspector?l.aM.black:l.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(O,z){const V=O.context,F=V.gl,W=((ce,he,ne)=>({u_sky_color:ce.properties.get("sky-color"),u_horizon_color:ce.properties.get("horizon-color"),u_horizon:(he.height/2+he.getHorizon())*ne,u_sky_horizon_blend:ce.properties.get("sky-horizon-blend")*he.height/2*ne}))(z,O.style.map.transform,O.pixelRatio),J=new Gt(F.LEQUAL,Gt.ReadWrite,[0,1]),ee=On.disabled,se=O.colorModeForRenderPass(),le=O.useProgram("sky");if(!z.mesh){const ce=new l.aX;ce.emplaceBack(-1,-1),ce.emplaceBack(1,-1),ce.emplaceBack(1,1),ce.emplaceBack(-1,1);const he=new l.aY;he.emplaceBack(0,1,2),he.emplaceBack(0,2,3),z.mesh=new gu(V.createVertexBuffer(ce,Fo.members),V.createIndexBuffer(he),l.a0.simpleSegment(0,0,ce.length,he.length))}le.draw(V,F.TRIANGLES,J,ee,se,Tn.disabled,W,void 0,"sky",z.mesh.vertexBuffer,z.mesh.indexBuffer,z.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=d.showOverdrawInspector,this.depthRangeFor3D=[0,1-(s._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=m.length-1;this.currentLayer>=0;this.currentLayer--){const O=this.style._layers[m[this.currentLayer]],z=y[O.source],V=x[O.source];this._renderTileClippingMasks(O,V),this.renderLayer(this,z,O,V)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<m.length;this.currentLayer++){const O=this.style._layers[m[this.currentLayer]],z=y[O.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(O))continue;const V=(O.type==="symbol"?P:M)[O.source];this._renderTileClippingMasks(O,x[O.source]),this.renderLayer(this,z,O,V)}if(this.options.showTileBoundaries){const O=function(z,V){let F=null;const W=Object.values(z._layers).flatMap(le=>le.source&&!le.isHidden(V)?[z.sourceCaches[le.source]]:[]),J=W.filter(le=>le.getSource().type==="vector"),ee=W.filter(le=>le.getSource().type!=="vector"),se=le=>{(!F||F.getSource().maxzoom<le.getSource().maxzoom)&&(F=le)};return J.forEach(le=>se(le)),F||ee.forEach(le=>se(le)),F}(this.style,this.transform.zoom);O&&function(z,V,F){for(let W=0;W<F.length;W++)gm(z,V,F[W])}(this,O,O.getVisibleCoordinates())}this.options.showPadding&&function(O){const z=O.transform.padding;La(O,O.transform.height-(z.top||0),3,md),La(O,z.bottom||0,3,un),mm(O,z.left||0,3,fu),mm(O,O.transform.width-(z.right||0),3,v_);const V=O.transform.centerPoint;(function(F,W,J,ee){mu(F,W-1,J-10,2,20,ee),mu(F,W-10,J-1,20,2,ee)})(O,V.x,O.transform.height-V.y,fm)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(s){if(!this.style||!this.style.map||!this.style.map.terrain)return;const d=this.terrainFacilitator.matrix,m=this.transform.modelViewProjectionMatrix;let y=this.terrainFacilitator.dirty;y||(y=s?!l.a_(d,m):!l.a$(d,m)),y||(y=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),y&&(l.b0(d,m),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(x,M){const P=x.context,O=P.gl,z=Jn.unblended,V=new Gt(O.LEQUAL,Gt.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.sourceCache.getRenderableTiles(),J=x.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1});for(const ee of W){const se=M.getTerrainData(ee.tileID),le={u_matrix:x.transform.calculatePosMatrix(ee.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(x.transform.zoom)};J.draw(P,O.TRIANGLES,V,On.disabled,z,Tn.backCCW,le,se,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain),function(x,M){const P=x.context,O=P.gl,z=Jn.unblended,V=new Gt(O.LEQUAL,Gt.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.getCoordsTexture(),J=M.sourceCache.getRenderableTiles(),ee=x.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1}),M.coordsIndex=[];for(const se of J){const le=M.getTerrainData(se.tileID);P.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,W.texture);const ce={u_matrix:x.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(x.transform.zoom)};ee.draw(P,O.TRIANGLES,V,On.disabled,z,Tn.backCCW,ce,le,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),M.coordsIndex.push(se.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain))}renderLayer(s,d,m,y){if(!m.isHidden(this.transform.zoom)&&(m.type==="background"||m.type==="custom"||(y||[]).length))switch(this.id=m.id,m.type){case"symbol":(function(x,M,P,O,z){if(x.renderPass!=="translucent")return;const V=On.disabled,F=x.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(W,J,ee,se,le,ce,he,ne,me){const ge=J.transform,xe=Vo(),De=le==="map",Ve=ce==="map";for(const Je of W){const st=se.getTile(Je),Ze=st.getBucket(ee);if(!Ze||!Ze.text||!Ze.text.segments.get().length)continue;const We=l.ag(Ze.textSizeData,ge.zoom),mt=Kt(st,1,J.transform.zoom),Ot=qi(Je.posMatrix,Ve,De,J.transform,mt),Xe=ee.layout.get("icon-text-fit")!=="none"&&Ze.hasIconData();if(We){const nt=Math.pow(2,ge.zoom-st.tileID.overscaledZ),It=J.style.map.terrain?($t,Jt)=>J.style.map.terrain.getElevation(Je,$t,Jt):null,Fn=xe.translatePosition(ge,st,he,ne);Ba(Ze,De,Ve,me,ge,Ot,Je.posMatrix,nt,We,Xe,xe,Fn,Je.toUnwrapped(),It)}}}(O,x,P,M,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),z),P.paint.get("icon-opacity").constantOr(1)!==0&&dd(x,M,P,O,!1,P.paint.get("icon-translate"),P.paint.get("icon-translate-anchor"),P.layout.get("icon-rotation-alignment"),P.layout.get("icon-pitch-alignment"),P.layout.get("icon-keep-upright"),V,F),P.paint.get("text-opacity").constantOr(1)!==0&&dd(x,M,P,O,!0,P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.layout.get("text-keep-upright"),V,F),M.map.showCollisionBoxes&&(jl(x,M,P,O,!0),jl(x,M,P,O,!1))})(s,d,m,y,this.style.placement.variableOffsets);break;case"circle":(function(x,M,P,O){if(x.renderPass!=="translucent")return;const z=P.paint.get("circle-opacity"),V=P.paint.get("circle-stroke-width"),F=P.paint.get("circle-stroke-opacity"),W=!P.layout.get("circle-sort-key").isConstant();if(z.constantOr(1)===0&&(V.constantOr(1)===0||F.constantOr(1)===0))return;const J=x.context,ee=J.gl,se=x.depthModeForSublayer(0,Gt.ReadOnly),le=On.disabled,ce=x.colorModeForRenderPass(),he=[];for(let ne=0;ne<O.length;ne++){const me=O[ne],ge=M.getTile(me),xe=ge.getBucket(P);if(!xe)continue;const De=xe.programConfigurations.get(P.id),Ve=x.useProgram("circle",De),Je=xe.layoutVertexBuffer,st=xe.indexBuffer,Ze=x.style.map.terrain&&x.style.map.terrain.getTerrainData(me),We={programConfiguration:De,program:Ve,layoutVertexBuffer:Je,indexBuffer:st,uniformValues:a_(x,me,ge,P),terrainData:Ze};if(W){const mt=xe.segments.get();for(const Ot of mt)he.push({segments:new l.a0([Ot]),sortKey:Ot.sortKey,state:We})}else he.push({segments:xe.segments,sortKey:0,state:We})}W&&he.sort((ne,me)=>ne.sortKey-me.sortKey);for(const ne of he){const{programConfiguration:me,program:ge,layoutVertexBuffer:xe,indexBuffer:De,uniformValues:Ve,terrainData:Je}=ne.state;ge.draw(J,ee.TRIANGLES,se,le,ce,Tn.disabled,Ve,Je,P.id,xe,De,ne.segments,P.paint,x.transform.zoom,me)}})(s,d,m,y);break;case"heatmap":(function(x,M,P,O){if(P.paint.get("heatmap-opacity")===0)return;const z=x.context;if(x.style.map.terrain){for(const V of O){const F=M.getTile(V);M.hasRenderableParent(V)||(x.renderPass==="offscreen"?fd(x,F,P,V):x.renderPass==="translucent"&&Go(x,P,V))}z.viewport.set([0,0,x.width,x.height])}else x.renderPass==="offscreen"?function(V,F,W,J){const ee=V.context,se=ee.gl,le=On.disabled,ce=new Jn([se.ONE,se.ONE],l.aM.transparent,[!0,!0,!0,!0]);(function(he,ne,me){const ge=he.gl;he.activeTexture.set(ge.TEXTURE1),he.viewport.set([0,0,ne.width/4,ne.height/4]);let xe=me.heatmapFbos.get(l.aU);xe?(ge.bindTexture(ge.TEXTURE_2D,xe.colorAttachment.get()),he.bindFramebuffer.set(xe.framebuffer)):(xe=Hl(he,ne.width/4,ne.height/4),me.heatmapFbos.set(l.aU,xe))})(ee,V,W),ee.clear({color:l.aM.transparent});for(let he=0;he<J.length;he++){const ne=J[he];if(F.hasRenderableParent(ne))continue;const me=F.getTile(ne),ge=me.getBucket(W);if(!ge)continue;const xe=ge.programConfigurations.get(W.id),De=V.useProgram("heatmap",xe),{zoom:Ve}=V.transform;De.draw(ee,se.TRIANGLES,Gt.disabled,le,ce,Tn.disabled,ir(ne.posMatrix,me,Ve,W.paint.get("heatmap-intensity")),null,W.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,W.paint,V.transform.zoom,xe)}ee.viewport.set([0,0,V.width,V.height])}(x,M,P,O):x.renderPass==="translucent"&&function(V,F){const W=V.context,J=W.gl;W.setColorMode(V.colorModeForRenderPass());const ee=F.heatmapFbos.get(l.aU);ee&&(W.activeTexture.set(J.TEXTURE0),J.bindTexture(J.TEXTURE_2D,ee.colorAttachment.get()),W.activeTexture.set(J.TEXTURE1),ql(W,F).bind(J.LINEAR,J.CLAMP_TO_EDGE),V.useProgram("heatmapTexture").draw(W,J.TRIANGLES,Gt.disabled,On.disabled,V.colorModeForRenderPass(),Tn.disabled,ru(V,F,0,1),null,F.id,V.viewportBuffer,V.quadTriangleIndexBuffer,V.viewportSegments,F.paint,V.transform.zoom))}(x,P)})(s,d,m,y);break;case"line":(function(x,M,P,O){if(x.renderPass!=="translucent")return;const z=P.paint.get("line-opacity"),V=P.paint.get("line-width");if(z.constantOr(1)===0||V.constantOr(1)===0)return;const F=x.depthModeForSublayer(0,Gt.ReadOnly),W=x.colorModeForRenderPass(),J=P.paint.get("line-dasharray"),ee=P.paint.get("line-pattern"),se=ee.constantOr(1),le=P.paint.get("line-gradient"),ce=P.getCrossfadeParameters(),he=se?"linePattern":J?"lineSDF":le?"lineGradient":"line",ne=x.context,me=ne.gl;let ge=!0;for(const xe of O){const De=M.getTile(xe);if(se&&!De.patternsLoaded())continue;const Ve=De.getBucket(P);if(!Ve)continue;const Je=Ve.programConfigurations.get(P.id),st=x.context.program.get(),Ze=x.useProgram(he,Je),We=ge||Ze.program!==st,mt=x.style.map.terrain&&x.style.map.terrain.getTerrainData(xe),Ot=ee.constantOr(null);if(Ot&&De.imageAtlas){const It=De.imageAtlas,Fn=It.patternPositions[Ot.to.toString()],$t=It.patternPositions[Ot.from.toString()];Fn&&$t&&Je.setConstantPatternPositions(Fn,$t)}const Xe=mt?xe:null,nt=se?Da(x,De,P,ce,Xe):J?l_(x,De,P,J,ce,Xe):le?Kf(x,De,P,Ve.lineClipsArray.length,Xe):ou(x,De,P,Xe);if(se)ne.activeTexture.set(me.TEXTURE0),De.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),Je.updatePaintBuffers(ce);else if(J&&(We||x.lineAtlas.dirty))ne.activeTexture.set(me.TEXTURE0),x.lineAtlas.bind(ne);else if(le){const It=Ve.gradients[P.id];let Fn=It.texture;if(P.gradientVersion!==It.version){let $t=256;if(P.stepInterpolant){const Jt=M.getSource().maxzoom,$n=xe.canonical.z===Jt?Math.ceil(1<<x.transform.maxZoom-xe.canonical.z):1;$t=l.ac(l.aV(Ve.maxLineLength/l.X*1024*$n),256,ne.maxTextureSize)}It.gradient=l.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:$t,image:It.gradient||void 0,clips:Ve.lineClipsArray}),It.texture?It.texture.update(It.gradient):It.texture=new tt(ne,It.gradient,me.RGBA),It.version=P.gradientVersion,Fn=It.texture}ne.activeTexture.set(me.TEXTURE0),Fn.bind(P.stepInterpolant?me.NEAREST:me.LINEAR,me.CLAMP_TO_EDGE)}Ze.draw(ne,me.TRIANGLES,F,x.stencilModeForClipping(xe),W,Tn.disabled,nt,mt,P.id,Ve.layoutVertexBuffer,Ve.indexBuffer,Ve.segments,P.paint,x.transform.zoom,Je,Ve.layoutVertexBuffer2),ge=!1}})(s,d,m,y);break;case"fill":(function(x,M,P,O){const z=P.paint.get("fill-color"),V=P.paint.get("fill-opacity");if(V.constantOr(1)===0)return;const F=x.colorModeForRenderPass(),W=P.paint.get("fill-pattern"),J=x.opaquePassEnabledForLayer()&&!W.constantOr(1)&&z.constantOr(l.aM.transparent).a===1&&V.constantOr(0)===1?"opaque":"translucent";if(x.renderPass===J){const ee=x.depthModeForSublayer(1,x.renderPass==="opaque"?Gt.ReadWrite:Gt.ReadOnly);Wl(x,M,P,O,ee,F,!1)}if(x.renderPass==="translucent"&&P.paint.get("fill-antialias")){const ee=x.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,Gt.ReadOnly);Wl(x,M,P,O,ee,F,!0)}})(s,d,m,y);break;case"fill-extrusion":(function(x,M,P,O){const z=P.paint.get("fill-extrusion-opacity");if(z!==0&&x.renderPass==="translucent"){const V=new Gt(x.context.gl.LEQUAL,Gt.ReadWrite,x.depthRangeFor3D);if(z!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))pu(x,M,P,O,V,On.disabled,Jn.disabled),pu(x,M,P,O,V,x.stencilModeFor3D(),x.colorModeForRenderPass());else{const F=x.colorModeForRenderPass();pu(x,M,P,O,V,On.disabled,F)}}})(s,d,m,y);break;case"hillshade":(function(x,M,P,O){if(x.renderPass!=="offscreen"&&x.renderPass!=="translucent")return;const z=x.context,V=x.depthModeForSublayer(0,Gt.ReadOnly),F=x.colorModeForRenderPass(),[W,J]=x.renderPass==="translucent"?x.stencilConfigForOverlap(O):[{},O];for(const ee of J){const se=M.getTile(ee);se.needsHillshadePrepare!==void 0&&se.needsHillshadePrepare&&x.renderPass==="offscreen"?Ra(x,se,P,V,On.disabled,F):x.renderPass==="translucent"&&za(x,ee,se,P,V,W[ee.overscaledZ],F)}z.viewport.set([0,0,x.width,x.height])})(s,d,m,y);break;case"raster":(function(x,M,P,O){if(x.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!O.length)return;const z=x.context,V=z.gl,F=M.getSource(),W=x.useProgram("raster"),J=x.colorModeForRenderPass(),[ee,se]=F instanceof mi?[{},O]:x.stencilConfigForOverlap(O),le=se[se.length-1].overscaledZ,ce=!x.options.moving;for(const he of se){const ne=x.depthModeForSublayer(he.overscaledZ-le,P.paint.get("raster-opacity")===1?Gt.ReadWrite:Gt.ReadOnly,V.LESS),me=M.getTile(he);me.registerFadeDuration(P.paint.get("raster-fade-duration"));const ge=M.findLoadedParent(he,0),xe=M.findLoadedSibling(he),De=pm(me,ge||xe||null,M,P,x.transform,x.style.map.terrain);let Ve,Je;const st=P.paint.get("raster-resampling")==="nearest"?V.NEAREST:V.LINEAR;z.activeTexture.set(V.TEXTURE0),me.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),z.activeTexture.set(V.TEXTURE1),ge?(ge.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),Ve=Math.pow(2,ge.tileID.overscaledZ-me.tileID.overscaledZ),Je=[me.tileID.canonical.x*Ve%1,me.tileID.canonical.y*Ve%1]):me.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),me.texture.useMipmap&&z.extTextureFilterAnisotropic&&x.transform.pitch>20&&V.texParameterf(V.TEXTURE_2D,z.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,z.extTextureFilterAnisotropicMax);const Ze=x.style.map.terrain&&x.style.map.terrain.getTerrainData(he),We=Ze?he:null,mt=We?We.posMatrix:x.transform.calculatePosMatrix(he.toUnwrapped(),ce),Ot=c_(mt,Je||[0,0],Ve||1,De,P);F instanceof mi?W.draw(z,V.TRIANGLES,ne,On.disabled,J,Tn.disabled,Ot,Ze,P.id,F.boundsBuffer,x.quadTriangleIndexBuffer,F.boundsSegments):W.draw(z,V.TRIANGLES,ne,ee[he.overscaledZ],J,Tn.disabled,Ot,Ze,P.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments)}})(s,d,m,y);break;case"background":(function(x,M,P,O){const z=P.paint.get("background-color"),V=P.paint.get("background-opacity");if(V===0)return;const F=x.context,W=F.gl,J=x.transform,ee=J.tileSize,se=P.paint.get("background-pattern");if(x.isPatternMissing(se))return;const le=!se&&z.a===1&&V===1&&x.opaquePassEnabledForLayer()?"opaque":"translucent";if(x.renderPass!==le)return;const ce=On.disabled,he=x.depthModeForSublayer(0,le==="opaque"?Gt.ReadWrite:Gt.ReadOnly),ne=x.colorModeForRenderPass(),me=x.useProgram(se?"backgroundPattern":"background"),ge=O||J.coveringTiles({tileSize:ee,terrain:x.style.map.terrain});se&&(F.activeTexture.set(W.TEXTURE0),x.imageManager.bind(x.context));const xe=P.getCrossfadeParameters();for(const De of ge){const Ve=O?De.posMatrix:x.transform.calculatePosMatrix(De.toUnwrapped()),Je=se?td(Ve,V,x,se,{tileID:De,tileSize:ee},xe):au(Ve,V,z),st=x.style.map.terrain&&x.style.map.terrain.getTerrainData(De);me.draw(F,W.TRIANGLES,he,ce,ne,Tn.disabled,Je,st,P.id,x.tileExtentBuffer,x.quadTriangleIndexBuffer,x.tileExtentSegments)}})(s,0,m,y);break;case"custom":(function(x,M,P){const O=x.context,z=P.implementation;if(x.renderPass==="offscreen"){const V=z.prerender;V&&(x.setCustomLayerDefaults(),O.setColorMode(x.colorModeForRenderPass()),V.call(z,O.gl,x.transform.customLayerMatrix()),O.setDirty(),x.setBaseState())}else if(x.renderPass==="translucent"){x.setCustomLayerDefaults(),O.setColorMode(x.colorModeForRenderPass()),O.setStencilMode(On.disabled);const V=z.renderingMode==="3d"?new Gt(x.context.gl.LEQUAL,Gt.ReadWrite,x.depthRangeFor3D):x.depthModeForSublayer(0,Gt.ReadOnly);O.setDepthMode(V),z.render(O.gl,x.transform.customLayerMatrix(),{farZ:x.transform.farZ,nearZ:x.transform.nearZ,fov:x.transform._fov,modelViewProjectionMatrix:x.transform.modelViewProjectionMatrix,projectionMatrix:x.transform.projectionMatrix}),O.setDirty(),x.setBaseState(),O.bindFramebuffer.set(null)}})(s,0,m)}}translatePosMatrix(s,d,m,y,x){if(!m[0]&&!m[1])return s;const M=x?y==="map"?this.transform.angle:0:y==="viewport"?-this.transform.angle:0;if(M){const z=Math.sin(M),V=Math.cos(M);m=[m[0]*V-m[1]*z,m[0]*z+m[1]*V]}const P=[x?m[0]:Kt(d,m[0],this.transform.zoom),x?m[1]:Kt(d,m[1],this.transform.zoom),0],O=new Float32Array(16);return l.J(O,s,P),O}saveTileTexture(s){const d=this._tileTextures[s.size[0]];d?d.push(s):this._tileTextures[s.size[0]]=[s]}getTileTexture(s){const d=this._tileTextures[s];return d&&d.length>0?d.pop():null}isPatternMissing(s){if(!s)return!1;if(!s.from||!s.to)return!0;const d=this.imageManager.getPattern(s.from.toString()),m=this.imageManager.getPattern(s.to.toString());return!d||!m}useProgram(s,d){this.cache=this.cache||{};const m=s+(d?d.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[m]||(this.cache[m]=new Qh(this.context,uo[s],d,nd[s],this._showOverdrawInspector,this.style.map.terrain)),this.cache[m]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const s=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(s.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new tt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:s,drawingBufferHeight:d}=this.context.gl;return this.width!==s||this.height!==d}}class Va{constructor(s,d){this.points=s,this.planes=d}static fromInvProjectionMatrix(s,d,m){const y=Math.pow(2,m),x=[[-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(P=>{const O=1/(P=l.af([],P,s))[3]/d*y;return l.b1(P,P,[O,O,1/P[3],O])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const O=function(W,J){var ee=J[0],se=J[1],le=J[2],ce=ee*ee+se*se+le*le;return ce>0&&(ce=1/Math.sqrt(ce)),W[0]=J[0]*ce,W[1]=J[1]*ce,W[2]=J[2]*ce,W}([],function(W,J,ee){var se=J[0],le=J[1],ce=J[2],he=ee[0],ne=ee[1],me=ee[2];return W[0]=le*me-ce*ne,W[1]=ce*he-se*me,W[2]=se*ne-le*he,W}([],Ae([],x[P[0]],x[P[1]]),Ae([],x[P[2]],x[P[1]]))),z=-((V=O)[0]*(F=x[P[1]])[0]+V[1]*F[1]+V[2]*F[2]);var V,F;return O.concat(z)});return new Va(x,M)}}class Fa{constructor(s,d){this.min=s,this.max=d,this.center=function(m,y,x){return m[0]=.5*y[0],m[1]=.5*y[1],m[2]=.5*y[2],m}([],function(m,y,x){return m[0]=y[0]+x[0],m[1]=y[1]+x[1],m[2]=y[2]+x[2],m}([],this.min,this.max))}quadrant(s){const d=[s%2==0,s<2],m=Me(this.min),y=Me(this.max);for(let x=0;x<d.length;x++)m[x]=d[x]?this.min[x]:this.center[x],y[x]=d[x]?this.center[x]:this.max[x];return y[2]=this.max[2],new Fa(m,y)}distanceX(s){return Math.max(Math.min(this.max[0],s[0]),this.min[0])-s[0]}distanceY(s){return Math.max(Math.min(this.max[1],s[1]),this.min[1])-s[1]}intersects(s){const d=[[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]];let m=!0;for(let y=0;y<s.planes.length;y++){const x=s.planes[y];let M=0;for(let P=0;P<d.length;P++)l.b2(x,d[P])>=0&&M++;if(M===0)return 0;M!==d.length&&(m=!1)}if(m)return 2;for(let y=0;y<3;y++){let x=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<s.points.length;P++){const O=s.points[P][y]-this.min[y];x=Math.min(x,O),M=Math.max(M,O)}if(M<0||x>this.max[y]-this.min[y])return 0}return 1}}class $a{constructor(s=0,d=0,m=0,y=0){if(isNaN(s)||s<0||isNaN(d)||d<0||isNaN(m)||m<0||isNaN(y)||y<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=s,this.bottom=d,this.left=m,this.right=y}interpolate(s,d,m){return d.top!=null&&s.top!=null&&(this.top=l.y.number(s.top,d.top,m)),d.bottom!=null&&s.bottom!=null&&(this.bottom=l.y.number(s.bottom,d.bottom,m)),d.left!=null&&s.left!=null&&(this.left=l.y.number(s.left,d.left,m)),d.right!=null&&s.right!=null&&(this.right=l.y.number(s.right,d.right,m)),this}getCenter(s,d){const m=l.ac((this.left+s-this.right)/2,0,s),y=l.ac((this.top+d-this.bottom)/2,0,d);return new l.P(m,y)}equals(s){return this.top===s.top&&this.bottom===s.bottom&&this.left===s.left&&this.right===s.right}clone(){return new $a(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const gd=85.051129;class ja{constructor(s,d,m,y,x){this.tileSize=512,this._renderWorldCopies=x===void 0||!!x,this._minZoom=s||0,this._maxZoom=d||22,this._minPitch=m??0,this._maxPitch=y??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new l.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new $a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const s=new ja(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return s.apply(this),s}apply(s){this.tileSize=s.tileSize,this.latRange=s.latRange,this.lngRange=s.lngRange,this.width=s.width,this.height=s.height,this._center=s._center,this._elevation=s._elevation,this.minElevationForCurrentTile=s.minElevationForCurrentTile,this.zoom=s.zoom,this.angle=s.angle,this._fov=s._fov,this._pitch=s._pitch,this._unmodified=s._unmodified,this._edgeInsets=s._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(s){this._minZoom!==s&&(this._minZoom=s,this.zoom=Math.max(this.zoom,s))}get maxZoom(){return this._maxZoom}set maxZoom(s){this._maxZoom!==s&&(this._maxZoom=s,this.zoom=Math.min(this.zoom,s))}get minPitch(){return this._minPitch}set minPitch(s){this._minPitch!==s&&(this._minPitch=s,this.pitch=Math.max(this.pitch,s))}get maxPitch(){return this._maxPitch}set maxPitch(s){this._maxPitch!==s&&(this._maxPitch=s,this.pitch=Math.min(this.pitch,s))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(s){s===void 0?s=!0:s===null&&(s=!1),this._renderWorldCopies=s}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(s){const d=-l.b3(s,-180,180)*Math.PI/180;this.angle!==d&&(this._unmodified=!1,this.angle=d,this._calcMatrices(),this.rotationMatrix=function(){var m=new l.A(4);return l.A!=Float32Array&&(m[1]=0,m[2]=0),m[0]=1,m[3]=1,m}(),function(m,y,x){var M=y[0],P=y[1],O=y[2],z=y[3],V=Math.sin(x),F=Math.cos(x);m[0]=M*F+O*V,m[1]=P*F+z*V,m[2]=M*-V+O*F,m[3]=P*-V+z*F}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(s){const d=l.ac(s,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==d&&(this._unmodified=!1,this._pitch=d,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(s){s=Math.max(.01,Math.min(60,s)),this._fov!==s&&(this._unmodified=!1,this._fov=s/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(s){const d=Math.min(Math.max(s,this.minZoom),this.maxZoom);this._zoom!==d&&(this._unmodified=!1,this._zoom=d,this.tileZoom=Math.max(0,Math.floor(d)),this.scale=this.zoomScale(d),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(s){s.lat===this._center.lat&&s.lng===this._center.lng||(this._unmodified=!1,this._center=s,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(s){s!==this._elevation&&(this._elevation=s,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(s){this._edgeInsets.equals(s)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,s,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(s){return this._edgeInsets.equals(s)}interpolatePadding(s,d,m){this._unmodified=!1,this._edgeInsets.interpolate(s,d,m),this._constrain(),this._calcMatrices()}coveringZoomLevel(s){const d=(s.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/s.tileSize));return Math.max(0,d)}getVisibleUnwrappedCoordinates(s){const d=[new l.b4(0,s)];if(this._renderWorldCopies){const m=this.pointCoordinate(new l.P(0,0)),y=this.pointCoordinate(new l.P(this.width,0)),x=this.pointCoordinate(new l.P(this.width,this.height)),M=this.pointCoordinate(new l.P(0,this.height)),P=Math.floor(Math.min(m.x,y.x,x.x,M.x)),O=Math.floor(Math.max(m.x,y.x,x.x,M.x)),z=1;for(let V=P-z;V<=O+z;V++)V!==0&&d.push(new l.b4(V,s))}return d}coveringTiles(s){var d,m;let y=this.coveringZoomLevel(s);const x=y;if(s.minzoom!==void 0&&y<s.minzoom)return[];s.maxzoom!==void 0&&y>s.maxzoom&&(y=s.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=l.Z.fromLngLat(this.center),O=Math.pow(2,y),z=[O*M.x,O*M.y,0],V=[O*P.x,O*P.y,0],F=Va.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,y);let W=s.minzoom||0;!s.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(W=y);const J=s.terrain?2/Math.min(this.tileSize,s.tileSize)*this.tileSize:3,ee=ne=>({aabb:new Fa([ne*O,0,0],[(ne+1)*O,O,0]),zoom:0,x:0,y:0,wrap:ne,fullyVisible:!1}),se=[],le=[],ce=y,he=s.reparseOverscaled?x:y;if(this._renderWorldCopies)for(let ne=1;ne<=3;ne++)se.push(ee(-ne)),se.push(ee(ne));for(se.push(ee(0));se.length>0;){const ne=se.pop(),me=ne.x,ge=ne.y;let xe=ne.fullyVisible;if(!xe){const Ze=ne.aabb.intersects(F);if(Ze===0)continue;xe=Ze===2}const De=s.terrain?z:V,Ve=ne.aabb.distanceX(De),Je=ne.aabb.distanceY(De),st=Math.max(Math.abs(Ve),Math.abs(Je));if(ne.zoom===ce||st>J+(1<<ce-ne.zoom)-2&&ne.zoom>=W){const Ze=ce-ne.zoom,We=z[0]-.5-(me<<Ze),mt=z[1]-.5-(ge<<Ze);le.push({tileID:new l.S(ne.zoom===ce?he:ne.zoom,ne.wrap,ne.zoom,me,ge),distanceSq:Fe([V[0]-.5-me,V[1]-.5-ge]),tileDistanceToCamera:Math.sqrt(We*We+mt*mt)})}else for(let Ze=0;Ze<4;Ze++){const We=(me<<1)+Ze%2,mt=(ge<<1)+(Ze>>1),Ot=ne.zoom+1;let Xe=ne.aabb.quadrant(Ze);if(s.terrain){const nt=new l.S(Ot,ne.wrap,Ot,We,mt),It=s.terrain.getMinMaxElevation(nt),Fn=(d=It.minElevation)!==null&&d!==void 0?d:this.elevation,$t=(m=It.maxElevation)!==null&&m!==void 0?m:this.elevation;Xe=new Fa([Xe.min[0],Xe.min[1],Fn],[Xe.max[0],Xe.max[1],$t])}se.push({aabb:Xe,zoom:Ot,x:We,y:mt,wrap:ne.wrap,fullyVisible:xe})}}return le.sort((ne,me)=>ne.distanceSq-me.distanceSq).map(ne=>ne.tileID)}resize(s,d){this.width=s,this.height=d,this.pixelsToGLUnits=[2/s,-2/d],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(s){return Math.pow(2,s)}scaleZoom(s){return Math.log(s)/Math.LN2}project(s){const d=l.ac(s.lat,-85.051129,gd);return new l.P(l.O(s.lng)*this.worldSize,l.Q(d)*this.worldSize)}unproject(s){return new l.Z(s.x/this.worldSize,s.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(s){const d=this.elevation,m=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,y=this.pointLocation(this.centerPoint,s),x=s.getElevationForLngLatZoom(y,this.tileZoom);if(!(this.elevation-x))return;const M=m+d-x,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/l.b5(1,y.lat),O=this.scaleZoom(P/this.tileSize);this._elevation=x,this._center=y,this.zoom=O}setLocationAtPoint(s,d){const m=this.pointCoordinate(d),y=this.pointCoordinate(this.centerPoint),x=this.locationCoordinate(s),M=new l.Z(x.x-(m.x-y.x),x.y-(m.y-y.y));this.center=this.coordinateLocation(M),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(s,d){return d?this.coordinatePoint(this.locationCoordinate(s),d.getElevationForLngLatZoom(s,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(s))}pointLocation(s,d){return this.coordinateLocation(this.pointCoordinate(s,d))}locationCoordinate(s){return l.Z.fromLngLat(s)}coordinateLocation(s){return s&&s.toLngLat()}pointCoordinate(s,d){if(d){const W=d.pointCoordinate(s);if(W!=null)return W}const m=[s.x,s.y,0,1],y=[s.x,s.y,1,1];l.af(m,m,this.pixelMatrixInverse),l.af(y,y,this.pixelMatrixInverse);const x=m[3],M=y[3],P=m[1]/x,O=y[1]/M,z=m[2]/x,V=y[2]/M,F=z===V?0:(0-z)/(V-z);return new l.Z(l.y.number(m[0]/x,y[0]/M,F)/this.worldSize,l.y.number(P,O,F)/this.worldSize)}coordinatePoint(s,d=0,m=this.pixelMatrix){const y=[s.x*this.worldSize,s.y*this.worldSize,d,1];return l.af(y,y,m),new l.P(y[0]/y[3],y[1]/y[3])}getBounds(){const s=Math.max(0,this.height/2-this.getHorizon());return new ve().extend(this.pointLocation(new l.P(0,s))).extend(this.pointLocation(new l.P(this.width,s))).extend(this.pointLocation(new l.P(this.width,this.height))).extend(this.pointLocation(new l.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(s){s?(this.lngRange=[s.getWest(),s.getEast()],this.latRange=[s.getSouth(),s.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,gd])}calculateTileMatrix(s){const d=s.canonical,m=this.worldSize/this.zoomScale(d.z),y=d.x+Math.pow(2,d.z)*s.wrap,x=l.an(new Float64Array(16));return l.J(x,x,[y*m,d.y*m,0]),l.K(x,x,[m/l.X,m/l.X,1]),x}calculatePosMatrix(s,d=!1){const m=s.key,y=d?this._alignedPosMatrixCache:this._posMatrixCache;if(y[m])return y[m];const x=this.calculateTileMatrix(s);return l.L(x,d?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,x),y[m]=new Float32Array(x),y[m]}calculateFogMatrix(s){const d=s.key,m=this._fogMatrixCache;if(m[d])return m[d];const y=this.calculateTileMatrix(s);return l.L(y,this.fogMatrix,y),m[d]=new Float32Array(y),m[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(s,d){d=l.ac(+d,this.minZoom,this.maxZoom);const m={center:new l.N(s.lng,s.lat),zoom:d};let y=this.lngRange;if(!this._renderWorldCopies&&y===null){const ne=179.9999999999;y=[-ne,ne]}const x=this.tileSize*this.zoomScale(m.zoom);let M=0,P=x,O=0,z=x,V=0,F=0;const{x:W,y:J}=this.size;if(this.latRange){const ne=this.latRange;M=l.Q(ne[1])*x,P=l.Q(ne[0])*x,P-M<J&&(V=J/(P-M))}y&&(O=l.b3(l.O(y[0])*x,0,x),z=l.b3(l.O(y[1])*x,0,x),z<O&&(z+=x),z-O<W&&(F=W/(z-O)));const{x:ee,y:se}=this.project.call({worldSize:x},s);let le,ce;const he=Math.max(F||0,V||0);if(he){const ne=new l.P(F?(z+O)/2:ee,V?(P+M)/2:se);return m.center=this.unproject.call({worldSize:x},ne).wrap(),m.zoom+=this.scaleZoom(he),m}if(this.latRange){const ne=J/2;se-ne<M&&(ce=M+ne),se+ne>P&&(ce=P-ne)}if(y){const ne=(O+z)/2;let me=ee;this._renderWorldCopies&&(me=l.b3(ee,ne-x/2,ne+x/2));const ge=W/2;me-ge<O&&(le=O+ge),me+ge>z&&(le=z-ge)}if(le!==void 0||ce!==void 0){const ne=new l.P(le??ee,ce??se);m.center=this.unproject.call({worldSize:x},ne).wrap()}return m}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const s=this._unmodified,{center:d,zoom:m}=this.getConstrained(this.center,this.zoom);this.center=d,this.zoom=m,this._unmodified=s,this._constraining=!1}_calcMatrices(){if(!this.height)return;const s=this.centerOffset,d=this.point.x,m=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=l.b5(1,this.center.lat)*this.worldSize;let y=l.an(new Float64Array(16));l.K(y,y,[this.width/2,-this.height/2,1]),l.J(y,y,[1,-1,0]),this.labelPlaneMatrix=y,y=l.an(new Float64Array(16)),l.K(y,y,[1,-1,1]),l.J(y,y,[-1,-1,0]),l.K(y,y,[2/this.width,2/this.height,1]),this.glCoordMatrix=y;const x=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=x-M*this._pixelPerMeter/Math.cos(this._pitch),O=M<0?P:x,z=Math.PI/2+this._pitch,V=this._fov*(.5+s.y/this.height),F=Math.sin(V)*O/Math.sin(l.ac(Math.PI-z-V,.01,Math.PI-.01)),W=this.getHorizon(),J=2*Math.atan(W/this.cameraToCenterDistance)*(.5+s.y/(2*W)),ee=Math.sin(J)*O/Math.sin(l.ac(Math.PI-z-J,.01,Math.PI-.01)),se=Math.min(F,ee);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+O),this.nearZ=this.height/50,y=new Float64Array(16),l.b6(y,this._fov,this.width/this.height,this.nearZ,this.farZ),y[8]=2*-s.x/this.width,y[9]=2*s.y/this.height,this.projectionMatrix=l.ae(y),l.K(y,y,[1,-1,1]),l.J(y,y,[0,0,-this.cameraToCenterDistance]),l.b7(y,y,this._pitch),l.ad(y,y,this.angle),l.J(y,y,[-d,-m,0]),this.mercatorMatrix=l.K([],y,[this.worldSize,this.worldSize,this.worldSize]),l.K(y,y,[1,1,this._pixelPerMeter]),this.pixelMatrix=l.L(new Float64Array(16),this.labelPlaneMatrix,y),l.J(y,y,[0,0,-this.elevation]),this.modelViewProjectionMatrix=y,this.invModelViewProjectionMatrix=l.as([],y),this.fogMatrix=new Float64Array(16),l.b6(this.fogMatrix,this._fov,this.width/this.height,x,this.farZ),this.fogMatrix[8]=2*-s.x/this.width,this.fogMatrix[9]=2*s.y/this.height,l.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),l.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),l.b7(this.fogMatrix,this.fogMatrix,this._pitch),l.ad(this.fogMatrix,this.fogMatrix,this.angle),l.J(this.fogMatrix,this.fogMatrix,[-d,-m,0]),l.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),l.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=l.L(new Float64Array(16),this.labelPlaneMatrix,y);const le=this.width%2/2,ce=this.height%2/2,he=Math.cos(this.angle),ne=Math.sin(this.angle),me=d-Math.round(d)+he*le+ne*ce,ge=m-Math.round(m)+he*ce+ne*le,xe=new Float64Array(y);if(l.J(xe,xe,[me>.5?me-1:me,ge>.5?ge-1:ge,0]),this.alignedModelViewProjectionMatrix=xe,y=l.as(new Float64Array(16),this.pixelMatrix),!y)throw new Error("failed to invert matrix");this.pixelMatrixInverse=y,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const s=this.pointCoordinate(new l.P(0,0)),d=[s.x*this.worldSize,s.y*this.worldSize,0,1];return l.af(d,d,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const s=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(0,s))}getCameraQueryGeometry(s){const d=this.getCameraPoint();if(s.length===1)return[s[0],d];{let m=d.x,y=d.y,x=d.x,M=d.y;for(const P of s)m=Math.min(m,P.x),y=Math.min(y,P.y),x=Math.max(x,P.x),M=Math.max(M,P.y);return[new l.P(m,y),new l.P(x,y),new l.P(x,M),new l.P(m,M),new l.P(m,y)]}}lngLatToCameraDepth(s,d){const m=this.locationCoordinate(s),y=[m.x*this.worldSize,m.y*this.worldSize,d,1];return l.af(y,y,this.modelViewProjectionMatrix),y[2]/y[3]}}function Gl(v,s){let d,m=!1,y=null,x=null;const M=()=>{y=null,m&&(v.apply(x,d),y=setTimeout(M,s),m=!1)};return(...P)=>(m=!0,x=this,d=P,y||M(),y)}class _u{constructor(s){this._getCurrentHash=()=>{const d=window.location.hash.replace("#","");if(this._hashName){let m;return d.split("&").map(y=>y.split("=")).forEach(y=>{y[0]===this._hashName&&(m=y)}),(m&&m[1]||"").split("/")}return d.split("/")},this._onHashChange=()=>{const d=this._getCurrentHash();if(d.length>=3&&!d.some(m=>isNaN(m))){const m=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(d[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+d[2],+d[1]],zoom:+d[0],bearing:m,pitch:+(d[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const d=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,d)},this._removeHash=()=>{const d=this._getCurrentHash();if(d.length===0)return;const m=d.join("/");let y=m;y.split("&").length>0&&(y=y.split("&")[0]),this._hashName&&(y=`${this._hashName}=${m}`);let x=window.location.hash.replace(y,"");x.startsWith("#&")?x=x.slice(0,1)+x.slice(2):x==="#"&&(x="");let M=window.location.href.replace(/(#.+)?$/,x);M=M.replace("&&","&"),window.history.replaceState(window.history.state,null,M)},this._updateHash=Gl(this._updateHashUnthrottled,300),this._hashName=s&&encodeURIComponent(s)}addTo(s){return this._map=s,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(s){const d=this._map.getCenter(),m=Math.round(100*this._map.getZoom())/100,y=Math.ceil((m*Math.LN2+Math.log(512/360/.5))/Math.LN10),x=Math.pow(10,y),M=Math.round(d.lng*x)/x,P=Math.round(d.lat*x)/x,O=this._map.getBearing(),z=this._map.getPitch();let V="";if(V+=s?`/${M}/${P}/${m}`:`${m}/${P}/${M}`,(O||z)&&(V+="/"+Math.round(10*O)/10),z&&(V+=`/${Math.round(z)}`),this._hashName){const F=this._hashName;let W=!1;const J=window.location.hash.slice(1).split("&").map(ee=>{const se=ee.split("=")[0];return se===F?(W=!0,`${se}=${V}`):ee}).filter(ee=>ee);return W||J.push(`${F}=${V}`),`#${J.join("&")}`}return`#${V}`}}const bu={linearity:.3,easing:l.b8(0,0,.3,1)},yd=l.e({deceleration:2500,maxSpeed:1400},bu),w_=l.e({deceleration:20,maxSpeed:1400},bu),_m=l.e({deceleration:1e3,maxSpeed:360},bu),xu=l.e({deceleration:1e3,maxSpeed:90},bu);class _d{constructor(s){this._map=s,this.clear()}clear(){this._inertiaBuffer=[]}record(s){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:E.now(),settings:s})}_drainInertiaBuffer(){const s=this._inertiaBuffer,d=E.now();for(;s.length>0&&d-s[0].time>160;)s.shift()}_onMoveEnd(s){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const d={zoom:0,bearing:0,pitch:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:x}of this._inertiaBuffer)d.zoom+=x.zoomDelta||0,d.bearing+=x.bearingDelta||0,d.pitch+=x.pitchDelta||0,x.panDelta&&d.pan._add(x.panDelta),x.around&&(d.around=x.around),x.pinchAround&&(d.pinchAround=x.pinchAround);const m=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,y={};if(d.pan.mag()){const x=Yl(d.pan.mag(),m,l.e({},yd,s||{}));y.offset=d.pan.mult(x.amount/d.pan.mag()),y.center=this._map.transform.center,Zl(y,x)}if(d.zoom){const x=Yl(d.zoom,m,w_);y.zoom=this._map.transform.zoom+x.amount,Zl(y,x)}if(d.bearing){const x=Yl(d.bearing,m,_m);y.bearing=this._map.transform.bearing+l.ac(x.amount,-179,179),Zl(y,x)}if(d.pitch){const x=Yl(d.pitch,m,xu);y.pitch=this._map.transform.pitch+x.amount,Zl(y,x)}if(y.zoom||y.bearing){const x=d.pinchAround===void 0?d.around:d.pinchAround;y.around=x?this._map.unproject(x):this._map.getCenter()}return this.clear(),l.e(y,{noMoveStart:!0})}}function Zl(v,s){(!v.duration||v.duration<s.duration)&&(v.duration=s.duration,v.easing=s.easing)}function Yl(v,s,d){const{maxSpeed:m,linearity:y,deceleration:x}=d,M=l.ac(v*y/(s/1e3),-m,m),P=Math.abs(M)/(x*y);return{easing:d.easing,duration:1e3*P,amount:M*(P/2)}}class Oi extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m,y={}){const x=C.mousePos(d.getCanvas(),m),M=d.unproject(x);super(s,l.e({point:x,lngLat:M,originalEvent:m},y)),this._defaultPrevented=!1,this.target=d}}class Zo extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m){const y=s==="touchend"?m.changedTouches:m.touches,x=C.touchPos(d.getCanvasContainer(),y),M=x.map(O=>d.unproject(O)),P=x.reduce((O,z,V,F)=>O.add(z.div(F.length)),new l.P(0,0));super(s,{points:x,point:P,lngLats:M,lngLat:d.unproject(P),originalEvent:m}),this._defaultPrevented=!1}}class bm extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m){super(s,{originalEvent:m}),this._defaultPrevented=!1}}class xm{constructor(s,d){this._map=s,this._clickTolerance=d.clickTolerance}reset(){delete this._mousedownPos}wheel(s){return this._firePreventable(new bm(s.type,this._map,s))}mousedown(s,d){return this._mousedownPos=d,this._firePreventable(new Oi(s.type,this._map,s))}mouseup(s){this._map.fire(new Oi(s.type,this._map,s))}click(s,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||this._map.fire(new Oi(s.type,this._map,s))}dblclick(s){return this._firePreventable(new Oi(s.type,this._map,s))}mouseover(s){this._map.fire(new Oi(s.type,this._map,s))}mouseout(s){this._map.fire(new Oi(s.type,this._map,s))}touchstart(s){return this._firePreventable(new Zo(s.type,this._map,s))}touchmove(s){this._map.fire(new Zo(s.type,this._map,s))}touchend(s){this._map.fire(new Zo(s.type,this._map,s))}touchcancel(s){this._map.fire(new Zo(s.type,this._map,s))}_firePreventable(s){if(this._map.fire(s),s.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Qn{constructor(s){this._map=s}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(s){this._map.fire(new Oi(s.type,this._map,s))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(s){this._delayContextMenu?this._contextMenuEvent=s:this._ignoreContextMenu||this._map.fire(new Oi(s.type,this._map,s)),this._map.listens("contextmenu")&&s.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ts{constructor(s){this._map=s}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(s){return this.transform.pointLocation(l.P.convert(s),this._map.terrain)}}class _r{constructor(s,d){this._map=s,this._tr=new ts(s),this._el=s.getCanvasContainer(),this._container=s.getContainer(),this._clickTolerance=d.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(s,d){this.isEnabled()&&s.shiftKey&&s.button===0&&(C.disableDrag(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(s,d){if(!this._active)return;const m=d;if(this._lastPos.equals(m)||!this._box&&m.dist(this._startPos)<this._clickTolerance)return;const y=this._startPos;this._lastPos=m,this._box||(this._box=C.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",s));const x=Math.min(y.x,m.x),M=Math.max(y.x,m.x),P=Math.min(y.y,m.y),O=Math.max(y.y,m.y);C.setTransform(this._box,`translate(${x}px,${P}px)`),this._box.style.width=M-x+"px",this._box.style.height=O-P+"px"}mouseupWindow(s,d){if(!this._active||s.button!==0)return;const m=this._startPos,y=d;if(this.reset(),C.suppressClick(),m.x!==y.x||m.y!==y.y)return this._map.fire(new l.k("boxzoomend",{originalEvent:s})),{cameraAnimation:x=>x.fitScreenCoordinates(m,y,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",s)}keydown(s){this._active&&s.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",s))}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(s,d){return this._map.fire(new l.k(s,{originalEvent:d}))}}function Xl(v,s){if(v.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${v.length}, points ${s.length}`);const d={};for(let m=0;m<v.length;m++)d[v[m].identifier]=s[m];return d}class bd{constructor(s){this.reset(),this.numTouches=s.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(s,d,m){(this.centroid||m.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=s.timeStamp),m.length===this.numTouches&&(this.centroid=function(y){const x=new l.P(0,0);for(const M of y)x._add(M);return x.div(y.length)}(d),this.touches=Xl(m,d)))}touchmove(s,d,m){if(this.aborted||!this.centroid)return;const y=Xl(m,d);for(const x in this.touches){const M=y[x];(!M||M.dist(this.touches[x])>30)&&(this.aborted=!0)}}touchend(s,d,m){if((!this.centroid||s.timeStamp-this.startTime>500)&&(this.aborted=!0),m.length===0){const y=!this.aborted&&this.centroid;if(this.reset(),y)return y}}}class vu{constructor(s){this.singleTap=new bd(s),this.numTaps=s.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(s,d,m){this.singleTap.touchstart(s,d,m)}touchmove(s,d,m){this.singleTap.touchmove(s,d,m)}touchend(s,d,m){const y=this.singleTap.touchend(s,d,m);if(y){const x=s.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(y)<30;if(x&&M||this.reset(),this.count++,this.lastTime=s.timeStamp,this.lastTap=y,this.count===this.numTaps)return this.reset(),y}}}class Ua{constructor(s){this._tr=new ts(s),this._zoomIn=new vu({numTouches:1,numTaps:2}),this._zoomOut=new vu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(s,d,m){this._zoomIn.touchstart(s,d,m),this._zoomOut.touchstart(s,d,m)}touchmove(s,d,m){this._zoomIn.touchmove(s,d,m),this._zoomOut.touchmove(s,d,m)}touchend(s,d,m){const y=this._zoomIn.touchend(s,d,m),x=this._zoomOut.touchend(s,d,m),M=this._tr;return y?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(y)},{originalEvent:s})}):x?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(x)},{originalEvent:s})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qs{constructor(s){this._enabled=!!s.enable,this._moveStateManager=s.moveStateManager,this._clickTolerance=s.clickTolerance||1,this._moveFunction=s.move,this._activateOnStart=!!s.activateOnStart,s.assignEvents(this),this.reset()}reset(s){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(s)}_move(...s){const d=this._moveFunction(...s);if(d.bearingDelta||d.pitchDelta||d.around||d.panDelta)return this._active=!0,d}dragStart(s,d){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(s)&&(this._moveStateManager.startMove(s),this._lastPoint=d.length?d[0]:d,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(s,d){if(!this.isEnabled())return;const m=this._lastPoint;if(!m)return;if(s.preventDefault(),!this._moveStateManager.isValidMoveEvent(s))return void this.reset(s);const y=d.length?d[0]:d;return!this._moved&&y.dist(m)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=y,this._move(m,y))}dragEnd(s){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(s)&&(this._moved&&C.suppressClick(),this.reset(s))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const xd={0:1,2:2};class wu{constructor(s){this._correctEvent=s.checkCorrectEvent}startMove(s){const d=C.mouseButton(s);this._eventButton=d}endMove(s){delete this._eventButton}isValidStartEvent(s){return this._correctEvent(s)}isValidMoveEvent(s){return!function(d,m){const y=xd[m];return d.buttons===void 0||(d.buttons&y)!==y}(s,this._eventButton)}isValidEndEvent(s){return C.mouseButton(s)===this._eventButton}}class vd{constructor(){this._firstTouch=void 0}_isOneFingerTouch(s){return s.targetTouches.length===1}_isSameTouchEvent(s){return s.targetTouches[0].identifier===this._firstTouch}startMove(s){this._firstTouch=s.targetTouches[0].identifier}endMove(s){delete this._firstTouch}isValidStartEvent(s){return this._isOneFingerTouch(s)}isValidMoveEvent(s){return this._isOneFingerTouch(s)&&this._isSameTouchEvent(s)}isValidEndEvent(s){return this._isOneFingerTouch(s)&&this._isSameTouchEvent(s)}}const ku=v=>{v.mousedown=v.dragStart,v.mousemoveWindow=v.dragMove,v.mouseup=v.dragEnd,v.contextmenu=s=>{s.preventDefault()}},wd=({enable:v,clickTolerance:s,bearingDegreesPerPixelMoved:d=.8})=>{const m=new wu({checkCorrectEvent:y=>C.mouseButton(y)===0&&y.ctrlKey||C.mouseButton(y)===2});return new qs({clickTolerance:s,move:(y,x)=>({bearingDelta:(x.x-y.x)*d}),moveStateManager:m,enable:v,assignEvents:ku})},kd=({enable:v,clickTolerance:s,pitchDegreesPerPixelMoved:d=-.5})=>{const m=new wu({checkCorrectEvent:y=>C.mouseButton(y)===0&&y.ctrlKey||C.mouseButton(y)===2});return new qs({clickTolerance:s,move:(y,x)=>({pitchDelta:(x.y-y.y)*d}),moveStateManager:m,enable:v,assignEvents:ku})};class Yo{constructor(s,d){this._clickTolerance=s.clickTolerance||1,this._map=d,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0)}_shouldBePrevented(s){return s<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(s,d,m){return this._calculateTransform(s,d,m)}touchmove(s,d,m){if(this._active){if(!this._shouldBePrevented(m.length))return s.preventDefault(),this._calculateTransform(s,d,m);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",s)}}touchend(s,d,m){this._calculateTransform(s,d,m),this._active&&this._shouldBePrevented(m.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(s,d,m){m.length>0&&(this._active=!0);const y=Xl(m,d),x=new l.P(0,0),M=new l.P(0,0);let P=0;for(const z in y){const V=y[z],F=this._touches[z];F&&(x._add(V),M._add(V.sub(F)),P++,y[z]=V)}if(this._touches=y,this._shouldBePrevented(P)||!M.mag())return;const O=M.div(P);return this._sum._add(O),this._sum.mag()<this._clickTolerance?void 0:{around:x.div(P),panDelta:O}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Su{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(s,d,m){this._firstTwoTouches||m.length<2||(this._firstTwoTouches=[m[0].identifier,m[1].identifier],this._start([d[0],d[1]]))}touchmove(s,d,m){if(!this._firstTwoTouches)return;s.preventDefault();const[y,x]=this._firstTwoTouches,M=Kl(m,d,y),P=Kl(m,d,x);if(!M||!P)return;const O=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],O,s)}touchend(s,d,m){if(!this._firstTwoTouches)return;const[y,x]=this._firstTwoTouches,M=Kl(m,d,y),P=Kl(m,d,x);M&&P||(this._active&&C.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(s){this._enabled=!0,this._aroundCenter=!!s&&s.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Kl(v,s,d){for(let m=0;m<v.length;m++)if(v[m].identifier===d)return s[m]}function Sd(v,s){return Math.log(v/s)/Math.LN2}class Ed extends Su{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(s){this._startDistance=this._distance=s[0].dist(s[1])}_move(s,d){const m=this._distance;if(this._distance=s[0].dist(s[1]),this._active||!(Math.abs(Sd(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Sd(this._distance,m),pinchAround:d}}}function Cd(v,s){return 180*v.angleWith(s)/Math.PI}class Td extends Su{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(s){this._startVector=this._vector=s[0].sub(s[1]),this._minDiameter=s[0].dist(s[1])}_move(s,d,m){const y=this._vector;if(this._vector=s[0].sub(s[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Cd(this._vector,y),pinchAround:d}}_isBelowThreshold(s){this._minDiameter=Math.min(this._minDiameter,s.mag());const d=25/(Math.PI*this._minDiameter)*360,m=Cd(s,this._startVector);return Math.abs(m)<d}}function Eu(v){return Math.abs(v.y)>Math.abs(v.x)}class Ha extends Su{constructor(s){super(),this._currentTouchCount=0,this._map=s}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(s,d,m){super.touchstart(s,d,m),this._currentTouchCount=m.length}_start(s){this._lastPoints=s,Eu(s[0].sub(s[1]))&&(this._valid=!1)}_move(s,d,m){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const y=s[0].sub(this._lastPoints[0]),x=s[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(y,x,m.timeStamp),this._valid?(this._lastPoints=s,this._active=!0,{pitchDelta:(y.y+x.y)/2*-.5}):void 0}gestureBeginsVertically(s,d,m){if(this._valid!==void 0)return this._valid;const y=s.mag()>=2,x=d.mag()>=2;if(!y&&!x)return;if(!y||!x)return this._firstMove===void 0&&(this._firstMove=m),m-this._firstMove<100&&void 0;const M=s.y>0==d.y>0;return Eu(s)&&Eu(d)&&M}}const vm={panStep:100,bearingStep:15,pitchStep:10};class Lr{constructor(s){this._tr=new ts(s);const d=vm;this._panStep=d.panStep,this._bearingStep=d.bearingStep,this._pitchStep=d.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(s){if(s.altKey||s.ctrlKey||s.metaKey)return;let d=0,m=0,y=0,x=0,M=0;switch(s.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:s.shiftKey?m=-1:(s.preventDefault(),x=-1);break;case 39:s.shiftKey?m=1:(s.preventDefault(),x=1);break;case 38:s.shiftKey?y=1:(s.preventDefault(),M=-1);break;case 40:s.shiftKey?y=-1:(s.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(m=0,y=0),{cameraAnimation:P=>{const O=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:As,zoom:d?Math.round(O.zoom)+d*(s.shiftKey?2:1):O.zoom,bearing:O.bearing+m*this._bearingStep,pitch:O.pitch+y*this._pitchStep,offset:[-x*this._panStep,-M*this._panStep],center:O.center},{originalEvent:s})}}}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 As(v){return v*(2-v)}const Md=4.000244140625;class ns{constructor(s,d){this._onTimeout=m=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(m)},this._map=s,this._tr=new ts(s),this._triggerRenderFrame=d,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(s){this._defaultZoomRate=s}setWheelZoomRate(s){this._wheelZoomRate=s}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(s){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!s&&s.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(s){return!!this._map.cooperativeGestures.isEnabled()&&!(s.ctrlKey||this._map.cooperativeGestures.isBypassed(s))}wheel(s){if(!this.isEnabled())return;if(this._shouldBePrevented(s))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",s);let d=s.deltaMode===WheelEvent.DOM_DELTA_LINE?40*s.deltaY:s.deltaY;const m=E.now(),y=m-(this._lastWheelEventTime||0);this._lastWheelEventTime=m,d!==0&&d%Md==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":y>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,s)):this._type||(this._type=Math.abs(y*d)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,d+=this._lastValue)),s.shiftKey&&d&&(d/=4),this._type&&(this._lastWheelEvent=s,this._delta-=d,this._active||this._start(s)),s.preventDefault()}_start(s){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const d=C.mousePos(this._map.getCanvas(),s),m=this._tr;this._around=d.y>m.transform.height/2-m.transform.getHorizon()?l.N.convert(this._aroundCenter?m.center:m.unproject(d)):l.N.convert(m.center),this._aroundPoint=m.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const s=this._tr.transform;if(this._delta!==0){const O=this._type==="wheel"&&Math.abs(this._delta)>Md?this._wheelZoomRate:this._defaultZoomRate;let z=2/(1+Math.exp(-Math.abs(this._delta*O)));this._delta<0&&z!==0&&(z=1/z);const V=typeof this._targetZoom=="number"?s.zoomScale(this._targetZoom):s.scale;this._targetZoom=Math.min(s.maxZoom,Math.max(s.minZoom,s.scaleZoom(V*z))),this._type==="wheel"&&(this._startZoom=s.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const d=typeof this._targetZoom=="number"?this._targetZoom:s.zoom,m=this._startZoom,y=this._easing;let x,M=!1;const P=E.now()-this._lastWheelEventTime;if(this._type==="wheel"&&m&&y&&P){const O=Math.min(P/200,1),z=y(O);x=l.y.number(m,d,z),O<1?this._frameId||(this._frameId=!0):M=!0}else x=d,M=!0;return this._active=!0,M&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!M,zoomDelta:x-s.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(s){let d=l.b9;if(this._prevEase){const m=this._prevEase,y=(E.now()-m.start)/m.duration,x=m.easing(y+.01)-m.easing(y),M=.27/Math.sqrt(x*x+1e-4)*.01,P=Math.sqrt(.0729-M*M);d=l.b8(M,P,.25,1)}return this._prevEase={start:E.now(),duration:s,easing:d},d}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Xo{constructor(s,d){this._clickZoom=s,this._tapZoom=d}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 k_{constructor(s){this._tr=new ts(s),this.reset()}reset(){this._active=!1}dblclick(s,d){return s.preventDefault(),{cameraAnimation:m=>{m.easeTo({duration:300,zoom:this._tr.zoom+(s.shiftKey?-1:1),around:this._tr.unproject(d)},{originalEvent:s})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class S_{constructor(){this._tap=new vu({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(s,d,m){if(!this._swipePoint)if(this._tapTime){const y=d[0],x=s.timeStamp-this._tapTime<500,M=this._tapPoint.dist(y)<30;x&&M?m.length>0&&(this._swipePoint=y,this._swipeTouch=m[0].identifier):this.reset()}else this._tap.touchstart(s,d,m)}touchmove(s,d,m){if(this._tapTime){if(this._swipePoint){if(m[0].identifier!==this._swipeTouch)return;const y=d[0],x=y.y-this._swipePoint.y;return this._swipePoint=y,s.preventDefault(),this._active=!0,{zoomDelta:x/128}}}else this._tap.touchmove(s,d,m)}touchend(s,d,m){if(this._tapTime)this._swipePoint&&m.length===0&&this.reset();else{const y=this._tap.touchend(s,d,m);y&&(this._tapTime=s.timeStamp,this._tapPoint=y)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wm{constructor(s,d,m){this._el=s,this._mousePan=d,this._touchPan=m}enable(s){this._inertiaOptions=s||{},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 km{constructor(s,d,m){this._pitchWithRotate=s.pitchWithRotate,this._mouseRotate=d,this._mousePitch=m}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 Ad{constructor(s,d,m,y){this._el=s,this._touchZoom=d,this._touchRotate=m,this._tapDragZoom=y,this._rotationDisabled=!1,this._enabled=!0}enable(s){this._touchZoom.enable(s),this._rotationDisabled||this._touchRotate.enable(s),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 qa{constructor(s,d){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=s,this._options=d,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const s=this._map.getCanvasContainer();s.classList.add("maplibregl-cooperative-gestures"),this._container=C.create("div","maplibregl-cooperative-gesture-screen",s);let d=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(d=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const m=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),y=document.createElement("div");y.className="maplibregl-desktop-message",y.textContent=d,this._container.appendChild(y);const x=document.createElement("div");x.className="maplibregl-mobile-message",x.textContent=m,this._container.appendChild(x),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(s){return s[this._bypassKey]}notifyGestureBlocked(s,d){this._enabled&&(this._map.fire(new l.k("cooperativegestureprevented",{gestureType:s,originalEvent:d})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Vr=v=>v.zoom||v.drag||v.pitch||v.rotate;class lt extends l.k{}function Cu(v){return v.panDelta&&v.panDelta.mag()||v.zoomDelta||v.bearingDelta||v.pitchDelta}class Pd{constructor(s,d){this.handleWindowEvent=y=>{this.handleEvent(y,`${y.type}Window`)},this.handleEvent=(y,x)=>{if(y.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=y.type==="renderFrame"?void 0:y,P={needsRenderFrame:!1},O={},z={},V=y.touches,F=V?this._getMapTouches(V):void 0,W=F?C.touchPos(this._map.getCanvas(),F):C.mousePos(this._map.getCanvas(),y);for(const{handlerName:se,handler:le,allowed:ce}of this._handlers){if(!le.isEnabled())continue;let he;this._blockedByActive(z,ce,se)?le.reset():le[x||y.type]&&(he=le[x||y.type](y,W,F),this.mergeHandlerResult(P,O,he,se,M),he&&he.needsRenderFrame&&this._triggerRenderFrame()),(he||le.isActive())&&(z[se]=le)}const J={};for(const se in this._previousActiveHandlers)z[se]||(J[se]=M);this._previousActiveHandlers=z,(Object.keys(J).length||Cu(P))&&(this._changes.push([P,O,J]),this._triggerRenderFrame()),(Object.keys(z).length||Cu(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ee}=P;ee&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ee(this._map))},this._map=s,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new _d(s),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(d);const m=this._el;this._listeners=[[m,"touchstart",{passive:!0}],[m,"touchmove",{passive:!1}],[m,"touchend",void 0],[m,"touchcancel",void 0],[m,"mousedown",void 0],[m,"mousemove",void 0],[m,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[m,"mouseover",void 0],[m,"mouseout",void 0],[m,"dblclick",void 0],[m,"click",void 0],[m,"keydown",{capture:!1}],[m,"keyup",void 0],[m,"wheel",{passive:!1}],[m,"contextmenu",void 0],[window,"blur",void 0]];for(const[y,x,M]of this._listeners)C.addEventListener(y,x,y===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[s,d,m]of this._listeners)C.removeEventListener(s,d,s===document?this.handleWindowEvent:this.handleEvent,m)}_addDefaultHandlers(s){const d=this._map,m=d.getCanvasContainer();this._add("mapEvent",new xm(d,s));const y=d.boxZoom=new _r(d,s);this._add("boxZoom",y),s.interactive&&s.boxZoom&&y.enable();const x=d.cooperativeGestures=new qa(d,s.cooperativeGestures);this._add("cooperativeGestures",x),s.cooperativeGestures&&x.enable();const M=new Ua(d),P=new k_(d);d.doubleClickZoom=new Xo(P,M),this._add("tapZoom",M),this._add("clickZoom",P),s.interactive&&s.doubleClickZoom&&d.doubleClickZoom.enable();const O=new S_;this._add("tapDragZoom",O);const z=d.touchPitch=new Ha(d);this._add("touchPitch",z),s.interactive&&s.touchPitch&&d.touchPitch.enable(s.touchPitch);const V=wd(s),F=kd(s);d.dragRotate=new km(s,V,F),this._add("mouseRotate",V,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),s.interactive&&s.dragRotate&&d.dragRotate.enable();const W=(({enable:he,clickTolerance:ne})=>{const me=new wu({checkCorrectEvent:ge=>C.mouseButton(ge)===0&&!ge.ctrlKey});return new qs({clickTolerance:ne,move:(ge,xe)=>({around:xe,panDelta:xe.sub(ge)}),activateOnStart:!0,moveStateManager:me,enable:he,assignEvents:ku})})(s),J=new Yo(s,d);d.dragPan=new wm(m,W,J),this._add("mousePan",W),this._add("touchPan",J,["touchZoom","touchRotate"]),s.interactive&&s.dragPan&&d.dragPan.enable(s.dragPan);const ee=new Td,se=new Ed;d.touchZoomRotate=new Ad(m,se,ee,O),this._add("touchRotate",ee,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),s.interactive&&s.touchZoomRotate&&d.touchZoomRotate.enable(s.touchZoomRotate);const le=d.scrollZoom=new ns(d,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),s.interactive&&s.scrollZoom&&d.scrollZoom.enable(s.scrollZoom);const ce=d.keyboard=new Lr(d);this._add("keyboard",ce),s.interactive&&s.keyboard&&d.keyboard.enable(),this._add("blockableMapEvent",new Qn(d))}_add(s,d,m){this._handlers.push({handlerName:s,handler:d,allowed:m}),this._handlersById[s]=d}stop(s){if(!this._updatingCamera){for(const{handler:d}of this._handlers)d.reset();this._inertia.clear(),this._fireEvents({},{},s),this._changes=[]}}isActive(){for(const{handler:s}of this._handlers)if(s.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Vr(this._eventsInProgress)||this.isZooming()}_blockedByActive(s,d,m){for(const y in s)if(y!==m&&(!d||d.indexOf(y)<0))return!0;return!1}_getMapTouches(s){const d=[];for(const m of s)this._el.contains(m.target)&&d.push(m);return d}mergeHandlerResult(s,d,m,y,x){if(!m)return;l.e(s,m);const M={handlerName:y,originalEvent:m.originalEvent||x};m.zoomDelta!==void 0&&(d.zoom=M),m.panDelta!==void 0&&(d.drag=M),m.pitchDelta!==void 0&&(d.pitch=M),m.bearingDelta!==void 0&&(d.rotate=M)}_applyChanges(){const s={},d={},m={};for(const[y,x,M]of this._changes)y.panDelta&&(s.panDelta=(s.panDelta||new l.P(0,0))._add(y.panDelta)),y.zoomDelta&&(s.zoomDelta=(s.zoomDelta||0)+y.zoomDelta),y.bearingDelta&&(s.bearingDelta=(s.bearingDelta||0)+y.bearingDelta),y.pitchDelta&&(s.pitchDelta=(s.pitchDelta||0)+y.pitchDelta),y.around!==void 0&&(s.around=y.around),y.pinchAround!==void 0&&(s.pinchAround=y.pinchAround),y.noInertia&&(s.noInertia=y.noInertia),l.e(d,x),l.e(m,M);this._updateMapTransform(s,d,m),this._changes=[]}_updateMapTransform(s,d,m){const y=this._map,x=y._getTransformForUpdate(),M=y.terrain;if(!(Cu(s)||M&&this._terrainMovement))return this._fireEvents(d,m,!0);let{panDelta:P,zoomDelta:O,bearingDelta:z,pitchDelta:V,around:F,pinchAround:W}=s;W!==void 0&&(F=W),y._stop(!0),F=F||y.transform.centerPoint;const J=x.pointLocation(P?F.sub(P):F);z&&(x.bearing+=z),V&&(x.pitch+=V),O&&(x.zoom+=O),M?this._terrainMovement||!d.drag&&!d.zoom?d.drag&&this._terrainMovement?x.center=x.pointLocation(x.centerPoint.sub(P)):x.setLocationAtPoint(J,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,x.setLocationAtPoint(J,F)):x.setLocationAtPoint(J,F),y._applyUpdatedTransform(x),this._map._update(),s.noInertia||this._inertia.record(s),this._fireEvents(d,m,!0)}_fireEvents(s,d,m){const y=Vr(this._eventsInProgress),x=Vr(s),M={};for(const F in s){const{originalEvent:W}=s[F];this._eventsInProgress[F]||(M[`${F}start`]=W),this._eventsInProgress[F]=s[F]}!y&&x&&this._fireEvent("movestart",x.originalEvent);for(const F in M)this._fireEvent(F,M[F]);x&&this._fireEvent("move",x.originalEvent);for(const F in s){const{originalEvent:W}=s[F];this._fireEvent(F,W)}const P={};let O;for(const F in this._eventsInProgress){const{handlerName:W,originalEvent:J}=this._eventsInProgress[F];this._handlersById[W].isActive()||(delete this._eventsInProgress[F],O=d[W]||J,P[`${F}end`]=O)}for(const F in P)this._fireEvent(F,P[F]);const z=Vr(this._eventsInProgress),V=(y||x)&&!z;if(V&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(m&&V){this._updatingCamera=!0;const F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),W=J=>J!==0&&-this._bearingSnap<J&&J<this._bearingSnap;!F||!F.essential&&E.prefersReducedMotion?(this._map.fire(new l.k("moveend",{originalEvent:O})),W(this._map.getBearing())&&this._map.resetNorth()):(W(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:O})),this._updatingCamera=!1}}_fireEvent(s,d){this._map.fire(new l.k(s,d?{originalEvent:d}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(s=>{delete this._frameId,this.handleEvent(new lt("renderFrame",{timeStamp:s})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Sm extends l.E{constructor(s,d){super(),this._renderFrameCallback=()=>{const m=Math.min((E.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(m)),m<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=s,this._bearingSnap=d.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new l.N(this.transform.center.lng,this.transform.center.lat)}setCenter(s,d){return this.jumpTo({center:s},d)}panBy(s,d,m){return s=l.P.convert(s).mult(-1),this.panTo(this.transform.center,l.e({offset:s},d),m)}panTo(s,d,m){return this.easeTo(l.e({center:s},d),m)}getZoom(){return this.transform.zoom}setZoom(s,d){return this.jumpTo({zoom:s},d),this}zoomTo(s,d,m){return this.easeTo(l.e({zoom:s},d),m)}zoomIn(s,d){return this.zoomTo(this.getZoom()+1,s,d),this}zoomOut(s,d){return this.zoomTo(this.getZoom()-1,s,d),this}getBearing(){return this.transform.bearing}setBearing(s,d){return this.jumpTo({bearing:s},d),this}getPadding(){return this.transform.padding}setPadding(s,d){return this.jumpTo({padding:s},d),this}rotateTo(s,d,m){return this.easeTo(l.e({bearing:s},d),m)}resetNorth(s,d){return this.rotateTo(0,l.e({duration:1e3},s),d),this}resetNorthPitch(s,d){return this.easeTo(l.e({bearing:0,pitch:0,duration:1e3},s),d),this}snapToNorth(s,d){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(s,d):this}getPitch(){return this.transform.pitch}setPitch(s,d){return this.jumpTo({pitch:s},d),this}cameraForBounds(s,d){s=ve.convert(s).adjustAntiMeridian();const m=d&&d.bearing||0;return this._cameraForBoxAndBearing(s.getNorthWest(),s.getSouthEast(),m,d)}_cameraForBoxAndBearing(s,d,m,y){const x={top:0,bottom:0,right:0,left:0};if(typeof(y=l.e({padding:x,offset:[0,0],maxZoom:this.transform.maxZoom},y)).padding=="number"){const Ze=y.padding;y.padding={top:Ze,bottom:Ze,right:Ze,left:Ze}}y.padding=l.e(x,y.padding);const M=this.transform,P=M.padding,O=new ve(s,d),z=M.project(O.getNorthWest()),V=M.project(O.getNorthEast()),F=M.project(O.getSouthEast()),W=M.project(O.getSouthWest()),J=l.ba(-m),ee=z.rotate(J),se=V.rotate(J),le=F.rotate(J),ce=W.rotate(J),he=new l.P(Math.max(ee.x,se.x,ce.x,le.x),Math.max(ee.y,se.y,ce.y,le.y)),ne=new l.P(Math.min(ee.x,se.x,ce.x,le.x),Math.min(ee.y,se.y,ce.y,le.y)),me=he.sub(ne),ge=(M.width-(P.left+P.right+y.padding.left+y.padding.right))/me.x,xe=(M.height-(P.top+P.bottom+y.padding.top+y.padding.bottom))/me.y;if(xe<0||ge<0)return void l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const De=Math.min(M.scaleZoom(M.scale*Math.min(ge,xe)),y.maxZoom),Ve=l.P.convert(y.offset),Je=new l.P((y.padding.left-y.padding.right)/2,(y.padding.top-y.padding.bottom)/2).rotate(l.ba(m)),st=Ve.add(Je).mult(M.scale/M.zoomScale(De));return{center:M.unproject(z.add(F).div(2).sub(st)),zoom:De,bearing:m}}fitBounds(s,d,m){return this._fitInternal(this.cameraForBounds(s,d),d,m)}fitScreenCoordinates(s,d,m,y,x){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(l.P.convert(s)),this.transform.pointLocation(l.P.convert(d)),m,y),y,x)}_fitInternal(s,d,m){return s?(delete(d=l.e(s,d)).padding,d.linear?this.easeTo(d,m):this.flyTo(d,m)):this}jumpTo(s,d){this.stop();const m=this._getTransformForUpdate();let y=!1,x=!1,M=!1;return"zoom"in s&&m.zoom!==+s.zoom&&(y=!0,m.zoom=+s.zoom),s.center!==void 0&&(m.center=l.N.convert(s.center)),"bearing"in s&&m.bearing!==+s.bearing&&(x=!0,m.bearing=+s.bearing),"pitch"in s&&m.pitch!==+s.pitch&&(M=!0,m.pitch=+s.pitch),s.padding==null||m.isPaddingEqual(s.padding)||(m.padding=s.padding),this._applyUpdatedTransform(m),this.fire(new l.k("movestart",d)).fire(new l.k("move",d)),y&&this.fire(new l.k("zoomstart",d)).fire(new l.k("zoom",d)).fire(new l.k("zoomend",d)),x&&this.fire(new l.k("rotatestart",d)).fire(new l.k("rotate",d)).fire(new l.k("rotateend",d)),M&&this.fire(new l.k("pitchstart",d)).fire(new l.k("pitch",d)).fire(new l.k("pitchend",d)),this.fire(new l.k("moveend",d))}calculateCameraOptionsFromTo(s,d,m,y=0){const x=l.Z.fromLngLat(s,d),M=l.Z.fromLngLat(m,y),P=M.x-x.x,O=M.y-x.y,z=M.z-x.z,V=Math.hypot(P,O,z);if(V===0)throw new Error("Can't calculate camera options with same From and To");const F=Math.hypot(P,O),W=this.transform.scaleZoom(this.transform.cameraToCenterDistance/V/this.transform.tileSize),J=180*Math.atan2(P,-O)/Math.PI;let ee=180*Math.acos(F/V)/Math.PI;return ee=z<0?90-ee:90+ee,{center:M.toLngLat(),zoom:W,pitch:ee,bearing:J}}easeTo(s,d){var m;this._stop(!1,s.easeId),((s=l.e({offset:[0,0],duration:500,easing:l.b9},s)).animate===!1||!s.essential&&E.prefersReducedMotion)&&(s.duration=0);const y=this._getTransformForUpdate(),x=y.zoom,M=y.bearing,P=y.pitch,O=y.padding,z="bearing"in s?this._normalizeBearing(s.bearing,M):M,V="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:y.padding,W=l.P.convert(s.offset);let J=y.centerPoint.add(W);const ee=y.pointLocation(J),{center:se,zoom:le}=y.getConstrained(l.N.convert(s.center||ee),(m=s.zoom)!==null&&m!==void 0?m:x);this._normalizeCenter(se,y);const ce=y.project(ee),he=y.project(se).sub(ce),ne=y.zoomScale(le-x);let me,ge;s.around&&(me=l.N.convert(s.around),ge=y.locationPoint(me));const xe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==x,this._rotating=this._rotating||M!==z,this._pitching=this._pitching||V!==P,this._padding=!y.isPaddingEqual(F),this._easeId=s.easeId,this._prepareEase(d,s.noMoveStart,xe),this.terrain&&this._prepareElevation(se),this._ease(De=>{if(this._zooming&&(y.zoom=l.y.number(x,le,De)),this._rotating&&(y.bearing=l.y.number(M,z,De)),this._pitching&&(y.pitch=l.y.number(P,V,De)),this._padding&&(y.interpolatePadding(O,F,De),J=y.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(De),me)y.setLocationAtPoint(me,ge);else{const Ve=y.zoomScale(y.zoom-x),Je=le>x?Math.min(2,ne):Math.max(.5,ne),st=Math.pow(Je,1-De),Ze=y.unproject(ce.add(he.mult(De*st)).mult(Ve));y.setLocationAtPoint(y.renderWorldCopies?Ze.wrap():Ze,J)}this._applyUpdatedTransform(y),this._fireMoveEvents(d)},De=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d,De)},s),this}_prepareEase(s,d,m={}){this._moving=!0,d||m.moving||this.fire(new l.k("movestart",s)),this._zooming&&!m.zooming&&this.fire(new l.k("zoomstart",s)),this._rotating&&!m.rotating&&this.fire(new l.k("rotatestart",s)),this._pitching&&!m.pitching&&this.fire(new l.k("pitchstart",s))}_prepareElevation(s){this._elevationCenter=s,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(s,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(s){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const d=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(s<1&&d!==this._elevationTarget){const m=this._elevationTarget-this._elevationStart;this._elevationStart+=s*(m-(d-(m*s+this._elevationStart))/(1-s)),this._elevationTarget=d}this.transform.elevation=l.y.number(this._elevationStart,this._elevationTarget,s)}_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(s){const d=s.getCameraPosition(),m=this.terrain.getElevationForLngLatZoom(d.lngLat,s.zoom);if(d.altitude<m){const y=this.calculateCameraOptionsFromTo(d.lngLat,m,s.center,s.elevation);return{pitch:y.pitch,zoom:y.zoom}}return{}}_applyUpdatedTransform(s){const d=[];if(this.terrain&&d.push(y=>this._elevateCameraIfInsideTerrain(y)),this.transformCameraUpdate&&d.push(y=>this.transformCameraUpdate(y)),!d.length)return;const m=s.clone();for(const y of d){const x=m.clone(),{center:M,zoom:P,pitch:O,bearing:z,elevation:V}=y(x);M&&(x.center=M),P!==void 0&&(x.zoom=P),O!==void 0&&(x.pitch=O),z!==void 0&&(x.bearing=z),V!==void 0&&(x.elevation=V),m.apply(x)}this.transform.apply(m)}_fireMoveEvents(s){this.fire(new l.k("move",s)),this._zooming&&this.fire(new l.k("zoom",s)),this._rotating&&this.fire(new l.k("rotate",s)),this._pitching&&this.fire(new l.k("pitch",s))}_afterEase(s,d){if(this._easeId&&d&&this._easeId===d)return;delete this._easeId;const m=this._zooming,y=this._rotating,x=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,m&&this.fire(new l.k("zoomend",s)),y&&this.fire(new l.k("rotateend",s)),x&&this.fire(new l.k("pitchend",s)),this.fire(new l.k("moveend",s))}flyTo(s,d){var m;if(!s.essential&&E.prefersReducedMotion){const nt=l.M(s,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,d)}this.stop(),s=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.b9},s);const y=this._getTransformForUpdate(),x=y.zoom,M=y.bearing,P=y.pitch,O=y.padding,z="bearing"in s?this._normalizeBearing(s.bearing,M):M,V="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:y.padding,W=l.P.convert(s.offset);let J=y.centerPoint.add(W);const ee=y.pointLocation(J),{center:se,zoom:le}=y.getConstrained(l.N.convert(s.center||ee),(m=s.zoom)!==null&&m!==void 0?m:x);this._normalizeCenter(se,y);const ce=y.zoomScale(le-x),he=y.project(ee),ne=y.project(se).sub(he);let me=s.curve;const ge=Math.max(y.width,y.height),xe=ge/ce,De=ne.mag();if("minZoom"in s){const nt=l.ac(Math.min(s.minZoom,x,le),y.minZoom,y.maxZoom),It=ge/y.zoomScale(nt-x);me=Math.sqrt(It/De*2)}const Ve=me*me;function Je(nt){const It=(xe*xe-ge*ge+(nt?-1:1)*Ve*Ve*De*De)/(2*(nt?xe:ge)*Ve*De);return Math.log(Math.sqrt(It*It+1)-It)}function st(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Ze(nt){return(Math.exp(nt)+Math.exp(-nt))/2}const We=Je(!1);let mt=function(nt){return Ze(We)/Ze(We+me*nt)},Ot=function(nt){return ge*((Ze(We)*(st(It=We+me*nt)/Ze(It))-st(We))/Ve)/De;var It},Xe=(Je(!0)-We)/me;if(Math.abs(De)<1e-6||!isFinite(Xe)){if(Math.abs(ge-xe)<1e-6)return this.easeTo(s,d);const nt=xe<ge?-1:1;Xe=Math.abs(Math.log(xe/ge))/me,Ot=()=>0,mt=It=>Math.exp(nt*me*It)}return s.duration="duration"in s?+s.duration:1e3*Xe/("screenSpeed"in s?+s.screenSpeed/me:+s.speed),s.maxDuration&&s.duration>s.maxDuration&&(s.duration=0),this._zooming=!0,this._rotating=M!==z,this._pitching=V!==P,this._padding=!y.isPaddingEqual(F),this._prepareEase(d,!1),this.terrain&&this._prepareElevation(se),this._ease(nt=>{const It=nt*Xe,Fn=1/mt(It);y.zoom=nt===1?le:x+y.scaleZoom(Fn),this._rotating&&(y.bearing=l.y.number(M,z,nt)),this._pitching&&(y.pitch=l.y.number(P,V,nt)),this._padding&&(y.interpolatePadding(O,F,nt),J=y.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(nt);const $t=nt===1?se:y.unproject(he.add(ne.mult(Ot(It))).mult(Fn));y.setLocationAtPoint(y.renderWorldCopies?$t.wrap():$t,J),this._applyUpdatedTransform(y),this._fireMoveEvents(d)},()=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d)},s),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(s,d){var m;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const y=this._onEaseEnd;delete this._onEaseEnd,y.call(this,d)}return s||(m=this.handlers)===null||m===void 0||m.stop(!1),this}_ease(s,d,m){m.animate===!1||m.duration===0?(s(1),d()):(this._easeStart=E.now(),this._easeOptions=m,this._onEaseFrame=s,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(s,d){s=l.b3(s,-180,180);const m=Math.abs(s-d);return Math.abs(s-360-d)<m&&(s-=360),Math.abs(s+360-d)<m&&(s+=360),s}_normalizeCenter(s,d){if(!d.renderWorldCopies||d.lngRange)return;const m=s.lng-d.center.lng;s.lng+=m>180?-360:m<-180?360:0}queryTerrainElevation(s){return this.terrain?this.terrain.getElevationForLngLatZoom(l.N.convert(s),this.transform.tileZoom)-this.transform.elevation:null}}const Wa={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ga{constructor(s=Wa){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=d=>{!d||d.sourceDataType!=="metadata"&&d.sourceDataType!=="visibility"&&d.dataType!=="style"&&d.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=s}getDefaultPosition(){return"bottom-right"}onAdd(s){return this._map=s,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(s,d){const m=this._map._getUIString(`AttributionControl.${d}`);s.title=m,s.setAttribute("aria-label",m)}_updateAttributions(){if(!this._map.style)return;let s=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?s=s.concat(this.options.customAttribution.map(y=>typeof y!="string"?"":y)):typeof this.options.customAttribution=="string"&&s.push(this.options.customAttribution)),this._map.style.stylesheet){const y=this._map.style.stylesheet;this.styleOwner=y.owner,this.styleId=y.id}const d=this._map.style.sourceCaches;for(const y in d){const x=d[y];if(x.used||x.usedForTerrain){const M=x.getSource();M.attribution&&s.indexOf(M.attribution)<0&&s.push(M.attribution)}}s=s.filter(y=>String(y).trim()),s.sort((y,x)=>y.length-x.length),s=s.filter((y,x)=>{for(let M=x+1;M<s.length;M++)if(s[M].indexOf(y)>=0)return!1;return!0});const m=s.join(" | ");m!==this._attribHTML&&(this._attribHTML=m,s.length?(this._innerContainer.innerHTML=m,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Id{constructor(s={}){this._updateCompact=()=>{const d=this._container.children;if(d.length){const m=d[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&m.classList.add("maplibregl-compact"):m.classList.remove("maplibregl-compact")}},this.options=s}getDefaultPosition(){return"bottom-left"}onAdd(s){this._map=s,this._compact=this.options&&this.options.compact,this._container=C.create("div","maplibregl-ctrl");const d=C.create("a","maplibregl-ctrl-logo");return d.target="_blank",d.rel="noopener nofollow",d.href="https://maplibre.org/",d.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),d.setAttribute("rel","noopener nofollow"),this._container.appendChild(d),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 en{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(s){const d=++this._id;return this._queue.push({callback:s,id:d,cancelled:!1}),d}remove(s){const d=this._currentlyRunning,m=d?this._queue.concat(d):this._queue;for(const y of m)if(y.id===s)return void(y.cancelled=!0)}run(s=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const d=this._currentlyRunning=this._queue;this._queue=[];for(const m of d)if(!m.cancelled&&(m.callback(s),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Dd=l.Y([{name:"a_pos3d",type:"Int16",components:3}]);class E_ extends l.E{constructor(s){super(),this.sourceCache=s,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,s.usedForTerrain=!0,s.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(s,d){this.sourceCache.update(s,d),this._renderableTilesKeys=[];const m={};for(const y of s.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:d}))m[y.key]=!0,this._renderableTilesKeys.push(y.key),this._tiles[y.key]||(y.posMatrix=new Float64Array(16),l.aP(y.posMatrix,0,l.X,0,l.X,0,1),this._tiles[y.key]=new Ts(y,this.tileSize));for(const y in this._tiles)m[y]||delete this._tiles[y]}freeRtt(s){for(const d in this._tiles){const m=this._tiles[d];(!s||m.tileID.equals(s)||m.tileID.isChildOf(s)||s.isChildOf(m.tileID))&&(m.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(s=>this.getTileByID(s))}getTileByID(s){return this._tiles[s]}getTerrainCoords(s){const d={};for(const m of this._renderableTilesKeys){const y=this._tiles[m].tileID;if(y.canonical.equals(s.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16),l.aP(x.posMatrix,0,l.X,0,l.X,0,1),d[m]=x}else if(y.canonical.isChildOf(s.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16);const M=y.canonical.z-s.canonical.z,P=y.canonical.x-(y.canonical.x>>M<<M),O=y.canonical.y-(y.canonical.y>>M<<M),z=l.X>>M;l.aP(x.posMatrix,0,z,0,z,0,1),l.J(x.posMatrix,x.posMatrix,[-P*z,-O*z,0]),d[m]=x}else if(s.canonical.isChildOf(y.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16);const M=s.canonical.z-y.canonical.z,P=s.canonical.x-(s.canonical.x>>M<<M),O=s.canonical.y-(s.canonical.y>>M<<M),z=l.X>>M;l.aP(x.posMatrix,0,l.X,0,l.X,0,1),l.J(x.posMatrix,x.posMatrix,[P*z,O*z,0]),l.K(x.posMatrix,x.posMatrix,[1/2**M,1/2**M,0]),d[m]=x}}return d}getSourceTile(s,d){const m=this.sourceCache._source;let y=s.overscaledZ-this.deltaZoom;if(y>m.maxzoom&&(y=m.maxzoom),y<m.minzoom)return null;this._sourceTileCache[s.key]||(this._sourceTileCache[s.key]=s.scaledTo(y).key);let x=this.sourceCache.getTileByID(this._sourceTileCache[s.key]);if((!x||!x.dem)&&d)for(;y>=m.minzoom&&(!x||!x.dem);)x=this.sourceCache.getTileByID(s.scaledTo(y--).key);return x}tilesAfterTime(s=Date.now()){return Object.values(this._tiles).filter(d=>d.timeAdded>=s)}}class Od{constructor(s,d,m){this.painter=s,this.sourceCache=new E_(d),this.options=m,this.exaggeration=typeof m.exaggeration=="number"?m.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(s,d,m,y=l.X){var x;if(!(d>=0&&d<y&&m>=0&&m<y))return 0;const M=this.getTerrainData(s),P=(x=M.tile)===null||x===void 0?void 0:x.dem;if(!P)return 0;const O=function(ee,se,le){var ce=se[0],he=se[1];return ee[0]=le[0]*ce+le[4]*he+le[12],ee[1]=le[1]*ce+le[5]*he+le[13],ee}([],[d/y*l.X,m/y*l.X],M.u_terrain_matrix),z=[O[0]*P.dim,O[1]*P.dim],V=Math.floor(z[0]),F=Math.floor(z[1]),W=z[0]-V,J=z[1]-F;return P.get(V,F)*(1-W)*(1-J)+P.get(V+1,F)*W*(1-J)+P.get(V,F+1)*(1-W)*J+P.get(V+1,F+1)*W*J}getElevationForLngLatZoom(s,d){if(!l.bb(d,s.wrap()))return 0;const{tileID:m,mercatorX:y,mercatorY:x}=this._getOverscaledTileIDFromLngLatZoom(s,d);return this.getElevation(m,y%l.X,x%l.X,l.X)}getElevation(s,d,m,y=l.X){return this.getDEMElevation(s,d,m,y)*this.exaggeration}getTerrainData(s){if(!this._emptyDemTexture){const y=this.painter.context,x=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new tt(y,x,y.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new tt(y,new l.R({width:1,height:1}),y.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(y.gl.NEAREST,y.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.an([])}const d=this.sourceCache.getSourceTile(s,!0);if(d&&d.dem&&(!d.demTexture||d.needsTerrainPrepare)){const y=this.painter.context;d.demTexture=this.painter.getTileTexture(d.dem.stride),d.demTexture?d.demTexture.update(d.dem.getPixels(),{premultiply:!1}):d.demTexture=new tt(y,d.dem.getPixels(),y.gl.RGBA,{premultiply:!1}),d.demTexture.bind(y.gl.NEAREST,y.gl.CLAMP_TO_EDGE),d.needsTerrainPrepare=!1}const m=d&&d+d.tileID.key+s.key;if(m&&!this._demMatrixCache[m]){const y=this.sourceCache.sourceCache._source.maxzoom;let x=s.canonical.z-d.tileID.canonical.z;s.overscaledZ>s.canonical.z&&(s.canonical.z>=y?x=s.canonical.z-y:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=s.canonical.x-(s.canonical.x>>x<<x),P=s.canonical.y-(s.canonical.y>>x<<x),O=l.bc(new Float64Array(16),[1/(l.X<<x),1/(l.X<<x),0]);l.J(O,O,[M*l.X,P*l.X,0]),this._demMatrixCache[s.key]={matrix:O,coord:s}}return{u_depth:2,u_terrain:3,u_terrain_dim:d&&d.dem&&d.dem.dim||1,u_terrain_matrix:m?this._demMatrixCache[s.key].matrix:this._emptyDemMatrix,u_terrain_unpack:d&&d.dem&&d.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(d&&d.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:d}}getFramebuffer(s){const d=this.painter,m=d.width/devicePixelRatio,y=d.height/devicePixelRatio;return!this._fbo||this._fbo.width===m&&this._fbo.height===y||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new tt(d.context,{width:m,height:y,data:null},d.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(d.context.gl.NEAREST,d.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new tt(d.context,{width:m,height:y,data:null},d.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(d.context.gl.NEAREST,d.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=d.context.createFramebuffer(m,y,!0,!1),this._fbo.depthAttachment.set(d.context.createRenderbuffer(d.context.gl.DEPTH_COMPONENT16,m,y))),this._fbo.colorAttachment.set(s==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const s=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const d=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let x=0,M=0;x<this._coordsTextureSize;x++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)d[M+0]=255&P,d[M+1]=255&x,d[M+2]=P>>8<<4|x>>8,d[M+3]=0;const m=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(d.buffer)),y=new tt(s,m,s.gl.RGBA,{premultiply:!1});return y.bind(s.gl.NEAREST,s.gl.CLAMP_TO_EDGE),this._coordsTexture=y,y}pointCoordinate(s){this.painter.maybeDrawDepthAndCoords(!0);const d=new Uint8Array(4),m=this.painter.context,y=m.gl,x=Math.round(s.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(s.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);m.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),y.readPixels(x,P-M-1,1,1,y.RGBA,y.UNSIGNED_BYTE,d),m.bindFramebuffer.set(null);const O=d[0]+(d[2]>>4<<8),z=d[1]+((15&d[2])<<8),V=this.coordsIndex[255-d[3]],F=V&&this.sourceCache.getTileByID(V);if(!F)return null;const W=this._coordsTextureSize,J=(1<<F.tileID.canonical.z)*W;return new l.Z((F.tileID.canonical.x*W+O)/J+F.tileID.wrap,(F.tileID.canonical.y*W+z)/J,this.getElevation(F.tileID,O,z,W))}depthAtPoint(s){const d=new Uint8Array(4),m=this.painter.context,y=m.gl;return m.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),y.readPixels(s.x,this.painter.height/devicePixelRatio-s.y-1,1,1,y.RGBA,y.UNSIGNED_BYTE,d),m.bindFramebuffer.set(null),(d[0]/16777216+d[1]/65536+d[2]/256+d[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const s=this.painter.context,d=new l.bd,m=new l.aY,y=this.meshSize,x=l.X/y,M=y*y;for(let F=0;F<=y;F++)for(let W=0;W<=y;W++)d.emplaceBack(W*x,F*x,0);for(let F=0;F<M;F+=y+1)for(let W=0;W<y;W++)m.emplaceBack(W+F,y+W+F+1,y+W+F+2),m.emplaceBack(W+F,y+W+F+2,W+F+1);const P=d.length,O=P+2*(y+1);for(const F of[0,1])for(let W=0;W<=y;W++)for(const J of[0,1])d.emplaceBack(W*x,F*l.X,J);for(let F=0;F<2*y;F+=2)m.emplaceBack(O+F,O+F+1,O+F+3),m.emplaceBack(O+F,O+F+3,O+F+2),m.emplaceBack(P+F,P+F+3,P+F+1),m.emplaceBack(P+F,P+F+2,P+F+3);const z=d.length,V=z+2*(y+1);for(const F of[0,1])for(let W=0;W<=y;W++)for(const J of[0,1])d.emplaceBack(F*l.X,W*x,J);for(let F=0;F<2*y;F+=2)m.emplaceBack(z+F,z+F+1,z+F+3),m.emplaceBack(z+F,z+F+3,z+F+2),m.emplaceBack(V+F,V+F+3,V+F+1),m.emplaceBack(V+F,V+F+2,V+F+3);return this._mesh=new gu(s.createVertexBuffer(d,Dd.members),s.createIndexBuffer(m),l.a0.simpleSegment(0,0,d.length,m.length)),this._mesh}getMeshFrameDelta(s){return 2*Math.PI*l.be/Math.pow(2,s)/5}getMinTileElevationForLngLatZoom(s,d){var m;const{tileID:y}=this._getOverscaledTileIDFromLngLatZoom(s,d);return(m=this.getMinMaxElevation(y).minElevation)!==null&&m!==void 0?m:0}getMinMaxElevation(s){const d=this.getTerrainData(s).tile,m={minElevation:null,maxElevation:null};return d&&d.dem&&(m.minElevation=d.dem.min*this.exaggeration,m.maxElevation=d.dem.max*this.exaggeration),m}_getOverscaledTileIDFromLngLatZoom(s,d){const m=l.Z.fromLngLat(s.wrap()),y=(1<<d)*l.X,x=m.x*y,M=m.y*y,P=Math.floor(x/l.X),O=Math.floor(M/l.X);return{tileID:new l.S(d,0,d,P,O),mercatorX:x,mercatorY:M}}}class C_{constructor(s,d,m){this._context=s,this._size=d,this._tileSize=m,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const s of this._objects)s.texture.destroy(),s.fbo.destroy()}_createObject(s){const d=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),m=new tt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return m.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),d.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),d.colorAttachment.set(m.texture),{id:s,fbo:d,texture:m,stamp:-1,inUse:!1}}getObjectForId(s){return this._objects[s]}useObject(s){s.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(d=>s.id!==d),this._recentlyUsed.push(s.id)}stampObject(s){s.stamp=++this._stamp}getOrCreateFreeObject(){for(const d of this._recentlyUsed)if(!this._objects[d].inUse)return this._objects[d];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const s=this._createObject(this._objects.length);return this._objects.push(s),s}freeObject(s){s.inUse=!1}freeAllObjects(){for(const s of this._objects)this.freeObject(s)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(s=>!s.inUse)===!1}}const Za={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Em{constructor(s,d){this.painter=s,this.terrain=d,this.pool=new C_(s.context,30,d.sourceCache.tileSize*d.qualityFactor)}destruct(){this.pool.destruct()}getTexture(s){return this.pool.getObjectForId(s.rtt[this._stacks.length-1].id).texture}prepareForRender(s,d){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=s._order.filter(m=>!s._layers[m].isHidden(d)),this._coordsDescendingInv={};for(const m in s.sourceCaches){this._coordsDescendingInv[m]={};const y=s.sourceCaches[m].getVisibleCoordinates();for(const x of y){const M=this.terrain.sourceCache.getTerrainCoords(x);for(const P in M)this._coordsDescendingInv[m][P]||(this._coordsDescendingInv[m][P]=[]),this._coordsDescendingInv[m][P].push(M[P])}}this._coordsDescendingInvStr={};for(const m of s._order){const y=s._layers[m],x=y.source;if(Za[y.type]&&!this._coordsDescendingInvStr[x]){this._coordsDescendingInvStr[x]={};for(const M in this._coordsDescendingInv[x])this._coordsDescendingInvStr[x][M]=this._coordsDescendingInv[x][M].map(P=>P.key).sort().join()}}for(const m of this._renderableTiles)for(const y in this._coordsDescendingInvStr){const x=this._coordsDescendingInvStr[y][m.tileID.key];x&&x!==m.rttCoords[y]&&(m.rtt=[])}}renderLayer(s){if(s.isHidden(this.painter.transform.zoom))return!1;const d=s.type,m=this.painter,y=this._renderableLayerIds[this._renderableLayerIds.length-1]===s.id;if(Za[d]&&(this._prevType&&Za[this._prevType]||this._stacks.push([]),this._prevType=d,this._stacks[this._stacks.length-1].push(s.id),!y))return!0;if(Za[this._prevType]||Za[d]&&y){this._prevType=d;const x=this._stacks.length-1,M=this._stacks[x]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(ym(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[x]){const z=this.pool.getObjectForId(P.rtt[x].id);if(z.stamp===P.rtt[x].stamp){this.pool.useObject(z);continue}}const O=this.pool.getOrCreateFreeObject();this.pool.useObject(O),this.pool.stampObject(O),P.rtt[x]={id:O.id,stamp:O.stamp},m.context.bindFramebuffer.set(O.fbo.framebuffer),m.context.clear({color:l.aM.transparent,stencil:0}),m.currentStencilSource=void 0;for(let z=0;z<M.length;z++){const V=m.style._layers[M[z]],F=V.source?this._coordsDescendingInv[V.source][P.tileID.key]:[P.tileID];m.context.viewport.set([0,0,O.fbo.width,O.fbo.height]),m._renderTileClippingMasks(V,F),m.renderLayer(m,m.style.sourceCaches[V.source],V,F),V.source&&(P.rttCoords[V.source]=this._coordsDescendingInvStr[V.source][P.tileID.key])}}return ym(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Za[d]}return!1}}const Bd={"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 ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Cm=g,T_={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Wa,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:l.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},Nd=v=>{v.touchstart=v.dragStart,v.touchmoveWindow=v.dragMove,v.touchend=v.dragEnd},M_={showCompass:!0,showZoom:!0,visualizePitch:!1};class A_{constructor(s,d,m=!1){this.mousedown=M=>{this.startMouse(l.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),C.mousePos(this.element,M)),C.addEventListener(window,"mousemove",this.mousemove),C.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,C.mousePos(this.element,M))},this.mouseup=M=>{this.mouseRotate.dragEnd(M),this.mousePitch&&this.mousePitch.dragEnd(M),this.offTemp()},this.touchstart=M=>{M.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=C.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),C.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=C.touchPos(this.element,M.targetTouches)[0],this.moveTouch(M,this._lastPos))},this.touchend=M=>{M.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;const y=s.dragRotate._mouseRotate.getClickTolerance(),x=s.dragRotate._mousePitch.getClickTolerance();this.element=d,this.mouseRotate=wd({clickTolerance:y,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:O=.8})=>{const z=new vd;return new qs({clickTolerance:P,move:(V,F)=>({bearingDelta:(F.x-V.x)*O}),moveStateManager:z,enable:M,assignEvents:Nd})})({clickTolerance:y,enable:!0}),this.map=s,m&&(this.mousePitch=kd({clickTolerance:x,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:O=-.5})=>{const z=new vd;return new qs({clickTolerance:P,move:(V,F)=>({pitchDelta:(F.y-V.y)*O}),moveStateManager:z,enable:M,assignEvents:Nd})})({clickTolerance:x,enable:!0})),C.addEventListener(d,"mousedown",this.mousedown),C.addEventListener(d,"touchstart",this.touchstart,{passive:!1}),C.addEventListener(d,"touchcancel",this.reset)}startMouse(s,d){this.mouseRotate.dragStart(s,d),this.mousePitch&&this.mousePitch.dragStart(s,d),C.disableDrag()}startTouch(s,d){this.touchRotate.dragStart(s,d),this.touchPitch&&this.touchPitch.dragStart(s,d),C.disableDrag()}moveMouse(s,d){const m=this.map,{bearingDelta:y}=this.mouseRotate.dragMove(s,d)||{};if(y&&m.setBearing(m.getBearing()+y),this.mousePitch){const{pitchDelta:x}=this.mousePitch.dragMove(s,d)||{};x&&m.setPitch(m.getPitch()+x)}}moveTouch(s,d){const m=this.map,{bearingDelta:y}=this.touchRotate.dragMove(s,d)||{};if(y&&m.setBearing(m.getBearing()+y),this.touchPitch){const{pitchDelta:x}=this.touchPitch.dragMove(s,d)||{};x&&m.setPitch(m.getPitch()+x)}}off(){const s=this.element;C.removeEventListener(s,"mousedown",this.mousedown),C.removeEventListener(s,"touchstart",this.touchstart,{passive:!1}),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend),C.removeEventListener(s,"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 br;function Vn(v,s,d){const m=new l.N(v.lng,v.lat);if(v=new l.N(v.lng,v.lat),s){const y=new l.N(v.lng-360,v.lat),x=new l.N(v.lng+360,v.lat),M=d.locationPoint(v).distSqr(s);d.locationPoint(y).distSqr(s)<M?v=y:d.locationPoint(x).distSqr(s)<M&&(v=x)}for(;Math.abs(v.lng-d.center.lng)>180;){const y=d.locationPoint(v);if(y.x>=0&&y.y>=0&&y.x<=d.width&&y.y<=d.height)break;v.lng>d.center.lng?v.lng-=360:v.lng+=360}return v.lng!==m.lng&&d.locationPoint(v).y>d.height/2-d.getHorizon()?v:m}const Ya={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 Tu(v,s,d){const m=v.classList;for(const y in Ya)m.remove(`maplibregl-${d}-anchor-${y}`);m.add(`maplibregl-${d}-anchor-${s}`)}class Mu extends l.E{constructor(s){if(super(),this._onKeyPress=d=>{const m=d.code,y=d.charCode||d.keyCode;m!=="Space"&&m!=="Enter"&&y!==32&&y!==13||this.togglePopup()},this._onMapClick=d=>{const m=d.originalEvent.target,y=this._element;this._popup&&(m===y||y.contains(m))&&this.togglePopup()},this._update=d=>{var m;if(!this._map)return;const y=this._map.loaded()&&!this._map.isMoving();((d==null?void 0:d.type)==="terrain"||(d==null?void 0:d.type)==="render"&&!y)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Vn(this._lngLat,this._flatPos,this._map.transform):(m=this._lngLat)===null||m===void 0?void 0:m.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 x="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?x=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(x=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let M="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?M="rotateX(0deg)":this._pitchAlignment==="map"&&(M=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||d&&d.type!=="moveend"||(this._pos=this._pos.round()),C.setTransform(this._element,`${Ya[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${x}`),E.frameAsync(new AbortController).then(()=>{this._updateOpacity(d&&d.type==="moveend")}).catch(()=>{})},this._onMove=d=>{if(!this._isDragging){const m=this._clickTolerance||this._map._clickTolerance;this._isDragging=d.point.dist(this._pointerdownPos)>=m}this._isDragging&&(this._pos=d.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 l.k("dragstart"))),this.fire(new l.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 l.k("dragend")),this._state="inactive"},this._addDragHandler=d=>{this._element.contains(d.originalEvent.target)&&(d.preventDefault(),this._positionDelta=d.point.sub(this._pos).add(this._offset),this._pointerdownPos=d.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=s&&s.anchor||"center",this._color=s&&s.color||"#3FB1CE",this._scale=s&&s.scale||1,this._draggable=s&&s.draggable||!1,this._clickTolerance=s&&s.clickTolerance||0,this._subpixelPositioning=s&&s.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=s&&s.rotation||0,this._rotationAlignment=s&&s.rotationAlignment||"auto",this._pitchAlignment=s&&s.pitchAlignment&&s.pitchAlignment!=="auto"?s.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(s==null?void 0:s.opacity,s==null?void 0:s.opacityWhenCovered),s&&s.element)this._element=s.element,this._offset=l.P.convert(s&&s.offset||[0,0]);else{this._defaultMarker=!0,this._element=C.create("div");const d=C.createNS("http://www.w3.org/2000/svg","svg"),m=41,y=27;d.setAttributeNS(null,"display","block"),d.setAttributeNS(null,"height",`${m}px`),d.setAttributeNS(null,"width",`${y}px`),d.setAttributeNS(null,"viewBox",`0 0 ${y} ${m}`);const x=C.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"stroke","none"),x.setAttributeNS(null,"stroke-width","1"),x.setAttributeNS(null,"fill","none"),x.setAttributeNS(null,"fill-rule","evenodd");const M=C.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=C.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const O=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ce of O){const he=C.createNS("http://www.w3.org/2000/svg","ellipse");he.setAttributeNS(null,"opacity","0.04"),he.setAttributeNS(null,"cx","10.5"),he.setAttributeNS(null,"cy","5.80029008"),he.setAttributeNS(null,"rx",ce.rx),he.setAttributeNS(null,"ry",ce.ry),P.appendChild(he)}const z=C.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"fill",this._color);const V=C.createNS("http://www.w3.org/2000/svg","path");V.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"),z.appendChild(V);const F=C.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");const W=C.createNS("http://www.w3.org/2000/svg","path");W.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(W);const J=C.createNS("http://www.w3.org/2000/svg","g");J.setAttributeNS(null,"transform","translate(6.0, 7.0)"),J.setAttributeNS(null,"fill","#FFFFFF");const ee=C.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=C.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const le=C.createNS("http://www.w3.org/2000/svg","circle");le.setAttributeNS(null,"fill","#FFFFFF"),le.setAttributeNS(null,"cx","5.5"),le.setAttributeNS(null,"cy","5.5"),le.setAttributeNS(null,"r","5.4999962"),ee.appendChild(se),ee.appendChild(le),M.appendChild(P),M.appendChild(z),M.appendChild(F),M.appendChild(J),M.appendChild(ee),d.appendChild(M),d.setAttributeNS(null,"height",m*this._scale+"px"),d.setAttributeNS(null,"width",y*this._scale+"px"),this._element.appendChild(d),this._offset=l.P.convert(s&&s.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",d=>{d.preventDefault()}),this._element.addEventListener("mousedown",d=>{d.preventDefault()}),Tu(this._element,this._anchor,"marker"),s&&s.className)for(const d of s.className.split(" "))this._element.classList.add(d);this._popup=null}addTo(s){return this.remove(),this._map=s,this._element.setAttribute("aria-label",s._getUIString("Marker.Title")),s.getCanvasContainer().appendChild(this._element),s.on("move",this._update),s.on("moveend",this._update),s.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(s){return this._lngLat=l.N.convert(s),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(s){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),s){if(!("offset"in s.options)){const y=Math.abs(13.5)/Math.SQRT2;s.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[y,-1*(38.1-13.5+y)],"bottom-right":[-y,-1*(38.1-13.5+y)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=s,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(s){return this._subpixelPositioning=s,this}getPopup(){return this._popup}togglePopup(){const s=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:s?(s.isOpen()?s.remove():(s.setLngLat(this._lngLat),s.addTo(this._map)),this):this}_updateOpacity(s=!1){var d,m;if(!(!((d=this._map)===null||d===void 0)&&d.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(s)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const y=this._map,x=y.terrain.depthAtPoint(this._pos),M=y.terrain.getElevationForLngLatZoom(this._lngLat,y.transform.tileZoom);if(y.transform.lngLatToCameraDepth(this._lngLat,M)-x<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/y.transform._pixelPerMeter,O=Math.sin(y.getPitch()*Math.PI/180)*P,z=y.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),V=y.transform.lngLatToCameraDepth(this._lngLat,M+O)-z>.006;!((m=this._popup)===null||m===void 0)&&m.isOpen()&&V&&this._popup.remove(),this._element.style.opacity=V?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(s){return this._offset=l.P.convert(s),this._update(),this}addClassName(s){this._element.classList.add(s)}removeClassName(s){this._element.classList.remove(s)}toggleClassName(s){return this._element.classList.toggle(s)}setDraggable(s){return this._draggable=!!s,this._map&&(s?(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(s){return this._rotation=s||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(s){return this._rotationAlignment=s||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(s){return this._pitchAlignment=s&&s!=="auto"?s:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(s,d){return s===void 0&&d===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),s!==void 0&&(this._opacity=s),d!==void 0&&(this._opacityWhenCovered=d),this._map&&this._updateOpacity(!0),this}}const Tm={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Jl=0,Ql=!1;const Ps={maxWidth:100,unit:"metric"};function ec(v,s,d){const m=d&&d.maxWidth||100,y=v._container.clientHeight/2,x=v.unproject([0,y]),M=v.unproject([m,y]),P=x.distanceTo(M);if(d&&d.unit==="imperial"){const O=3.2808*P;O>5280?ft(s,m,O/5280,v._getUIString("ScaleControl.Miles")):ft(s,m,O,v._getUIString("ScaleControl.Feet"))}else d&&d.unit==="nautical"?ft(s,m,P/1852,v._getUIString("ScaleControl.NauticalMiles")):P>=1e3?ft(s,m,P/1e3,v._getUIString("ScaleControl.Kilometers")):ft(s,m,P,v._getUIString("ScaleControl.Meters"))}function ft(v,s,d,m){const y=function(x){const M=Math.pow(10,`${Math.floor(x)}`.length-1);let P=x/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(O){const z=Math.pow(10,Math.ceil(-Math.log(O)/Math.LN10));return Math.round(O*z)/z}(P),M*P}(d);v.style.width=s*(y/d)+"px",v.innerHTML=`${y}&nbsp;${m}`}const Et={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Au=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Pu(v){if(v){if(typeof v=="number"){const s=Math.round(Math.abs(v)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,v),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-v),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(v,0),right:new l.P(-v,0)}}if(v instanceof l.P||Array.isArray(v)){const s=l.P.convert(v);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:l.P.convert(v.center||[0,0]),top:l.P.convert(v.top||[0,0]),"top-left":l.P.convert(v["top-left"]||[0,0]),"top-right":l.P.convert(v["top-right"]||[0,0]),bottom:l.P.convert(v.bottom||[0,0]),"bottom-left":l.P.convert(v["bottom-left"]||[0,0]),"bottom-right":l.P.convert(v["bottom-right"]||[0,0]),left:l.P.convert(v.left||[0,0]),right:l.P.convert(v.right||[0,0])}}return Pu(new l.P(0,0))}const zd=g;u.AJAXError=l.bh,u.Evented=l.E,u.LngLat=l.N,u.MercatorCoordinate=l.Z,u.Point=l.P,u.addProtocol=l.bi,u.config=l.a,u.removeProtocol=l.bj,u.AttributionControl=Ga,u.BoxZoomHandler=_r,u.CanvasSource=wi,u.CooperativeGesturesHandler=qa,u.DoubleClickZoomHandler=Xo,u.DragPanHandler=wm,u.DragRotateHandler=km,u.EdgeInsets=$a,u.FullscreenControl=class extends l.E{constructor(v={}){super(),this._onFullscreenChange=()=>{var s;let d=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((s=d==null?void 0:d.shadowRoot)===null||s===void 0)&&s.fullscreenElement;)d=d.shadowRoot.fullscreenElement;d===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,v&&v.container&&(v.container instanceof HTMLElement?this._container=v.container:l.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(v){return this._map=v,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(){const v=this._fullscreenButton=C.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);C.create("span","maplibregl-ctrl-icon",v).setAttribute("aria-hidden","true"),v.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const v=this._getTitle();this._fullscreenButton.setAttribute("aria-label",v),this._fullscreenButton.title=v}_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 l.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new l.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()}},u.GeoJSONSource=vi,u.GeolocateControl=class extends l.E{constructor(v){super(),this._onSuccess=s=>{if(this._map){if(this._isOutOfMapMaxBounds(s))return this._setErrorState(),this.fire(new l.k("outofmaxbounds",s)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=s,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(s),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(s),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new l.k("geolocate",s)),this._finish()}},this._updateCamera=s=>{const d=new l.N(s.coords.longitude,s.coords.latitude),m=s.coords.accuracy,y=this._map.getBearing(),x=l.e({bearing:y},this.options.fitBoundsOptions),M=ve.fromLngLat(d,m);this._map.fitBounds(M,x,{geolocateSource:!0})},this._updateMarker=s=>{if(s){const d=new l.N(s.coords.longitude,s.coords.latitude);this._accuracyCircleMarker.setLngLat(d).addTo(this._map),this._userLocationDotMarker.setLngLat(d).addTo(this._map),this._accuracy=s.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=s=>{if(this._map){if(this.options.trackUserLocation)if(s.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(s.code===3&&Ql)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.k("error",s)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",s=>s.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=s=>{if(this._map){if(s===!1){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d)}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 Mu({element:this._dotElement}),this._circleElement=C.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Mu({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",d=>{d.geolocateSource||this._watchState!=="ACTIVE_LOCK"||d.originalEvent&&d.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 l.k("trackuserlocationend")),this.fire(new l.k("userlocationlostfocus")))})}},this.options=l.e({},Tm,v)}onAdd(v){return this._map=v,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,function*(s=!1){if(br!==void 0&&!s)return br;if(window.navigator.permissions===void 0)return br=!!window.navigator.geolocation,br;try{br=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{br=!!window.navigator.geolocation}return br})}().then(s=>this._finishSetupUI(s)),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,Jl=0,Ql=!1}_isOutOfMapMaxBounds(v){const s=this._map.getMaxBounds(),d=v.coords;return s&&(d.longitude<s.getWest()||d.longitude>s.getEast()||d.latitude<s.getSouth()||d.latitude>s.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const v=this._map.getBounds(),s=v.getSouthEast(),d=v.getNorthEast(),m=s.distanceTo(d),y=Math.ceil(this._accuracy/(m/this._map._container.clientHeight)*2);this._circleElement.style.width=`${y}px`,this._circleElement.style.height=`${y}px`}trigger(){if(!this._setup)return l.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 l.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Jl--,Ql=!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 l.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 l.k("trackuserlocationstart")),this.fire(new l.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 v;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Jl++,Jl>1?(v={maximumAge:6e5,timeout:0},Ql=!0):(v=this.options.positionOptions,Ql=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,v)}}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)}},u.Hash=_u,u.ImageSource=mi,u.KeyboardHandler=Lr,u.LngLatBounds=ve,u.LogoControl=Id,u.Map=class extends Sm{constructor(v){l.bf.mark(l.bg.create);const s=Object.assign(Object.assign({},T_),v);if(s.minZoom!=null&&s.maxZoom!=null&&s.minZoom>s.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(s.minPitch!=null&&s.maxPitch!=null&&s.minPitch>s.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(s.minPitch!=null&&s.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(s.maxPitch!=null&&s.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ja(s.minZoom,s.maxZoom,s.minPitch,s.maxPitch,s.renderWorldCopies),{bearingSnap:s.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new en,this._controls=[],this._mapId=l.a4(),this._contextLost=d=>{d.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new l.k("webglcontextlost",{originalEvent:d}))},this._contextRestored=d=>{this._setupPainter(),this.resize(),this._update(),this.fire(new l.k("webglcontextrestored",{originalEvent:d}))},this._onMapScroll=d=>{if(d.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=s.interactive,this._maxTileCacheSize=s.maxTileCacheSize,this._maxTileCacheZoomLevels=s.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=s.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=s.preserveDrawingBuffer===!0,this._antialias=s.antialias===!0,this._trackResize=s.trackResize===!0,this._bearingSnap=s.bearingSnap,this._refreshExpiredTiles=s.refreshExpiredTiles===!0,this._fadeDuration=s.fadeDuration,this._crossSourceCollisions=s.crossSourceCollisions===!0,this._collectResourceTiming=s.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Bd),s.locale),this._clickTolerance=s.clickTolerance,this._overridePixelRatio=s.pixelRatio,this._maxCanvasSize=s.maxCanvasSize,this.transformCameraUpdate=s.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=s.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new Q(s.transformRequest),typeof s.container=="string"){if(this._container=document.getElementById(s.container),!this._container)throw new Error(`Container '${s.container}' not found.`)}else{if(!(s.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=s.container}if(s.maxBounds&&this.setMaxBounds(s.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 d=!1;const m=Gl(y=>{this._trackResize&&!this._removed&&(this.resize(y),this.redraw())},50);this._resizeObserver=new ResizeObserver(y=>{d?m(y):d=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Pd(this,s),this._hash=s.hash&&new _u(typeof s.hash=="string"&&s.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch}),s.bounds&&(this.resize(),this.fitBounds(s.bounds,l.e({},s.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=s.localIdeographFontFamily,this._validateStyle=s.validateStyle,s.style&&this.setStyle(s.style,{localIdeographFontFamily:s.localIdeographFontFamily}),s.attributionControl&&this.addControl(new Ga(typeof s.attributionControl=="boolean"?void 0:s.attributionControl)),s.maplibreLogo&&this.addControl(new Id,s.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",d=>{this._update(d.dataType==="style"),this.fire(new l.k(`${d.dataType}data`,d))}),this.on("dataloading",d=>{this.fire(new l.k(`${d.dataType}dataloading`,d))}),this.on("dataabort",d=>{this.fire(new l.k("sourcedataabort",d))})}_getMapId(){return this._mapId}addControl(v,s){if(s===void 0&&(s=v.getDefaultPosition?v.getDefaultPosition():"top-right"),!v||!v.onAdd)return this.fire(new l.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=v.onAdd(this);this._controls.push(v);const m=this._controlPositions[s];return s.indexOf("bottom")!==-1?m.insertBefore(d,m.firstChild):m.appendChild(d),this}removeControl(v){if(!v||!v.onRemove)return this.fire(new l.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(v);return s>-1&&this._controls.splice(s,1),v.onRemove(this),this}hasControl(v){return this._controls.indexOf(v)>-1}calculateCameraOptionsFromTo(v,s,d,m){return m==null&&this.terrain&&(m=this.terrain.getElevationForLngLatZoom(d,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(v,s,d,m)}resize(v){var s;const d=this._containerDimensions(),m=d[0],y=d[1],x=this._getClampedPixelRatio(m,y);if(this._resizeCanvas(m,y,x),this.painter.resize(m,y,x),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const O=this._getClampedPixelRatio(m,y);this._resizeCanvas(m,y,O),this.painter.resize(m,y,O)}this.transform.resize(m,y),(s=this._requestedCameraState)===null||s===void 0||s.resize(m,y);const M=!this._moving;return M&&(this.stop(),this.fire(new l.k("movestart",v)).fire(new l.k("move",v))),this.fire(new l.k("resize",v)),M&&this.fire(new l.k("moveend",v)),this}_getClampedPixelRatio(v,s){const{0:d,1:m}=this._maxCanvasSize,y=this.getPixelRatio(),x=v*y,M=s*y;return Math.min(x>d?d/x:1,M>m?m/M:1)*y}getPixelRatio(){var v;return(v=this._overridePixelRatio)!==null&&v!==void 0?v:devicePixelRatio}setPixelRatio(v){this._overridePixelRatio=v,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(v){return this.transform.setMaxBounds(ve.convert(v)),this._update()}setMinZoom(v){if((v=v??-2)>=-2&&v<=this.transform.maxZoom)return this.transform.minZoom=v,this._update(),this.getZoom()<v&&this.setZoom(v),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(v){if((v=v??22)>=this.transform.minZoom)return this.transform.maxZoom=v,this._update(),this.getZoom()>v&&this.setZoom(v),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(v){if((v=v??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(v>=0&&v<=this.transform.maxPitch)return this.transform.minPitch=v,this._update(),this.getPitch()<v&&this.setPitch(v),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(v){if((v=v??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(v>=this.transform.minPitch)return this.transform.maxPitch=v,this._update(),this.getPitch()>v&&this.setPitch(v),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(v){return this.transform.renderWorldCopies=v,this._update()}project(v){return this.transform.locationPoint(l.N.convert(v),this.style&&this.terrain)}unproject(v){return this.transform.pointLocation(l.P.convert(v),this.terrain)}isMoving(){var v;return this._moving||((v=this.handlers)===null||v===void 0?void 0:v.isMoving())}isZooming(){var v;return this._zooming||((v=this.handlers)===null||v===void 0?void 0:v.isZooming())}isRotating(){var v;return this._rotating||((v=this.handlers)===null||v===void 0?void 0:v.isRotating())}_createDelegatedListener(v,s,d){if(v==="mouseenter"||v==="mouseover"){let m=!1;return{layers:s,listener:d,delegates:{mousemove:x=>{const M=s.filter(O=>this.getLayer(O)),P=M.length!==0?this.queryRenderedFeatures(x.point,{layers:M}):[];P.length?m||(m=!0,d.call(this,new Oi(v,this,x.originalEvent,{features:P}))):m=!1},mouseout:()=>{m=!1}}}}if(v==="mouseleave"||v==="mouseout"){let m=!1;return{layers:s,listener:d,delegates:{mousemove:M=>{const P=s.filter(O=>this.getLayer(O));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?m=!0:m&&(m=!1,d.call(this,new Oi(v,this,M.originalEvent)))},mouseout:M=>{m&&(m=!1,d.call(this,new Oi(v,this,M.originalEvent)))}}}}{const m=y=>{const x=s.filter(P=>this.getLayer(P)),M=x.length!==0?this.queryRenderedFeatures(y.point,{layers:x}):[];M.length&&(y.features=M,d.call(this,y),delete y.features)};return{layers:s,listener:d,delegates:{[v]:m}}}}_saveDelegatedListener(v,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[v]=this._delegatedListeners[v]||[],this._delegatedListeners[v].push(s)}_removeDelegatedListener(v,s,d){if(!this._delegatedListeners||!this._delegatedListeners[v])return;const m=this._delegatedListeners[v];for(let y=0;y<m.length;y++){const x=m[y];if(x.listener===d&&x.layers.length===s.length&&x.layers.every(M=>s.includes(M))){for(const M in x.delegates)this.off(M,x.delegates[M]);return void m.splice(y,1)}}}on(v,s,d){if(d===void 0)return super.on(v,s);const m=this._createDelegatedListener(v,typeof s=="string"?[s]:s,d);this._saveDelegatedListener(v,m);for(const y in m.delegates)this.on(y,m.delegates[y]);return this}once(v,s,d){if(d===void 0)return super.once(v,s);const m=typeof s=="string"?[s]:s,y=this._createDelegatedListener(v,m,d);for(const x in y.delegates){const M=y.delegates[x];y.delegates[x]=(...P)=>{this._removeDelegatedListener(v,m,d),M(...P)}}this._saveDelegatedListener(v,y);for(const x in y.delegates)this.once(x,y.delegates[x]);return this}off(v,s,d){return d===void 0?super.off(v,s):(this._removeDelegatedListener(v,typeof s=="string"?[s]:s,d),this)}queryRenderedFeatures(v,s){if(!this.style)return[];let d;const m=v instanceof l.P||Array.isArray(v),y=m?v:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(m?{}:v)||{},y instanceof l.P||typeof y[0]=="number")d=[l.P.convert(y)];else{const x=l.P.convert(y[0]),M=l.P.convert(y[1]);d=[x,new l.P(M.x,x.y),M,new l.P(x.x,M.y),x]}return this.style.queryRenderedFeatures(d,s,this.transform)}querySourceFeatures(v,s){return this.style.querySourceFeatures(v,s)}setStyle(v,s){return(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff!==!1&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&v?(this._diffStyle(v,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(v,s))}setTransformRequest(v){return this._requestManager.setTransformRequest(v),this}_getUIString(v){const s=this._locale[v];if(s==null)throw new Error(`Missing UI string '${v}'`);return s}_updateStyle(v,s){if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(v,s));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!v)),v?(this.style=new tu(this,s||{}),this.style.setEventedParent(this,{style:this.style}),typeof v=="string"?this.style.loadURL(v,s,d):this.style.loadJSON(v,s,d),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new tu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(v,s){if(typeof v=="string"){const d=this._requestManager.transformRequest(v,"Style");l.h(d,new AbortController).then(m=>{this._updateDiff(m.data,s)}).catch(m=>{m&&this.fire(new l.j(m))})}else typeof v=="object"&&this._updateDiff(v,s)}_updateDiff(v,s){try{this.style.setState(v,s)&&this._update(!0)}catch(d){l.w(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(v,s)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():l.w("There is no style added to the map.")}addSource(v,s){return this._lazyInitEmptyStyle(),this.style.addSource(v,s),this._update(!0)}isSourceLoaded(v){const s=this.style&&this.style.sourceCaches[v];if(s!==void 0)return s.loaded();this.fire(new l.j(new Error(`There is no source with ID '${v}'`)))}setTerrain(v){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),v){const s=this.style.sourceCaches[v.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${v.source}`);this.terrain===null&&s.reload();for(const d in this.style._layers){const m=this.style._layers[d];m.type==="hillshade"&&m.source===v.source&&l.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 Od(this.painter,s,v),this.painter.renderToTexture=new Em(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=d=>{d.dataType==="style"?this.terrain.sourceCache.freeRtt():d.dataType==="source"&&d.tile&&(d.sourceId!==v.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(d.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 l.k("terrain",{terrain:v})),this}getTerrain(){var v,s;return(s=(v=this.terrain)===null||v===void 0?void 0:v.options)!==null&&s!==void 0?s:null}areTilesLoaded(){const v=this.style&&this.style.sourceCaches;for(const s in v){const d=v[s]._tiles;for(const m in d){const y=d[m];if(y.state!=="loaded"&&y.state!=="errored")return!1}}return!0}removeSource(v){return this.style.removeSource(v),this._update(!0)}getSource(v){return this.style.getSource(v)}addImage(v,s,d={}){const{pixelRatio:m=1,sdf:y=!1,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z}=d;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||l.b(s))){if(s.width===void 0||s.height===void 0)return this.fire(new l.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:V,height:F,data:W}=s,J=s;return this.style.addImage(v,{data:new l.R({width:V,height:F},new Uint8Array(W)),pixelRatio:m,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z,sdf:y,version:0,userImage:J}),J.onAdd&&J.onAdd(this,v),this}}{const{width:V,height:F,data:W}=E.getImageData(s);this.style.addImage(v,{data:new l.R({width:V,height:F},W),pixelRatio:m,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z,sdf:y,version:0})}}updateImage(v,s){const d=this.style.getImage(v);if(!d)return this.fire(new l.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const m=s instanceof HTMLImageElement||l.b(s)?E.getImageData(s):s,{width:y,height:x,data:M}=m;if(y===void 0||x===void 0)return this.fire(new l.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(y!==d.data.width||x!==d.data.height)return this.fire(new l.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const P=!(s instanceof HTMLImageElement||l.b(s));return d.data.replace(M,P),this.style.updateImage(v,d),this}getImage(v){return this.style.getImage(v)}hasImage(v){return v?!!this.style.getImage(v):(this.fire(new l.j(new Error("Missing required image id"))),!1)}removeImage(v){this.style.removeImage(v)}loadImage(v){return Z.getImage(this._requestManager.transformRequest(v,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(v,s){return this._lazyInitEmptyStyle(),this.style.addLayer(v,s),this._update(!0)}moveLayer(v,s){return this.style.moveLayer(v,s),this._update(!0)}removeLayer(v){return this.style.removeLayer(v),this._update(!0)}getLayer(v){return this.style.getLayer(v)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(v,s,d){return this.style.setLayerZoomRange(v,s,d),this._update(!0)}setFilter(v,s,d={}){return this.style.setFilter(v,s,d),this._update(!0)}getFilter(v){return this.style.getFilter(v)}setPaintProperty(v,s,d,m={}){return this.style.setPaintProperty(v,s,d,m),this._update(!0)}getPaintProperty(v,s){return this.style.getPaintProperty(v,s)}setLayoutProperty(v,s,d,m={}){return this.style.setLayoutProperty(v,s,d,m),this._update(!0)}getLayoutProperty(v,s){return this.style.getLayoutProperty(v,s)}setGlyphs(v,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(v,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(v,s,d={}){return this._lazyInitEmptyStyle(),this.style.addSprite(v,s,d,m=>{m||this._update(!0)}),this}removeSprite(v){return this._lazyInitEmptyStyle(),this.style.removeSprite(v),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(v,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(v,s,d=>{d||this._update(!0)}),this}setLight(v,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(v,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(v){return this._lazyInitEmptyStyle(),this.style.setSky(v),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(v,s){return this.style.setFeatureState(v,s),this._update()}removeFeatureState(v,s){return this.style.removeFeatureState(v,s),this._update()}getFeatureState(v){return this.style.getFeatureState(v)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let v=0,s=0;return this._container&&(v=this._container.clientWidth||400,s=this._container.clientHeight||300),[v,s]}_setupContainer(){const v=this._container;v.classList.add("maplibregl-map");const s=this._canvasContainer=C.create("div","maplibregl-canvas-container",v);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=C.create("canvas","maplibregl-canvas",s),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");const d=this._containerDimensions(),m=this._getClampedPixelRatio(d[0],d[1]);this._resizeCanvas(d[0],d[1],m);const y=this._controlContainer=C.create("div","maplibregl-control-container",v),x=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{x[M]=C.create("div",`maplibregl-ctrl-${M} `,y)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(v,s,d){this._canvas.width=Math.floor(d*v),this._canvas.height=Math.floor(d*s),this._canvas.style.width=`${v}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const v={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let s=null;this._canvas.addEventListener("webglcontextcreationerror",m=>{s={requestedAttributes:v},m&&(s.statusMessage=m.statusMessage,s.type=m.type)},{once:!0});const d=this._canvas.getContext("webgl2",v)||this._canvas.getContext("webgl",v);if(!d){const m="Failed to initialize WebGL";throw s?(s.message=m,new Error(JSON.stringify(s))):new Error(m)}this.painter=new yu(d,this.transform),I.testSupport(d)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(v){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||v,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(v){return this._update(),this._renderTaskQueue.add(v)}_cancelRenderFrame(v){this._renderTaskQueue.remove(v)}_render(v){const s=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(v),this._removed)return;let d=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const y=this.transform.zoom,x=E.now();this.style.zoomHistory.update(y,x);const M=new l.z(y,{now:x,fadeDuration:s,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=M.crossFadingFactor();P===1&&P===this._crossFadingFactor||(d=!0,this._crossFadingFactor=P),this.style.update(M)}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,s,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,showPadding:this.showPadding}),this.fire(new l.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.bf.mark(l.bg.load),this.fire(new l.k("load"))),this.style&&(this.style.hasTransitions()||d)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const m=this._sourcesDirty||this._styleDirty||this._placementDirty;return m||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.k("idle")),!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,l.bf.mark(l.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var v;this._hash&&this._hash.remove();for(const d of this._controls)d.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),Z.removeThrottleControl(this._imageQueueHandle),(v=this._resizeObserver)===null||v===void 0||v.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");s!=null&&s.loseContext&&s.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"),l.bf.clearMetrics(),this._removed=!0,this.fire(new l.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,E.frameAsync(this._frameRequest).then(v=>{l.bf.frame(v),this._frameRequest=null,this._render(v)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(v){this._showTileBoundaries!==v&&(this._showTileBoundaries=v,this._update())}get showPadding(){return!!this._showPadding}set showPadding(v){this._showPadding!==v&&(this._showPadding=v,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(v){this._showCollisionBoxes!==v&&(this._showCollisionBoxes=v,v?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(v){this._showOverdrawInspector!==v&&(this._showOverdrawInspector=v,this._update())}get repaint(){return!!this._repaint}set repaint(v){this._repaint!==v&&(this._repaint=v,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(v){this._vertices=v,this._update()}get version(){return Cm}getCameraTargetElevation(){return this.transform.elevation}},u.MapMouseEvent=Oi,u.MapTouchEvent=Zo,u.MapWheelEvent=bm,u.Marker=Mu,u.NavigationControl=class{constructor(v){this._updateZoomButtons=()=>{const s=this._map.getZoom(),d=s===this._map.getMaxZoom(),m=s===this._map.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=m,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",m.toString())},this._rotateCompassArrow=()=>{const s=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=s},this._setButtonTitle=(s,d)=>{const m=this._map._getUIString(`NavigationControl.${d}`);s.title=m,s.setAttribute("aria-label",m)},this.options=l.e({},M_,v),this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",s=>s.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",s=>this._map.zoomIn({},{originalEvent:s})),C.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",s=>this._map.zoomOut({},{originalEvent:s})),C.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",s=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:s}):this._map.resetNorth({},{originalEvent:s})}),this._compassIcon=C.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(v){return this._map=v,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 A_(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(v,s){const d=C.create("button",v,this._container);return d.type="button",d.addEventListener("click",s),d}},u.Popup=class extends l.E{constructor(v){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 l.k("close"))),this),this._onMouseUp=s=>{this._update(s.point)},this._onMouseMove=s=>{this._update(s.point)},this._onDrag=s=>{this._update(s.point)},this._update=s=>{var d;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(const P of this.options.className.split(" "))this._container.classList.add(P);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?Vn(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.wrap(),this._trackPointer&&!s)return;const m=this._flatPos=this._pos=this._trackPointer&&s?s:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&s?s:this._map.transform.locationPoint(this._lngLat));let y=this.options.anchor;const x=Pu(this.options.offset);if(!y){const P=this._container.offsetWidth,O=this._container.offsetHeight;let z;z=m.y+x.bottom.y<O?["top"]:m.y>this._map.transform.height-O?["bottom"]:[],m.x<P/2?z.push("left"):m.x>this._map.transform.width-P/2&&z.push("right"),y=z.length===0?"bottom":z.join("-")}let M=m.add(x[y]);this.options.subpixelPositioning||(M=M.round()),C.setTransform(this._container,`${Ya[y]} translate(${M.x}px,${M.y}px)`),Tu(this._container,y,"popup")},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(Et),v)}addTo(v){return this._map&&this.remove(),this._map=v,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 l.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(v){return this._lngLat=l.N.convert(v),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(v){return this.setDOMContent(document.createTextNode(v))}setHTML(v){const s=document.createDocumentFragment(),d=document.createElement("body");let m;for(d.innerHTML=v;m=d.firstChild,m;)s.appendChild(m);return this.setDOMContent(s)}getMaxWidth(){var v;return(v=this._container)===null||v===void 0?void 0:v.style.maxWidth}setMaxWidth(v){return this.options.maxWidth=v,this._update(),this}setDOMContent(v){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(v),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(v){return this._container&&this._container.classList.add(v),this}removeClassName(v){return this._container&&this._container.classList.remove(v),this}setOffset(v){return this.options.offset=v,this._update(),this}toggleClassName(v){if(this._container)return this._container.classList.toggle(v)}setSubpixelPositioning(v){this.options.subpixelPositioning=v}_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;const v=this._container.querySelector(Au);v&&v.focus()}},u.RasterDEMTileSource=on,u.RasterTileSource=qt,u.ScaleControl=class{constructor(v){this._onMove=()=>{ec(this._map,this._container,this.options)},this.setUnit=s=>{this.options.unit=s,ec(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ps),v)}getDefaultPosition(){return"bottom-left"}onAdd(v){return this._map=v,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-scale",v.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}},u.ScrollZoomHandler=ns,u.Style=tu,u.TerrainControl=class{constructor(v){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=v}onAdd(v){return this._map=v,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}},u.TwoFingersTouchPitchHandler=Ha,u.TwoFingersTouchRotateHandler=Td,u.TwoFingersTouchZoomHandler=Ed,u.TwoFingersTouchZoomRotateHandler=Ad,u.VectorTileSource=pr,u.VideoSource=Or,u.addSourceType=(v,s)=>l._(void 0,void 0,void 0,function*(){if(Cs(v))throw new Error(`A source type called "${v}" already exists.`);((d,m)=>{Es[d]=m})(v,s)}),u.clearPrewarmedResources=function(){const v=Ee;v&&(v.isPreloaded()&&v.numActive()===1?(v.release(zn),Ee=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()"))},u.getMaxParallelImageRequests=function(){return l.a.MAX_PARALLEL_IMAGE_REQUESTS},u.getRTLTextPluginStatus=function(){return Nr().getRTLTextPluginStatus()},u.getVersion=function(){return zd},u.getWorkerCount=function(){return In.workerCount},u.getWorkerUrl=function(){return l.a.WORKER_URL},u.importScriptInWorkers=function(v){return Lt().broadcast("IS",v)},u.prewarm=function(){Ye().acquire(zn)},u.setMaxParallelImageRequests=function(v){l.a.MAX_PARALLEL_IMAGE_REQUESTS=v},u.setRTLTextPlugin=function(v,s){return Nr().setRTLTextPlugin(v,s)},u.setWorkerCount=function(v){In.workerCount=v},u.setWorkerUrl=function(v){l.a.WORKER_URL=v}});var a=t;return a})})(Y1);var MB=Y1.exports;const AB=CB(MB),PB={},IB={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"};function DB(n,e,t,i,r,a){return f.openBlock(),f.createElementBlock("svg",IB,e[0]||(e[0]=[f.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),f.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),f.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const OB=Ue(PB,[["render",DB]]),Cr="widget-map-source",BB={components:{IconClose:OB},props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:50},height:{type:String,default:"400px"}},data(){return{map:null,isOpen:!1,selectedBaseLayer:"graymap",isGeometryVisible:!0,baseLayers:[{id:"graymap",name:"Сіра карта",url:"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",service:"TMS"},{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS"},{id:"osmb",name:"Open Street Map",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",service:"TMS"},{id:"gsv",name:"Google Street View",url:"https://mt2.google.com/vt/?lyrs=svv|cb_client:apiv3&style=50&x={x}&y={y}&z={z}",service:"TMS"}]}},mounted(){this.initMap()},watch:{geometry(){this.initGeometryLayer()}},methods:{initMap(){this.map=new AB.Map({container:this.$refs.mapContainer,style:{version:8,sources:{"base-layer":{type:"raster",tiles:[this.getLayerById(this.selectedBaseLayer).url],tileSize:256}},layers:[{id:"base-layer",type:"raster",source:"base-layer"}]},center:[0,0],zoom:2}),this.map.on("load",()=>{this.geometry&&this.initGeometryLayer(),this.map.resize()})},changeBaseLayer(n){const e=this.map.getSource("base-layer");e&&(e.tiles=[n.url],this.map.style.sourceCaches["base-layer"].clearTiles(),this.map.style.sourceCaches["base-layer"].update(this.map.transform),this.map.triggerRepaint())},getLayerById(n){return this.baseLayers.find(e=>e.id===n)},initGeometryLayer(){const{map:n}=this;if(!n)return;const e=this.formatGeojson(this.geometry),t=n.getSource(Cr);if(this.zoomToGeometry(e),t){t.setData(e);return}n.addSource(Cr,{type:"geojson",data:e}),n.addLayer({id:`${Cr}-point`,type:"circle",source:Cr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),n.addLayer({id:`${Cr}-polygon`,type:"fill",source:Cr,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),n.addLayer({id:`${Cr}-polygon-line`,type:"line",source:Cr,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),n.addLayer({id:`${Cr}-line`,type:"line",source:Cr,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(n){let e=n;const t=n==null?void 0:n.type;if(Array.isArray(n))return Z1(n);if(!t)throw new Error("Unknown geometry type!");return t==="FeatureCollection"?n:(t==="Feature"&&(e=[n]),!["FeatureCollection","Feature"].includes(t)&&(e=[TB(n)]),Z1(e))},zoomToGeometry(n){const{map:e}=this,t=SB(n);e.fitBounds(t,{zoom:this.zoom,padding:30,duration:0})},toggleGeometryVisibility(){[`${Cr}-polygon`,`${Cr}-polygon-line`,`${Cr}-line`,`${Cr}-point`].forEach(e=>{this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.isGeometryVisible?"visible":"none")})}}},NB={class:"relative w-full"},zB={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},RB={class:"border-b p-2 flex items-center justify-between"},LB={class:"flex items-center"},VB=["value","onChange"],FB={class:"ml-2"},$B={key:0,class:"p-2"},jB={class:"flex items-center"};function UB(n,e,t,i,r,a){const u=f.resolveComponent("IconClose");return f.openBlock(),f.createElementBlock("div",NB,[r.isOpen?(f.openBlock(),f.createElementBlock("div",zB,[f.createElementVNode("div",RB,[e[5]||(e[5]=f.createElementVNode("div",null,"Базові шари",-1)),f.createVNode(u,{onClick:e[1]||(e[1]=l=>r.isOpen=!1),class:"h-4 w-4"})]),f.createElementVNode("div",{class:f.normalizeClass(["p-2",{"border-b":t.geometry}])},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(r.baseLayers,l=>(f.openBlock(),f.createElementBlock("div",{key:l.id,class:"mb-2"},[f.createElementVNode("label",LB,[f.withDirectives(f.createElementVNode("input",{type:"radio",name:"base-layer",value:l.id,"onUpdate:modelValue":e[2]||(e[2]=g=>r.selectedBaseLayer=g),onChange:g=>a.changeBaseLayer(l)},null,40,VB),[[f.vModelRadio,r.selectedBaseLayer]]),f.createElementVNode("span",FB,f.toDisplayString(l.name),1)])]))),128))],2),t.geometry?(f.openBlock(),f.createElementBlock("div",$B,[f.createElementVNode("label",jB,[f.withDirectives(f.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[3]||(e[3]=l=>r.isGeometryVisible=l),onChange:e[4]||(e[4]=(...l)=>a.toggleGeometryVisibility&&a.toggleGeometryVisibility(...l))},null,544),[[f.vModelCheckbox,r.isGeometryVisible]]),e[6]||(e[6]=f.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):f.createCommentVNode("",!0)])):(f.openBlock(),f.createElementBlock("div",{key:0,class:"bg-white absolute top-[10px] right-[10px] z-20 p-2 border rounded-lg cursor-pointer",onClick:e[0]||(e[0]=l=>r.isOpen=!0)}," Базові шари ")),f.createElementVNode("div",{ref:"mapContainer",style:f.normalizeStyle({height:t.height,width:"100%"})},null,4)])}const sy=Ue(BB,[["render",UB]]),at=(n,e=1e4)=>(n=parseFloat(n+"")||0,Math.round((n+Number.EPSILON)*e)/e),oy=function(n){if(!(n&&n instanceof Element&&n.offsetParent))return!1;const e=n.scrollHeight>n.clientHeight,t=window.getComputedStyle(n).overflowY,i=t.indexOf("hidden")!==-1,r=t.indexOf("visible")!==-1;return e&&!i&&!r},Lp=function(n,e=void 0){return!(!n||n===document.body||e&&n===e)&&(oy(n)?n:Lp(n.parentElement,e))},Qs=function(n){var e=new DOMParser().parseFromString(n,"text/html").body;if(e.childElementCount>1){for(var t=document.createElement("div");e.firstChild;)t.appendChild(e.firstChild);return t}return e.firstChild},ay=n=>`${n||""}`.split(" ").filter(e=>!!e),eo=(n,e,t)=>{n&&ay(e).forEach(i=>{n.classList.toggle(i,t||!1)})};class Sc{constructor(e){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=e,this.pageX=e.pageX,this.pageY=e.pageY,this.clientX=e.clientX,this.clientY=e.clientY,this.id=self.Touch&&e instanceof Touch?e.identifier:-1,this.time=Date.now()}}const Ec={passive:!1};class HB{constructor(e,{start:t=()=>!0,move:i=()=>{},end:r=()=>{}}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=e,this.startCallback=t,this.moveCallback=i,this.endCallback=r;for(const a of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[a]=this[a].bind(this);this.element.addEventListener("mousedown",this.onPointerStart,Ec),this.element.addEventListener("touchstart",this.onTouchStart,Ec),this.element.addEventListener("touchmove",this.onMove,Ec),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const t=new Sc(e);this.currentPointers.some(i=>i.id===t.id)||this.triggerPointerStart(t,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const t of Array.from(e.changedTouches||[]))this.triggerPointerStart(new Sc(t),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const t=this.currentPointers.slice(),i="changedTouches"in e?Array.from(e.changedTouches||[]).map(a=>new Sc(a)):[new Sc(e)],r=[];for(const a of i){const u=this.currentPointers.findIndex(l=>l.id===a.id);u<0||(r.push(a),this.currentPointers[u]=a)}r.length&&this.moveCallback(e,this.currentPointers.slice(),t)}onPointerEnd(e){e.buttons>0&&e.button!==0||(this.triggerPointerEnd(e,new Sc(e)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(e){for(const t of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new Sc(t))}triggerPointerStart(e,t){return!!this.startCallback(t,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,t){const i=this.currentPointers.findIndex(r=>r.id===t.id);i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(e,t,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const e=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event("touchend",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}),e,this.currentPointers.slice())}}stop(){this.element.removeEventListener("mousedown",this.onPointerStart,Ec),this.element.removeEventListener("touchstart",this.onTouchStart,Ec),this.element.removeEventListener("touchmove",this.onMove,Ec),this.element.removeEventListener("touchend",this.onTouchEnd),this.element.removeEventListener("touchcancel",this.onTouchEnd),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur)}}function X1(n,e){return e?Math.sqrt(Math.pow(e.clientX-n.clientX,2)+Math.pow(e.clientY-n.clientY,2)):0}function K1(n,e){return e?{clientX:(n.clientX+e.clientX)/2,clientY:(n.clientY+e.clientY)/2}:n}const ly=n=>typeof n=="object"&&n!==null&&n.constructor===Object&&Object.prototype.toString.call(n)==="[object Object]",Tr=(n,...e)=>{const t=e.length;for(let i=0;i<t;i++){const r=e[i]||{};Object.entries(r).forEach(([a,u])=>{const l=Array.isArray(u)?[]:{};n[a]||Object.assign(n,{[a]:l}),ly(u)?Object.assign(n[a],Tr(l,u)):Array.isArray(u)?Object.assign(n,{[a]:[...u]}):Object.assign(n,{[a]:u})})}return n},cy=function(n,e){return n.split(".").reduce((t,i)=>typeof t=="object"?t[i]:void 0,e)};class Vp{constructor(e={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(e);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith("on")&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}setOptions(e){this.options=e?Tr({},this.constructor.defaults,e):{};for(const[t,i]of Object.entries(this.option("on")||{}))this.on(t,i)}option(e,...t){let i=cy(e,this.options);return i&&typeof i=="function"&&(i=i.call(this,this,...t)),i}optionFor(e,t,i,...r){let a=cy(t,e);var u;typeof(u=a)!="string"||isNaN(u)||isNaN(parseFloat(u))||(a=parseFloat(a)),a==="true"&&(a=!0),a==="false"&&(a=!1),a&&typeof a=="function"&&(a=a.call(this,this,e,...r));let l=cy(t,this.options);return l&&typeof l=="function"?a=l.call(this,this,e,...r,a):a===void 0&&(a=l),a===void 0?i:a}cn(e){const t=this.options.classes;return t&&t[e]||""}localize(e,t=[]){e=String(e).replace(/\{\{(\w+).?(\w+)?\}\}/g,(i,r,a)=>{let u="";return a?u=this.option(`${r[0]+r.toLowerCase().substring(1)}.l10n.${a}`):r&&(u=this.option(`l10n.${r}`)),u||(u=i),u});for(let i=0;i<t.length;i++)e=e.split(t[i][0]).join(t[i][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(i,r)=>r)}on(e,t){let i=[];typeof e=="string"?i=e.split(" "):Array.isArray(e)&&(i=e),this.events||(this.events=new Map),i.forEach(r=>{let a=this.events.get(r);a||(this.events.set(r,[]),a=[]),a.includes(t)||a.push(t),this.events.set(r,a)})}off(e,t){let i=[];typeof e=="string"?i=e.split(" "):Array.isArray(e)&&(i=e),i.forEach(r=>{const a=this.events.get(r);if(Array.isArray(a)){const u=a.indexOf(t);u>-1&&a.splice(u,1)}})}emit(e,...t){[...this.events.get(e)||[]].forEach(i=>i(this,...t)),e!=="*"&&this.emit("*",e,...t)}}Object.defineProperty(Vp,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(Vp,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class uy extends Vp{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const t=new Map;for(const[i,r]of Object.entries(e)){const a=this.option(i),u=this.plugins[i];u||a===!1?u&&a===!1&&(u.detach(),delete this.plugins[i]):t.set(i,new r(this,a||{}))}for(const[i,r]of t)this.plugins[i]=r,r.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const t of e){const i=this.plugins[t];i&&i.detach(),delete this.plugins[t]}return this.emit("detachPlugins"),this}}var Pn;(function(n){n[n.Init=0]="Init",n[n.Error=1]="Error",n[n.Ready=2]="Ready",n[n.Panning=3]="Panning",n[n.Mousemove=4]="Mousemove",n[n.Destroy=5]="Destroy"})(Pn||(Pn={}));const Po=["a","b","c","d","e","f"],J1={PANUP:"Move up",PANDOWN:"Move down",PANLEFT:"Move left",PANRIGHT:"Move right",ZOOMIN:"Zoom in",ZOOMOUT:"Zoom out",TOGGLEZOOM:"Toggle zoom level",TOGGLE1TO1:"Toggle zoom level",ITERATEZOOM:"Toggle zoom level",ROTATECCW:"Rotate counterclockwise",ROTATECW:"Rotate clockwise",FLIPX:"Flip horizontally",FLIPY:"Flip vertically",FITX:"Fit horizontally",FITY:"Fit vertically",RESET:"Reset",TOGGLEFS:"Toggle fullscreen"},qB={content:null,width:"auto",height:"auto",panMode:"drag",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:"auto",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:"toggleZoom",dblClick:!1,wheel:"zoom",wheelLimit:7,spinner:!0,bounds:"auto",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:"f-panzoom__content",isLoading:"is-loading",canZoomIn:"can-zoom_in",canZoomOut:"can-zoom_out",isDraggable:"is-draggable",isDragging:"is-dragging",inFullscreen:"in-fullscreen",htmlHasFullscreen:"with-panzoom-in-fullscreen"},l10n:J1},Q1='<circle cx="25" cy="25" r="20"></circle>',hy='<div class="f-spinner"><svg viewBox="0 0 50 50">'+Q1+Q1+"</svg></div>",Mr=n=>n&&n!==null&&n instanceof Element&&"nodeType"in n,En=(n,e)=>{n&&ay(e).forEach(t=>{n.classList.remove(t)})},Ct=(n,e)=>{n&&ay(e).forEach(t=>{n.classList.add(t)})},Fp={a:1,b:0,c:0,d:1,e:0,f:0},WB=1e5,$p=1e4,fs="mousemove",ev="drag",tv="content",ms="auto";let dy=null,py=null;class ua extends uy{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return py===null&&(py=window.matchMedia("(hover: none)").matches),py}get isMobile(){return dy===null&&(dy=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),dy}get panMode(){return this.options.panMode!==fs||this.isTouchDevice?ev:fs}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===ms?this.isTouchDevice:e}get isInfinite(){return this.option("infinite")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:e,b:t}=this.current;return Math.sqrt(e*e+t*t)||1}get targetScale(){const{a:e,b:t}=this.target;return Math.sqrt(e*e+t*t)||1}get minScale(){return this.option("minScale")||1}get fullScale(){const{contentRect:e}=this;return e.fullWidth/e.fitWidth||1}get maxScale(){return this.fullScale*(this.option("maxScale")||1)||1}get coverScale(){const{containerRect:e,contentRect:t}=this,i=Math.max(e.height/t.fitHeight,e.width/t.fitWidth)||1;return Math.min(this.fullScale,i)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const e=this.content;return!!(e&&e instanceof HTMLImageElement)&&!e.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const e of Po){const t=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>t)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,t={},i={}){var r;if(super(t),Object.defineProperty(this,"pointerTracker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"resizeObserver",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"updateTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rAF",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isTicking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreBounds",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingX",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingY",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"clicks",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"trackingPoints",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pwt",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"cwd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pmme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"friction",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Pn.Init}),Object.defineProperty(this,"isDragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"spinner",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"containerRect",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,"contentRect",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,"dragStart",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,"dragOffset",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,"current",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},Fp)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},Fp)}),Object.defineProperty(this,"velocity",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,"lockedAxis",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!e)throw new Error("Container Element Not Found");this.container=e,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},ua.Plugins),i)),this.emit("attachPlugins"),this.emit("init");const a=this.content;if(a.addEventListener("load",this.onLoad),a.addEventListener("error",this.onError),this.isContentLoading){if(this.option("spinner")){e.classList.add(this.cn("isLoading"));const u=Qs(hy);!e.contains(a)||a.parentElement instanceof HTMLPictureElement?this.spinner=e.appendChild(u):this.spinner=((r=a.parentElement)===null||r===void 0?void 0:r.insertBefore(u,a))||null}this.emit("beforeLoad")}else queueMicrotask(()=>{this.enable()})}initContent(){const{container:e}=this,t=this.cn(tv);let i=this.option(tv)||e.querySelector(`.${t}`);if(i||(i=e.querySelector("img,picture")||e.firstElementChild,i&&Ct(i,t)),i instanceof HTMLPictureElement&&(i=i.querySelector("img")),!i)throw new Error("No content found");this.content=i}onLoad(){const{spinner:e,container:t,state:i}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&t.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),i===Pn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Pn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Pn.Error,this.emit("error"))}getNextScale(e){const{fullScale:t,targetScale:i,coverScale:r,maxScale:a,minScale:u}=this;let l=u;switch(e){case"toggleMax":l=i-u<.5*(a-u)?a:u;break;case"toggleCover":l=i-u<.5*(r-u)?r:u;break;case"toggleZoom":l=i-u<.5*(t-u)?t:u;break;case"iterateZoom":let g=[1,t,a].sort((k,E)=>k-E),b=g.findIndex(k=>k>i+1e-5);l=g[b]||1}return l}attachObserver(){var e;const t=()=>{const{container:i,containerRect:r}=this;return Math.abs(r.width-i.getBoundingClientRect().width)>.1||Math.abs(r.height-i.getBoundingClientRect().height)>.1};this.resizeObserver||window.ResizeObserver===void 0||(this.resizeObserver=new ResizeObserver(()=>{this.updateTimer||(t()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{t()&&this.onResize(),this.updateTimer=null},500))):this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null))})),(e=this.resizeObserver)===null||e===void 0||e.observe(this.container)}detachObserver(){var e;(e=this.resizeObserver)===null||e===void 0||e.disconnect()}attachEvents(){const{container:e}=this;e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("wheel",this.onWheel,{passive:!1}),this.pointerTracker=new HB(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(fs,this.onMouseMove)}detachEvents(){var e;const{container:t}=this;t.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),t.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(fs,this.onMouseMove),document.removeEventListener("keydown",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){this.setTargetForce();const e=this.friction,t=this.option("maxVelocity");for(const i of Po)e?(this.velocity[i]*=1-e,t&&!this.isScaling&&(this.velocity[i]=Math.max(Math.min(this.velocity[i],t),-1*t)),this.current[i]+=this.velocity[i]):this.current[i]=this.target[i];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame(()=>this.animate()):this.stop("current")}setTargetForce(){for(const e of Po)e==="e"&&this.isBouncingX||e==="f"&&this.isBouncingY||(this.velocity[e]=(1/(1-this.friction)-1)*(this.target[e]-this.current[e]))}checkBounds(e=0,t=0){const{current:i}=this,r=i.e+e,a=i.f+t,u=this.getBounds(),{x:l,y:g}=u,b=l.min,k=l.max,E=g.min,C=g.max;let I=0,D=0;return b!==1/0&&r<b?I=b-r:k!==1/0&&r>k&&(I=k-r),E!==1/0&&a<E?D=E-a:C!==1/0&&a>C&&(D=C-a),Math.abs(I)<1e-4&&(I=0),Math.abs(D)<1e-4&&(D=0),Object.assign(Object.assign({},u),{xDiff:I,yDiff:D,inBounds:!I&&!D})}clampTargetBounds(){const{target:e}=this,{x:t,y:i}=this.getBounds();t.min!==1/0&&(e.e=Math.max(e.e,t.min)),t.max!==1/0&&(e.e=Math.min(e.e,t.max)),i.min!==1/0&&(e.f=Math.max(e.f,i.min)),i.max!==1/0&&(e.f=Math.min(e.f,i.max))}calculateContentDim(e=this.current){const{content:t,contentRect:i}=this,{fitWidth:r,fitHeight:a,fullWidth:u,fullHeight:l}=i;let g=u,b=l;if(this.option("zoom")||this.angle!==0){const k=!(t instanceof HTMLImageElement)&&(window.getComputedStyle(t).maxWidth==="none"||window.getComputedStyle(t).maxHeight==="none"),E=k?u:r,C=k?l:a,I=this.getMatrix(e),D=new DOMPoint(0,0).matrixTransform(I),R=new DOMPoint(0+E,0).matrixTransform(I),$=new DOMPoint(0+E,0+C).matrixTransform(I),G=new DOMPoint(0,0+C).matrixTransform(I),te=Math.abs($.x-D.x),Z=Math.abs($.y-D.y),Q=Math.abs(G.x-R.x),Me=Math.abs(G.y-R.y);g=Math.max(te,Q),b=Math.max(Z,Me)}return{contentWidth:g,contentHeight:b}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===fs||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:t,y:i,xDiff:r,yDiff:a}=this.checkBounds(),u=this.option("maxVelocity");let l=this.velocity.e,g=this.velocity.f;r!==0?(this.isBouncingX=!0,r*l<=0?l+=.14*r:(l=.14*r,t.min!==1/0&&(this.target.e=Math.max(e.e,t.min)),t.max!==1/0&&(this.target.e=Math.min(e.e,t.max))),u&&(l=Math.max(Math.min(l,u),-1*u))):this.isBouncingX=!1,a!==0?(this.isBouncingY=!0,a*g<=0?g+=.14*a:(g=.14*a,i.min!==1/0&&(this.target.f=Math.max(e.f,i.min)),i.max!==1/0&&(this.target.f=Math.min(e.f,i.max))),u&&(g=Math.max(Math.min(g,u),-1*u))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=l),this.isBouncingY&&(this.velocity.f=g)}enable(){const{content:e}=this,t=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const i of Po)this.current[i]=this.target[i]=t[i];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Pn.Ready,this.emit("ready")}onClick(e){var t;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((t=this.pointerTracker)===null||t===void 0||t.clear(),this.trackingPoints=[],this.startDecelAnim());const i=e.target;if(!i||e.defaultPrevented)return;if(i.hasAttribute("disabled"))return e.preventDefault(),void e.stopPropagation();if((()=>{const I=window.getSelection();return I&&I.type==="Range"})()&&!i.closest("button"))return;const r=i.closest("[data-panzoom-action]"),a=i.closest("[data-panzoom-change]"),u=r||a,l=u&&Mr(u)?u.dataset:null;if(l){const I=l.panzoomChange,D=l.panzoomAction;if((I||D)&&e.preventDefault(),I){let R={};try{R=JSON.parse(I)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(R)}if(D)return void(this[D]&&this[D]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return e.preventDefault(),void e.stopPropagation();if(i.closest("[data-fancybox]"))return;const g=this.content.getBoundingClientRect(),b=this.dragStart;if(b.time&&!this.canZoomOut()&&(Math.abs(g.x-b.x)>2||Math.abs(g.y-b.y)>2))return;this.dragStart.time=0;const k=I=>{this.option("zoom",e)&&I&&typeof I=="string"&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(I)&&typeof this[I]=="function"&&(e.preventDefault(),this[I]({event:e}))},E=this.option("click",e),C=this.option("dblClick",e);C?(this.clicks++,this.clicks==1&&(this.clickTimer=setTimeout(()=>{this.clicks===1?(this.emit("click",e),!e.defaultPrevented&&E&&k(E)):(this.emit("dblClick",e),e.defaultPrevented||k(C)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&E&&k(E))}addTrackingPoint(e){const t=this.trackingPoints.filter(i=>i.time>Date.now()-100);t.push(e),this.trackingPoints=t}onPointerDown(e,t,i){var r;if(this.option("touch",e)===!1)return!1;this.pwt=0,this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const a=this.content.getBoundingClientRect();if(this.dragStart={x:a.x,y:a.y,top:a.top,left:a.left,time:Date.now()},this.clickTimer)return!1;if(this.panMode===fs&&this.targetScale>1)return e.preventDefault(),e.stopPropagation(),!1;const u=e.composedPath()[0];if(!i.length){if(["TEXTAREA","OPTION","INPUT","SELECT","VIDEO","IFRAME"].includes(u.nodeName)||u.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]"))return!1;(r=window.getSelection())===null||r===void 0||r.removeAllRanges()}if(e.type==="mousedown")["A","BUTTON"].includes(u.nodeName)||e.preventDefault();else if(Math.abs(this.velocity.a)>.3)return!1;return this.target.e=this.current.e,this.target.f=this.current.f,this.stop(),this.isDragging||(this.isDragging=!0,this.addTrackingPoint(t),this.emit("touchStart",e)),!0}onPointerMove(e,t,i){if(this.option("touch",e)===!1||!this.isDragging||t.length<2&&this.panOnlyZoomed&&at(this.targetScale)<=at(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(t[0]);const{content:r}=this,a=K1(i[0],i[1]),u=K1(t[0],t[1]);let l=0,g=0;if(t.length>1){const Z=r.getBoundingClientRect();l=a.clientX-Z.left-.5*Z.width,g=a.clientY-Z.top-.5*Z.height}const b=X1(i[0],i[1]),k=X1(t[0],t[1]);let E=b?k/b:1,C=u.clientX-a.clientX,I=u.clientY-a.clientY;this.dragOffset.x+=C,this.dragOffset.y+=I,this.dragOffset.time=Date.now()-this.dragStart.time;let D=at(this.targetScale)===at(this.minScale)&&this.option("lockAxis");if(D&&!this.lockedAxis)if(D==="xy"||D==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const Z=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=Z>45&&Z<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,C=0,I=0}else this.lockedAxis=D;if(Lp(e.target,this.content)&&(D="x",this.dragOffset.y=0),D&&D!=="xy"&&this.lockedAxis!==D&&at(this.targetScale)===at(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const R=this.checkBounds(C,I);this.option("rubberband")?(this.isInfinite!=="x"&&(R.xDiff>0&&C<0||R.xDiff<0&&C>0)&&(C*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*R.xDiff))),this.isInfinite!=="y"&&(R.yDiff>0&&I<0||R.yDiff<0&&I>0)&&(I*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*R.yDiff)))):(R.xDiff&&(C=0),R.yDiff&&(I=0));const $=this.targetScale,G=this.minScale,te=this.maxScale;$<.5*G&&(E=Math.max(E,G)),$>1.5*te&&(E=Math.min(E,te)),this.lockedAxis==="y"&&at($)===at(G)&&(C=0),this.lockedAxis==="x"&&at($)===at(G)&&(I=0),this.applyChange({originX:l,originY:g,panX:C,panY:I,scale:E,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,t,i){if(i.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn("isDragging")),this.isDragging&&(this.addTrackingPoint(t),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),Lp(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Pn.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const t=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const Z of Po)this.velocity[Z]=0;this.target.e=this.current.e,this.target.f=this.current.f,En(this.container,"is-scaling"),En(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:i}=this,r=i[0],a=i[i.length-1];let u=0,l=0,g=0;a&&r&&(u=a.clientX-r.clientX,l=a.clientY-r.clientY,g=a.time-r.time);const b=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;b!==1&&(u*=b,l*=b);let k=0,E=0,C=0,I=0,D=this.option("decelFriction");const R=this.targetScale;if(g>0){C=Math.abs(u)>3?u/(g/30):0,I=Math.abs(l)>3?l/(g/30):0;const Z=this.option("maxVelocity");Z&&(C=Math.max(Math.min(C,Z),-1*Z),I=Math.max(Math.min(I,Z),-1*Z))}C&&(k=C/(1/(1-D)-1)),I&&(E=I/(1/(1-D)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&at(R)===this.minScale)&&(k=C=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&at(R)===this.minScale)&&(E=I=0);const $=this.dragOffset.x,G=this.dragOffset.y,te=this.option("dragMinThreshold")||0;Math.abs($)<te&&Math.abs(G)<te&&(k=E=0,C=I=0),(this.option("zoom")&&(R<this.minScale-1e-5||R>this.maxScale+1e-5)||t&&!k&&!E)&&(D=.35),this.applyChange({panX:k,panY:E,friction:D}),this.emit("decel",C,I,$,G)}onWheel(e){var t=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(a,u){return Math.abs(u)>Math.abs(a)?u:a});const i=Math.max(-1,Math.min(1,t));if(this.emit("wheel",e,i),this.panMode===fs||e.defaultPrevented)return;const r=this.option("wheel");r==="pan"?(e.preventDefault(),this.panOnlyZoomed&&!this.canZoomOut()||this.applyChange({panX:2*-e.deltaX,panY:2*-e.deltaY,bounce:!1})):r==="zoom"&&this.option("zoom")!==!1&&this.zoomWithWheel(e)}onMouseMove(e){this.panWithMouse(e)}onKeydown(e){e.key==="Escape"&&this.toggleFS()}onResize(){this.updateMetrics(),this.checkBounds().inBounds||this.requestTick()}setTransform(){this.emit("beforeTransform");const{current:e,target:t,content:i,contentRect:r}=this,a=Object.assign({},Fp);for(const $ of Po){const G=$=="e"||$==="f"?$p:WB;a[$]=at(e[$],G),Math.abs(t[$]-e[$])<($=="e"||$==="f"?.51:.001)&&(e[$]=t[$])}let{a:u,b:l,c:g,d:b,e:k,f:E}=a,C=`matrix(${u}, ${l}, ${g}, ${b}, ${k}, ${E})`,I=i.parentElement instanceof HTMLPictureElement?i.parentElement:i;if(this.option("transformParent")&&(I=I.parentElement||I),I.style.transform===C)return;I.style.transform=C;const{contentWidth:D,contentHeight:R}=this.calculateContentDim();r.width=D,r.height=R,this.emit("afterTransform")}updateMetrics(e=!1){var t;if(!this||this.state===Pn.Destroy||this.isContentLoading)return;const i=Math.max(1,((t=window.visualViewport)===null||t===void 0?void 0:t.scale)||1),{container:r,content:a}=this,u=a instanceof HTMLImageElement,l=r.getBoundingClientRect(),g=getComputedStyle(this.container);let b=l.width*i,k=l.height*i;const E=parseFloat(g.paddingTop)+parseFloat(g.paddingBottom),C=b-(parseFloat(g.paddingLeft)+parseFloat(g.paddingRight)),I=k-E;this.containerRect={width:b,height:k,innerWidth:C,innerHeight:I};const D=parseFloat(a.dataset.width||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalWidth:rt instanceof SVGElement?rt.width.baseVal.value:Math.max(rt.offsetWidth,rt.scrollWidth),Tt||0})(a),R=parseFloat(a.dataset.height||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalHeight:rt instanceof SVGElement?rt.height.baseVal.value:Math.max(rt.offsetHeight,rt.scrollHeight),Tt||0})(a);let $=this.option("width",D)||ms,G=this.option("height",R)||ms;const te=$===ms,Z=G===ms;typeof $!="number"&&($=D),typeof G!="number"&&(G=R),te&&($=D*(G/R)),Z&&(G=R/(D/$));let Q=a.parentElement instanceof HTMLPictureElement?a.parentElement:a;this.option("transformParent")&&(Q=Q.parentElement||Q);const Me=Q.getAttribute("style")||"";Q.style.setProperty("transform","none","important"),u&&(Q.style.width="",Q.style.height=""),Q.offsetHeight;const ke=a.getBoundingClientRect();let Ae=ke.width*i,Fe=ke.height*i,Ne=Ae,dt=Fe;Ae=Math.min(Ae,$),Fe=Math.min(Fe,G),u?{width:Ae,height:Fe}=((rt,Tt,zt,Vt)=>{const Ft=zt/rt,Ht=Vt/Tt,Cn=Math.min(Ft,Ht);return{width:rt*=Cn,height:Tt*=Cn}})($,G,Ae,Fe):(Ae=Math.min(Ae,$),Fe=Math.min(Fe,G));let tt=.5*(dt-Fe),Nt=.5*(Ne-Ae);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ke.top-l.top+tt,bottom:l.bottom-ke.bottom+tt,left:ke.left-l.left+Nt,right:l.right-ke.right+Nt,fitWidth:Ae,fitHeight:Fe,width:Ae,height:Fe,fullWidth:$,fullHeight:G}),Q.style.cssText=Me,u&&(Q.style.width=`${Ae}px`,Q.style.height=`${Fe}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(at(this.targetScale)<at(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Pn.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:t}=this.calculateContentDim(this.target),{targetScale:i,lockedAxis:r}=this,{fitWidth:a,fitHeight:u}=this.contentRect;let l=0,g=0,b=0,k=0;const E=this.option("infinite");if(E===!0||r&&E===r)l=-1/0,b=1/0,g=-1/0,k=1/0;else{let{containerRect:C,contentRect:I}=this,D=at(a*i,$p),R=at(u*i,$p),{innerWidth:$,innerHeight:G}=C;if(C.width===D&&($=C.width),C.width===R&&(G=C.height),e>$){b=.5*(e-$),l=-1*b;let te=.5*(I.right-I.left);l+=te,b+=te}if(a>$&&e<$&&(l-=.5*(a-$),b-=.5*(a-$)),t>G){k=.5*(t-G),g=-1*k;let te=.5*(I.bottom-I.top);g+=te,k+=te}u>G&&t<G&&(l-=.5*(u-G),b-=.5*(u-G))}return{x:{min:l,max:b},y:{min:g,max:k}}}getBounds(){const e=this.option("bounds");return e!==ms?e:this.calculateBounds()}updateControls(){const e=this,t=e.container,{panMode:i,contentRect:r,targetScale:a,minScale:u}=e;let l=u,g=e.option("click")||!1;g&&(l=e.getNextScale(g));let b=e.canZoomIn(),k=e.canZoomOut(),E=i===ev&&!!this.option("touch"),C=k&&E;if(E&&(at(a)<at(u)&&!this.panOnlyZoomed&&(C=!0),(at(r.width,1)>at(r.fitWidth,1)||at(r.height,1)>at(r.fitHeight,1))&&(C=!0)),at(r.width*a,1)<at(r.fitWidth,1)&&(C=!1),i===fs&&(C=!1),eo(t,this.cn("isDraggable"),C),!this.option("zoom"))return;let I=b&&at(l)>at(a),D=!I&&!C&&k&&at(l)<at(a);eo(t,this.cn("canZoomIn"),I),eo(t,this.cn("canZoomOut"),D);for(const R of t.querySelectorAll("[data-panzoom-action]")){let $=!1,G=!1;switch(R.dataset.panzoomAction){case"zoomIn":b?$=!0:G=!0;break;case"zoomOut":k?$=!0:G=!0;break;case"toggleZoom":case"iterateZoom":b||k?$=!0:G=!0;const te=R.querySelector("g");te&&(te.style.display=b?"":"none")}$?(R.removeAttribute("disabled"),R.removeAttribute("tabindex")):G&&(R.setAttribute("disabled",""),R.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:t=this.target.f,scale:i=this.targetScale,friction:r=this.option("friction"),angle:a=0,originX:u=0,originY:l=0,flipX:g=!1,flipY:b=!1,ignoreBounds:k=!1}){this.state!==Pn.Destroy&&this.applyChange({panX:e-this.target.e,panY:t-this.target.f,scale:i/this.targetScale,angle:a,originX:u,originY:l,friction:r,flipX:g,flipY:b,ignoreBounds:k})}applyChange({panX:e=0,panY:t=0,scale:i=1,angle:r=0,originX:a=-this.current.e,originY:u=-this.current.f,friction:l=this.option("friction"),flipX:g=!1,flipY:b=!1,ignoreBounds:k=!1,bounce:E=this.option("bounce")}){const C=this.state;if(C===Pn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=l||0,this.ignoreBounds=k;const{current:I}=this,D=I.e,R=I.f,$=this.getMatrix(this.target);let G=new DOMMatrix().translate(D,R).translate(a,u).translate(e,t);if(this.option("zoom")){if(!k){const te=this.targetScale,Z=this.minScale,Q=this.maxScale;te*i<Z&&(i=Z/te),te*i>Q&&(i=Q/te)}G=G.scale(i)}G=G.translate(-a,-u).translate(-D,-R).multiply($),r&&(G=G.rotate(r)),g&&(G=G.scale(-1,1)),b&&(G=G.scale(1,-1));for(const te of Po)te!=="e"&&te!=="f"&&(G[te]>this.minScale+1e-5||G[te]<this.minScale-1e-5)?this.target[te]=G[te]:this.target[te]=at(G[te],$p);(this.targetScale<this.scale||Math.abs(i-1)>.1||this.panMode===fs||E===!1)&&!k&&this.clampTargetBounds(),C===Pn.Init?this.animate():this.isResting||(this.state=Pn.Panning,this.requestTick())}stop(e=!1){if(this.state===Pn.Init||this.state===Pn.Destroy)return;const t=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const i of Po)this.velocity[i]=0,e==="current"?this.current[i]=this.target[i]:e==="target"&&(this.target[i]=this.current[i]);this.setTransform(),En(this.container,"is-scaling"),En(this.container,"is-animating"),this.isTicking=!1,this.state=Pn.Ready,t&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),Ct(this.container,"is-animating"),this.isScaling&&Ct(this.container,"is-scaling")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame(()=>this.animate()))}panWithMouse(e,t=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==fs||!e||at(this.targetScale)<=at(this.minScale))return;this.emit("mouseMove",e);const{container:i,containerRect:r,contentRect:a}=this,u=r.width,l=r.height,g=i.getBoundingClientRect(),b=(e.clientX||0)-g.left,k=(e.clientY||0)-g.top;let{contentWidth:E,contentHeight:C}=this.calculateContentDim(this.target);const I=this.option("mouseMoveFactor");I>1&&(E!==u&&(E*=I),C!==l&&(C*=I));let D=.5*(E-u)-b/u*100/100*(E-u);D+=.5*(a.right-a.left);let R=.5*(C-l)-k/l*100/100*(C-l);R+=.5*(a.bottom-a.top),this.applyChange({panX:D-this.target.e,panY:R-this.target.f,friction:t})}zoomWithWheel(e){if(this.state===Pn.Destroy||this.state===Pn.Init)return;const t=Date.now();if(t-this.pwt<45)return void e.preventDefault();this.pwt=t;var i=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(b,k){return Math.abs(k)>Math.abs(b)?k:b});const r=Math.max(-1,Math.min(1,i)),{targetScale:a,maxScale:u,minScale:l}=this;let g=a*(100+45*r)/100;at(g)<at(l)&&at(a)<=at(l)?(this.cwd+=Math.abs(r),g=l):at(g)>at(u)&&at(a)>=at(u)?(this.cwd+=Math.abs(r),g=u):(this.cwd=0,g=Math.max(Math.min(g,u),l)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),at(g)!==at(a)&&this.zoomTo(g,{event:e}))}canZoomIn(){return this.option("zoom")&&(at(this.contentRect.width,1)<at(this.contentRect.fitWidth,1)||at(this.targetScale)<at(this.maxScale))}canZoomOut(){return this.option("zoom")&&at(this.targetScale)>at(this.minScale)}zoomIn(e=1.25,t){this.zoomTo(this.targetScale*e,t)}zoomOut(e=.8,t){this.zoomTo(this.targetScale*e,t)}zoomToFit(e){this.zoomTo("fit",e)}zoomToCover(e){this.zoomTo("cover",e)}zoomToFull(e){this.zoomTo("full",e)}zoomToMax(e){this.zoomTo("max",e)}toggleZoom(e){this.zoomTo(this.getNextScale("toggleZoom"),e)}toggleMax(e){this.zoomTo(this.getNextScale("toggleMax"),e)}toggleCover(e){this.zoomTo(this.getNextScale("toggleCover"),e)}iterateZoom(e){this.zoomTo("next",e)}zoomTo(e=1,{friction:t=ms,originX:i=ms,originY:r=ms,event:a}={}){if(this.isContentLoading||this.state===Pn.Destroy)return;const{targetScale:u,fullScale:l,maxScale:g,coverScale:b}=this;if(this.stop(),this.panMode===fs&&(a=this.pmme||a),a||i===ms||r===ms){const E=this.content.getBoundingClientRect(),C=this.container.getBoundingClientRect(),I=a?a.clientX:C.left+.5*C.width,D=a?a.clientY:C.top+.5*C.height;i=I-E.left-.5*E.width,r=D-E.top-.5*E.height}let k=1;typeof e=="number"?k=e:e==="full"?k=l:e==="cover"?k=b:e==="max"?k=g:e==="fit"?k=1:e==="next"&&(k=this.getNextScale("iterateZoom")),k=k/u||1,t=t===ms?k>1?.15:.25:t,this.applyChange({scale:k,originX:i,originY:r,friction:t}),a&&this.panMode===fs&&this.panWithMouse(a,t)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop("target");const{containerRect:e,contentRect:t,target:i}=this;this.applyChange({panX:.5*e.width-(t.left+.5*t.fitWidth)-i.e,panY:.5*e.height-(t.top+.5*t.fitHeight)-i.f,scale:e.width/t.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:t,target:i}=this;this.applyChange({panX:.5*e.width-(t.left+.5*t.fitWidth)-i.e,panY:.5*e.innerHeight-(t.top+.5*t.fitHeight)-i.f,scale:e.height/t.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,t=this.cn("inFullscreen"),i=this.cn("htmlHasFullscreen");e.classList.toggle(t);const r=e.classList.contains(t);r?(document.documentElement.classList.add(i),document.addEventListener("keydown",this.onKeydown,!0)):(document.documentElement.classList.remove(i),document.removeEventListener("keydown",this.onKeydown,!0)),this.updateMetrics(),this.emit(r?"enterFS":"exitFS")}getMatrix(e=this.current){const{a:t,b:i,c:r,d:a,e:u,f:l}=e;return new DOMMatrix([t,i,r,a,u,l])}reset(e){if(this.state!==Pn.Init&&this.state!==Pn.Destroy){this.stop("current");for(const t of Po)this.target[t]=Fp[t];this.target.a=this.minScale,this.target.d=this.minScale,this.clampTargetBounds(),this.isResting||(this.friction=e===void 0?this.option("friction"):e,this.state=Pn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Pn.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:t}=this,i=this.option("classes")||{};for(const r of Object.values(i))e.classList.remove(r+"");t&&(t.removeEventListener("load",this.onLoad),t.removeEventListener("error",this.onError)),this.detachPlugins()}}Object.defineProperty(ua,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:qB}),Object.defineProperty(ua,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const nv=function(n,e){let t=!0;return(...i)=>{t&&(t=!1,n(...i),setTimeout(()=>{t=!0},e))}},iv=(n,e)=>{let t=[];return n.childNodes.forEach(i=>{i.nodeType!==Node.ELEMENT_NODE||e&&!i.matches(e)||t.push(i)}),t},GB={viewport:null,track:null,enabled:!0,slides:[],axis:"x",transition:"fade",preload:1,slidesPerPage:"auto",initialPage:0,friction:.12,Panzoom:{decelFriction:.12},center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:"ltr",classes:{container:"f-carousel",viewport:"f-carousel__viewport",track:"f-carousel__track",slide:"f-carousel__slide",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",inTransition:"in-transition",isSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide #%d"}};var di;(function(n){n[n.Init=0]="Init",n[n.Ready=1]="Ready",n[n.Destroy=2]="Destroy"})(di||(di={}));const fy=n=>{if(typeof n=="string"||n instanceof HTMLElement)n={html:n};else{const e=n.thumb;e!==void 0&&(typeof e=="string"&&(n.thumbSrc=e),e instanceof HTMLImageElement&&(n.thumbEl=e,n.thumbElSrc=e.src,n.thumbSrc=e.src),delete n.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},n)},ZB=(n={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},n);class Vs extends Vp{constructor(e,t){super(t),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}}const YB={classes:{list:"f-carousel__dots",isDynamic:"is-dynamic",hasDots:"has-dots",dot:"f-carousel__dot",isBeforePrev:"is-before-prev",isPrev:"is-prev",isCurrent:"is-current",isNext:"is-next",isAfterNext:"is-after-next"},dotTpl:'<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>',dynamicFrom:11,maxCount:1/0,minCount:2};class rv extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"isDynamic",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let e=this.list;if(!e){e=document.createElement("ul"),Ct(e,this.cn("list")),e.setAttribute("role","tablist");const t=this.instance.container;t.appendChild(e),Ct(t,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const t=this.instance.pages.length,i=Math.min(2,this.option("minCount")),r=Math.max(2e3,this.option("maxCount")),a=this.option("dynamicFrom");if(t<i||t>r)return void this.cleanup();const u=typeof a=="number"&&t>5&&t>=a,l=!this.list||this.isDynamic!==u||this.list.children.length!==t;l&&this.cleanup();const g=this.build();if(eo(g,this.cn("isDynamic"),!!u),l)for(let E=0;E<t;E++)g.append(this.createItem(E));let b,k=0;for(const E of[...g.children]){const C=k===this.instance.page;C&&(b=E),eo(E,this.cn("isCurrent"),C),(e=E.children[0])===null||e===void 0||e.setAttribute("aria-selected",C?"true":"false");for(const I of["isBeforePrev","isPrev","isNext","isAfterNext"])En(E,this.cn(I));k++}if(b=b||g.firstChild,u&&b){const E=b.previousElementSibling,C=E&&E.previousElementSibling;Ct(E,this.cn("isPrev")),Ct(C,this.cn("isBeforePrev"));const I=b.nextElementSibling,D=I&&I.nextElementSibling;Ct(I,this.cn("isNext")),Ct(D,this.cn("isAfterNext"))}this.isDynamic=u}createItem(e=0){var t;const i=document.createElement("li");i.setAttribute("role","presentation");const r=Qs(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return i.appendChild(r),(t=i.children[0])===null||t===void 0||t.setAttribute("role","tab"),i}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,En(this.instance.container,this.cn("hasDots"))}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}}Object.defineProperty(rv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:YB});const jp="disabled",Up="next",sv="prev";class ov extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"prev",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"next",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isDom",{enumerable:!0,configurable:!0,writable:!0,value:!1})}onRefresh(){const e=this.instance,t=e.pages.length,i=e.page;if(t<2)return void this.cleanup();this.build();let r=this.prev,a=this.next;r&&a&&(r.removeAttribute(jp),a.removeAttribute(jp),e.isInfinite||(i<=0&&r.setAttribute(jp,""),i>=t-1&&a.setAttribute(jp,"")))}addBtn(e){var t;const i=this.instance,r=document.createElement("button");r.setAttribute("tabindex","0"),r.setAttribute("title",i.localize(`{{${e.toUpperCase()}}}`)),Ct(r,this.cn("button")+" "+this.cn(e===Up?"isNext":"isPrev"));const a=i.isRTL?e===Up?sv:Up:e;var u;return r.innerHTML=i.localize(this.option(`${a}Tpl`)),r.dataset[`carousel${u=e,u?u.match("^[a-z]")?u.charAt(0).toUpperCase()+u.substring(1):u:""}`]="true",(t=this.container)===null||t===void 0||t.appendChild(r),r}build(){const e=this.instance.container,t=this.cn("container");let{container:i,prev:r,next:a}=this;i||(i=e.querySelector("."+t),this.isDom=!!i),i||(i=document.createElement("div"),Ct(i,t),e.appendChild(i)),this.container=i,a||(a=i.querySelector("[data-carousel-next]")),a||(a=this.addBtn(Up)),this.next=a,r||(r=i.querySelector("[data-carousel-prev]")),r||(r=this.addBtn(sv)),this.prev=r}cleanup(){this.isDom||(this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove()),this.prev=null,this.next=null,this.container=null,this.isDom=!1}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}}Object.defineProperty(ov,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:"f-carousel__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"},nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>'}});class av extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"selectedIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(e){this.target=this.instance,this.nav=e,this.attachEvents()}addAsNavFor(e){this.nav=this.instance,this.target=e,this.attachEvents()}attachEvents(){const{nav:e,target:t}=this;e&&t&&(e.options.initialSlide=t.options.initialPage,e.state===di.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),t.state===di.Ready?this.onTargetReady(t):t.on("ready",this.onTargetReady))}onNavReady(e){e.on("createSlide",this.onNavCreateSlide),e.on("Panzoom.click",this.onNavClick),e.on("Panzoom.touchEnd",this.onNavTouch),this.onTargetChange()}onTargetReady(e){e.on("change",this.onTargetChange),e.on("Panzoom.refresh",this.onTargetChange),this.onTargetChange()}onNavClick(e,t,i){this.onNavTouch(e,e.panzoom,i)}onNavTouch(e,t,i){var r,a;if(Math.abs(t.dragOffset.x)>3||Math.abs(t.dragOffset.y)>3)return;const u=i.target,{nav:l,target:g}=this;if(!l||!g||!u)return;const b=u.closest("[data-index]");if(i.stopPropagation(),i.preventDefault(),!b)return;const k=parseInt(b.dataset.index||"",10)||0,E=g.getPageForSlide(k),C=l.getPageForSlide(k);l.slideTo(C),g.slideTo(E,{friction:((a=(r=this.nav)===null||r===void 0?void 0:r.plugins)===null||a===void 0?void 0:a.Sync.option("friction"))||0}),this.markSelectedSlide(k)}onNavCreateSlide(e,t){t.index===this.selectedIndex&&this.markSelectedSlide(t.index)}onTargetChange(){var e,t;const{target:i,nav:r}=this;if(!i||!r||r.state!==di.Ready||i.state!==di.Ready)return;const a=(t=(e=i.pages[i.page])===null||e===void 0?void 0:e.slides[0])===null||t===void 0?void 0:t.index,u=r.getPageForSlide(a);this.markSelectedSlide(a),r.slideTo(u,r.prevPage===null&&i.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const t=this.nav;t&&t.state===di.Ready&&(this.selectedIndex=e,[...t.slides].map(i=>{i.el&&i.el.classList[i.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let t=e.options.target,i=e.options.nav;t?e.addAsNavFor(t):i&&e.addAsTargetFor(i)}detach(){const e=this,t=e.nav,i=e.target;t&&(t.off("ready",e.onNavReady),t.off("createSlide",e.onNavCreateSlide),t.off("Panzoom.click",e.onNavClick),t.off("Panzoom.touchEnd",e.onNavTouch)),e.nav=null,i&&(i.off("ready",e.onTargetReady),i.off("refresh",e.onTargetChange),i.off("change",e.onTargetChange)),e.target=null}}Object.defineProperty(av,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const XB={Navigation:ov,Dots:rv,Sync:av},Hp="animationend",lv="isSelected",qp="slide";class ha extends uy{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===di.Ready}get isInfinite(){let e=!1;const{contentDim:t,viewportDim:i,pages:r,slides:a}=this,u=a[0];return r.length>=2&&u&&t+u.dim>=i&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,t={},i={}){if(super(),Object.defineProperty(this,"bp",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"lp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:di.Init}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevPage",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"viewport",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"slides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"panzoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"inTransition",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"contentDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"viewportDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),typeof e=="string"&&(e=document.querySelector(e)),!e||!Mr(e))throw new Error("No Element found");this.container=e,this.slideNext=nv(this.slideNext.bind(this),150),this.slidePrev=nv(this.slidePrev.bind(this),150),this.userOptions=t,this.userPlugins=i,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,t;const i=Tr({},ha.defaults,this.userOptions);let r="";const a=i.breakpoints;if(a&&ly(a))for(const[u,l]of Object.entries(a))window.matchMedia(u).matches&&ly(l)&&(r+=u,Tr(i,l));r===this.bp&&this.state!==di.Init||(this.bp=r,this.state===di.Ready&&(i.initialSlide=((t=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||t===void 0?void 0:t.index)||0),this.state!==di.Init&&this.destroy(),super.setOptions(i),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=di.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},ha.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=di.Ready,this.emit("ready")}initLayout(){const{container:e}=this,t=this.option("classes");Ct(e,this.cn("container")),eo(e,t.isLTR,!this.isRTL),eo(e,t.isRTL,this.isRTL),eo(e,t.isVertical,!this.isHorizontal),eo(e,t.isHorizontal,this.isHorizontal);let i=this.option("viewport")||e.querySelector(`.${t.viewport}`);i||(i=document.createElement("div"),Ct(i,t.viewport),i.append(...iv(e,`.${t.slide}`)),e.prepend(i)),i.addEventListener("scroll",this.onScroll);let r=this.option("track")||e.querySelector(`.${t.track}`);r||(r=document.createElement("div"),Ct(r,t.track),r.append(...Array.from(i.childNodes))),r.setAttribute("aria-live","polite"),i.contains(r)||i.prepend(r),this.viewport=i,this.track=r,this.emit("initLayout")}initSlides(){const{track:e}=this;if(!e)return;const t=[...this.slides],i=[];[...iv(e,`.${this.cn(qp)}`)].forEach(r=>{if(Mr(r)){const a=fy({el:r,isDom:!0,index:this.slides.length});i.push(a)}});for(let r of[...this.option("slides",[])||[],...t])i.push(fy(r));this.slides=i;for(let r=0;r<this.slides.length;r++)this.slides[r].index=r;for(const r of i)this.emit("beforeInitSlide",r,r.index),this.emit("initSlide",r,r.index);this.emit("initSlides")}setInitialPage(){const e=this.option("initialSlide");this.page=typeof e=="number"?this.getPageForSlide(e):parseInt(this.option("initialPage",0)+"",10)||0}setInitialPosition(){const{track:e,pages:t,isHorizontal:i}=this;if(!e||!t.length)return;let r=this.page;t[r]||(this.page=r=0);const a=(t[r].pos||0)*(this.isRTL&&i?1:-1),u=i?`${a}px`:"0",l=i?"0":`${a}px`;e.style.transform=`translate3d(${u}, ${l}, 0) scale(1)`,this.option("adaptiveHeight")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const e=this.option("Panzoom")||{};this.panzoom=new ua(this.viewport,Tr({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:t=>!(this.pages.length<2&&!t.options.infinite),bounds:()=>this.getBounds(),maxVelocity:t=>Math.abs(t.target[this.axis]-t.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(t,i,...r)=>{this.emit(`Panzoom.${i}`,t,...r)}),this.panzoom.on("decel",this.onDecel),this.panzoom.on("refresh",this.onRefresh),this.panzoom.on("beforeTransform",this.onBeforeTransform),this.panzoom.on("endAnimation",this.onEndAnimation)}attachEvents(){const e=this.container;e&&(e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("slideTo",this.onSlideTo)),window.addEventListener("resize",this.onResize)}createPages(){let e=[];const{contentDim:t,viewportDim:i}=this;let r=this.option("slidesPerPage");r=(r==="auto"||t<=i)&&this.option("fill")!==!1?1/0:parseFloat(r+"");let a=0,u=0,l=0;for(const g of this.slides)(!e.length||u+g.dim-i>.05||l>=r)&&(e.push(ZB()),a=e.length-1,u=0,l=0),e[a].slides.push(g),u+=g.dim+g.gap,l++;return e}processPages(){const e=this.pages,{contentDim:t,viewportDim:i,isInfinite:r}=this,a=this.option("center"),u=this.option("fill"),l=u&&a&&t>i&&!r;if(e.forEach((k,E)=>{var C;k.index=E,k.pos=((C=k.slides[0])===null||C===void 0?void 0:C.pos)||0,k.dim=0;for(const[I,D]of k.slides.entries())k.dim+=D.dim,I<k.slides.length-1&&(k.dim+=D.gap);l&&k.pos+.5*k.dim<.5*i?k.pos=0:l&&k.pos+.5*k.dim>=t-.5*i?k.pos=t-i:a&&(k.pos+=-.5*(i-k.dim))}),e.forEach(k=>{u&&!r&&t>i&&(k.pos=Math.max(k.pos,0),k.pos=Math.min(k.pos,t-i)),k.pos=at(k.pos,1e3),k.dim=at(k.dim,1e3),Math.abs(k.pos)<=.1&&(k.pos=0)}),r)return e;const g=[];let b;return e.forEach(k=>{const E=Object.assign({},k);b&&E.pos===b.pos?(b.dim+=E.dim,b.slides=[...b.slides,...E.slides]):(E.index=g.length,b=E,g.push(E))}),g}getPageFromIndex(e=0){const t=this.pages.length;let i;return e=parseInt((e||0).toString())||0,i=this.isInfinite?(e%t+t)%t:Math.max(Math.min(e,t-1),0),i}getSlideMetrics(e){var t,i;const r=this.isHorizontal?"width":"height";let a=0,u=0,l=e.el;const g=!(!l||l.parentNode);if(l?a=parseFloat(l.dataset[r]||"")||0:(l=document.createElement("div"),l.style.visibility="hidden",(this.track||document.body).prepend(l)),Ct(l,this.cn(qp)+" "+e.class+" "+e.customClass),a)l.style[r]=`${a}px`,l.style[r==="width"?"height":"width"]="";else{g&&(this.track||document.body).prepend(l),a=l.getBoundingClientRect()[r]*Math.max(1,((t=window.visualViewport)===null||t===void 0?void 0:t.scale)||1);let k=l[this.isHorizontal?"offsetWidth":"offsetHeight"];k-1>a&&(a=k)}const b=getComputedStyle(l);return b.boxSizing==="content-box"&&(this.isHorizontal?(a+=parseFloat(b.paddingLeft)||0,a+=parseFloat(b.paddingRight)||0):(a+=parseFloat(b.paddingTop)||0,a+=parseFloat(b.paddingBottom)||0)),u=parseFloat(b[this.isHorizontal?"marginRight":"marginBottom"])||0,g?(i=l.parentElement)===null||i===void 0||i.removeChild(l):e.el||l.remove(),{dim:at(a,1e3),gap:at(u,1e3)}}getBounds(){const{isInfinite:e,isRTL:t,isHorizontal:i,pages:r}=this;let a={min:0,max:0};if(e)a={min:-1/0,max:1/0};else if(r.length){const u=r[0].pos,l=r[r.length-1].pos;a=t&&i?{min:u,max:l}:{min:-1*l,max:-1*u}}return{x:i?a:{min:0,max:0},y:i?{min:0,max:0}:a}}repositionSlides(){let e,{isHorizontal:t,isRTL:i,isInfinite:r,viewport:a,viewportDim:u,contentDim:l,page:g,pages:b,slides:k,panzoom:E}=this,C=0,I=0,D=0,R=0;E?R=-1*E.current[this.axis]:b[g]&&(R=b[g].pos||0),e=t?i?"right":"left":"top",i&&t&&(R*=-1);for(const Z of k){const Q=Z.el;Q?(e==="top"?(Q.style.right="",Q.style.left=""):Q.style.top="",Z.index!==C?Q.style[e]=I===0?"":`${at(I,1e3)}px`:Q.style[e]="",D+=Z.dim+Z.gap,C++):I+=Z.dim+Z.gap}if(r&&D&&a){let Z=getComputedStyle(a),Q="padding",Me=t?"Right":"Bottom",ke=parseFloat(Z[Q+(t?"Left":"Top")]);R-=ke,u+=ke,u+=parseFloat(Z[Q+Me]);for(const Ae of k)Ae.el&&(at(Ae.pos)<at(u)&&at(Ae.pos+Ae.dim+Ae.gap)<at(R)&&at(R)>at(l-u)&&(Ae.el.style[e]=`${at(I+D,1e3)}px`),at(Ae.pos+Ae.gap)>=at(l-u)&&at(Ae.pos)>at(R+u)&&at(R)<at(u)&&(Ae.el.style[e]=`-${at(D,1e3)}px`))}let $,G,te=[...this.inTransition];if(te.length>1&&($=b[te[0]],G=b[te[1]]),$&&G){let Z=0;for(const Q of k)Q.el?this.inTransition.has(Q.index)&&$.slides.indexOf(Q)<0&&(Q.el.style[e]=`${at(Z+($.pos-G.pos),1e3)}px`):Z+=Q.dim+Q.gap}}createSlideEl(e){const{track:t,slides:i}=this;if(!t||!e||e.el&&e.el.parentNode)return;const r=e.el||document.createElement("div");Ct(r,this.cn(qp)),Ct(r,e.class),Ct(r,e.customClass);const a=e.html;a&&(a instanceof HTMLElement?r.appendChild(a):r.innerHTML=e.html+"");const u=[];i.forEach((k,E)=>{k.el&&u.push(E)});const l=e.index;let g=null;u.length&&(g=i[u.reduce((k,E)=>Math.abs(E-l)<Math.abs(k-l)?E:k)]);const b=g&&g.el&&g.el.parentNode?g.index<e.index?g.el.nextSibling:g.el:null;t.insertBefore(r,t.contains(b)?b:null),e.el=r,this.emit("createSlide",e)}removeSlideEl(e,t=!1){const i=e==null?void 0:e.el;if(!i||!i.parentNode)return;const r=this.cn(lv);if(i.classList.contains(r)&&(En(i,r),this.emit("unselectSlide",e)),e.isDom&&!t)return i.removeAttribute("aria-hidden"),i.removeAttribute("data-index"),void(i.style.left="");this.emit("removeSlide",e);const a=new CustomEvent(Hp);i.dispatchEvent(a),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,t=this.option("transition")){var i,r,a,u;if(!t)return!1;const l=this.page,{pages:g,panzoom:b}=this;e=parseInt((e||0).toString())||0;const k=this.getPageFromIndex(e);if(!b||!g[k]||g.length<2||Math.abs((((r=(i=g[l])===null||i===void 0?void 0:i.slides[0])===null||r===void 0?void 0:r.dim)||0)-this.viewportDim)>1)return!1;let E=e>l?1:-1;this.isInfinite&&(l===0&&e===g.length-1&&(E=-1),l===g.length-1&&e===0&&(E=1));const C=g[k].pos*(this.isRTL?1:-1);if(l===k&&Math.abs(C-b.target[this.axis])<1)return!1;this.clearTransitions();const I=b.isResting;Ct(this.container,this.cn("inTransition"));const D=((a=g[l])===null||a===void 0?void 0:a.slides[0])||null,R=((u=g[k])===null||u===void 0?void 0:u.slides[0])||null;this.inTransition.add(R.index),this.createSlideEl(R);let $=D.el,G=R.el;I||t===qp||(t="fadeFast",$=null);const te=this.isRTL?"next":"prev",Z=this.isRTL?"prev":"next";return $&&(this.inTransition.add(D.index),D.transition=t,$.addEventListener(Hp,this.onAnimationEnd),$.classList.add(`f-${t}Out`,`to-${E>0?Z:te}`)),G&&(R.transition=t,G.addEventListener(Hp,this.onAnimationEnd),G.classList.add(`f-${t}In`,`from-${E>0?te:Z}`)),b.current[this.axis]=C,b.target[this.axis]=C,b.requestTick(),this.onChange(k),!0}manageSlideVisiblity(){const e=new Set,t=new Set,i=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const r of this.slides)i.has(r)?e.add(r):t.add(r);for(const r of this.inTransition)e.add(this.slides[r]);for(const r of e)this.createSlideEl(r),this.lazyLoadSlide(r);for(const r of t)e.has(r)||this.removeSlideEl(r);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const e="aria-hidden";let t=this.cn(lv);if(t)for(const i of this.slides){const r=i.el;r&&(r.dataset.index=`${i.index}`,r.classList.contains("f-thumbs__slide")?this.getVisibleSlides(0).has(i)?r.removeAttribute(e):r.setAttribute(e,"true"):this.pages[this.page].slides.includes(i)?(r.classList.contains(t)||(Ct(r,t),this.emit("selectSlide",i)),r.removeAttribute(e)):(r.classList.contains(t)&&(En(r,t),this.emit("unselectSlide",i)),r.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:t,isInfinite:i,isRTL:r,viewportDim:a,contentDim:u}=this,l=this.panzoom;if(!l||!i)return;let g=l.current[e],b=l.target[e]-g,k=0,E=.5*a;r&&t?(g<-E&&(k=-1,g+=u),g>u-E&&(k=1,g-=u)):(g>E&&(k=1,g-=u),g<-u+E&&(k=-1,g+=u)),k&&(l.current[e]=g,l.target[e]=g+b)}lazyLoadImg(e,t){const i=this,r="f-fadeIn",a="is-preloading";let u=!1,l=null;const g=()=>{u||(u=!0,l&&(l.remove(),l=null),En(t,a),t.complete&&(Ct(t,r),setTimeout(()=>{En(t,r)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(i.updateMetrics(),i.setViewportHeight()),this.emit("load",e))};Ct(t,a),t.src=t.dataset.lazySrcset||t.dataset.lazySrc||"",delete t.dataset.lazySrc,delete t.dataset.lazySrcset,t.addEventListener("error",()=>{g()}),t.addEventListener("load",()=>{g()}),setTimeout(()=>{const b=t.parentNode;b&&e.el&&(t.complete?g():u||(l=Qs(hy),b.insertBefore(l,t)))},300)}lazyLoadSlide(e){const t=e&&e.el;if(!t)return;const i=new Set;let r=Array.from(t.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));t.dataset.lazySrc&&r.push(t),r.map(a=>{a instanceof HTMLImageElement?i.add(a):a instanceof HTMLElement&&a.dataset.lazySrc&&(a.style.backgroundImage=`url('${a.dataset.lazySrc}')`,delete a.dataset.lazySrc)});for(const a of i)this.lazyLoadImg(e,a)}onAnimationEnd(e){var t;const i=e.target,r=i?parseInt(i.dataset.index||"",10)||0:-1,a=this.slides[r],u=e.animationName;if(!i||!a||!u)return;const l=!!this.inTransition.has(r)&&a.transition;l&&u.substring(0,l.length+2)===`f-${l}`&&this.inTransition.delete(r),this.inTransition.size||this.clearTransitions(),r===this.page&&(!((t=this.panzoom)===null||t===void 0)&&t.isResting)&&this.emit("settle")}onDecel(e,t=0,i=0,r=0,a=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:u,isHorizontal:l,axis:g,pages:b}=this,k=b.length,E=Math.abs(Math.atan2(i,t)/(Math.PI/180));let C=0;if(C=E>45&&E<135?l?0:i:l?t:0,!k)return;let I=this.page,D=u&&l?1:-1;const R=e.current[g]*D;let{pageIndex:$}=this.getPageFromPosition(R);Math.abs(C)>5?(b[I].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(I=$),I=u&&l?C<0?I-1:I+1:C<0?I+1:I-1):I=r===0&&a===0?I:$,this.slideTo(I,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const t=e.target,i=t&&Mr(t)?t.dataset:null;let r,a;i&&(i.carouselPage!==void 0?(a="slideTo",r=i.carouselPage):i.carouselNext!==void 0?a="slideNext":i.carouselPrev!==void 0&&(a="slidePrev")),a?(e.preventDefault(),e.stopPropagation(),t&&!t.hasAttribute("disabled")&&this[a](r)):this.emit("click",e)}onSlideTo(e){const t=e.detail||0;this.slideTo(this.getPageForSlide(t),{friction:0})}onChange(e,t=0){const i=this.page;this.prevPage=i,this.page=e,this.option("adaptiveHeight")&&this.setViewportHeight(),e!==i&&(this.markSelectedSlides(),this.emit("change",e,i,t))}onRefresh(){let e=this.contentDim,t=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===t||this.slideTo(this.page,{friction:0,transition:!1})}onScroll(){var e;(e=this.viewport)===null||e===void 0||e.scroll(0,0)}onResize(){this.option("breakpoints")&&this.processOptions()}onBeforeTransform(e){this.lp!==e.current[this.axis]&&(this.flipInfiniteTrack(),this.manageSlideVisiblity()),this.lp=e.current.e}onEndAnimation(){this.inTransition.size||this.emit("settle")}reInit(e=null,t=null){this.destroy(),this.state=di.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=t||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:t=this.option("friction"),transition:i=this.option("transition")}={}){if(this.state===di.Destroy)return;e=parseInt((e||0).toString())||0;const r=this.getPageFromIndex(e),{axis:a,isHorizontal:u,isRTL:l,pages:g,panzoom:b}=this,k=g.length,E=l&&u?1:-1;if(!b||!k)return;if(this.page!==r){const I=new Event("beforeChange",{bubbles:!0,cancelable:!0});if(this.emit("beforeChange",I,e),I.defaultPrevented)return}if(this.transitionTo(e,i))return;let C=g[r].pos;if(this.isInfinite){const I=this.contentDim,D=b.target[a]*E;k===2?C+=I*Math.floor(parseFloat(e+"")/2):C=[C,C-I,C+I].reduce(function(R,$){return Math.abs($-D)<Math.abs(R-D)?$:R})}C*=E,Math.abs(b.target[a]-C)<1||(b.panTo({x:u?C:0,y:u?0:C,friction:t}),this.onChange(r))}slideToClosest(e){if(this.panzoom){const{pageIndex:t}=this.getPageFromPosition();this.slideTo(t,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),En(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const t of this.slides){const i=t.el;if(i){i.removeEventListener(Hp,this.onAnimationEnd),i.classList.remove(...e);const r=t.transition;r&&i.classList.remove(`f-${r}Out`,`f-${r}In`)}}this.manageSlideVisiblity()}addSlide(e,t){var i,r,a,u;const l=this.panzoom,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.pos)||0,b=((r=this.pages[this.page])===null||r===void 0?void 0:r.dim)||0,k=this.contentDim<this.viewportDim;let E=Array.isArray(t)?t:[t];const C=[];for(const I of E)C.push(fy(I));this.slides.splice(e,0,...C);for(let I=0;I<this.slides.length;I++)this.slides[I].index=I;for(const I of C)this.emit("beforeInitSlide",I,I.index);if(this.page>=e&&(this.page+=C.length),this.updateMetrics(),l){const I=((a=this.pages[this.page])===null||a===void 0?void 0:a.pos)||0,D=((u=this.pages[this.page])===null||u===void 0?void 0:u.dim)||0,R=this.pages.length||1,$=this.isRTL?b-D:D-b,G=this.isRTL?g-I:I-g;k&&R===1?(e<=this.page&&(l.current[this.axis]-=$,l.target[this.axis]-=$),l.panTo({[this.isHorizontal?"x":"y"]:-1*I})):G&&e<=this.page&&(l.target[this.axis]-=G,l.current[this.axis]-=G,l.requestTick())}for(const I of C)this.emit("initSlide",I,I.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const t=this.slides.length;e=(e%t+t)%t;const i=this.slides[e];if(i){this.removeSlideEl(i,!0),this.slides.splice(e,1);for(let r=0;r<this.slides.length;r++)this.slides[r].index=r;this.updateMetrics(),this.slideTo(this.page,{friction:0,transition:!1}),this.emit("destroySlide",i)}}updateMetrics(){const{panzoom:e,viewport:t,track:i,slides:r,isHorizontal:a,isInfinite:u}=this;if(!i)return;const l=a?"width":"height",g=a?"offsetWidth":"offsetHeight";if(t){let E=Math.max(t[g],at(t.getBoundingClientRect()[l],1e3)),C=getComputedStyle(t),I="padding",D=a?"Right":"Bottom";E-=parseFloat(C[I+(a?"Left":"Top")])+parseFloat(C[I+D]),this.viewportDim=E}let b,k=0;for(const[E,C]of r.entries()){let I=0,D=0;!C.el&&b?(I=b.dim,D=b.gap):({dim:I,gap:D}=this.getSlideMetrics(C),b=C),I=at(I,1e3),D=at(D,1e3),C.dim=I,C.gap=D,C.pos=k,k+=I,(u||E<r.length-1)&&(k+=D)}k=at(k,1e3),this.contentDim=k,e&&(e.contentRect[l]=k,e.contentRect[a?"fullWidth":"fullHeight"]=k),this.pages=this.createPages(),this.pages=this.processPages(),this.state===di.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,t=!1,i=!1){e===void 0&&(e=this.page);const r=this,a=r.panzoom,u=r.contentDim,l=r.pages[e]||0;if(!l||!a)return e>this.page?-1:1;let g=-1*a.current.e,b=at((g-l.pos)/(1*l.dim),1e3),k=b,E=b;this.isInfinite&&i!==!0&&(k=at((g-l.pos+u)/(1*l.dim),1e3),E=at((g-l.pos-u)/(1*l.dim),1e3));let C=[b,k,E].reduce(function(I,D){return Math.abs(D)<Math.abs(I)?D:I});return t?C:C>1?1:C<-1?-1:C}setViewportHeight(){const{page:e,pages:t,viewport:i,isHorizontal:r}=this;if(!i||!t[e])return;let a=0;r&&this.track&&(this.track.style.height="auto",t[e].slides.forEach(u=>{u.el&&(a=Math.max(a,u.el.offsetHeight))})),i.style.height=a?`${a}px`:""}getPageForSlide(e){for(const t of this.pages)for(const i of t.slides)if(i.index===e)return t.index;return-1}getVisibleSlides(e=0){var t;const i=new Set;let{panzoom:r,contentDim:a,viewportDim:u,pages:l,page:g}=this;if(u){a=a+((t=this.slides[this.slides.length-1])===null||t===void 0?void 0:t.gap)||0;let b=0;b=r&&r.state!==Pn.Init&&r.state!==Pn.Destroy?-1*r.current[this.axis]:l[g]&&l[g].pos||0,this.isInfinite&&(b-=Math.floor(b/a)*a),this.isRTL&&this.isHorizontal&&(b*=-1);const k=b-u*e,E=b+u*(e+1),C=this.isInfinite?[-1,0,1]:[0];for(const I of this.slides)for(const D of C){const R=I.pos+D*a,$=R+I.dim+I.gap;R<E&&$>k&&i.add(I)}}return i}getPageFromPosition(e){const{viewportDim:t,contentDim:i,slides:r,pages:a,panzoom:u}=this,l=a.length,g=r.length,b=r[0],k=r[g-1],E=this.option("center");let C=0,I=0,D=0,R=e===void 0?-1*((u==null?void 0:u.target[this.axis])||0):e;E&&(R+=.5*t),this.isInfinite?(R<b.pos-.5*k.gap&&(R-=i,D=-1),R>k.pos+k.dim+.5*k.gap&&(R-=i,D=1)):R=Math.max(b.pos||0,Math.min(R,k.pos));let $=k,G=r.find(te=>{const Z=te.pos-.5*$.gap,Q=te.pos+te.dim+.5*te.gap;return $=te,R>=Z&&R<Q});return G||(G=k),I=this.getPageForSlide(G.index),C=I+D*l,{page:C,pageIndex:I}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([di.Destroy].includes(this.state))return;this.state=di.Destroy;const{container:e,viewport:t,track:i,slides:r,panzoom:a}=this,u=this.option("classes");e.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),e.removeEventListener("slideTo",this.onSlideTo),window.removeEventListener("resize",this.onResize),a&&(a.destroy(),this.panzoom=null),r&&r.forEach(g=>{this.removeSlideEl(g)}),this.detachPlugins(),t&&(t.removeEventListener("scroll",this.onScroll),t.offsetParent&&i&&i.offsetParent&&t.replaceWith(...i.childNodes));for(const[g,b]of Object.entries(u))g!=="container"&&b&&e.classList.remove(b);this.track=null,this.viewport=null,this.page=0,this.slides=[];const l=this.events.get("ready");this.events=new Map,l&&this.events.set("ready",l)}}Object.defineProperty(ha,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:ua}),Object.defineProperty(ha,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:GB}),Object.defineProperty(ha,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:XB});const cv=function(n){if(!Mr(n))return 0;const e=window.scrollY,t=window.innerHeight,i=e+t,r=n.getBoundingClientRect(),a=r.y+e,u=r.height,l=a+u;if(e>l||i<a)return 0;if(e<a&&i>l||a<e&&l>i)return 100;let g=u;a<e&&(g-=e-a),l>i&&(g-=l-i);const b=g/t*100;return Math.round(b)},fh=!(typeof window>"u"||!window.document||!window.document.createElement);let my;const gy=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)","iframe","object","embed","video","audio","[contenteditable]",'[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","),uv=n=>{if(n&&fh){my===void 0&&document.createElement("div").focus({get preventScroll(){return my=!0,!1}});try{if(my)n.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,t=window.scrollX||document.body.scrollLeft;n.focus(),document.body.scrollTo({top:e,left:t,behavior:"auto"})}}catch{}}},hv=()=>{const n=document;let e,t="",i="",r="";return n.fullscreenEnabled?(t="requestFullscreen",i="exitFullscreen",r="fullscreenElement"):n.webkitFullscreenEnabled&&(t="webkitRequestFullscreen",i="webkitExitFullscreen",r="webkitFullscreenElement"),t&&(e={request:function(a=n.documentElement){return t==="webkitRequestFullscreen"?a[t](Element.ALLOW_KEYBOARD_INPUT):a[t]()},exit:function(){return n[r]&&n[i]()},isFullscreen:function(){return n[r]}}),e},yy={animated:!0,autoFocus:!0,backdropClick:"close",Carousel:{classes:{container:"fancybox__carousel",viewport:"fancybox__viewport",track:"fancybox__track",slide:"fancybox__slide"}},closeButton:"auto",closeExisting:!1,commonCaption:!1,compact:()=>window.matchMedia("(max-width: 578px), (max-height: 578px)").matches,contentClick:"toggleZoom",contentDblClick:!1,defaultType:"image",defaultDisplay:"flex",dragToClose:!0,Fullscreen:{autoStart:!1},groupAll:!1,groupAttr:"data-fancybox",hideClass:"f-fadeOut",hideScrollbar:!0,idle:3500,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"prev",ArrowDown:"next",ArrowRight:"next",ArrowLeft:"prev"},l10n:Object.assign(Object.assign({},J1),{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page",TOGGLE_ZOOM:"Toggle zoom level",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_SLIDESHOW:"Toggle slideshow",TOGGLE_FULLSCREEN:"Toggle full-screen mode",DOWNLOAD:"Download"}),parentEl:null,placeFocusBack:!0,showClass:"f-zoomInUp",startIndex:0,tpl:{closeButton:'<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>',main:`<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">
624
+ `),ne=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(ne,ce),P.compileShader(ne),!P.getShaderParameter(ne,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(ne)}`);P.attachShader(this.program,ne);const me=P.createShader(P.VERTEX_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(me,he),P.compileShader(me),!P.getShaderParameter(me,P.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${P.getShaderInfoLog(me)}`);P.attachShader(this.program,me),this.attributes={};const ge={};this.numAttributes=V.length;for(let xe=0;xe<this.numAttributes;xe++)V[xe]&&(P.bindAttribLocation(this.program,xe,V[xe]),this.attributes[V[xe]]=xe);if(P.linkProgram(this.program),!P.getProgramParameter(this.program,P.LINK_STATUS))throw new Error(`Program failed to link: ${P.getProgramInfoLog(this.program)}`);P.deleteShader(me),P.deleteShader(ne);for(let xe=0;xe<se.length;xe++){const De=se[xe];if(De&&!ge[De]){const Ve=P.getUniformLocation(this.program,De);Ve&&(ge[De]=Ve)}}this.fixedUniforms=y(s,ge),this.terrainUniforms=((xe,De)=>({u_depth:new l.aH(xe,De.u_depth),u_terrain:new l.aH(xe,De.u_terrain),u_terrain_dim:new l.aI(xe,De.u_terrain_dim),u_terrain_matrix:new l.aJ(xe,De.u_terrain_matrix),u_terrain_unpack:new l.aK(xe,De.u_terrain_unpack),u_terrain_exaggeration:new l.aI(xe,De.u_terrain_exaggeration)}))(s,ge),this.binderUniforms=m?m.getUniforms(s,ge):[]}draw(s,d,m,y,x,M,P,O,z,V,F,W,J,ee,se,le,ce,he){const ne=s.gl;if(this.failedToCreate)return;if(s.program.set(this.program),s.setDepthMode(m),s.setStencilMode(y),s.setColorMode(x),s.setCullFace(M),O){s.activeTexture.set(ne.TEXTURE2),ne.bindTexture(ne.TEXTURE_2D,O.depthTexture),s.activeTexture.set(ne.TEXTURE3),ne.bindTexture(ne.TEXTURE_2D,O.texture);for(const ge in this.terrainUniforms)this.terrainUniforms[ge].set(O[ge])}for(const ge in this.fixedUniforms)this.fixedUniforms[ge].set(P[ge]);se&&se.setUniforms(s,this.binderUniforms,J,{zoom:ee});let me=0;switch(d){case ne.LINES:me=2;break;case ne.TRIANGLES:me=3;break;case ne.LINE_STRIP:me=1}for(const ge of W.get()){const xe=ge.vaos||(ge.vaos={});(xe[z]||(xe[z]=new Kh)).bind(s,this,V,se?se.getPaintVertexBuffers():[],F,ge.vertexOffset,le,ce,he),ne.drawElements(d,ge.primitiveLength*me,ne.UNSIGNED_SHORT,ge.primitiveOffset*me*2)}}}function nu(v,s,d){const m=1/Kt(d,1,s.transform.tileZoom),y=Math.pow(2,d.tileID.overscaledZ),x=d.tileSize*Math.pow(2,s.transform.tileZoom)/y,M=x*(d.tileID.canonical.x+d.tileID.wrap*y),P=x*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[m,v.fromScale,v.toScale],u_fade:v.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Ll=(v,s,d,m)=>{const y=s.style.light,x=y.properties.get("position"),M=[x.x,x.y,x.z],P=function(){var z=new l.A(9);return l.A!=Float32Array&&(z[1]=0,z[2]=0,z[3]=0,z[5]=0,z[6]=0,z[7]=0),z[0]=1,z[4]=1,z[8]=1,z}();y.properties.get("anchor")==="viewport"&&function(z,V){var F=Math.sin(V),W=Math.cos(V);z[0]=W,z[1]=F,z[2]=0,z[3]=-F,z[4]=W,z[5]=0,z[6]=0,z[7]=0,z[8]=1}(P,-s.transform.angle),function(z,V,F){var W=V[0],J=V[1],ee=V[2];z[0]=W*F[0]+J*F[3]+ee*F[6],z[1]=W*F[1]+J*F[4]+ee*F[7],z[2]=W*F[2]+J*F[5]+ee*F[8]}(M,M,P);const O=y.properties.get("color");return{u_matrix:v,u_lightpos:M,u_lightintensity:y.properties.get("intensity"),u_lightcolor:[O.r,O.g,O.b],u_vertical_gradient:+d,u_opacity:m}},iu=(v,s,d,m,y,x,M)=>l.e(Ll(v,s,d,m),nu(x,s,M),{u_height_factor:-Math.pow(2,y.overscaledZ)/M.tileSize/8}),Ia=v=>({u_matrix:v}),Yf=(v,s,d,m)=>l.e(Ia(v),nu(d,s,m)),o_=(v,s)=>({u_matrix:v,u_world:s}),Xf=(v,s,d,m,y)=>l.e(Yf(v,s,d,m),{u_world:y}),a_=(v,s,d,m)=>{const y=v.transform;let x,M;if(m.paint.get("circle-pitch-alignment")==="map"){const P=Kt(d,1,y.zoom);x=!0,M=[P,P]}else x=!1,M=y.pixelsToGLUnits;return{u_camera_to_center_distance:y.cameraToCenterDistance,u_scale_with_map:+(m.paint.get("circle-pitch-scale")==="map"),u_matrix:v.translatePosMatrix(s.posMatrix,d,m.paint.get("circle-translate"),m.paint.get("circle-translate-anchor")),u_pitch_with_map:+x,u_device_pixel_ratio:v.pixelRatio,u_extrude_scale:M}},$o=(v,s,d)=>({u_matrix:v,u_inv_matrix:s,u_camera_to_center_distance:d.cameraToCenterDistance,u_viewport_size:[d.width,d.height]}),Vl=(v,s,d=1)=>({u_matrix:v,u_color:s,u_overlay:0,u_overlay_scale:d}),nr=v=>({u_matrix:v}),ir=(v,s,d,m)=>({u_matrix:v,u_extrude_scale:Kt(s,1,d),u_intensity:m}),ru=(v,s,d,m)=>{const y=l.H();l.aP(y,0,v.width,v.height,0,0,1);const x=v.context.gl;return{u_matrix:y,u_world:[x.drawingBufferWidth,x.drawingBufferHeight],u_image:d,u_color_ramp:m,u_opacity:s.paint.get("heatmap-opacity")}};function su(v,s){const d=Math.pow(2,s.canonical.z),m=s.canonical.y;return[new l.Z(0,m/d).toLngLat().lat,new l.Z(0,(m+1)/d).toLngLat().lat]}const ou=(v,s,d,m)=>{const y=v.transform;return{u_matrix:Qf(v,s,d,m),u_ratio:1/Kt(s,1,y.zoom),u_device_pixel_ratio:v.pixelRatio,u_units_to_pixels:[1/y.pixelsToGLUnits[0],1/y.pixelsToGLUnits[1]]}},Kf=(v,s,d,m,y)=>l.e(ou(v,s,d,y),{u_image:0,u_image_height:m}),Da=(v,s,d,m,y)=>{const x=v.transform,M=Jf(s,x);return{u_matrix:Qf(v,s,d,y),u_texsize:s.imageAtlasTexture.size,u_ratio:1/Kt(s,1,x.zoom),u_device_pixel_ratio:v.pixelRatio,u_image:0,u_scale:[M,m.fromScale,m.toScale],u_fade:m.t,u_units_to_pixels:[1/x.pixelsToGLUnits[0],1/x.pixelsToGLUnits[1]]}},l_=(v,s,d,m,y,x)=>{const M=v.lineAtlas,P=Jf(s,v.transform),O=d.layout.get("line-cap")==="round",z=M.getDash(m.from,O),V=M.getDash(m.to,O),F=z.width*y.fromScale,W=V.width*y.toScale;return l.e(ou(v,s,d,x),{u_patternscale_a:[P/F,-z.height/2],u_patternscale_b:[P/W,-V.height/2],u_sdfgamma:M.width/(256*Math.min(F,W)*v.pixelRatio)/2,u_image:0,u_tex_y_a:z.y,u_tex_y_b:V.y,u_mix:y.t})};function Jf(v,s){return 1/Kt(v,1,s.tileZoom)}function Qf(v,s,d,m){return v.translatePosMatrix(m?m.posMatrix:s.tileID.posMatrix,s,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}const c_=(v,s,d,m,y)=>{return{u_matrix:v,u_tl_parent:s,u_scale_parent:d,u_buffer_scale:1,u_fade_t:m.mix,u_opacity:m.opacity*y.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:y.paint.get("raster-brightness-min"),u_brightness_high:y.paint.get("raster-brightness-max"),u_saturation_factor:(M=y.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(x=y.paint.get("raster-contrast"),x>0?1/(1-x):1+x),u_spin_weights:u_(y.paint.get("raster-hue-rotate"))};var x,M};function u_(v){v*=Math.PI/180;const s=Math.sin(v),d=Math.cos(v);return[(2*d+1)/3,(-Math.sqrt(3)*s-d+1)/3,(Math.sqrt(3)*s-d+1)/3]}const em=(v,s,d,m,y,x,M,P,O,z,V,F,W,J)=>{const ee=M.transform;return{u_is_size_zoom_constant:+(v==="constant"||v==="source"),u_is_size_feature_constant:+(v==="constant"||v==="camera"),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:ee.cameraToCenterDistance,u_pitch:ee.pitch/360*2*Math.PI,u_rotate_symbol:+d,u_aspect_ratio:ee.width/ee.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:O,u_coord_matrix:z,u_is_text:+F,u_pitch_with_map:+m,u_is_along_line:y,u_is_variable_anchor:x,u_texsize:W,u_texture:0,u_translation:V,u_pitched_scale:J}},Fl=(v,s,d,m,y,x,M,P,O,z,V,F,W,J,ee)=>{const se=M.transform;return l.e(em(v,s,d,m,y,x,M,P,O,z,V,F,W,ee),{u_gamma_scale:m?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:+J})},ed=(v,s,d,m,y,x,M,P,O,z,V,F,W,J)=>l.e(Fl(v,s,d,m,y,x,M,P,O,z,V,!0,F,!0,J),{u_texsize_icon:W,u_texture_icon:1}),au=(v,s,d)=>({u_matrix:v,u_opacity:s,u_color:d}),td=(v,s,d,m,y,x)=>l.e(function(M,P,O,z){const V=O.imageManager.getPattern(M.from.toString()),F=O.imageManager.getPattern(M.to.toString()),{width:W,height:J}=O.imageManager.getPixelSize(),ee=Math.pow(2,z.tileID.overscaledZ),se=z.tileSize*Math.pow(2,O.transform.tileZoom)/ee,le=se*(z.tileID.canonical.x+z.tileID.wrap*ee),ce=se*z.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:V.tl,u_pattern_br_a:V.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[W,J],u_mix:P.t,u_pattern_size_a:V.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Kt(z,1,O.transform.tileZoom),u_pixel_coord_upper:[le>>16,ce>>16],u_pixel_coord_lower:[65535&le,65535&ce]}}(m,x,d,y),{u_matrix:v,u_opacity:s}),nd={fillExtrusion:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_lightpos:new l.aN(v,s.u_lightpos),u_lightintensity:new l.aI(v,s.u_lightintensity),u_lightcolor:new l.aN(v,s.u_lightcolor),u_vertical_gradient:new l.aI(v,s.u_vertical_gradient),u_opacity:new l.aI(v,s.u_opacity)}),fillExtrusionPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_lightpos:new l.aN(v,s.u_lightpos),u_lightintensity:new l.aI(v,s.u_lightintensity),u_lightcolor:new l.aN(v,s.u_lightcolor),u_vertical_gradient:new l.aI(v,s.u_vertical_gradient),u_height_factor:new l.aI(v,s.u_height_factor),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade),u_opacity:new l.aI(v,s.u_opacity)}),fill:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix)}),fillPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),fillOutline:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world)}),fillOutlinePattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world),u_image:new l.aH(v,s.u_image),u_texsize:new l.aO(v,s.u_texsize),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),circle:(v,s)=>({u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_scale_with_map:new l.aH(v,s.u_scale_with_map),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_extrude_scale:new l.aO(v,s.u_extrude_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_matrix:new l.aJ(v,s.u_matrix)}),collisionBox:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_pixel_extrude_scale:new l.aO(v,s.u_pixel_extrude_scale)}),collisionCircle:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_inv_matrix:new l.aJ(v,s.u_inv_matrix),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_viewport_size:new l.aO(v,s.u_viewport_size)}),debug:(v,s)=>({u_color:new l.aL(v,s.u_color),u_matrix:new l.aJ(v,s.u_matrix),u_overlay:new l.aH(v,s.u_overlay),u_overlay_scale:new l.aI(v,s.u_overlay_scale)}),clippingMask:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix)}),heatmap:(v,s)=>({u_extrude_scale:new l.aI(v,s.u_extrude_scale),u_intensity:new l.aI(v,s.u_intensity),u_matrix:new l.aJ(v,s.u_matrix)}),heatmapTexture:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_world:new l.aO(v,s.u_world),u_image:new l.aH(v,s.u_image),u_color_ramp:new l.aH(v,s.u_color_ramp),u_opacity:new l.aI(v,s.u_opacity)}),hillshade:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_latrange:new l.aO(v,s.u_latrange),u_light:new l.aO(v,s.u_light),u_shadow:new l.aL(v,s.u_shadow),u_highlight:new l.aL(v,s.u_highlight),u_accent:new l.aL(v,s.u_accent)}),hillshadePrepare:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_image:new l.aH(v,s.u_image),u_dimension:new l.aO(v,s.u_dimension),u_zoom:new l.aI(v,s.u_zoom),u_unpack:new l.aK(v,s.u_unpack)}),line:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels)}),lineGradient:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_image:new l.aH(v,s.u_image),u_image_height:new l.aI(v,s.u_image_height)}),linePattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texsize:new l.aO(v,s.u_texsize),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_image:new l.aH(v,s.u_image),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_scale:new l.aN(v,s.u_scale),u_fade:new l.aI(v,s.u_fade)}),lineSDF:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ratio:new l.aI(v,s.u_ratio),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(v,s.u_units_to_pixels),u_patternscale_a:new l.aO(v,s.u_patternscale_a),u_patternscale_b:new l.aO(v,s.u_patternscale_b),u_sdfgamma:new l.aI(v,s.u_sdfgamma),u_image:new l.aH(v,s.u_image),u_tex_y_a:new l.aI(v,s.u_tex_y_a),u_tex_y_b:new l.aI(v,s.u_tex_y_b),u_mix:new l.aI(v,s.u_mix)}),raster:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_tl_parent:new l.aO(v,s.u_tl_parent),u_scale_parent:new l.aI(v,s.u_scale_parent),u_buffer_scale:new l.aI(v,s.u_buffer_scale),u_fade_t:new l.aI(v,s.u_fade_t),u_opacity:new l.aI(v,s.u_opacity),u_image0:new l.aH(v,s.u_image0),u_image1:new l.aH(v,s.u_image1),u_brightness_low:new l.aI(v,s.u_brightness_low),u_brightness_high:new l.aI(v,s.u_brightness_high),u_saturation_factor:new l.aI(v,s.u_saturation_factor),u_contrast_factor:new l.aI(v,s.u_contrast_factor),u_spin_weights:new l.aN(v,s.u_spin_weights)}),symbolIcon:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texture:new l.aH(v,s.u_texture),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),symbolSDF:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texture:new l.aH(v,s.u_texture),u_gamma_scale:new l.aI(v,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_is_halo:new l.aH(v,s.u_is_halo),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),symbolTextAndIcon:(v,s)=>({u_is_size_zoom_constant:new l.aH(v,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(v,s.u_is_size_feature_constant),u_size_t:new l.aI(v,s.u_size_t),u_size:new l.aI(v,s.u_size),u_camera_to_center_distance:new l.aI(v,s.u_camera_to_center_distance),u_pitch:new l.aI(v,s.u_pitch),u_rotate_symbol:new l.aH(v,s.u_rotate_symbol),u_aspect_ratio:new l.aI(v,s.u_aspect_ratio),u_fade_change:new l.aI(v,s.u_fade_change),u_matrix:new l.aJ(v,s.u_matrix),u_label_plane_matrix:new l.aJ(v,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(v,s.u_coord_matrix),u_is_text:new l.aH(v,s.u_is_text),u_pitch_with_map:new l.aH(v,s.u_pitch_with_map),u_is_along_line:new l.aH(v,s.u_is_along_line),u_is_variable_anchor:new l.aH(v,s.u_is_variable_anchor),u_texsize:new l.aO(v,s.u_texsize),u_texsize_icon:new l.aO(v,s.u_texsize_icon),u_texture:new l.aH(v,s.u_texture),u_texture_icon:new l.aH(v,s.u_texture_icon),u_gamma_scale:new l.aI(v,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(v,s.u_device_pixel_ratio),u_is_halo:new l.aH(v,s.u_is_halo),u_translation:new l.aO(v,s.u_translation),u_pitched_scale:new l.aI(v,s.u_pitched_scale)}),background:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_opacity:new l.aI(v,s.u_opacity),u_color:new l.aL(v,s.u_color)}),backgroundPattern:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_opacity:new l.aI(v,s.u_opacity),u_image:new l.aH(v,s.u_image),u_pattern_tl_a:new l.aO(v,s.u_pattern_tl_a),u_pattern_br_a:new l.aO(v,s.u_pattern_br_a),u_pattern_tl_b:new l.aO(v,s.u_pattern_tl_b),u_pattern_br_b:new l.aO(v,s.u_pattern_br_b),u_texsize:new l.aO(v,s.u_texsize),u_mix:new l.aI(v,s.u_mix),u_pattern_size_a:new l.aO(v,s.u_pattern_size_a),u_pattern_size_b:new l.aO(v,s.u_pattern_size_b),u_scale_a:new l.aI(v,s.u_scale_a),u_scale_b:new l.aI(v,s.u_scale_b),u_pixel_coord_upper:new l.aO(v,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(v,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.aI(v,s.u_tile_units_to_pixels)}),terrain:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texture:new l.aH(v,s.u_texture),u_ele_delta:new l.aI(v,s.u_ele_delta),u_fog_matrix:new l.aJ(v,s.u_fog_matrix),u_fog_color:new l.aL(v,s.u_fog_color),u_fog_ground_blend:new l.aI(v,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.aI(v,s.u_fog_ground_blend_opacity),u_horizon_color:new l.aL(v,s.u_horizon_color),u_horizon_fog_blend:new l.aI(v,s.u_horizon_fog_blend)}),terrainDepth:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_ele_delta:new l.aI(v,s.u_ele_delta)}),terrainCoords:(v,s)=>({u_matrix:new l.aJ(v,s.u_matrix),u_texture:new l.aH(v,s.u_texture),u_terrain_coords_id:new l.aI(v,s.u_terrain_coords_id),u_ele_delta:new l.aI(v,s.u_ele_delta)}),sky:(v,s)=>({u_sky_color:new l.aL(v,s.u_sky_color),u_horizon_color:new l.aL(v,s.u_horizon_color),u_horizon:new l.aI(v,s.u_horizon),u_sky_horizon_blend:new l.aI(v,s.u_sky_horizon_blend)})};class Ms{constructor(s,d,m){this.context=s;const y=s.gl;this.buffer=y.createBuffer(),this.dynamicDraw=!!m,this.context.unbindVAO(),s.bindElementBuffer.set(this.buffer),y.bufferData(y.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?y.DYNAMIC_DRAW:y.STATIC_DRAW),this.dynamicDraw||delete d.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(s){const d=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),d.bufferSubData(d.ELEMENT_ARRAY_BUFFER,0,s.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const h_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class id{constructor(s,d,m,y){this.length=d.length,this.attributes=m,this.itemSize=d.bytesPerElement,this.dynamicDraw=y,this.context=s;const x=s.gl;this.buffer=x.createBuffer(),s.bindVertexBuffer.set(this.buffer),x.bufferData(x.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?x.DYNAMIC_DRAW:x.STATIC_DRAW),this.dynamicDraw||delete d.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(s){if(s.length!==this.length)throw new Error(`Length of new data is ${s.length}, which doesn't match current length of ${this.length}`);const d=this.context.gl;this.bind(),d.bufferSubData(d.ARRAY_BUFFER,0,s.arrayBuffer)}enableAttributes(s,d){for(let m=0;m<this.attributes.length;m++){const y=d.attributes[this.attributes[m].name];y!==void 0&&s.enableVertexAttribArray(y)}}setVertexAttribPointers(s,d,m){for(let y=0;y<this.attributes.length;y++){const x=this.attributes[y],M=d.attributes[x.name];M!==void 0&&s.vertexAttribPointer(M,x.components,s[h_[x.type]],!1,this.itemSize,x.offset+this.itemSize*(m||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const jo=new WeakMap;function ho(v){var s;if(jo.has(v))return jo.get(v);{const d=(s=v.getParameter(v.VERSION))===null||s===void 0?void 0:s.startsWith("WebGL 2.0");return jo.set(v,d),d}}class _n{constructor(s){this.gl=s.gl,this.default=this.getDefault(),this.current=this.default,this.dirty=!1}get(){return this.current}set(s){}getDefault(){return this.default}setDefault(){this.set(this.default)}}class lu extends _n{getDefault(){return l.aM.transparent}set(s){const d=this.current;(s.r!==d.r||s.g!==d.g||s.b!==d.b||s.a!==d.a||this.dirty)&&(this.gl.clearColor(s.r,s.g,s.b,s.a),this.current=s,this.dirty=!1)}}class d_ extends _n{getDefault(){return 1}set(s){(s!==this.current||this.dirty)&&(this.gl.clearDepth(s),this.current=s,this.dirty=!1)}}class Oa extends _n{getDefault(){return 0}set(s){(s!==this.current||this.dirty)&&(this.gl.clearStencil(s),this.current=s,this.dirty=!1)}}class p_ extends _n{getDefault(){return[!0,!0,!0,!0]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||s[3]!==d[3]||this.dirty)&&(this.gl.colorMask(s[0],s[1],s[2],s[3]),this.current=s,this.dirty=!1)}}class tm extends _n{getDefault(){return!0}set(s){(s!==this.current||this.dirty)&&(this.gl.depthMask(s),this.current=s,this.dirty=!1)}}class f_ extends _n{getDefault(){return 255}set(s){(s!==this.current||this.dirty)&&(this.gl.stencilMask(s),this.current=s,this.dirty=!1)}}class nm extends _n{getDefault(){return{func:this.gl.ALWAYS,ref:0,mask:255}}set(s){const d=this.current;(s.func!==d.func||s.ref!==d.ref||s.mask!==d.mask||this.dirty)&&(this.gl.stencilFunc(s.func,s.ref,s.mask),this.current=s,this.dirty=!1)}}class rd extends _n{getDefault(){const s=this.gl;return[s.KEEP,s.KEEP,s.KEEP]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||this.dirty)&&(this.gl.stencilOp(s[0],s[1],s[2]),this.current=s,this.dirty=!1)}}class im extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.STENCIL_TEST):d.disable(d.STENCIL_TEST),this.current=s,this.dirty=!1}}class rm extends _n{getDefault(){return[0,1]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||this.dirty)&&(this.gl.depthRange(s[0],s[1]),this.current=s,this.dirty=!1)}}class sm extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.DEPTH_TEST):d.disable(d.DEPTH_TEST),this.current=s,this.dirty=!1}}class om extends _n{getDefault(){return this.gl.LESS}set(s){(s!==this.current||this.dirty)&&(this.gl.depthFunc(s),this.current=s,this.dirty=!1)}}class Uo extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.BLEND):d.disable(d.BLEND),this.current=s,this.dirty=!1}}class am extends _n{getDefault(){const s=this.gl;return[s.ONE,s.ZERO]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||this.dirty)&&(this.gl.blendFunc(s[0],s[1]),this.current=s,this.dirty=!1)}}class m_ extends _n{getDefault(){return l.aM.transparent}set(s){const d=this.current;(s.r!==d.r||s.g!==d.g||s.b!==d.b||s.a!==d.a||this.dirty)&&(this.gl.blendColor(s.r,s.g,s.b,s.a),this.current=s,this.dirty=!1)}}class lm extends _n{getDefault(){return this.gl.FUNC_ADD}set(s){(s!==this.current||this.dirty)&&(this.gl.blendEquation(s),this.current=s,this.dirty=!1)}}class $l extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;s?d.enable(d.CULL_FACE):d.disable(d.CULL_FACE),this.current=s,this.dirty=!1}}class g_ extends _n{getDefault(){return this.gl.BACK}set(s){(s!==this.current||this.dirty)&&(this.gl.cullFace(s),this.current=s,this.dirty=!1)}}class cu extends _n{getDefault(){return this.gl.CCW}set(s){(s!==this.current||this.dirty)&&(this.gl.frontFace(s),this.current=s,this.dirty=!1)}}class y_ extends _n{getDefault(){return null}set(s){(s!==this.current||this.dirty)&&(this.gl.useProgram(s),this.current=s,this.dirty=!1)}}class __ extends _n{getDefault(){return this.gl.TEXTURE0}set(s){(s!==this.current||this.dirty)&&(this.gl.activeTexture(s),this.current=s,this.dirty=!1)}}class cm extends _n{getDefault(){const s=this.gl;return[0,0,s.drawingBufferWidth,s.drawingBufferHeight]}set(s){const d=this.current;(s[0]!==d[0]||s[1]!==d[1]||s[2]!==d[2]||s[3]!==d[3]||this.dirty)&&(this.gl.viewport(s[0],s[1],s[2],s[3]),this.current=s,this.dirty=!1)}}class um extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindFramebuffer(d.FRAMEBUFFER,s),this.current=s,this.dirty=!1}}class hm extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindRenderbuffer(d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class sd extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindTexture(d.TEXTURE_2D,s),this.current=s,this.dirty=!1}}class dm extends _n{getDefault(){return null}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.bindBuffer(d.ARRAY_BUFFER,s),this.current=s,this.dirty=!1}}class uu extends _n{getDefault(){return null}set(s){const d=this.gl;d.bindBuffer(d.ELEMENT_ARRAY_BUFFER,s),this.current=s,this.dirty=!1}}class Hs extends _n{getDefault(){return null}set(s){var d;if(s===this.current&&!this.dirty)return;const m=this.gl;ho(m)?m.bindVertexArray(s):(d=m.getExtension("OES_vertex_array_object"))===null||d===void 0||d.bindVertexArrayOES(s),this.current=s,this.dirty=!1}}class od extends _n{getDefault(){return 4}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_ALIGNMENT,s),this.current=s,this.dirty=!1}}class ad extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_PREMULTIPLY_ALPHA_WEBGL,s),this.current=s,this.dirty=!1}}class ld extends _n{getDefault(){return!1}set(s){if(s===this.current&&!this.dirty)return;const d=this.gl;d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,s),this.current=s,this.dirty=!1}}class hu extends _n{constructor(s,d){super(s),this.context=s,this.parent=d}getDefault(){return null}}class cd extends hu{setDirty(){this.dirty=!0}set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferTexture2D(d.FRAMEBUFFER,d.COLOR_ATTACHMENT0,d.TEXTURE_2D,s,0),this.current=s,this.dirty=!1}}class Ho extends hu{set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class ud extends hu{set(s){if(s===this.current&&!this.dirty)return;this.context.bindFramebuffer.set(this.parent);const d=this.gl;d.framebufferRenderbuffer(d.FRAMEBUFFER,d.DEPTH_STENCIL_ATTACHMENT,d.RENDERBUFFER,s),this.current=s,this.dirty=!1}}class b_{constructor(s,d,m,y,x){this.context=s,this.width=d,this.height=m;const M=s.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new cd(s,P),y)this.depthAttachment=x?new ud(s,P):new Ho(s,P);else if(x)throw new Error("Stencil cannot be set without depth");if(M.checkFramebufferStatus(M.FRAMEBUFFER)!==M.FRAMEBUFFER_COMPLETE)throw new Error("Framebuffer is not complete")}destroy(){const s=this.context.gl,d=this.colorAttachment.get();if(d&&s.deleteTexture(d),this.depthAttachment){const m=this.depthAttachment.get();m&&s.deleteRenderbuffer(m)}s.deleteFramebuffer(this.framebuffer)}}class Jn{constructor(s,d,m){this.blendFunction=s,this.blendColor=d,this.mask=m}}Jn.Replace=[1,0],Jn.disabled=new Jn(Jn.Replace,l.aM.transparent,[!1,!1,!1,!1]),Jn.unblended=new Jn(Jn.Replace,l.aM.transparent,[!0,!0,!0,!0]),Jn.alphaBlended=new Jn([1,771],l.aM.transparent,[!0,!0,!0,!0]);class x_{constructor(s){var d,m;if(this.gl=s,this.clearColor=new lu(this),this.clearDepth=new d_(this),this.clearStencil=new Oa(this),this.colorMask=new p_(this),this.depthMask=new tm(this),this.stencilMask=new f_(this),this.stencilFunc=new nm(this),this.stencilOp=new rd(this),this.stencilTest=new im(this),this.depthRange=new rm(this),this.depthTest=new sm(this),this.depthFunc=new om(this),this.blend=new Uo(this),this.blendFunc=new am(this),this.blendColor=new m_(this),this.blendEquation=new lm(this),this.cullFace=new $l(this),this.cullFaceSide=new g_(this),this.frontFace=new cu(this),this.program=new y_(this),this.activeTexture=new __(this),this.viewport=new cm(this),this.bindFramebuffer=new um(this),this.bindRenderbuffer=new hm(this),this.bindTexture=new sd(this),this.bindVertexBuffer=new dm(this),this.bindElementBuffer=new uu(this),this.bindVertexArray=new Hs(this),this.pixelStoreUnpack=new od(this),this.pixelStoreUnpackPremultiplyAlpha=new ad(this),this.pixelStoreUnpackFlipY=new ld(this),this.extTextureFilterAnisotropic=s.getExtension("EXT_texture_filter_anisotropic")||s.getExtension("MOZ_EXT_texture_filter_anisotropic")||s.getExtension("WEBKIT_EXT_texture_filter_anisotropic"),this.extTextureFilterAnisotropic&&(this.extTextureFilterAnisotropicMax=s.getParameter(this.extTextureFilterAnisotropic.MAX_TEXTURE_MAX_ANISOTROPY_EXT)),this.maxTextureSize=s.getParameter(s.MAX_TEXTURE_SIZE),ho(s)){this.HALF_FLOAT=s.HALF_FLOAT;const y=s.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(d=s.RGBA16F)!==null&&d!==void 0?d:y==null?void 0:y.RGBA16F_EXT,this.RGB16F=(m=s.RGB16F)!==null&&m!==void 0?m:y==null?void 0:y.RGB16F_EXT,s.getExtension("EXT_color_buffer_float")}else{s.getExtension("EXT_color_buffer_half_float"),s.getExtension("OES_texture_half_float_linear");const y=s.getExtension("OES_texture_half_float");this.HALF_FLOAT=y==null?void 0:y.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(s,d){return new Ms(this,s,d)}createVertexBuffer(s,d,m){return new id(this,s,d,m)}createRenderbuffer(s,d,m){const y=this.gl,x=y.createRenderbuffer();return this.bindRenderbuffer.set(x),y.renderbufferStorage(y.RENDERBUFFER,s,d,m),this.bindRenderbuffer.set(null),x}createFramebuffer(s,d,m,y){return new b_(this,s,d,m,y)}clear({color:s,depth:d,stencil:m}){const y=this.gl;let x=0;s&&(x|=y.COLOR_BUFFER_BIT,this.clearColor.set(s),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(x|=y.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),m!==void 0&&(x|=y.STENCIL_BUFFER_BIT,this.clearStencil.set(m),this.stencilMask.set(255)),y.clear(x)}setCullFace(s){s.enable===!1?this.cullFace.set(!1):(this.cullFace.set(!0),this.cullFaceSide.set(s.mode),this.frontFace.set(s.frontFace))}setDepthMode(s){s.func!==this.gl.ALWAYS||s.mask?(this.depthTest.set(!0),this.depthFunc.set(s.func),this.depthMask.set(s.mask),this.depthRange.set(s.range)):this.depthTest.set(!1)}setStencilMode(s){s.test.func!==this.gl.ALWAYS||s.mask?(this.stencilTest.set(!0),this.stencilMask.set(s.mask),this.stencilOp.set([s.fail,s.depthFail,s.pass]),this.stencilFunc.set({func:s.test.func,ref:s.ref,mask:s.test.mask})):this.stencilTest.set(!1)}setColorMode(s){l.aE(s.blendFunction,Jn.Replace)?this.blend.set(!1):(this.blend.set(!0),this.blendFunc.set(s.blendFunction),this.blendColor.set(s.blendColor)),this.colorMask.set(s.mask)}createVertexArray(){var s;return ho(this.gl)?this.gl.createVertexArray():(s=this.gl.getExtension("OES_vertex_array_object"))===null||s===void 0?void 0:s.createVertexArrayOES()}deleteVertexArray(s){var d;return ho(this.gl)?this.gl.deleteVertexArray(s):(d=this.gl.getExtension("OES_vertex_array_object"))===null||d===void 0?void 0:d.deleteVertexArrayOES(s)}unbindVAO(){this.bindVertexArray.set(null)}}class Gt{constructor(s,d,m){this.func=s,this.mask=d,this.range=m}}Gt.ReadOnly=!1,Gt.ReadWrite=!0,Gt.disabled=new Gt(519,Gt.ReadOnly,[0,1]);const du=7680;class On{constructor(s,d,m,y,x,M){this.test=s,this.ref=d,this.mask=m,this.fail=y,this.depthFail=x,this.pass=M}}On.disabled=new On({func:519,mask:0},0,0,du,du,du);class Tn{constructor(s,d,m){this.enable=s,this.mode=d,this.frontFace=m}}let qo;function jl(v,s,d,m,y){const x=v.context,M=x.gl,P=v.useProgram("collisionBox"),O=[];let z=0,V=0;for(let ce=0;ce<m.length;ce++){const he=m[ce],ne=s.getTile(he).getBucket(d);if(!ne)continue;const me=y?ne.textCollisionBox:ne.iconCollisionBox,ge=ne.collisionCircleArray;if(ge.length>0){const xe=l.H();l.aQ(xe,ne.placementInvProjMatrix,v.transform.glCoordMatrix),l.aQ(xe,xe,ne.placementViewportMatrix),O.push({circleArray:ge,circleOffset:V,transform:he.posMatrix,invTransform:xe,coord:he}),z+=ge.length/4,V=z}me&&P.draw(x,M.LINES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,{u_matrix:he.posMatrix,u_pixel_extrude_scale:[1/(F=v.transform).width,1/F.height]},v.style.map.terrain&&v.style.map.terrain.getTerrainData(he),d.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,v.transform.zoom,null,null,me.collisionVertexBuffer)}var F;if(!y||!O.length)return;const W=v.useProgram("collisionCircle"),J=new l.aR;J.resize(4*z),J._trim();let ee=0;for(const ce of O)for(let he=0;he<ce.circleArray.length/4;he++){const ne=4*he,me=ce.circleArray[ne+0],ge=ce.circleArray[ne+1],xe=ce.circleArray[ne+2],De=ce.circleArray[ne+3];J.emplace(ee++,me,ge,xe,De,0),J.emplace(ee++,me,ge,xe,De,1),J.emplace(ee++,me,ge,xe,De,2),J.emplace(ee++,me,ge,xe,De,3)}(!qo||qo.length<2*z)&&(qo=function(ce){const he=2*ce,ne=new l.aT;ne.resize(he),ne._trim();for(let me=0;me<he;me++){const ge=6*me;ne.uint16[ge+0]=4*me+0,ne.uint16[ge+1]=4*me+1,ne.uint16[ge+2]=4*me+2,ne.uint16[ge+3]=4*me+2,ne.uint16[ge+4]=4*me+3,ne.uint16[ge+5]=4*me+0}return ne}(z));const se=x.createIndexBuffer(qo,!0),le=x.createVertexBuffer(J,l.aS.members,!0);for(const ce of O){const he=$o(ce.transform,ce.invTransform,v.transform);W.draw(x,M.TRIANGLES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,he,v.style.map.terrain&&v.style.map.terrain.getTerrainData(ce.coord),d.id,le,se,l.a0.simpleSegment(0,2*ce.circleOffset,ce.circleArray.length,ce.circleArray.length/2),null,v.transform.zoom,null,null,null)}le.destroy(),se.destroy()}Tn.disabled=new Tn(!1,1029,2305),Tn.backCCW=new Tn(!0,1029,2305);const Ul=l.an(new Float32Array(16));function hd(v,s,d,m,y,x){const{horizontalAlign:M,verticalAlign:P}=l.au(v);return new l.P((-(M-.5)*s/y+m[0])*x,(-(P-.5)*d/y+m[1])*x)}function Wo(v,s,d,m,y,x){const M=s.tileAnchorPoint.add(new l.P(s.translation[0],s.translation[1]));if(s.pitchWithMap){let P=m.mult(x);d||(P=P.rotate(-y));const O=M.add(P);return oe(O.x,O.y,s.labelPlaneMatrix,s.getElevation).point}if(d){const P=Te(s.tileAnchorPoint.x+1,s.tileAnchorPoint.y,s).point.sub(v),O=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return v.add(m.rotate(O))}return v.add(m)}function Ba(v,s,d,m,y,x,M,P,O,z,V,F,W,J){const ee=v.text.placedSymbolArray,se=v.text.dynamicLayoutVertexArray,le=v.icon.dynamicLayoutVertexArray,ce={};se.clear();for(let he=0;he<ee.length;he++){const ne=ee.get(he),me=ne.hidden||!ne.crossTileID||v.allowVerticalPlacement&&!ne.placedOrientation?null:m[ne.crossTileID];if(me){const ge=new l.P(ne.anchorX,ne.anchorY),xe={getElevation:J,width:y.width,height:y.height,labelPlaneMatrix:x,lineVertexArray:null,pitchWithMap:d,projection:V,projectionCache:null,tileAnchorPoint:ge,translation:F,unwrappedTileID:W},De=d?oe(ge.x,ge.y,M,J):Te(ge.x,ge.y,xe),Ve=H(y.cameraToCenterDistance,De.signedDistanceFromCamera);let Je=l.ai(v.textSizeData,O,ne)*Ve/l.ap;d&&(Je*=v.tilePixelRatio/P);const{width:st,height:Ze,anchor:We,textOffset:mt,textBoxScale:Ot}=me,Xe=hd(We,st,Ze,mt,Ot,Je),nt=V.getPitchedTextCorrection(y,ge.add(new l.P(F[0],F[1])),W),It=Wo(De.point,xe,s,Xe,y.angle,nt),Fn=v.allowVerticalPlacement&&ne.placedOrientation===l.ah.vertical?Math.PI/2:0;for(let $t=0;$t<ne.numGlyphs;$t++)l.aj(se,It,Fn);z&&ne.associatedIconIndex>=0&&(ce[ne.associatedIconIndex]={shiftedAnchor:It,angle:Fn})}else kt(ne.numGlyphs,se)}if(z){le.clear();const he=v.icon.placedSymbolArray;for(let ne=0;ne<he.length;ne++){const me=he.get(ne);if(me.hidden)kt(me.numGlyphs,le);else{const ge=ce[ne];if(ge)for(let xe=0;xe<me.numGlyphs;xe++)l.aj(le,ge.shiftedAnchor,ge.angle);else kt(me.numGlyphs,le)}}v.icon.dynamicLayoutVertexBuffer.updateData(le)}v.text.dynamicLayoutVertexBuffer.updateData(se)}function Rr(v,s,d){return d.iconsInText&&s?"symbolTextAndIcon":v?"symbolSDF":"symbolIcon"}function dd(v,s,d,m,y,x,M,P,O,z,V,F){const W=v.context,J=W.gl,ee=v.transform,se=Vo(),le=P==="map",ce=O==="map",he=P!=="viewport"&&d.layout.get("symbol-placement")!=="point",ne=le&&!ce&&!he,me=!ce&&he,ge=!d.layout.get("symbol-sort-key").isConstant();let xe=!1;const De=v.depthModeForSublayer(0,Gt.ReadOnly),Ve=d._unevaluatedLayout.hasValue("text-variable-anchor")||d._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Je=[],st=se.getCircleRadiusCorrection(ee);for(const Ze of m){const We=s.getTile(Ze),mt=We.getBucket(d);if(!mt)continue;const Ot=y?mt.text:mt.icon;if(!Ot||!Ot.segments.get().length||!Ot.hasVisibleVertices)continue;const Xe=Ot.programConfigurations.get(d.id),nt=y||mt.sdfIcons,It=y?mt.textSizeData:mt.iconSizeData,Fn=ce||ee.pitch!==0,$t=v.useProgram(Rr(nt,y,mt),Xe),Jt=l.ag(It,ee.zoom),$n=v.style.map.terrain&&v.style.map.terrain.getTerrainData(Ze);let Bi,is,jn,rr,Gi=[0,0],Ni=null;if(y)is=We.glyphAtlasTexture,jn=J.LINEAR,Bi=We.glyphAtlasTexture.size,mt.iconsInText&&(Gi=We.imageAtlasTexture.size,Ni=We.imageAtlasTexture,rr=Fn||v.options.rotating||v.options.zooming||It.kind==="composite"||It.kind==="camera"?J.LINEAR:J.NEAREST);else{const tn=d.layout.get("icon-size").constantOr(0)!==1||mt.iconsNeedLinear;is=We.imageAtlasTexture,jn=nt||v.options.rotating||v.options.zooming||tn||Fn?J.LINEAR:J.NEAREST,Bi=We.imageAtlasTexture.size}const Zi=Kt(We,1,v.transform.zoom),Is=me?Ze.posMatrix:Ul,Xa=qi(Is,ce,le,v.transform,Zi),Iu=fr(Is,ce,le,v.transform,Zi),Ka=fr(Ze.posMatrix,ce,le,v.transform,Zi),Fr=se.translatePosition(v.transform,We,x,M),Du=Ve&&mt.hasTextData(),Rd=d.layout.get("icon-text-fit")!=="none"&&Du&&mt.hasIconData();if(he){const tn=v.style.map.terrain?(Ja,Qa)=>v.style.map.terrain.getElevation(Ze,Ja,Qa):null,Ko=d.layout.get("text-rotation-alignment")==="map";X(mt,Ze.posMatrix,v,y,Xa,Ka,ce,z,Ko,se,Ze.toUnwrapped(),ee.width,ee.height,Fr,tn)}const $r=Ze.posMatrix,jr=y&&Ve||Rd,po=he||jr?Ul:Xa,rs=Iu,Ei=nt&&d.paint.get(y?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let zi;zi=nt?mt.iconsInText?ed(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,Bi,Gi,st):Fl(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,y,Bi,!0,st):em(It.kind,Jt,ne,ce,he,jr,v,$r,po,rs,Fr,y,Bi,st);const xr={program:$t,buffers:Ot,uniformValues:zi,atlasTexture:is,atlasTextureIcon:Ni,atlasInterpolation:jn,atlasInterpolationIcon:rr,isSDF:nt,hasHalo:Ei};if(ge&&mt.canOverlap){xe=!0;const tn=Ot.segments.get();for(const Ko of tn)Je.push({segments:new l.a0([Ko]),sortKey:Ko.sortKey,state:xr,terrainData:$n})}else Je.push({segments:Ot.segments,sortKey:0,state:xr,terrainData:$n})}xe&&Je.sort((Ze,We)=>Ze.sortKey-We.sortKey);for(const Ze of Je){const We=Ze.state;if(W.activeTexture.set(J.TEXTURE0),We.atlasTexture.bind(We.atlasInterpolation,J.CLAMP_TO_EDGE),We.atlasTextureIcon&&(W.activeTexture.set(J.TEXTURE1),We.atlasTextureIcon&&We.atlasTextureIcon.bind(We.atlasInterpolationIcon,J.CLAMP_TO_EDGE)),We.isSDF){const mt=We.uniformValues;We.hasHalo&&(mt.u_is_halo=1,pd(We.buffers,Ze.segments,d,v,We.program,De,V,F,mt,Ze.terrainData)),mt.u_is_halo=0}pd(We.buffers,Ze.segments,d,v,We.program,De,V,F,We.uniformValues,Ze.terrainData)}}function pd(v,s,d,m,y,x,M,P,O,z){const V=m.context;y.draw(V,V.gl.TRIANGLES,x,M,P,Tn.disabled,O,z,d.id,v.layoutVertexBuffer,v.indexBuffer,s,d.paint,m.transform.zoom,v.programConfigurations.get(d.id),v.dynamicLayoutVertexBuffer,v.opacityVertexBuffer)}function fd(v,s,d,m){const y=v.context,x=y.gl,M=On.disabled,P=new Jn([x.ONE,x.ONE],l.aM.transparent,[!0,!0,!0,!0]),O=s.getBucket(d);if(!O)return;const z=m.key;let V=d.heatmapFbos.get(z);V||(V=Hl(y,s.tileSize,s.tileSize),d.heatmapFbos.set(z,V)),y.bindFramebuffer.set(V.framebuffer),y.viewport.set([0,0,s.tileSize,s.tileSize]),y.clear({color:l.aM.transparent});const F=O.programConfigurations.get(d.id),W=v.useProgram("heatmap",F),J=v.style.map.terrain.getTerrainData(m);W.draw(y,x.TRIANGLES,Gt.disabled,M,P,Tn.disabled,ir(m.posMatrix,s,v.transform.zoom,d.paint.get("heatmap-intensity")),J,d.id,O.layoutVertexBuffer,O.indexBuffer,O.segments,d.paint,v.transform.zoom,F)}function Go(v,s,d){const m=v.context,y=m.gl;m.setColorMode(v.colorModeForRenderPass());const x=ql(m,s),M=d.key,P=s.heatmapFbos.get(M);P&&(m.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,P.colorAttachment.get()),m.activeTexture.set(y.TEXTURE1),x.bind(y.LINEAR,y.CLAMP_TO_EDGE),v.useProgram("heatmapTexture").draw(m,y.TRIANGLES,Gt.disabled,On.disabled,v.colorModeForRenderPass(),Tn.disabled,ru(v,s,0,1),null,s.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments,s.paint,v.transform.zoom),P.destroy(),s.heatmapFbos.delete(M))}function Hl(v,s,d){var m,y;const x=v.gl,M=x.createTexture();x.bindTexture(x.TEXTURE_2D,M),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_S,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_WRAP_T,x.CLAMP_TO_EDGE),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MIN_FILTER,x.LINEAR),x.texParameteri(x.TEXTURE_2D,x.TEXTURE_MAG_FILTER,x.LINEAR);const P=(m=v.HALF_FLOAT)!==null&&m!==void 0?m:x.UNSIGNED_BYTE,O=(y=v.RGBA16F)!==null&&y!==void 0?y:x.RGBA;x.texImage2D(x.TEXTURE_2D,0,O,s,d,0,x.RGBA,P,null);const z=v.createFramebuffer(s,d,!1,!1);return z.colorAttachment.set(M),z}function ql(v,s){return s.colorRampTexture||(s.colorRampTexture=new tt(v,s.colorRamp,v.gl.RGBA)),s.colorRampTexture}function Na(v,s,d,m,y){if(!d||!m||!m.imageAtlas)return;const x=m.imageAtlas.patternPositions;let M=x[d.to.toString()],P=x[d.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const O=y.getPaintProperty(s);M=x[O],P=x[O]}M&&P&&v.setConstantPatternPositions(M,P)}function Wl(v,s,d,m,y,x,M){const P=v.context.gl,O="fill-pattern",z=d.paint.get(O),V=z&&z.constantOr(1),F=d.getCrossfadeParameters();let W,J,ee,se,le;M?(J=V&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",W=P.LINES):(J=V?"fillPattern":"fill",W=P.TRIANGLES);const ce=z.constantOr(null);for(const he of m){const ne=s.getTile(he);if(V&&!ne.patternsLoaded())continue;const me=ne.getBucket(d);if(!me)continue;const ge=me.programConfigurations.get(d.id),xe=v.useProgram(J,ge),De=v.style.map.terrain&&v.style.map.terrain.getTerrainData(he);V&&(v.context.activeTexture.set(P.TEXTURE0),ne.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ge.updatePaintBuffers(F)),Na(ge,O,ce,ne,d);const Ve=De?he:null,Je=v.translatePosMatrix(Ve?Ve.posMatrix:he.posMatrix,ne,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(M){se=me.indexBuffer2,le=me.segments2;const st=[P.drawingBufferWidth,P.drawingBufferHeight];ee=J==="fillOutlinePattern"&&V?Xf(Je,v,F,ne,st):o_(Je,st)}else se=me.indexBuffer,le=me.segments,ee=V?Yf(Je,v,F,ne):Ia(Je);xe.draw(v.context,W,y,v.stencilModeForClipping(he),x,Tn.disabled,ee,De,d.id,me.layoutVertexBuffer,se,le,d.paint,v.transform.zoom,ge)}}function pu(v,s,d,m,y,x,M){const P=v.context,O=P.gl,z="fill-extrusion-pattern",V=d.paint.get(z),F=V.constantOr(1),W=d.getCrossfadeParameters(),J=d.paint.get("fill-extrusion-opacity"),ee=V.constantOr(null);for(const se of m){const le=s.getTile(se),ce=le.getBucket(d);if(!ce)continue;const he=v.style.map.terrain&&v.style.map.terrain.getTerrainData(se),ne=ce.programConfigurations.get(d.id),me=v.useProgram(F?"fillExtrusionPattern":"fillExtrusion",ne);F&&(v.context.activeTexture.set(O.TEXTURE0),le.imageAtlasTexture.bind(O.LINEAR,O.CLAMP_TO_EDGE),ne.updatePaintBuffers(W)),Na(ne,z,ee,le,d);const ge=v.translatePosMatrix(se.posMatrix,le,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),xe=d.paint.get("fill-extrusion-vertical-gradient"),De=F?iu(ge,v,xe,J,se,W,le):Ll(ge,v,xe,J);me.draw(P,P.gl.TRIANGLES,y,x,M,Tn.backCCW,De,he,d.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,d.paint,v.transform.zoom,ne,v.style.map.terrain&&ce.centroidVertexBuffer)}}function za(v,s,d,m,y,x,M){const P=v.context,O=P.gl,z=d.fbo;if(!z)return;const V=v.useProgram("hillshade"),F=v.style.map.terrain&&v.style.map.terrain.getTerrainData(s);P.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,z.colorAttachment.get()),V.draw(P,O.TRIANGLES,y,x,M,Tn.disabled,((W,J,ee,se)=>{const le=ee.paint.get("hillshade-shadow-color"),ce=ee.paint.get("hillshade-highlight-color"),he=ee.paint.get("hillshade-accent-color");let ne=ee.paint.get("hillshade-illumination-direction")*(Math.PI/180);ee.paint.get("hillshade-illumination-anchor")==="viewport"&&(ne-=W.transform.angle);const me=!W.options.moving;return{u_matrix:se?se.posMatrix:W.transform.calculatePosMatrix(J.tileID.toUnwrapped(),me),u_image:0,u_latrange:su(0,J.tileID),u_light:[ee.paint.get("hillshade-exaggeration"),ne],u_shadow:le,u_highlight:ce,u_accent:he}})(v,d,m,F?s:null),F,m.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments)}function Ra(v,s,d,m,y,x){const M=v.context,P=M.gl,O=s.dem;if(O&&O.data){const z=O.dim,V=O.stride,F=O.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),s.demTexture=s.demTexture||v.getTileTexture(V),s.demTexture){const J=s.demTexture;J.update(F,{premultiply:!1}),J.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else s.demTexture=new tt(M,F,P.RGBA,{premultiply:!1}),s.demTexture.bind(P.NEAREST,P.CLAMP_TO_EDGE);M.activeTexture.set(P.TEXTURE0);let W=s.fbo;if(!W){const J=new tt(M,{width:z,height:z,data:null},P.RGBA);J.bind(P.LINEAR,P.CLAMP_TO_EDGE),W=s.fbo=M.createFramebuffer(z,z,!0,!1),W.colorAttachment.set(J.texture)}M.bindFramebuffer.set(W.framebuffer),M.viewport.set([0,0,z,z]),v.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,m,y,x,Tn.disabled,((J,ee)=>{const se=ee.stride,le=l.H();return l.aP(le,0,l.X,-l.X,0,0,1),l.J(le,le,[0,-l.X,0]),{u_matrix:le,u_image:1,u_dimension:[se,se],u_zoom:J.overscaledZ,u_unpack:ee.getUnpackVector()}})(s.tileID,O),null,d.id,v.rasterBoundsBuffer,v.quadTriangleIndexBuffer,v.rasterBoundsSegments),s.needsHillshadePrepare=!1}}function pm(v,s,d,m,y,x){const M=m.paint.get("raster-fade-duration");if(!x&&M>0){const P=E.now(),O=(P-v.timeAdded)/M,z=s?(P-s.timeAdded)/M:-1,V=d.getSource(),F=y.coveringZoomLevel({tileSize:V.tileSize,roundZoom:V.roundZoom}),W=!s||Math.abs(s.tileID.overscaledZ-F)>Math.abs(v.tileID.overscaledZ-F),J=W&&v.refreshedUponExpiration?1:l.ac(W?O:1-z,0,1);return v.refreshedUponExpiration&&O>=1&&(v.refreshedUponExpiration=!1),s?{opacity:1,mix:1-J}:{opacity:J,mix:0}}return{opacity:1,mix:0}}const md=new l.aM(1,0,0,1),un=new l.aM(0,1,0,1),fu=new l.aM(0,0,1,1),v_=new l.aM(1,0,1,1),fm=new l.aM(0,1,1,1);function La(v,s,d,m){mu(v,0,s+d/2,v.transform.width,d,m)}function mm(v,s,d,m){mu(v,s-d/2,0,d,v.transform.height,m)}function mu(v,s,d,m,y,x){const M=v.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(s*v.pixelRatio,d*v.pixelRatio,m*v.pixelRatio,y*v.pixelRatio),M.clear({color:x}),P.disable(P.SCISSOR_TEST)}function gm(v,s,d){const m=v.context,y=m.gl,x=d.posMatrix,M=v.useProgram("debug"),P=Gt.disabled,O=On.disabled,z=v.colorModeForRenderPass(),V="$debug",F=v.style.map.terrain&&v.style.map.terrain.getTerrainData(d);m.activeTexture.set(y.TEXTURE0);const W=s.getTileByID(d.key).latestRawTileData,J=Math.floor((W&&W.byteLength||0)/1024),ee=s.getTile(d).tileSize,se=512/Math.min(ee,512)*(d.overscaledZ/v.transform.zoom)*.5;let le=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(le+=` => ${d.overscaledZ}`),function(ce,he){ce.initDebugOverlayCanvas();const ne=ce.debugOverlayCanvas,me=ce.context.gl,ge=ce.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,ne.width,ne.height),ge.shadowColor="white",ge.shadowBlur=2,ge.lineWidth=1.5,ge.strokeStyle="white",ge.textBaseline="top",ge.font="bold 36px Open Sans, sans-serif",ge.fillText(he,5,5),ge.strokeText(he,5,5),ce.debugOverlayTexture.update(ne),ce.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(v,`${le} ${J}kB`),M.draw(m,y.TRIANGLES,P,O,Jn.alphaBlended,Tn.disabled,Vl(x,l.aM.transparent,se),null,V,v.debugBuffer,v.quadTriangleIndexBuffer,v.debugSegments),M.draw(m,y.LINE_STRIP,P,O,z,Tn.disabled,Vl(x,l.aM.red),F,V,v.debugBuffer,v.tileBorderIndexBuffer,v.debugSegments)}function ym(v,s,d){const m=v.context,y=m.gl,x=v.colorModeForRenderPass(),M=new Gt(y.LEQUAL,Gt.ReadWrite,v.depthRangeFor3D),P=v.useProgram("terrain"),O=s.getTerrainMesh();m.bindFramebuffer.set(null),m.viewport.set([0,0,v.width,v.height]);for(const z of d){const V=v.renderToTexture.getTexture(z),F=s.getTerrainData(z.tileID);m.activeTexture.set(y.TEXTURE0),y.bindTexture(y.TEXTURE_2D,V.texture);const W=v.transform.calculatePosMatrix(z.tileID.toUnwrapped()),J=s.getMeshFrameDelta(v.transform.zoom),ee=v.transform.calculateFogMatrix(z.tileID.toUnwrapped()),se=Jh(W,J,ee,v.style.sky,v.transform.pitch);P.draw(m,y.TRIANGLES,M,On.disabled,x,Tn.backCCW,se,F,"terrain",O.vertexBuffer,O.indexBuffer,O.segments)}}class gu{constructor(s,d,m){this.vertexBuffer=s,this.indexBuffer=d,this.segments=m}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class yu{constructor(s,d){this.context=new x_(s),this.transform=d,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=ze.maxUnderzooming+ze.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Xh}resize(s,d,m){if(this.width=Math.floor(s*m),this.height=Math.floor(d*m),this.pixelRatio=m,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const y of this.style._order)this.style._layers[y].resize()}setup(){const s=this.context,d=new l.aX;d.emplaceBack(0,0),d.emplaceBack(l.X,0),d.emplaceBack(0,l.X),d.emplaceBack(l.X,l.X),this.tileExtentBuffer=s.createVertexBuffer(d,Fo.members),this.tileExtentSegments=l.a0.simpleSegment(0,0,4,2);const m=new l.aX;m.emplaceBack(0,0),m.emplaceBack(l.X,0),m.emplaceBack(0,l.X),m.emplaceBack(l.X,l.X),this.debugBuffer=s.createVertexBuffer(m,Fo.members),this.debugSegments=l.a0.simpleSegment(0,0,4,5);const y=new l.$;y.emplaceBack(0,0,0,0),y.emplaceBack(l.X,0,l.X,0),y.emplaceBack(0,l.X,0,l.X),y.emplaceBack(l.X,l.X,l.X,l.X),this.rasterBoundsBuffer=s.createVertexBuffer(y,ui.members),this.rasterBoundsSegments=l.a0.simpleSegment(0,0,4,2);const x=new l.aX;x.emplaceBack(0,0),x.emplaceBack(1,0),x.emplaceBack(0,1),x.emplaceBack(1,1),this.viewportBuffer=s.createVertexBuffer(x,Fo.members),this.viewportSegments=l.a0.simpleSegment(0,0,4,2);const M=new l.aZ;M.emplaceBack(0),M.emplaceBack(1),M.emplaceBack(3),M.emplaceBack(2),M.emplaceBack(0),this.tileBorderIndexBuffer=s.createIndexBuffer(M);const P=new l.aY;P.emplaceBack(0,1,2),P.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=s.createIndexBuffer(P);const O=this.context.gl;this.stencilClearMode=new On({func:O.ALWAYS,mask:0},0,255,O.ZERO,O.ZERO,O.ZERO)}clearStencil(){const s=this.context,d=s.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const m=l.H();l.aP(m,0,this.width,this.height,0,0,1),l.K(m,m,[d.drawingBufferWidth,d.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(s,d.TRIANGLES,Gt.disabled,this.stencilClearMode,Jn.disabled,Tn.disabled,nr(m),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(s,d){if(this.currentStencilSource===s.source||!s.isTileClipped()||!d||!d.length)return;this.currentStencilSource=s.source;const m=this.context,y=m.gl;this.nextStencilID+d.length>256&&this.clearStencil(),m.setColorMode(Jn.disabled),m.setDepthMode(Gt.disabled);const x=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of d){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,O=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);x.draw(m,y.TRIANGLES,Gt.disabled,new On({func:y.ALWAYS,mask:0},P,255,y.KEEP,y.KEEP,y.REPLACE),Jn.disabled,Tn.disabled,nr(M.posMatrix),O,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const s=this.nextStencilID++,d=this.context.gl;return new On({func:d.NOTEQUAL,mask:255},s,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(s){const d=this.context.gl;return new On({func:d.EQUAL,mask:255},this._tileClippingMaskIDs[s.key],0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(s){const d=this.context.gl,m=s.sort((M,P)=>P.overscaledZ-M.overscaledZ),y=m[m.length-1].overscaledZ,x=m[0].overscaledZ-y+1;if(x>1){this.currentStencilSource=void 0,this.nextStencilID+x>256&&this.clearStencil();const M={};for(let P=0;P<x;P++)M[P+y]=new On({func:d.GEQUAL,mask:255},P+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=x,[M,m]}return[{[y]:On.disabled},m]}colorModeForRenderPass(){const s=this.context.gl;return this._showOverdrawInspector?new Jn([s.CONSTANT_COLOR,s.ONE],new l.aM(.125,.125,.125,0),[!0,!0,!0,!0]):this.renderPass==="opaque"?Jn.unblended:Jn.alphaBlended}depthModeForSublayer(s,d,m){if(!this.opaquePassEnabledForLayer())return Gt.disabled;const y=1-((1+this.currentLayer)*this.numSublayers+s)*this.depthEpsilon;return new Gt(m||this.context.gl.LEQUAL,d,[y,y])}opaquePassEnabledForLayer(){return this.currentLayer<this.opaquePassCutoff}render(s,d){this.style=s,this.options=d,this.lineAtlas=s.lineAtlas,this.imageManager=s.imageManager,this.glyphManager=s.glyphManager,this.symbolFadeChange=s.placement.symbolFadeChange(E.now()),this.imageManager.beginFrame();const m=this.style._order,y=this.style.sourceCaches,x={},M={},P={};for(const O in y){const z=y[O];z.used&&z.prepare(this.context),x[O]=z.getVisibleCoordinates(),M[O]=x[O].slice().reverse(),P[O]=z.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let O=0;O<m.length;O++)if(this.style._layers[m[O]].is3D()){this.opaquePassCutoff=O;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const O of m){const z=this.style._layers[O];if(!z.hasOffscreenPass()||z.isHidden(this.transform.zoom))continue;const V=M[z.source];(z.type==="custom"||V.length)&&this.renderLayer(this,y[z.source],z,V)}if(this.context.bindFramebuffer.set(null),this.context.clear({color:d.showOverdrawInspector?l.aM.black:l.aM.transparent,depth:1}),this.clearStencil(),this.style.sky&&function(O,z){const V=O.context,F=V.gl,W=((ce,he,ne)=>({u_sky_color:ce.properties.get("sky-color"),u_horizon_color:ce.properties.get("horizon-color"),u_horizon:(he.height/2+he.getHorizon())*ne,u_sky_horizon_blend:ce.properties.get("sky-horizon-blend")*he.height/2*ne}))(z,O.style.map.transform,O.pixelRatio),J=new Gt(F.LEQUAL,Gt.ReadWrite,[0,1]),ee=On.disabled,se=O.colorModeForRenderPass(),le=O.useProgram("sky");if(!z.mesh){const ce=new l.aX;ce.emplaceBack(-1,-1),ce.emplaceBack(1,-1),ce.emplaceBack(1,1),ce.emplaceBack(-1,1);const he=new l.aY;he.emplaceBack(0,1,2),he.emplaceBack(0,2,3),z.mesh=new gu(V.createVertexBuffer(ce,Fo.members),V.createIndexBuffer(he),l.a0.simpleSegment(0,0,ce.length,he.length))}le.draw(V,F.TRIANGLES,J,ee,se,Tn.disabled,W,void 0,"sky",z.mesh.vertexBuffer,z.mesh.indexBuffer,z.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=d.showOverdrawInspector,this.depthRangeFor3D=[0,1-(s._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=m.length-1;this.currentLayer>=0;this.currentLayer--){const O=this.style._layers[m[this.currentLayer]],z=y[O.source],V=x[O.source];this._renderTileClippingMasks(O,V),this.renderLayer(this,z,O,V)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<m.length;this.currentLayer++){const O=this.style._layers[m[this.currentLayer]],z=y[O.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(O))continue;const V=(O.type==="symbol"?P:M)[O.source];this._renderTileClippingMasks(O,x[O.source]),this.renderLayer(this,z,O,V)}if(this.options.showTileBoundaries){const O=function(z,V){let F=null;const W=Object.values(z._layers).flatMap(le=>le.source&&!le.isHidden(V)?[z.sourceCaches[le.source]]:[]),J=W.filter(le=>le.getSource().type==="vector"),ee=W.filter(le=>le.getSource().type!=="vector"),se=le=>{(!F||F.getSource().maxzoom<le.getSource().maxzoom)&&(F=le)};return J.forEach(le=>se(le)),F||ee.forEach(le=>se(le)),F}(this.style,this.transform.zoom);O&&function(z,V,F){for(let W=0;W<F.length;W++)gm(z,V,F[W])}(this,O,O.getVisibleCoordinates())}this.options.showPadding&&function(O){const z=O.transform.padding;La(O,O.transform.height-(z.top||0),3,md),La(O,z.bottom||0,3,un),mm(O,z.left||0,3,fu),mm(O,O.transform.width-(z.right||0),3,v_);const V=O.transform.centerPoint;(function(F,W,J,ee){mu(F,W-1,J-10,2,20,ee),mu(F,W-10,J-1,20,2,ee)})(O,V.x,O.transform.height-V.y,fm)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(s){if(!this.style||!this.style.map||!this.style.map.terrain)return;const d=this.terrainFacilitator.matrix,m=this.transform.modelViewProjectionMatrix;let y=this.terrainFacilitator.dirty;y||(y=s?!l.a_(d,m):!l.a$(d,m)),y||(y=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),y&&(l.b0(d,m),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(x,M){const P=x.context,O=P.gl,z=Jn.unblended,V=new Gt(O.LEQUAL,Gt.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.sourceCache.getRenderableTiles(),J=x.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1});for(const ee of W){const se=M.getTerrainData(ee.tileID),le={u_matrix:x.transform.calculatePosMatrix(ee.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(x.transform.zoom)};J.draw(P,O.TRIANGLES,V,On.disabled,z,Tn.backCCW,le,se,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain),function(x,M){const P=x.context,O=P.gl,z=Jn.unblended,V=new Gt(O.LEQUAL,Gt.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.getCoordsTexture(),J=M.sourceCache.getRenderableTiles(),ee=x.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,x.width/devicePixelRatio,x.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1}),M.coordsIndex=[];for(const se of J){const le=M.getTerrainData(se.tileID);P.activeTexture.set(O.TEXTURE0),O.bindTexture(O.TEXTURE_2D,W.texture);const ce={u_matrix:x.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(x.transform.zoom)};ee.draw(P,O.TRIANGLES,V,On.disabled,z,Tn.backCCW,ce,le,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),M.coordsIndex.push(se.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,x.width,x.height])}(this,this.style.map.terrain))}renderLayer(s,d,m,y){if(!m.isHidden(this.transform.zoom)&&(m.type==="background"||m.type==="custom"||(y||[]).length))switch(this.id=m.id,m.type){case"symbol":(function(x,M,P,O,z){if(x.renderPass!=="translucent")return;const V=On.disabled,F=x.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(W,J,ee,se,le,ce,he,ne,me){const ge=J.transform,xe=Vo(),De=le==="map",Ve=ce==="map";for(const Je of W){const st=se.getTile(Je),Ze=st.getBucket(ee);if(!Ze||!Ze.text||!Ze.text.segments.get().length)continue;const We=l.ag(Ze.textSizeData,ge.zoom),mt=Kt(st,1,J.transform.zoom),Ot=qi(Je.posMatrix,Ve,De,J.transform,mt),Xe=ee.layout.get("icon-text-fit")!=="none"&&Ze.hasIconData();if(We){const nt=Math.pow(2,ge.zoom-st.tileID.overscaledZ),It=J.style.map.terrain?($t,Jt)=>J.style.map.terrain.getElevation(Je,$t,Jt):null,Fn=xe.translatePosition(ge,st,he,ne);Ba(Ze,De,Ve,me,ge,Ot,Je.posMatrix,nt,We,Xe,xe,Fn,Je.toUnwrapped(),It)}}}(O,x,P,M,P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),z),P.paint.get("icon-opacity").constantOr(1)!==0&&dd(x,M,P,O,!1,P.paint.get("icon-translate"),P.paint.get("icon-translate-anchor"),P.layout.get("icon-rotation-alignment"),P.layout.get("icon-pitch-alignment"),P.layout.get("icon-keep-upright"),V,F),P.paint.get("text-opacity").constantOr(1)!==0&&dd(x,M,P,O,!0,P.paint.get("text-translate"),P.paint.get("text-translate-anchor"),P.layout.get("text-rotation-alignment"),P.layout.get("text-pitch-alignment"),P.layout.get("text-keep-upright"),V,F),M.map.showCollisionBoxes&&(jl(x,M,P,O,!0),jl(x,M,P,O,!1))})(s,d,m,y,this.style.placement.variableOffsets);break;case"circle":(function(x,M,P,O){if(x.renderPass!=="translucent")return;const z=P.paint.get("circle-opacity"),V=P.paint.get("circle-stroke-width"),F=P.paint.get("circle-stroke-opacity"),W=!P.layout.get("circle-sort-key").isConstant();if(z.constantOr(1)===0&&(V.constantOr(1)===0||F.constantOr(1)===0))return;const J=x.context,ee=J.gl,se=x.depthModeForSublayer(0,Gt.ReadOnly),le=On.disabled,ce=x.colorModeForRenderPass(),he=[];for(let ne=0;ne<O.length;ne++){const me=O[ne],ge=M.getTile(me),xe=ge.getBucket(P);if(!xe)continue;const De=xe.programConfigurations.get(P.id),Ve=x.useProgram("circle",De),Je=xe.layoutVertexBuffer,st=xe.indexBuffer,Ze=x.style.map.terrain&&x.style.map.terrain.getTerrainData(me),We={programConfiguration:De,program:Ve,layoutVertexBuffer:Je,indexBuffer:st,uniformValues:a_(x,me,ge,P),terrainData:Ze};if(W){const mt=xe.segments.get();for(const Ot of mt)he.push({segments:new l.a0([Ot]),sortKey:Ot.sortKey,state:We})}else he.push({segments:xe.segments,sortKey:0,state:We})}W&&he.sort((ne,me)=>ne.sortKey-me.sortKey);for(const ne of he){const{programConfiguration:me,program:ge,layoutVertexBuffer:xe,indexBuffer:De,uniformValues:Ve,terrainData:Je}=ne.state;ge.draw(J,ee.TRIANGLES,se,le,ce,Tn.disabled,Ve,Je,P.id,xe,De,ne.segments,P.paint,x.transform.zoom,me)}})(s,d,m,y);break;case"heatmap":(function(x,M,P,O){if(P.paint.get("heatmap-opacity")===0)return;const z=x.context;if(x.style.map.terrain){for(const V of O){const F=M.getTile(V);M.hasRenderableParent(V)||(x.renderPass==="offscreen"?fd(x,F,P,V):x.renderPass==="translucent"&&Go(x,P,V))}z.viewport.set([0,0,x.width,x.height])}else x.renderPass==="offscreen"?function(V,F,W,J){const ee=V.context,se=ee.gl,le=On.disabled,ce=new Jn([se.ONE,se.ONE],l.aM.transparent,[!0,!0,!0,!0]);(function(he,ne,me){const ge=he.gl;he.activeTexture.set(ge.TEXTURE1),he.viewport.set([0,0,ne.width/4,ne.height/4]);let xe=me.heatmapFbos.get(l.aU);xe?(ge.bindTexture(ge.TEXTURE_2D,xe.colorAttachment.get()),he.bindFramebuffer.set(xe.framebuffer)):(xe=Hl(he,ne.width/4,ne.height/4),me.heatmapFbos.set(l.aU,xe))})(ee,V,W),ee.clear({color:l.aM.transparent});for(let he=0;he<J.length;he++){const ne=J[he];if(F.hasRenderableParent(ne))continue;const me=F.getTile(ne),ge=me.getBucket(W);if(!ge)continue;const xe=ge.programConfigurations.get(W.id),De=V.useProgram("heatmap",xe),{zoom:Ve}=V.transform;De.draw(ee,se.TRIANGLES,Gt.disabled,le,ce,Tn.disabled,ir(ne.posMatrix,me,Ve,W.paint.get("heatmap-intensity")),null,W.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,W.paint,V.transform.zoom,xe)}ee.viewport.set([0,0,V.width,V.height])}(x,M,P,O):x.renderPass==="translucent"&&function(V,F){const W=V.context,J=W.gl;W.setColorMode(V.colorModeForRenderPass());const ee=F.heatmapFbos.get(l.aU);ee&&(W.activeTexture.set(J.TEXTURE0),J.bindTexture(J.TEXTURE_2D,ee.colorAttachment.get()),W.activeTexture.set(J.TEXTURE1),ql(W,F).bind(J.LINEAR,J.CLAMP_TO_EDGE),V.useProgram("heatmapTexture").draw(W,J.TRIANGLES,Gt.disabled,On.disabled,V.colorModeForRenderPass(),Tn.disabled,ru(V,F,0,1),null,F.id,V.viewportBuffer,V.quadTriangleIndexBuffer,V.viewportSegments,F.paint,V.transform.zoom))}(x,P)})(s,d,m,y);break;case"line":(function(x,M,P,O){if(x.renderPass!=="translucent")return;const z=P.paint.get("line-opacity"),V=P.paint.get("line-width");if(z.constantOr(1)===0||V.constantOr(1)===0)return;const F=x.depthModeForSublayer(0,Gt.ReadOnly),W=x.colorModeForRenderPass(),J=P.paint.get("line-dasharray"),ee=P.paint.get("line-pattern"),se=ee.constantOr(1),le=P.paint.get("line-gradient"),ce=P.getCrossfadeParameters(),he=se?"linePattern":J?"lineSDF":le?"lineGradient":"line",ne=x.context,me=ne.gl;let ge=!0;for(const xe of O){const De=M.getTile(xe);if(se&&!De.patternsLoaded())continue;const Ve=De.getBucket(P);if(!Ve)continue;const Je=Ve.programConfigurations.get(P.id),st=x.context.program.get(),Ze=x.useProgram(he,Je),We=ge||Ze.program!==st,mt=x.style.map.terrain&&x.style.map.terrain.getTerrainData(xe),Ot=ee.constantOr(null);if(Ot&&De.imageAtlas){const It=De.imageAtlas,Fn=It.patternPositions[Ot.to.toString()],$t=It.patternPositions[Ot.from.toString()];Fn&&$t&&Je.setConstantPatternPositions(Fn,$t)}const Xe=mt?xe:null,nt=se?Da(x,De,P,ce,Xe):J?l_(x,De,P,J,ce,Xe):le?Kf(x,De,P,Ve.lineClipsArray.length,Xe):ou(x,De,P,Xe);if(se)ne.activeTexture.set(me.TEXTURE0),De.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),Je.updatePaintBuffers(ce);else if(J&&(We||x.lineAtlas.dirty))ne.activeTexture.set(me.TEXTURE0),x.lineAtlas.bind(ne);else if(le){const It=Ve.gradients[P.id];let Fn=It.texture;if(P.gradientVersion!==It.version){let $t=256;if(P.stepInterpolant){const Jt=M.getSource().maxzoom,$n=xe.canonical.z===Jt?Math.ceil(1<<x.transform.maxZoom-xe.canonical.z):1;$t=l.ac(l.aV(Ve.maxLineLength/l.X*1024*$n),256,ne.maxTextureSize)}It.gradient=l.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:$t,image:It.gradient||void 0,clips:Ve.lineClipsArray}),It.texture?It.texture.update(It.gradient):It.texture=new tt(ne,It.gradient,me.RGBA),It.version=P.gradientVersion,Fn=It.texture}ne.activeTexture.set(me.TEXTURE0),Fn.bind(P.stepInterpolant?me.NEAREST:me.LINEAR,me.CLAMP_TO_EDGE)}Ze.draw(ne,me.TRIANGLES,F,x.stencilModeForClipping(xe),W,Tn.disabled,nt,mt,P.id,Ve.layoutVertexBuffer,Ve.indexBuffer,Ve.segments,P.paint,x.transform.zoom,Je,Ve.layoutVertexBuffer2),ge=!1}})(s,d,m,y);break;case"fill":(function(x,M,P,O){const z=P.paint.get("fill-color"),V=P.paint.get("fill-opacity");if(V.constantOr(1)===0)return;const F=x.colorModeForRenderPass(),W=P.paint.get("fill-pattern"),J=x.opaquePassEnabledForLayer()&&!W.constantOr(1)&&z.constantOr(l.aM.transparent).a===1&&V.constantOr(0)===1?"opaque":"translucent";if(x.renderPass===J){const ee=x.depthModeForSublayer(1,x.renderPass==="opaque"?Gt.ReadWrite:Gt.ReadOnly);Wl(x,M,P,O,ee,F,!1)}if(x.renderPass==="translucent"&&P.paint.get("fill-antialias")){const ee=x.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,Gt.ReadOnly);Wl(x,M,P,O,ee,F,!0)}})(s,d,m,y);break;case"fill-extrusion":(function(x,M,P,O){const z=P.paint.get("fill-extrusion-opacity");if(z!==0&&x.renderPass==="translucent"){const V=new Gt(x.context.gl.LEQUAL,Gt.ReadWrite,x.depthRangeFor3D);if(z!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))pu(x,M,P,O,V,On.disabled,Jn.disabled),pu(x,M,P,O,V,x.stencilModeFor3D(),x.colorModeForRenderPass());else{const F=x.colorModeForRenderPass();pu(x,M,P,O,V,On.disabled,F)}}})(s,d,m,y);break;case"hillshade":(function(x,M,P,O){if(x.renderPass!=="offscreen"&&x.renderPass!=="translucent")return;const z=x.context,V=x.depthModeForSublayer(0,Gt.ReadOnly),F=x.colorModeForRenderPass(),[W,J]=x.renderPass==="translucent"?x.stencilConfigForOverlap(O):[{},O];for(const ee of J){const se=M.getTile(ee);se.needsHillshadePrepare!==void 0&&se.needsHillshadePrepare&&x.renderPass==="offscreen"?Ra(x,se,P,V,On.disabled,F):x.renderPass==="translucent"&&za(x,ee,se,P,V,W[ee.overscaledZ],F)}z.viewport.set([0,0,x.width,x.height])})(s,d,m,y);break;case"raster":(function(x,M,P,O){if(x.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!O.length)return;const z=x.context,V=z.gl,F=M.getSource(),W=x.useProgram("raster"),J=x.colorModeForRenderPass(),[ee,se]=F instanceof mi?[{},O]:x.stencilConfigForOverlap(O),le=se[se.length-1].overscaledZ,ce=!x.options.moving;for(const he of se){const ne=x.depthModeForSublayer(he.overscaledZ-le,P.paint.get("raster-opacity")===1?Gt.ReadWrite:Gt.ReadOnly,V.LESS),me=M.getTile(he);me.registerFadeDuration(P.paint.get("raster-fade-duration"));const ge=M.findLoadedParent(he,0),xe=M.findLoadedSibling(he),De=pm(me,ge||xe||null,M,P,x.transform,x.style.map.terrain);let Ve,Je;const st=P.paint.get("raster-resampling")==="nearest"?V.NEAREST:V.LINEAR;z.activeTexture.set(V.TEXTURE0),me.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),z.activeTexture.set(V.TEXTURE1),ge?(ge.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),Ve=Math.pow(2,ge.tileID.overscaledZ-me.tileID.overscaledZ),Je=[me.tileID.canonical.x*Ve%1,me.tileID.canonical.y*Ve%1]):me.texture.bind(st,V.CLAMP_TO_EDGE,V.LINEAR_MIPMAP_NEAREST),me.texture.useMipmap&&z.extTextureFilterAnisotropic&&x.transform.pitch>20&&V.texParameterf(V.TEXTURE_2D,z.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,z.extTextureFilterAnisotropicMax);const Ze=x.style.map.terrain&&x.style.map.terrain.getTerrainData(he),We=Ze?he:null,mt=We?We.posMatrix:x.transform.calculatePosMatrix(he.toUnwrapped(),ce),Ot=c_(mt,Je||[0,0],Ve||1,De,P);F instanceof mi?W.draw(z,V.TRIANGLES,ne,On.disabled,J,Tn.disabled,Ot,Ze,P.id,F.boundsBuffer,x.quadTriangleIndexBuffer,F.boundsSegments):W.draw(z,V.TRIANGLES,ne,ee[he.overscaledZ],J,Tn.disabled,Ot,Ze,P.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments)}})(s,d,m,y);break;case"background":(function(x,M,P,O){const z=P.paint.get("background-color"),V=P.paint.get("background-opacity");if(V===0)return;const F=x.context,W=F.gl,J=x.transform,ee=J.tileSize,se=P.paint.get("background-pattern");if(x.isPatternMissing(se))return;const le=!se&&z.a===1&&V===1&&x.opaquePassEnabledForLayer()?"opaque":"translucent";if(x.renderPass!==le)return;const ce=On.disabled,he=x.depthModeForSublayer(0,le==="opaque"?Gt.ReadWrite:Gt.ReadOnly),ne=x.colorModeForRenderPass(),me=x.useProgram(se?"backgroundPattern":"background"),ge=O||J.coveringTiles({tileSize:ee,terrain:x.style.map.terrain});se&&(F.activeTexture.set(W.TEXTURE0),x.imageManager.bind(x.context));const xe=P.getCrossfadeParameters();for(const De of ge){const Ve=O?De.posMatrix:x.transform.calculatePosMatrix(De.toUnwrapped()),Je=se?td(Ve,V,x,se,{tileID:De,tileSize:ee},xe):au(Ve,V,z),st=x.style.map.terrain&&x.style.map.terrain.getTerrainData(De);me.draw(F,W.TRIANGLES,he,ce,ne,Tn.disabled,Je,st,P.id,x.tileExtentBuffer,x.quadTriangleIndexBuffer,x.tileExtentSegments)}})(s,0,m,y);break;case"custom":(function(x,M,P){const O=x.context,z=P.implementation;if(x.renderPass==="offscreen"){const V=z.prerender;V&&(x.setCustomLayerDefaults(),O.setColorMode(x.colorModeForRenderPass()),V.call(z,O.gl,x.transform.customLayerMatrix()),O.setDirty(),x.setBaseState())}else if(x.renderPass==="translucent"){x.setCustomLayerDefaults(),O.setColorMode(x.colorModeForRenderPass()),O.setStencilMode(On.disabled);const V=z.renderingMode==="3d"?new Gt(x.context.gl.LEQUAL,Gt.ReadWrite,x.depthRangeFor3D):x.depthModeForSublayer(0,Gt.ReadOnly);O.setDepthMode(V),z.render(O.gl,x.transform.customLayerMatrix(),{farZ:x.transform.farZ,nearZ:x.transform.nearZ,fov:x.transform._fov,modelViewProjectionMatrix:x.transform.modelViewProjectionMatrix,projectionMatrix:x.transform.projectionMatrix}),O.setDirty(),x.setBaseState(),O.bindFramebuffer.set(null)}})(s,0,m)}}translatePosMatrix(s,d,m,y,x){if(!m[0]&&!m[1])return s;const M=x?y==="map"?this.transform.angle:0:y==="viewport"?-this.transform.angle:0;if(M){const z=Math.sin(M),V=Math.cos(M);m=[m[0]*V-m[1]*z,m[0]*z+m[1]*V]}const P=[x?m[0]:Kt(d,m[0],this.transform.zoom),x?m[1]:Kt(d,m[1],this.transform.zoom),0],O=new Float32Array(16);return l.J(O,s,P),O}saveTileTexture(s){const d=this._tileTextures[s.size[0]];d?d.push(s):this._tileTextures[s.size[0]]=[s]}getTileTexture(s){const d=this._tileTextures[s];return d&&d.length>0?d.pop():null}isPatternMissing(s){if(!s)return!1;if(!s.from||!s.to)return!0;const d=this.imageManager.getPattern(s.from.toString()),m=this.imageManager.getPattern(s.to.toString());return!d||!m}useProgram(s,d){this.cache=this.cache||{};const m=s+(d?d.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[m]||(this.cache[m]=new Qh(this.context,uo[s],d,nd[s],this._showOverdrawInspector,this.style.map.terrain)),this.cache[m]}setCustomLayerDefaults(){this.context.unbindVAO(),this.context.cullFace.setDefault(),this.context.activeTexture.setDefault(),this.context.pixelStoreUnpack.setDefault(),this.context.pixelStoreUnpackPremultiplyAlpha.setDefault(),this.context.pixelStoreUnpackFlipY.setDefault()}setBaseState(){const s=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(s.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new tt(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:s,drawingBufferHeight:d}=this.context.gl;return this.width!==s||this.height!==d}}class Va{constructor(s,d){this.points=s,this.planes=d}static fromInvProjectionMatrix(s,d,m){const y=Math.pow(2,m),x=[[-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(P=>{const O=1/(P=l.af([],P,s))[3]/d*y;return l.b1(P,P,[O,O,1/P[3],O])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const O=function(W,J){var ee=J[0],se=J[1],le=J[2],ce=ee*ee+se*se+le*le;return ce>0&&(ce=1/Math.sqrt(ce)),W[0]=J[0]*ce,W[1]=J[1]*ce,W[2]=J[2]*ce,W}([],function(W,J,ee){var se=J[0],le=J[1],ce=J[2],he=ee[0],ne=ee[1],me=ee[2];return W[0]=le*me-ce*ne,W[1]=ce*he-se*me,W[2]=se*ne-le*he,W}([],Ae([],x[P[0]],x[P[1]]),Ae([],x[P[2]],x[P[1]]))),z=-((V=O)[0]*(F=x[P[1]])[0]+V[1]*F[1]+V[2]*F[2]);var V,F;return O.concat(z)});return new Va(x,M)}}class Fa{constructor(s,d){this.min=s,this.max=d,this.center=function(m,y,x){return m[0]=.5*y[0],m[1]=.5*y[1],m[2]=.5*y[2],m}([],function(m,y,x){return m[0]=y[0]+x[0],m[1]=y[1]+x[1],m[2]=y[2]+x[2],m}([],this.min,this.max))}quadrant(s){const d=[s%2==0,s<2],m=Me(this.min),y=Me(this.max);for(let x=0;x<d.length;x++)m[x]=d[x]?this.min[x]:this.center[x],y[x]=d[x]?this.center[x]:this.max[x];return y[2]=this.max[2],new Fa(m,y)}distanceX(s){return Math.max(Math.min(this.max[0],s[0]),this.min[0])-s[0]}distanceY(s){return Math.max(Math.min(this.max[1],s[1]),this.min[1])-s[1]}intersects(s){const d=[[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]];let m=!0;for(let y=0;y<s.planes.length;y++){const x=s.planes[y];let M=0;for(let P=0;P<d.length;P++)l.b2(x,d[P])>=0&&M++;if(M===0)return 0;M!==d.length&&(m=!1)}if(m)return 2;for(let y=0;y<3;y++){let x=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<s.points.length;P++){const O=s.points[P][y]-this.min[y];x=Math.min(x,O),M=Math.max(M,O)}if(M<0||x>this.max[y]-this.min[y])return 0}return 1}}class $a{constructor(s=0,d=0,m=0,y=0){if(isNaN(s)||s<0||isNaN(d)||d<0||isNaN(m)||m<0||isNaN(y)||y<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=s,this.bottom=d,this.left=m,this.right=y}interpolate(s,d,m){return d.top!=null&&s.top!=null&&(this.top=l.y.number(s.top,d.top,m)),d.bottom!=null&&s.bottom!=null&&(this.bottom=l.y.number(s.bottom,d.bottom,m)),d.left!=null&&s.left!=null&&(this.left=l.y.number(s.left,d.left,m)),d.right!=null&&s.right!=null&&(this.right=l.y.number(s.right,d.right,m)),this}getCenter(s,d){const m=l.ac((this.left+s-this.right)/2,0,s),y=l.ac((this.top+d-this.bottom)/2,0,d);return new l.P(m,y)}equals(s){return this.top===s.top&&this.bottom===s.bottom&&this.left===s.left&&this.right===s.right}clone(){return new $a(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const gd=85.051129;class ja{constructor(s,d,m,y,x){this.tileSize=512,this._renderWorldCopies=x===void 0||!!x,this._minZoom=s||0,this._maxZoom=d||22,this._minPitch=m??0,this._maxPitch=y??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new l.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new $a,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const s=new ja(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return s.apply(this),s}apply(s){this.tileSize=s.tileSize,this.latRange=s.latRange,this.lngRange=s.lngRange,this.width=s.width,this.height=s.height,this._center=s._center,this._elevation=s._elevation,this.minElevationForCurrentTile=s.minElevationForCurrentTile,this.zoom=s.zoom,this.angle=s.angle,this._fov=s._fov,this._pitch=s._pitch,this._unmodified=s._unmodified,this._edgeInsets=s._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(s){this._minZoom!==s&&(this._minZoom=s,this.zoom=Math.max(this.zoom,s))}get maxZoom(){return this._maxZoom}set maxZoom(s){this._maxZoom!==s&&(this._maxZoom=s,this.zoom=Math.min(this.zoom,s))}get minPitch(){return this._minPitch}set minPitch(s){this._minPitch!==s&&(this._minPitch=s,this.pitch=Math.max(this.pitch,s))}get maxPitch(){return this._maxPitch}set maxPitch(s){this._maxPitch!==s&&(this._maxPitch=s,this.pitch=Math.min(this.pitch,s))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(s){s===void 0?s=!0:s===null&&(s=!1),this._renderWorldCopies=s}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new l.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(s){const d=-l.b3(s,-180,180)*Math.PI/180;this.angle!==d&&(this._unmodified=!1,this.angle=d,this._calcMatrices(),this.rotationMatrix=function(){var m=new l.A(4);return l.A!=Float32Array&&(m[1]=0,m[2]=0),m[0]=1,m[3]=1,m}(),function(m,y,x){var M=y[0],P=y[1],O=y[2],z=y[3],V=Math.sin(x),F=Math.cos(x);m[0]=M*F+O*V,m[1]=P*F+z*V,m[2]=M*-V+O*F,m[3]=P*-V+z*F}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(s){const d=l.ac(s,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==d&&(this._unmodified=!1,this._pitch=d,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(s){s=Math.max(.01,Math.min(60,s)),this._fov!==s&&(this._unmodified=!1,this._fov=s/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(s){const d=Math.min(Math.max(s,this.minZoom),this.maxZoom);this._zoom!==d&&(this._unmodified=!1,this._zoom=d,this.tileZoom=Math.max(0,Math.floor(d)),this.scale=this.zoomScale(d),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(s){s.lat===this._center.lat&&s.lng===this._center.lng||(this._unmodified=!1,this._center=s,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(s){s!==this._elevation&&(this._elevation=s,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(s){this._edgeInsets.equals(s)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,s,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(s){return this._edgeInsets.equals(s)}interpolatePadding(s,d,m){this._unmodified=!1,this._edgeInsets.interpolate(s,d,m),this._constrain(),this._calcMatrices()}coveringZoomLevel(s){const d=(s.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/s.tileSize));return Math.max(0,d)}getVisibleUnwrappedCoordinates(s){const d=[new l.b4(0,s)];if(this._renderWorldCopies){const m=this.pointCoordinate(new l.P(0,0)),y=this.pointCoordinate(new l.P(this.width,0)),x=this.pointCoordinate(new l.P(this.width,this.height)),M=this.pointCoordinate(new l.P(0,this.height)),P=Math.floor(Math.min(m.x,y.x,x.x,M.x)),O=Math.floor(Math.max(m.x,y.x,x.x,M.x)),z=1;for(let V=P-z;V<=O+z;V++)V!==0&&d.push(new l.b4(V,s))}return d}coveringTiles(s){var d,m;let y=this.coveringZoomLevel(s);const x=y;if(s.minzoom!==void 0&&y<s.minzoom)return[];s.maxzoom!==void 0&&y>s.maxzoom&&(y=s.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=l.Z.fromLngLat(this.center),O=Math.pow(2,y),z=[O*M.x,O*M.y,0],V=[O*P.x,O*P.y,0],F=Va.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,y);let W=s.minzoom||0;!s.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(W=y);const J=s.terrain?2/Math.min(this.tileSize,s.tileSize)*this.tileSize:3,ee=ne=>({aabb:new Fa([ne*O,0,0],[(ne+1)*O,O,0]),zoom:0,x:0,y:0,wrap:ne,fullyVisible:!1}),se=[],le=[],ce=y,he=s.reparseOverscaled?x:y;if(this._renderWorldCopies)for(let ne=1;ne<=3;ne++)se.push(ee(-ne)),se.push(ee(ne));for(se.push(ee(0));se.length>0;){const ne=se.pop(),me=ne.x,ge=ne.y;let xe=ne.fullyVisible;if(!xe){const Ze=ne.aabb.intersects(F);if(Ze===0)continue;xe=Ze===2}const De=s.terrain?z:V,Ve=ne.aabb.distanceX(De),Je=ne.aabb.distanceY(De),st=Math.max(Math.abs(Ve),Math.abs(Je));if(ne.zoom===ce||st>J+(1<<ce-ne.zoom)-2&&ne.zoom>=W){const Ze=ce-ne.zoom,We=z[0]-.5-(me<<Ze),mt=z[1]-.5-(ge<<Ze);le.push({tileID:new l.S(ne.zoom===ce?he:ne.zoom,ne.wrap,ne.zoom,me,ge),distanceSq:Fe([V[0]-.5-me,V[1]-.5-ge]),tileDistanceToCamera:Math.sqrt(We*We+mt*mt)})}else for(let Ze=0;Ze<4;Ze++){const We=(me<<1)+Ze%2,mt=(ge<<1)+(Ze>>1),Ot=ne.zoom+1;let Xe=ne.aabb.quadrant(Ze);if(s.terrain){const nt=new l.S(Ot,ne.wrap,Ot,We,mt),It=s.terrain.getMinMaxElevation(nt),Fn=(d=It.minElevation)!==null&&d!==void 0?d:this.elevation,$t=(m=It.maxElevation)!==null&&m!==void 0?m:this.elevation;Xe=new Fa([Xe.min[0],Xe.min[1],Fn],[Xe.max[0],Xe.max[1],$t])}se.push({aabb:Xe,zoom:Ot,x:We,y:mt,wrap:ne.wrap,fullyVisible:xe})}}return le.sort((ne,me)=>ne.distanceSq-me.distanceSq).map(ne=>ne.tileID)}resize(s,d){this.width=s,this.height=d,this.pixelsToGLUnits=[2/s,-2/d],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(s){return Math.pow(2,s)}scaleZoom(s){return Math.log(s)/Math.LN2}project(s){const d=l.ac(s.lat,-85.051129,gd);return new l.P(l.O(s.lng)*this.worldSize,l.Q(d)*this.worldSize)}unproject(s){return new l.Z(s.x/this.worldSize,s.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(s){const d=this.elevation,m=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,y=this.pointLocation(this.centerPoint,s),x=s.getElevationForLngLatZoom(y,this.tileZoom);if(!(this.elevation-x))return;const M=m+d-x,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/l.b5(1,y.lat),O=this.scaleZoom(P/this.tileSize);this._elevation=x,this._center=y,this.zoom=O}setLocationAtPoint(s,d){const m=this.pointCoordinate(d),y=this.pointCoordinate(this.centerPoint),x=this.locationCoordinate(s),M=new l.Z(x.x-(m.x-y.x),x.y-(m.y-y.y));this.center=this.coordinateLocation(M),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(s,d){return d?this.coordinatePoint(this.locationCoordinate(s),d.getElevationForLngLatZoom(s,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(s))}pointLocation(s,d){return this.coordinateLocation(this.pointCoordinate(s,d))}locationCoordinate(s){return l.Z.fromLngLat(s)}coordinateLocation(s){return s&&s.toLngLat()}pointCoordinate(s,d){if(d){const W=d.pointCoordinate(s);if(W!=null)return W}const m=[s.x,s.y,0,1],y=[s.x,s.y,1,1];l.af(m,m,this.pixelMatrixInverse),l.af(y,y,this.pixelMatrixInverse);const x=m[3],M=y[3],P=m[1]/x,O=y[1]/M,z=m[2]/x,V=y[2]/M,F=z===V?0:(0-z)/(V-z);return new l.Z(l.y.number(m[0]/x,y[0]/M,F)/this.worldSize,l.y.number(P,O,F)/this.worldSize)}coordinatePoint(s,d=0,m=this.pixelMatrix){const y=[s.x*this.worldSize,s.y*this.worldSize,d,1];return l.af(y,y,m),new l.P(y[0]/y[3],y[1]/y[3])}getBounds(){const s=Math.max(0,this.height/2-this.getHorizon());return new ve().extend(this.pointLocation(new l.P(0,s))).extend(this.pointLocation(new l.P(this.width,s))).extend(this.pointLocation(new l.P(this.width,this.height))).extend(this.pointLocation(new l.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(s){s?(this.lngRange=[s.getWest(),s.getEast()],this.latRange=[s.getSouth(),s.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,gd])}calculateTileMatrix(s){const d=s.canonical,m=this.worldSize/this.zoomScale(d.z),y=d.x+Math.pow(2,d.z)*s.wrap,x=l.an(new Float64Array(16));return l.J(x,x,[y*m,d.y*m,0]),l.K(x,x,[m/l.X,m/l.X,1]),x}calculatePosMatrix(s,d=!1){const m=s.key,y=d?this._alignedPosMatrixCache:this._posMatrixCache;if(y[m])return y[m];const x=this.calculateTileMatrix(s);return l.L(x,d?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,x),y[m]=new Float32Array(x),y[m]}calculateFogMatrix(s){const d=s.key,m=this._fogMatrixCache;if(m[d])return m[d];const y=this.calculateTileMatrix(s);return l.L(y,this.fogMatrix,y),m[d]=new Float32Array(y),m[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(s,d){d=l.ac(+d,this.minZoom,this.maxZoom);const m={center:new l.N(s.lng,s.lat),zoom:d};let y=this.lngRange;if(!this._renderWorldCopies&&y===null){const ne=179.9999999999;y=[-ne,ne]}const x=this.tileSize*this.zoomScale(m.zoom);let M=0,P=x,O=0,z=x,V=0,F=0;const{x:W,y:J}=this.size;if(this.latRange){const ne=this.latRange;M=l.Q(ne[1])*x,P=l.Q(ne[0])*x,P-M<J&&(V=J/(P-M))}y&&(O=l.b3(l.O(y[0])*x,0,x),z=l.b3(l.O(y[1])*x,0,x),z<O&&(z+=x),z-O<W&&(F=W/(z-O)));const{x:ee,y:se}=this.project.call({worldSize:x},s);let le,ce;const he=Math.max(F||0,V||0);if(he){const ne=new l.P(F?(z+O)/2:ee,V?(P+M)/2:se);return m.center=this.unproject.call({worldSize:x},ne).wrap(),m.zoom+=this.scaleZoom(he),m}if(this.latRange){const ne=J/2;se-ne<M&&(ce=M+ne),se+ne>P&&(ce=P-ne)}if(y){const ne=(O+z)/2;let me=ee;this._renderWorldCopies&&(me=l.b3(ee,ne-x/2,ne+x/2));const ge=W/2;me-ge<O&&(le=O+ge),me+ge>z&&(le=z-ge)}if(le!==void 0||ce!==void 0){const ne=new l.P(le??ee,ce??se);m.center=this.unproject.call({worldSize:x},ne).wrap()}return m}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const s=this._unmodified,{center:d,zoom:m}=this.getConstrained(this.center,this.zoom);this.center=d,this.zoom=m,this._unmodified=s,this._constraining=!1}_calcMatrices(){if(!this.height)return;const s=this.centerOffset,d=this.point.x,m=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=l.b5(1,this.center.lat)*this.worldSize;let y=l.an(new Float64Array(16));l.K(y,y,[this.width/2,-this.height/2,1]),l.J(y,y,[1,-1,0]),this.labelPlaneMatrix=y,y=l.an(new Float64Array(16)),l.K(y,y,[1,-1,1]),l.J(y,y,[-1,-1,0]),l.K(y,y,[2/this.width,2/this.height,1]),this.glCoordMatrix=y;const x=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=x-M*this._pixelPerMeter/Math.cos(this._pitch),O=M<0?P:x,z=Math.PI/2+this._pitch,V=this._fov*(.5+s.y/this.height),F=Math.sin(V)*O/Math.sin(l.ac(Math.PI-z-V,.01,Math.PI-.01)),W=this.getHorizon(),J=2*Math.atan(W/this.cameraToCenterDistance)*(.5+s.y/(2*W)),ee=Math.sin(J)*O/Math.sin(l.ac(Math.PI-z-J,.01,Math.PI-.01)),se=Math.min(F,ee);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+O),this.nearZ=this.height/50,y=new Float64Array(16),l.b6(y,this._fov,this.width/this.height,this.nearZ,this.farZ),y[8]=2*-s.x/this.width,y[9]=2*s.y/this.height,this.projectionMatrix=l.ae(y),l.K(y,y,[1,-1,1]),l.J(y,y,[0,0,-this.cameraToCenterDistance]),l.b7(y,y,this._pitch),l.ad(y,y,this.angle),l.J(y,y,[-d,-m,0]),this.mercatorMatrix=l.K([],y,[this.worldSize,this.worldSize,this.worldSize]),l.K(y,y,[1,1,this._pixelPerMeter]),this.pixelMatrix=l.L(new Float64Array(16),this.labelPlaneMatrix,y),l.J(y,y,[0,0,-this.elevation]),this.modelViewProjectionMatrix=y,this.invModelViewProjectionMatrix=l.as([],y),this.fogMatrix=new Float64Array(16),l.b6(this.fogMatrix,this._fov,this.width/this.height,x,this.farZ),this.fogMatrix[8]=2*-s.x/this.width,this.fogMatrix[9]=2*s.y/this.height,l.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),l.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),l.b7(this.fogMatrix,this.fogMatrix,this._pitch),l.ad(this.fogMatrix,this.fogMatrix,this.angle),l.J(this.fogMatrix,this.fogMatrix,[-d,-m,0]),l.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),l.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=l.L(new Float64Array(16),this.labelPlaneMatrix,y);const le=this.width%2/2,ce=this.height%2/2,he=Math.cos(this.angle),ne=Math.sin(this.angle),me=d-Math.round(d)+he*le+ne*ce,ge=m-Math.round(m)+he*ce+ne*le,xe=new Float64Array(y);if(l.J(xe,xe,[me>.5?me-1:me,ge>.5?ge-1:ge,0]),this.alignedModelViewProjectionMatrix=xe,y=l.as(new Float64Array(16),this.pixelMatrix),!y)throw new Error("failed to invert matrix");this.pixelMatrixInverse=y,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const s=this.pointCoordinate(new l.P(0,0)),d=[s.x*this.worldSize,s.y*this.worldSize,0,1];return l.af(d,d,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const s=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new l.P(0,s))}getCameraQueryGeometry(s){const d=this.getCameraPoint();if(s.length===1)return[s[0],d];{let m=d.x,y=d.y,x=d.x,M=d.y;for(const P of s)m=Math.min(m,P.x),y=Math.min(y,P.y),x=Math.max(x,P.x),M=Math.max(M,P.y);return[new l.P(m,y),new l.P(x,y),new l.P(x,M),new l.P(m,M),new l.P(m,y)]}}lngLatToCameraDepth(s,d){const m=this.locationCoordinate(s),y=[m.x*this.worldSize,m.y*this.worldSize,d,1];return l.af(y,y,this.modelViewProjectionMatrix),y[2]/y[3]}}function Gl(v,s){let d,m=!1,y=null,x=null;const M=()=>{y=null,m&&(v.apply(x,d),y=setTimeout(M,s),m=!1)};return(...P)=>(m=!0,x=this,d=P,y||M(),y)}class _u{constructor(s){this._getCurrentHash=()=>{const d=window.location.hash.replace("#","");if(this._hashName){let m;return d.split("&").map(y=>y.split("=")).forEach(y=>{y[0]===this._hashName&&(m=y)}),(m&&m[1]||"").split("/")}return d.split("/")},this._onHashChange=()=>{const d=this._getCurrentHash();if(d.length>=3&&!d.some(m=>isNaN(m))){const m=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(d[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+d[2],+d[1]],zoom:+d[0],bearing:m,pitch:+(d[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const d=window.location.href.replace(/(#.*)?$/,this.getHashString());window.history.replaceState(window.history.state,null,d)},this._removeHash=()=>{const d=this._getCurrentHash();if(d.length===0)return;const m=d.join("/");let y=m;y.split("&").length>0&&(y=y.split("&")[0]),this._hashName&&(y=`${this._hashName}=${m}`);let x=window.location.hash.replace(y,"");x.startsWith("#&")?x=x.slice(0,1)+x.slice(2):x==="#"&&(x="");let M=window.location.href.replace(/(#.+)?$/,x);M=M.replace("&&","&"),window.history.replaceState(window.history.state,null,M)},this._updateHash=Gl(this._updateHashUnthrottled,300),this._hashName=s&&encodeURIComponent(s)}addTo(s){return this._map=s,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(s){const d=this._map.getCenter(),m=Math.round(100*this._map.getZoom())/100,y=Math.ceil((m*Math.LN2+Math.log(512/360/.5))/Math.LN10),x=Math.pow(10,y),M=Math.round(d.lng*x)/x,P=Math.round(d.lat*x)/x,O=this._map.getBearing(),z=this._map.getPitch();let V="";if(V+=s?`/${M}/${P}/${m}`:`${m}/${P}/${M}`,(O||z)&&(V+="/"+Math.round(10*O)/10),z&&(V+=`/${Math.round(z)}`),this._hashName){const F=this._hashName;let W=!1;const J=window.location.hash.slice(1).split("&").map(ee=>{const se=ee.split("=")[0];return se===F?(W=!0,`${se}=${V}`):ee}).filter(ee=>ee);return W||J.push(`${F}=${V}`),`#${J.join("&")}`}return`#${V}`}}const bu={linearity:.3,easing:l.b8(0,0,.3,1)},yd=l.e({deceleration:2500,maxSpeed:1400},bu),w_=l.e({deceleration:20,maxSpeed:1400},bu),_m=l.e({deceleration:1e3,maxSpeed:360},bu),xu=l.e({deceleration:1e3,maxSpeed:90},bu);class _d{constructor(s){this._map=s,this.clear()}clear(){this._inertiaBuffer=[]}record(s){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:E.now(),settings:s})}_drainInertiaBuffer(){const s=this._inertiaBuffer,d=E.now();for(;s.length>0&&d-s[0].time>160;)s.shift()}_onMoveEnd(s){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const d={zoom:0,bearing:0,pitch:0,pan:new l.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:x}of this._inertiaBuffer)d.zoom+=x.zoomDelta||0,d.bearing+=x.bearingDelta||0,d.pitch+=x.pitchDelta||0,x.panDelta&&d.pan._add(x.panDelta),x.around&&(d.around=x.around),x.pinchAround&&(d.pinchAround=x.pinchAround);const m=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,y={};if(d.pan.mag()){const x=Yl(d.pan.mag(),m,l.e({},yd,s||{}));y.offset=d.pan.mult(x.amount/d.pan.mag()),y.center=this._map.transform.center,Zl(y,x)}if(d.zoom){const x=Yl(d.zoom,m,w_);y.zoom=this._map.transform.zoom+x.amount,Zl(y,x)}if(d.bearing){const x=Yl(d.bearing,m,_m);y.bearing=this._map.transform.bearing+l.ac(x.amount,-179,179),Zl(y,x)}if(d.pitch){const x=Yl(d.pitch,m,xu);y.pitch=this._map.transform.pitch+x.amount,Zl(y,x)}if(y.zoom||y.bearing){const x=d.pinchAround===void 0?d.around:d.pinchAround;y.around=x?this._map.unproject(x):this._map.getCenter()}return this.clear(),l.e(y,{noMoveStart:!0})}}function Zl(v,s){(!v.duration||v.duration<s.duration)&&(v.duration=s.duration,v.easing=s.easing)}function Yl(v,s,d){const{maxSpeed:m,linearity:y,deceleration:x}=d,M=l.ac(v*y/(s/1e3),-m,m),P=Math.abs(M)/(x*y);return{easing:d.easing,duration:1e3*P,amount:M*(P/2)}}class Oi extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m,y={}){const x=C.mousePos(d.getCanvas(),m),M=d.unproject(x);super(s,l.e({point:x,lngLat:M,originalEvent:m},y)),this._defaultPrevented=!1,this.target=d}}class Zo extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m){const y=s==="touchend"?m.changedTouches:m.touches,x=C.touchPos(d.getCanvasContainer(),y),M=x.map(O=>d.unproject(O)),P=x.reduce((O,z,V,F)=>O.add(z.div(F.length)),new l.P(0,0));super(s,{points:x,point:P,lngLats:M,lngLat:d.unproject(P),originalEvent:m}),this._defaultPrevented=!1}}class bm extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,m){super(s,{originalEvent:m}),this._defaultPrevented=!1}}class xm{constructor(s,d){this._map=s,this._clickTolerance=d.clickTolerance}reset(){delete this._mousedownPos}wheel(s){return this._firePreventable(new bm(s.type,this._map,s))}mousedown(s,d){return this._mousedownPos=d,this._firePreventable(new Oi(s.type,this._map,s))}mouseup(s){this._map.fire(new Oi(s.type,this._map,s))}click(s,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||this._map.fire(new Oi(s.type,this._map,s))}dblclick(s){return this._firePreventable(new Oi(s.type,this._map,s))}mouseover(s){this._map.fire(new Oi(s.type,this._map,s))}mouseout(s){this._map.fire(new Oi(s.type,this._map,s))}touchstart(s){return this._firePreventable(new Zo(s.type,this._map,s))}touchmove(s){this._map.fire(new Zo(s.type,this._map,s))}touchend(s){this._map.fire(new Zo(s.type,this._map,s))}touchcancel(s){this._map.fire(new Zo(s.type,this._map,s))}_firePreventable(s){if(this._map.fire(s),s.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Qn{constructor(s){this._map=s}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(s){this._map.fire(new Oi(s.type,this._map,s))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Oi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(s){this._delayContextMenu?this._contextMenuEvent=s:this._ignoreContextMenu||this._map.fire(new Oi(s.type,this._map,s)),this._map.listens("contextmenu")&&s.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class ts{constructor(s){this._map=s}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(s){return this.transform.pointLocation(l.P.convert(s),this._map.terrain)}}class _r{constructor(s,d){this._map=s,this._tr=new ts(s),this._el=s.getCanvasContainer(),this._container=s.getContainer(),this._clickTolerance=d.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(s,d){this.isEnabled()&&s.shiftKey&&s.button===0&&(C.disableDrag(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(s,d){if(!this._active)return;const m=d;if(this._lastPos.equals(m)||!this._box&&m.dist(this._startPos)<this._clickTolerance)return;const y=this._startPos;this._lastPos=m,this._box||(this._box=C.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",s));const x=Math.min(y.x,m.x),M=Math.max(y.x,m.x),P=Math.min(y.y,m.y),O=Math.max(y.y,m.y);C.setTransform(this._box,`translate(${x}px,${P}px)`),this._box.style.width=M-x+"px",this._box.style.height=O-P+"px"}mouseupWindow(s,d){if(!this._active||s.button!==0)return;const m=this._startPos,y=d;if(this.reset(),C.suppressClick(),m.x!==y.x||m.y!==y.y)return this._map.fire(new l.k("boxzoomend",{originalEvent:s})),{cameraAnimation:x=>x.fitScreenCoordinates(m,y,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",s)}keydown(s){this._active&&s.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",s))}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(s,d){return this._map.fire(new l.k(s,{originalEvent:d}))}}function Xl(v,s){if(v.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${v.length}, points ${s.length}`);const d={};for(let m=0;m<v.length;m++)d[v[m].identifier]=s[m];return d}class bd{constructor(s){this.reset(),this.numTouches=s.numTouches}reset(){delete this.centroid,delete this.startTime,delete this.touches,this.aborted=!1}touchstart(s,d,m){(this.centroid||m.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=s.timeStamp),m.length===this.numTouches&&(this.centroid=function(y){const x=new l.P(0,0);for(const M of y)x._add(M);return x.div(y.length)}(d),this.touches=Xl(m,d)))}touchmove(s,d,m){if(this.aborted||!this.centroid)return;const y=Xl(m,d);for(const x in this.touches){const M=y[x];(!M||M.dist(this.touches[x])>30)&&(this.aborted=!0)}}touchend(s,d,m){if((!this.centroid||s.timeStamp-this.startTime>500)&&(this.aborted=!0),m.length===0){const y=!this.aborted&&this.centroid;if(this.reset(),y)return y}}}class vu{constructor(s){this.singleTap=new bd(s),this.numTaps=s.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(s,d,m){this.singleTap.touchstart(s,d,m)}touchmove(s,d,m){this.singleTap.touchmove(s,d,m)}touchend(s,d,m){const y=this.singleTap.touchend(s,d,m);if(y){const x=s.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(y)<30;if(x&&M||this.reset(),this.count++,this.lastTime=s.timeStamp,this.lastTap=y,this.count===this.numTaps)return this.reset(),y}}}class Ua{constructor(s){this._tr=new ts(s),this._zoomIn=new vu({numTouches:1,numTaps:2}),this._zoomOut=new vu({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(s,d,m){this._zoomIn.touchstart(s,d,m),this._zoomOut.touchstart(s,d,m)}touchmove(s,d,m){this._zoomIn.touchmove(s,d,m),this._zoomOut.touchmove(s,d,m)}touchend(s,d,m){const y=this._zoomIn.touchend(s,d,m),x=this._zoomOut.touchend(s,d,m),M=this._tr;return y?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(y)},{originalEvent:s})}):x?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(x)},{originalEvent:s})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class qs{constructor(s){this._enabled=!!s.enable,this._moveStateManager=s.moveStateManager,this._clickTolerance=s.clickTolerance||1,this._moveFunction=s.move,this._activateOnStart=!!s.activateOnStart,s.assignEvents(this),this.reset()}reset(s){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(s)}_move(...s){const d=this._moveFunction(...s);if(d.bearingDelta||d.pitchDelta||d.around||d.panDelta)return this._active=!0,d}dragStart(s,d){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(s)&&(this._moveStateManager.startMove(s),this._lastPoint=d.length?d[0]:d,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(s,d){if(!this.isEnabled())return;const m=this._lastPoint;if(!m)return;if(s.preventDefault(),!this._moveStateManager.isValidMoveEvent(s))return void this.reset(s);const y=d.length?d[0]:d;return!this._moved&&y.dist(m)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=y,this._move(m,y))}dragEnd(s){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(s)&&(this._moved&&C.suppressClick(),this.reset(s))}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}getClickTolerance(){return this._clickTolerance}}const xd={0:1,2:2};class wu{constructor(s){this._correctEvent=s.checkCorrectEvent}startMove(s){const d=C.mouseButton(s);this._eventButton=d}endMove(s){delete this._eventButton}isValidStartEvent(s){return this._correctEvent(s)}isValidMoveEvent(s){return!function(d,m){const y=xd[m];return d.buttons===void 0||(d.buttons&y)!==y}(s,this._eventButton)}isValidEndEvent(s){return C.mouseButton(s)===this._eventButton}}class vd{constructor(){this._firstTouch=void 0}_isOneFingerTouch(s){return s.targetTouches.length===1}_isSameTouchEvent(s){return s.targetTouches[0].identifier===this._firstTouch}startMove(s){this._firstTouch=s.targetTouches[0].identifier}endMove(s){delete this._firstTouch}isValidStartEvent(s){return this._isOneFingerTouch(s)}isValidMoveEvent(s){return this._isOneFingerTouch(s)&&this._isSameTouchEvent(s)}isValidEndEvent(s){return this._isOneFingerTouch(s)&&this._isSameTouchEvent(s)}}const ku=v=>{v.mousedown=v.dragStart,v.mousemoveWindow=v.dragMove,v.mouseup=v.dragEnd,v.contextmenu=s=>{s.preventDefault()}},wd=({enable:v,clickTolerance:s,bearingDegreesPerPixelMoved:d=.8})=>{const m=new wu({checkCorrectEvent:y=>C.mouseButton(y)===0&&y.ctrlKey||C.mouseButton(y)===2});return new qs({clickTolerance:s,move:(y,x)=>({bearingDelta:(x.x-y.x)*d}),moveStateManager:m,enable:v,assignEvents:ku})},kd=({enable:v,clickTolerance:s,pitchDegreesPerPixelMoved:d=-.5})=>{const m=new wu({checkCorrectEvent:y=>C.mouseButton(y)===0&&y.ctrlKey||C.mouseButton(y)===2});return new qs({clickTolerance:s,move:(y,x)=>({pitchDelta:(x.y-y.y)*d}),moveStateManager:m,enable:v,assignEvents:ku})};class Yo{constructor(s,d){this._clickTolerance=s.clickTolerance||1,this._map=d,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new l.P(0,0)}_shouldBePrevented(s){return s<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(s,d,m){return this._calculateTransform(s,d,m)}touchmove(s,d,m){if(this._active){if(!this._shouldBePrevented(m.length))return s.preventDefault(),this._calculateTransform(s,d,m);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",s)}}touchend(s,d,m){this._calculateTransform(s,d,m),this._active&&this._shouldBePrevented(m.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(s,d,m){m.length>0&&(this._active=!0);const y=Xl(m,d),x=new l.P(0,0),M=new l.P(0,0);let P=0;for(const z in y){const V=y[z],F=this._touches[z];F&&(x._add(V),M._add(V.sub(F)),P++,y[z]=V)}if(this._touches=y,this._shouldBePrevented(P)||!M.mag())return;const O=M.div(P);return this._sum._add(O),this._sum.mag()<this._clickTolerance?void 0:{around:x.div(P),panDelta:O}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Su{constructor(){this.reset()}reset(){this._active=!1,delete this._firstTwoTouches}touchstart(s,d,m){this._firstTwoTouches||m.length<2||(this._firstTwoTouches=[m[0].identifier,m[1].identifier],this._start([d[0],d[1]]))}touchmove(s,d,m){if(!this._firstTwoTouches)return;s.preventDefault();const[y,x]=this._firstTwoTouches,M=Kl(m,d,y),P=Kl(m,d,x);if(!M||!P)return;const O=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],O,s)}touchend(s,d,m){if(!this._firstTwoTouches)return;const[y,x]=this._firstTwoTouches,M=Kl(m,d,y),P=Kl(m,d,x);M&&P||(this._active&&C.suppressClick(),this.reset())}touchcancel(){this.reset()}enable(s){this._enabled=!0,this._aroundCenter=!!s&&s.around==="center"}disable(){this._enabled=!1,this.reset()}isEnabled(){return!!this._enabled}isActive(){return!!this._active}}function Kl(v,s,d){for(let m=0;m<v.length;m++)if(v[m].identifier===d)return s[m]}function Sd(v,s){return Math.log(v/s)/Math.LN2}class Ed extends Su{reset(){super.reset(),delete this._distance,delete this._startDistance}_start(s){this._startDistance=this._distance=s[0].dist(s[1])}_move(s,d){const m=this._distance;if(this._distance=s[0].dist(s[1]),this._active||!(Math.abs(Sd(this._distance,this._startDistance))<.1))return this._active=!0,{zoomDelta:Sd(this._distance,m),pinchAround:d}}}function Cd(v,s){return 180*v.angleWith(s)/Math.PI}class Td extends Su{reset(){super.reset(),delete this._minDiameter,delete this._startVector,delete this._vector}_start(s){this._startVector=this._vector=s[0].sub(s[1]),this._minDiameter=s[0].dist(s[1])}_move(s,d,m){const y=this._vector;if(this._vector=s[0].sub(s[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Cd(this._vector,y),pinchAround:d}}_isBelowThreshold(s){this._minDiameter=Math.min(this._minDiameter,s.mag());const d=25/(Math.PI*this._minDiameter)*360,m=Cd(s,this._startVector);return Math.abs(m)<d}}function Eu(v){return Math.abs(v.y)>Math.abs(v.x)}class Ha extends Su{constructor(s){super(),this._currentTouchCount=0,this._map=s}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(s,d,m){super.touchstart(s,d,m),this._currentTouchCount=m.length}_start(s){this._lastPoints=s,Eu(s[0].sub(s[1]))&&(this._valid=!1)}_move(s,d,m){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const y=s[0].sub(this._lastPoints[0]),x=s[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(y,x,m.timeStamp),this._valid?(this._lastPoints=s,this._active=!0,{pitchDelta:(y.y+x.y)/2*-.5}):void 0}gestureBeginsVertically(s,d,m){if(this._valid!==void 0)return this._valid;const y=s.mag()>=2,x=d.mag()>=2;if(!y&&!x)return;if(!y||!x)return this._firstMove===void 0&&(this._firstMove=m),m-this._firstMove<100&&void 0;const M=s.y>0==d.y>0;return Eu(s)&&Eu(d)&&M}}const vm={panStep:100,bearingStep:15,pitchStep:10};class Lr{constructor(s){this._tr=new ts(s);const d=vm;this._panStep=d.panStep,this._bearingStep=d.bearingStep,this._pitchStep=d.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(s){if(s.altKey||s.ctrlKey||s.metaKey)return;let d=0,m=0,y=0,x=0,M=0;switch(s.keyCode){case 61:case 107:case 171:case 187:d=1;break;case 189:case 109:case 173:d=-1;break;case 37:s.shiftKey?m=-1:(s.preventDefault(),x=-1);break;case 39:s.shiftKey?m=1:(s.preventDefault(),x=1);break;case 38:s.shiftKey?y=1:(s.preventDefault(),M=-1);break;case 40:s.shiftKey?y=-1:(s.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(m=0,y=0),{cameraAnimation:P=>{const O=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:As,zoom:d?Math.round(O.zoom)+d*(s.shiftKey?2:1):O.zoom,bearing:O.bearing+m*this._bearingStep,pitch:O.pitch+y*this._pitchStep,offset:[-x*this._panStep,-M*this._panStep],center:O.center},{originalEvent:s})}}}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 As(v){return v*(2-v)}const Md=4.000244140625;class ns{constructor(s,d){this._onTimeout=m=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(m)},this._map=s,this._tr=new ts(s),this._triggerRenderFrame=d,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(s){this._defaultZoomRate=s}setWheelZoomRate(s){this._wheelZoomRate=s}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(s){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!s&&s.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(s){return!!this._map.cooperativeGestures.isEnabled()&&!(s.ctrlKey||this._map.cooperativeGestures.isBypassed(s))}wheel(s){if(!this.isEnabled())return;if(this._shouldBePrevented(s))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",s);let d=s.deltaMode===WheelEvent.DOM_DELTA_LINE?40*s.deltaY:s.deltaY;const m=E.now(),y=m-(this._lastWheelEventTime||0);this._lastWheelEventTime=m,d!==0&&d%Md==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":y>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,s)):this._type||(this._type=Math.abs(y*d)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,d+=this._lastValue)),s.shiftKey&&d&&(d/=4),this._type&&(this._lastWheelEvent=s,this._delta-=d,this._active||this._start(s)),s.preventDefault()}_start(s){if(!this._delta)return;this._frameId&&(this._frameId=null),this._active=!0,this.isZooming()||(this._zooming=!0),this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout);const d=C.mousePos(this._map.getCanvas(),s),m=this._tr;this._around=d.y>m.transform.height/2-m.transform.getHorizon()?l.N.convert(this._aroundCenter?m.center:m.unproject(d)):l.N.convert(m.center),this._aroundPoint=m.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const s=this._tr.transform;if(this._delta!==0){const O=this._type==="wheel"&&Math.abs(this._delta)>Md?this._wheelZoomRate:this._defaultZoomRate;let z=2/(1+Math.exp(-Math.abs(this._delta*O)));this._delta<0&&z!==0&&(z=1/z);const V=typeof this._targetZoom=="number"?s.zoomScale(this._targetZoom):s.scale;this._targetZoom=Math.min(s.maxZoom,Math.max(s.minZoom,s.scaleZoom(V*z))),this._type==="wheel"&&(this._startZoom=s.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const d=typeof this._targetZoom=="number"?this._targetZoom:s.zoom,m=this._startZoom,y=this._easing;let x,M=!1;const P=E.now()-this._lastWheelEventTime;if(this._type==="wheel"&&m&&y&&P){const O=Math.min(P/200,1),z=y(O);x=l.y.number(m,d,z),O<1?this._frameId||(this._frameId=!0):M=!0}else x=d,M=!0;return this._active=!0,M&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!M,zoomDelta:x-s.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(s){let d=l.b9;if(this._prevEase){const m=this._prevEase,y=(E.now()-m.start)/m.duration,x=m.easing(y+.01)-m.easing(y),M=.27/Math.sqrt(x*x+1e-4)*.01,P=Math.sqrt(.0729-M*M);d=l.b8(M,P,.25,1)}return this._prevEase={start:E.now(),duration:s,easing:d},d}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class Xo{constructor(s,d){this._clickZoom=s,this._tapZoom=d}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 k_{constructor(s){this._tr=new ts(s),this.reset()}reset(){this._active=!1}dblclick(s,d){return s.preventDefault(),{cameraAnimation:m=>{m.easeTo({duration:300,zoom:this._tr.zoom+(s.shiftKey?-1:1),around:this._tr.unproject(d)},{originalEvent:s})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class S_{constructor(){this._tap=new vu({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(s,d,m){if(!this._swipePoint)if(this._tapTime){const y=d[0],x=s.timeStamp-this._tapTime<500,M=this._tapPoint.dist(y)<30;x&&M?m.length>0&&(this._swipePoint=y,this._swipeTouch=m[0].identifier):this.reset()}else this._tap.touchstart(s,d,m)}touchmove(s,d,m){if(this._tapTime){if(this._swipePoint){if(m[0].identifier!==this._swipeTouch)return;const y=d[0],x=y.y-this._swipePoint.y;return this._swipePoint=y,s.preventDefault(),this._active=!0,{zoomDelta:x/128}}}else this._tap.touchmove(s,d,m)}touchend(s,d,m){if(this._tapTime)this._swipePoint&&m.length===0&&this.reset();else{const y=this._tap.touchend(s,d,m);y&&(this._tapTime=s.timeStamp,this._tapPoint=y)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class wm{constructor(s,d,m){this._el=s,this._mousePan=d,this._touchPan=m}enable(s){this._inertiaOptions=s||{},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 km{constructor(s,d,m){this._pitchWithRotate=s.pitchWithRotate,this._mouseRotate=d,this._mousePitch=m}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 Ad{constructor(s,d,m,y){this._el=s,this._touchZoom=d,this._touchRotate=m,this._tapDragZoom=y,this._rotationDisabled=!1,this._enabled=!0}enable(s){this._touchZoom.enable(s),this._rotationDisabled||this._touchRotate.enable(s),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 qa{constructor(s,d){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=s,this._options=d,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const s=this._map.getCanvasContainer();s.classList.add("maplibregl-cooperative-gestures"),this._container=C.create("div","maplibregl-cooperative-gesture-screen",s);let d=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(d=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const m=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),y=document.createElement("div");y.className="maplibregl-desktop-message",y.textContent=d,this._container.appendChild(y);const x=document.createElement("div");x.className="maplibregl-mobile-message",x.textContent=m,this._container.appendChild(x),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(s){return s[this._bypassKey]}notifyGestureBlocked(s,d){this._enabled&&(this._map.fire(new l.k("cooperativegestureprevented",{gestureType:s,originalEvent:d})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Vr=v=>v.zoom||v.drag||v.pitch||v.rotate;class lt extends l.k{}function Cu(v){return v.panDelta&&v.panDelta.mag()||v.zoomDelta||v.bearingDelta||v.pitchDelta}class Pd{constructor(s,d){this.handleWindowEvent=y=>{this.handleEvent(y,`${y.type}Window`)},this.handleEvent=(y,x)=>{if(y.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=y.type==="renderFrame"?void 0:y,P={needsRenderFrame:!1},O={},z={},V=y.touches,F=V?this._getMapTouches(V):void 0,W=F?C.touchPos(this._map.getCanvas(),F):C.mousePos(this._map.getCanvas(),y);for(const{handlerName:se,handler:le,allowed:ce}of this._handlers){if(!le.isEnabled())continue;let he;this._blockedByActive(z,ce,se)?le.reset():le[x||y.type]&&(he=le[x||y.type](y,W,F),this.mergeHandlerResult(P,O,he,se,M),he&&he.needsRenderFrame&&this._triggerRenderFrame()),(he||le.isActive())&&(z[se]=le)}const J={};for(const se in this._previousActiveHandlers)z[se]||(J[se]=M);this._previousActiveHandlers=z,(Object.keys(J).length||Cu(P))&&(this._changes.push([P,O,J]),this._triggerRenderFrame()),(Object.keys(z).length||Cu(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:ee}=P;ee&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],ee(this._map))},this._map=s,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new _d(s),this._bearingSnap=d.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(d);const m=this._el;this._listeners=[[m,"touchstart",{passive:!0}],[m,"touchmove",{passive:!1}],[m,"touchend",void 0],[m,"touchcancel",void 0],[m,"mousedown",void 0],[m,"mousemove",void 0],[m,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[m,"mouseover",void 0],[m,"mouseout",void 0],[m,"dblclick",void 0],[m,"click",void 0],[m,"keydown",{capture:!1}],[m,"keyup",void 0],[m,"wheel",{passive:!1}],[m,"contextmenu",void 0],[window,"blur",void 0]];for(const[y,x,M]of this._listeners)C.addEventListener(y,x,y===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[s,d,m]of this._listeners)C.removeEventListener(s,d,s===document?this.handleWindowEvent:this.handleEvent,m)}_addDefaultHandlers(s){const d=this._map,m=d.getCanvasContainer();this._add("mapEvent",new xm(d,s));const y=d.boxZoom=new _r(d,s);this._add("boxZoom",y),s.interactive&&s.boxZoom&&y.enable();const x=d.cooperativeGestures=new qa(d,s.cooperativeGestures);this._add("cooperativeGestures",x),s.cooperativeGestures&&x.enable();const M=new Ua(d),P=new k_(d);d.doubleClickZoom=new Xo(P,M),this._add("tapZoom",M),this._add("clickZoom",P),s.interactive&&s.doubleClickZoom&&d.doubleClickZoom.enable();const O=new S_;this._add("tapDragZoom",O);const z=d.touchPitch=new Ha(d);this._add("touchPitch",z),s.interactive&&s.touchPitch&&d.touchPitch.enable(s.touchPitch);const V=wd(s),F=kd(s);d.dragRotate=new km(s,V,F),this._add("mouseRotate",V,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),s.interactive&&s.dragRotate&&d.dragRotate.enable();const W=(({enable:he,clickTolerance:ne})=>{const me=new wu({checkCorrectEvent:ge=>C.mouseButton(ge)===0&&!ge.ctrlKey});return new qs({clickTolerance:ne,move:(ge,xe)=>({around:xe,panDelta:xe.sub(ge)}),activateOnStart:!0,moveStateManager:me,enable:he,assignEvents:ku})})(s),J=new Yo(s,d);d.dragPan=new wm(m,W,J),this._add("mousePan",W),this._add("touchPan",J,["touchZoom","touchRotate"]),s.interactive&&s.dragPan&&d.dragPan.enable(s.dragPan);const ee=new Td,se=new Ed;d.touchZoomRotate=new Ad(m,se,ee,O),this._add("touchRotate",ee,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),s.interactive&&s.touchZoomRotate&&d.touchZoomRotate.enable(s.touchZoomRotate);const le=d.scrollZoom=new ns(d,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),s.interactive&&s.scrollZoom&&d.scrollZoom.enable(s.scrollZoom);const ce=d.keyboard=new Lr(d);this._add("keyboard",ce),s.interactive&&s.keyboard&&d.keyboard.enable(),this._add("blockableMapEvent",new Qn(d))}_add(s,d,m){this._handlers.push({handlerName:s,handler:d,allowed:m}),this._handlersById[s]=d}stop(s){if(!this._updatingCamera){for(const{handler:d}of this._handlers)d.reset();this._inertia.clear(),this._fireEvents({},{},s),this._changes=[]}}isActive(){for(const{handler:s}of this._handlers)if(s.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Vr(this._eventsInProgress)||this.isZooming()}_blockedByActive(s,d,m){for(const y in s)if(y!==m&&(!d||d.indexOf(y)<0))return!0;return!1}_getMapTouches(s){const d=[];for(const m of s)this._el.contains(m.target)&&d.push(m);return d}mergeHandlerResult(s,d,m,y,x){if(!m)return;l.e(s,m);const M={handlerName:y,originalEvent:m.originalEvent||x};m.zoomDelta!==void 0&&(d.zoom=M),m.panDelta!==void 0&&(d.drag=M),m.pitchDelta!==void 0&&(d.pitch=M),m.bearingDelta!==void 0&&(d.rotate=M)}_applyChanges(){const s={},d={},m={};for(const[y,x,M]of this._changes)y.panDelta&&(s.panDelta=(s.panDelta||new l.P(0,0))._add(y.panDelta)),y.zoomDelta&&(s.zoomDelta=(s.zoomDelta||0)+y.zoomDelta),y.bearingDelta&&(s.bearingDelta=(s.bearingDelta||0)+y.bearingDelta),y.pitchDelta&&(s.pitchDelta=(s.pitchDelta||0)+y.pitchDelta),y.around!==void 0&&(s.around=y.around),y.pinchAround!==void 0&&(s.pinchAround=y.pinchAround),y.noInertia&&(s.noInertia=y.noInertia),l.e(d,x),l.e(m,M);this._updateMapTransform(s,d,m),this._changes=[]}_updateMapTransform(s,d,m){const y=this._map,x=y._getTransformForUpdate(),M=y.terrain;if(!(Cu(s)||M&&this._terrainMovement))return this._fireEvents(d,m,!0);let{panDelta:P,zoomDelta:O,bearingDelta:z,pitchDelta:V,around:F,pinchAround:W}=s;W!==void 0&&(F=W),y._stop(!0),F=F||y.transform.centerPoint;const J=x.pointLocation(P?F.sub(P):F);z&&(x.bearing+=z),V&&(x.pitch+=V),O&&(x.zoom+=O),M?this._terrainMovement||!d.drag&&!d.zoom?d.drag&&this._terrainMovement?x.center=x.pointLocation(x.centerPoint.sub(P)):x.setLocationAtPoint(J,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,x.setLocationAtPoint(J,F)):x.setLocationAtPoint(J,F),y._applyUpdatedTransform(x),this._map._update(),s.noInertia||this._inertia.record(s),this._fireEvents(d,m,!0)}_fireEvents(s,d,m){const y=Vr(this._eventsInProgress),x=Vr(s),M={};for(const F in s){const{originalEvent:W}=s[F];this._eventsInProgress[F]||(M[`${F}start`]=W),this._eventsInProgress[F]=s[F]}!y&&x&&this._fireEvent("movestart",x.originalEvent);for(const F in M)this._fireEvent(F,M[F]);x&&this._fireEvent("move",x.originalEvent);for(const F in s){const{originalEvent:W}=s[F];this._fireEvent(F,W)}const P={};let O;for(const F in this._eventsInProgress){const{handlerName:W,originalEvent:J}=this._eventsInProgress[F];this._handlersById[W].isActive()||(delete this._eventsInProgress[F],O=d[W]||J,P[`${F}end`]=O)}for(const F in P)this._fireEvent(F,P[F]);const z=Vr(this._eventsInProgress),V=(y||x)&&!z;if(V&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(m&&V){this._updatingCamera=!0;const F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),W=J=>J!==0&&-this._bearingSnap<J&&J<this._bearingSnap;!F||!F.essential&&E.prefersReducedMotion?(this._map.fire(new l.k("moveend",{originalEvent:O})),W(this._map.getBearing())&&this._map.resetNorth()):(W(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:O})),this._updatingCamera=!1}}_fireEvent(s,d){this._map.fire(new l.k(s,d?{originalEvent:d}:{}))}_requestFrame(){return this._map.triggerRepaint(),this._map._renderTaskQueue.add(s=>{delete this._frameId,this.handleEvent(new lt("renderFrame",{timeStamp:s})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class Sm extends l.E{constructor(s,d){super(),this._renderFrameCallback=()=>{const m=Math.min((E.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(m)),m<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=s,this._bearingSnap=d.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new l.N(this.transform.center.lng,this.transform.center.lat)}setCenter(s,d){return this.jumpTo({center:s},d)}panBy(s,d,m){return s=l.P.convert(s).mult(-1),this.panTo(this.transform.center,l.e({offset:s},d),m)}panTo(s,d,m){return this.easeTo(l.e({center:s},d),m)}getZoom(){return this.transform.zoom}setZoom(s,d){return this.jumpTo({zoom:s},d),this}zoomTo(s,d,m){return this.easeTo(l.e({zoom:s},d),m)}zoomIn(s,d){return this.zoomTo(this.getZoom()+1,s,d),this}zoomOut(s,d){return this.zoomTo(this.getZoom()-1,s,d),this}getBearing(){return this.transform.bearing}setBearing(s,d){return this.jumpTo({bearing:s},d),this}getPadding(){return this.transform.padding}setPadding(s,d){return this.jumpTo({padding:s},d),this}rotateTo(s,d,m){return this.easeTo(l.e({bearing:s},d),m)}resetNorth(s,d){return this.rotateTo(0,l.e({duration:1e3},s),d),this}resetNorthPitch(s,d){return this.easeTo(l.e({bearing:0,pitch:0,duration:1e3},s),d),this}snapToNorth(s,d){return Math.abs(this.getBearing())<this._bearingSnap?this.resetNorth(s,d):this}getPitch(){return this.transform.pitch}setPitch(s,d){return this.jumpTo({pitch:s},d),this}cameraForBounds(s,d){s=ve.convert(s).adjustAntiMeridian();const m=d&&d.bearing||0;return this._cameraForBoxAndBearing(s.getNorthWest(),s.getSouthEast(),m,d)}_cameraForBoxAndBearing(s,d,m,y){const x={top:0,bottom:0,right:0,left:0};if(typeof(y=l.e({padding:x,offset:[0,0],maxZoom:this.transform.maxZoom},y)).padding=="number"){const Ze=y.padding;y.padding={top:Ze,bottom:Ze,right:Ze,left:Ze}}y.padding=l.e(x,y.padding);const M=this.transform,P=M.padding,O=new ve(s,d),z=M.project(O.getNorthWest()),V=M.project(O.getNorthEast()),F=M.project(O.getSouthEast()),W=M.project(O.getSouthWest()),J=l.ba(-m),ee=z.rotate(J),se=V.rotate(J),le=F.rotate(J),ce=W.rotate(J),he=new l.P(Math.max(ee.x,se.x,ce.x,le.x),Math.max(ee.y,se.y,ce.y,le.y)),ne=new l.P(Math.min(ee.x,se.x,ce.x,le.x),Math.min(ee.y,se.y,ce.y,le.y)),me=he.sub(ne),ge=(M.width-(P.left+P.right+y.padding.left+y.padding.right))/me.x,xe=(M.height-(P.top+P.bottom+y.padding.top+y.padding.bottom))/me.y;if(xe<0||ge<0)return void l.w("Map cannot fit within canvas with the given bounds, padding, and/or offset.");const De=Math.min(M.scaleZoom(M.scale*Math.min(ge,xe)),y.maxZoom),Ve=l.P.convert(y.offset),Je=new l.P((y.padding.left-y.padding.right)/2,(y.padding.top-y.padding.bottom)/2).rotate(l.ba(m)),st=Ve.add(Je).mult(M.scale/M.zoomScale(De));return{center:M.unproject(z.add(F).div(2).sub(st)),zoom:De,bearing:m}}fitBounds(s,d,m){return this._fitInternal(this.cameraForBounds(s,d),d,m)}fitScreenCoordinates(s,d,m,y,x){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(l.P.convert(s)),this.transform.pointLocation(l.P.convert(d)),m,y),y,x)}_fitInternal(s,d,m){return s?(delete(d=l.e(s,d)).padding,d.linear?this.easeTo(d,m):this.flyTo(d,m)):this}jumpTo(s,d){this.stop();const m=this._getTransformForUpdate();let y=!1,x=!1,M=!1;return"zoom"in s&&m.zoom!==+s.zoom&&(y=!0,m.zoom=+s.zoom),s.center!==void 0&&(m.center=l.N.convert(s.center)),"bearing"in s&&m.bearing!==+s.bearing&&(x=!0,m.bearing=+s.bearing),"pitch"in s&&m.pitch!==+s.pitch&&(M=!0,m.pitch=+s.pitch),s.padding==null||m.isPaddingEqual(s.padding)||(m.padding=s.padding),this._applyUpdatedTransform(m),this.fire(new l.k("movestart",d)).fire(new l.k("move",d)),y&&this.fire(new l.k("zoomstart",d)).fire(new l.k("zoom",d)).fire(new l.k("zoomend",d)),x&&this.fire(new l.k("rotatestart",d)).fire(new l.k("rotate",d)).fire(new l.k("rotateend",d)),M&&this.fire(new l.k("pitchstart",d)).fire(new l.k("pitch",d)).fire(new l.k("pitchend",d)),this.fire(new l.k("moveend",d))}calculateCameraOptionsFromTo(s,d,m,y=0){const x=l.Z.fromLngLat(s,d),M=l.Z.fromLngLat(m,y),P=M.x-x.x,O=M.y-x.y,z=M.z-x.z,V=Math.hypot(P,O,z);if(V===0)throw new Error("Can't calculate camera options with same From and To");const F=Math.hypot(P,O),W=this.transform.scaleZoom(this.transform.cameraToCenterDistance/V/this.transform.tileSize),J=180*Math.atan2(P,-O)/Math.PI;let ee=180*Math.acos(F/V)/Math.PI;return ee=z<0?90-ee:90+ee,{center:M.toLngLat(),zoom:W,pitch:ee,bearing:J}}easeTo(s,d){var m;this._stop(!1,s.easeId),((s=l.e({offset:[0,0],duration:500,easing:l.b9},s)).animate===!1||!s.essential&&E.prefersReducedMotion)&&(s.duration=0);const y=this._getTransformForUpdate(),x=y.zoom,M=y.bearing,P=y.pitch,O=y.padding,z="bearing"in s?this._normalizeBearing(s.bearing,M):M,V="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:y.padding,W=l.P.convert(s.offset);let J=y.centerPoint.add(W);const ee=y.pointLocation(J),{center:se,zoom:le}=y.getConstrained(l.N.convert(s.center||ee),(m=s.zoom)!==null&&m!==void 0?m:x);this._normalizeCenter(se,y);const ce=y.project(ee),he=y.project(se).sub(ce),ne=y.zoomScale(le-x);let me,ge;s.around&&(me=l.N.convert(s.around),ge=y.locationPoint(me));const xe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==x,this._rotating=this._rotating||M!==z,this._pitching=this._pitching||V!==P,this._padding=!y.isPaddingEqual(F),this._easeId=s.easeId,this._prepareEase(d,s.noMoveStart,xe),this.terrain&&this._prepareElevation(se),this._ease(De=>{if(this._zooming&&(y.zoom=l.y.number(x,le,De)),this._rotating&&(y.bearing=l.y.number(M,z,De)),this._pitching&&(y.pitch=l.y.number(P,V,De)),this._padding&&(y.interpolatePadding(O,F,De),J=y.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(De),me)y.setLocationAtPoint(me,ge);else{const Ve=y.zoomScale(y.zoom-x),Je=le>x?Math.min(2,ne):Math.max(.5,ne),st=Math.pow(Je,1-De),Ze=y.unproject(ce.add(he.mult(De*st)).mult(Ve));y.setLocationAtPoint(y.renderWorldCopies?Ze.wrap():Ze,J)}this._applyUpdatedTransform(y),this._fireMoveEvents(d)},De=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d,De)},s),this}_prepareEase(s,d,m={}){this._moving=!0,d||m.moving||this.fire(new l.k("movestart",s)),this._zooming&&!m.zooming&&this.fire(new l.k("zoomstart",s)),this._rotating&&!m.rotating&&this.fire(new l.k("rotatestart",s)),this._pitching&&!m.pitching&&this.fire(new l.k("pitchstart",s))}_prepareElevation(s){this._elevationCenter=s,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(s,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(s){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const d=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(s<1&&d!==this._elevationTarget){const m=this._elevationTarget-this._elevationStart;this._elevationStart+=s*(m-(d-(m*s+this._elevationStart))/(1-s)),this._elevationTarget=d}this.transform.elevation=l.y.number(this._elevationStart,this._elevationTarget,s)}_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(s){const d=s.getCameraPosition(),m=this.terrain.getElevationForLngLatZoom(d.lngLat,s.zoom);if(d.altitude<m){const y=this.calculateCameraOptionsFromTo(d.lngLat,m,s.center,s.elevation);return{pitch:y.pitch,zoom:y.zoom}}return{}}_applyUpdatedTransform(s){const d=[];if(this.terrain&&d.push(y=>this._elevateCameraIfInsideTerrain(y)),this.transformCameraUpdate&&d.push(y=>this.transformCameraUpdate(y)),!d.length)return;const m=s.clone();for(const y of d){const x=m.clone(),{center:M,zoom:P,pitch:O,bearing:z,elevation:V}=y(x);M&&(x.center=M),P!==void 0&&(x.zoom=P),O!==void 0&&(x.pitch=O),z!==void 0&&(x.bearing=z),V!==void 0&&(x.elevation=V),m.apply(x)}this.transform.apply(m)}_fireMoveEvents(s){this.fire(new l.k("move",s)),this._zooming&&this.fire(new l.k("zoom",s)),this._rotating&&this.fire(new l.k("rotate",s)),this._pitching&&this.fire(new l.k("pitch",s))}_afterEase(s,d){if(this._easeId&&d&&this._easeId===d)return;delete this._easeId;const m=this._zooming,y=this._rotating,x=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,m&&this.fire(new l.k("zoomend",s)),y&&this.fire(new l.k("rotateend",s)),x&&this.fire(new l.k("pitchend",s)),this.fire(new l.k("moveend",s))}flyTo(s,d){var m;if(!s.essential&&E.prefersReducedMotion){const nt=l.M(s,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,d)}this.stop(),s=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.b9},s);const y=this._getTransformForUpdate(),x=y.zoom,M=y.bearing,P=y.pitch,O=y.padding,z="bearing"in s?this._normalizeBearing(s.bearing,M):M,V="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:y.padding,W=l.P.convert(s.offset);let J=y.centerPoint.add(W);const ee=y.pointLocation(J),{center:se,zoom:le}=y.getConstrained(l.N.convert(s.center||ee),(m=s.zoom)!==null&&m!==void 0?m:x);this._normalizeCenter(se,y);const ce=y.zoomScale(le-x),he=y.project(ee),ne=y.project(se).sub(he);let me=s.curve;const ge=Math.max(y.width,y.height),xe=ge/ce,De=ne.mag();if("minZoom"in s){const nt=l.ac(Math.min(s.minZoom,x,le),y.minZoom,y.maxZoom),It=ge/y.zoomScale(nt-x);me=Math.sqrt(It/De*2)}const Ve=me*me;function Je(nt){const It=(xe*xe-ge*ge+(nt?-1:1)*Ve*Ve*De*De)/(2*(nt?xe:ge)*Ve*De);return Math.log(Math.sqrt(It*It+1)-It)}function st(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Ze(nt){return(Math.exp(nt)+Math.exp(-nt))/2}const We=Je(!1);let mt=function(nt){return Ze(We)/Ze(We+me*nt)},Ot=function(nt){return ge*((Ze(We)*(st(It=We+me*nt)/Ze(It))-st(We))/Ve)/De;var It},Xe=(Je(!0)-We)/me;if(Math.abs(De)<1e-6||!isFinite(Xe)){if(Math.abs(ge-xe)<1e-6)return this.easeTo(s,d);const nt=xe<ge?-1:1;Xe=Math.abs(Math.log(xe/ge))/me,Ot=()=>0,mt=It=>Math.exp(nt*me*It)}return s.duration="duration"in s?+s.duration:1e3*Xe/("screenSpeed"in s?+s.screenSpeed/me:+s.speed),s.maxDuration&&s.duration>s.maxDuration&&(s.duration=0),this._zooming=!0,this._rotating=M!==z,this._pitching=V!==P,this._padding=!y.isPaddingEqual(F),this._prepareEase(d,!1),this.terrain&&this._prepareElevation(se),this._ease(nt=>{const It=nt*Xe,Fn=1/mt(It);y.zoom=nt===1?le:x+y.scaleZoom(Fn),this._rotating&&(y.bearing=l.y.number(M,z,nt)),this._pitching&&(y.pitch=l.y.number(P,V,nt)),this._padding&&(y.interpolatePadding(O,F,nt),J=y.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(nt);const $t=nt===1?se:y.unproject(he.add(ne.mult(Ot(It))).mult(Fn));y.setLocationAtPoint(y.renderWorldCopies?$t.wrap():$t,J),this._applyUpdatedTransform(y),this._fireMoveEvents(d)},()=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d)},s),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(s,d){var m;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const y=this._onEaseEnd;delete this._onEaseEnd,y.call(this,d)}return s||(m=this.handlers)===null||m===void 0||m.stop(!1),this}_ease(s,d,m){m.animate===!1||m.duration===0?(s(1),d()):(this._easeStart=E.now(),this._easeOptions=m,this._onEaseFrame=s,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(s,d){s=l.b3(s,-180,180);const m=Math.abs(s-d);return Math.abs(s-360-d)<m&&(s-=360),Math.abs(s+360-d)<m&&(s+=360),s}_normalizeCenter(s,d){if(!d.renderWorldCopies||d.lngRange)return;const m=s.lng-d.center.lng;s.lng+=m>180?-360:m<-180?360:0}queryTerrainElevation(s){return this.terrain?this.terrain.getElevationForLngLatZoom(l.N.convert(s),this.transform.tileZoom)-this.transform.elevation:null}}const Wa={compact:!0,customAttribution:'<a href="https://maplibre.org/" target="_blank">MapLibre</a>'};class Ga{constructor(s=Wa){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=d=>{!d||d.sourceDataType!=="metadata"&&d.sourceDataType!=="visibility"&&d.dataType!=="style"&&d.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=s}getDefaultPosition(){return"bottom-right"}onAdd(s){return this._map=s,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(s,d){const m=this._map._getUIString(`AttributionControl.${d}`);s.title=m,s.setAttribute("aria-label",m)}_updateAttributions(){if(!this._map.style)return;let s=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?s=s.concat(this.options.customAttribution.map(y=>typeof y!="string"?"":y)):typeof this.options.customAttribution=="string"&&s.push(this.options.customAttribution)),this._map.style.stylesheet){const y=this._map.style.stylesheet;this.styleOwner=y.owner,this.styleId=y.id}const d=this._map.style.sourceCaches;for(const y in d){const x=d[y];if(x.used||x.usedForTerrain){const M=x.getSource();M.attribution&&s.indexOf(M.attribution)<0&&s.push(M.attribution)}}s=s.filter(y=>String(y).trim()),s.sort((y,x)=>y.length-x.length),s=s.filter((y,x)=>{for(let M=x+1;M<s.length;M++)if(s[M].indexOf(y)>=0)return!1;return!0});const m=s.join(" | ");m!==this._attribHTML&&(this._attribHTML=m,s.length?(this._innerContainer.innerHTML=m,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Id{constructor(s={}){this._updateCompact=()=>{const d=this._container.children;if(d.length){const m=d[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&m.classList.add("maplibregl-compact"):m.classList.remove("maplibregl-compact")}},this.options=s}getDefaultPosition(){return"bottom-left"}onAdd(s){this._map=s,this._compact=this.options&&this.options.compact,this._container=C.create("div","maplibregl-ctrl");const d=C.create("a","maplibregl-ctrl-logo");return d.target="_blank",d.rel="noopener nofollow",d.href="https://maplibre.org/",d.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),d.setAttribute("rel","noopener nofollow"),this._container.appendChild(d),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 en{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(s){const d=++this._id;return this._queue.push({callback:s,id:d,cancelled:!1}),d}remove(s){const d=this._currentlyRunning,m=d?this._queue.concat(d):this._queue;for(const y of m)if(y.id===s)return void(y.cancelled=!0)}run(s=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const d=this._currentlyRunning=this._queue;this._queue=[];for(const m of d)if(!m.cancelled&&(m.callback(s),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Dd=l.Y([{name:"a_pos3d",type:"Int16",components:3}]);class E_ extends l.E{constructor(s){super(),this.sourceCache=s,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,s.usedForTerrain=!0,s.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(s,d){this.sourceCache.update(s,d),this._renderableTilesKeys=[];const m={};for(const y of s.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:d}))m[y.key]=!0,this._renderableTilesKeys.push(y.key),this._tiles[y.key]||(y.posMatrix=new Float64Array(16),l.aP(y.posMatrix,0,l.X,0,l.X,0,1),this._tiles[y.key]=new Ts(y,this.tileSize));for(const y in this._tiles)m[y]||delete this._tiles[y]}freeRtt(s){for(const d in this._tiles){const m=this._tiles[d];(!s||m.tileID.equals(s)||m.tileID.isChildOf(s)||s.isChildOf(m.tileID))&&(m.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(s=>this.getTileByID(s))}getTileByID(s){return this._tiles[s]}getTerrainCoords(s){const d={};for(const m of this._renderableTilesKeys){const y=this._tiles[m].tileID;if(y.canonical.equals(s.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16),l.aP(x.posMatrix,0,l.X,0,l.X,0,1),d[m]=x}else if(y.canonical.isChildOf(s.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16);const M=y.canonical.z-s.canonical.z,P=y.canonical.x-(y.canonical.x>>M<<M),O=y.canonical.y-(y.canonical.y>>M<<M),z=l.X>>M;l.aP(x.posMatrix,0,z,0,z,0,1),l.J(x.posMatrix,x.posMatrix,[-P*z,-O*z,0]),d[m]=x}else if(s.canonical.isChildOf(y.canonical)){const x=s.clone();x.posMatrix=new Float64Array(16);const M=s.canonical.z-y.canonical.z,P=s.canonical.x-(s.canonical.x>>M<<M),O=s.canonical.y-(s.canonical.y>>M<<M),z=l.X>>M;l.aP(x.posMatrix,0,l.X,0,l.X,0,1),l.J(x.posMatrix,x.posMatrix,[P*z,O*z,0]),l.K(x.posMatrix,x.posMatrix,[1/2**M,1/2**M,0]),d[m]=x}}return d}getSourceTile(s,d){const m=this.sourceCache._source;let y=s.overscaledZ-this.deltaZoom;if(y>m.maxzoom&&(y=m.maxzoom),y<m.minzoom)return null;this._sourceTileCache[s.key]||(this._sourceTileCache[s.key]=s.scaledTo(y).key);let x=this.sourceCache.getTileByID(this._sourceTileCache[s.key]);if((!x||!x.dem)&&d)for(;y>=m.minzoom&&(!x||!x.dem);)x=this.sourceCache.getTileByID(s.scaledTo(y--).key);return x}tilesAfterTime(s=Date.now()){return Object.values(this._tiles).filter(d=>d.timeAdded>=s)}}class Od{constructor(s,d,m){this.painter=s,this.sourceCache=new E_(d),this.options=m,this.exaggeration=typeof m.exaggeration=="number"?m.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(s,d,m,y=l.X){var x;if(!(d>=0&&d<y&&m>=0&&m<y))return 0;const M=this.getTerrainData(s),P=(x=M.tile)===null||x===void 0?void 0:x.dem;if(!P)return 0;const O=function(ee,se,le){var ce=se[0],he=se[1];return ee[0]=le[0]*ce+le[4]*he+le[12],ee[1]=le[1]*ce+le[5]*he+le[13],ee}([],[d/y*l.X,m/y*l.X],M.u_terrain_matrix),z=[O[0]*P.dim,O[1]*P.dim],V=Math.floor(z[0]),F=Math.floor(z[1]),W=z[0]-V,J=z[1]-F;return P.get(V,F)*(1-W)*(1-J)+P.get(V+1,F)*W*(1-J)+P.get(V,F+1)*(1-W)*J+P.get(V+1,F+1)*W*J}getElevationForLngLatZoom(s,d){if(!l.bb(d,s.wrap()))return 0;const{tileID:m,mercatorX:y,mercatorY:x}=this._getOverscaledTileIDFromLngLatZoom(s,d);return this.getElevation(m,y%l.X,x%l.X,l.X)}getElevation(s,d,m,y=l.X){return this.getDEMElevation(s,d,m,y)*this.exaggeration}getTerrainData(s){if(!this._emptyDemTexture){const y=this.painter.context,x=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new tt(y,x,y.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new tt(y,new l.R({width:1,height:1}),y.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(y.gl.NEAREST,y.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.an([])}const d=this.sourceCache.getSourceTile(s,!0);if(d&&d.dem&&(!d.demTexture||d.needsTerrainPrepare)){const y=this.painter.context;d.demTexture=this.painter.getTileTexture(d.dem.stride),d.demTexture?d.demTexture.update(d.dem.getPixels(),{premultiply:!1}):d.demTexture=new tt(y,d.dem.getPixels(),y.gl.RGBA,{premultiply:!1}),d.demTexture.bind(y.gl.NEAREST,y.gl.CLAMP_TO_EDGE),d.needsTerrainPrepare=!1}const m=d&&d+d.tileID.key+s.key;if(m&&!this._demMatrixCache[m]){const y=this.sourceCache.sourceCache._source.maxzoom;let x=s.canonical.z-d.tileID.canonical.z;s.overscaledZ>s.canonical.z&&(s.canonical.z>=y?x=s.canonical.z-y:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=s.canonical.x-(s.canonical.x>>x<<x),P=s.canonical.y-(s.canonical.y>>x<<x),O=l.bc(new Float64Array(16),[1/(l.X<<x),1/(l.X<<x),0]);l.J(O,O,[M*l.X,P*l.X,0]),this._demMatrixCache[s.key]={matrix:O,coord:s}}return{u_depth:2,u_terrain:3,u_terrain_dim:d&&d.dem&&d.dem.dim||1,u_terrain_matrix:m?this._demMatrixCache[s.key].matrix:this._emptyDemMatrix,u_terrain_unpack:d&&d.dem&&d.dem.getUnpackVector()||this._emptyDemUnpack,u_terrain_exaggeration:this.exaggeration,texture:(d&&d.demTexture||this._emptyDemTexture).texture,depthTexture:(this._fboDepthTexture||this._emptyDepthTexture).texture,tile:d}}getFramebuffer(s){const d=this.painter,m=d.width/devicePixelRatio,y=d.height/devicePixelRatio;return!this._fbo||this._fbo.width===m&&this._fbo.height===y||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new tt(d.context,{width:m,height:y,data:null},d.context.gl.RGBA,{premultiply:!1}),this._fboCoordsTexture.bind(d.context.gl.NEAREST,d.context.gl.CLAMP_TO_EDGE)),this._fboDepthTexture||(this._fboDepthTexture=new tt(d.context,{width:m,height:y,data:null},d.context.gl.RGBA,{premultiply:!1}),this._fboDepthTexture.bind(d.context.gl.NEAREST,d.context.gl.CLAMP_TO_EDGE)),this._fbo||(this._fbo=d.context.createFramebuffer(m,y,!0,!1),this._fbo.depthAttachment.set(d.context.createRenderbuffer(d.context.gl.DEPTH_COMPONENT16,m,y))),this._fbo.colorAttachment.set(s==="coords"?this._fboCoordsTexture.texture:this._fboDepthTexture.texture),this._fbo}getCoordsTexture(){const s=this.painter.context;if(this._coordsTexture)return this._coordsTexture;const d=new Uint8Array(this._coordsTextureSize*this._coordsTextureSize*4);for(let x=0,M=0;x<this._coordsTextureSize;x++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)d[M+0]=255&P,d[M+1]=255&x,d[M+2]=P>>8<<4|x>>8,d[M+3]=0;const m=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(d.buffer)),y=new tt(s,m,s.gl.RGBA,{premultiply:!1});return y.bind(s.gl.NEAREST,s.gl.CLAMP_TO_EDGE),this._coordsTexture=y,y}pointCoordinate(s){this.painter.maybeDrawDepthAndCoords(!0);const d=new Uint8Array(4),m=this.painter.context,y=m.gl,x=Math.round(s.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(s.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);m.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),y.readPixels(x,P-M-1,1,1,y.RGBA,y.UNSIGNED_BYTE,d),m.bindFramebuffer.set(null);const O=d[0]+(d[2]>>4<<8),z=d[1]+((15&d[2])<<8),V=this.coordsIndex[255-d[3]],F=V&&this.sourceCache.getTileByID(V);if(!F)return null;const W=this._coordsTextureSize,J=(1<<F.tileID.canonical.z)*W;return new l.Z((F.tileID.canonical.x*W+O)/J+F.tileID.wrap,(F.tileID.canonical.y*W+z)/J,this.getElevation(F.tileID,O,z,W))}depthAtPoint(s){const d=new Uint8Array(4),m=this.painter.context,y=m.gl;return m.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),y.readPixels(s.x,this.painter.height/devicePixelRatio-s.y-1,1,1,y.RGBA,y.UNSIGNED_BYTE,d),m.bindFramebuffer.set(null),(d[0]/16777216+d[1]/65536+d[2]/256+d[3])/256}getTerrainMesh(){if(this._mesh)return this._mesh;const s=this.painter.context,d=new l.bd,m=new l.aY,y=this.meshSize,x=l.X/y,M=y*y;for(let F=0;F<=y;F++)for(let W=0;W<=y;W++)d.emplaceBack(W*x,F*x,0);for(let F=0;F<M;F+=y+1)for(let W=0;W<y;W++)m.emplaceBack(W+F,y+W+F+1,y+W+F+2),m.emplaceBack(W+F,y+W+F+2,W+F+1);const P=d.length,O=P+2*(y+1);for(const F of[0,1])for(let W=0;W<=y;W++)for(const J of[0,1])d.emplaceBack(W*x,F*l.X,J);for(let F=0;F<2*y;F+=2)m.emplaceBack(O+F,O+F+1,O+F+3),m.emplaceBack(O+F,O+F+3,O+F+2),m.emplaceBack(P+F,P+F+3,P+F+1),m.emplaceBack(P+F,P+F+2,P+F+3);const z=d.length,V=z+2*(y+1);for(const F of[0,1])for(let W=0;W<=y;W++)for(const J of[0,1])d.emplaceBack(F*l.X,W*x,J);for(let F=0;F<2*y;F+=2)m.emplaceBack(z+F,z+F+1,z+F+3),m.emplaceBack(z+F,z+F+3,z+F+2),m.emplaceBack(V+F,V+F+3,V+F+1),m.emplaceBack(V+F,V+F+2,V+F+3);return this._mesh=new gu(s.createVertexBuffer(d,Dd.members),s.createIndexBuffer(m),l.a0.simpleSegment(0,0,d.length,m.length)),this._mesh}getMeshFrameDelta(s){return 2*Math.PI*l.be/Math.pow(2,s)/5}getMinTileElevationForLngLatZoom(s,d){var m;const{tileID:y}=this._getOverscaledTileIDFromLngLatZoom(s,d);return(m=this.getMinMaxElevation(y).minElevation)!==null&&m!==void 0?m:0}getMinMaxElevation(s){const d=this.getTerrainData(s).tile,m={minElevation:null,maxElevation:null};return d&&d.dem&&(m.minElevation=d.dem.min*this.exaggeration,m.maxElevation=d.dem.max*this.exaggeration),m}_getOverscaledTileIDFromLngLatZoom(s,d){const m=l.Z.fromLngLat(s.wrap()),y=(1<<d)*l.X,x=m.x*y,M=m.y*y,P=Math.floor(x/l.X),O=Math.floor(M/l.X);return{tileID:new l.S(d,0,d,P,O),mercatorX:x,mercatorY:M}}}class C_{constructor(s,d,m){this._context=s,this._size=d,this._tileSize=m,this._objects=[],this._recentlyUsed=[],this._stamp=0}destruct(){for(const s of this._objects)s.texture.destroy(),s.fbo.destroy()}_createObject(s){const d=this._context.createFramebuffer(this._tileSize,this._tileSize,!0,!0),m=new tt(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return m.bind(this._context.gl.LINEAR,this._context.gl.CLAMP_TO_EDGE),d.depthAttachment.set(this._context.createRenderbuffer(this._context.gl.DEPTH_STENCIL,this._tileSize,this._tileSize)),d.colorAttachment.set(m.texture),{id:s,fbo:d,texture:m,stamp:-1,inUse:!1}}getObjectForId(s){return this._objects[s]}useObject(s){s.inUse=!0,this._recentlyUsed=this._recentlyUsed.filter(d=>s.id!==d),this._recentlyUsed.push(s.id)}stampObject(s){s.stamp=++this._stamp}getOrCreateFreeObject(){for(const d of this._recentlyUsed)if(!this._objects[d].inUse)return this._objects[d];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const s=this._createObject(this._objects.length);return this._objects.push(s),s}freeObject(s){s.inUse=!1}freeAllObjects(){for(const s of this._objects)this.freeObject(s)}isFull(){return!(this._objects.length<this._size)&&this._objects.some(s=>!s.inUse)===!1}}const Za={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class Em{constructor(s,d){this.painter=s,this.terrain=d,this.pool=new C_(s.context,30,d.sourceCache.tileSize*d.qualityFactor)}destruct(){this.pool.destruct()}getTexture(s){return this.pool.getObjectForId(s.rtt[this._stacks.length-1].id).texture}prepareForRender(s,d){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=s._order.filter(m=>!s._layers[m].isHidden(d)),this._coordsDescendingInv={};for(const m in s.sourceCaches){this._coordsDescendingInv[m]={};const y=s.sourceCaches[m].getVisibleCoordinates();for(const x of y){const M=this.terrain.sourceCache.getTerrainCoords(x);for(const P in M)this._coordsDescendingInv[m][P]||(this._coordsDescendingInv[m][P]=[]),this._coordsDescendingInv[m][P].push(M[P])}}this._coordsDescendingInvStr={};for(const m of s._order){const y=s._layers[m],x=y.source;if(Za[y.type]&&!this._coordsDescendingInvStr[x]){this._coordsDescendingInvStr[x]={};for(const M in this._coordsDescendingInv[x])this._coordsDescendingInvStr[x][M]=this._coordsDescendingInv[x][M].map(P=>P.key).sort().join()}}for(const m of this._renderableTiles)for(const y in this._coordsDescendingInvStr){const x=this._coordsDescendingInvStr[y][m.tileID.key];x&&x!==m.rttCoords[y]&&(m.rtt=[])}}renderLayer(s){if(s.isHidden(this.painter.transform.zoom))return!1;const d=s.type,m=this.painter,y=this._renderableLayerIds[this._renderableLayerIds.length-1]===s.id;if(Za[d]&&(this._prevType&&Za[this._prevType]||this._stacks.push([]),this._prevType=d,this._stacks[this._stacks.length-1].push(s.id),!y))return!0;if(Za[this._prevType]||Za[d]&&y){this._prevType=d;const x=this._stacks.length-1,M=this._stacks[x]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(ym(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[x]){const z=this.pool.getObjectForId(P.rtt[x].id);if(z.stamp===P.rtt[x].stamp){this.pool.useObject(z);continue}}const O=this.pool.getOrCreateFreeObject();this.pool.useObject(O),this.pool.stampObject(O),P.rtt[x]={id:O.id,stamp:O.stamp},m.context.bindFramebuffer.set(O.fbo.framebuffer),m.context.clear({color:l.aM.transparent,stencil:0}),m.currentStencilSource=void 0;for(let z=0;z<M.length;z++){const V=m.style._layers[M[z]],F=V.source?this._coordsDescendingInv[V.source][P.tileID.key]:[P.tileID];m.context.viewport.set([0,0,O.fbo.width,O.fbo.height]),m._renderTileClippingMasks(V,F),m.renderLayer(m,m.style.sourceCaches[V.source],V,F),V.source&&(P.rttCoords[V.source]=this._coordsDescendingInvStr[V.source][P.tileID.key])}}return ym(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Za[d]}return!1}}const Bd={"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 ⌘ + scroll to zoom the map","CooperativeGesturesHandler.MobileHelpText":"Use two fingers to move the map"},Cm=g,T_={hash:!1,interactive:!0,bearingSnap:7,attributionControl:Wa,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:l.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},Nd=v=>{v.touchstart=v.dragStart,v.touchmoveWindow=v.dragMove,v.touchend=v.dragEnd},M_={showCompass:!0,showZoom:!0,visualizePitch:!1};class A_{constructor(s,d,m=!1){this.mousedown=M=>{this.startMouse(l.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),C.mousePos(this.element,M)),C.addEventListener(window,"mousemove",this.mousemove),C.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,C.mousePos(this.element,M))},this.mouseup=M=>{this.mouseRotate.dragEnd(M),this.mousePitch&&this.mousePitch.dragEnd(M),this.offTemp()},this.touchstart=M=>{M.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=C.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),C.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=C.touchPos(this.element,M.targetTouches)[0],this.moveTouch(M,this._lastPos))},this.touchend=M=>{M.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;const y=s.dragRotate._mouseRotate.getClickTolerance(),x=s.dragRotate._mousePitch.getClickTolerance();this.element=d,this.mouseRotate=wd({clickTolerance:y,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:O=.8})=>{const z=new vd;return new qs({clickTolerance:P,move:(V,F)=>({bearingDelta:(F.x-V.x)*O}),moveStateManager:z,enable:M,assignEvents:Nd})})({clickTolerance:y,enable:!0}),this.map=s,m&&(this.mousePitch=kd({clickTolerance:x,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:O=-.5})=>{const z=new vd;return new qs({clickTolerance:P,move:(V,F)=>({pitchDelta:(F.y-V.y)*O}),moveStateManager:z,enable:M,assignEvents:Nd})})({clickTolerance:x,enable:!0})),C.addEventListener(d,"mousedown",this.mousedown),C.addEventListener(d,"touchstart",this.touchstart,{passive:!1}),C.addEventListener(d,"touchcancel",this.reset)}startMouse(s,d){this.mouseRotate.dragStart(s,d),this.mousePitch&&this.mousePitch.dragStart(s,d),C.disableDrag()}startTouch(s,d){this.touchRotate.dragStart(s,d),this.touchPitch&&this.touchPitch.dragStart(s,d),C.disableDrag()}moveMouse(s,d){const m=this.map,{bearingDelta:y}=this.mouseRotate.dragMove(s,d)||{};if(y&&m.setBearing(m.getBearing()+y),this.mousePitch){const{pitchDelta:x}=this.mousePitch.dragMove(s,d)||{};x&&m.setPitch(m.getPitch()+x)}}moveTouch(s,d){const m=this.map,{bearingDelta:y}=this.touchRotate.dragMove(s,d)||{};if(y&&m.setBearing(m.getBearing()+y),this.touchPitch){const{pitchDelta:x}=this.touchPitch.dragMove(s,d)||{};x&&m.setPitch(m.getPitch()+x)}}off(){const s=this.element;C.removeEventListener(s,"mousedown",this.mousedown),C.removeEventListener(s,"touchstart",this.touchstart,{passive:!1}),C.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),C.removeEventListener(window,"touchend",this.touchend),C.removeEventListener(s,"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 br;function Vn(v,s,d){const m=new l.N(v.lng,v.lat);if(v=new l.N(v.lng,v.lat),s){const y=new l.N(v.lng-360,v.lat),x=new l.N(v.lng+360,v.lat),M=d.locationPoint(v).distSqr(s);d.locationPoint(y).distSqr(s)<M?v=y:d.locationPoint(x).distSqr(s)<M&&(v=x)}for(;Math.abs(v.lng-d.center.lng)>180;){const y=d.locationPoint(v);if(y.x>=0&&y.y>=0&&y.x<=d.width&&y.y<=d.height)break;v.lng>d.center.lng?v.lng-=360:v.lng+=360}return v.lng!==m.lng&&d.locationPoint(v).y>d.height/2-d.getHorizon()?v:m}const Ya={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 Tu(v,s,d){const m=v.classList;for(const y in Ya)m.remove(`maplibregl-${d}-anchor-${y}`);m.add(`maplibregl-${d}-anchor-${s}`)}class Mu extends l.E{constructor(s){if(super(),this._onKeyPress=d=>{const m=d.code,y=d.charCode||d.keyCode;m!=="Space"&&m!=="Enter"&&y!==32&&y!==13||this.togglePopup()},this._onMapClick=d=>{const m=d.originalEvent.target,y=this._element;this._popup&&(m===y||y.contains(m))&&this.togglePopup()},this._update=d=>{var m;if(!this._map)return;const y=this._map.loaded()&&!this._map.isMoving();((d==null?void 0:d.type)==="terrain"||(d==null?void 0:d.type)==="render"&&!y)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Vn(this._lngLat,this._flatPos,this._map.transform):(m=this._lngLat)===null||m===void 0?void 0:m.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 x="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?x=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(x=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let M="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?M="rotateX(0deg)":this._pitchAlignment==="map"&&(M=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||d&&d.type!=="moveend"||(this._pos=this._pos.round()),C.setTransform(this._element,`${Ya[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${x}`),E.frameAsync(new AbortController).then(()=>{this._updateOpacity(d&&d.type==="moveend")}).catch(()=>{})},this._onMove=d=>{if(!this._isDragging){const m=this._clickTolerance||this._map._clickTolerance;this._isDragging=d.point.dist(this._pointerdownPos)>=m}this._isDragging&&(this._pos=d.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 l.k("dragstart"))),this.fire(new l.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 l.k("dragend")),this._state="inactive"},this._addDragHandler=d=>{this._element.contains(d.originalEvent.target)&&(d.preventDefault(),this._positionDelta=d.point.sub(this._pos).add(this._offset),this._pointerdownPos=d.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=s&&s.anchor||"center",this._color=s&&s.color||"#3FB1CE",this._scale=s&&s.scale||1,this._draggable=s&&s.draggable||!1,this._clickTolerance=s&&s.clickTolerance||0,this._subpixelPositioning=s&&s.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=s&&s.rotation||0,this._rotationAlignment=s&&s.rotationAlignment||"auto",this._pitchAlignment=s&&s.pitchAlignment&&s.pitchAlignment!=="auto"?s.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(s==null?void 0:s.opacity,s==null?void 0:s.opacityWhenCovered),s&&s.element)this._element=s.element,this._offset=l.P.convert(s&&s.offset||[0,0]);else{this._defaultMarker=!0,this._element=C.create("div");const d=C.createNS("http://www.w3.org/2000/svg","svg"),m=41,y=27;d.setAttributeNS(null,"display","block"),d.setAttributeNS(null,"height",`${m}px`),d.setAttributeNS(null,"width",`${y}px`),d.setAttributeNS(null,"viewBox",`0 0 ${y} ${m}`);const x=C.createNS("http://www.w3.org/2000/svg","g");x.setAttributeNS(null,"stroke","none"),x.setAttributeNS(null,"stroke-width","1"),x.setAttributeNS(null,"fill","none"),x.setAttributeNS(null,"fill-rule","evenodd");const M=C.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=C.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const O=[{rx:"10.5",ry:"5.25002273"},{rx:"10.5",ry:"5.25002273"},{rx:"9.5",ry:"4.77275007"},{rx:"8.5",ry:"4.29549936"},{rx:"7.5",ry:"3.81822308"},{rx:"6.5",ry:"3.34094679"},{rx:"5.5",ry:"2.86367051"},{rx:"4.5",ry:"2.38636864"}];for(const ce of O){const he=C.createNS("http://www.w3.org/2000/svg","ellipse");he.setAttributeNS(null,"opacity","0.04"),he.setAttributeNS(null,"cx","10.5"),he.setAttributeNS(null,"cy","5.80029008"),he.setAttributeNS(null,"rx",ce.rx),he.setAttributeNS(null,"ry",ce.ry),P.appendChild(he)}const z=C.createNS("http://www.w3.org/2000/svg","g");z.setAttributeNS(null,"fill",this._color);const V=C.createNS("http://www.w3.org/2000/svg","path");V.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"),z.appendChild(V);const F=C.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");const W=C.createNS("http://www.w3.org/2000/svg","path");W.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(W);const J=C.createNS("http://www.w3.org/2000/svg","g");J.setAttributeNS(null,"transform","translate(6.0, 7.0)"),J.setAttributeNS(null,"fill","#FFFFFF");const ee=C.createNS("http://www.w3.org/2000/svg","g");ee.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=C.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const le=C.createNS("http://www.w3.org/2000/svg","circle");le.setAttributeNS(null,"fill","#FFFFFF"),le.setAttributeNS(null,"cx","5.5"),le.setAttributeNS(null,"cy","5.5"),le.setAttributeNS(null,"r","5.4999962"),ee.appendChild(se),ee.appendChild(le),M.appendChild(P),M.appendChild(z),M.appendChild(F),M.appendChild(J),M.appendChild(ee),d.appendChild(M),d.setAttributeNS(null,"height",m*this._scale+"px"),d.setAttributeNS(null,"width",y*this._scale+"px"),this._element.appendChild(d),this._offset=l.P.convert(s&&s.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",d=>{d.preventDefault()}),this._element.addEventListener("mousedown",d=>{d.preventDefault()}),Tu(this._element,this._anchor,"marker"),s&&s.className)for(const d of s.className.split(" "))this._element.classList.add(d);this._popup=null}addTo(s){return this.remove(),this._map=s,this._element.setAttribute("aria-label",s._getUIString("Marker.Title")),s.getCanvasContainer().appendChild(this._element),s.on("move",this._update),s.on("moveend",this._update),s.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(s){return this._lngLat=l.N.convert(s),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(s){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),s){if(!("offset"in s.options)){const y=Math.abs(13.5)/Math.SQRT2;s.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[y,-1*(38.1-13.5+y)],"bottom-right":[-y,-1*(38.1-13.5+y)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=s,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(s){return this._subpixelPositioning=s,this}getPopup(){return this._popup}togglePopup(){const s=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:s?(s.isOpen()?s.remove():(s.setLngLat(this._lngLat),s.addTo(this._map)),this):this}_updateOpacity(s=!1){var d,m;if(!(!((d=this._map)===null||d===void 0)&&d.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(s)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const y=this._map,x=y.terrain.depthAtPoint(this._pos),M=y.terrain.getElevationForLngLatZoom(this._lngLat,y.transform.tileZoom);if(y.transform.lngLatToCameraDepth(this._lngLat,M)-x<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/y.transform._pixelPerMeter,O=Math.sin(y.getPitch()*Math.PI/180)*P,z=y.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),V=y.transform.lngLatToCameraDepth(this._lngLat,M+O)-z>.006;!((m=this._popup)===null||m===void 0)&&m.isOpen()&&V&&this._popup.remove(),this._element.style.opacity=V?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(s){return this._offset=l.P.convert(s),this._update(),this}addClassName(s){this._element.classList.add(s)}removeClassName(s){this._element.classList.remove(s)}toggleClassName(s){return this._element.classList.toggle(s)}setDraggable(s){return this._draggable=!!s,this._map&&(s?(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(s){return this._rotation=s||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(s){return this._rotationAlignment=s||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(s){return this._pitchAlignment=s&&s!=="auto"?s:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(s,d){return s===void 0&&d===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),s!==void 0&&(this._opacity=s),d!==void 0&&(this._opacityWhenCovered=d),this._map&&this._updateOpacity(!0),this}}const Tm={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Jl=0,Ql=!1;const Ps={maxWidth:100,unit:"metric"};function ec(v,s,d){const m=d&&d.maxWidth||100,y=v._container.clientHeight/2,x=v.unproject([0,y]),M=v.unproject([m,y]),P=x.distanceTo(M);if(d&&d.unit==="imperial"){const O=3.2808*P;O>5280?ft(s,m,O/5280,v._getUIString("ScaleControl.Miles")):ft(s,m,O,v._getUIString("ScaleControl.Feet"))}else d&&d.unit==="nautical"?ft(s,m,P/1852,v._getUIString("ScaleControl.NauticalMiles")):P>=1e3?ft(s,m,P/1e3,v._getUIString("ScaleControl.Kilometers")):ft(s,m,P,v._getUIString("ScaleControl.Meters"))}function ft(v,s,d,m){const y=function(x){const M=Math.pow(10,`${Math.floor(x)}`.length-1);let P=x/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(O){const z=Math.pow(10,Math.ceil(-Math.log(O)/Math.LN10));return Math.round(O*z)/z}(P),M*P}(d);v.style.width=s*(y/d)+"px",v.innerHTML=`${y}&nbsp;${m}`}const Et={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},Au=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function Pu(v){if(v){if(typeof v=="number"){const s=Math.round(Math.abs(v)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,v),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-v),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(v,0),right:new l.P(-v,0)}}if(v instanceof l.P||Array.isArray(v)){const s=l.P.convert(v);return{center:s,top:s,"top-left":s,"top-right":s,bottom:s,"bottom-left":s,"bottom-right":s,left:s,right:s}}return{center:l.P.convert(v.center||[0,0]),top:l.P.convert(v.top||[0,0]),"top-left":l.P.convert(v["top-left"]||[0,0]),"top-right":l.P.convert(v["top-right"]||[0,0]),bottom:l.P.convert(v.bottom||[0,0]),"bottom-left":l.P.convert(v["bottom-left"]||[0,0]),"bottom-right":l.P.convert(v["bottom-right"]||[0,0]),left:l.P.convert(v.left||[0,0]),right:l.P.convert(v.right||[0,0])}}return Pu(new l.P(0,0))}const zd=g;u.AJAXError=l.bh,u.Evented=l.E,u.LngLat=l.N,u.MercatorCoordinate=l.Z,u.Point=l.P,u.addProtocol=l.bi,u.config=l.a,u.removeProtocol=l.bj,u.AttributionControl=Ga,u.BoxZoomHandler=_r,u.CanvasSource=wi,u.CooperativeGesturesHandler=qa,u.DoubleClickZoomHandler=Xo,u.DragPanHandler=wm,u.DragRotateHandler=km,u.EdgeInsets=$a,u.FullscreenControl=class extends l.E{constructor(v={}){super(),this._onFullscreenChange=()=>{var s;let d=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((s=d==null?void 0:d.shadowRoot)===null||s===void 0)&&s.fullscreenElement;)d=d.shadowRoot.fullscreenElement;d===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,v&&v.container&&(v.container instanceof HTMLElement?this._container=v.container:l.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(v){return this._map=v,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(){const v=this._fullscreenButton=C.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);C.create("span","maplibregl-ctrl-icon",v).setAttribute("aria-hidden","true"),v.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const v=this._getTitle();this._fullscreenButton.setAttribute("aria-label",v),this._fullscreenButton.title=v}_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 l.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new l.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()}},u.GeoJSONSource=vi,u.GeolocateControl=class extends l.E{constructor(v){super(),this._onSuccess=s=>{if(this._map){if(this._isOutOfMapMaxBounds(s))return this._setErrorState(),this.fire(new l.k("outofmaxbounds",s)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=s,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(s),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(s),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new l.k("geolocate",s)),this._finish()}},this._updateCamera=s=>{const d=new l.N(s.coords.longitude,s.coords.latitude),m=s.coords.accuracy,y=this._map.getBearing(),x=l.e({bearing:y},this.options.fitBoundsOptions),M=ve.fromLngLat(d,m);this._map.fitBounds(M,x,{geolocateSource:!0})},this._updateMarker=s=>{if(s){const d=new l.N(s.coords.longitude,s.coords.latitude);this._accuracyCircleMarker.setLngLat(d).addTo(this._map),this._userLocationDotMarker.setLngLat(d).addTo(this._map),this._accuracy=s.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=s=>{if(this._map){if(this.options.trackUserLocation)if(s.code===1){this._watchState="OFF",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.disabled=!0;const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(s.code===3&&Ql)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new l.k("error",s)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",s=>s.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=s=>{if(this._map){if(s===!1){l.w("Geolocation support is not available so the GeolocateControl will be disabled.");const d=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d)}else{const d=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=d,this._geolocateButton.setAttribute("aria-label",d)}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 Mu({element:this._dotElement}),this._circleElement=C.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Mu({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",d=>{d.geolocateSource||this._watchState!=="ACTIVE_LOCK"||d.originalEvent&&d.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 l.k("trackuserlocationend")),this.fire(new l.k("userlocationlostfocus")))})}},this.options=l.e({},Tm,v)}onAdd(v){return this._map=v,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,function*(s=!1){if(br!==void 0&&!s)return br;if(window.navigator.permissions===void 0)return br=!!window.navigator.geolocation,br;try{br=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{br=!!window.navigator.geolocation}return br})}().then(s=>this._finishSetupUI(s)),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,Jl=0,Ql=!1}_isOutOfMapMaxBounds(v){const s=this._map.getMaxBounds(),d=v.coords;return s&&(d.longitude<s.getWest()||d.longitude>s.getEast()||d.latitude<s.getSouth()||d.latitude>s.getNorth())}_setErrorState(){switch(this._watchState){case"WAITING_ACTIVE":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error");break;case"ACTIVE_LOCK":this._watchState="ACTIVE_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-active"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-active-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"BACKGROUND":this._watchState="BACKGROUND_ERROR",this._geolocateButton.classList.remove("maplibregl-ctrl-geolocate-background"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-background-error"),this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting");break;case"ACTIVE_ERROR":break;default:throw new Error(`Unexpected watchState ${this._watchState}`)}}_updateCircleRadius(){const v=this._map.getBounds(),s=v.getSouthEast(),d=v.getNorthEast(),m=s.distanceTo(d),y=Math.ceil(this._accuracy/(m/this._map._container.clientHeight)*2);this._circleElement.style.width=`${y}px`,this._circleElement.style.height=`${y}px`}trigger(){if(!this._setup)return l.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 l.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Jl--,Ql=!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 l.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 l.k("trackuserlocationstart")),this.fire(new l.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 v;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Jl++,Jl>1?(v={maximumAge:6e5,timeout:0},Ql=!0):(v=this.options.positionOptions,Ql=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,v)}}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)}},u.Hash=_u,u.ImageSource=mi,u.KeyboardHandler=Lr,u.LngLatBounds=ve,u.LogoControl=Id,u.Map=class extends Sm{constructor(v){l.bf.mark(l.bg.create);const s=Object.assign(Object.assign({},T_),v);if(s.minZoom!=null&&s.maxZoom!=null&&s.minZoom>s.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(s.minPitch!=null&&s.maxPitch!=null&&s.minPitch>s.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(s.minPitch!=null&&s.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(s.maxPitch!=null&&s.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new ja(s.minZoom,s.maxZoom,s.minPitch,s.maxPitch,s.renderWorldCopies),{bearingSnap:s.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new en,this._controls=[],this._mapId=l.a4(),this._contextLost=d=>{d.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new l.k("webglcontextlost",{originalEvent:d}))},this._contextRestored=d=>{this._setupPainter(),this.resize(),this._update(),this.fire(new l.k("webglcontextrestored",{originalEvent:d}))},this._onMapScroll=d=>{if(d.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=s.interactive,this._maxTileCacheSize=s.maxTileCacheSize,this._maxTileCacheZoomLevels=s.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=s.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=s.preserveDrawingBuffer===!0,this._antialias=s.antialias===!0,this._trackResize=s.trackResize===!0,this._bearingSnap=s.bearingSnap,this._refreshExpiredTiles=s.refreshExpiredTiles===!0,this._fadeDuration=s.fadeDuration,this._crossSourceCollisions=s.crossSourceCollisions===!0,this._collectResourceTiming=s.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},Bd),s.locale),this._clickTolerance=s.clickTolerance,this._overridePixelRatio=s.pixelRatio,this._maxCanvasSize=s.maxCanvasSize,this.transformCameraUpdate=s.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=s.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Z.addThrottleControl(()=>this.isMoving()),this._requestManager=new Q(s.transformRequest),typeof s.container=="string"){if(this._container=document.getElementById(s.container),!this._container)throw new Error(`Container '${s.container}' not found.`)}else{if(!(s.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=s.container}if(s.maxBounds&&this.setMaxBounds(s.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 d=!1;const m=Gl(y=>{this._trackResize&&!this._removed&&(this.resize(y),this.redraw())},50);this._resizeObserver=new ResizeObserver(y=>{d?m(y):d=!0}),this._resizeObserver.observe(this._container)}this.handlers=new Pd(this,s),this._hash=s.hash&&new _u(typeof s.hash=="string"&&s.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:s.center,zoom:s.zoom,bearing:s.bearing,pitch:s.pitch}),s.bounds&&(this.resize(),this.fitBounds(s.bounds,l.e({},s.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=s.localIdeographFontFamily,this._validateStyle=s.validateStyle,s.style&&this.setStyle(s.style,{localIdeographFontFamily:s.localIdeographFontFamily}),s.attributionControl&&this.addControl(new Ga(typeof s.attributionControl=="boolean"?void 0:s.attributionControl)),s.maplibreLogo&&this.addControl(new Id,s.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",d=>{this._update(d.dataType==="style"),this.fire(new l.k(`${d.dataType}data`,d))}),this.on("dataloading",d=>{this.fire(new l.k(`${d.dataType}dataloading`,d))}),this.on("dataabort",d=>{this.fire(new l.k("sourcedataabort",d))})}_getMapId(){return this._mapId}addControl(v,s){if(s===void 0&&(s=v.getDefaultPosition?v.getDefaultPosition():"top-right"),!v||!v.onAdd)return this.fire(new l.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const d=v.onAdd(this);this._controls.push(v);const m=this._controlPositions[s];return s.indexOf("bottom")!==-1?m.insertBefore(d,m.firstChild):m.appendChild(d),this}removeControl(v){if(!v||!v.onRemove)return this.fire(new l.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const s=this._controls.indexOf(v);return s>-1&&this._controls.splice(s,1),v.onRemove(this),this}hasControl(v){return this._controls.indexOf(v)>-1}calculateCameraOptionsFromTo(v,s,d,m){return m==null&&this.terrain&&(m=this.terrain.getElevationForLngLatZoom(d,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(v,s,d,m)}resize(v){var s;const d=this._containerDimensions(),m=d[0],y=d[1],x=this._getClampedPixelRatio(m,y);if(this._resizeCanvas(m,y,x),this.painter.resize(m,y,x),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const O=this._getClampedPixelRatio(m,y);this._resizeCanvas(m,y,O),this.painter.resize(m,y,O)}this.transform.resize(m,y),(s=this._requestedCameraState)===null||s===void 0||s.resize(m,y);const M=!this._moving;return M&&(this.stop(),this.fire(new l.k("movestart",v)).fire(new l.k("move",v))),this.fire(new l.k("resize",v)),M&&this.fire(new l.k("moveend",v)),this}_getClampedPixelRatio(v,s){const{0:d,1:m}=this._maxCanvasSize,y=this.getPixelRatio(),x=v*y,M=s*y;return Math.min(x>d?d/x:1,M>m?m/M:1)*y}getPixelRatio(){var v;return(v=this._overridePixelRatio)!==null&&v!==void 0?v:devicePixelRatio}setPixelRatio(v){this._overridePixelRatio=v,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(v){return this.transform.setMaxBounds(ve.convert(v)),this._update()}setMinZoom(v){if((v=v??-2)>=-2&&v<=this.transform.maxZoom)return this.transform.minZoom=v,this._update(),this.getZoom()<v&&this.setZoom(v),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(v){if((v=v??22)>=this.transform.minZoom)return this.transform.maxZoom=v,this._update(),this.getZoom()>v&&this.setZoom(v),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(v){if((v=v??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(v>=0&&v<=this.transform.maxPitch)return this.transform.minPitch=v,this._update(),this.getPitch()<v&&this.setPitch(v),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(v){if((v=v??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(v>=this.transform.minPitch)return this.transform.maxPitch=v,this._update(),this.getPitch()>v&&this.setPitch(v),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(v){return this.transform.renderWorldCopies=v,this._update()}project(v){return this.transform.locationPoint(l.N.convert(v),this.style&&this.terrain)}unproject(v){return this.transform.pointLocation(l.P.convert(v),this.terrain)}isMoving(){var v;return this._moving||((v=this.handlers)===null||v===void 0?void 0:v.isMoving())}isZooming(){var v;return this._zooming||((v=this.handlers)===null||v===void 0?void 0:v.isZooming())}isRotating(){var v;return this._rotating||((v=this.handlers)===null||v===void 0?void 0:v.isRotating())}_createDelegatedListener(v,s,d){if(v==="mouseenter"||v==="mouseover"){let m=!1;return{layers:s,listener:d,delegates:{mousemove:x=>{const M=s.filter(O=>this.getLayer(O)),P=M.length!==0?this.queryRenderedFeatures(x.point,{layers:M}):[];P.length?m||(m=!0,d.call(this,new Oi(v,this,x.originalEvent,{features:P}))):m=!1},mouseout:()=>{m=!1}}}}if(v==="mouseleave"||v==="mouseout"){let m=!1;return{layers:s,listener:d,delegates:{mousemove:M=>{const P=s.filter(O=>this.getLayer(O));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?m=!0:m&&(m=!1,d.call(this,new Oi(v,this,M.originalEvent)))},mouseout:M=>{m&&(m=!1,d.call(this,new Oi(v,this,M.originalEvent)))}}}}{const m=y=>{const x=s.filter(P=>this.getLayer(P)),M=x.length!==0?this.queryRenderedFeatures(y.point,{layers:x}):[];M.length&&(y.features=M,d.call(this,y),delete y.features)};return{layers:s,listener:d,delegates:{[v]:m}}}}_saveDelegatedListener(v,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[v]=this._delegatedListeners[v]||[],this._delegatedListeners[v].push(s)}_removeDelegatedListener(v,s,d){if(!this._delegatedListeners||!this._delegatedListeners[v])return;const m=this._delegatedListeners[v];for(let y=0;y<m.length;y++){const x=m[y];if(x.listener===d&&x.layers.length===s.length&&x.layers.every(M=>s.includes(M))){for(const M in x.delegates)this.off(M,x.delegates[M]);return void m.splice(y,1)}}}on(v,s,d){if(d===void 0)return super.on(v,s);const m=this._createDelegatedListener(v,typeof s=="string"?[s]:s,d);this._saveDelegatedListener(v,m);for(const y in m.delegates)this.on(y,m.delegates[y]);return this}once(v,s,d){if(d===void 0)return super.once(v,s);const m=typeof s=="string"?[s]:s,y=this._createDelegatedListener(v,m,d);for(const x in y.delegates){const M=y.delegates[x];y.delegates[x]=(...P)=>{this._removeDelegatedListener(v,m,d),M(...P)}}this._saveDelegatedListener(v,y);for(const x in y.delegates)this.once(x,y.delegates[x]);return this}off(v,s,d){return d===void 0?super.off(v,s):(this._removeDelegatedListener(v,typeof s=="string"?[s]:s,d),this)}queryRenderedFeatures(v,s){if(!this.style)return[];let d;const m=v instanceof l.P||Array.isArray(v),y=m?v:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(m?{}:v)||{},y instanceof l.P||typeof y[0]=="number")d=[l.P.convert(y)];else{const x=l.P.convert(y[0]),M=l.P.convert(y[1]);d=[x,new l.P(M.x,x.y),M,new l.P(x.x,M.y),x]}return this.style.queryRenderedFeatures(d,s,this.transform)}querySourceFeatures(v,s){return this.style.querySourceFeatures(v,s)}setStyle(v,s){return(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff!==!1&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&v?(this._diffStyle(v,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(v,s))}setTransformRequest(v){return this._requestManager.setTransformRequest(v),this}_getUIString(v){const s=this._locale[v];if(s==null)throw new Error(`Missing UI string '${v}'`);return s}_updateStyle(v,s){if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(v,s));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!v)),v?(this.style=new tu(this,s||{}),this.style.setEventedParent(this,{style:this.style}),typeof v=="string"?this.style.loadURL(v,s,d):this.style.loadJSON(v,s,d),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new tu(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(v,s){if(typeof v=="string"){const d=this._requestManager.transformRequest(v,"Style");l.h(d,new AbortController).then(m=>{this._updateDiff(m.data,s)}).catch(m=>{m&&this.fire(new l.j(m))})}else typeof v=="object"&&this._updateDiff(v,s)}_updateDiff(v,s){try{this.style.setState(v,s)&&this._update(!0)}catch(d){l.w(`Unable to perform style diff: ${d.message||d.error||d}. Rebuilding the style from scratch.`),this._updateStyle(v,s)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():l.w("There is no style added to the map.")}addSource(v,s){return this._lazyInitEmptyStyle(),this.style.addSource(v,s),this._update(!0)}isSourceLoaded(v){const s=this.style&&this.style.sourceCaches[v];if(s!==void 0)return s.loaded();this.fire(new l.j(new Error(`There is no source with ID '${v}'`)))}setTerrain(v){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),v){const s=this.style.sourceCaches[v.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${v.source}`);this.terrain===null&&s.reload();for(const d in this.style._layers){const m=this.style._layers[d];m.type==="hillshade"&&m.source===v.source&&l.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 Od(this.painter,s,v),this.painter.renderToTexture=new Em(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=d=>{d.dataType==="style"?this.terrain.sourceCache.freeRtt():d.dataType==="source"&&d.tile&&(d.sourceId!==v.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(d.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 l.k("terrain",{terrain:v})),this}getTerrain(){var v,s;return(s=(v=this.terrain)===null||v===void 0?void 0:v.options)!==null&&s!==void 0?s:null}areTilesLoaded(){const v=this.style&&this.style.sourceCaches;for(const s in v){const d=v[s]._tiles;for(const m in d){const y=d[m];if(y.state!=="loaded"&&y.state!=="errored")return!1}}return!0}removeSource(v){return this.style.removeSource(v),this._update(!0)}getSource(v){return this.style.getSource(v)}addImage(v,s,d={}){const{pixelRatio:m=1,sdf:y=!1,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z}=d;if(this._lazyInitEmptyStyle(),!(s instanceof HTMLImageElement||l.b(s))){if(s.width===void 0||s.height===void 0)return this.fire(new l.j(new Error("Invalid arguments to map.addImage(). The second argument must be an `HTMLImageElement`, `ImageData`, `ImageBitmap`, or object with `width`, `height`, and `data` properties with the same format as `ImageData`")));{const{width:V,height:F,data:W}=s,J=s;return this.style.addImage(v,{data:new l.R({width:V,height:F},new Uint8Array(W)),pixelRatio:m,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z,sdf:y,version:0,userImage:J}),J.onAdd&&J.onAdd(this,v),this}}{const{width:V,height:F,data:W}=E.getImageData(s);this.style.addImage(v,{data:new l.R({width:V,height:F},W),pixelRatio:m,stretchX:x,stretchY:M,content:P,textFitWidth:O,textFitHeight:z,sdf:y,version:0})}}updateImage(v,s){const d=this.style.getImage(v);if(!d)return this.fire(new l.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const m=s instanceof HTMLImageElement||l.b(s)?E.getImageData(s):s,{width:y,height:x,data:M}=m;if(y===void 0||x===void 0)return this.fire(new l.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(y!==d.data.width||x!==d.data.height)return this.fire(new l.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const P=!(s instanceof HTMLImageElement||l.b(s));return d.data.replace(M,P),this.style.updateImage(v,d),this}getImage(v){return this.style.getImage(v)}hasImage(v){return v?!!this.style.getImage(v):(this.fire(new l.j(new Error("Missing required image id"))),!1)}removeImage(v){this.style.removeImage(v)}loadImage(v){return Z.getImage(this._requestManager.transformRequest(v,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(v,s){return this._lazyInitEmptyStyle(),this.style.addLayer(v,s),this._update(!0)}moveLayer(v,s){return this.style.moveLayer(v,s),this._update(!0)}removeLayer(v){return this.style.removeLayer(v),this._update(!0)}getLayer(v){return this.style.getLayer(v)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(v,s,d){return this.style.setLayerZoomRange(v,s,d),this._update(!0)}setFilter(v,s,d={}){return this.style.setFilter(v,s,d),this._update(!0)}getFilter(v){return this.style.getFilter(v)}setPaintProperty(v,s,d,m={}){return this.style.setPaintProperty(v,s,d,m),this._update(!0)}getPaintProperty(v,s){return this.style.getPaintProperty(v,s)}setLayoutProperty(v,s,d,m={}){return this.style.setLayoutProperty(v,s,d,m),this._update(!0)}getLayoutProperty(v,s){return this.style.getLayoutProperty(v,s)}setGlyphs(v,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(v,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(v,s,d={}){return this._lazyInitEmptyStyle(),this.style.addSprite(v,s,d,m=>{m||this._update(!0)}),this}removeSprite(v){return this._lazyInitEmptyStyle(),this.style.removeSprite(v),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(v,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(v,s,d=>{d||this._update(!0)}),this}setLight(v,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(v,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(v){return this._lazyInitEmptyStyle(),this.style.setSky(v),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(v,s){return this.style.setFeatureState(v,s),this._update()}removeFeatureState(v,s){return this.style.removeFeatureState(v,s),this._update()}getFeatureState(v){return this.style.getFeatureState(v)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let v=0,s=0;return this._container&&(v=this._container.clientWidth||400,s=this._container.clientHeight||300),[v,s]}_setupContainer(){const v=this._container;v.classList.add("maplibregl-map");const s=this._canvasContainer=C.create("div","maplibregl-canvas-container",v);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=C.create("canvas","maplibregl-canvas",s),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");const d=this._containerDimensions(),m=this._getClampedPixelRatio(d[0],d[1]);this._resizeCanvas(d[0],d[1],m);const y=this._controlContainer=C.create("div","maplibregl-control-container",v),x=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{x[M]=C.create("div",`maplibregl-ctrl-${M} `,y)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(v,s,d){this._canvas.width=Math.floor(d*v),this._canvas.height=Math.floor(d*s),this._canvas.style.width=`${v}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const v={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let s=null;this._canvas.addEventListener("webglcontextcreationerror",m=>{s={requestedAttributes:v},m&&(s.statusMessage=m.statusMessage,s.type=m.type)},{once:!0});const d=this._canvas.getContext("webgl2",v)||this._canvas.getContext("webgl",v);if(!d){const m="Failed to initialize WebGL";throw s?(s.message=m,new Error(JSON.stringify(s))):new Error(m)}this.painter=new yu(d,this.transform),I.testSupport(d)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(v){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||v,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(v){return this._update(),this._renderTaskQueue.add(v)}_cancelRenderFrame(v){this._renderTaskQueue.remove(v)}_render(v){const s=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(v),this._removed)return;let d=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const y=this.transform.zoom,x=E.now();this.style.zoomHistory.update(y,x);const M=new l.z(y,{now:x,fadeDuration:s,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),P=M.crossFadingFactor();P===1&&P===this._crossFadingFactor||(d=!0,this._crossFadingFactor=P),this.style.update(M)}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,s,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:s,showPadding:this.showPadding}),this.fire(new l.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,l.bf.mark(l.bg.load),this.fire(new l.k("load"))),this.style&&(this.style.hasTransitions()||d)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const m=this._sourcesDirty||this._styleDirty||this._placementDirty;return m||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.k("idle")),!this._loaded||this._fullyLoaded||m||(this._fullyLoaded=!0,l.bf.mark(l.bg.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var v;this._hash&&this._hash.remove();for(const d of this._controls)d.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),Z.removeThrottleControl(this._imageQueueHandle),(v=this._resizeObserver)===null||v===void 0||v.disconnect();const s=this.painter.context.gl.getExtension("WEBGL_lose_context");s!=null&&s.loseContext&&s.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"),l.bf.clearMetrics(),this._removed=!0,this.fire(new l.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,E.frameAsync(this._frameRequest).then(v=>{l.bf.frame(v),this._frameRequest=null,this._render(v)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(v){this._showTileBoundaries!==v&&(this._showTileBoundaries=v,this._update())}get showPadding(){return!!this._showPadding}set showPadding(v){this._showPadding!==v&&(this._showPadding=v,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(v){this._showCollisionBoxes!==v&&(this._showCollisionBoxes=v,v?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(v){this._showOverdrawInspector!==v&&(this._showOverdrawInspector=v,this._update())}get repaint(){return!!this._repaint}set repaint(v){this._repaint!==v&&(this._repaint=v,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(v){this._vertices=v,this._update()}get version(){return Cm}getCameraTargetElevation(){return this.transform.elevation}},u.MapMouseEvent=Oi,u.MapTouchEvent=Zo,u.MapWheelEvent=bm,u.Marker=Mu,u.NavigationControl=class{constructor(v){this._updateZoomButtons=()=>{const s=this._map.getZoom(),d=s===this._map.getMaxZoom(),m=s===this._map.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=m,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",m.toString())},this._rotateCompassArrow=()=>{const s=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=s},this._setButtonTitle=(s,d)=>{const m=this._map._getUIString(`NavigationControl.${d}`);s.title=m,s.setAttribute("aria-label",m)},this.options=l.e({},M_,v),this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",s=>s.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",s=>this._map.zoomIn({},{originalEvent:s})),C.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",s=>this._map.zoomOut({},{originalEvent:s})),C.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",s=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:s}):this._map.resetNorth({},{originalEvent:s})}),this._compassIcon=C.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(v){return this._map=v,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 A_(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(v,s){const d=C.create("button",v,this._container);return d.type="button",d.addEventListener("click",s),d}},u.Popup=class extends l.E{constructor(v){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 l.k("close"))),this),this._onMouseUp=s=>{this._update(s.point)},this._onMouseMove=s=>{this._update(s.point)},this._onDrag=s=>{this._update(s.point)},this._update=s=>{var d;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(const P of this.options.className.split(" "))this._container.classList.add(P);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?Vn(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.wrap(),this._trackPointer&&!s)return;const m=this._flatPos=this._pos=this._trackPointer&&s?s:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&s?s:this._map.transform.locationPoint(this._lngLat));let y=this.options.anchor;const x=Pu(this.options.offset);if(!y){const P=this._container.offsetWidth,O=this._container.offsetHeight;let z;z=m.y+x.bottom.y<O?["top"]:m.y>this._map.transform.height-O?["bottom"]:[],m.x<P/2?z.push("left"):m.x>this._map.transform.width-P/2&&z.push("right"),y=z.length===0?"bottom":z.join("-")}let M=m.add(x[y]);this.options.subpixelPositioning||(M=M.round()),C.setTransform(this._container,`${Ya[y]} translate(${M.x}px,${M.y}px)`),Tu(this._container,y,"popup")},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(Et),v)}addTo(v){return this._map&&this.remove(),this._map=v,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 l.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(v){return this._lngLat=l.N.convert(v),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(v){return this.setDOMContent(document.createTextNode(v))}setHTML(v){const s=document.createDocumentFragment(),d=document.createElement("body");let m;for(d.innerHTML=v;m=d.firstChild,m;)s.appendChild(m);return this.setDOMContent(s)}getMaxWidth(){var v;return(v=this._container)===null||v===void 0?void 0:v.style.maxWidth}setMaxWidth(v){return this.options.maxWidth=v,this._update(),this}setDOMContent(v){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(v),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(v){return this._container&&this._container.classList.add(v),this}removeClassName(v){return this._container&&this._container.classList.remove(v),this}setOffset(v){return this.options.offset=v,this._update(),this}toggleClassName(v){if(this._container)return this._container.classList.toggle(v)}setSubpixelPositioning(v){this.options.subpixelPositioning=v}_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;const v=this._container.querySelector(Au);v&&v.focus()}},u.RasterDEMTileSource=on,u.RasterTileSource=qt,u.ScaleControl=class{constructor(v){this._onMove=()=>{ec(this._map,this._container,this.options)},this.setUnit=s=>{this.options.unit=s,ec(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Ps),v)}getDefaultPosition(){return"bottom-left"}onAdd(v){return this._map=v,this._container=C.create("div","maplibregl-ctrl maplibregl-ctrl-scale",v.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}},u.ScrollZoomHandler=ns,u.Style=tu,u.TerrainControl=class{constructor(v){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=v}onAdd(v){return this._map=v,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}},u.TwoFingersTouchPitchHandler=Ha,u.TwoFingersTouchRotateHandler=Td,u.TwoFingersTouchZoomHandler=Ed,u.TwoFingersTouchZoomRotateHandler=Ad,u.VectorTileSource=pr,u.VideoSource=Or,u.addSourceType=(v,s)=>l._(void 0,void 0,void 0,function*(){if(Cs(v))throw new Error(`A source type called "${v}" already exists.`);((d,m)=>{Es[d]=m})(v,s)}),u.clearPrewarmedResources=function(){const v=Ee;v&&(v.isPreloaded()&&v.numActive()===1?(v.release(zn),Ee=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()"))},u.getMaxParallelImageRequests=function(){return l.a.MAX_PARALLEL_IMAGE_REQUESTS},u.getRTLTextPluginStatus=function(){return Nr().getRTLTextPluginStatus()},u.getVersion=function(){return zd},u.getWorkerCount=function(){return In.workerCount},u.getWorkerUrl=function(){return l.a.WORKER_URL},u.importScriptInWorkers=function(v){return Lt().broadcast("IS",v)},u.prewarm=function(){Ye().acquire(zn)},u.setMaxParallelImageRequests=function(v){l.a.MAX_PARALLEL_IMAGE_REQUESTS=v},u.setRTLTextPlugin=function(v,s){return Nr().setRTLTextPlugin(v,s)},u.setWorkerCount=function(v){In.workerCount=v},u.setWorkerUrl=function(v){l.a.WORKER_URL=v}});var a=t;return a})})(Y1);var MB=Y1.exports;const AB=CB(MB),PB={},IB={xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"icon icon-tabler icons-tabler-outline icon-tabler-x"};function DB(n,e,t,i,r,a){return f.openBlock(),f.createElementBlock("svg",IB,e[0]||(e[0]=[f.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),f.createElementVNode("path",{d:"M18 6l-12 12"},null,-1),f.createElementVNode("path",{d:"M6 6l12 12"},null,-1)]))}const OB=Ue(PB,[["render",DB]]),Cr="widget-map-source",BB={components:{IconClose:OB},props:{geometry:{type:Object,default:()=>null},zoom:{type:Number,default:50},height:{type:String,default:"400px"}},data(){return{map:null,isOpen:!1,selectedBaseLayer:"topo100",isGeometryVisible:!0,baseLayers:[{id:"topo100",name:"Карта України",url:"https://data.gki.com.ua/api-user/rtile/voyager/ua/{z}/{x}/{y}.png"},{id:"orto10",name:"Ortophoto 1:10К",url:"https://data.gki.com.ua/api-user/rtile/orto10/ua/{z}/{x}/{y}.png",service:"TMS"},{id:"osmb",name:"Open Street Map",url:"https://tile.openstreetmap.org.ua/styles/osm-bright/{z}/{x}/{y}.png",service:"TMS"},{id:"gsv",name:"Google Street View",url:"https://mt2.google.com/vt/?lyrs=svv|cb_client:apiv3&style=50&x={x}&y={y}&z={z}",service:"TMS"}]}},mounted(){this.initMap()},watch:{geometry(){this.initGeometryLayer()}},methods:{initMap(){this.map=new AB.Map({container:this.$refs.mapContainer,style:{version:8,sources:{"base-layer":{type:"raster",tiles:[this.getLayerById(this.selectedBaseLayer).url],tileSize:256}},layers:[{id:"base-layer",type:"raster",source:"base-layer"}]},center:[0,0],zoom:2}),this.map.on("load",()=>{this.geometry&&this.initGeometryLayer(),this.map.resize()})},changeBaseLayer(n){const e=this.map.getSource("base-layer");e&&(e.tiles=[n.url],this.map.style.sourceCaches["base-layer"].clearTiles(),this.map.style.sourceCaches["base-layer"].update(this.map.transform),this.map.triggerRepaint())},getLayerById(n){return this.baseLayers.find(e=>e.id===n)},initGeometryLayer(){const{map:n}=this;if(!n)return;const e=this.formatGeojson(this.geometry),t=n.getSource(Cr);if(this.zoomToGeometry(e),t){t.setData(e);return}n.addSource(Cr,{type:"geojson",data:e}),n.addLayer({id:`${Cr}-point`,type:"circle",source:Cr,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),n.addLayer({id:`${Cr}-polygon`,type:"fill",source:Cr,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),n.addLayer({id:`${Cr}-polygon-line`,type:"line",source:Cr,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),n.addLayer({id:`${Cr}-line`,type:"line",source:Cr,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(n){let e=n;const t=n==null?void 0:n.type;if(Array.isArray(n))return Z1(n);if(!t)throw new Error("Unknown geometry type!");return t==="FeatureCollection"?n:(t==="Feature"&&(e=[n]),!["FeatureCollection","Feature"].includes(t)&&(e=[TB(n)]),Z1(e))},zoomToGeometry(n){const{map:e}=this,t=SB(n);e.fitBounds(t,{zoom:this.zoom,padding:30,duration:0})},toggleGeometryVisibility(){[`${Cr}-polygon`,`${Cr}-polygon-line`,`${Cr}-line`,`${Cr}-point`].forEach(e=>{this.map.getLayer(e)&&this.map.setLayoutProperty(e,"visibility",this.isGeometryVisible?"visible":"none")})}}},NB={class:"relative w-full"},zB={key:1,class:"bg-white absolute top-[10px] right-[10px] z-20 border rounded-lg cursor-pointer"},RB={class:"border-b p-2 flex items-center justify-between"},LB={class:"flex items-center"},VB=["value","onChange"],FB={class:"ml-2"},$B={key:0,class:"p-2"},jB={class:"flex items-center"};function UB(n,e,t,i,r,a){const u=f.resolveComponent("IconClose");return f.openBlock(),f.createElementBlock("div",NB,[r.isOpen?(f.openBlock(),f.createElementBlock("div",zB,[f.createElementVNode("div",RB,[e[5]||(e[5]=f.createElementVNode("div",null,"Базові шари",-1)),f.createVNode(u,{onClick:e[1]||(e[1]=l=>r.isOpen=!1),class:"h-4 w-4"})]),f.createElementVNode("div",{class:f.normalizeClass(["p-2",{"border-b":t.geometry}])},[(f.openBlock(!0),f.createElementBlock(f.Fragment,null,f.renderList(r.baseLayers,l=>(f.openBlock(),f.createElementBlock("div",{key:l.id,class:"mb-2"},[f.createElementVNode("label",LB,[f.withDirectives(f.createElementVNode("input",{type:"radio",name:"base-layer",value:l.id,"onUpdate:modelValue":e[2]||(e[2]=g=>r.selectedBaseLayer=g),onChange:g=>a.changeBaseLayer(l)},null,40,VB),[[f.vModelRadio,r.selectedBaseLayer]]),f.createElementVNode("span",FB,f.toDisplayString(l.name),1)])]))),128))],2),t.geometry?(f.openBlock(),f.createElementBlock("div",$B,[f.createElementVNode("label",jB,[f.withDirectives(f.createElementVNode("input",{type:"checkbox","onUpdate:modelValue":e[3]||(e[3]=l=>r.isGeometryVisible=l),onChange:e[4]||(e[4]=(...l)=>a.toggleGeometryVisibility&&a.toggleGeometryVisibility(...l))},null,544),[[f.vModelCheckbox,r.isGeometryVisible]]),e[6]||(e[6]=f.createElementVNode("span",{class:"ml-2"},"Показати геометрію",-1))])])):f.createCommentVNode("",!0)])):(f.openBlock(),f.createElementBlock("div",{key:0,class:"bg-white absolute top-[10px] right-[10px] z-20 p-2 border rounded-lg cursor-pointer",onClick:e[0]||(e[0]=l=>r.isOpen=!0)}," Базові шари ")),f.createElementVNode("div",{ref:"mapContainer",style:f.normalizeStyle({height:t.height,width:"100%"})},null,4)])}const sy=Ue(BB,[["render",UB]]),at=(n,e=1e4)=>(n=parseFloat(n+"")||0,Math.round((n+Number.EPSILON)*e)/e),oy=function(n){if(!(n&&n instanceof Element&&n.offsetParent))return!1;const e=n.scrollHeight>n.clientHeight,t=window.getComputedStyle(n).overflowY,i=t.indexOf("hidden")!==-1,r=t.indexOf("visible")!==-1;return e&&!i&&!r},Lp=function(n,e=void 0){return!(!n||n===document.body||e&&n===e)&&(oy(n)?n:Lp(n.parentElement,e))},Qs=function(n){var e=new DOMParser().parseFromString(n,"text/html").body;if(e.childElementCount>1){for(var t=document.createElement("div");e.firstChild;)t.appendChild(e.firstChild);return t}return e.firstChild},ay=n=>`${n||""}`.split(" ").filter(e=>!!e),eo=(n,e,t)=>{n&&ay(e).forEach(i=>{n.classList.toggle(i,t||!1)})};class Sc{constructor(e){Object.defineProperty(this,"pageX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"pageY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientX",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"clientY",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"time",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"nativePointer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.nativePointer=e,this.pageX=e.pageX,this.pageY=e.pageY,this.clientX=e.clientX,this.clientY=e.clientY,this.id=self.Touch&&e instanceof Touch?e.identifier:-1,this.time=Date.now()}}const Ec={passive:!1};class HB{constructor(e,{start:t=()=>!0,move:i=()=>{},end:r=()=>{}}){Object.defineProperty(this,"element",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"startCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"moveCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"endCallback",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"currentPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"startPointers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),this.element=e,this.startCallback=t,this.moveCallback=i,this.endCallback=r;for(const a of["onPointerStart","onTouchStart","onMove","onTouchEnd","onPointerEnd","onWindowBlur"])this[a]=this[a].bind(this);this.element.addEventListener("mousedown",this.onPointerStart,Ec),this.element.addEventListener("touchstart",this.onTouchStart,Ec),this.element.addEventListener("touchmove",this.onMove,Ec),this.element.addEventListener("touchend",this.onTouchEnd),this.element.addEventListener("touchcancel",this.onTouchEnd)}onPointerStart(e){if(!e.buttons||e.button!==0)return;const t=new Sc(e);this.currentPointers.some(i=>i.id===t.id)||this.triggerPointerStart(t,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const t of Array.from(e.changedTouches||[]))this.triggerPointerStart(new Sc(t),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const t=this.currentPointers.slice(),i="changedTouches"in e?Array.from(e.changedTouches||[]).map(a=>new Sc(a)):[new Sc(e)],r=[];for(const a of i){const u=this.currentPointers.findIndex(l=>l.id===a.id);u<0||(r.push(a),this.currentPointers[u]=a)}r.length&&this.moveCallback(e,this.currentPointers.slice(),t)}onPointerEnd(e){e.buttons>0&&e.button!==0||(this.triggerPointerEnd(e,new Sc(e)),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur))}onTouchEnd(e){for(const t of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new Sc(t))}triggerPointerStart(e,t){return!!this.startCallback(t,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,t){const i=this.currentPointers.findIndex(r=>r.id===t.id);i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(e,t,this.currentPointers.slice()))}onWindowBlur(){this.clear()}clear(){for(;this.currentPointers.length;){const e=this.currentPointers[this.currentPointers.length-1];this.currentPointers.splice(this.currentPointers.length-1,1),this.startPointers.splice(this.currentPointers.length-1,1),this.endCallback(new Event("touchend",{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY}),e,this.currentPointers.slice())}}stop(){this.element.removeEventListener("mousedown",this.onPointerStart,Ec),this.element.removeEventListener("touchstart",this.onTouchStart,Ec),this.element.removeEventListener("touchmove",this.onMove,Ec),this.element.removeEventListener("touchend",this.onTouchEnd),this.element.removeEventListener("touchcancel",this.onTouchEnd),window.removeEventListener("mousemove",this.onMove),window.removeEventListener("mouseup",this.onPointerEnd),window.removeEventListener("blur",this.onWindowBlur)}}function X1(n,e){return e?Math.sqrt(Math.pow(e.clientX-n.clientX,2)+Math.pow(e.clientY-n.clientY,2)):0}function K1(n,e){return e?{clientX:(n.clientX+e.clientX)/2,clientY:(n.clientY+e.clientY)/2}:n}const ly=n=>typeof n=="object"&&n!==null&&n.constructor===Object&&Object.prototype.toString.call(n)==="[object Object]",Tr=(n,...e)=>{const t=e.length;for(let i=0;i<t;i++){const r=e[i]||{};Object.entries(r).forEach(([a,u])=>{const l=Array.isArray(u)?[]:{};n[a]||Object.assign(n,{[a]:l}),ly(u)?Object.assign(n[a],Tr(l,u)):Array.isArray(u)?Object.assign(n,{[a]:[...u]}):Object.assign(n,{[a]:u})})}return n},cy=function(n,e){return n.split(".").reduce((t,i)=>typeof t=="object"?t[i]:void 0,e)};class Vp{constructor(e={}){Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:e}),Object.defineProperty(this,"events",{enumerable:!0,configurable:!0,writable:!0,value:new Map}),this.setOptions(e);for(const t of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))t.startsWith("on")&&typeof this[t]=="function"&&(this[t]=this[t].bind(this))}setOptions(e){this.options=e?Tr({},this.constructor.defaults,e):{};for(const[t,i]of Object.entries(this.option("on")||{}))this.on(t,i)}option(e,...t){let i=cy(e,this.options);return i&&typeof i=="function"&&(i=i.call(this,this,...t)),i}optionFor(e,t,i,...r){let a=cy(t,e);var u;typeof(u=a)!="string"||isNaN(u)||isNaN(parseFloat(u))||(a=parseFloat(a)),a==="true"&&(a=!0),a==="false"&&(a=!1),a&&typeof a=="function"&&(a=a.call(this,this,e,...r));let l=cy(t,this.options);return l&&typeof l=="function"?a=l.call(this,this,e,...r,a):a===void 0&&(a=l),a===void 0?i:a}cn(e){const t=this.options.classes;return t&&t[e]||""}localize(e,t=[]){e=String(e).replace(/\{\{(\w+).?(\w+)?\}\}/g,(i,r,a)=>{let u="";return a?u=this.option(`${r[0]+r.toLowerCase().substring(1)}.l10n.${a}`):r&&(u=this.option(`l10n.${r}`)),u||(u=i),u});for(let i=0;i<t.length;i++)e=e.split(t[i][0]).join(t[i][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(i,r)=>r)}on(e,t){let i=[];typeof e=="string"?i=e.split(" "):Array.isArray(e)&&(i=e),this.events||(this.events=new Map),i.forEach(r=>{let a=this.events.get(r);a||(this.events.set(r,[]),a=[]),a.includes(t)||a.push(t),this.events.set(r,a)})}off(e,t){let i=[];typeof e=="string"?i=e.split(" "):Array.isArray(e)&&(i=e),i.forEach(r=>{const a=this.events.get(r);if(Array.isArray(a)){const u=a.indexOf(t);u>-1&&a.splice(u,1)}})}emit(e,...t){[...this.events.get(e)||[]].forEach(i=>i(this,...t)),e!=="*"&&this.emit("*",e,...t)}}Object.defineProperty(Vp,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(Vp,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class uy extends Vp{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const t=new Map;for(const[i,r]of Object.entries(e)){const a=this.option(i),u=this.plugins[i];u||a===!1?u&&a===!1&&(u.detach(),delete this.plugins[i]):t.set(i,new r(this,a||{}))}for(const[i,r]of t)this.plugins[i]=r,r.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const t of e){const i=this.plugins[t];i&&i.detach(),delete this.plugins[t]}return this.emit("detachPlugins"),this}}var Pn;(function(n){n[n.Init=0]="Init",n[n.Error=1]="Error",n[n.Ready=2]="Ready",n[n.Panning=3]="Panning",n[n.Mousemove=4]="Mousemove",n[n.Destroy=5]="Destroy"})(Pn||(Pn={}));const Po=["a","b","c","d","e","f"],J1={PANUP:"Move up",PANDOWN:"Move down",PANLEFT:"Move left",PANRIGHT:"Move right",ZOOMIN:"Zoom in",ZOOMOUT:"Zoom out",TOGGLEZOOM:"Toggle zoom level",TOGGLE1TO1:"Toggle zoom level",ITERATEZOOM:"Toggle zoom level",ROTATECCW:"Rotate counterclockwise",ROTATECW:"Rotate clockwise",FLIPX:"Flip horizontally",FLIPY:"Flip vertically",FITX:"Fit horizontally",FITY:"Fit vertically",RESET:"Reset",TOGGLEFS:"Toggle fullscreen"},qB={content:null,width:"auto",height:"auto",panMode:"drag",touch:!0,dragMinThreshold:3,lockAxis:!1,mouseMoveFactor:1,mouseMoveFriction:.12,zoom:!0,pinchToZoom:!0,panOnlyZoomed:"auto",minScale:1,maxScale:2,friction:.25,dragFriction:.35,decelFriction:.05,click:"toggleZoom",dblClick:!1,wheel:"zoom",wheelLimit:7,spinner:!0,bounds:"auto",infinite:!1,rubberband:!0,bounce:!0,maxVelocity:75,transformParent:!1,classes:{content:"f-panzoom__content",isLoading:"is-loading",canZoomIn:"can-zoom_in",canZoomOut:"can-zoom_out",isDraggable:"is-draggable",isDragging:"is-dragging",inFullscreen:"in-fullscreen",htmlHasFullscreen:"with-panzoom-in-fullscreen"},l10n:J1},Q1='<circle cx="25" cy="25" r="20"></circle>',hy='<div class="f-spinner"><svg viewBox="0 0 50 50">'+Q1+Q1+"</svg></div>",Mr=n=>n&&n!==null&&n instanceof Element&&"nodeType"in n,En=(n,e)=>{n&&ay(e).forEach(t=>{n.classList.remove(t)})},Ct=(n,e)=>{n&&ay(e).forEach(t=>{n.classList.add(t)})},Fp={a:1,b:0,c:0,d:1,e:0,f:0},WB=1e5,$p=1e4,fs="mousemove",ev="drag",tv="content",ms="auto";let dy=null,py=null;class ua extends uy{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return py===null&&(py=window.matchMedia("(hover: none)").matches),py}get isMobile(){return dy===null&&(dy=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),dy}get panMode(){return this.options.panMode!==fs||this.isTouchDevice?ev:fs}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===ms?this.isTouchDevice:e}get isInfinite(){return this.option("infinite")}get angle(){return 180*Math.atan2(this.current.b,this.current.a)/Math.PI||0}get targetAngle(){return 180*Math.atan2(this.target.b,this.target.a)/Math.PI||0}get scale(){const{a:e,b:t}=this.current;return Math.sqrt(e*e+t*t)||1}get targetScale(){const{a:e,b:t}=this.target;return Math.sqrt(e*e+t*t)||1}get minScale(){return this.option("minScale")||1}get fullScale(){const{contentRect:e}=this;return e.fullWidth/e.fitWidth||1}get maxScale(){return this.fullScale*(this.option("maxScale")||1)||1}get coverScale(){const{containerRect:e,contentRect:t}=this,i=Math.max(e.height/t.fitHeight,e.width/t.fitWidth)||1;return Math.min(this.fullScale,i)}get isScaling(){return Math.abs(this.targetScale-this.scale)>1e-5&&!this.isResting}get isContentLoading(){const e=this.content;return!!(e&&e instanceof HTMLImageElement)&&!e.complete}get isResting(){if(this.isBouncingX||this.isBouncingY)return!1;for(const e of Po){const t=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>t)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,t={},i={}){var r;if(super(t),Object.defineProperty(this,"pointerTracker",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"resizeObserver",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"updateTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"rAF",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isTicking",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"ignoreBounds",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingX",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"isBouncingY",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"clicks",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"trackingPoints",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pwt",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"cwd",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"pmme",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"friction",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Pn.Init}),Object.defineProperty(this,"isDragging",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"content",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"spinner",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"containerRect",{enumerable:!0,configurable:!0,writable:!0,value:{width:0,height:0,innerWidth:0,innerHeight:0}}),Object.defineProperty(this,"contentRect",{enumerable:!0,configurable:!0,writable:!0,value:{top:0,right:0,bottom:0,left:0,fullWidth:0,fullHeight:0,fitWidth:0,fitHeight:0,width:0,height:0}}),Object.defineProperty(this,"dragStart",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,top:0,left:0,time:0}}),Object.defineProperty(this,"dragOffset",{enumerable:!0,configurable:!0,writable:!0,value:{x:0,y:0,time:0}}),Object.defineProperty(this,"current",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},Fp)}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:Object.assign({},Fp)}),Object.defineProperty(this,"velocity",{enumerable:!0,configurable:!0,writable:!0,value:{a:0,b:0,c:0,d:0,e:0,f:0}}),Object.defineProperty(this,"lockedAxis",{enumerable:!0,configurable:!0,writable:!0,value:!1}),!e)throw new Error("Container Element Not Found");this.container=e,this.initContent(),this.attachPlugins(Object.assign(Object.assign({},ua.Plugins),i)),this.emit("attachPlugins"),this.emit("init");const a=this.content;if(a.addEventListener("load",this.onLoad),a.addEventListener("error",this.onError),this.isContentLoading){if(this.option("spinner")){e.classList.add(this.cn("isLoading"));const u=Qs(hy);!e.contains(a)||a.parentElement instanceof HTMLPictureElement?this.spinner=e.appendChild(u):this.spinner=((r=a.parentElement)===null||r===void 0?void 0:r.insertBefore(u,a))||null}this.emit("beforeLoad")}else queueMicrotask(()=>{this.enable()})}initContent(){const{container:e}=this,t=this.cn(tv);let i=this.option(tv)||e.querySelector(`.${t}`);if(i||(i=e.querySelector("img,picture")||e.firstElementChild,i&&Ct(i,t)),i instanceof HTMLPictureElement&&(i=i.querySelector("img")),!i)throw new Error("No content found");this.content=i}onLoad(){const{spinner:e,container:t,state:i}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&t.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),i===Pn.Init?this.enable():this.updateMetrics()}onError(){this.state!==Pn.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=Pn.Error,this.emit("error"))}getNextScale(e){const{fullScale:t,targetScale:i,coverScale:r,maxScale:a,minScale:u}=this;let l=u;switch(e){case"toggleMax":l=i-u<.5*(a-u)?a:u;break;case"toggleCover":l=i-u<.5*(r-u)?r:u;break;case"toggleZoom":l=i-u<.5*(t-u)?t:u;break;case"iterateZoom":let g=[1,t,a].sort((k,E)=>k-E),b=g.findIndex(k=>k>i+1e-5);l=g[b]||1}return l}attachObserver(){var e;const t=()=>{const{container:i,containerRect:r}=this;return Math.abs(r.width-i.getBoundingClientRect().width)>.1||Math.abs(r.height-i.getBoundingClientRect().height)>.1};this.resizeObserver||window.ResizeObserver===void 0||(this.resizeObserver=new ResizeObserver(()=>{this.updateTimer||(t()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{t()&&this.onResize(),this.updateTimer=null},500))):this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null))})),(e=this.resizeObserver)===null||e===void 0||e.observe(this.container)}detachObserver(){var e;(e=this.resizeObserver)===null||e===void 0||e.disconnect()}attachEvents(){const{container:e}=this;e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("wheel",this.onWheel,{passive:!1}),this.pointerTracker=new HB(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(fs,this.onMouseMove)}detachEvents(){var e;const{container:t}=this;t.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),t.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(fs,this.onMouseMove),document.removeEventListener("keydown",this.onKeydown,!0),this.clickTimer&&(clearTimeout(this.clickTimer),this.clickTimer=null),this.updateTimer&&(clearTimeout(this.updateTimer),this.updateTimer=null)}animate(){this.setTargetForce();const e=this.friction,t=this.option("maxVelocity");for(const i of Po)e?(this.velocity[i]*=1-e,t&&!this.isScaling&&(this.velocity[i]=Math.max(Math.min(this.velocity[i],t),-1*t)),this.current[i]+=this.velocity[i]):this.current[i]=this.target[i];this.setTransform(),this.setEdgeForce(),!this.isResting||this.isDragging?this.rAF=requestAnimationFrame(()=>this.animate()):this.stop("current")}setTargetForce(){for(const e of Po)e==="e"&&this.isBouncingX||e==="f"&&this.isBouncingY||(this.velocity[e]=(1/(1-this.friction)-1)*(this.target[e]-this.current[e]))}checkBounds(e=0,t=0){const{current:i}=this,r=i.e+e,a=i.f+t,u=this.getBounds(),{x:l,y:g}=u,b=l.min,k=l.max,E=g.min,C=g.max;let I=0,D=0;return b!==1/0&&r<b?I=b-r:k!==1/0&&r>k&&(I=k-r),E!==1/0&&a<E?D=E-a:C!==1/0&&a>C&&(D=C-a),Math.abs(I)<1e-4&&(I=0),Math.abs(D)<1e-4&&(D=0),Object.assign(Object.assign({},u),{xDiff:I,yDiff:D,inBounds:!I&&!D})}clampTargetBounds(){const{target:e}=this,{x:t,y:i}=this.getBounds();t.min!==1/0&&(e.e=Math.max(e.e,t.min)),t.max!==1/0&&(e.e=Math.min(e.e,t.max)),i.min!==1/0&&(e.f=Math.max(e.f,i.min)),i.max!==1/0&&(e.f=Math.min(e.f,i.max))}calculateContentDim(e=this.current){const{content:t,contentRect:i}=this,{fitWidth:r,fitHeight:a,fullWidth:u,fullHeight:l}=i;let g=u,b=l;if(this.option("zoom")||this.angle!==0){const k=!(t instanceof HTMLImageElement)&&(window.getComputedStyle(t).maxWidth==="none"||window.getComputedStyle(t).maxHeight==="none"),E=k?u:r,C=k?l:a,I=this.getMatrix(e),D=new DOMPoint(0,0).matrixTransform(I),R=new DOMPoint(0+E,0).matrixTransform(I),$=new DOMPoint(0+E,0+C).matrixTransform(I),G=new DOMPoint(0,0+C).matrixTransform(I),te=Math.abs($.x-D.x),Z=Math.abs($.y-D.y),Q=Math.abs(G.x-R.x),Me=Math.abs(G.y-R.y);g=Math.max(te,Q),b=Math.max(Z,Me)}return{contentWidth:g,contentHeight:b}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===fs||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:t,y:i,xDiff:r,yDiff:a}=this.checkBounds(),u=this.option("maxVelocity");let l=this.velocity.e,g=this.velocity.f;r!==0?(this.isBouncingX=!0,r*l<=0?l+=.14*r:(l=.14*r,t.min!==1/0&&(this.target.e=Math.max(e.e,t.min)),t.max!==1/0&&(this.target.e=Math.min(e.e,t.max))),u&&(l=Math.max(Math.min(l,u),-1*u))):this.isBouncingX=!1,a!==0?(this.isBouncingY=!0,a*g<=0?g+=.14*a:(g=.14*a,i.min!==1/0&&(this.target.f=Math.max(e.f,i.min)),i.max!==1/0&&(this.target.f=Math.min(e.f,i.max))),u&&(g=Math.max(Math.min(g,u),-1*u))):this.isBouncingY=!1,this.isBouncingX&&(this.velocity.e=l),this.isBouncingY&&(this.velocity.f=g)}enable(){const{content:e}=this,t=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const i of Po)this.current[i]=this.target[i]=t[i];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=Pn.Ready,this.emit("ready")}onClick(e){var t;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((t=this.pointerTracker)===null||t===void 0||t.clear(),this.trackingPoints=[],this.startDecelAnim());const i=e.target;if(!i||e.defaultPrevented)return;if(i.hasAttribute("disabled"))return e.preventDefault(),void e.stopPropagation();if((()=>{const I=window.getSelection();return I&&I.type==="Range"})()&&!i.closest("button"))return;const r=i.closest("[data-panzoom-action]"),a=i.closest("[data-panzoom-change]"),u=r||a,l=u&&Mr(u)?u.dataset:null;if(l){const I=l.panzoomChange,D=l.panzoomAction;if((I||D)&&e.preventDefault(),I){let R={};try{R=JSON.parse(I)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(R)}if(D)return void(this[D]&&this[D]())}if(Math.abs(this.dragOffset.x)>3||Math.abs(this.dragOffset.y)>3)return e.preventDefault(),void e.stopPropagation();if(i.closest("[data-fancybox]"))return;const g=this.content.getBoundingClientRect(),b=this.dragStart;if(b.time&&!this.canZoomOut()&&(Math.abs(g.x-b.x)>2||Math.abs(g.y-b.y)>2))return;this.dragStart.time=0;const k=I=>{this.option("zoom",e)&&I&&typeof I=="string"&&/(iterateZoom)|(toggle(Zoom|Full|Cover|Max)|(zoomTo(Fit|Cover|Max)))/.test(I)&&typeof this[I]=="function"&&(e.preventDefault(),this[I]({event:e}))},E=this.option("click",e),C=this.option("dblClick",e);C?(this.clicks++,this.clicks==1&&(this.clickTimer=setTimeout(()=>{this.clicks===1?(this.emit("click",e),!e.defaultPrevented&&E&&k(E)):(this.emit("dblClick",e),e.defaultPrevented||k(C)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&E&&k(E))}addTrackingPoint(e){const t=this.trackingPoints.filter(i=>i.time>Date.now()-100);t.push(e),this.trackingPoints=t}onPointerDown(e,t,i){var r;if(this.option("touch",e)===!1)return!1;this.pwt=0,this.dragOffset={x:0,y:0,time:0},this.trackingPoints=[];const a=this.content.getBoundingClientRect();if(this.dragStart={x:a.x,y:a.y,top:a.top,left:a.left,time:Date.now()},this.clickTimer)return!1;if(this.panMode===fs&&this.targetScale>1)return e.preventDefault(),e.stopPropagation(),!1;const u=e.composedPath()[0];if(!i.length){if(["TEXTAREA","OPTION","INPUT","SELECT","VIDEO","IFRAME"].includes(u.nodeName)||u.closest("[contenteditable],[data-selectable],[data-draggable],[data-clickable],[data-panzoom-change],[data-panzoom-action]"))return!1;(r=window.getSelection())===null||r===void 0||r.removeAllRanges()}if(e.type==="mousedown")["A","BUTTON"].includes(u.nodeName)||e.preventDefault();else if(Math.abs(this.velocity.a)>.3)return!1;return this.target.e=this.current.e,this.target.f=this.current.f,this.stop(),this.isDragging||(this.isDragging=!0,this.addTrackingPoint(t),this.emit("touchStart",e)),!0}onPointerMove(e,t,i){if(this.option("touch",e)===!1||!this.isDragging||t.length<2&&this.panOnlyZoomed&&at(this.targetScale)<=at(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(t[0]);const{content:r}=this,a=K1(i[0],i[1]),u=K1(t[0],t[1]);let l=0,g=0;if(t.length>1){const Z=r.getBoundingClientRect();l=a.clientX-Z.left-.5*Z.width,g=a.clientY-Z.top-.5*Z.height}const b=X1(i[0],i[1]),k=X1(t[0],t[1]);let E=b?k/b:1,C=u.clientX-a.clientX,I=u.clientY-a.clientY;this.dragOffset.x+=C,this.dragOffset.y+=I,this.dragOffset.time=Date.now()-this.dragStart.time;let D=at(this.targetScale)===at(this.minScale)&&this.option("lockAxis");if(D&&!this.lockedAxis)if(D==="xy"||D==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const Z=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=Z>45&&Z<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,C=0,I=0}else this.lockedAxis=D;if(Lp(e.target,this.content)&&(D="x",this.dragOffset.y=0),D&&D!=="xy"&&this.lockedAxis!==D&&at(this.targetScale)===at(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const R=this.checkBounds(C,I);this.option("rubberband")?(this.isInfinite!=="x"&&(R.xDiff>0&&C<0||R.xDiff<0&&C>0)&&(C*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*R.xDiff))),this.isInfinite!=="y"&&(R.yDiff>0&&I<0||R.yDiff<0&&I>0)&&(I*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*R.yDiff)))):(R.xDiff&&(C=0),R.yDiff&&(I=0));const $=this.targetScale,G=this.minScale,te=this.maxScale;$<.5*G&&(E=Math.max(E,G)),$>1.5*te&&(E=Math.min(E,te)),this.lockedAxis==="y"&&at($)===at(G)&&(C=0),this.lockedAxis==="x"&&at($)===at(G)&&(I=0),this.applyChange({originX:l,originY:g,panX:C,panY:I,scale:E,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,t,i){if(i.length)return this.dragOffset.x=0,this.dragOffset.y=0,void(this.trackingPoints=[]);this.container.classList.remove(this.cn("isDragging")),this.isDragging&&(this.addTrackingPoint(t),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),Lp(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==Pn.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const t=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const Z of Po)this.velocity[Z]=0;this.target.e=this.current.e,this.target.f=this.current.f,En(this.container,"is-scaling"),En(this.container,"is-animating"),this.isTicking=!1;const{trackingPoints:i}=this,r=i[0],a=i[i.length-1];let u=0,l=0,g=0;a&&r&&(u=a.clientX-r.clientX,l=a.clientY-r.clientY,g=a.time-r.time);const b=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;b!==1&&(u*=b,l*=b);let k=0,E=0,C=0,I=0,D=this.option("decelFriction");const R=this.targetScale;if(g>0){C=Math.abs(u)>3?u/(g/30):0,I=Math.abs(l)>3?l/(g/30):0;const Z=this.option("maxVelocity");Z&&(C=Math.max(Math.min(C,Z),-1*Z),I=Math.max(Math.min(I,Z),-1*Z))}C&&(k=C/(1/(1-D)-1)),I&&(E=I/(1/(1-D)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&at(R)===this.minScale)&&(k=C=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&at(R)===this.minScale)&&(E=I=0);const $=this.dragOffset.x,G=this.dragOffset.y,te=this.option("dragMinThreshold")||0;Math.abs($)<te&&Math.abs(G)<te&&(k=E=0,C=I=0),(this.option("zoom")&&(R<this.minScale-1e-5||R>this.maxScale+1e-5)||t&&!k&&!E)&&(D=.35),this.applyChange({panX:k,panY:E,friction:D}),this.emit("decel",C,I,$,G)}onWheel(e){var t=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(a,u){return Math.abs(u)>Math.abs(a)?u:a});const i=Math.max(-1,Math.min(1,t));if(this.emit("wheel",e,i),this.panMode===fs||e.defaultPrevented)return;const r=this.option("wheel");r==="pan"?(e.preventDefault(),this.panOnlyZoomed&&!this.canZoomOut()||this.applyChange({panX:2*-e.deltaX,panY:2*-e.deltaY,bounce:!1})):r==="zoom"&&this.option("zoom")!==!1&&this.zoomWithWheel(e)}onMouseMove(e){this.panWithMouse(e)}onKeydown(e){e.key==="Escape"&&this.toggleFS()}onResize(){this.updateMetrics(),this.checkBounds().inBounds||this.requestTick()}setTransform(){this.emit("beforeTransform");const{current:e,target:t,content:i,contentRect:r}=this,a=Object.assign({},Fp);for(const $ of Po){const G=$=="e"||$==="f"?$p:WB;a[$]=at(e[$],G),Math.abs(t[$]-e[$])<($=="e"||$==="f"?.51:.001)&&(e[$]=t[$])}let{a:u,b:l,c:g,d:b,e:k,f:E}=a,C=`matrix(${u}, ${l}, ${g}, ${b}, ${k}, ${E})`,I=i.parentElement instanceof HTMLPictureElement?i.parentElement:i;if(this.option("transformParent")&&(I=I.parentElement||I),I.style.transform===C)return;I.style.transform=C;const{contentWidth:D,contentHeight:R}=this.calculateContentDim();r.width=D,r.height=R,this.emit("afterTransform")}updateMetrics(e=!1){var t;if(!this||this.state===Pn.Destroy||this.isContentLoading)return;const i=Math.max(1,((t=window.visualViewport)===null||t===void 0?void 0:t.scale)||1),{container:r,content:a}=this,u=a instanceof HTMLImageElement,l=r.getBoundingClientRect(),g=getComputedStyle(this.container);let b=l.width*i,k=l.height*i;const E=parseFloat(g.paddingTop)+parseFloat(g.paddingBottom),C=b-(parseFloat(g.paddingLeft)+parseFloat(g.paddingRight)),I=k-E;this.containerRect={width:b,height:k,innerWidth:C,innerHeight:I};const D=parseFloat(a.dataset.width||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalWidth:rt instanceof SVGElement?rt.width.baseVal.value:Math.max(rt.offsetWidth,rt.scrollWidth),Tt||0})(a),R=parseFloat(a.dataset.height||"")||(rt=>{let Tt=0;return Tt=rt instanceof HTMLImageElement?rt.naturalHeight:rt instanceof SVGElement?rt.height.baseVal.value:Math.max(rt.offsetHeight,rt.scrollHeight),Tt||0})(a);let $=this.option("width",D)||ms,G=this.option("height",R)||ms;const te=$===ms,Z=G===ms;typeof $!="number"&&($=D),typeof G!="number"&&(G=R),te&&($=D*(G/R)),Z&&(G=R/(D/$));let Q=a.parentElement instanceof HTMLPictureElement?a.parentElement:a;this.option("transformParent")&&(Q=Q.parentElement||Q);const Me=Q.getAttribute("style")||"";Q.style.setProperty("transform","none","important"),u&&(Q.style.width="",Q.style.height=""),Q.offsetHeight;const ke=a.getBoundingClientRect();let Ae=ke.width*i,Fe=ke.height*i,Ne=Ae,dt=Fe;Ae=Math.min(Ae,$),Fe=Math.min(Fe,G),u?{width:Ae,height:Fe}=((rt,Tt,zt,Vt)=>{const Ft=zt/rt,Ht=Vt/Tt,Cn=Math.min(Ft,Ht);return{width:rt*=Cn,height:Tt*=Cn}})($,G,Ae,Fe):(Ae=Math.min(Ae,$),Fe=Math.min(Fe,G));let tt=.5*(dt-Fe),Nt=.5*(Ne-Ae);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ke.top-l.top+tt,bottom:l.bottom-ke.bottom+tt,left:ke.left-l.left+Nt,right:l.right-ke.right+Nt,fitWidth:Ae,fitHeight:Fe,width:Ae,height:Fe,fullWidth:$,fullHeight:G}),Q.style.cssText=Me,u&&(Q.style.width=`${Ae}px`,Q.style.height=`${Fe}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(at(this.targetScale)<at(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===Pn.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:t}=this.calculateContentDim(this.target),{targetScale:i,lockedAxis:r}=this,{fitWidth:a,fitHeight:u}=this.contentRect;let l=0,g=0,b=0,k=0;const E=this.option("infinite");if(E===!0||r&&E===r)l=-1/0,b=1/0,g=-1/0,k=1/0;else{let{containerRect:C,contentRect:I}=this,D=at(a*i,$p),R=at(u*i,$p),{innerWidth:$,innerHeight:G}=C;if(C.width===D&&($=C.width),C.width===R&&(G=C.height),e>$){b=.5*(e-$),l=-1*b;let te=.5*(I.right-I.left);l+=te,b+=te}if(a>$&&e<$&&(l-=.5*(a-$),b-=.5*(a-$)),t>G){k=.5*(t-G),g=-1*k;let te=.5*(I.bottom-I.top);g+=te,k+=te}u>G&&t<G&&(l-=.5*(u-G),b-=.5*(u-G))}return{x:{min:l,max:b},y:{min:g,max:k}}}getBounds(){const e=this.option("bounds");return e!==ms?e:this.calculateBounds()}updateControls(){const e=this,t=e.container,{panMode:i,contentRect:r,targetScale:a,minScale:u}=e;let l=u,g=e.option("click")||!1;g&&(l=e.getNextScale(g));let b=e.canZoomIn(),k=e.canZoomOut(),E=i===ev&&!!this.option("touch"),C=k&&E;if(E&&(at(a)<at(u)&&!this.panOnlyZoomed&&(C=!0),(at(r.width,1)>at(r.fitWidth,1)||at(r.height,1)>at(r.fitHeight,1))&&(C=!0)),at(r.width*a,1)<at(r.fitWidth,1)&&(C=!1),i===fs&&(C=!1),eo(t,this.cn("isDraggable"),C),!this.option("zoom"))return;let I=b&&at(l)>at(a),D=!I&&!C&&k&&at(l)<at(a);eo(t,this.cn("canZoomIn"),I),eo(t,this.cn("canZoomOut"),D);for(const R of t.querySelectorAll("[data-panzoom-action]")){let $=!1,G=!1;switch(R.dataset.panzoomAction){case"zoomIn":b?$=!0:G=!0;break;case"zoomOut":k?$=!0:G=!0;break;case"toggleZoom":case"iterateZoom":b||k?$=!0:G=!0;const te=R.querySelector("g");te&&(te.style.display=b?"":"none")}$?(R.removeAttribute("disabled"),R.removeAttribute("tabindex")):G&&(R.setAttribute("disabled",""),R.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:t=this.target.f,scale:i=this.targetScale,friction:r=this.option("friction"),angle:a=0,originX:u=0,originY:l=0,flipX:g=!1,flipY:b=!1,ignoreBounds:k=!1}){this.state!==Pn.Destroy&&this.applyChange({panX:e-this.target.e,panY:t-this.target.f,scale:i/this.targetScale,angle:a,originX:u,originY:l,friction:r,flipX:g,flipY:b,ignoreBounds:k})}applyChange({panX:e=0,panY:t=0,scale:i=1,angle:r=0,originX:a=-this.current.e,originY:u=-this.current.f,friction:l=this.option("friction"),flipX:g=!1,flipY:b=!1,ignoreBounds:k=!1,bounce:E=this.option("bounce")}){const C=this.state;if(C===Pn.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=l||0,this.ignoreBounds=k;const{current:I}=this,D=I.e,R=I.f,$=this.getMatrix(this.target);let G=new DOMMatrix().translate(D,R).translate(a,u).translate(e,t);if(this.option("zoom")){if(!k){const te=this.targetScale,Z=this.minScale,Q=this.maxScale;te*i<Z&&(i=Z/te),te*i>Q&&(i=Q/te)}G=G.scale(i)}G=G.translate(-a,-u).translate(-D,-R).multiply($),r&&(G=G.rotate(r)),g&&(G=G.scale(-1,1)),b&&(G=G.scale(1,-1));for(const te of Po)te!=="e"&&te!=="f"&&(G[te]>this.minScale+1e-5||G[te]<this.minScale-1e-5)?this.target[te]=G[te]:this.target[te]=at(G[te],$p);(this.targetScale<this.scale||Math.abs(i-1)>.1||this.panMode===fs||E===!1)&&!k&&this.clampTargetBounds(),C===Pn.Init?this.animate():this.isResting||(this.state=Pn.Panning,this.requestTick())}stop(e=!1){if(this.state===Pn.Init||this.state===Pn.Destroy)return;const t=this.isTicking;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const i of Po)this.velocity[i]=0,e==="current"?this.current[i]=this.target[i]:e==="target"&&(this.target[i]=this.current[i]);this.setTransform(),En(this.container,"is-scaling"),En(this.container,"is-animating"),this.isTicking=!1,this.state=Pn.Ready,t&&(this.emit("endAnimation"),this.updateControls())}requestTick(){this.isTicking||(this.emit("startAnimation"),this.updateControls(),Ct(this.container,"is-animating"),this.isScaling&&Ct(this.container,"is-scaling")),this.isTicking=!0,this.rAF||(this.rAF=requestAnimationFrame(()=>this.animate()))}panWithMouse(e,t=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==fs||!e||at(this.targetScale)<=at(this.minScale))return;this.emit("mouseMove",e);const{container:i,containerRect:r,contentRect:a}=this,u=r.width,l=r.height,g=i.getBoundingClientRect(),b=(e.clientX||0)-g.left,k=(e.clientY||0)-g.top;let{contentWidth:E,contentHeight:C}=this.calculateContentDim(this.target);const I=this.option("mouseMoveFactor");I>1&&(E!==u&&(E*=I),C!==l&&(C*=I));let D=.5*(E-u)-b/u*100/100*(E-u);D+=.5*(a.right-a.left);let R=.5*(C-l)-k/l*100/100*(C-l);R+=.5*(a.bottom-a.top),this.applyChange({panX:D-this.target.e,panY:R-this.target.f,friction:t})}zoomWithWheel(e){if(this.state===Pn.Destroy||this.state===Pn.Init)return;const t=Date.now();if(t-this.pwt<45)return void e.preventDefault();this.pwt=t;var i=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(b,k){return Math.abs(k)>Math.abs(b)?k:b});const r=Math.max(-1,Math.min(1,i)),{targetScale:a,maxScale:u,minScale:l}=this;let g=a*(100+45*r)/100;at(g)<at(l)&&at(a)<=at(l)?(this.cwd+=Math.abs(r),g=l):at(g)>at(u)&&at(a)>=at(u)?(this.cwd+=Math.abs(r),g=u):(this.cwd=0,g=Math.max(Math.min(g,u),l)),this.cwd>this.option("wheelLimit")||(e.preventDefault(),at(g)!==at(a)&&this.zoomTo(g,{event:e}))}canZoomIn(){return this.option("zoom")&&(at(this.contentRect.width,1)<at(this.contentRect.fitWidth,1)||at(this.targetScale)<at(this.maxScale))}canZoomOut(){return this.option("zoom")&&at(this.targetScale)>at(this.minScale)}zoomIn(e=1.25,t){this.zoomTo(this.targetScale*e,t)}zoomOut(e=.8,t){this.zoomTo(this.targetScale*e,t)}zoomToFit(e){this.zoomTo("fit",e)}zoomToCover(e){this.zoomTo("cover",e)}zoomToFull(e){this.zoomTo("full",e)}zoomToMax(e){this.zoomTo("max",e)}toggleZoom(e){this.zoomTo(this.getNextScale("toggleZoom"),e)}toggleMax(e){this.zoomTo(this.getNextScale("toggleMax"),e)}toggleCover(e){this.zoomTo(this.getNextScale("toggleCover"),e)}iterateZoom(e){this.zoomTo("next",e)}zoomTo(e=1,{friction:t=ms,originX:i=ms,originY:r=ms,event:a}={}){if(this.isContentLoading||this.state===Pn.Destroy)return;const{targetScale:u,fullScale:l,maxScale:g,coverScale:b}=this;if(this.stop(),this.panMode===fs&&(a=this.pmme||a),a||i===ms||r===ms){const E=this.content.getBoundingClientRect(),C=this.container.getBoundingClientRect(),I=a?a.clientX:C.left+.5*C.width,D=a?a.clientY:C.top+.5*C.height;i=I-E.left-.5*E.width,r=D-E.top-.5*E.height}let k=1;typeof e=="number"?k=e:e==="full"?k=l:e==="cover"?k=b:e==="max"?k=g:e==="fit"?k=1:e==="next"&&(k=this.getNextScale("iterateZoom")),k=k/u||1,t=t===ms?k>1?.15:.25:t,this.applyChange({scale:k,originX:i,originY:r,friction:t}),a&&this.panMode===fs&&this.panWithMouse(a,t)}rotateCCW(){this.applyChange({angle:-90})}rotateCW(){this.applyChange({angle:90})}flipX(){this.applyChange({flipX:!0})}flipY(){this.applyChange({flipY:!0})}fitX(){this.stop("target");const{containerRect:e,contentRect:t,target:i}=this;this.applyChange({panX:.5*e.width-(t.left+.5*t.fitWidth)-i.e,panY:.5*e.height-(t.top+.5*t.fitHeight)-i.f,scale:e.width/t.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:t,target:i}=this;this.applyChange({panX:.5*e.width-(t.left+.5*t.fitWidth)-i.e,panY:.5*e.innerHeight-(t.top+.5*t.fitHeight)-i.f,scale:e.height/t.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,t=this.cn("inFullscreen"),i=this.cn("htmlHasFullscreen");e.classList.toggle(t);const r=e.classList.contains(t);r?(document.documentElement.classList.add(i),document.addEventListener("keydown",this.onKeydown,!0)):(document.documentElement.classList.remove(i),document.removeEventListener("keydown",this.onKeydown,!0)),this.updateMetrics(),this.emit(r?"enterFS":"exitFS")}getMatrix(e=this.current){const{a:t,b:i,c:r,d:a,e:u,f:l}=e;return new DOMMatrix([t,i,r,a,u,l])}reset(e){if(this.state!==Pn.Init&&this.state!==Pn.Destroy){this.stop("current");for(const t of Po)this.target[t]=Fp[t];this.target.a=this.minScale,this.target.d=this.minScale,this.clampTargetBounds(),this.isResting||(this.friction=e===void 0?this.option("friction"):e,this.state=Pn.Panning,this.requestTick())}}destroy(){this.stop(),this.state=Pn.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:t}=this,i=this.option("classes")||{};for(const r of Object.values(i))e.classList.remove(r+"");t&&(t.removeEventListener("load",this.onLoad),t.removeEventListener("error",this.onError)),this.detachPlugins()}}Object.defineProperty(ua,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:qB}),Object.defineProperty(ua,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const nv=function(n,e){let t=!0;return(...i)=>{t&&(t=!1,n(...i),setTimeout(()=>{t=!0},e))}},iv=(n,e)=>{let t=[];return n.childNodes.forEach(i=>{i.nodeType!==Node.ELEMENT_NODE||e&&!i.matches(e)||t.push(i)}),t},GB={viewport:null,track:null,enabled:!0,slides:[],axis:"x",transition:"fade",preload:1,slidesPerPage:"auto",initialPage:0,friction:.12,Panzoom:{decelFriction:.12},center:!0,infinite:!0,fill:!0,dragFree:!1,adaptiveHeight:!1,direction:"ltr",classes:{container:"f-carousel",viewport:"f-carousel__viewport",track:"f-carousel__track",slide:"f-carousel__slide",isLTR:"is-ltr",isRTL:"is-rtl",isHorizontal:"is-horizontal",isVertical:"is-vertical",inTransition:"in-transition",isSelected:"is-selected"},l10n:{NEXT:"Next slide",PREV:"Previous slide",GOTO:"Go to slide #%d"}};var di;(function(n){n[n.Init=0]="Init",n[n.Ready=1]="Ready",n[n.Destroy=2]="Destroy"})(di||(di={}));const fy=n=>{if(typeof n=="string"||n instanceof HTMLElement)n={html:n};else{const e=n.thumb;e!==void 0&&(typeof e=="string"&&(n.thumbSrc=e),e instanceof HTMLImageElement&&(n.thumbEl=e,n.thumbElSrc=e.src,n.thumbSrc=e.src),delete n.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},n)},ZB=(n={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},n);class Vs extends Vp{constructor(e,t){super(t),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}}const YB={classes:{list:"f-carousel__dots",isDynamic:"is-dynamic",hasDots:"has-dots",dot:"f-carousel__dot",isBeforePrev:"is-before-prev",isPrev:"is-prev",isCurrent:"is-current",isNext:"is-next",isAfterNext:"is-after-next"},dotTpl:'<button type="button" data-carousel-page="%i" aria-label="{{GOTO}}"><span class="f-carousel__dot" aria-hidden="true"></span></button>',dynamicFrom:11,maxCount:1/0,minCount:2};class rv extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"isDynamic",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"list",{enumerable:!0,configurable:!0,writable:!0,value:null})}onRefresh(){this.refresh()}build(){let e=this.list;if(!e){e=document.createElement("ul"),Ct(e,this.cn("list")),e.setAttribute("role","tablist");const t=this.instance.container;t.appendChild(e),Ct(t,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const t=this.instance.pages.length,i=Math.min(2,this.option("minCount")),r=Math.max(2e3,this.option("maxCount")),a=this.option("dynamicFrom");if(t<i||t>r)return void this.cleanup();const u=typeof a=="number"&&t>5&&t>=a,l=!this.list||this.isDynamic!==u||this.list.children.length!==t;l&&this.cleanup();const g=this.build();if(eo(g,this.cn("isDynamic"),!!u),l)for(let E=0;E<t;E++)g.append(this.createItem(E));let b,k=0;for(const E of[...g.children]){const C=k===this.instance.page;C&&(b=E),eo(E,this.cn("isCurrent"),C),(e=E.children[0])===null||e===void 0||e.setAttribute("aria-selected",C?"true":"false");for(const I of["isBeforePrev","isPrev","isNext","isAfterNext"])En(E,this.cn(I));k++}if(b=b||g.firstChild,u&&b){const E=b.previousElementSibling,C=E&&E.previousElementSibling;Ct(E,this.cn("isPrev")),Ct(C,this.cn("isBeforePrev"));const I=b.nextElementSibling,D=I&&I.nextElementSibling;Ct(I,this.cn("isNext")),Ct(D,this.cn("isAfterNext"))}this.isDynamic=u}createItem(e=0){var t;const i=document.createElement("li");i.setAttribute("role","presentation");const r=Qs(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return i.appendChild(r),(t=i.children[0])===null||t===void 0||t.setAttribute("role","tab"),i}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,En(this.instance.container,this.cn("hasDots"))}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}}Object.defineProperty(rv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:YB});const jp="disabled",Up="next",sv="prev";class ov extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"prev",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"next",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"isDom",{enumerable:!0,configurable:!0,writable:!0,value:!1})}onRefresh(){const e=this.instance,t=e.pages.length,i=e.page;if(t<2)return void this.cleanup();this.build();let r=this.prev,a=this.next;r&&a&&(r.removeAttribute(jp),a.removeAttribute(jp),e.isInfinite||(i<=0&&r.setAttribute(jp,""),i>=t-1&&a.setAttribute(jp,"")))}addBtn(e){var t;const i=this.instance,r=document.createElement("button");r.setAttribute("tabindex","0"),r.setAttribute("title",i.localize(`{{${e.toUpperCase()}}}`)),Ct(r,this.cn("button")+" "+this.cn(e===Up?"isNext":"isPrev"));const a=i.isRTL?e===Up?sv:Up:e;var u;return r.innerHTML=i.localize(this.option(`${a}Tpl`)),r.dataset[`carousel${u=e,u?u.match("^[a-z]")?u.charAt(0).toUpperCase()+u.substring(1):u:""}`]="true",(t=this.container)===null||t===void 0||t.appendChild(r),r}build(){const e=this.instance.container,t=this.cn("container");let{container:i,prev:r,next:a}=this;i||(i=e.querySelector("."+t),this.isDom=!!i),i||(i=document.createElement("div"),Ct(i,t),e.appendChild(i)),this.container=i,a||(a=i.querySelector("[data-carousel-next]")),a||(a=this.addBtn(Up)),this.next=a,r||(r=i.querySelector("[data-carousel-prev]")),r||(r=this.addBtn(sv)),this.prev=r}cleanup(){this.isDom||(this.prev&&this.prev.remove(),this.next&&this.next.remove(),this.container&&this.container.remove()),this.prev=null,this.next=null,this.container=null,this.isDom=!1}attach(){this.instance.on(["refresh","change"],this.onRefresh)}detach(){this.instance.off(["refresh","change"],this.onRefresh),this.cleanup()}}Object.defineProperty(ov,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{classes:{container:"f-carousel__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"},nextTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M9 3l9 9-9 9"/></svg>',prevTpl:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M15 3l-9 9 9 9"/></svg>'}});class av extends Vs{constructor(){super(...arguments),Object.defineProperty(this,"selectedIndex",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"target",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"nav",{enumerable:!0,configurable:!0,writable:!0,value:null})}addAsTargetFor(e){this.target=this.instance,this.nav=e,this.attachEvents()}addAsNavFor(e){this.nav=this.instance,this.target=e,this.attachEvents()}attachEvents(){const{nav:e,target:t}=this;e&&t&&(e.options.initialSlide=t.options.initialPage,e.state===di.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),t.state===di.Ready?this.onTargetReady(t):t.on("ready",this.onTargetReady))}onNavReady(e){e.on("createSlide",this.onNavCreateSlide),e.on("Panzoom.click",this.onNavClick),e.on("Panzoom.touchEnd",this.onNavTouch),this.onTargetChange()}onTargetReady(e){e.on("change",this.onTargetChange),e.on("Panzoom.refresh",this.onTargetChange),this.onTargetChange()}onNavClick(e,t,i){this.onNavTouch(e,e.panzoom,i)}onNavTouch(e,t,i){var r,a;if(Math.abs(t.dragOffset.x)>3||Math.abs(t.dragOffset.y)>3)return;const u=i.target,{nav:l,target:g}=this;if(!l||!g||!u)return;const b=u.closest("[data-index]");if(i.stopPropagation(),i.preventDefault(),!b)return;const k=parseInt(b.dataset.index||"",10)||0,E=g.getPageForSlide(k),C=l.getPageForSlide(k);l.slideTo(C),g.slideTo(E,{friction:((a=(r=this.nav)===null||r===void 0?void 0:r.plugins)===null||a===void 0?void 0:a.Sync.option("friction"))||0}),this.markSelectedSlide(k)}onNavCreateSlide(e,t){t.index===this.selectedIndex&&this.markSelectedSlide(t.index)}onTargetChange(){var e,t;const{target:i,nav:r}=this;if(!i||!r||r.state!==di.Ready||i.state!==di.Ready)return;const a=(t=(e=i.pages[i.page])===null||e===void 0?void 0:e.slides[0])===null||t===void 0?void 0:t.index,u=r.getPageForSlide(a);this.markSelectedSlide(a),r.slideTo(u,r.prevPage===null&&i.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const t=this.nav;t&&t.state===di.Ready&&(this.selectedIndex=e,[...t.slides].map(i=>{i.el&&i.el.classList[i.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let t=e.options.target,i=e.options.nav;t?e.addAsNavFor(t):i&&e.addAsTargetFor(i)}detach(){const e=this,t=e.nav,i=e.target;t&&(t.off("ready",e.onNavReady),t.off("createSlide",e.onNavCreateSlide),t.off("Panzoom.click",e.onNavClick),t.off("Panzoom.touchEnd",e.onNavTouch)),e.nav=null,i&&(i.off("ready",e.onTargetReady),i.off("refresh",e.onTargetChange),i.off("change",e.onTargetChange)),e.target=null}}Object.defineProperty(av,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const XB={Navigation:ov,Dots:rv,Sync:av},Hp="animationend",lv="isSelected",qp="slide";class ha extends uy{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===di.Ready}get isInfinite(){let e=!1;const{contentDim:t,viewportDim:i,pages:r,slides:a}=this,u=a[0];return r.length>=2&&u&&t+u.dim>=i&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,t={},i={}){if(super(),Object.defineProperty(this,"bp",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"lp",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"userOptions",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:di.Init}),Object.defineProperty(this,"page",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"prevPage",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"viewport",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"slides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pages",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"panzoom",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"inTransition",{enumerable:!0,configurable:!0,writable:!0,value:new Set}),Object.defineProperty(this,"contentDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"viewportDim",{enumerable:!0,configurable:!0,writable:!0,value:0}),typeof e=="string"&&(e=document.querySelector(e)),!e||!Mr(e))throw new Error("No Element found");this.container=e,this.slideNext=nv(this.slideNext.bind(this),150),this.slidePrev=nv(this.slidePrev.bind(this),150),this.userOptions=t,this.userPlugins=i,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,t;const i=Tr({},ha.defaults,this.userOptions);let r="";const a=i.breakpoints;if(a&&ly(a))for(const[u,l]of Object.entries(a))window.matchMedia(u).matches&&ly(l)&&(r+=u,Tr(i,l));r===this.bp&&this.state!==di.Init||(this.bp=r,this.state===di.Ready&&(i.initialSlide=((t=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||t===void 0?void 0:t.index)||0),this.state!==di.Init&&this.destroy(),super.setOptions(i),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=di.Init,this.emit("init"),this.attachPlugins(Object.assign(Object.assign({},ha.Plugins),this.userPlugins)),this.emit("attachPlugins"),this.initLayout(),this.initSlides(),this.updateMetrics(),this.setInitialPosition(),this.initPanzoom(),this.attachEvents(),this.state=di.Ready,this.emit("ready")}initLayout(){const{container:e}=this,t=this.option("classes");Ct(e,this.cn("container")),eo(e,t.isLTR,!this.isRTL),eo(e,t.isRTL,this.isRTL),eo(e,t.isVertical,!this.isHorizontal),eo(e,t.isHorizontal,this.isHorizontal);let i=this.option("viewport")||e.querySelector(`.${t.viewport}`);i||(i=document.createElement("div"),Ct(i,t.viewport),i.append(...iv(e,`.${t.slide}`)),e.prepend(i)),i.addEventListener("scroll",this.onScroll);let r=this.option("track")||e.querySelector(`.${t.track}`);r||(r=document.createElement("div"),Ct(r,t.track),r.append(...Array.from(i.childNodes))),r.setAttribute("aria-live","polite"),i.contains(r)||i.prepend(r),this.viewport=i,this.track=r,this.emit("initLayout")}initSlides(){const{track:e}=this;if(!e)return;const t=[...this.slides],i=[];[...iv(e,`.${this.cn(qp)}`)].forEach(r=>{if(Mr(r)){const a=fy({el:r,isDom:!0,index:this.slides.length});i.push(a)}});for(let r of[...this.option("slides",[])||[],...t])i.push(fy(r));this.slides=i;for(let r=0;r<this.slides.length;r++)this.slides[r].index=r;for(const r of i)this.emit("beforeInitSlide",r,r.index),this.emit("initSlide",r,r.index);this.emit("initSlides")}setInitialPage(){const e=this.option("initialSlide");this.page=typeof e=="number"?this.getPageForSlide(e):parseInt(this.option("initialPage",0)+"",10)||0}setInitialPosition(){const{track:e,pages:t,isHorizontal:i}=this;if(!e||!t.length)return;let r=this.page;t[r]||(this.page=r=0);const a=(t[r].pos||0)*(this.isRTL&&i?1:-1),u=i?`${a}px`:"0",l=i?"0":`${a}px`;e.style.transform=`translate3d(${u}, ${l}, 0) scale(1)`,this.option("adaptiveHeight")&&this.setViewportHeight()}initPanzoom(){this.panzoom&&(this.panzoom.destroy(),this.panzoom=null);const e=this.option("Panzoom")||{};this.panzoom=new ua(this.viewport,Tr({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:t=>!(this.pages.length<2&&!t.options.infinite),bounds:()=>this.getBounds(),maxVelocity:t=>Math.abs(t.target[this.axis]-t.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(t,i,...r)=>{this.emit(`Panzoom.${i}`,t,...r)}),this.panzoom.on("decel",this.onDecel),this.panzoom.on("refresh",this.onRefresh),this.panzoom.on("beforeTransform",this.onBeforeTransform),this.panzoom.on("endAnimation",this.onEndAnimation)}attachEvents(){const e=this.container;e&&(e.addEventListener("click",this.onClick,{passive:!1,capture:!1}),e.addEventListener("slideTo",this.onSlideTo)),window.addEventListener("resize",this.onResize)}createPages(){let e=[];const{contentDim:t,viewportDim:i}=this;let r=this.option("slidesPerPage");r=(r==="auto"||t<=i)&&this.option("fill")!==!1?1/0:parseFloat(r+"");let a=0,u=0,l=0;for(const g of this.slides)(!e.length||u+g.dim-i>.05||l>=r)&&(e.push(ZB()),a=e.length-1,u=0,l=0),e[a].slides.push(g),u+=g.dim+g.gap,l++;return e}processPages(){const e=this.pages,{contentDim:t,viewportDim:i,isInfinite:r}=this,a=this.option("center"),u=this.option("fill"),l=u&&a&&t>i&&!r;if(e.forEach((k,E)=>{var C;k.index=E,k.pos=((C=k.slides[0])===null||C===void 0?void 0:C.pos)||0,k.dim=0;for(const[I,D]of k.slides.entries())k.dim+=D.dim,I<k.slides.length-1&&(k.dim+=D.gap);l&&k.pos+.5*k.dim<.5*i?k.pos=0:l&&k.pos+.5*k.dim>=t-.5*i?k.pos=t-i:a&&(k.pos+=-.5*(i-k.dim))}),e.forEach(k=>{u&&!r&&t>i&&(k.pos=Math.max(k.pos,0),k.pos=Math.min(k.pos,t-i)),k.pos=at(k.pos,1e3),k.dim=at(k.dim,1e3),Math.abs(k.pos)<=.1&&(k.pos=0)}),r)return e;const g=[];let b;return e.forEach(k=>{const E=Object.assign({},k);b&&E.pos===b.pos?(b.dim+=E.dim,b.slides=[...b.slides,...E.slides]):(E.index=g.length,b=E,g.push(E))}),g}getPageFromIndex(e=0){const t=this.pages.length;let i;return e=parseInt((e||0).toString())||0,i=this.isInfinite?(e%t+t)%t:Math.max(Math.min(e,t-1),0),i}getSlideMetrics(e){var t,i;const r=this.isHorizontal?"width":"height";let a=0,u=0,l=e.el;const g=!(!l||l.parentNode);if(l?a=parseFloat(l.dataset[r]||"")||0:(l=document.createElement("div"),l.style.visibility="hidden",(this.track||document.body).prepend(l)),Ct(l,this.cn(qp)+" "+e.class+" "+e.customClass),a)l.style[r]=`${a}px`,l.style[r==="width"?"height":"width"]="";else{g&&(this.track||document.body).prepend(l),a=l.getBoundingClientRect()[r]*Math.max(1,((t=window.visualViewport)===null||t===void 0?void 0:t.scale)||1);let k=l[this.isHorizontal?"offsetWidth":"offsetHeight"];k-1>a&&(a=k)}const b=getComputedStyle(l);return b.boxSizing==="content-box"&&(this.isHorizontal?(a+=parseFloat(b.paddingLeft)||0,a+=parseFloat(b.paddingRight)||0):(a+=parseFloat(b.paddingTop)||0,a+=parseFloat(b.paddingBottom)||0)),u=parseFloat(b[this.isHorizontal?"marginRight":"marginBottom"])||0,g?(i=l.parentElement)===null||i===void 0||i.removeChild(l):e.el||l.remove(),{dim:at(a,1e3),gap:at(u,1e3)}}getBounds(){const{isInfinite:e,isRTL:t,isHorizontal:i,pages:r}=this;let a={min:0,max:0};if(e)a={min:-1/0,max:1/0};else if(r.length){const u=r[0].pos,l=r[r.length-1].pos;a=t&&i?{min:u,max:l}:{min:-1*l,max:-1*u}}return{x:i?a:{min:0,max:0},y:i?{min:0,max:0}:a}}repositionSlides(){let e,{isHorizontal:t,isRTL:i,isInfinite:r,viewport:a,viewportDim:u,contentDim:l,page:g,pages:b,slides:k,panzoom:E}=this,C=0,I=0,D=0,R=0;E?R=-1*E.current[this.axis]:b[g]&&(R=b[g].pos||0),e=t?i?"right":"left":"top",i&&t&&(R*=-1);for(const Z of k){const Q=Z.el;Q?(e==="top"?(Q.style.right="",Q.style.left=""):Q.style.top="",Z.index!==C?Q.style[e]=I===0?"":`${at(I,1e3)}px`:Q.style[e]="",D+=Z.dim+Z.gap,C++):I+=Z.dim+Z.gap}if(r&&D&&a){let Z=getComputedStyle(a),Q="padding",Me=t?"Right":"Bottom",ke=parseFloat(Z[Q+(t?"Left":"Top")]);R-=ke,u+=ke,u+=parseFloat(Z[Q+Me]);for(const Ae of k)Ae.el&&(at(Ae.pos)<at(u)&&at(Ae.pos+Ae.dim+Ae.gap)<at(R)&&at(R)>at(l-u)&&(Ae.el.style[e]=`${at(I+D,1e3)}px`),at(Ae.pos+Ae.gap)>=at(l-u)&&at(Ae.pos)>at(R+u)&&at(R)<at(u)&&(Ae.el.style[e]=`-${at(D,1e3)}px`))}let $,G,te=[...this.inTransition];if(te.length>1&&($=b[te[0]],G=b[te[1]]),$&&G){let Z=0;for(const Q of k)Q.el?this.inTransition.has(Q.index)&&$.slides.indexOf(Q)<0&&(Q.el.style[e]=`${at(Z+($.pos-G.pos),1e3)}px`):Z+=Q.dim+Q.gap}}createSlideEl(e){const{track:t,slides:i}=this;if(!t||!e||e.el&&e.el.parentNode)return;const r=e.el||document.createElement("div");Ct(r,this.cn(qp)),Ct(r,e.class),Ct(r,e.customClass);const a=e.html;a&&(a instanceof HTMLElement?r.appendChild(a):r.innerHTML=e.html+"");const u=[];i.forEach((k,E)=>{k.el&&u.push(E)});const l=e.index;let g=null;u.length&&(g=i[u.reduce((k,E)=>Math.abs(E-l)<Math.abs(k-l)?E:k)]);const b=g&&g.el&&g.el.parentNode?g.index<e.index?g.el.nextSibling:g.el:null;t.insertBefore(r,t.contains(b)?b:null),e.el=r,this.emit("createSlide",e)}removeSlideEl(e,t=!1){const i=e==null?void 0:e.el;if(!i||!i.parentNode)return;const r=this.cn(lv);if(i.classList.contains(r)&&(En(i,r),this.emit("unselectSlide",e)),e.isDom&&!t)return i.removeAttribute("aria-hidden"),i.removeAttribute("data-index"),void(i.style.left="");this.emit("removeSlide",e);const a=new CustomEvent(Hp);i.dispatchEvent(a),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,t=this.option("transition")){var i,r,a,u;if(!t)return!1;const l=this.page,{pages:g,panzoom:b}=this;e=parseInt((e||0).toString())||0;const k=this.getPageFromIndex(e);if(!b||!g[k]||g.length<2||Math.abs((((r=(i=g[l])===null||i===void 0?void 0:i.slides[0])===null||r===void 0?void 0:r.dim)||0)-this.viewportDim)>1)return!1;let E=e>l?1:-1;this.isInfinite&&(l===0&&e===g.length-1&&(E=-1),l===g.length-1&&e===0&&(E=1));const C=g[k].pos*(this.isRTL?1:-1);if(l===k&&Math.abs(C-b.target[this.axis])<1)return!1;this.clearTransitions();const I=b.isResting;Ct(this.container,this.cn("inTransition"));const D=((a=g[l])===null||a===void 0?void 0:a.slides[0])||null,R=((u=g[k])===null||u===void 0?void 0:u.slides[0])||null;this.inTransition.add(R.index),this.createSlideEl(R);let $=D.el,G=R.el;I||t===qp||(t="fadeFast",$=null);const te=this.isRTL?"next":"prev",Z=this.isRTL?"prev":"next";return $&&(this.inTransition.add(D.index),D.transition=t,$.addEventListener(Hp,this.onAnimationEnd),$.classList.add(`f-${t}Out`,`to-${E>0?Z:te}`)),G&&(R.transition=t,G.addEventListener(Hp,this.onAnimationEnd),G.classList.add(`f-${t}In`,`from-${E>0?te:Z}`)),b.current[this.axis]=C,b.target[this.axis]=C,b.requestTick(),this.onChange(k),!0}manageSlideVisiblity(){const e=new Set,t=new Set,i=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const r of this.slides)i.has(r)?e.add(r):t.add(r);for(const r of this.inTransition)e.add(this.slides[r]);for(const r of e)this.createSlideEl(r),this.lazyLoadSlide(r);for(const r of t)e.has(r)||this.removeSlideEl(r);this.markSelectedSlides(),this.repositionSlides()}markSelectedSlides(){if(!this.pages[this.page]||!this.pages[this.page].slides)return;const e="aria-hidden";let t=this.cn(lv);if(t)for(const i of this.slides){const r=i.el;r&&(r.dataset.index=`${i.index}`,r.classList.contains("f-thumbs__slide")?this.getVisibleSlides(0).has(i)?r.removeAttribute(e):r.setAttribute(e,"true"):this.pages[this.page].slides.includes(i)?(r.classList.contains(t)||(Ct(r,t),this.emit("selectSlide",i)),r.removeAttribute(e)):(r.classList.contains(t)&&(En(r,t),this.emit("unselectSlide",i)),r.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:t,isInfinite:i,isRTL:r,viewportDim:a,contentDim:u}=this,l=this.panzoom;if(!l||!i)return;let g=l.current[e],b=l.target[e]-g,k=0,E=.5*a;r&&t?(g<-E&&(k=-1,g+=u),g>u-E&&(k=1,g-=u)):(g>E&&(k=1,g-=u),g<-u+E&&(k=-1,g+=u)),k&&(l.current[e]=g,l.target[e]=g+b)}lazyLoadImg(e,t){const i=this,r="f-fadeIn",a="is-preloading";let u=!1,l=null;const g=()=>{u||(u=!0,l&&(l.remove(),l=null),En(t,a),t.complete&&(Ct(t,r),setTimeout(()=>{En(t,r)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(i.updateMetrics(),i.setViewportHeight()),this.emit("load",e))};Ct(t,a),t.src=t.dataset.lazySrcset||t.dataset.lazySrc||"",delete t.dataset.lazySrc,delete t.dataset.lazySrcset,t.addEventListener("error",()=>{g()}),t.addEventListener("load",()=>{g()}),setTimeout(()=>{const b=t.parentNode;b&&e.el&&(t.complete?g():u||(l=Qs(hy),b.insertBefore(l,t)))},300)}lazyLoadSlide(e){const t=e&&e.el;if(!t)return;const i=new Set;let r=Array.from(t.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));t.dataset.lazySrc&&r.push(t),r.map(a=>{a instanceof HTMLImageElement?i.add(a):a instanceof HTMLElement&&a.dataset.lazySrc&&(a.style.backgroundImage=`url('${a.dataset.lazySrc}')`,delete a.dataset.lazySrc)});for(const a of i)this.lazyLoadImg(e,a)}onAnimationEnd(e){var t;const i=e.target,r=i?parseInt(i.dataset.index||"",10)||0:-1,a=this.slides[r],u=e.animationName;if(!i||!a||!u)return;const l=!!this.inTransition.has(r)&&a.transition;l&&u.substring(0,l.length+2)===`f-${l}`&&this.inTransition.delete(r),this.inTransition.size||this.clearTransitions(),r===this.page&&(!((t=this.panzoom)===null||t===void 0)&&t.isResting)&&this.emit("settle")}onDecel(e,t=0,i=0,r=0,a=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:u,isHorizontal:l,axis:g,pages:b}=this,k=b.length,E=Math.abs(Math.atan2(i,t)/(Math.PI/180));let C=0;if(C=E>45&&E<135?l?0:i:l?t:0,!k)return;let I=this.page,D=u&&l?1:-1;const R=e.current[g]*D;let{pageIndex:$}=this.getPageFromPosition(R);Math.abs(C)>5?(b[I].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(I=$),I=u&&l?C<0?I-1:I+1:C<0?I+1:I-1):I=r===0&&a===0?I:$,this.slideTo(I,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const t=e.target,i=t&&Mr(t)?t.dataset:null;let r,a;i&&(i.carouselPage!==void 0?(a="slideTo",r=i.carouselPage):i.carouselNext!==void 0?a="slideNext":i.carouselPrev!==void 0&&(a="slidePrev")),a?(e.preventDefault(),e.stopPropagation(),t&&!t.hasAttribute("disabled")&&this[a](r)):this.emit("click",e)}onSlideTo(e){const t=e.detail||0;this.slideTo(this.getPageForSlide(t),{friction:0})}onChange(e,t=0){const i=this.page;this.prevPage=i,this.page=e,this.option("adaptiveHeight")&&this.setViewportHeight(),e!==i&&(this.markSelectedSlides(),this.emit("change",e,i,t))}onRefresh(){let e=this.contentDim,t=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===t||this.slideTo(this.page,{friction:0,transition:!1})}onScroll(){var e;(e=this.viewport)===null||e===void 0||e.scroll(0,0)}onResize(){this.option("breakpoints")&&this.processOptions()}onBeforeTransform(e){this.lp!==e.current[this.axis]&&(this.flipInfiniteTrack(),this.manageSlideVisiblity()),this.lp=e.current.e}onEndAnimation(){this.inTransition.size||this.emit("settle")}reInit(e=null,t=null){this.destroy(),this.state=di.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=t||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:t=this.option("friction"),transition:i=this.option("transition")}={}){if(this.state===di.Destroy)return;e=parseInt((e||0).toString())||0;const r=this.getPageFromIndex(e),{axis:a,isHorizontal:u,isRTL:l,pages:g,panzoom:b}=this,k=g.length,E=l&&u?1:-1;if(!b||!k)return;if(this.page!==r){const I=new Event("beforeChange",{bubbles:!0,cancelable:!0});if(this.emit("beforeChange",I,e),I.defaultPrevented)return}if(this.transitionTo(e,i))return;let C=g[r].pos;if(this.isInfinite){const I=this.contentDim,D=b.target[a]*E;k===2?C+=I*Math.floor(parseFloat(e+"")/2):C=[C,C-I,C+I].reduce(function(R,$){return Math.abs($-D)<Math.abs(R-D)?$:R})}C*=E,Math.abs(b.target[a]-C)<1||(b.panTo({x:u?C:0,y:u?0:C,friction:t}),this.onChange(r))}slideToClosest(e){if(this.panzoom){const{pageIndex:t}=this.getPageFromPosition();this.slideTo(t,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),En(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const t of this.slides){const i=t.el;if(i){i.removeEventListener(Hp,this.onAnimationEnd),i.classList.remove(...e);const r=t.transition;r&&i.classList.remove(`f-${r}Out`,`f-${r}In`)}}this.manageSlideVisiblity()}addSlide(e,t){var i,r,a,u;const l=this.panzoom,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.pos)||0,b=((r=this.pages[this.page])===null||r===void 0?void 0:r.dim)||0,k=this.contentDim<this.viewportDim;let E=Array.isArray(t)?t:[t];const C=[];for(const I of E)C.push(fy(I));this.slides.splice(e,0,...C);for(let I=0;I<this.slides.length;I++)this.slides[I].index=I;for(const I of C)this.emit("beforeInitSlide",I,I.index);if(this.page>=e&&(this.page+=C.length),this.updateMetrics(),l){const I=((a=this.pages[this.page])===null||a===void 0?void 0:a.pos)||0,D=((u=this.pages[this.page])===null||u===void 0?void 0:u.dim)||0,R=this.pages.length||1,$=this.isRTL?b-D:D-b,G=this.isRTL?g-I:I-g;k&&R===1?(e<=this.page&&(l.current[this.axis]-=$,l.target[this.axis]-=$),l.panTo({[this.isHorizontal?"x":"y"]:-1*I})):G&&e<=this.page&&(l.target[this.axis]-=G,l.current[this.axis]-=G,l.requestTick())}for(const I of C)this.emit("initSlide",I,I.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const t=this.slides.length;e=(e%t+t)%t;const i=this.slides[e];if(i){this.removeSlideEl(i,!0),this.slides.splice(e,1);for(let r=0;r<this.slides.length;r++)this.slides[r].index=r;this.updateMetrics(),this.slideTo(this.page,{friction:0,transition:!1}),this.emit("destroySlide",i)}}updateMetrics(){const{panzoom:e,viewport:t,track:i,slides:r,isHorizontal:a,isInfinite:u}=this;if(!i)return;const l=a?"width":"height",g=a?"offsetWidth":"offsetHeight";if(t){let E=Math.max(t[g],at(t.getBoundingClientRect()[l],1e3)),C=getComputedStyle(t),I="padding",D=a?"Right":"Bottom";E-=parseFloat(C[I+(a?"Left":"Top")])+parseFloat(C[I+D]),this.viewportDim=E}let b,k=0;for(const[E,C]of r.entries()){let I=0,D=0;!C.el&&b?(I=b.dim,D=b.gap):({dim:I,gap:D}=this.getSlideMetrics(C),b=C),I=at(I,1e3),D=at(D,1e3),C.dim=I,C.gap=D,C.pos=k,k+=I,(u||E<r.length-1)&&(k+=D)}k=at(k,1e3),this.contentDim=k,e&&(e.contentRect[l]=k,e.contentRect[a?"fullWidth":"fullHeight"]=k),this.pages=this.createPages(),this.pages=this.processPages(),this.state===di.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,t=!1,i=!1){e===void 0&&(e=this.page);const r=this,a=r.panzoom,u=r.contentDim,l=r.pages[e]||0;if(!l||!a)return e>this.page?-1:1;let g=-1*a.current.e,b=at((g-l.pos)/(1*l.dim),1e3),k=b,E=b;this.isInfinite&&i!==!0&&(k=at((g-l.pos+u)/(1*l.dim),1e3),E=at((g-l.pos-u)/(1*l.dim),1e3));let C=[b,k,E].reduce(function(I,D){return Math.abs(D)<Math.abs(I)?D:I});return t?C:C>1?1:C<-1?-1:C}setViewportHeight(){const{page:e,pages:t,viewport:i,isHorizontal:r}=this;if(!i||!t[e])return;let a=0;r&&this.track&&(this.track.style.height="auto",t[e].slides.forEach(u=>{u.el&&(a=Math.max(a,u.el.offsetHeight))})),i.style.height=a?`${a}px`:""}getPageForSlide(e){for(const t of this.pages)for(const i of t.slides)if(i.index===e)return t.index;return-1}getVisibleSlides(e=0){var t;const i=new Set;let{panzoom:r,contentDim:a,viewportDim:u,pages:l,page:g}=this;if(u){a=a+((t=this.slides[this.slides.length-1])===null||t===void 0?void 0:t.gap)||0;let b=0;b=r&&r.state!==Pn.Init&&r.state!==Pn.Destroy?-1*r.current[this.axis]:l[g]&&l[g].pos||0,this.isInfinite&&(b-=Math.floor(b/a)*a),this.isRTL&&this.isHorizontal&&(b*=-1);const k=b-u*e,E=b+u*(e+1),C=this.isInfinite?[-1,0,1]:[0];for(const I of this.slides)for(const D of C){const R=I.pos+D*a,$=R+I.dim+I.gap;R<E&&$>k&&i.add(I)}}return i}getPageFromPosition(e){const{viewportDim:t,contentDim:i,slides:r,pages:a,panzoom:u}=this,l=a.length,g=r.length,b=r[0],k=r[g-1],E=this.option("center");let C=0,I=0,D=0,R=e===void 0?-1*((u==null?void 0:u.target[this.axis])||0):e;E&&(R+=.5*t),this.isInfinite?(R<b.pos-.5*k.gap&&(R-=i,D=-1),R>k.pos+k.dim+.5*k.gap&&(R-=i,D=1)):R=Math.max(b.pos||0,Math.min(R,k.pos));let $=k,G=r.find(te=>{const Z=te.pos-.5*$.gap,Q=te.pos+te.dim+.5*te.gap;return $=te,R>=Z&&R<Q});return G||(G=k),I=this.getPageForSlide(G.index),C=I+D*l,{page:C,pageIndex:I}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([di.Destroy].includes(this.state))return;this.state=di.Destroy;const{container:e,viewport:t,track:i,slides:r,panzoom:a}=this,u=this.option("classes");e.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),e.removeEventListener("slideTo",this.onSlideTo),window.removeEventListener("resize",this.onResize),a&&(a.destroy(),this.panzoom=null),r&&r.forEach(g=>{this.removeSlideEl(g)}),this.detachPlugins(),t&&(t.removeEventListener("scroll",this.onScroll),t.offsetParent&&i&&i.offsetParent&&t.replaceWith(...i.childNodes));for(const[g,b]of Object.entries(u))g!=="container"&&b&&e.classList.remove(b);this.track=null,this.viewport=null,this.page=0,this.slides=[];const l=this.events.get("ready");this.events=new Map,l&&this.events.set("ready",l)}}Object.defineProperty(ha,"Panzoom",{enumerable:!0,configurable:!0,writable:!0,value:ua}),Object.defineProperty(ha,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:GB}),Object.defineProperty(ha,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:XB});const cv=function(n){if(!Mr(n))return 0;const e=window.scrollY,t=window.innerHeight,i=e+t,r=n.getBoundingClientRect(),a=r.y+e,u=r.height,l=a+u;if(e>l||i<a)return 0;if(e<a&&i>l||a<e&&l>i)return 100;let g=u;a<e&&(g-=e-a),l>i&&(g-=l-i);const b=g/t*100;return Math.round(b)},fh=!(typeof window>"u"||!window.document||!window.document.createElement);let my;const gy=["a[href]","area[href]",'input:not([disabled]):not([type="hidden"]):not([aria-hidden])',"select:not([disabled]):not([aria-hidden])","textarea:not([disabled]):not([aria-hidden])","button:not([disabled]):not([aria-hidden]):not(.fancybox-focus-guard)","iframe","object","embed","video","audio","[contenteditable]",'[tabindex]:not([tabindex^="-"]):not([disabled]):not([aria-hidden])'].join(","),uv=n=>{if(n&&fh){my===void 0&&document.createElement("div").focus({get preventScroll(){return my=!0,!1}});try{if(my)n.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,t=window.scrollX||document.body.scrollLeft;n.focus(),document.body.scrollTo({top:e,left:t,behavior:"auto"})}}catch{}}},hv=()=>{const n=document;let e,t="",i="",r="";return n.fullscreenEnabled?(t="requestFullscreen",i="exitFullscreen",r="fullscreenElement"):n.webkitFullscreenEnabled&&(t="webkitRequestFullscreen",i="webkitExitFullscreen",r="webkitFullscreenElement"),t&&(e={request:function(a=n.documentElement){return t==="webkitRequestFullscreen"?a[t](Element.ALLOW_KEYBOARD_INPUT):a[t]()},exit:function(){return n[r]&&n[i]()},isFullscreen:function(){return n[r]}}),e},yy={animated:!0,autoFocus:!0,backdropClick:"close",Carousel:{classes:{container:"fancybox__carousel",viewport:"fancybox__viewport",track:"fancybox__track",slide:"fancybox__slide"}},closeButton:"auto",closeExisting:!1,commonCaption:!1,compact:()=>window.matchMedia("(max-width: 578px), (max-height: 578px)").matches,contentClick:"toggleZoom",contentDblClick:!1,defaultType:"image",defaultDisplay:"flex",dragToClose:!0,Fullscreen:{autoStart:!1},groupAll:!1,groupAttr:"data-fancybox",hideClass:"f-fadeOut",hideScrollbar:!0,idle:3500,keyboard:{Escape:"close",Delete:"close",Backspace:"close",PageUp:"next",PageDown:"prev",ArrowUp:"prev",ArrowDown:"next",ArrowRight:"next",ArrowLeft:"prev"},l10n:Object.assign(Object.assign({},J1),{CLOSE:"Close",NEXT:"Next",PREV:"Previous",MODAL:"You can close this modal content with the ESC key",ERROR:"Something Went Wrong, Please Try Again Later",IMAGE_ERROR:"Image Not Found",ELEMENT_NOT_FOUND:"HTML Element Not Found",AJAX_NOT_FOUND:"Error Loading AJAX : Not Found",AJAX_FORBIDDEN:"Error Loading AJAX : Forbidden",IFRAME_ERROR:"Error Loading Page",TOGGLE_ZOOM:"Toggle zoom level",TOGGLE_THUMBS:"Toggle thumbnails",TOGGLE_SLIDESHOW:"Toggle slideshow",TOGGLE_FULLSCREEN:"Toggle full-screen mode",DOWNLOAD:"Download"}),parentEl:null,placeFocusBack:!0,showClass:"f-zoomInUp",startIndex:0,tpl:{closeButton:'<button data-fancybox-close class="f-button is-close-btn" title="{{CLOSE}}"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" tabindex="-1"><path d="M20 20L4 4m16 0L4 20"/></svg></button>',main:`<div class="fancybox__container" role="dialog" aria-modal="true" aria-label="{{MODAL}}" tabindex="-1">
625
625
  <div class="fancybox__backdrop"></div>
626
626
  <div class="fancybox__carousel"></div>
627
627
  <div class="fancybox__footer"></div>