@opengis/admin 0.1.32 → 0.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -29
- package/config.js +4 -4
- package/dist/{IconSearch-CxDTYG1J.js → IconSearch-1BcTMxEE.js} +1 -1
- package/dist/{add-page-D_Fg9HXW.js → add-page-wcbfNL4F.js} +1 -1
- package/dist/{admin-interface-BRAtve0X.js → admin-interface-DXUh5O3U.js} +2 -2
- package/dist/{admin-view-DEPFLjx8.js → admin-view-C6kdm9x5.js} +3 -3
- package/dist/admin.js +1 -1
- package/dist/admin.umd.cjs +4 -4
- package/dist/{card-page-DBDmzwDl.js → card-page-BZoBOZQ0.js} +2 -2
- package/dist/{card-view-BqFARR8P.js → card-view-hVzD8WTT.js} +1 -1
- package/dist/{edit-page-DxYGPaLO.js → edit-page-CPzwH3_B.js} +1 -1
- package/dist/{import-file-BtyRoYT7.js → import-file-BioYjefB.js} +19 -12
- package/dist/style.css +1 -1
- package/module/settings/card/admin.roles.table/access.hbs +27 -27
- package/module/settings/card/admin.roles.table/general_info.hbs +16 -16
- package/module/settings/card/admin.roles.table/index.yml +14 -14
- package/module/settings/card/admin.roles.table/users.hbs +27 -27
- package/module/settings/card/admin.routes.table/general_info.hbs +40 -40
- package/module/settings/card/admin.routes.table/index.yml +8 -8
- package/module/settings/card/admin.routes.table/users.hbs +33 -33
- package/module/settings/card/admin.users.table/general_info.hbs +25 -25
- package/module/settings/card/admin.users.table/index.yml +12 -12
- package/module/settings/card/admin.users.table/logs.hbs +30 -30
- package/module/settings/card/admin.users.table/user_roles.hbs +24 -24
- package/module/settings/cls/core.actions.json +13 -13
- package/module/settings/cls/core.scope.json +13 -13
- package/module/settings/cls/properties.site_status.json +13 -13
- package/module/settings/cls/properties.widget_status.json +13 -13
- package/module/settings/cls/users.user_type.json +13 -13
- package/module/settings/form/admin.access.form.json +36 -36
- package/module/settings/form/admin.properties.form.json +15 -15
- package/module/settings/form/admin.roles.form.json +19 -19
- package/module/settings/form/admin.routes.form.json +25 -25
- package/module/settings/form/admin.user_properties.entity.form.json +71 -0
- package/module/settings/form/admin.user_properties.form.json +15 -15
- package/module/settings/form/admin.user_roles.form.json +21 -21
- package/module/settings/form/admin.users.form.json +150 -150
- package/module/settings/form/user.user_roles.form.json +13 -13
- package/module/settings/interface/admin.properties.json +4 -4
- package/module/settings/interface/admin.roles.json +4 -4
- package/module/settings/interface/admin.routes.json +4 -4
- package/module/settings/interface/admin.users.json +4 -4
- package/module/settings/menu.json +45 -39
- package/module/settings/select/core.roles.json +2 -2
- package/module/settings/select/core.user_uid.sql +1 -1
- package/module/settings/table/admin.access.table.json +77 -77
- package/module/settings/table/admin.properties.table.json +33 -33
- package/module/settings/table/admin.roles.table.json +58 -58
- package/module/settings/table/admin.routes.table.json +55 -55
- package/module/settings/table/admin.user_properties.entity.table.json +76 -0
- package/module/settings/table/admin.user_properties.table.json +29 -28
- package/module/settings/table/admin.user_roles.table.json +66 -66
- package/module/settings/table/admin.users.table.json +119 -119
- package/package.json +74 -74
- package/plugin.js +100 -102
- package/server/helpers/controllers/badge.js +11 -11
- package/server/helpers/controllers/hb.js +2 -2
- package/server/helpers/controllers/map.js +2 -2
- package/server/helpers/controllers/mls.js +2 -2
- package/server/helpers/controllers/vue.js +2 -2
- package/server/helpers/index.mjs +13 -13
- package/server/plugins/docs.js +28 -28
- package/server/plugins/hook.js +166 -166
- package/server/plugins/vite.js +69 -69
- package/server/routes/data/controllers/cardData.js +56 -56
- package/server/routes/data/controllers/cardTabData.js +39 -39
- package/server/routes/data/controllers/funcs/getFilterSQL/index.js +85 -85
- package/server/routes/data/controllers/funcs/getFilterSQL/util/formatValue.js +142 -142
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getCustomQuery.js +13 -13
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getFilterQuery.js +67 -67
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getOptimizedQuery.js +12 -12
- package/server/routes/data/controllers/funcs/getFilterSQL/util/getTableSql.js +34 -34
- package/server/routes/data/controllers/tableData.js +121 -121
- package/server/routes/data/controllers/tableDataId.js +27 -27
- package/server/routes/data/controllers/tableFilter.js +54 -54
- package/server/routes/data/controllers/utils/assignTokens.js +30 -30
- package/server/routes/data/controllers/utils/getColumns.js +21 -21
- package/server/routes/data/index.mjs +12 -12
- package/server/routes/menu/controllers/getMenu.js +33 -33
- package/server/routes/menu/index.mjs +5 -5
- package/server/routes/properties/controllers/admin.properties.get.js +29 -29
- package/server/routes/properties/controllers/user.properties.get.js +34 -34
- package/server/routes/properties/controllers/user.properties.post.js +30 -30
- package/server/routes/properties/funcs/getSettings.js +56 -56
- package/server/routes/properties/funcs/setSettings.js +44 -44
- package/server/routes/properties/funcs/utils/dataInsert.js +26 -26
- package/server/routes/properties/index.mjs +26 -26
- package/server/routes/root.mjs +3 -3
- package/server/routes/templates/controllers/getTemplate.js +14 -14
- package/server/routes/templates/index.mjs +14 -14
- package/server/templates/cls/itree.recrzone_category.json +73 -73
- package/server/templates/cls/test.json +9 -9
- package/server/templates/form/admin.user_cls.data.form.json +49 -49
- package/server/templates/form/admin.user_group_rel.form.json +21 -21
- package/server/templates/form/cp_building.form.json +32 -32
- package/server/templates/form/form-user-pass.json +10 -10
- package/server/templates/form/form-user_group.json +39 -39
- package/server/templates/form/form-users.json +156 -156
- package/server/templates/form/user_group_access.form.json +22 -22
- package/server/templates/select/account_id.json +2 -2
- package/server/templates/table/gis.dataset.table.json +43 -43
- package/server/templates/table/management.user_group.table.json +112 -112
- package/server/templates/table/management.users.table.json +126 -126
- package/utils.js +8 -8
package/dist/admin.umd.cjs
CHANGED
|
@@ -621,15 +621,15 @@ uniform ${B} ${F} u_${W};
|
|
|
621
621
|
#endif
|
|
622
622
|
`}),staticAttributes:f,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,f,m,b,M,P,D,L){this.context=s;let B=this.boundPaintVertexBuffers.length!==m.length;for(let F=0;!B&&F<m.length;F++)this.boundPaintVertexBuffers[F]!==m[F]&&(B=!0);!this.vao||this.boundProgram!==d||this.boundLayoutVertexBuffer!==f||B||this.boundIndexBuffer!==b||this.boundVertexOffset!==M||this.boundDynamicVertexBuffer!==P||this.boundDynamicVertexBuffer2!==D||this.boundDynamicVertexBuffer3!==L?this.freshBind(d,f,m,b,M,P,D,L):(s.bindVertexArray.set(this.vao),P&&P.bind(),b&&b.dynamicDraw&&b.bind(),D&&D.bind(),L&&L.bind())}freshBind(s,d,f,m,b,M,P,D){const L=s.numAttributes,B=this.context,F=B.gl;this.vao&&this.destroy(),this.vao=B.createVertexArray(),B.bindVertexArray.set(this.vao),this.boundProgram=s,this.boundLayoutVertexBuffer=d,this.boundPaintVertexBuffers=f,this.boundIndexBuffer=m,this.boundVertexOffset=b,this.boundDynamicVertexBuffer=M,this.boundDynamicVertexBuffer2=P,this.boundDynamicVertexBuffer3=D,d.enableAttributes(F,s);for(const W of f)W.enableAttributes(F,s);M&&M.enableAttributes(F,s),P&&P.enableAttributes(F,s),D&&D.enableAttributes(F,s),d.bind(),d.setVertexAttribPointers(F,s,b);for(const W of f)W.bind(),W.setVertexAttribPointers(F,s,b);M&&(M.bind(),M.setVertexAttribPointers(F,s,b)),m&&m.bind(),P&&(P.bind(),P.setVertexAttribPointers(F,s,b)),D&&(D.bind(),D.setVertexAttribPointers(F,s,b)),B.currentNumAttributes=L}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Jh=(x,s,d,f,m)=>({u_matrix:x,u_texture:0,u_ele_delta:s,u_fog_matrix:d,u_fog_color:f?f.properties.get("fog-color"):l.aM.white,u_fog_ground_blend:f?f.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:f?f.calculateFogBlendOpacity(m):0,u_horizon_color:f?f.properties.get("horizon-color"):l.aM.white,u_horizon_fog_blend:f?f.properties.get("horizon-fog-blend"):1});function Pa(x){const s=[];for(let d=0;d<x.length;d++){if(x[d]===null)continue;const f=x[d].split(" ");s.push(f.pop())}return s}class Qh{constructor(s,d,f,m,b,M){const P=s.gl;this.program=P.createProgram();const D=Pa(d.staticAttributes),L=f?f.getBinderAttributes():[],B=D.concat(L),F=uo.prelude.staticUniforms?Pa(uo.prelude.staticUniforms):[],W=d.staticUniforms?Pa(d.staticUniforms):[],K=f?f.getBinderUniforms():[],Q=F.concat(W).concat(K),re=[];for(const xe of Q)re.indexOf(xe)<0&&re.push(xe);const le=f?f.defines():[];b&&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
|
-
`),te=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(te,ce),P.compileShader(te),!P.getShaderParameter(te,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(te)}`);P.attachShader(this.program,te);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=B.length;for(let xe=0;xe<this.numAttributes;xe++)B[xe]&&(P.bindAttribLocation(this.program,xe,B[xe]),this.attributes[B[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(te);for(let xe=0;xe<re.length;xe++){const Oe=re[xe];if(Oe&&!ge[Oe]){const Fe=P.getUniformLocation(this.program,Oe);Fe&&(ge[Oe]=Fe)}}this.fixedUniforms=m(s,ge),this.terrainUniforms=((xe,Oe)=>({u_depth:new l.aH(xe,Oe.u_depth),u_terrain:new l.aH(xe,Oe.u_terrain),u_terrain_dim:new l.aI(xe,Oe.u_terrain_dim),u_terrain_matrix:new l.aJ(xe,Oe.u_terrain_matrix),u_terrain_unpack:new l.aK(xe,Oe.u_terrain_unpack),u_terrain_exaggeration:new l.aI(xe,Oe.u_terrain_exaggeration)}))(s,ge),this.binderUniforms=f?f.getUniforms(s,ge):[]}draw(s,d,f,m,b,M,P,D,L,B,F,W,K,Q,re,le,ce,he){const te=s.gl;if(this.failedToCreate)return;if(s.program.set(this.program),s.setDepthMode(f),s.setStencilMode(m),s.setColorMode(b),s.setCullFace(M),D){s.activeTexture.set(te.TEXTURE2),te.bindTexture(te.TEXTURE_2D,D.depthTexture),s.activeTexture.set(te.TEXTURE3),te.bindTexture(te.TEXTURE_2D,D.texture);for(const ge in this.terrainUniforms)this.terrainUniforms[ge].set(D[ge])}for(const ge in this.fixedUniforms)this.fixedUniforms[ge].set(P[ge]);re&&re.setUniforms(s,this.binderUniforms,K,{zoom:Q});let me=0;switch(d){case te.LINES:me=2;break;case te.TRIANGLES:me=3;break;case te.LINE_STRIP:me=1}for(const ge of W.get()){const xe=ge.vaos||(ge.vaos={});(xe[L]||(xe[L]=new Kh)).bind(s,this,B,re?re.getPaintVertexBuffers():[],F,ge.vertexOffset,le,ce,he),te.drawElements(d,ge.primitiveLength*me,te.UNSIGNED_SHORT,ge.primitiveOffset*me*2)}}}function nu(x,s,d){const f=1/Zt(d,1,s.transform.tileZoom),m=Math.pow(2,d.tileID.overscaledZ),b=d.tileSize*Math.pow(2,s.transform.tileZoom)/m,M=b*(d.tileID.canonical.x+d.tileID.wrap*m),P=b*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[f,x.fromScale,x.toScale],u_fade:x.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Bl=(x,s,d,f)=>{const m=s.style.light,b=m.properties.get("position"),M=[b.x,b.y,b.z],P=function(){var L=new l.A(9);return l.A!=Float32Array&&(L[1]=0,L[2]=0,L[3]=0,L[5]=0,L[6]=0,L[7]=0),L[0]=1,L[4]=1,L[8]=1,L}();m.properties.get("anchor")==="viewport"&&function(L,B){var F=Math.sin(B),W=Math.cos(B);L[0]=W,L[1]=F,L[2]=0,L[3]=-F,L[4]=W,L[5]=0,L[6]=0,L[7]=0,L[8]=1}(P,-s.transform.angle),function(L,B,F){var W=B[0],K=B[1],Q=B[2];L[0]=W*F[0]+K*F[3]+Q*F[6],L[1]=W*F[1]+K*F[4]+Q*F[7],L[2]=W*F[2]+K*F[5]+Q*F[8]}(M,M,P);const D=m.properties.get("color");return{u_matrix:x,u_lightpos:M,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[D.r,D.g,D.b],u_vertical_gradient:+d,u_opacity:f}},iu=(x,s,d,f,m,b,M)=>l.e(Bl(x,s,d,f),nu(b,s,M),{u_height_factor:-Math.pow(2,m.overscaledZ)/M.tileSize/8}),Ia=x=>({u_matrix:x}),Gf=(x,s,d,f)=>l.e(Ia(x),nu(d,s,f)),X0=(x,s)=>({u_matrix:x,u_world:s}),Zf=(x,s,d,f,m)=>l.e(Gf(x,s,d,f),{u_world:m}),K0=(x,s,d,f)=>{const m=x.transform;let b,M;if(f.paint.get("circle-pitch-alignment")==="map"){const P=Zt(d,1,m.zoom);b=!0,M=[P,P]}else b=!1,M=m.pixelsToGLUnits;return{u_camera_to_center_distance:m.cameraToCenterDistance,u_scale_with_map:+(f.paint.get("circle-pitch-scale")==="map"),u_matrix:x.translatePosMatrix(s.posMatrix,d,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_pitch_with_map:+b,u_device_pixel_ratio:x.pixelRatio,u_extrude_scale:M}},jo=(x,s,d)=>({u_matrix:x,u_inv_matrix:s,u_camera_to_center_distance:d.cameraToCenterDistance,u_viewport_size:[d.width,d.height]}),Fl=(x,s,d=1)=>({u_matrix:x,u_color:s,u_overlay:0,u_overlay_scale:d}),nr=x=>({u_matrix:x}),ir=(x,s,d,f)=>({u_matrix:x,u_extrude_scale:Zt(s,1,d),u_intensity:f}),ru=(x,s,d,f)=>{const m=l.H();l.aP(m,0,x.width,x.height,0,0,1);const b=x.context.gl;return{u_matrix:m,u_world:[b.drawingBufferWidth,b.drawingBufferHeight],u_image:d,u_color_ramp:f,u_opacity:s.paint.get("heatmap-opacity")}};function su(x,s){const d=Math.pow(2,s.canonical.z),f=s.canonical.y;return[new l.Z(0,f/d).toLngLat().lat,new l.Z(0,(f+1)/d).toLngLat().lat]}const ou=(x,s,d,f)=>{const m=x.transform;return{u_matrix:Kf(x,s,d,f),u_ratio:1/Zt(s,1,m.zoom),u_device_pixel_ratio:x.pixelRatio,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},Yf=(x,s,d,f,m)=>l.e(ou(x,s,d,m),{u_image:0,u_image_height:f}),Da=(x,s,d,f,m)=>{const b=x.transform,M=Xf(s,b);return{u_matrix:Kf(x,s,d,m),u_texsize:s.imageAtlasTexture.size,u_ratio:1/Zt(s,1,b.zoom),u_device_pixel_ratio:x.pixelRatio,u_image:0,u_scale:[M,f.fromScale,f.toScale],u_fade:f.t,u_units_to_pixels:[1/b.pixelsToGLUnits[0],1/b.pixelsToGLUnits[1]]}},J0=(x,s,d,f,m,b)=>{const M=x.lineAtlas,P=Xf(s,x.transform),D=d.layout.get("line-cap")==="round",L=M.getDash(f.from,D),B=M.getDash(f.to,D),F=L.width*m.fromScale,W=B.width*m.toScale;return l.e(ou(x,s,d,b),{u_patternscale_a:[P/F,-L.height/2],u_patternscale_b:[P/W,-B.height/2],u_sdfgamma:M.width/(256*Math.min(F,W)*x.pixelRatio)/2,u_image:0,u_tex_y_a:L.y,u_tex_y_b:B.y,u_mix:m.t})};function Xf(x,s){return 1/Zt(x,1,s.tileZoom)}function Kf(x,s,d,f){return x.translatePosMatrix(f?f.posMatrix:s.tileID.posMatrix,s,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}const Q0=(x,s,d,f,m)=>{return{u_matrix:x,u_tl_parent:s,u_scale_parent:d,u_buffer_scale:1,u_fade_t:f.mix,u_opacity:f.opacity*m.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:m.paint.get("raster-brightness-min"),u_brightness_high:m.paint.get("raster-brightness-max"),u_saturation_factor:(M=m.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(b=m.paint.get("raster-contrast"),b>0?1/(1-b):1+b),u_spin_weights:e_(m.paint.get("raster-hue-rotate"))};var b,M};function e_(x){x*=Math.PI/180;const s=Math.sin(x),d=Math.cos(x);return[(2*d+1)/3,(-Math.sqrt(3)*s-d+1)/3,(Math.sqrt(3)*s-d+1)/3]}const Jf=(x,s,d,f,m,b,M,P,D,L,B,F,W,K)=>{const Q=M.transform;return{u_is_size_zoom_constant:+(x==="constant"||x==="source"),u_is_size_feature_constant:+(x==="constant"||x==="camera"),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:Q.cameraToCenterDistance,u_pitch:Q.pitch/360*2*Math.PI,u_rotate_symbol:+d,u_aspect_ratio:Q.width/Q.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:D,u_coord_matrix:L,u_is_text:+F,u_pitch_with_map:+f,u_is_along_line:m,u_is_variable_anchor:b,u_texsize:W,u_texture:0,u_translation:B,u_pitched_scale:K}},Vl=(x,s,d,f,m,b,M,P,D,L,B,F,W,K,Q)=>{const re=M.transform;return l.e(Jf(x,s,d,f,m,b,M,P,D,L,B,F,W,Q),{u_gamma_scale:f?Math.cos(re._pitch)*re.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:+K})},ed=(x,s,d,f,m,b,M,P,D,L,B,F,W,K)=>l.e(Vl(x,s,d,f,m,b,M,P,D,L,B,!0,F,!0,K),{u_texsize_icon:W,u_texture_icon:1}),au=(x,s,d)=>({u_matrix:x,u_opacity:s,u_color:d}),td=(x,s,d,f,m,b)=>l.e(function(M,P,D,L){const B=D.imageManager.getPattern(M.from.toString()),F=D.imageManager.getPattern(M.to.toString()),{width:W,height:K}=D.imageManager.getPixelSize(),Q=Math.pow(2,L.tileID.overscaledZ),re=L.tileSize*Math.pow(2,D.transform.tileZoom)/Q,le=re*(L.tileID.canonical.x+L.tileID.wrap*Q),ce=re*L.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:B.tl,u_pattern_br_a:B.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[W,K],u_mix:P.t,u_pattern_size_a:B.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Zt(L,1,D.transform.tileZoom),u_pixel_coord_upper:[le>>16,ce>>16],u_pixel_coord_lower:[65535&le,65535&ce]}}(f,b,d,m),{u_matrix:x,u_opacity:s}),nd={fillExtrusion:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_lightpos:new l.aN(x,s.u_lightpos),u_lightintensity:new l.aI(x,s.u_lightintensity),u_lightcolor:new l.aN(x,s.u_lightcolor),u_vertical_gradient:new l.aI(x,s.u_vertical_gradient),u_opacity:new l.aI(x,s.u_opacity)}),fillExtrusionPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_lightpos:new l.aN(x,s.u_lightpos),u_lightintensity:new l.aI(x,s.u_lightintensity),u_lightcolor:new l.aN(x,s.u_lightcolor),u_vertical_gradient:new l.aI(x,s.u_vertical_gradient),u_height_factor:new l.aI(x,s.u_height_factor),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade),u_opacity:new l.aI(x,s.u_opacity)}),fill:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix)}),fillPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),fillOutline:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world)}),fillOutlinePattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),circle:(x,s)=>({u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_scale_with_map:new l.aH(x,s.u_scale_with_map),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_extrude_scale:new l.aO(x,s.u_extrude_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_matrix:new l.aJ(x,s.u_matrix)}),collisionBox:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_pixel_extrude_scale:new l.aO(x,s.u_pixel_extrude_scale)}),collisionCircle:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_inv_matrix:new l.aJ(x,s.u_inv_matrix),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_viewport_size:new l.aO(x,s.u_viewport_size)}),debug:(x,s)=>({u_color:new l.aL(x,s.u_color),u_matrix:new l.aJ(x,s.u_matrix),u_overlay:new l.aH(x,s.u_overlay),u_overlay_scale:new l.aI(x,s.u_overlay_scale)}),clippingMask:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix)}),heatmap:(x,s)=>({u_extrude_scale:new l.aI(x,s.u_extrude_scale),u_intensity:new l.aI(x,s.u_intensity),u_matrix:new l.aJ(x,s.u_matrix)}),heatmapTexture:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world),u_image:new l.aH(x,s.u_image),u_color_ramp:new l.aH(x,s.u_color_ramp),u_opacity:new l.aI(x,s.u_opacity)}),hillshade:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_latrange:new l.aO(x,s.u_latrange),u_light:new l.aO(x,s.u_light),u_shadow:new l.aL(x,s.u_shadow),u_highlight:new l.aL(x,s.u_highlight),u_accent:new l.aL(x,s.u_accent)}),hillshadePrepare:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_dimension:new l.aO(x,s.u_dimension),u_zoom:new l.aI(x,s.u_zoom),u_unpack:new l.aK(x,s.u_unpack)}),line:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels)}),lineGradient:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_image:new l.aH(x,s.u_image),u_image_height:new l.aI(x,s.u_image_height)}),linePattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texsize:new l.aO(x,s.u_texsize),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_image:new l.aH(x,s.u_image),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),lineSDF:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_patternscale_a:new l.aO(x,s.u_patternscale_a),u_patternscale_b:new l.aO(x,s.u_patternscale_b),u_sdfgamma:new l.aI(x,s.u_sdfgamma),u_image:new l.aH(x,s.u_image),u_tex_y_a:new l.aI(x,s.u_tex_y_a),u_tex_y_b:new l.aI(x,s.u_tex_y_b),u_mix:new l.aI(x,s.u_mix)}),raster:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_tl_parent:new l.aO(x,s.u_tl_parent),u_scale_parent:new l.aI(x,s.u_scale_parent),u_buffer_scale:new l.aI(x,s.u_buffer_scale),u_fade_t:new l.aI(x,s.u_fade_t),u_opacity:new l.aI(x,s.u_opacity),u_image0:new l.aH(x,s.u_image0),u_image1:new l.aH(x,s.u_image1),u_brightness_low:new l.aI(x,s.u_brightness_low),u_brightness_high:new l.aI(x,s.u_brightness_high),u_saturation_factor:new l.aI(x,s.u_saturation_factor),u_contrast_factor:new l.aI(x,s.u_contrast_factor),u_spin_weights:new l.aN(x,s.u_spin_weights)}),symbolIcon:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texture:new l.aH(x,s.u_texture),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),symbolSDF:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texture:new l.aH(x,s.u_texture),u_gamma_scale:new l.aI(x,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_is_halo:new l.aH(x,s.u_is_halo),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),symbolTextAndIcon:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texsize_icon:new l.aO(x,s.u_texsize_icon),u_texture:new l.aH(x,s.u_texture),u_texture_icon:new l.aH(x,s.u_texture_icon),u_gamma_scale:new l.aI(x,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_is_halo:new l.aH(x,s.u_is_halo),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),background:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_opacity:new l.aI(x,s.u_opacity),u_color:new l.aL(x,s.u_color)}),backgroundPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_opacity:new l.aI(x,s.u_opacity),u_image:new l.aH(x,s.u_image),u_pattern_tl_a:new l.aO(x,s.u_pattern_tl_a),u_pattern_br_a:new l.aO(x,s.u_pattern_br_a),u_pattern_tl_b:new l.aO(x,s.u_pattern_tl_b),u_pattern_br_b:new l.aO(x,s.u_pattern_br_b),u_texsize:new l.aO(x,s.u_texsize),u_mix:new l.aI(x,s.u_mix),u_pattern_size_a:new l.aO(x,s.u_pattern_size_a),u_pattern_size_b:new l.aO(x,s.u_pattern_size_b),u_scale_a:new l.aI(x,s.u_scale_a),u_scale_b:new l.aI(x,s.u_scale_b),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.aI(x,s.u_tile_units_to_pixels)}),terrain:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texture:new l.aH(x,s.u_texture),u_ele_delta:new l.aI(x,s.u_ele_delta),u_fog_matrix:new l.aJ(x,s.u_fog_matrix),u_fog_color:new l.aL(x,s.u_fog_color),u_fog_ground_blend:new l.aI(x,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.aI(x,s.u_fog_ground_blend_opacity),u_horizon_color:new l.aL(x,s.u_horizon_color),u_horizon_fog_blend:new l.aI(x,s.u_horizon_fog_blend)}),terrainDepth:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ele_delta:new l.aI(x,s.u_ele_delta)}),terrainCoords:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texture:new l.aH(x,s.u_texture),u_terrain_coords_id:new l.aI(x,s.u_terrain_coords_id),u_ele_delta:new l.aI(x,s.u_ele_delta)}),sky:(x,s)=>({u_sky_color:new l.aL(x,s.u_sky_color),u_horizon_color:new l.aL(x,s.u_horizon_color),u_horizon:new l.aI(x,s.u_horizon),u_sky_horizon_blend:new l.aI(x,s.u_sky_horizon_blend)})};class Ms{constructor(s,d,f){this.context=s;const m=s.gl;this.buffer=m.createBuffer(),this.dynamicDraw=!!f,this.context.unbindVAO(),s.bindElementBuffer.set(this.buffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.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 t_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class id{constructor(s,d,f,m){this.length=d.length,this.attributes=f,this.itemSize=d.bytesPerElement,this.dynamicDraw=m,this.context=s;const b=s.gl;this.buffer=b.createBuffer(),s.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.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 f=0;f<this.attributes.length;f++){const m=d.attributes[this.attributes[f].name];m!==void 0&&s.enableVertexAttribArray(m)}}setVertexAttribPointers(s,d,f){for(let m=0;m<this.attributes.length;m++){const b=this.attributes[m],M=d.attributes[b.name];M!==void 0&&s.vertexAttribPointer(M,b.components,s[t_[b.type]],!1,this.itemSize,b.offset+this.itemSize*(f||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Uo=new WeakMap;function ho(x){var s;if(Uo.has(x))return Uo.get(x);{const d=(s=x.getParameter(x.VERSION))===null||s===void 0?void 0:s.startsWith("WebGL 2.0");return Uo.set(x,d),d}}class gn{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 gn{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 n_ extends gn{getDefault(){return 1}set(s){(s!==this.current||this.dirty)&&(this.gl.clearDepth(s),this.current=s,this.dirty=!1)}}class Oa extends gn{getDefault(){return 0}set(s){(s!==this.current||this.dirty)&&(this.gl.clearStencil(s),this.current=s,this.dirty=!1)}}class i_ extends gn{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 Qf extends gn{getDefault(){return!0}set(s){(s!==this.current||this.dirty)&&(this.gl.depthMask(s),this.current=s,this.dirty=!1)}}class r_ extends gn{getDefault(){return 255}set(s){(s!==this.current||this.dirty)&&(this.gl.stencilMask(s),this.current=s,this.dirty=!1)}}class em extends gn{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 gn{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 tm extends gn{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 nm extends gn{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 im extends gn{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 rm extends gn{getDefault(){return this.gl.LESS}set(s){(s!==this.current||this.dirty)&&(this.gl.depthFunc(s),this.current=s,this.dirty=!1)}}class Ho extends gn{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 sm extends gn{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 s_ extends gn{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 om extends gn{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 gn{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 o_ extends gn{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 gn{getDefault(){return this.gl.CCW}set(s){(s!==this.current||this.dirty)&&(this.gl.frontFace(s),this.current=s,this.dirty=!1)}}class a_ extends gn{getDefault(){return null}set(s){(s!==this.current||this.dirty)&&(this.gl.useProgram(s),this.current=s,this.dirty=!1)}}class l_ extends gn{getDefault(){return this.gl.TEXTURE0}set(s){(s!==this.current||this.dirty)&&(this.gl.activeTexture(s),this.current=s,this.dirty=!1)}}class am extends gn{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 lm extends gn{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 cm extends gn{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 gn{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 um extends gn{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 gn{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 gn{getDefault(){return null}set(s){var d;if(s===this.current&&!this.dirty)return;const f=this.gl;ho(f)?f.bindVertexArray(s):(d=f.getExtension("OES_vertex_array_object"))===null||d===void 0||d.bindVertexArrayOES(s),this.current=s,this.dirty=!1}}class od extends gn{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 gn{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 gn{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 gn{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 qo 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 c_{constructor(s,d,f,m,b){this.context=s,this.width=d,this.height=f;const M=s.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new cd(s,P),m)this.depthAttachment=b?new ud(s,P):new qo(s,P);else if(b)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 f=this.depthAttachment.get();f&&s.deleteRenderbuffer(f)}s.deleteFramebuffer(this.framebuffer)}}class Jn{constructor(s,d,f){this.blendFunction=s,this.blendColor=d,this.mask=f}}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 u_{constructor(s){var d,f;if(this.gl=s,this.clearColor=new lu(this),this.clearDepth=new n_(this),this.clearStencil=new Oa(this),this.colorMask=new i_(this),this.depthMask=new Qf(this),this.stencilMask=new r_(this),this.stencilFunc=new em(this),this.stencilOp=new rd(this),this.stencilTest=new tm(this),this.depthRange=new nm(this),this.depthTest=new im(this),this.depthFunc=new rm(this),this.blend=new Ho(this),this.blendFunc=new sm(this),this.blendColor=new s_(this),this.blendEquation=new om(this),this.cullFace=new $l(this),this.cullFaceSide=new o_(this),this.frontFace=new cu(this),this.program=new a_(this),this.activeTexture=new l_(this),this.viewport=new am(this),this.bindFramebuffer=new lm(this),this.bindRenderbuffer=new cm(this),this.bindTexture=new sd(this),this.bindVertexBuffer=new um(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 m=s.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(d=s.RGBA16F)!==null&&d!==void 0?d:m==null?void 0:m.RGBA16F_EXT,this.RGB16F=(f=s.RGB16F)!==null&&f!==void 0?f:m==null?void 0:m.RGB16F_EXT,s.getExtension("EXT_color_buffer_float")}else{s.getExtension("EXT_color_buffer_half_float"),s.getExtension("OES_texture_half_float_linear");const m=s.getExtension("OES_texture_half_float");this.HALF_FLOAT=m==null?void 0:m.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,f){return new id(this,s,d,f)}createRenderbuffer(s,d,f){const m=this.gl,b=m.createRenderbuffer();return this.bindRenderbuffer.set(b),m.renderbufferStorage(m.RENDERBUFFER,s,d,f),this.bindRenderbuffer.set(null),b}createFramebuffer(s,d,f,m){return new c_(this,s,d,f,m)}clear({color:s,depth:d,stencil:f}){const m=this.gl;let b=0;s&&(b|=m.COLOR_BUFFER_BIT,this.clearColor.set(s),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(b|=m.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),f!==void 0&&(b|=m.STENCIL_BUFFER_BIT,this.clearStencil.set(f),this.stencilMask.set(255)),m.clear(b)}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 Ht{constructor(s,d,f){this.func=s,this.mask=d,this.range=f}}Ht.ReadOnly=!1,Ht.ReadWrite=!0,Ht.disabled=new Ht(519,Ht.ReadOnly,[0,1]);const du=7680;class Dn{constructor(s,d,f,m,b,M){this.test=s,this.ref=d,this.mask=f,this.fail=m,this.depthFail=b,this.pass=M}}Dn.disabled=new Dn({func:519,mask:0},0,0,du,du,du);class Cn{constructor(s,d,f){this.enable=s,this.mode=d,this.frontFace=f}}let Wo;function jl(x,s,d,f,m){const b=x.context,M=b.gl,P=x.useProgram("collisionBox"),D=[];let L=0,B=0;for(let ce=0;ce<f.length;ce++){const he=f[ce],te=s.getTile(he).getBucket(d);if(!te)continue;const me=m?te.textCollisionBox:te.iconCollisionBox,ge=te.collisionCircleArray;if(ge.length>0){const xe=l.H();l.aQ(xe,te.placementInvProjMatrix,x.transform.glCoordMatrix),l.aQ(xe,xe,te.placementViewportMatrix),D.push({circleArray:ge,circleOffset:B,transform:he.posMatrix,invTransform:xe,coord:he}),L+=ge.length/4,B=L}me&&P.draw(b,M.LINES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,{u_matrix:he.posMatrix,u_pixel_extrude_scale:[1/(F=x.transform).width,1/F.height]},x.style.map.terrain&&x.style.map.terrain.getTerrainData(he),d.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,x.transform.zoom,null,null,me.collisionVertexBuffer)}var F;if(!m||!D.length)return;const W=x.useProgram("collisionCircle"),K=new l.aR;K.resize(4*L),K._trim();let Q=0;for(const ce of D)for(let he=0;he<ce.circleArray.length/4;he++){const te=4*he,me=ce.circleArray[te+0],ge=ce.circleArray[te+1],xe=ce.circleArray[te+2],Oe=ce.circleArray[te+3];K.emplace(Q++,me,ge,xe,Oe,0),K.emplace(Q++,me,ge,xe,Oe,1),K.emplace(Q++,me,ge,xe,Oe,2),K.emplace(Q++,me,ge,xe,Oe,3)}(!Wo||Wo.length<2*L)&&(Wo=function(ce){const he=2*ce,te=new l.aT;te.resize(he),te._trim();for(let me=0;me<he;me++){const ge=6*me;te.uint16[ge+0]=4*me+0,te.uint16[ge+1]=4*me+1,te.uint16[ge+2]=4*me+2,te.uint16[ge+3]=4*me+2,te.uint16[ge+4]=4*me+3,te.uint16[ge+5]=4*me+0}return te}(L));const re=b.createIndexBuffer(Wo,!0),le=b.createVertexBuffer(K,l.aS.members,!0);for(const ce of D){const he=jo(ce.transform,ce.invTransform,x.transform);W.draw(b,M.TRIANGLES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,he,x.style.map.terrain&&x.style.map.terrain.getTerrainData(ce.coord),d.id,le,re,l.a0.simpleSegment(0,2*ce.circleOffset,ce.circleArray.length,ce.circleArray.length/2),null,x.transform.zoom,null,null,null)}le.destroy(),re.destroy()}Cn.disabled=new Cn(!1,1029,2305),Cn.backCCW=new Cn(!0,1029,2305);const Ul=l.an(new Float32Array(16));function hd(x,s,d,f,m,b){const{horizontalAlign:M,verticalAlign:P}=l.au(x);return new l.P((-(M-.5)*s/m+f[0])*b,(-(P-.5)*d/m+f[1])*b)}function Go(x,s,d,f,m,b){const M=s.tileAnchorPoint.add(new l.P(s.translation[0],s.translation[1]));if(s.pitchWithMap){let P=f.mult(b);d||(P=P.rotate(-m));const D=M.add(P);return se(D.x,D.y,s.labelPlaneMatrix,s.getElevation).point}if(d){const P=Te(s.tileAnchorPoint.x+1,s.tileAnchorPoint.y,s).point.sub(x),D=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return x.add(f.rotate(D))}return x.add(f)}function za(x,s,d,f,m,b,M,P,D,L,B,F,W,K){const Q=x.text.placedSymbolArray,re=x.text.dynamicLayoutVertexArray,le=x.icon.dynamicLayoutVertexArray,ce={};re.clear();for(let he=0;he<Q.length;he++){const te=Q.get(he),me=te.hidden||!te.crossTileID||x.allowVerticalPlacement&&!te.placedOrientation?null:f[te.crossTileID];if(me){const ge=new l.P(te.anchorX,te.anchorY),xe={getElevation:K,width:m.width,height:m.height,labelPlaneMatrix:b,lineVertexArray:null,pitchWithMap:d,projection:B,projectionCache:null,tileAnchorPoint:ge,translation:F,unwrappedTileID:W},Oe=d?se(ge.x,ge.y,M,K):Te(ge.x,ge.y,xe),Fe=U(m.cameraToCenterDistance,Oe.signedDistanceFromCamera);let Ke=l.ai(x.textSizeData,D,te)*Fe/l.ap;d&&(Ke*=x.tilePixelRatio/P);const{width:nt,height:We,anchor:He,textOffset:pt,textBoxScale:Ot}=me,Ge=hd(He,nt,We,pt,Ot,Ke),et=B.getPitchedTextCorrection(m,ge.add(new l.P(F[0],F[1])),W),Pt=Go(Oe.point,xe,s,Ge,m.angle,et),Nn=x.allowVerticalPlacement&&te.placedOrientation===l.ah.vertical?Math.PI/2:0;for(let Ft=0;Ft<te.numGlyphs;Ft++)l.aj(re,Pt,Nn);L&&te.associatedIconIndex>=0&&(ce[te.associatedIconIndex]={shiftedAnchor:Pt,angle:Nn})}else kt(te.numGlyphs,re)}if(L){le.clear();const he=x.icon.placedSymbolArray;for(let te=0;te<he.length;te++){const me=he.get(te);if(me.hidden)kt(me.numGlyphs,le);else{const ge=ce[te];if(ge)for(let xe=0;xe<me.numGlyphs;xe++)l.aj(le,ge.shiftedAnchor,ge.angle);else kt(me.numGlyphs,le)}}x.icon.dynamicLayoutVertexBuffer.updateData(le)}x.text.dynamicLayoutVertexBuffer.updateData(re)}function Lr(x,s,d){return d.iconsInText&&s?"symbolTextAndIcon":x?"symbolSDF":"symbolIcon"}function dd(x,s,d,f,m,b,M,P,D,L,B,F){const W=x.context,K=W.gl,Q=x.transform,re=Vo(),le=P==="map",ce=D==="map",he=P!=="viewport"&&d.layout.get("symbol-placement")!=="point",te=le&&!ce&&!he,me=!ce&&he,ge=!d.layout.get("symbol-sort-key").isConstant();let xe=!1;const Oe=x.depthModeForSublayer(0,Ht.ReadOnly),Fe=d._unevaluatedLayout.hasValue("text-variable-anchor")||d._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ke=[],nt=re.getCircleRadiusCorrection(Q);for(const We of f){const He=s.getTile(We),pt=He.getBucket(d);if(!pt)continue;const Ot=m?pt.text:pt.icon;if(!Ot||!Ot.segments.get().length||!Ot.hasVisibleVertices)continue;const Ge=Ot.programConfigurations.get(d.id),et=m||pt.sdfIcons,Pt=m?pt.textSizeData:pt.iconSizeData,Nn=ce||Q.pitch!==0,Ft=x.useProgram(Lr(et,m,pt),Ge),Yt=l.ag(Pt,Q.zoom),Bn=x.style.map.terrain&&x.style.map.terrain.getTerrainData(We);let Ii,ns,Fn,rr,qi=[0,0],Di=null;if(m)ns=He.glyphAtlasTexture,Fn=K.LINEAR,Ii=He.glyphAtlasTexture.size,pt.iconsInText&&(qi=He.imageAtlasTexture.size,Di=He.imageAtlasTexture,rr=Nn||x.options.rotating||x.options.zooming||Pt.kind==="composite"||Pt.kind==="camera"?K.LINEAR:K.NEAREST);else{const Qt=d.layout.get("icon-size").constantOr(0)!==1||pt.iconsNeedLinear;ns=He.imageAtlasTexture,Fn=et||x.options.rotating||x.options.zooming||Qt||Nn?K.LINEAR:K.NEAREST,Ii=He.imageAtlasTexture.size}const Wi=Zt(He,1,x.transform.zoom),Is=me?We.posMatrix:Ul,Xa=Ui(Is,ce,le,x.transform,Wi),Iu=pr(Is,ce,le,x.transform,Wi),Ka=pr(We.posMatrix,ce,le,x.transform,Wi),Fr=re.translatePosition(x.transform,He,b,M),Du=Fe&&pt.hasTextData(),Nd=d.layout.get("icon-text-fit")!=="none"&&Du&&pt.hasIconData();if(he){const Qt=x.style.map.terrain?(Ja,Qa)=>x.style.map.terrain.getElevation(We,Ja,Qa):null,Jo=d.layout.get("text-rotation-alignment")==="map";Y(pt,We.posMatrix,x,m,Xa,Ka,ce,L,Jo,re,We.toUnwrapped(),Q.width,Q.height,Fr,Qt)}const Vr=We.posMatrix,$r=m&&Fe||Nd,po=he||$r?Ul:Xa,is=Iu,ki=et&&d.paint.get(m?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Oi;Oi=et?pt.iconsInText?ed(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,Ii,qi,nt):Vl(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,m,Ii,!0,nt):Jf(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,m,Ii,nt);const br={program:Ft,buffers:Ot,uniformValues:Oi,atlasTexture:ns,atlasTextureIcon:Di,atlasInterpolation:Fn,atlasInterpolationIcon:rr,isSDF:et,hasHalo:ki};if(ge&&pt.canOverlap){xe=!0;const Qt=Ot.segments.get();for(const Jo of Qt)Ke.push({segments:new l.a0([Jo]),sortKey:Jo.sortKey,state:br,terrainData:Bn})}else Ke.push({segments:Ot.segments,sortKey:0,state:br,terrainData:Bn})}xe&&Ke.sort((We,He)=>We.sortKey-He.sortKey);for(const We of Ke){const He=We.state;if(W.activeTexture.set(K.TEXTURE0),He.atlasTexture.bind(He.atlasInterpolation,K.CLAMP_TO_EDGE),He.atlasTextureIcon&&(W.activeTexture.set(K.TEXTURE1),He.atlasTextureIcon&&He.atlasTextureIcon.bind(He.atlasInterpolationIcon,K.CLAMP_TO_EDGE)),He.isSDF){const pt=He.uniformValues;He.hasHalo&&(pt.u_is_halo=1,pd(He.buffers,We.segments,d,x,He.program,Oe,B,F,pt,We.terrainData)),pt.u_is_halo=0}pd(He.buffers,We.segments,d,x,He.program,Oe,B,F,He.uniformValues,We.terrainData)}}function pd(x,s,d,f,m,b,M,P,D,L){const B=f.context;m.draw(B,B.gl.TRIANGLES,b,M,P,Cn.disabled,D,L,d.id,x.layoutVertexBuffer,x.indexBuffer,s,d.paint,f.transform.zoom,x.programConfigurations.get(d.id),x.dynamicLayoutVertexBuffer,x.opacityVertexBuffer)}function fd(x,s,d,f){const m=x.context,b=m.gl,M=Dn.disabled,P=new Jn([b.ONE,b.ONE],l.aM.transparent,[!0,!0,!0,!0]),D=s.getBucket(d);if(!D)return;const L=f.key;let B=d.heatmapFbos.get(L);B||(B=Hl(m,s.tileSize,s.tileSize),d.heatmapFbos.set(L,B)),m.bindFramebuffer.set(B.framebuffer),m.viewport.set([0,0,s.tileSize,s.tileSize]),m.clear({color:l.aM.transparent});const F=D.programConfigurations.get(d.id),W=x.useProgram("heatmap",F),K=x.style.map.terrain.getTerrainData(f);W.draw(m,b.TRIANGLES,Ht.disabled,M,P,Cn.disabled,ir(f.posMatrix,s,x.transform.zoom,d.paint.get("heatmap-intensity")),K,d.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,d.paint,x.transform.zoom,F)}function Zo(x,s,d){const f=x.context,m=f.gl;f.setColorMode(x.colorModeForRenderPass());const b=ql(f,s),M=d.key,P=s.heatmapFbos.get(M);P&&(f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,P.colorAttachment.get()),f.activeTexture.set(m.TEXTURE1),b.bind(m.LINEAR,m.CLAMP_TO_EDGE),x.useProgram("heatmapTexture").draw(f,m.TRIANGLES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,ru(x,s,0,1),null,s.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments,s.paint,x.transform.zoom),P.destroy(),s.heatmapFbos.delete(M))}function Hl(x,s,d){var f,m;const b=x.gl,M=b.createTexture();b.bindTexture(b.TEXTURE_2D,M),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);const P=(f=x.HALF_FLOAT)!==null&&f!==void 0?f:b.UNSIGNED_BYTE,D=(m=x.RGBA16F)!==null&&m!==void 0?m:b.RGBA;b.texImage2D(b.TEXTURE_2D,0,D,s,d,0,b.RGBA,P,null);const L=x.createFramebuffer(s,d,!1,!1);return L.colorAttachment.set(M),L}function ql(x,s){return s.colorRampTexture||(s.colorRampTexture=new it(x,s.colorRamp,x.gl.RGBA)),s.colorRampTexture}function Ra(x,s,d,f,m){if(!d||!f||!f.imageAtlas)return;const b=f.imageAtlas.patternPositions;let M=b[d.to.toString()],P=b[d.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const D=m.getPaintProperty(s);M=b[D],P=b[D]}M&&P&&x.setConstantPatternPositions(M,P)}function Wl(x,s,d,f,m,b,M){const P=x.context.gl,D="fill-pattern",L=d.paint.get(D),B=L&&L.constantOr(1),F=d.getCrossfadeParameters();let W,K,Q,re,le;M?(K=B&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",W=P.LINES):(K=B?"fillPattern":"fill",W=P.TRIANGLES);const ce=L.constantOr(null);for(const he of f){const te=s.getTile(he);if(B&&!te.patternsLoaded())continue;const me=te.getBucket(d);if(!me)continue;const ge=me.programConfigurations.get(d.id),xe=x.useProgram(K,ge),Oe=x.style.map.terrain&&x.style.map.terrain.getTerrainData(he);B&&(x.context.activeTexture.set(P.TEXTURE0),te.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ge.updatePaintBuffers(F)),Ra(ge,D,ce,te,d);const Fe=Oe?he:null,Ke=x.translatePosMatrix(Fe?Fe.posMatrix:he.posMatrix,te,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(M){re=me.indexBuffer2,le=me.segments2;const nt=[P.drawingBufferWidth,P.drawingBufferHeight];Q=K==="fillOutlinePattern"&&B?Zf(Ke,x,F,te,nt):X0(Ke,nt)}else re=me.indexBuffer,le=me.segments,Q=B?Gf(Ke,x,F,te):Ia(Ke);xe.draw(x.context,W,m,x.stencilModeForClipping(he),b,Cn.disabled,Q,Oe,d.id,me.layoutVertexBuffer,re,le,d.paint,x.transform.zoom,ge)}}function pu(x,s,d,f,m,b,M){const P=x.context,D=P.gl,L="fill-extrusion-pattern",B=d.paint.get(L),F=B.constantOr(1),W=d.getCrossfadeParameters(),K=d.paint.get("fill-extrusion-opacity"),Q=B.constantOr(null);for(const re of f){const le=s.getTile(re),ce=le.getBucket(d);if(!ce)continue;const he=x.style.map.terrain&&x.style.map.terrain.getTerrainData(re),te=ce.programConfigurations.get(d.id),me=x.useProgram(F?"fillExtrusionPattern":"fillExtrusion",te);F&&(x.context.activeTexture.set(D.TEXTURE0),le.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),te.updatePaintBuffers(W)),Ra(te,L,Q,le,d);const ge=x.translatePosMatrix(re.posMatrix,le,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),xe=d.paint.get("fill-extrusion-vertical-gradient"),Oe=F?iu(ge,x,xe,K,re,W,le):Bl(ge,x,xe,K);me.draw(P,P.gl.TRIANGLES,m,b,M,Cn.backCCW,Oe,he,d.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,d.paint,x.transform.zoom,te,x.style.map.terrain&&ce.centroidVertexBuffer)}}function La(x,s,d,f,m,b,M){const P=x.context,D=P.gl,L=d.fbo;if(!L)return;const B=x.useProgram("hillshade"),F=x.style.map.terrain&&x.style.map.terrain.getTerrainData(s);P.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,L.colorAttachment.get()),B.draw(P,D.TRIANGLES,m,b,M,Cn.disabled,((W,K,Q,re)=>{const le=Q.paint.get("hillshade-shadow-color"),ce=Q.paint.get("hillshade-highlight-color"),he=Q.paint.get("hillshade-accent-color");let te=Q.paint.get("hillshade-illumination-direction")*(Math.PI/180);Q.paint.get("hillshade-illumination-anchor")==="viewport"&&(te-=W.transform.angle);const me=!W.options.moving;return{u_matrix:re?re.posMatrix:W.transform.calculatePosMatrix(K.tileID.toUnwrapped(),me),u_image:0,u_latrange:su(0,K.tileID),u_light:[Q.paint.get("hillshade-exaggeration"),te],u_shadow:le,u_highlight:ce,u_accent:he}})(x,d,f,F?s:null),F,f.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments)}function Na(x,s,d,f,m,b){const M=x.context,P=M.gl,D=s.dem;if(D&&D.data){const L=D.dim,B=D.stride,F=D.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),s.demTexture=s.demTexture||x.getTileTexture(B),s.demTexture){const K=s.demTexture;K.update(F,{premultiply:!1}),K.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else s.demTexture=new it(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 K=new it(M,{width:L,height:L,data:null},P.RGBA);K.bind(P.LINEAR,P.CLAMP_TO_EDGE),W=s.fbo=M.createFramebuffer(L,L,!0,!1),W.colorAttachment.set(K.texture)}M.bindFramebuffer.set(W.framebuffer),M.viewport.set([0,0,L,L]),x.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,f,m,b,Cn.disabled,((K,Q)=>{const re=Q.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:[re,re],u_zoom:K.overscaledZ,u_unpack:Q.getUnpackVector()}})(s.tileID,D),null,d.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments),s.needsHillshadePrepare=!1}}function hm(x,s,d,f,m,b){const M=f.paint.get("raster-fade-duration");if(!b&&M>0){const P=E.now(),D=(P-x.timeAdded)/M,L=s?(P-s.timeAdded)/M:-1,B=d.getSource(),F=m.coveringZoomLevel({tileSize:B.tileSize,roundZoom:B.roundZoom}),W=!s||Math.abs(s.tileID.overscaledZ-F)>Math.abs(x.tileID.overscaledZ-F),K=W&&x.refreshedUponExpiration?1:l.ac(W?D:1-L,0,1);return x.refreshedUponExpiration&&D>=1&&(x.refreshedUponExpiration=!1),s?{opacity:1,mix:1-K}:{opacity:K,mix:0}}return{opacity:1,mix:0}}const md=new l.aM(1,0,0,1),cn=new l.aM(0,1,0,1),fu=new l.aM(0,0,1,1),h_=new l.aM(1,0,1,1),dm=new l.aM(0,1,1,1);function Ba(x,s,d,f){mu(x,0,s+d/2,x.transform.width,d,f)}function pm(x,s,d,f){mu(x,s-d/2,0,d,x.transform.height,f)}function mu(x,s,d,f,m,b){const M=x.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(s*x.pixelRatio,d*x.pixelRatio,f*x.pixelRatio,m*x.pixelRatio),M.clear({color:b}),P.disable(P.SCISSOR_TEST)}function fm(x,s,d){const f=x.context,m=f.gl,b=d.posMatrix,M=x.useProgram("debug"),P=Ht.disabled,D=Dn.disabled,L=x.colorModeForRenderPass(),B="$debug",F=x.style.map.terrain&&x.style.map.terrain.getTerrainData(d);f.activeTexture.set(m.TEXTURE0);const W=s.getTileByID(d.key).latestRawTileData,K=Math.floor((W&&W.byteLength||0)/1024),Q=s.getTile(d).tileSize,re=512/Math.min(Q,512)*(d.overscaledZ/x.transform.zoom)*.5;let le=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(le+=` => ${d.overscaledZ}`),function(ce,he){ce.initDebugOverlayCanvas();const te=ce.debugOverlayCanvas,me=ce.context.gl,ge=ce.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,te.width,te.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(te),ce.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(x,`${le} ${K}kB`),M.draw(f,m.TRIANGLES,P,D,Jn.alphaBlended,Cn.disabled,Fl(b,l.aM.transparent,re),null,B,x.debugBuffer,x.quadTriangleIndexBuffer,x.debugSegments),M.draw(f,m.LINE_STRIP,P,D,L,Cn.disabled,Fl(b,l.aM.red),F,B,x.debugBuffer,x.tileBorderIndexBuffer,x.debugSegments)}function mm(x,s,d){const f=x.context,m=f.gl,b=x.colorModeForRenderPass(),M=new Ht(m.LEQUAL,Ht.ReadWrite,x.depthRangeFor3D),P=x.useProgram("terrain"),D=s.getTerrainMesh();f.bindFramebuffer.set(null),f.viewport.set([0,0,x.width,x.height]);for(const L of d){const B=x.renderToTexture.getTexture(L),F=s.getTerrainData(L.tileID);f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,B.texture);const W=x.transform.calculatePosMatrix(L.tileID.toUnwrapped()),K=s.getMeshFrameDelta(x.transform.zoom),Q=x.transform.calculateFogMatrix(L.tileID.toUnwrapped()),re=Jh(W,K,Q,x.style.sky,x.transform.pitch);P.draw(f,m.TRIANGLES,M,Dn.disabled,b,Cn.backCCW,re,F,"terrain",D.vertexBuffer,D.indexBuffer,D.segments)}}class gu{constructor(s,d,f){this.vertexBuffer=s,this.indexBuffer=d,this.segments=f}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 u_(s),this.transform=d,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Re.maxUnderzooming+Re.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Xh}resize(s,d,f){if(this.width=Math.floor(s*f),this.height=Math.floor(d*f),this.pixelRatio=f,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const m of this.style._order)this.style._layers[m].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,$o.members),this.tileExtentSegments=l.a0.simpleSegment(0,0,4,2);const f=new l.aX;f.emplaceBack(0,0),f.emplaceBack(l.X,0),f.emplaceBack(0,l.X),f.emplaceBack(l.X,l.X),this.debugBuffer=s.createVertexBuffer(f,$o.members),this.debugSegments=l.a0.simpleSegment(0,0,4,5);const m=new l.$;m.emplaceBack(0,0,0,0),m.emplaceBack(l.X,0,l.X,0),m.emplaceBack(0,l.X,0,l.X),m.emplaceBack(l.X,l.X,l.X,l.X),this.rasterBoundsBuffer=s.createVertexBuffer(m,tr.members),this.rasterBoundsSegments=l.a0.simpleSegment(0,0,4,2);const b=new l.aX;b.emplaceBack(0,0),b.emplaceBack(1,0),b.emplaceBack(0,1),b.emplaceBack(1,1),this.viewportBuffer=s.createVertexBuffer(b,$o.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 D=this.context.gl;this.stencilClearMode=new Dn({func:D.ALWAYS,mask:0},0,255,D.ZERO,D.ZERO,D.ZERO)}clearStencil(){const s=this.context,d=s.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const f=l.H();l.aP(f,0,this.width,this.height,0,0,1),l.K(f,f,[d.drawingBufferWidth,d.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(s,d.TRIANGLES,Ht.disabled,this.stencilClearMode,Jn.disabled,Cn.disabled,nr(f),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 f=this.context,m=f.gl;this.nextStencilID+d.length>256&&this.clearStencil(),f.setColorMode(Jn.disabled),f.setDepthMode(Ht.disabled);const b=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of d){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,D=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);b.draw(f,m.TRIANGLES,Ht.disabled,new Dn({func:m.ALWAYS,mask:0},P,255,m.KEEP,m.KEEP,m.REPLACE),Jn.disabled,Cn.disabled,nr(M.posMatrix),D,"$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 Dn({func:d.NOTEQUAL,mask:255},s,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(s){const d=this.context.gl;return new Dn({func:d.EQUAL,mask:255},this._tileClippingMaskIDs[s.key],0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(s){const d=this.context.gl,f=s.sort((M,P)=>P.overscaledZ-M.overscaledZ),m=f[f.length-1].overscaledZ,b=f[0].overscaledZ-m+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();const M={};for(let P=0;P<b;P++)M[P+m]=new Dn({func:d.GEQUAL,mask:255},P+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=b,[M,f]}return[{[m]:Dn.disabled},f]}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,f){if(!this.opaquePassEnabledForLayer())return Ht.disabled;const m=1-((1+this.currentLayer)*this.numSublayers+s)*this.depthEpsilon;return new Ht(f||this.context.gl.LEQUAL,d,[m,m])}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 f=this.style._order,m=this.style.sourceCaches,b={},M={},P={};for(const D in m){const L=m[D];L.used&&L.prepare(this.context),b[D]=L.getVisibleCoordinates(),M[D]=b[D].slice().reverse(),P[D]=L.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let D=0;D<f.length;D++)if(this.style._layers[f[D]].is3D()){this.opaquePassCutoff=D;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const D of f){const L=this.style._layers[D];if(!L.hasOffscreenPass()||L.isHidden(this.transform.zoom))continue;const B=M[L.source];(L.type==="custom"||B.length)&&this.renderLayer(this,m[L.source],L,B)}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(D,L){const B=D.context,F=B.gl,W=((ce,he,te)=>({u_sky_color:ce.properties.get("sky-color"),u_horizon_color:ce.properties.get("horizon-color"),u_horizon:(he.height/2+he.getHorizon())*te,u_sky_horizon_blend:ce.properties.get("sky-horizon-blend")*he.height/2*te}))(L,D.style.map.transform,D.pixelRatio),K=new Ht(F.LEQUAL,Ht.ReadWrite,[0,1]),Q=Dn.disabled,re=D.colorModeForRenderPass(),le=D.useProgram("sky");if(!L.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),L.mesh=new gu(B.createVertexBuffer(ce,$o.members),B.createIndexBuffer(he),l.a0.simpleSegment(0,0,ce.length,he.length))}le.draw(B,F.TRIANGLES,K,Q,re,Cn.disabled,W,void 0,"sky",L.mesh.vertexBuffer,L.mesh.indexBuffer,L.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=f.length-1;this.currentLayer>=0;this.currentLayer--){const D=this.style._layers[f[this.currentLayer]],L=m[D.source],B=b[D.source];this._renderTileClippingMasks(D,B),this.renderLayer(this,L,D,B)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<f.length;this.currentLayer++){const D=this.style._layers[f[this.currentLayer]],L=m[D.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(D))continue;const B=(D.type==="symbol"?P:M)[D.source];this._renderTileClippingMasks(D,b[D.source]),this.renderLayer(this,L,D,B)}if(this.options.showTileBoundaries){const D=function(L,B){let F=null;const W=Object.values(L._layers).flatMap(le=>le.source&&!le.isHidden(B)?[L.sourceCaches[le.source]]:[]),K=W.filter(le=>le.getSource().type==="vector"),Q=W.filter(le=>le.getSource().type!=="vector"),re=le=>{(!F||F.getSource().maxzoom<le.getSource().maxzoom)&&(F=le)};return K.forEach(le=>re(le)),F||Q.forEach(le=>re(le)),F}(this.style,this.transform.zoom);D&&function(L,B,F){for(let W=0;W<F.length;W++)fm(L,B,F[W])}(this,D,D.getVisibleCoordinates())}this.options.showPadding&&function(D){const L=D.transform.padding;Ba(D,D.transform.height-(L.top||0),3,md),Ba(D,L.bottom||0,3,cn),pm(D,L.left||0,3,fu),pm(D,D.transform.width-(L.right||0),3,h_);const B=D.transform.centerPoint;(function(F,W,K,Q){mu(F,W-1,K-10,2,20,Q),mu(F,W-10,K-1,20,2,Q)})(D,B.x,D.transform.height-B.y,dm)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(s){if(!this.style||!this.style.map||!this.style.map.terrain)return;const d=this.terrainFacilitator.matrix,f=this.transform.modelViewProjectionMatrix;let m=this.terrainFacilitator.dirty;m||(m=s?!l.a_(d,f):!l.a$(d,f)),m||(m=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),m&&(l.b0(d,f),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(b,M){const P=b.context,D=P.gl,L=Jn.unblended,B=new Ht(D.LEQUAL,Ht.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.sourceCache.getRenderableTiles(),K=b.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1});for(const Q of W){const re=M.getTerrainData(Q.tileID),le={u_matrix:b.transform.calculatePosMatrix(Q.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(b.transform.zoom)};K.draw(P,D.TRIANGLES,B,Dn.disabled,L,Cn.backCCW,le,re,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain),function(b,M){const P=b.context,D=P.gl,L=Jn.unblended,B=new Ht(D.LEQUAL,Ht.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.getCoordsTexture(),K=M.sourceCache.getRenderableTiles(),Q=b.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1}),M.coordsIndex=[];for(const re of K){const le=M.getTerrainData(re.tileID);P.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,W.texture);const ce={u_matrix:b.transform.calculatePosMatrix(re.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(b.transform.zoom)};Q.draw(P,D.TRIANGLES,B,Dn.disabled,L,Cn.backCCW,ce,le,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),M.coordsIndex.push(re.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain))}renderLayer(s,d,f,m){if(!f.isHidden(this.transform.zoom)&&(f.type==="background"||f.type==="custom"||(m||[]).length))switch(this.id=f.id,f.type){case"symbol":(function(b,M,P,D,L){if(b.renderPass!=="translucent")return;const B=Dn.disabled,F=b.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(W,K,Q,re,le,ce,he,te,me){const ge=K.transform,xe=Vo(),Oe=le==="map",Fe=ce==="map";for(const Ke of W){const nt=re.getTile(Ke),We=nt.getBucket(Q);if(!We||!We.text||!We.text.segments.get().length)continue;const He=l.ag(We.textSizeData,ge.zoom),pt=Zt(nt,1,K.transform.zoom),Ot=Ui(Ke.posMatrix,Fe,Oe,K.transform,pt),Ge=Q.layout.get("icon-text-fit")!=="none"&&We.hasIconData();if(He){const et=Math.pow(2,ge.zoom-nt.tileID.overscaledZ),Pt=K.style.map.terrain?(Ft,Yt)=>K.style.map.terrain.getElevation(Ke,Ft,Yt):null,Nn=xe.translatePosition(ge,nt,he,te);za(We,Oe,Fe,me,ge,Ot,Ke.posMatrix,et,He,Ge,xe,Nn,Ke.toUnwrapped(),Pt)}}}(D,b,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"),L),P.paint.get("icon-opacity").constantOr(1)!==0&&dd(b,M,P,D,!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"),B,F),P.paint.get("text-opacity").constantOr(1)!==0&&dd(b,M,P,D,!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"),B,F),M.map.showCollisionBoxes&&(jl(b,M,P,D,!0),jl(b,M,P,D,!1))})(s,d,f,m,this.style.placement.variableOffsets);break;case"circle":(function(b,M,P,D){if(b.renderPass!=="translucent")return;const L=P.paint.get("circle-opacity"),B=P.paint.get("circle-stroke-width"),F=P.paint.get("circle-stroke-opacity"),W=!P.layout.get("circle-sort-key").isConstant();if(L.constantOr(1)===0&&(B.constantOr(1)===0||F.constantOr(1)===0))return;const K=b.context,Q=K.gl,re=b.depthModeForSublayer(0,Ht.ReadOnly),le=Dn.disabled,ce=b.colorModeForRenderPass(),he=[];for(let te=0;te<D.length;te++){const me=D[te],ge=M.getTile(me),xe=ge.getBucket(P);if(!xe)continue;const Oe=xe.programConfigurations.get(P.id),Fe=b.useProgram("circle",Oe),Ke=xe.layoutVertexBuffer,nt=xe.indexBuffer,We=b.style.map.terrain&&b.style.map.terrain.getTerrainData(me),He={programConfiguration:Oe,program:Fe,layoutVertexBuffer:Ke,indexBuffer:nt,uniformValues:K0(b,me,ge,P),terrainData:We};if(W){const pt=xe.segments.get();for(const Ot of pt)he.push({segments:new l.a0([Ot]),sortKey:Ot.sortKey,state:He})}else he.push({segments:xe.segments,sortKey:0,state:He})}W&&he.sort((te,me)=>te.sortKey-me.sortKey);for(const te of he){const{programConfiguration:me,program:ge,layoutVertexBuffer:xe,indexBuffer:Oe,uniformValues:Fe,terrainData:Ke}=te.state;ge.draw(K,Q.TRIANGLES,re,le,ce,Cn.disabled,Fe,Ke,P.id,xe,Oe,te.segments,P.paint,b.transform.zoom,me)}})(s,d,f,m);break;case"heatmap":(function(b,M,P,D){if(P.paint.get("heatmap-opacity")===0)return;const L=b.context;if(b.style.map.terrain){for(const B of D){const F=M.getTile(B);M.hasRenderableParent(B)||(b.renderPass==="offscreen"?fd(b,F,P,B):b.renderPass==="translucent"&&Zo(b,P,B))}L.viewport.set([0,0,b.width,b.height])}else b.renderPass==="offscreen"?function(B,F,W,K){const Q=B.context,re=Q.gl,le=Dn.disabled,ce=new Jn([re.ONE,re.ONE],l.aM.transparent,[!0,!0,!0,!0]);(function(he,te,me){const ge=he.gl;he.activeTexture.set(ge.TEXTURE1),he.viewport.set([0,0,te.width/4,te.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,te.width/4,te.height/4),me.heatmapFbos.set(l.aU,xe))})(Q,B,W),Q.clear({color:l.aM.transparent});for(let he=0;he<K.length;he++){const te=K[he];if(F.hasRenderableParent(te))continue;const me=F.getTile(te),ge=me.getBucket(W);if(!ge)continue;const xe=ge.programConfigurations.get(W.id),Oe=B.useProgram("heatmap",xe),{zoom:Fe}=B.transform;Oe.draw(Q,re.TRIANGLES,Ht.disabled,le,ce,Cn.disabled,ir(te.posMatrix,me,Fe,W.paint.get("heatmap-intensity")),null,W.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,W.paint,B.transform.zoom,xe)}Q.viewport.set([0,0,B.width,B.height])}(b,M,P,D):b.renderPass==="translucent"&&function(B,F){const W=B.context,K=W.gl;W.setColorMode(B.colorModeForRenderPass());const Q=F.heatmapFbos.get(l.aU);Q&&(W.activeTexture.set(K.TEXTURE0),K.bindTexture(K.TEXTURE_2D,Q.colorAttachment.get()),W.activeTexture.set(K.TEXTURE1),ql(W,F).bind(K.LINEAR,K.CLAMP_TO_EDGE),B.useProgram("heatmapTexture").draw(W,K.TRIANGLES,Ht.disabled,Dn.disabled,B.colorModeForRenderPass(),Cn.disabled,ru(B,F,0,1),null,F.id,B.viewportBuffer,B.quadTriangleIndexBuffer,B.viewportSegments,F.paint,B.transform.zoom))}(b,P)})(s,d,f,m);break;case"line":(function(b,M,P,D){if(b.renderPass!=="translucent")return;const L=P.paint.get("line-opacity"),B=P.paint.get("line-width");if(L.constantOr(1)===0||B.constantOr(1)===0)return;const F=b.depthModeForSublayer(0,Ht.ReadOnly),W=b.colorModeForRenderPass(),K=P.paint.get("line-dasharray"),Q=P.paint.get("line-pattern"),re=Q.constantOr(1),le=P.paint.get("line-gradient"),ce=P.getCrossfadeParameters(),he=re?"linePattern":K?"lineSDF":le?"lineGradient":"line",te=b.context,me=te.gl;let ge=!0;for(const xe of D){const Oe=M.getTile(xe);if(re&&!Oe.patternsLoaded())continue;const Fe=Oe.getBucket(P);if(!Fe)continue;const Ke=Fe.programConfigurations.get(P.id),nt=b.context.program.get(),We=b.useProgram(he,Ke),He=ge||We.program!==nt,pt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(xe),Ot=Q.constantOr(null);if(Ot&&Oe.imageAtlas){const Pt=Oe.imageAtlas,Nn=Pt.patternPositions[Ot.to.toString()],Ft=Pt.patternPositions[Ot.from.toString()];Nn&&Ft&&Ke.setConstantPatternPositions(Nn,Ft)}const Ge=pt?xe:null,et=re?Da(b,Oe,P,ce,Ge):K?J0(b,Oe,P,K,ce,Ge):le?Yf(b,Oe,P,Fe.lineClipsArray.length,Ge):ou(b,Oe,P,Ge);if(re)te.activeTexture.set(me.TEXTURE0),Oe.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),Ke.updatePaintBuffers(ce);else if(K&&(He||b.lineAtlas.dirty))te.activeTexture.set(me.TEXTURE0),b.lineAtlas.bind(te);else if(le){const Pt=Fe.gradients[P.id];let Nn=Pt.texture;if(P.gradientVersion!==Pt.version){let Ft=256;if(P.stepInterpolant){const Yt=M.getSource().maxzoom,Bn=xe.canonical.z===Yt?Math.ceil(1<<b.transform.maxZoom-xe.canonical.z):1;Ft=l.ac(l.aV(Fe.maxLineLength/l.X*1024*Bn),256,te.maxTextureSize)}Pt.gradient=l.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Ft,image:Pt.gradient||void 0,clips:Fe.lineClipsArray}),Pt.texture?Pt.texture.update(Pt.gradient):Pt.texture=new it(te,Pt.gradient,me.RGBA),Pt.version=P.gradientVersion,Nn=Pt.texture}te.activeTexture.set(me.TEXTURE0),Nn.bind(P.stepInterpolant?me.NEAREST:me.LINEAR,me.CLAMP_TO_EDGE)}We.draw(te,me.TRIANGLES,F,b.stencilModeForClipping(xe),W,Cn.disabled,et,pt,P.id,Fe.layoutVertexBuffer,Fe.indexBuffer,Fe.segments,P.paint,b.transform.zoom,Ke,Fe.layoutVertexBuffer2),ge=!1}})(s,d,f,m);break;case"fill":(function(b,M,P,D){const L=P.paint.get("fill-color"),B=P.paint.get("fill-opacity");if(B.constantOr(1)===0)return;const F=b.colorModeForRenderPass(),W=P.paint.get("fill-pattern"),K=b.opaquePassEnabledForLayer()&&!W.constantOr(1)&&L.constantOr(l.aM.transparent).a===1&&B.constantOr(0)===1?"opaque":"translucent";if(b.renderPass===K){const Q=b.depthModeForSublayer(1,b.renderPass==="opaque"?Ht.ReadWrite:Ht.ReadOnly);Wl(b,M,P,D,Q,F,!1)}if(b.renderPass==="translucent"&&P.paint.get("fill-antialias")){const Q=b.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,Ht.ReadOnly);Wl(b,M,P,D,Q,F,!0)}})(s,d,f,m);break;case"fill-extrusion":(function(b,M,P,D){const L=P.paint.get("fill-extrusion-opacity");if(L!==0&&b.renderPass==="translucent"){const B=new Ht(b.context.gl.LEQUAL,Ht.ReadWrite,b.depthRangeFor3D);if(L!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))pu(b,M,P,D,B,Dn.disabled,Jn.disabled),pu(b,M,P,D,B,b.stencilModeFor3D(),b.colorModeForRenderPass());else{const F=b.colorModeForRenderPass();pu(b,M,P,D,B,Dn.disabled,F)}}})(s,d,f,m);break;case"hillshade":(function(b,M,P,D){if(b.renderPass!=="offscreen"&&b.renderPass!=="translucent")return;const L=b.context,B=b.depthModeForSublayer(0,Ht.ReadOnly),F=b.colorModeForRenderPass(),[W,K]=b.renderPass==="translucent"?b.stencilConfigForOverlap(D):[{},D];for(const Q of K){const re=M.getTile(Q);re.needsHillshadePrepare!==void 0&&re.needsHillshadePrepare&&b.renderPass==="offscreen"?Na(b,re,P,B,Dn.disabled,F):b.renderPass==="translucent"&&La(b,Q,re,P,B,W[Q.overscaledZ],F)}L.viewport.set([0,0,b.width,b.height])})(s,d,f,m);break;case"raster":(function(b,M,P,D){if(b.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!D.length)return;const L=b.context,B=L.gl,F=M.getSource(),W=b.useProgram("raster"),K=b.colorModeForRenderPass(),[Q,re]=F instanceof bi?[{},D]:b.stencilConfigForOverlap(D),le=re[re.length-1].overscaledZ,ce=!b.options.moving;for(const he of re){const te=b.depthModeForSublayer(he.overscaledZ-le,P.paint.get("raster-opacity")===1?Ht.ReadWrite:Ht.ReadOnly,B.LESS),me=M.getTile(he);me.registerFadeDuration(P.paint.get("raster-fade-duration"));const ge=M.findLoadedParent(he,0),xe=M.findLoadedSibling(he),Oe=hm(me,ge||xe||null,M,P,b.transform,b.style.map.terrain);let Fe,Ke;const nt=P.paint.get("raster-resampling")==="nearest"?B.NEAREST:B.LINEAR;L.activeTexture.set(B.TEXTURE0),me.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),L.activeTexture.set(B.TEXTURE1),ge?(ge.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),Fe=Math.pow(2,ge.tileID.overscaledZ-me.tileID.overscaledZ),Ke=[me.tileID.canonical.x*Fe%1,me.tileID.canonical.y*Fe%1]):me.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),me.texture.useMipmap&&L.extTextureFilterAnisotropic&&b.transform.pitch>20&&B.texParameterf(B.TEXTURE_2D,L.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,L.extTextureFilterAnisotropicMax);const We=b.style.map.terrain&&b.style.map.terrain.getTerrainData(he),He=We?he:null,pt=He?He.posMatrix:b.transform.calculatePosMatrix(he.toUnwrapped(),ce),Ot=Q0(pt,Ke||[0,0],Fe||1,Oe,P);F instanceof bi?W.draw(L,B.TRIANGLES,te,Dn.disabled,K,Cn.disabled,Ot,We,P.id,F.boundsBuffer,b.quadTriangleIndexBuffer,F.boundsSegments):W.draw(L,B.TRIANGLES,te,Q[he.overscaledZ],K,Cn.disabled,Ot,We,P.id,b.rasterBoundsBuffer,b.quadTriangleIndexBuffer,b.rasterBoundsSegments)}})(s,d,f,m);break;case"background":(function(b,M,P,D){const L=P.paint.get("background-color"),B=P.paint.get("background-opacity");if(B===0)return;const F=b.context,W=F.gl,K=b.transform,Q=K.tileSize,re=P.paint.get("background-pattern");if(b.isPatternMissing(re))return;const le=!re&&L.a===1&&B===1&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==le)return;const ce=Dn.disabled,he=b.depthModeForSublayer(0,le==="opaque"?Ht.ReadWrite:Ht.ReadOnly),te=b.colorModeForRenderPass(),me=b.useProgram(re?"backgroundPattern":"background"),ge=D||K.coveringTiles({tileSize:Q,terrain:b.style.map.terrain});re&&(F.activeTexture.set(W.TEXTURE0),b.imageManager.bind(b.context));const xe=P.getCrossfadeParameters();for(const Oe of ge){const Fe=D?Oe.posMatrix:b.transform.calculatePosMatrix(Oe.toUnwrapped()),Ke=re?td(Fe,B,b,re,{tileID:Oe,tileSize:Q},xe):au(Fe,B,L),nt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(Oe);me.draw(F,W.TRIANGLES,he,ce,te,Cn.disabled,Ke,nt,P.id,b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}})(s,0,f,m);break;case"custom":(function(b,M,P){const D=b.context,L=P.implementation;if(b.renderPass==="offscreen"){const B=L.prerender;B&&(b.setCustomLayerDefaults(),D.setColorMode(b.colorModeForRenderPass()),B.call(L,D.gl,b.transform.customLayerMatrix()),D.setDirty(),b.setBaseState())}else if(b.renderPass==="translucent"){b.setCustomLayerDefaults(),D.setColorMode(b.colorModeForRenderPass()),D.setStencilMode(Dn.disabled);const B=L.renderingMode==="3d"?new Ht(b.context.gl.LEQUAL,Ht.ReadWrite,b.depthRangeFor3D):b.depthModeForSublayer(0,Ht.ReadOnly);D.setDepthMode(B),L.render(D.gl,b.transform.customLayerMatrix(),{farZ:b.transform.farZ,nearZ:b.transform.nearZ,fov:b.transform._fov,modelViewProjectionMatrix:b.transform.modelViewProjectionMatrix,projectionMatrix:b.transform.projectionMatrix}),D.setDirty(),b.setBaseState(),D.bindFramebuffer.set(null)}})(s,0,f)}}translatePosMatrix(s,d,f,m,b){if(!f[0]&&!f[1])return s;const M=b?m==="map"?this.transform.angle:0:m==="viewport"?-this.transform.angle:0;if(M){const L=Math.sin(M),B=Math.cos(M);f=[f[0]*B-f[1]*L,f[0]*L+f[1]*B]}const P=[b?f[0]:Zt(d,f[0],this.transform.zoom),b?f[1]:Zt(d,f[1],this.transform.zoom),0],D=new Float32Array(16);return l.J(D,s,P),D}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()),f=this.imageManager.getPattern(s.to.toString());return!d||!f}useProgram(s,d){this.cache=this.cache||{};const f=s+(d?d.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[f]||(this.cache[f]=new Qh(this.context,uo[s],d,nd[s],this._showOverdrawInspector,this.style.map.terrain)),this.cache[f]}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 it(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 Fa{constructor(s,d){this.points=s,this.planes=d}static fromInvProjectionMatrix(s,d,f){const m=Math.pow(2,f),b=[[-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 D=1/(P=l.af([],P,s))[3]/d*m;return l.b1(P,P,[D,D,1/P[3],D])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const D=function(W,K){var Q=K[0],re=K[1],le=K[2],ce=Q*Q+re*re+le*le;return ce>0&&(ce=1/Math.sqrt(ce)),W[0]=K[0]*ce,W[1]=K[1]*ce,W[2]=K[2]*ce,W}([],function(W,K,Q){var re=K[0],le=K[1],ce=K[2],he=Q[0],te=Q[1],me=Q[2];return W[0]=le*me-ce*te,W[1]=ce*he-re*me,W[2]=re*te-le*he,W}([],Me([],b[P[0]],b[P[1]]),Me([],b[P[2]],b[P[1]]))),L=-((B=D)[0]*(F=b[P[1]])[0]+B[1]*F[1]+B[2]*F[2]);var B,F;return D.concat(L)});return new Fa(b,M)}}class Va{constructor(s,d){this.min=s,this.max=d,this.center=function(f,m,b){return f[0]=.5*m[0],f[1]=.5*m[1],f[2]=.5*m[2],f}([],function(f,m,b){return f[0]=m[0]+b[0],f[1]=m[1]+b[1],f[2]=m[2]+b[2],f}([],this.min,this.max))}quadrant(s){const d=[s%2==0,s<2],f=Ae(this.min),m=Ae(this.max);for(let b=0;b<d.length;b++)f[b]=d[b]?this.min[b]:this.center[b],m[b]=d[b]?this.center[b]:this.max[b];return m[2]=this.max[2],new Va(f,m)}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 f=!0;for(let m=0;m<s.planes.length;m++){const b=s.planes[m];let M=0;for(let P=0;P<d.length;P++)l.b2(b,d[P])>=0&&M++;if(M===0)return 0;M!==d.length&&(f=!1)}if(f)return 2;for(let m=0;m<3;m++){let b=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<s.points.length;P++){const D=s.points[P][m]-this.min[m];b=Math.min(b,D),M=Math.max(M,D)}if(M<0||b>this.max[m]-this.min[m])return 0}return 1}}class $a{constructor(s=0,d=0,f=0,m=0){if(isNaN(s)||s<0||isNaN(d)||d<0||isNaN(f)||f<0||isNaN(m)||m<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=f,this.right=m}interpolate(s,d,f){return d.top!=null&&s.top!=null&&(this.top=l.y.number(s.top,d.top,f)),d.bottom!=null&&s.bottom!=null&&(this.bottom=l.y.number(s.bottom,d.bottom,f)),d.left!=null&&s.left!=null&&(this.left=l.y.number(s.left,d.left,f)),d.right!=null&&s.right!=null&&(this.right=l.y.number(s.right,d.right,f)),this}getCenter(s,d){const f=l.ac((this.left+s-this.right)/2,0,s),m=l.ac((this.top+d-this.bottom)/2,0,d);return new l.P(f,m)}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,f,m,b){this.tileSize=512,this._renderWorldCopies=b===void 0||!!b,this._minZoom=s||0,this._maxZoom=d||22,this._minPitch=f??0,this._maxPitch=m??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 f=new l.A(4);return l.A!=Float32Array&&(f[1]=0,f[2]=0),f[0]=1,f[3]=1,f}(),function(f,m,b){var M=m[0],P=m[1],D=m[2],L=m[3],B=Math.sin(b),F=Math.cos(b);f[0]=M*F+D*B,f[1]=P*F+L*B,f[2]=M*-B+D*F,f[3]=P*-B+L*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,f){this._unmodified=!1,this._edgeInsets.interpolate(s,d,f),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 f=this.pointCoordinate(new l.P(0,0)),m=this.pointCoordinate(new l.P(this.width,0)),b=this.pointCoordinate(new l.P(this.width,this.height)),M=this.pointCoordinate(new l.P(0,this.height)),P=Math.floor(Math.min(f.x,m.x,b.x,M.x)),D=Math.floor(Math.max(f.x,m.x,b.x,M.x)),L=1;for(let B=P-L;B<=D+L;B++)B!==0&&d.push(new l.b4(B,s))}return d}coveringTiles(s){var d,f;let m=this.coveringZoomLevel(s);const b=m;if(s.minzoom!==void 0&&m<s.minzoom)return[];s.maxzoom!==void 0&&m>s.maxzoom&&(m=s.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=l.Z.fromLngLat(this.center),D=Math.pow(2,m),L=[D*M.x,D*M.y,0],B=[D*P.x,D*P.y,0],F=Fa.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,m);let W=s.minzoom||0;!s.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(W=m);const K=s.terrain?2/Math.min(this.tileSize,s.tileSize)*this.tileSize:3,Q=te=>({aabb:new Va([te*D,0,0],[(te+1)*D,D,0]),zoom:0,x:0,y:0,wrap:te,fullyVisible:!1}),re=[],le=[],ce=m,he=s.reparseOverscaled?b:m;if(this._renderWorldCopies)for(let te=1;te<=3;te++)re.push(Q(-te)),re.push(Q(te));for(re.push(Q(0));re.length>0;){const te=re.pop(),me=te.x,ge=te.y;let xe=te.fullyVisible;if(!xe){const We=te.aabb.intersects(F);if(We===0)continue;xe=We===2}const Oe=s.terrain?L:B,Fe=te.aabb.distanceX(Oe),Ke=te.aabb.distanceY(Oe),nt=Math.max(Math.abs(Fe),Math.abs(Ke));if(te.zoom===ce||nt>K+(1<<ce-te.zoom)-2&&te.zoom>=W){const We=ce-te.zoom,He=L[0]-.5-(me<<We),pt=L[1]-.5-(ge<<We);le.push({tileID:new l.S(te.zoom===ce?he:te.zoom,te.wrap,te.zoom,me,ge),distanceSq:Le([B[0]-.5-me,B[1]-.5-ge]),tileDistanceToCamera:Math.sqrt(He*He+pt*pt)})}else for(let We=0;We<4;We++){const He=(me<<1)+We%2,pt=(ge<<1)+(We>>1),Ot=te.zoom+1;let Ge=te.aabb.quadrant(We);if(s.terrain){const et=new l.S(Ot,te.wrap,Ot,He,pt),Pt=s.terrain.getMinMaxElevation(et),Nn=(d=Pt.minElevation)!==null&&d!==void 0?d:this.elevation,Ft=(f=Pt.maxElevation)!==null&&f!==void 0?f:this.elevation;Ge=new Va([Ge.min[0],Ge.min[1],Nn],[Ge.max[0],Ge.max[1],Ft])}re.push({aabb:Ge,zoom:Ot,x:He,y:pt,wrap:te.wrap,fullyVisible:xe})}}return le.sort((te,me)=>te.distanceSq-me.distanceSq).map(te=>te.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,f=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,m=this.pointLocation(this.centerPoint,s),b=s.getElevationForLngLatZoom(m,this.tileZoom);if(!(this.elevation-b))return;const M=f+d-b,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/l.b5(1,m.lat),D=this.scaleZoom(P/this.tileSize);this._elevation=b,this._center=m,this.zoom=D}setLocationAtPoint(s,d){const f=this.pointCoordinate(d),m=this.pointCoordinate(this.centerPoint),b=this.locationCoordinate(s),M=new l.Z(b.x-(f.x-m.x),b.y-(f.y-m.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 f=[s.x,s.y,0,1],m=[s.x,s.y,1,1];l.af(f,f,this.pixelMatrixInverse),l.af(m,m,this.pixelMatrixInverse);const b=f[3],M=m[3],P=f[1]/b,D=m[1]/M,L=f[2]/b,B=m[2]/M,F=L===B?0:(0-L)/(B-L);return new l.Z(l.y.number(f[0]/b,m[0]/M,F)/this.worldSize,l.y.number(P,D,F)/this.worldSize)}coordinatePoint(s,d=0,f=this.pixelMatrix){const m=[s.x*this.worldSize,s.y*this.worldSize,d,1];return l.af(m,m,f),new l.P(m[0]/m[3],m[1]/m[3])}getBounds(){const s=Math.max(0,this.height/2-this.getHorizon());return new we().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 we([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,f=this.worldSize/this.zoomScale(d.z),m=d.x+Math.pow(2,d.z)*s.wrap,b=l.an(new Float64Array(16));return l.J(b,b,[m*f,d.y*f,0]),l.K(b,b,[f/l.X,f/l.X,1]),b}calculatePosMatrix(s,d=!1){const f=s.key,m=d?this._alignedPosMatrixCache:this._posMatrixCache;if(m[f])return m[f];const b=this.calculateTileMatrix(s);return l.L(b,d?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,b),m[f]=new Float32Array(b),m[f]}calculateFogMatrix(s){const d=s.key,f=this._fogMatrixCache;if(f[d])return f[d];const m=this.calculateTileMatrix(s);return l.L(m,this.fogMatrix,m),f[d]=new Float32Array(m),f[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(s,d){d=l.ac(+d,this.minZoom,this.maxZoom);const f={center:new l.N(s.lng,s.lat),zoom:d};let m=this.lngRange;if(!this._renderWorldCopies&&m===null){const te=179.9999999999;m=[-te,te]}const b=this.tileSize*this.zoomScale(f.zoom);let M=0,P=b,D=0,L=b,B=0,F=0;const{x:W,y:K}=this.size;if(this.latRange){const te=this.latRange;M=l.Q(te[1])*b,P=l.Q(te[0])*b,P-M<K&&(B=K/(P-M))}m&&(D=l.b3(l.O(m[0])*b,0,b),L=l.b3(l.O(m[1])*b,0,b),L<D&&(L+=b),L-D<W&&(F=W/(L-D)));const{x:Q,y:re}=this.project.call({worldSize:b},s);let le,ce;const he=Math.max(F||0,B||0);if(he){const te=new l.P(F?(L+D)/2:Q,B?(P+M)/2:re);return f.center=this.unproject.call({worldSize:b},te).wrap(),f.zoom+=this.scaleZoom(he),f}if(this.latRange){const te=K/2;re-te<M&&(ce=M+te),re+te>P&&(ce=P-te)}if(m){const te=(D+L)/2;let me=Q;this._renderWorldCopies&&(me=l.b3(Q,te-b/2,te+b/2));const ge=W/2;me-ge<D&&(le=D+ge),me+ge>L&&(le=L-ge)}if(le!==void 0||ce!==void 0){const te=new l.P(le??Q,ce??re);f.center=this.unproject.call({worldSize:b},te).wrap()}return f}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const s=this._unmodified,{center:d,zoom:f}=this.getConstrained(this.center,this.zoom);this.center=d,this.zoom=f,this._unmodified=s,this._constraining=!1}_calcMatrices(){if(!this.height)return;const s=this.centerOffset,d=this.point.x,f=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=l.b5(1,this.center.lat)*this.worldSize;let m=l.an(new Float64Array(16));l.K(m,m,[this.width/2,-this.height/2,1]),l.J(m,m,[1,-1,0]),this.labelPlaneMatrix=m,m=l.an(new Float64Array(16)),l.K(m,m,[1,-1,1]),l.J(m,m,[-1,-1,0]),l.K(m,m,[2/this.width,2/this.height,1]),this.glCoordMatrix=m;const b=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=b-M*this._pixelPerMeter/Math.cos(this._pitch),D=M<0?P:b,L=Math.PI/2+this._pitch,B=this._fov*(.5+s.y/this.height),F=Math.sin(B)*D/Math.sin(l.ac(Math.PI-L-B,.01,Math.PI-.01)),W=this.getHorizon(),K=2*Math.atan(W/this.cameraToCenterDistance)*(.5+s.y/(2*W)),Q=Math.sin(K)*D/Math.sin(l.ac(Math.PI-L-K,.01,Math.PI-.01)),re=Math.min(F,Q);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*re+D),this.nearZ=this.height/50,m=new Float64Array(16),l.b6(m,this._fov,this.width/this.height,this.nearZ,this.farZ),m[8]=2*-s.x/this.width,m[9]=2*s.y/this.height,this.projectionMatrix=l.ae(m),l.K(m,m,[1,-1,1]),l.J(m,m,[0,0,-this.cameraToCenterDistance]),l.b7(m,m,this._pitch),l.ad(m,m,this.angle),l.J(m,m,[-d,-f,0]),this.mercatorMatrix=l.K([],m,[this.worldSize,this.worldSize,this.worldSize]),l.K(m,m,[1,1,this._pixelPerMeter]),this.pixelMatrix=l.L(new Float64Array(16),this.labelPlaneMatrix,m),l.J(m,m,[0,0,-this.elevation]),this.modelViewProjectionMatrix=m,this.invModelViewProjectionMatrix=l.as([],m),this.fogMatrix=new Float64Array(16),l.b6(this.fogMatrix,this._fov,this.width/this.height,b,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,-f,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,m);const le=this.width%2/2,ce=this.height%2/2,he=Math.cos(this.angle),te=Math.sin(this.angle),me=d-Math.round(d)+he*le+te*ce,ge=f-Math.round(f)+he*ce+te*le,xe=new Float64Array(m);if(l.J(xe,xe,[me>.5?me-1:me,ge>.5?ge-1:ge,0]),this.alignedModelViewProjectionMatrix=xe,m=l.as(new Float64Array(16),this.pixelMatrix),!m)throw new Error("failed to invert matrix");this.pixelMatrixInverse=m,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 f=d.x,m=d.y,b=d.x,M=d.y;for(const P of s)f=Math.min(f,P.x),m=Math.min(m,P.y),b=Math.max(b,P.x),M=Math.max(M,P.y);return[new l.P(f,m),new l.P(b,m),new l.P(b,M),new l.P(f,M),new l.P(f,m)]}}lngLatToCameraDepth(s,d){const f=this.locationCoordinate(s),m=[f.x*this.worldSize,f.y*this.worldSize,d,1];return l.af(m,m,this.modelViewProjectionMatrix),m[2]/m[3]}}function Gl(x,s){let d,f=!1,m=null,b=null;const M=()=>{m=null,f&&(x.apply(b,d),m=setTimeout(M,s),f=!1)};return(...P)=>(f=!0,b=this,d=P,m||M(),m)}class _u{constructor(s){this._getCurrentHash=()=>{const d=window.location.hash.replace("#","");if(this._hashName){let f;return d.split("&").map(m=>m.split("=")).forEach(m=>{m[0]===this._hashName&&(f=m)}),(f&&f[1]||"").split("/")}return d.split("/")},this._onHashChange=()=>{const d=this._getCurrentHash();if(d.length>=3&&!d.some(f=>isNaN(f))){const f=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:f,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 f=d.join("/");let m=f;m.split("&").length>0&&(m=m.split("&")[0]),this._hashName&&(m=`${this._hashName}=${f}`);let b=window.location.hash.replace(m,"");b.startsWith("#&")?b=b.slice(0,1)+b.slice(2):b==="#"&&(b="");let M=window.location.href.replace(/(#.+)?$/,b);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(),f=Math.round(100*this._map.getZoom())/100,m=Math.ceil((f*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.pow(10,m),M=Math.round(d.lng*b)/b,P=Math.round(d.lat*b)/b,D=this._map.getBearing(),L=this._map.getPitch();let B="";if(B+=s?`/${M}/${P}/${f}`:`${f}/${P}/${M}`,(D||L)&&(B+="/"+Math.round(10*D)/10),L&&(B+=`/${Math.round(L)}`),this._hashName){const F=this._hashName;let W=!1;const K=window.location.hash.slice(1).split("&").map(Q=>{const re=Q.split("=")[0];return re===F?(W=!0,`${re}=${B}`):Q}).filter(Q=>Q);return W||K.push(`${F}=${B}`),`#${K.join("&")}`}return`#${B}`}}const bu={linearity:.3,easing:l.b8(0,0,.3,1)},yd=l.e({deceleration:2500,maxSpeed:1400},bu),d_=l.e({deceleration:20,maxSpeed:1400},bu),gm=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:b}of this._inertiaBuffer)d.zoom+=b.zoomDelta||0,d.bearing+=b.bearingDelta||0,d.pitch+=b.pitchDelta||0,b.panDelta&&d.pan._add(b.panDelta),b.around&&(d.around=b.around),b.pinchAround&&(d.pinchAround=b.pinchAround);const f=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,m={};if(d.pan.mag()){const b=Yl(d.pan.mag(),f,l.e({},yd,s||{}));m.offset=d.pan.mult(b.amount/d.pan.mag()),m.center=this._map.transform.center,Zl(m,b)}if(d.zoom){const b=Yl(d.zoom,f,d_);m.zoom=this._map.transform.zoom+b.amount,Zl(m,b)}if(d.bearing){const b=Yl(d.bearing,f,gm);m.bearing=this._map.transform.bearing+l.ac(b.amount,-179,179),Zl(m,b)}if(d.pitch){const b=Yl(d.pitch,f,xu);m.pitch=this._map.transform.pitch+b.amount,Zl(m,b)}if(m.zoom||m.bearing){const b=d.pinchAround===void 0?d.around:d.pinchAround;m.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),l.e(m,{noMoveStart:!0})}}function Zl(x,s){(!x.duration||x.duration<s.duration)&&(x.duration=s.duration,x.easing=s.easing)}function Yl(x,s,d){const{maxSpeed:f,linearity:m,deceleration:b}=d,M=l.ac(x*m/(s/1e3),-f,f),P=Math.abs(M)/(b*m);return{easing:d.easing,duration:1e3*P,amount:M*(P/2)}}class Pi extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f,m={}){const b=T.mousePos(d.getCanvas(),f),M=d.unproject(b);super(s,l.e({point:b,lngLat:M,originalEvent:f},m)),this._defaultPrevented=!1,this.target=d}}class Yo extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f){const m=s==="touchend"?f.changedTouches:f.touches,b=T.touchPos(d.getCanvasContainer(),m),M=b.map(D=>d.unproject(D)),P=b.reduce((D,L,B,F)=>D.add(L.div(F.length)),new l.P(0,0));super(s,{points:b,point:P,lngLats:M,lngLat:d.unproject(P),originalEvent:f}),this._defaultPrevented=!1}}class ym extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f){super(s,{originalEvent:f}),this._defaultPrevented=!1}}class _m{constructor(s,d){this._map=s,this._clickTolerance=d.clickTolerance}reset(){delete this._mousedownPos}wheel(s){return this._firePreventable(new ym(s.type,this._map,s))}mousedown(s,d){return this._mousedownPos=d,this._firePreventable(new Pi(s.type,this._map,s))}mouseup(s){this._map.fire(new Pi(s.type,this._map,s))}click(s,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||this._map.fire(new Pi(s.type,this._map,s))}dblclick(s){return this._firePreventable(new Pi(s.type,this._map,s))}mouseover(s){this._map.fire(new Pi(s.type,this._map,s))}mouseout(s){this._map.fire(new Pi(s.type,this._map,s))}touchstart(s){return this._firePreventable(new Yo(s.type,this._map,s))}touchmove(s){this._map.fire(new Yo(s.type,this._map,s))}touchend(s){this._map.fire(new Yo(s.type,this._map,s))}touchcancel(s){this._map.fire(new Yo(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 Pi(s.type,this._map,s))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Pi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(s){this._delayContextMenu?this._contextMenuEvent=s:this._ignoreContextMenu||this._map.fire(new Pi(s.type,this._map,s)),this._map.listens("contextmenu")&&s.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class es{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 yr{constructor(s,d){this._map=s,this._tr=new es(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&&(T.disableDrag(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(s,d){if(!this._active)return;const f=d;if(this._lastPos.equals(f)||!this._box&&f.dist(this._startPos)<this._clickTolerance)return;const m=this._startPos;this._lastPos=f,this._box||(this._box=T.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",s));const b=Math.min(m.x,f.x),M=Math.max(m.x,f.x),P=Math.min(m.y,f.y),D=Math.max(m.y,f.y);T.setTransform(this._box,`translate(${b}px,${P}px)`),this._box.style.width=M-b+"px",this._box.style.height=D-P+"px"}mouseupWindow(s,d){if(!this._active||s.button!==0)return;const f=this._startPos,m=d;if(this.reset(),T.suppressClick(),f.x!==m.x||f.y!==m.y)return this._map.fire(new l.k("boxzoomend",{originalEvent:s})),{cameraAnimation:b=>b.fitScreenCoordinates(f,m,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&&(T.remove(this._box),this._box=null),T.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(s,d){return this._map.fire(new l.k(s,{originalEvent:d}))}}function Xl(x,s){if(x.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${x.length}, points ${s.length}`);const d={};for(let f=0;f<x.length;f++)d[x[f].identifier]=s[f];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,f){(this.centroid||f.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=s.timeStamp),f.length===this.numTouches&&(this.centroid=function(m){const b=new l.P(0,0);for(const M of m)b._add(M);return b.div(m.length)}(d),this.touches=Xl(f,d)))}touchmove(s,d,f){if(this.aborted||!this.centroid)return;const m=Xl(f,d);for(const b in this.touches){const M=m[b];(!M||M.dist(this.touches[b])>30)&&(this.aborted=!0)}}touchend(s,d,f){if((!this.centroid||s.timeStamp-this.startTime>500)&&(this.aborted=!0),f.length===0){const m=!this.aborted&&this.centroid;if(this.reset(),m)return m}}}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,f){this.singleTap.touchstart(s,d,f)}touchmove(s,d,f){this.singleTap.touchmove(s,d,f)}touchend(s,d,f){const m=this.singleTap.touchend(s,d,f);if(m){const b=s.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(m)<30;if(b&&M||this.reset(),this.count++,this.lastTime=s.timeStamp,this.lastTap=m,this.count===this.numTaps)return this.reset(),m}}}class Ua{constructor(s){this._tr=new es(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,f){this._zoomIn.touchstart(s,d,f),this._zoomOut.touchstart(s,d,f)}touchmove(s,d,f){this._zoomIn.touchmove(s,d,f),this._zoomOut.touchmove(s,d,f)}touchend(s,d,f){const m=this._zoomIn.touchend(s,d,f),b=this._zoomOut.touchend(s,d,f),M=this._tr;return m?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(m)},{originalEvent:s})}):b?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(b)},{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 f=this._lastPoint;if(!f)return;if(s.preventDefault(),!this._moveStateManager.isValidMoveEvent(s))return void this.reset(s);const m=d.length?d[0]:d;return!this._moved&&m.dist(f)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=m,this._move(f,m))}dragEnd(s){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(s)&&(this._moved&&T.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=T.mouseButton(s);this._eventButton=d}endMove(s){delete this._eventButton}isValidStartEvent(s){return this._correctEvent(s)}isValidMoveEvent(s){return!function(d,f){const m=xd[f];return d.buttons===void 0||(d.buttons&m)!==m}(s,this._eventButton)}isValidEndEvent(s){return T.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=x=>{x.mousedown=x.dragStart,x.mousemoveWindow=x.dragMove,x.mouseup=x.dragEnd,x.contextmenu=s=>{s.preventDefault()}},wd=({enable:x,clickTolerance:s,bearingDegreesPerPixelMoved:d=.8})=>{const f=new wu({checkCorrectEvent:m=>T.mouseButton(m)===0&&m.ctrlKey||T.mouseButton(m)===2});return new qs({clickTolerance:s,move:(m,b)=>({bearingDelta:(b.x-m.x)*d}),moveStateManager:f,enable:x,assignEvents:ku})},kd=({enable:x,clickTolerance:s,pitchDegreesPerPixelMoved:d=-.5})=>{const f=new wu({checkCorrectEvent:m=>T.mouseButton(m)===0&&m.ctrlKey||T.mouseButton(m)===2});return new qs({clickTolerance:s,move:(m,b)=>({pitchDelta:(b.y-m.y)*d}),moveStateManager:f,enable:x,assignEvents:ku})};class Xo{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,f){return this._calculateTransform(s,d,f)}touchmove(s,d,f){if(this._active){if(!this._shouldBePrevented(f.length))return s.preventDefault(),this._calculateTransform(s,d,f);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",s)}}touchend(s,d,f){this._calculateTransform(s,d,f),this._active&&this._shouldBePrevented(f.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(s,d,f){f.length>0&&(this._active=!0);const m=Xl(f,d),b=new l.P(0,0),M=new l.P(0,0);let P=0;for(const L in m){const B=m[L],F=this._touches[L];F&&(b._add(B),M._add(B.sub(F)),P++,m[L]=B)}if(this._touches=m,this._shouldBePrevented(P)||!M.mag())return;const D=M.div(P);return this._sum._add(D),this._sum.mag()<this._clickTolerance?void 0:{around:b.div(P),panDelta:D}}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,f){this._firstTwoTouches||f.length<2||(this._firstTwoTouches=[f[0].identifier,f[1].identifier],this._start([d[0],d[1]]))}touchmove(s,d,f){if(!this._firstTwoTouches)return;s.preventDefault();const[m,b]=this._firstTwoTouches,M=Kl(f,d,m),P=Kl(f,d,b);if(!M||!P)return;const D=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],D,s)}touchend(s,d,f){if(!this._firstTwoTouches)return;const[m,b]=this._firstTwoTouches,M=Kl(f,d,m),P=Kl(f,d,b);M&&P||(this._active&&T.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(x,s,d){for(let f=0;f<x.length;f++)if(x[f].identifier===d)return s[f]}function Sd(x,s){return Math.log(x/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 f=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,f),pinchAround:d}}}function Cd(x,s){return 180*x.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,f){const m=this._vector;if(this._vector=s[0].sub(s[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Cd(this._vector,m),pinchAround:d}}_isBelowThreshold(s){this._minDiameter=Math.min(this._minDiameter,s.mag());const d=25/(Math.PI*this._minDiameter)*360,f=Cd(s,this._startVector);return Math.abs(f)<d}}function Eu(x){return Math.abs(x.y)>Math.abs(x.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,f){super.touchstart(s,d,f),this._currentTouchCount=f.length}_start(s){this._lastPoints=s,Eu(s[0].sub(s[1]))&&(this._valid=!1)}_move(s,d,f){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const m=s[0].sub(this._lastPoints[0]),b=s[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(m,b,f.timeStamp),this._valid?(this._lastPoints=s,this._active=!0,{pitchDelta:(m.y+b.y)/2*-.5}):void 0}gestureBeginsVertically(s,d,f){if(this._valid!==void 0)return this._valid;const m=s.mag()>=2,b=d.mag()>=2;if(!m&&!b)return;if(!m||!b)return this._firstMove===void 0&&(this._firstMove=f),f-this._firstMove<100&&void 0;const M=s.y>0==d.y>0;return Eu(s)&&Eu(d)&&M}}const bm={panStep:100,bearingStep:15,pitchStep:10};class Nr{constructor(s){this._tr=new es(s);const d=bm;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,f=0,m=0,b=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?f=-1:(s.preventDefault(),b=-1);break;case 39:s.shiftKey?f=1:(s.preventDefault(),b=1);break;case 38:s.shiftKey?m=1:(s.preventDefault(),M=-1);break;case 40:s.shiftKey?m=-1:(s.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(f=0,m=0),{cameraAnimation:P=>{const D=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:As,zoom:d?Math.round(D.zoom)+d*(s.shiftKey?2:1):D.zoom,bearing:D.bearing+f*this._bearingStep,pitch:D.pitch+m*this._pitchStep,offset:[-b*this._panStep,-M*this._panStep],center:D.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(x){return x*(2-x)}const Md=4.000244140625;class ts{constructor(s,d){this._onTimeout=f=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(f)},this._map=s,this._tr=new es(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 f=E.now(),m=f-(this._lastWheelEventTime||0);this._lastWheelEventTime=f,d!==0&&d%Md==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":m>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,s)):this._type||(this._type=Math.abs(m*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=T.mousePos(this._map.getCanvas(),s),f=this._tr;this._around=d.y>f.transform.height/2-f.transform.getHorizon()?l.N.convert(this._aroundCenter?f.center:f.unproject(d)):l.N.convert(f.center),this._aroundPoint=f.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 D=this._type==="wheel"&&Math.abs(this._delta)>Md?this._wheelZoomRate:this._defaultZoomRate;let L=2/(1+Math.exp(-Math.abs(this._delta*D)));this._delta<0&&L!==0&&(L=1/L);const B=typeof this._targetZoom=="number"?s.zoomScale(this._targetZoom):s.scale;this._targetZoom=Math.min(s.maxZoom,Math.max(s.minZoom,s.scaleZoom(B*L))),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,f=this._startZoom,m=this._easing;let b,M=!1;const P=E.now()-this._lastWheelEventTime;if(this._type==="wheel"&&f&&m&&P){const D=Math.min(P/200,1),L=m(D);b=l.y.number(f,d,L),D<1?this._frameId||(this._frameId=!0):M=!0}else b=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:b-s.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(s){let d=l.b9;if(this._prevEase){const f=this._prevEase,m=(E.now()-f.start)/f.duration,b=f.easing(m+.01)-f.easing(m),M=.27/Math.sqrt(b*b+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 Ko{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 p_{constructor(s){this._tr=new es(s),this.reset()}reset(){this._active=!1}dblclick(s,d){return s.preventDefault(),{cameraAnimation:f=>{f.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 f_{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,f){if(!this._swipePoint)if(this._tapTime){const m=d[0],b=s.timeStamp-this._tapTime<500,M=this._tapPoint.dist(m)<30;b&&M?f.length>0&&(this._swipePoint=m,this._swipeTouch=f[0].identifier):this.reset()}else this._tap.touchstart(s,d,f)}touchmove(s,d,f){if(this._tapTime){if(this._swipePoint){if(f[0].identifier!==this._swipeTouch)return;const m=d[0],b=m.y-this._swipePoint.y;return this._swipePoint=m,s.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(s,d,f)}touchend(s,d,f){if(this._tapTime)this._swipePoint&&f.length===0&&this.reset();else{const m=this._tap.touchend(s,d,f);m&&(this._tapTime=s.timeStamp,this._tapPoint=m)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xm{constructor(s,d,f){this._el=s,this._mousePan=d,this._touchPan=f}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 vm{constructor(s,d,f){this._pitchWithRotate=s.pitchWithRotate,this._mouseRotate=d,this._mousePitch=f}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,f,m){this._el=s,this._touchZoom=d,this._touchRotate=f,this._tapDragZoom=m,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=T.create("div","maplibregl-cooperative-gesture-screen",s);let d=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(d=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const f=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),m=document.createElement("div");m.className="maplibregl-desktop-message",m.textContent=d,this._container.appendChild(m);const b=document.createElement("div");b.className="maplibregl-mobile-message",b.textContent=f,this._container.appendChild(b),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(T.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 Br=x=>x.zoom||x.drag||x.pitch||x.rotate;class ot extends l.k{}function Cu(x){return x.panDelta&&x.panDelta.mag()||x.zoomDelta||x.bearingDelta||x.pitchDelta}class Pd{constructor(s,d){this.handleWindowEvent=m=>{this.handleEvent(m,`${m.type}Window`)},this.handleEvent=(m,b)=>{if(m.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=m.type==="renderFrame"?void 0:m,P={needsRenderFrame:!1},D={},L={},B=m.touches,F=B?this._getMapTouches(B):void 0,W=F?T.touchPos(this._map.getCanvas(),F):T.mousePos(this._map.getCanvas(),m);for(const{handlerName:re,handler:le,allowed:ce}of this._handlers){if(!le.isEnabled())continue;let he;this._blockedByActive(L,ce,re)?le.reset():le[b||m.type]&&(he=le[b||m.type](m,W,F),this.mergeHandlerResult(P,D,he,re,M),he&&he.needsRenderFrame&&this._triggerRenderFrame()),(he||le.isActive())&&(L[re]=le)}const K={};for(const re in this._previousActiveHandlers)L[re]||(K[re]=M);this._previousActiveHandlers=L,(Object.keys(K).length||Cu(P))&&(this._changes.push([P,D,K]),this._triggerRenderFrame()),(Object.keys(L).length||Cu(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Q}=P;Q&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Q(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 f=this._el;this._listeners=[[f,"touchstart",{passive:!0}],[f,"touchmove",{passive:!1}],[f,"touchend",void 0],[f,"touchcancel",void 0],[f,"mousedown",void 0],[f,"mousemove",void 0],[f,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[f,"mouseover",void 0],[f,"mouseout",void 0],[f,"dblclick",void 0],[f,"click",void 0],[f,"keydown",{capture:!1}],[f,"keyup",void 0],[f,"wheel",{passive:!1}],[f,"contextmenu",void 0],[window,"blur",void 0]];for(const[m,b,M]of this._listeners)T.addEventListener(m,b,m===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[s,d,f]of this._listeners)T.removeEventListener(s,d,s===document?this.handleWindowEvent:this.handleEvent,f)}_addDefaultHandlers(s){const d=this._map,f=d.getCanvasContainer();this._add("mapEvent",new _m(d,s));const m=d.boxZoom=new yr(d,s);this._add("boxZoom",m),s.interactive&&s.boxZoom&&m.enable();const b=d.cooperativeGestures=new qa(d,s.cooperativeGestures);this._add("cooperativeGestures",b),s.cooperativeGestures&&b.enable();const M=new Ua(d),P=new p_(d);d.doubleClickZoom=new Ko(P,M),this._add("tapZoom",M),this._add("clickZoom",P),s.interactive&&s.doubleClickZoom&&d.doubleClickZoom.enable();const D=new f_;this._add("tapDragZoom",D);const L=d.touchPitch=new Ha(d);this._add("touchPitch",L),s.interactive&&s.touchPitch&&d.touchPitch.enable(s.touchPitch);const B=wd(s),F=kd(s);d.dragRotate=new vm(s,B,F),this._add("mouseRotate",B,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),s.interactive&&s.dragRotate&&d.dragRotate.enable();const W=(({enable:he,clickTolerance:te})=>{const me=new wu({checkCorrectEvent:ge=>T.mouseButton(ge)===0&&!ge.ctrlKey});return new qs({clickTolerance:te,move:(ge,xe)=>({around:xe,panDelta:xe.sub(ge)}),activateOnStart:!0,moveStateManager:me,enable:he,assignEvents:ku})})(s),K=new Xo(s,d);d.dragPan=new xm(f,W,K),this._add("mousePan",W),this._add("touchPan",K,["touchZoom","touchRotate"]),s.interactive&&s.dragPan&&d.dragPan.enable(s.dragPan);const Q=new Td,re=new Ed;d.touchZoomRotate=new Ad(f,re,Q,D),this._add("touchRotate",Q,["touchPan","touchZoom"]),this._add("touchZoom",re,["touchPan","touchRotate"]),s.interactive&&s.touchZoomRotate&&d.touchZoomRotate.enable(s.touchZoomRotate);const le=d.scrollZoom=new ts(d,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),s.interactive&&s.scrollZoom&&d.scrollZoom.enable(s.scrollZoom);const ce=d.keyboard=new Nr(d);this._add("keyboard",ce),s.interactive&&s.keyboard&&d.keyboard.enable(),this._add("blockableMapEvent",new Qn(d))}_add(s,d,f){this._handlers.push({handlerName:s,handler:d,allowed:f}),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!!Br(this._eventsInProgress)||this.isZooming()}_blockedByActive(s,d,f){for(const m in s)if(m!==f&&(!d||d.indexOf(m)<0))return!0;return!1}_getMapTouches(s){const d=[];for(const f of s)this._el.contains(f.target)&&d.push(f);return d}mergeHandlerResult(s,d,f,m,b){if(!f)return;l.e(s,f);const M={handlerName:m,originalEvent:f.originalEvent||b};f.zoomDelta!==void 0&&(d.zoom=M),f.panDelta!==void 0&&(d.drag=M),f.pitchDelta!==void 0&&(d.pitch=M),f.bearingDelta!==void 0&&(d.rotate=M)}_applyChanges(){const s={},d={},f={};for(const[m,b,M]of this._changes)m.panDelta&&(s.panDelta=(s.panDelta||new l.P(0,0))._add(m.panDelta)),m.zoomDelta&&(s.zoomDelta=(s.zoomDelta||0)+m.zoomDelta),m.bearingDelta&&(s.bearingDelta=(s.bearingDelta||0)+m.bearingDelta),m.pitchDelta&&(s.pitchDelta=(s.pitchDelta||0)+m.pitchDelta),m.around!==void 0&&(s.around=m.around),m.pinchAround!==void 0&&(s.pinchAround=m.pinchAround),m.noInertia&&(s.noInertia=m.noInertia),l.e(d,b),l.e(f,M);this._updateMapTransform(s,d,f),this._changes=[]}_updateMapTransform(s,d,f){const m=this._map,b=m._getTransformForUpdate(),M=m.terrain;if(!(Cu(s)||M&&this._terrainMovement))return this._fireEvents(d,f,!0);let{panDelta:P,zoomDelta:D,bearingDelta:L,pitchDelta:B,around:F,pinchAround:W}=s;W!==void 0&&(F=W),m._stop(!0),F=F||m.transform.centerPoint;const K=b.pointLocation(P?F.sub(P):F);L&&(b.bearing+=L),B&&(b.pitch+=B),D&&(b.zoom+=D),M?this._terrainMovement||!d.drag&&!d.zoom?d.drag&&this._terrainMovement?b.center=b.pointLocation(b.centerPoint.sub(P)):b.setLocationAtPoint(K,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,b.setLocationAtPoint(K,F)):b.setLocationAtPoint(K,F),m._applyUpdatedTransform(b),this._map._update(),s.noInertia||this._inertia.record(s),this._fireEvents(d,f,!0)}_fireEvents(s,d,f){const m=Br(this._eventsInProgress),b=Br(s),M={};for(const F in s){const{originalEvent:W}=s[F];this._eventsInProgress[F]||(M[`${F}start`]=W),this._eventsInProgress[F]=s[F]}!m&&b&&this._fireEvent("movestart",b.originalEvent);for(const F in M)this._fireEvent(F,M[F]);b&&this._fireEvent("move",b.originalEvent);for(const F in s){const{originalEvent:W}=s[F];this._fireEvent(F,W)}const P={};let D;for(const F in this._eventsInProgress){const{handlerName:W,originalEvent:K}=this._eventsInProgress[F];this._handlersById[W].isActive()||(delete this._eventsInProgress[F],D=d[W]||K,P[`${F}end`]=D)}for(const F in P)this._fireEvent(F,P[F]);const L=Br(this._eventsInProgress),B=(m||b)&&!L;if(B&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(f&&B){this._updatingCamera=!0;const F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),W=K=>K!==0&&-this._bearingSnap<K&&K<this._bearingSnap;!F||!F.essential&&E.prefersReducedMotion?(this._map.fire(new l.k("moveend",{originalEvent:D})),W(this._map.getBearing())&&this._map.resetNorth()):(W(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:D})),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 ot("renderFrame",{timeStamp:s})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class wm extends l.E{constructor(s,d){super(),this._renderFrameCallback=()=>{const f=Math.min((E.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(f)),f<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,f){return s=l.P.convert(s).mult(-1),this.panTo(this.transform.center,l.e({offset:s},d),f)}panTo(s,d,f){return this.easeTo(l.e({center:s},d),f)}getZoom(){return this.transform.zoom}setZoom(s,d){return this.jumpTo({zoom:s},d),this}zoomTo(s,d,f){return this.easeTo(l.e({zoom:s},d),f)}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,f){return this.easeTo(l.e({bearing:s},d),f)}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=we.convert(s).adjustAntiMeridian();const f=d&&d.bearing||0;return this._cameraForBoxAndBearing(s.getNorthWest(),s.getSouthEast(),f,d)}_cameraForBoxAndBearing(s,d,f,m){const b={top:0,bottom:0,right:0,left:0};if(typeof(m=l.e({padding:b,offset:[0,0],maxZoom:this.transform.maxZoom},m)).padding=="number"){const We=m.padding;m.padding={top:We,bottom:We,right:We,left:We}}m.padding=l.e(b,m.padding);const M=this.transform,P=M.padding,D=new we(s,d),L=M.project(D.getNorthWest()),B=M.project(D.getNorthEast()),F=M.project(D.getSouthEast()),W=M.project(D.getSouthWest()),K=l.ba(-f),Q=L.rotate(K),re=B.rotate(K),le=F.rotate(K),ce=W.rotate(K),he=new l.P(Math.max(Q.x,re.x,ce.x,le.x),Math.max(Q.y,re.y,ce.y,le.y)),te=new l.P(Math.min(Q.x,re.x,ce.x,le.x),Math.min(Q.y,re.y,ce.y,le.y)),me=he.sub(te),ge=(M.width-(P.left+P.right+m.padding.left+m.padding.right))/me.x,xe=(M.height-(P.top+P.bottom+m.padding.top+m.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 Oe=Math.min(M.scaleZoom(M.scale*Math.min(ge,xe)),m.maxZoom),Fe=l.P.convert(m.offset),Ke=new l.P((m.padding.left-m.padding.right)/2,(m.padding.top-m.padding.bottom)/2).rotate(l.ba(f)),nt=Fe.add(Ke).mult(M.scale/M.zoomScale(Oe));return{center:M.unproject(L.add(F).div(2).sub(nt)),zoom:Oe,bearing:f}}fitBounds(s,d,f){return this._fitInternal(this.cameraForBounds(s,d),d,f)}fitScreenCoordinates(s,d,f,m,b){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(l.P.convert(s)),this.transform.pointLocation(l.P.convert(d)),f,m),m,b)}_fitInternal(s,d,f){return s?(delete(d=l.e(s,d)).padding,d.linear?this.easeTo(d,f):this.flyTo(d,f)):this}jumpTo(s,d){this.stop();const f=this._getTransformForUpdate();let m=!1,b=!1,M=!1;return"zoom"in s&&f.zoom!==+s.zoom&&(m=!0,f.zoom=+s.zoom),s.center!==void 0&&(f.center=l.N.convert(s.center)),"bearing"in s&&f.bearing!==+s.bearing&&(b=!0,f.bearing=+s.bearing),"pitch"in s&&f.pitch!==+s.pitch&&(M=!0,f.pitch=+s.pitch),s.padding==null||f.isPaddingEqual(s.padding)||(f.padding=s.padding),this._applyUpdatedTransform(f),this.fire(new l.k("movestart",d)).fire(new l.k("move",d)),m&&this.fire(new l.k("zoomstart",d)).fire(new l.k("zoom",d)).fire(new l.k("zoomend",d)),b&&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,f,m=0){const b=l.Z.fromLngLat(s,d),M=l.Z.fromLngLat(f,m),P=M.x-b.x,D=M.y-b.y,L=M.z-b.z,B=Math.hypot(P,D,L);if(B===0)throw new Error("Can't calculate camera options with same From and To");const F=Math.hypot(P,D),W=this.transform.scaleZoom(this.transform.cameraToCenterDistance/B/this.transform.tileSize),K=180*Math.atan2(P,-D)/Math.PI;let Q=180*Math.acos(F/B)/Math.PI;return Q=L<0?90-Q:90+Q,{center:M.toLngLat(),zoom:W,pitch:Q,bearing:K}}easeTo(s,d){var f;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 m=this._getTransformForUpdate(),b=m.zoom,M=m.bearing,P=m.pitch,D=m.padding,L="bearing"in s?this._normalizeBearing(s.bearing,M):M,B="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:m.padding,W=l.P.convert(s.offset);let K=m.centerPoint.add(W);const Q=m.pointLocation(K),{center:re,zoom:le}=m.getConstrained(l.N.convert(s.center||Q),(f=s.zoom)!==null&&f!==void 0?f:b);this._normalizeCenter(re,m);const ce=m.project(Q),he=m.project(re).sub(ce),te=m.zoomScale(le-b);let me,ge;s.around&&(me=l.N.convert(s.around),ge=m.locationPoint(me));const xe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==b,this._rotating=this._rotating||M!==L,this._pitching=this._pitching||B!==P,this._padding=!m.isPaddingEqual(F),this._easeId=s.easeId,this._prepareEase(d,s.noMoveStart,xe),this.terrain&&this._prepareElevation(re),this._ease(Oe=>{if(this._zooming&&(m.zoom=l.y.number(b,le,Oe)),this._rotating&&(m.bearing=l.y.number(M,L,Oe)),this._pitching&&(m.pitch=l.y.number(P,B,Oe)),this._padding&&(m.interpolatePadding(D,F,Oe),K=m.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(Oe),me)m.setLocationAtPoint(me,ge);else{const Fe=m.zoomScale(m.zoom-b),Ke=le>b?Math.min(2,te):Math.max(.5,te),nt=Math.pow(Ke,1-Oe),We=m.unproject(ce.add(he.mult(Oe*nt)).mult(Fe));m.setLocationAtPoint(m.renderWorldCopies?We.wrap():We,K)}this._applyUpdatedTransform(m),this._fireMoveEvents(d)},Oe=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d,Oe)},s),this}_prepareEase(s,d,f={}){this._moving=!0,d||f.moving||this.fire(new l.k("movestart",s)),this._zooming&&!f.zooming&&this.fire(new l.k("zoomstart",s)),this._rotating&&!f.rotating&&this.fire(new l.k("rotatestart",s)),this._pitching&&!f.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 f=this._elevationTarget-this._elevationStart;this._elevationStart+=s*(f-(d-(f*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(),f=this.terrain.getElevationForLngLatZoom(d.lngLat,s.zoom);if(d.altitude<f){const m=this.calculateCameraOptionsFromTo(d.lngLat,f,s.center,s.elevation);return{pitch:m.pitch,zoom:m.zoom}}return{}}_applyUpdatedTransform(s){const d=[];if(this.terrain&&d.push(m=>this._elevateCameraIfInsideTerrain(m)),this.transformCameraUpdate&&d.push(m=>this.transformCameraUpdate(m)),!d.length)return;const f=s.clone();for(const m of d){const b=f.clone(),{center:M,zoom:P,pitch:D,bearing:L,elevation:B}=m(b);M&&(b.center=M),P!==void 0&&(b.zoom=P),D!==void 0&&(b.pitch=D),L!==void 0&&(b.bearing=L),B!==void 0&&(b.elevation=B),f.apply(b)}this.transform.apply(f)}_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 f=this._zooming,m=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,f&&this.fire(new l.k("zoomend",s)),m&&this.fire(new l.k("rotateend",s)),b&&this.fire(new l.k("pitchend",s)),this.fire(new l.k("moveend",s))}flyTo(s,d){var f;if(!s.essential&&E.prefersReducedMotion){const et=l.M(s,["center","zoom","bearing","pitch","around"]);return this.jumpTo(et,d)}this.stop(),s=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.b9},s);const m=this._getTransformForUpdate(),b=m.zoom,M=m.bearing,P=m.pitch,D=m.padding,L="bearing"in s?this._normalizeBearing(s.bearing,M):M,B="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:m.padding,W=l.P.convert(s.offset);let K=m.centerPoint.add(W);const Q=m.pointLocation(K),{center:re,zoom:le}=m.getConstrained(l.N.convert(s.center||Q),(f=s.zoom)!==null&&f!==void 0?f:b);this._normalizeCenter(re,m);const ce=m.zoomScale(le-b),he=m.project(Q),te=m.project(re).sub(he);let me=s.curve;const ge=Math.max(m.width,m.height),xe=ge/ce,Oe=te.mag();if("minZoom"in s){const et=l.ac(Math.min(s.minZoom,b,le),m.minZoom,m.maxZoom),Pt=ge/m.zoomScale(et-b);me=Math.sqrt(Pt/Oe*2)}const Fe=me*me;function Ke(et){const Pt=(xe*xe-ge*ge+(et?-1:1)*Fe*Fe*Oe*Oe)/(2*(et?xe:ge)*Fe*Oe);return Math.log(Math.sqrt(Pt*Pt+1)-Pt)}function nt(et){return(Math.exp(et)-Math.exp(-et))/2}function We(et){return(Math.exp(et)+Math.exp(-et))/2}const He=Ke(!1);let pt=function(et){return We(He)/We(He+me*et)},Ot=function(et){return ge*((We(He)*(nt(Pt=He+me*et)/We(Pt))-nt(He))/Fe)/Oe;var Pt},Ge=(Ke(!0)-He)/me;if(Math.abs(Oe)<1e-6||!isFinite(Ge)){if(Math.abs(ge-xe)<1e-6)return this.easeTo(s,d);const et=xe<ge?-1:1;Ge=Math.abs(Math.log(xe/ge))/me,Ot=()=>0,pt=Pt=>Math.exp(et*me*Pt)}return s.duration="duration"in s?+s.duration:1e3*Ge/("screenSpeed"in s?+s.screenSpeed/me:+s.speed),s.maxDuration&&s.duration>s.maxDuration&&(s.duration=0),this._zooming=!0,this._rotating=M!==L,this._pitching=B!==P,this._padding=!m.isPaddingEqual(F),this._prepareEase(d,!1),this.terrain&&this._prepareElevation(re),this._ease(et=>{const Pt=et*Ge,Nn=1/pt(Pt);m.zoom=et===1?le:b+m.scaleZoom(Nn),this._rotating&&(m.bearing=l.y.number(M,L,et)),this._pitching&&(m.pitch=l.y.number(P,B,et)),this._padding&&(m.interpolatePadding(D,F,et),K=m.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(et);const Ft=et===1?re:m.unproject(he.add(te.mult(Ot(Pt))).mult(Nn));m.setLocationAtPoint(m.renderWorldCopies?Ft.wrap():Ft,K),this._applyUpdatedTransform(m),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 f;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const m=this._onEaseEnd;delete this._onEaseEnd,m.call(this,d)}return s||(f=this.handlers)===null||f===void 0||f.stop(!1),this}_ease(s,d,f){f.animate===!1||f.duration===0?(s(1),d()):(this._easeStart=E.now(),this._easeOptions=f,this._onEaseFrame=s,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(s,d){s=l.b3(s,-180,180);const f=Math.abs(s-d);return Math.abs(s-360-d)<f&&(s-=360),Math.abs(s+360-d)<f&&(s+=360),s}_normalizeCenter(s,d){if(!d.renderWorldCopies||d.lngRange)return;const f=s.lng-d.center.lng;s.lng+=f>180?-360:f<-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=T.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=T.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=T.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(){T.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 f=this._map._getUIString(`AttributionControl.${d}`);s.title=f,s.setAttribute("aria-label",f)}_updateAttributions(){if(!this._map.style)return;let s=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?s=s.concat(this.options.customAttribution.map(m=>typeof m!="string"?"":m)):typeof this.options.customAttribution=="string"&&s.push(this.options.customAttribution)),this._map.style.stylesheet){const m=this._map.style.stylesheet;this.styleOwner=m.owner,this.styleId=m.id}const d=this._map.style.sourceCaches;for(const m in d){const b=d[m];if(b.used||b.usedForTerrain){const M=b.getSource();M.attribution&&s.indexOf(M.attribution)<0&&s.push(M.attribution)}}s=s.filter(m=>String(m).trim()),s.sort((m,b)=>m.length-b.length),s=s.filter((m,b)=>{for(let M=b+1;M<s.length;M++)if(s[M].indexOf(m)>=0)return!1;return!0});const f=s.join(" | ");f!==this._attribHTML&&(this._attribHTML=f,s.length?(this._innerContainer.innerHTML=f,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 f=d[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&f.classList.add("maplibregl-compact"):f.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=T.create("div","maplibregl-ctrl");const d=T.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(){T.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Jt{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,f=d?this._queue.concat(d):this._queue;for(const m of f)if(m.id===s)return void(m.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 f of d)if(!f.cancelled&&(f.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 m_ 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 f={};for(const m of s.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:d}))f[m.key]=!0,this._renderableTilesKeys.push(m.key),this._tiles[m.key]||(m.posMatrix=new Float64Array(16),l.aP(m.posMatrix,0,l.X,0,l.X,0,1),this._tiles[m.key]=new Ts(m,this.tileSize));for(const m in this._tiles)f[m]||delete this._tiles[m]}freeRtt(s){for(const d in this._tiles){const f=this._tiles[d];(!s||f.tileID.equals(s)||f.tileID.isChildOf(s)||s.isChildOf(f.tileID))&&(f.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(s=>this.getTileByID(s))}getTileByID(s){return this._tiles[s]}getTerrainCoords(s){const d={};for(const f of this._renderableTilesKeys){const m=this._tiles[f].tileID;if(m.canonical.equals(s.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16),l.aP(b.posMatrix,0,l.X,0,l.X,0,1),d[f]=b}else if(m.canonical.isChildOf(s.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16);const M=m.canonical.z-s.canonical.z,P=m.canonical.x-(m.canonical.x>>M<<M),D=m.canonical.y-(m.canonical.y>>M<<M),L=l.X>>M;l.aP(b.posMatrix,0,L,0,L,0,1),l.J(b.posMatrix,b.posMatrix,[-P*L,-D*L,0]),d[f]=b}else if(s.canonical.isChildOf(m.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16);const M=s.canonical.z-m.canonical.z,P=s.canonical.x-(s.canonical.x>>M<<M),D=s.canonical.y-(s.canonical.y>>M<<M),L=l.X>>M;l.aP(b.posMatrix,0,l.X,0,l.X,0,1),l.J(b.posMatrix,b.posMatrix,[P*L,D*L,0]),l.K(b.posMatrix,b.posMatrix,[1/2**M,1/2**M,0]),d[f]=b}}return d}getSourceTile(s,d){const f=this.sourceCache._source;let m=s.overscaledZ-this.deltaZoom;if(m>f.maxzoom&&(m=f.maxzoom),m<f.minzoom)return null;this._sourceTileCache[s.key]||(this._sourceTileCache[s.key]=s.scaledTo(m).key);let b=this.sourceCache.getTileByID(this._sourceTileCache[s.key]);if((!b||!b.dem)&&d)for(;m>=f.minzoom&&(!b||!b.dem);)b=this.sourceCache.getTileByID(s.scaledTo(m--).key);return b}tilesAfterTime(s=Date.now()){return Object.values(this._tiles).filter(d=>d.timeAdded>=s)}}class Od{constructor(s,d,f){this.painter=s,this.sourceCache=new m_(d),this.options=f,this.exaggeration=typeof f.exaggeration=="number"?f.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(s,d,f,m=l.X){var b;if(!(d>=0&&d<m&&f>=0&&f<m))return 0;const M=this.getTerrainData(s),P=(b=M.tile)===null||b===void 0?void 0:b.dem;if(!P)return 0;const D=function(Q,re,le){var ce=re[0],he=re[1];return Q[0]=le[0]*ce+le[4]*he+le[12],Q[1]=le[1]*ce+le[5]*he+le[13],Q}([],[d/m*l.X,f/m*l.X],M.u_terrain_matrix),L=[D[0]*P.dim,D[1]*P.dim],B=Math.floor(L[0]),F=Math.floor(L[1]),W=L[0]-B,K=L[1]-F;return P.get(B,F)*(1-W)*(1-K)+P.get(B+1,F)*W*(1-K)+P.get(B,F+1)*(1-W)*K+P.get(B+1,F+1)*W*K}getElevationForLngLatZoom(s,d){if(!l.bb(d,s.wrap()))return 0;const{tileID:f,mercatorX:m,mercatorY:b}=this._getOverscaledTileIDFromLngLatZoom(s,d);return this.getElevation(f,m%l.X,b%l.X,l.X)}getElevation(s,d,f,m=l.X){return this.getDEMElevation(s,d,f,m)*this.exaggeration}getTerrainData(s){if(!this._emptyDemTexture){const m=this.painter.context,b=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new it(m,b,m.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new it(m,new l.R({width:1,height:1}),m.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(m.gl.NEAREST,m.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.an([])}const d=this.sourceCache.getSourceTile(s,!0);if(d&&d.dem&&(!d.demTexture||d.needsTerrainPrepare)){const m=this.painter.context;d.demTexture=this.painter.getTileTexture(d.dem.stride),d.demTexture?d.demTexture.update(d.dem.getPixels(),{premultiply:!1}):d.demTexture=new it(m,d.dem.getPixels(),m.gl.RGBA,{premultiply:!1}),d.demTexture.bind(m.gl.NEAREST,m.gl.CLAMP_TO_EDGE),d.needsTerrainPrepare=!1}const f=d&&d+d.tileID.key+s.key;if(f&&!this._demMatrixCache[f]){const m=this.sourceCache.sourceCache._source.maxzoom;let b=s.canonical.z-d.tileID.canonical.z;s.overscaledZ>s.canonical.z&&(s.canonical.z>=m?b=s.canonical.z-m:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=s.canonical.x-(s.canonical.x>>b<<b),P=s.canonical.y-(s.canonical.y>>b<<b),D=l.bc(new Float64Array(16),[1/(l.X<<b),1/(l.X<<b),0]);l.J(D,D,[M*l.X,P*l.X,0]),this._demMatrixCache[s.key]={matrix:D,coord:s}}return{u_depth:2,u_terrain:3,u_terrain_dim:d&&d.dem&&d.dem.dim||1,u_terrain_matrix:f?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,f=d.width/devicePixelRatio,m=d.height/devicePixelRatio;return!this._fbo||this._fbo.width===f&&this._fbo.height===m||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new it(d.context,{width:f,height:m,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 it(d.context,{width:f,height:m,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(f,m,!0,!1),this._fbo.depthAttachment.set(d.context.createRenderbuffer(d.context.gl.DEPTH_COMPONENT16,f,m))),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 b=0,M=0;b<this._coordsTextureSize;b++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)d[M+0]=255&P,d[M+1]=255&b,d[M+2]=P>>8<<4|b>>8,d[M+3]=0;const f=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(d.buffer)),m=new it(s,f,s.gl.RGBA,{premultiply:!1});return m.bind(s.gl.NEAREST,s.gl.CLAMP_TO_EDGE),this._coordsTexture=m,m}pointCoordinate(s){this.painter.maybeDrawDepthAndCoords(!0);const d=new Uint8Array(4),f=this.painter.context,m=f.gl,b=Math.round(s.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(s.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);f.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),m.readPixels(b,P-M-1,1,1,m.RGBA,m.UNSIGNED_BYTE,d),f.bindFramebuffer.set(null);const D=d[0]+(d[2]>>4<<8),L=d[1]+((15&d[2])<<8),B=this.coordsIndex[255-d[3]],F=B&&this.sourceCache.getTileByID(B);if(!F)return null;const W=this._coordsTextureSize,K=(1<<F.tileID.canonical.z)*W;return new l.Z((F.tileID.canonical.x*W+D)/K+F.tileID.wrap,(F.tileID.canonical.y*W+L)/K,this.getElevation(F.tileID,D,L,W))}depthAtPoint(s){const d=new Uint8Array(4),f=this.painter.context,m=f.gl;return f.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),m.readPixels(s.x,this.painter.height/devicePixelRatio-s.y-1,1,1,m.RGBA,m.UNSIGNED_BYTE,d),f.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,f=new l.aY,m=this.meshSize,b=l.X/m,M=m*m;for(let F=0;F<=m;F++)for(let W=0;W<=m;W++)d.emplaceBack(W*b,F*b,0);for(let F=0;F<M;F+=m+1)for(let W=0;W<m;W++)f.emplaceBack(W+F,m+W+F+1,m+W+F+2),f.emplaceBack(W+F,m+W+F+2,W+F+1);const P=d.length,D=P+2*(m+1);for(const F of[0,1])for(let W=0;W<=m;W++)for(const K of[0,1])d.emplaceBack(W*b,F*l.X,K);for(let F=0;F<2*m;F+=2)f.emplaceBack(D+F,D+F+1,D+F+3),f.emplaceBack(D+F,D+F+3,D+F+2),f.emplaceBack(P+F,P+F+3,P+F+1),f.emplaceBack(P+F,P+F+2,P+F+3);const L=d.length,B=L+2*(m+1);for(const F of[0,1])for(let W=0;W<=m;W++)for(const K of[0,1])d.emplaceBack(F*l.X,W*b,K);for(let F=0;F<2*m;F+=2)f.emplaceBack(L+F,L+F+1,L+F+3),f.emplaceBack(L+F,L+F+3,L+F+2),f.emplaceBack(B+F,B+F+3,B+F+1),f.emplaceBack(B+F,B+F+2,B+F+3);return this._mesh=new gu(s.createVertexBuffer(d,Dd.members),s.createIndexBuffer(f),l.a0.simpleSegment(0,0,d.length,f.length)),this._mesh}getMeshFrameDelta(s){return 2*Math.PI*l.be/Math.pow(2,s)/5}getMinTileElevationForLngLatZoom(s,d){var f;const{tileID:m}=this._getOverscaledTileIDFromLngLatZoom(s,d);return(f=this.getMinMaxElevation(m).minElevation)!==null&&f!==void 0?f:0}getMinMaxElevation(s){const d=this.getTerrainData(s).tile,f={minElevation:null,maxElevation:null};return d&&d.dem&&(f.minElevation=d.dem.min*this.exaggeration,f.maxElevation=d.dem.max*this.exaggeration),f}_getOverscaledTileIDFromLngLatZoom(s,d){const f=l.Z.fromLngLat(s.wrap()),m=(1<<d)*l.X,b=f.x*m,M=f.y*m,P=Math.floor(b/l.X),D=Math.floor(M/l.X);return{tileID:new l.S(d,0,d,P,D),mercatorX:b,mercatorY:M}}}class g_{constructor(s,d,f){this._context=s,this._size=d,this._tileSize=f,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),f=new it(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return f.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(f.texture),{id:s,fbo:d,texture:f,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 km{constructor(s,d){this.painter=s,this.terrain=d,this.pool=new g_(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(f=>!s._layers[f].isHidden(d)),this._coordsDescendingInv={};for(const f in s.sourceCaches){this._coordsDescendingInv[f]={};const m=s.sourceCaches[f].getVisibleCoordinates();for(const b of m){const M=this.terrain.sourceCache.getTerrainCoords(b);for(const P in M)this._coordsDescendingInv[f][P]||(this._coordsDescendingInv[f][P]=[]),this._coordsDescendingInv[f][P].push(M[P])}}this._coordsDescendingInvStr={};for(const f of s._order){const m=s._layers[f],b=m.source;if(Za[m.type]&&!this._coordsDescendingInvStr[b]){this._coordsDescendingInvStr[b]={};for(const M in this._coordsDescendingInv[b])this._coordsDescendingInvStr[b][M]=this._coordsDescendingInv[b][M].map(P=>P.key).sort().join()}}for(const f of this._renderableTiles)for(const m in this._coordsDescendingInvStr){const b=this._coordsDescendingInvStr[m][f.tileID.key];b&&b!==f.rttCoords[m]&&(f.rtt=[])}}renderLayer(s){if(s.isHidden(this.painter.transform.zoom))return!1;const d=s.type,f=this.painter,m=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),!m))return!0;if(Za[this._prevType]||Za[d]&&m){this._prevType=d;const b=this._stacks.length-1,M=this._stacks[b]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(mm(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[b]){const L=this.pool.getObjectForId(P.rtt[b].id);if(L.stamp===P.rtt[b].stamp){this.pool.useObject(L);continue}}const D=this.pool.getOrCreateFreeObject();this.pool.useObject(D),this.pool.stampObject(D),P.rtt[b]={id:D.id,stamp:D.stamp},f.context.bindFramebuffer.set(D.fbo.framebuffer),f.context.clear({color:l.aM.transparent,stencil:0}),f.currentStencilSource=void 0;for(let L=0;L<M.length;L++){const B=f.style._layers[M[L]],F=B.source?this._coordsDescendingInv[B.source][P.tileID.key]:[P.tileID];f.context.viewport.set([0,0,D.fbo.width,D.fbo.height]),f._renderTileClippingMasks(B,F),f.renderLayer(f,f.style.sourceCaches[B.source],B,F),B.source&&(P.rttCoords[B.source]=this._coordsDescendingInvStr[B.source][P.tileID.key])}}return mm(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Za[d]}return!1}}const zd={"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"},Sm=g,y_={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},Rd=x=>{x.touchstart=x.dragStart,x.touchmoveWindow=x.dragMove,x.touchend=x.dragEnd},__={showCompass:!0,showZoom:!0,visualizePitch:!1};class b_{constructor(s,d,f=!1){this.mousedown=M=>{this.startMouse(l.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),T.mousePos(this.element,M)),T.addEventListener(window,"mousemove",this.mousemove),T.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,T.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=T.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),T.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=T.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 m=s.dragRotate._mouseRotate.getClickTolerance(),b=s.dragRotate._mousePitch.getClickTolerance();this.element=d,this.mouseRotate=wd({clickTolerance:m,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:D=.8})=>{const L=new vd;return new qs({clickTolerance:P,move:(B,F)=>({bearingDelta:(F.x-B.x)*D}),moveStateManager:L,enable:M,assignEvents:Rd})})({clickTolerance:m,enable:!0}),this.map=s,f&&(this.mousePitch=kd({clickTolerance:b,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:D=-.5})=>{const L=new vd;return new qs({clickTolerance:P,move:(B,F)=>({pitchDelta:(F.y-B.y)*D}),moveStateManager:L,enable:M,assignEvents:Rd})})({clickTolerance:b,enable:!0})),T.addEventListener(d,"mousedown",this.mousedown),T.addEventListener(d,"touchstart",this.touchstart,{passive:!1}),T.addEventListener(d,"touchcancel",this.reset)}startMouse(s,d){this.mouseRotate.dragStart(s,d),this.mousePitch&&this.mousePitch.dragStart(s,d),T.disableDrag()}startTouch(s,d){this.touchRotate.dragStart(s,d),this.touchPitch&&this.touchPitch.dragStart(s,d),T.disableDrag()}moveMouse(s,d){const f=this.map,{bearingDelta:m}=this.mouseRotate.dragMove(s,d)||{};if(m&&f.setBearing(f.getBearing()+m),this.mousePitch){const{pitchDelta:b}=this.mousePitch.dragMove(s,d)||{};b&&f.setPitch(f.getPitch()+b)}}moveTouch(s,d){const f=this.map,{bearingDelta:m}=this.touchRotate.dragMove(s,d)||{};if(m&&f.setBearing(f.getBearing()+m),this.touchPitch){const{pitchDelta:b}=this.touchPitch.dragMove(s,d)||{};b&&f.setPitch(f.getPitch()+b)}}off(){const s=this.element;T.removeEventListener(s,"mousedown",this.mousedown),T.removeEventListener(s,"touchstart",this.touchstart,{passive:!1}),T.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.removeEventListener(window,"touchend",this.touchend),T.removeEventListener(s,"touchcancel",this.reset),this.offTemp()}offTemp(){T.enableDrag(),T.removeEventListener(window,"mousemove",this.mousemove),T.removeEventListener(window,"mouseup",this.mouseup),T.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.removeEventListener(window,"touchend",this.touchend)}}let _r;function Ln(x,s,d){const f=new l.N(x.lng,x.lat);if(x=new l.N(x.lng,x.lat),s){const m=new l.N(x.lng-360,x.lat),b=new l.N(x.lng+360,x.lat),M=d.locationPoint(x).distSqr(s);d.locationPoint(m).distSqr(s)<M?x=m:d.locationPoint(b).distSqr(s)<M&&(x=b)}for(;Math.abs(x.lng-d.center.lng)>180;){const m=d.locationPoint(x);if(m.x>=0&&m.y>=0&&m.x<=d.width&&m.y<=d.height)break;x.lng>d.center.lng?x.lng-=360:x.lng+=360}return x.lng!==f.lng&&d.locationPoint(x).y>d.height/2-d.getHorizon()?x:f}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(x,s,d){const f=x.classList;for(const m in Ya)f.remove(`maplibregl-${d}-anchor-${m}`);f.add(`maplibregl-${d}-anchor-${s}`)}class Mu extends l.E{constructor(s){if(super(),this._onKeyPress=d=>{const f=d.code,m=d.charCode||d.keyCode;f!=="Space"&&f!=="Enter"&&m!==32&&m!==13||this.togglePopup()},this._onMapClick=d=>{const f=d.originalEvent.target,m=this._element;this._popup&&(f===m||m.contains(f))&&this.togglePopup()},this._update=d=>{var f;if(!this._map)return;const m=this._map.loaded()&&!this._map.isMoving();((d==null?void 0:d.type)==="terrain"||(d==null?void 0:d.type)==="render"&&!m)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Ln(this._lngLat,this._flatPos,this._map.transform):(f=this._lngLat)===null||f===void 0?void 0:f.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 b="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?b=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(b=`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()),T.setTransform(this._element,`${Ya[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${b}`),E.frameAsync(new AbortController).then(()=>{this._updateOpacity(d&&d.type==="moveend")}).catch(()=>{})},this._onMove=d=>{if(!this._isDragging){const f=this._clickTolerance||this._map._clickTolerance;this._isDragging=d.point.dist(this._pointerdownPos)>=f}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=T.create("div");const d=T.createNS("http://www.w3.org/2000/svg","svg"),f=41,m=27;d.setAttributeNS(null,"display","block"),d.setAttributeNS(null,"height",`${f}px`),d.setAttributeNS(null,"width",`${m}px`),d.setAttributeNS(null,"viewBox",`0 0 ${m} ${f}`);const b=T.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"stroke","none"),b.setAttributeNS(null,"stroke-width","1"),b.setAttributeNS(null,"fill","none"),b.setAttributeNS(null,"fill-rule","evenodd");const M=T.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=T.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const D=[{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 D){const he=T.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 L=T.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"fill",this._color);const B=T.createNS("http://www.w3.org/2000/svg","path");B.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"),L.appendChild(B);const F=T.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");const W=T.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 K=T.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(6.0, 7.0)"),K.setAttributeNS(null,"fill","#FFFFFF");const Q=T.createNS("http://www.w3.org/2000/svg","g");Q.setAttributeNS(null,"transform","translate(8.0, 8.0)");const re=T.createNS("http://www.w3.org/2000/svg","circle");re.setAttributeNS(null,"fill","#000000"),re.setAttributeNS(null,"opacity","0.25"),re.setAttributeNS(null,"cx","5.5"),re.setAttributeNS(null,"cy","5.5"),re.setAttributeNS(null,"r","5.4999962");const le=T.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"),Q.appendChild(re),Q.appendChild(le),M.appendChild(P),M.appendChild(L),M.appendChild(F),M.appendChild(K),M.appendChild(Q),d.appendChild(M),d.setAttributeNS(null,"height",f*this._scale+"px"),d.setAttributeNS(null,"width",m*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),T.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 m=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":[m,-1*(38.1-13.5+m)],"bottom-right":[-m,-1*(38.1-13.5+m)],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,f;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 m=this._map,b=m.terrain.depthAtPoint(this._pos),M=m.terrain.getElevationForLngLatZoom(this._lngLat,m.transform.tileZoom);if(m.transform.lngLatToCameraDepth(this._lngLat,M)-b<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/m.transform._pixelPerMeter,D=Math.sin(m.getPitch()*Math.PI/180)*P,L=m.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),B=m.transform.lngLatToCameraDepth(this._lngLat,M+D)-L>.006;!((f=this._popup)===null||f===void 0)&&f.isOpen()&&B&&this._popup.remove(),this._element.style.opacity=B?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 Em={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(x,s,d){const f=d&&d.maxWidth||100,m=x._container.clientHeight/2,b=x.unproject([0,m]),M=x.unproject([f,m]),P=b.distanceTo(M);if(d&&d.unit==="imperial"){const D=3.2808*P;D>5280?dt(s,f,D/5280,x._getUIString("ScaleControl.Miles")):dt(s,f,D,x._getUIString("ScaleControl.Feet"))}else d&&d.unit==="nautical"?dt(s,f,P/1852,x._getUIString("ScaleControl.NauticalMiles")):P>=1e3?dt(s,f,P/1e3,x._getUIString("ScaleControl.Kilometers")):dt(s,f,P,x._getUIString("ScaleControl.Meters"))}function dt(x,s,d,f){const m=function(b){const M=Math.pow(10,`${Math.floor(b)}`.length-1);let P=b/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(D){const L=Math.pow(10,Math.ceil(-Math.log(D)/Math.LN10));return Math.round(D*L)/L}(P),M*P}(d);x.style.width=s*(m/d)+"px",x.innerHTML=`${m} ${f}`}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(x){if(x){if(typeof x=="number"){const s=Math.round(Math.abs(x)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,x),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-x),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(x,0),right:new l.P(-x,0)}}if(x instanceof l.P||Array.isArray(x)){const s=l.P.convert(x);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(x.center||[0,0]),top:l.P.convert(x.top||[0,0]),"top-left":l.P.convert(x["top-left"]||[0,0]),"top-right":l.P.convert(x["top-right"]||[0,0]),bottom:l.P.convert(x.bottom||[0,0]),"bottom-left":l.P.convert(x["bottom-left"]||[0,0]),"bottom-right":l.P.convert(x["bottom-right"]||[0,0]),left:l.P.convert(x.left||[0,0]),right:l.P.convert(x.right||[0,0])}}return Pu(new l.P(0,0))}const Ld=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=yr,u.CanvasSource=xi,u.CooperativeGesturesHandler=qa,u.DoubleClickZoomHandler=Ko,u.DragPanHandler=xm,u.DragRotateHandler=vm,u.EdgeInsets=$a,u.FullscreenControl=class extends l.E{constructor(x={}){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,x&&x.container&&(x.container instanceof HTMLElement?this._container=x.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(x){return this._map=x,this._container||(this._container=this._map.getContainer()),this._controlContainer=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){T.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const x=this._fullscreenButton=T.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);T.create("span","maplibregl-ctrl-icon",x).setAttribute("aria-hidden","true"),x.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const x=this._getTitle();this._fullscreenButton.setAttribute("aria-label",x),this._fullscreenButton.title=x}_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=er,u.GeolocateControl=class extends l.E{constructor(x){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),f=s.coords.accuracy,m=this._map.getBearing(),b=l.e({bearing:m},this.options.fitBoundsOptions),M=we.fromLngLat(d,f);this._map.fitBounds(M,b,{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=T.create("button","maplibregl-ctrl-geolocate",this._container),T.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=T.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Mu({element:this._dotElement}),this._circleElement=T.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({},Em,x)}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,function*(s=!1){if(_r!==void 0&&!s)return _r;if(window.navigator.permissions===void 0)return _r=!!window.navigator.geolocation,_r;try{_r=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_r=!!window.navigator.geolocation}return _r})}().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(),T.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Jl=0,Ql=!1}_isOutOfMapMaxBounds(x){const s=this._map.getMaxBounds(),d=x.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 x=this._map.getBounds(),s=x.getSouthEast(),d=x.getNorthEast(),f=s.distanceTo(d),m=Math.ceil(this._accuracy/(f/this._map._container.clientHeight)*2);this._circleElement.style.width=`${m}px`,this._circleElement.style.height=`${m}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 x;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Jl++,Jl>1?(x={maximumAge:6e5,timeout:0},Ql=!0):(x=this.options.positionOptions,Ql=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,x)}}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=bi,u.KeyboardHandler=Nr,u.LngLatBounds=we,u.LogoControl=Id,u.Map=class extends wm{constructor(x){l.bf.mark(l.bg.create);const s=Object.assign(Object.assign({},y_),x);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 Jt,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({},zd),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=oe.addThrottleControl(()=>this.isMoving()),this._requestManager=new J(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 f=Gl(m=>{this._trackResize&&!this._removed&&(this.resize(m),this.redraw())},50);this._resizeObserver=new ResizeObserver(m=>{d?f(m):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(x,s){if(s===void 0&&(s=x.getDefaultPosition?x.getDefaultPosition():"top-right"),!x||!x.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=x.onAdd(this);this._controls.push(x);const f=this._controlPositions[s];return s.indexOf("bottom")!==-1?f.insertBefore(d,f.firstChild):f.appendChild(d),this}removeControl(x){if(!x||!x.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(x);return s>-1&&this._controls.splice(s,1),x.onRemove(this),this}hasControl(x){return this._controls.indexOf(x)>-1}calculateCameraOptionsFromTo(x,s,d,f){return f==null&&this.terrain&&(f=this.terrain.getElevationForLngLatZoom(d,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(x,s,d,f)}resize(x){var s;const d=this._containerDimensions(),f=d[0],m=d[1],b=this._getClampedPixelRatio(f,m);if(this._resizeCanvas(f,m,b),this.painter.resize(f,m,b),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const D=this._getClampedPixelRatio(f,m);this._resizeCanvas(f,m,D),this.painter.resize(f,m,D)}this.transform.resize(f,m),(s=this._requestedCameraState)===null||s===void 0||s.resize(f,m);const M=!this._moving;return M&&(this.stop(),this.fire(new l.k("movestart",x)).fire(new l.k("move",x))),this.fire(new l.k("resize",x)),M&&this.fire(new l.k("moveend",x)),this}_getClampedPixelRatio(x,s){const{0:d,1:f}=this._maxCanvasSize,m=this.getPixelRatio(),b=x*m,M=s*m;return Math.min(b>d?d/b:1,M>f?f/M:1)*m}getPixelRatio(){var x;return(x=this._overridePixelRatio)!==null&&x!==void 0?x:devicePixelRatio}setPixelRatio(x){this._overridePixelRatio=x,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(x){return this.transform.setMaxBounds(we.convert(x)),this._update()}setMinZoom(x){if((x=x??-2)>=-2&&x<=this.transform.maxZoom)return this.transform.minZoom=x,this._update(),this.getZoom()<x&&this.setZoom(x),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(x){if((x=x??22)>=this.transform.minZoom)return this.transform.maxZoom=x,this._update(),this.getZoom()>x&&this.setZoom(x),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(x){if((x=x??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(x>=0&&x<=this.transform.maxPitch)return this.transform.minPitch=x,this._update(),this.getPitch()<x&&this.setPitch(x),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(x){if((x=x??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(x>=this.transform.minPitch)return this.transform.maxPitch=x,this._update(),this.getPitch()>x&&this.setPitch(x),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(x){return this.transform.renderWorldCopies=x,this._update()}project(x){return this.transform.locationPoint(l.N.convert(x),this.style&&this.terrain)}unproject(x){return this.transform.pointLocation(l.P.convert(x),this.terrain)}isMoving(){var x;return this._moving||((x=this.handlers)===null||x===void 0?void 0:x.isMoving())}isZooming(){var x;return this._zooming||((x=this.handlers)===null||x===void 0?void 0:x.isZooming())}isRotating(){var x;return this._rotating||((x=this.handlers)===null||x===void 0?void 0:x.isRotating())}_createDelegatedListener(x,s,d){if(x==="mouseenter"||x==="mouseover"){let f=!1;return{layers:s,listener:d,delegates:{mousemove:b=>{const M=s.filter(D=>this.getLayer(D)),P=M.length!==0?this.queryRenderedFeatures(b.point,{layers:M}):[];P.length?f||(f=!0,d.call(this,new Pi(x,this,b.originalEvent,{features:P}))):f=!1},mouseout:()=>{f=!1}}}}if(x==="mouseleave"||x==="mouseout"){let f=!1;return{layers:s,listener:d,delegates:{mousemove:M=>{const P=s.filter(D=>this.getLayer(D));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?f=!0:f&&(f=!1,d.call(this,new Pi(x,this,M.originalEvent)))},mouseout:M=>{f&&(f=!1,d.call(this,new Pi(x,this,M.originalEvent)))}}}}{const f=m=>{const b=s.filter(P=>this.getLayer(P)),M=b.length!==0?this.queryRenderedFeatures(m.point,{layers:b}):[];M.length&&(m.features=M,d.call(this,m),delete m.features)};return{layers:s,listener:d,delegates:{[x]:f}}}}_saveDelegatedListener(x,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[x]=this._delegatedListeners[x]||[],this._delegatedListeners[x].push(s)}_removeDelegatedListener(x,s,d){if(!this._delegatedListeners||!this._delegatedListeners[x])return;const f=this._delegatedListeners[x];for(let m=0;m<f.length;m++){const b=f[m];if(b.listener===d&&b.layers.length===s.length&&b.layers.every(M=>s.includes(M))){for(const M in b.delegates)this.off(M,b.delegates[M]);return void f.splice(m,1)}}}on(x,s,d){if(d===void 0)return super.on(x,s);const f=this._createDelegatedListener(x,typeof s=="string"?[s]:s,d);this._saveDelegatedListener(x,f);for(const m in f.delegates)this.on(m,f.delegates[m]);return this}once(x,s,d){if(d===void 0)return super.once(x,s);const f=typeof s=="string"?[s]:s,m=this._createDelegatedListener(x,f,d);for(const b in m.delegates){const M=m.delegates[b];m.delegates[b]=(...P)=>{this._removeDelegatedListener(x,f,d),M(...P)}}this._saveDelegatedListener(x,m);for(const b in m.delegates)this.once(b,m.delegates[b]);return this}off(x,s,d){return d===void 0?super.off(x,s):(this._removeDelegatedListener(x,typeof s=="string"?[s]:s,d),this)}queryRenderedFeatures(x,s){if(!this.style)return[];let d;const f=x instanceof l.P||Array.isArray(x),m=f?x:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(f?{}:x)||{},m instanceof l.P||typeof m[0]=="number")d=[l.P.convert(m)];else{const b=l.P.convert(m[0]),M=l.P.convert(m[1]);d=[b,new l.P(M.x,b.y),M,new l.P(b.x,M.y),b]}return this.style.queryRenderedFeatures(d,s,this.transform)}querySourceFeatures(x,s){return this.style.querySourceFeatures(x,s)}setStyle(x,s){return(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff!==!1&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&x?(this._diffStyle(x,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(x,s))}setTransformRequest(x){return this._requestManager.setTransformRequest(x),this}_getUIString(x){const s=this._locale[x];if(s==null)throw new Error(`Missing UI string '${x}'`);return s}_updateStyle(x,s){if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(x,s));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!x)),x?(this.style=new tu(this,s||{}),this.style.setEventedParent(this,{style:this.style}),typeof x=="string"?this.style.loadURL(x,s,d):this.style.loadJSON(x,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(x,s){if(typeof x=="string"){const d=this._requestManager.transformRequest(x,"Style");l.h(d,new AbortController).then(f=>{this._updateDiff(f.data,s)}).catch(f=>{f&&this.fire(new l.j(f))})}else typeof x=="object"&&this._updateDiff(x,s)}_updateDiff(x,s){try{this.style.setState(x,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(x,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(x,s){return this._lazyInitEmptyStyle(),this.style.addSource(x,s),this._update(!0)}isSourceLoaded(x){const s=this.style&&this.style.sourceCaches[x];if(s!==void 0)return s.loaded();this.fire(new l.j(new Error(`There is no source with ID '${x}'`)))}setTerrain(x){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),x){const s=this.style.sourceCaches[x.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${x.source}`);this.terrain===null&&s.reload();for(const d in this.style._layers){const f=this.style._layers[d];f.type==="hillshade"&&f.source===x.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,x),this.painter.renderToTexture=new km(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!==x.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:x})),this}getTerrain(){var x,s;return(s=(x=this.terrain)===null||x===void 0?void 0:x.options)!==null&&s!==void 0?s:null}areTilesLoaded(){const x=this.style&&this.style.sourceCaches;for(const s in x){const d=x[s]._tiles;for(const f in d){const m=d[f];if(m.state!=="loaded"&&m.state!=="errored")return!1}}return!0}removeSource(x){return this.style.removeSource(x),this._update(!0)}getSource(x){return this.style.getSource(x)}addImage(x,s,d={}){const{pixelRatio:f=1,sdf:m=!1,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L}=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:B,height:F,data:W}=s,K=s;return this.style.addImage(x,{data:new l.R({width:B,height:F},new Uint8Array(W)),pixelRatio:f,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L,sdf:m,version:0,userImage:K}),K.onAdd&&K.onAdd(this,x),this}}{const{width:B,height:F,data:W}=E.getImageData(s);this.style.addImage(x,{data:new l.R({width:B,height:F},W),pixelRatio:f,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L,sdf:m,version:0})}}updateImage(x,s){const d=this.style.getImage(x);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 f=s instanceof HTMLImageElement||l.b(s)?E.getImageData(s):s,{width:m,height:b,data:M}=f;if(m===void 0||b===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(m!==d.data.width||b!==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(x,d),this}getImage(x){return this.style.getImage(x)}hasImage(x){return x?!!this.style.getImage(x):(this.fire(new l.j(new Error("Missing required image id"))),!1)}removeImage(x){this.style.removeImage(x)}loadImage(x){return oe.getImage(this._requestManager.transformRequest(x,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(x,s){return this._lazyInitEmptyStyle(),this.style.addLayer(x,s),this._update(!0)}moveLayer(x,s){return this.style.moveLayer(x,s),this._update(!0)}removeLayer(x){return this.style.removeLayer(x),this._update(!0)}getLayer(x){return this.style.getLayer(x)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(x,s,d){return this.style.setLayerZoomRange(x,s,d),this._update(!0)}setFilter(x,s,d={}){return this.style.setFilter(x,s,d),this._update(!0)}getFilter(x){return this.style.getFilter(x)}setPaintProperty(x,s,d,f={}){return this.style.setPaintProperty(x,s,d,f),this._update(!0)}getPaintProperty(x,s){return this.style.getPaintProperty(x,s)}setLayoutProperty(x,s,d,f={}){return this.style.setLayoutProperty(x,s,d,f),this._update(!0)}getLayoutProperty(x,s){return this.style.getLayoutProperty(x,s)}setGlyphs(x,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(x,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(x,s,d={}){return this._lazyInitEmptyStyle(),this.style.addSprite(x,s,d,f=>{f||this._update(!0)}),this}removeSprite(x){return this._lazyInitEmptyStyle(),this.style.removeSprite(x),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(x,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(x,s,d=>{d||this._update(!0)}),this}setLight(x,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(x,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(x){return this._lazyInitEmptyStyle(),this.style.setSky(x),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(x,s){return this.style.setFeatureState(x,s),this._update()}removeFeatureState(x,s){return this.style.removeFeatureState(x,s),this._update()}getFeatureState(x){return this.style.getFeatureState(x)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let x=0,s=0;return this._container&&(x=this._container.clientWidth||400,s=this._container.clientHeight||300),[x,s]}_setupContainer(){const x=this._container;x.classList.add("maplibregl-map");const s=this._canvasContainer=T.create("div","maplibregl-canvas-container",x);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=T.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(),f=this._getClampedPixelRatio(d[0],d[1]);this._resizeCanvas(d[0],d[1],f);const m=this._controlContainer=T.create("div","maplibregl-control-container",x),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{b[M]=T.create("div",`maplibregl-ctrl-${M} `,m)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(x,s,d){this._canvas.width=Math.floor(d*x),this._canvas.height=Math.floor(d*s),this._canvas.style.width=`${x}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const x={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let s=null;this._canvas.addEventListener("webglcontextcreationerror",f=>{s={requestedAttributes:x},f&&(s.statusMessage=f.statusMessage,s.type=f.type)},{once:!0});const d=this._canvas.getContext("webgl2",x)||this._canvas.getContext("webgl",x);if(!d){const f="Failed to initialize WebGL";throw s?(s.message=f,new Error(JSON.stringify(s))):new Error(f)}this.painter=new yu(d,this.transform),I.testSupport(d)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(x){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||x,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(x){return this._update(),this._renderTaskQueue.add(x)}_cancelRenderFrame(x){this._renderTaskQueue.remove(x)}_render(x){const s=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(x),this._removed)return;let d=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const m=this.transform.zoom,b=E.now();this.style.zoomHistory.update(m,b);const M=new l.z(m,{now:b,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 f=this._sourcesDirty||this._styleDirty||this._placementDirty;return f||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.k("idle")),!this._loaded||this._fullyLoaded||f||(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 x;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),oe.removeThrottleControl(this._imageQueueHandle),(x=this._resizeObserver)===null||x===void 0||x.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),T.remove(this._canvasContainer),T.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(x=>{l.bf.frame(x),this._frameRequest=null,this._render(x)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(x){this._showTileBoundaries!==x&&(this._showTileBoundaries=x,this._update())}get showPadding(){return!!this._showPadding}set showPadding(x){this._showPadding!==x&&(this._showPadding=x,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(x){this._showCollisionBoxes!==x&&(this._showCollisionBoxes=x,x?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(x){this._showOverdrawInspector!==x&&(this._showOverdrawInspector=x,this._update())}get repaint(){return!!this._repaint}set repaint(x){this._repaint!==x&&(this._repaint=x,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(x){this._vertices=x,this._update()}get version(){return Sm}getCameraTargetElevation(){return this.transform.elevation}},u.MapMouseEvent=Pi,u.MapTouchEvent=Yo,u.MapWheelEvent=ym,u.Marker=Mu,u.NavigationControl=class{constructor(x){this._updateZoomButtons=()=>{const s=this._map.getZoom(),d=s===this._map.getMaxZoom(),f=s===this._map.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=f,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",f.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 f=this._map._getUIString(`NavigationControl.${d}`);s.title=f,s.setAttribute("aria-label",f)},this.options=l.e({},__,x),this._container=T.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})),T.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})),T.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=T.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(x){return this._map=x,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 b_(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){T.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(x,s){const d=T.create("button",x,this._container);return d.type="button",d.addEventListener("click",s),d}},u.Popup=class extends l.E{constructor(x){super(),this.remove=()=>(this._content&&T.remove(this._content),this._container&&(T.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=T.create("div","maplibregl-popup",this._map.getContainer()),this._tip=T.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?Ln(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.wrap(),this._trackPointer&&!s)return;const f=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 m=this.options.anchor;const b=Pu(this.options.offset);if(!m){const P=this._container.offsetWidth,D=this._container.offsetHeight;let L;L=f.y+b.bottom.y<D?["top"]:f.y>this._map.transform.height-D?["bottom"]:[],f.x<P/2?L.push("left"):f.x>this._map.transform.width-P/2&&L.push("right"),m=L.length===0?"bottom":L.join("-")}let M=f.add(b[m]);this.options.subpixelPositioning||(M=M.round()),T.setTransform(this._container,`${Ya[m]} translate(${M.x}px,${M.y}px)`),Tu(this._container,m,"popup")},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(Et),x)}addTo(x){return this._map&&this.remove(),this._map=x,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(x){return this._lngLat=l.N.convert(x),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(x){return this.setDOMContent(document.createTextNode(x))}setHTML(x){const s=document.createDocumentFragment(),d=document.createElement("body");let f;for(d.innerHTML=x;f=d.firstChild,f;)s.appendChild(f);return this.setDOMContent(s)}getMaxWidth(){var x;return(x=this._container)===null||x===void 0?void 0:x.style.maxWidth}setMaxWidth(x){return this.options.maxWidth=x,this._update(),this}setDOMContent(x){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=T.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(x),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(x){return this._container&&this._container.classList.add(x),this}removeClassName(x){return this._container&&this._container.classList.remove(x),this}setOffset(x){return this.options.offset=x,this._update(),this}toggleClassName(x){if(this._container)return this._container.classList.toggle(x)}setSubpixelPositioning(x){this.options.subpixelPositioning=x}_createCloseButton(){this.options.closeButton&&(this._closeButton=T.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const x=this._container.querySelector(Au);x&&x.focus()}},u.RasterDEMTileSource=dn,u.RasterTileSource=Kt,u.ScaleControl=class{constructor(x){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),x)}getDefaultPosition(){return"bottom-left"}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-scale",x.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){T.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},u.ScrollZoomHandler=ts,u.Style=tu,u.TerrainControl=class{constructor(x){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=x}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=T.create("button","maplibregl-ctrl-terrain",this._container),T.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(){T.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=Ss,u.VideoSource=Dr,u.addSourceType=(x,s)=>l._(void 0,void 0,void 0,function*(){if(Cs(x))throw new Error(`A source type called "${x}" already exists.`);((d,f)=>{Es[d]=f})(x,s)}),u.clearPrewarmedResources=function(){const x=Ce;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(Wn),Ce=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 zr().getRTLTextPluginStatus()},u.getVersion=function(){return Ld},u.getWorkerCount=function(){return jn.workerCount},u.getWorkerUrl=function(){return l.a.WORKER_URL},u.importScriptInWorkers=function(x){return Bt().broadcast("IS",x)},u.prewarm=function(){Xe().acquire(Wn)},u.setMaxParallelImageRequests=function(x){l.a.MAX_PARALLEL_IMAGE_REQUESTS=x},u.setRTLTextPlugin=function(x,s){return zr().setRTLTextPlugin(x,s)},u.setWorkerCount=function(x){jn.workerCount=x},u.setWorkerUrl=function(x){l.a.WORKER_URL=x}});var a=n;return a})})(L1);var qO=L1.exports;const WO=UO(qO),Rp=["#FF6633","#FFB399","#FF33FF","#00B3E6","#E6B333","#3366E6","#999966","#99FF99","#B34D4D","#80B300","#809900","#E6B3B3","#6680B3","#66991A","#FF99E6","#CCFF1A","#FF1A66","#E6331A","#33FFCC","#66994D","#B366CC","#4D8000","#B33300","#CC80CC","#66664D","#991AFF","#E666FF","#4DB3FF","#1AB399","#E666B3","#33991A","#CC9999","#B3B31A","#00E680","#4D8066","#809980","#E6FF80","#1AFF33","#999933","#FF3380","#CCCC00","#66E64D","#4D80CC","#9900B3","#E64D66","#4DB380","#FF4D4D","#99E6E6","#6666FF","#FFFF99"],Er={};async function Lp(t="pin4-sm-mi-plumber+f45942.png",e=null){try{const i=t!=null&&t.includes("/")?t:`/api-user/marker_icon/${t}`,r=await e.loadImage(i);if(e.hasImage(t))return;e==null||e.addImage(t,r.data,{sdf:t==null?void 0:t.includes("+sdf")})}catch(n){console.error(n)}}function GO(t){if(!(t!=null&&t.startsWith("rgba")))return t;const e=t.replace(/^rgba?\(|\s+|\)$/g,"").split(",");return`${((1<<24)+(parseInt(e[0],10)<<16)+(parseInt(e[1],10)<<8)+parseInt(e[2],10)).toString(16).slice(1)}`}Er.point=async(t={},e={},n=null)=>{var E,T,I,z,V,H,Z,ee,oe,J,Ae,ke;e||(e={}),((E=e==null?void 0:e.width)==null?void 0:E[0])==="["&&(e.width={stops:JSON.parse(e.width)}),typeof(e==null?void 0:e.width)=="string"&&(e.width-=0),typeof(e==null?void 0:e.opacity)=="string"&&(e.opacity=(e.opacity-0)*100);const i=((T=t.style)==null?void 0:T.colorAttr)||((I=t.style)==null?void 0:I.iconCls);let r={circle:"none-xl-{{marker}}+222.png",circle2:"circle-xl-{{marker}}+222.png",pin2:"pin2-xl-{{marker}}+sdf.png",pin:"pin-xl-{{marker}}+sdf.png"}[e.iconType]||(e==null?void 0:e.icon);const[a,u]=(r==null?void 0:r.split("-"))||[],l=((z=t.style)==null?void 0:z.color)||"blue";!((V=t.style)!=null&&V.iconAttr)&&(r!=null&&r.includes("{{marker}}"))&&(r=r.replace("{{marker}}","fa-star"));const g="gray",_=(Me,Le)=>`${Me==null?void 0:Me.split("+")[0]}+${Le.replace("#","")}.png`;if(t.legendAuto={icon:[],color:[]},(H=t.style)!=null&&H.iconAttr&&r){const Me=(ee=(Z=t.meta)==null?void 0:Z.columns)==null?void 0:ee.find(Ie=>{var Ye;return Ie.name===((Ye=t==null?void 0:t.style)==null?void 0:Ye.iconAttr)}),Le=(Me==null?void 0:Me.values)||await wt.get(`/api-user/gis-ir/${t.id}/${(oe=t.style)==null?void 0:oe.iconAttr}`).then(Ie=>Ie.data.rows);if(Le!=null&&Le.length){const Ie=r.replace("{{color}}",l.length?l:GO(l)||[0]).split("+")[1].split(/[.-]/)[0];Le.forEach((Ye,it)=>{var Nt;return Ye.icon=(Nt=Ye.icon)!=null&&Nt.includes("png")?Ye.icon:`${a}-${u}-${Ye.data||Ye.icon||`ub-${it}`}+${r!=null&&r.includes("circle")?"ddd-222":Ie}.png`}),r=r!=null&&r.includes("{{")?`${a}-${u}-fa-question+0c53ad.png`:r,t.legendAuto.iconText=(Me==null?void 0:Me.title)||t.style.iconAttr,Le.forEach(Ye=>t.legendAuto.icon.push(Ye)),t.legendAuto.icon.push({icon:r,text:"Не визначено"}),t.style.iconArr=["match",["get",t.style.iconAttr]].concat(Le.filter(Ye=>Ye.id).reduce((Ye,it)=>Ye.concat([it.id,it.icon]),[])).concat([r]),await Promise.all(Le.map(Ye=>Ye.icon).map(Ye=>Lp(Ye,n))),await Lp(r,n)}else r=i?"pin6-m-fa-star+{{color}}.png":`pin6-m-fa-star+${l==null?void 0:l.replace("#","")}.png`}if(r!=null&&r.includes("{{color}}")?r=r.replace("{{color}}","222"):e!=null&&e.icon&&e.iconAttr,i){const Me=(Ae=(J=t.meta)==null?void 0:J.columns)==null?void 0:Ae.find(Ie=>Ie.name===i),Le=(Me==null?void 0:Me.values)||await wt.get(`/api-user/gis-ir/${t.id}/${i}`).then(Ie=>Ie.data.rows);t.style.color=Le!=null&&Le.length?["match",["get",i]].concat(Le.filter(Ie=>Ie.id).reduce((Ie,Ye,it)=>Ie.concat([Ye.id,Ye.color||Rp[it]]),[])).concat(["#aaa"]):l,t.style.colorArr=t.style.color,t.legendAuto.colorText=(Me==null?void 0:Me.title)||i,Le.forEach(Ie=>t.legendAuto.color.push(Ie)),t.legendAuto.color.push({color:"#aaa",text:"Не визначено"}),!((ke=t.style)!=null&&ke.iconAttr)&&!(r!=null&&r.includes("+sdf"))&&r&&(Le.forEach((Ie,Ye)=>Ie.icon=_(r,Ie.color||Rp[Ye])),t.style.iconArr=["match",["get",i]].concat(Le.filter(Ie=>Ie.id).reduce((Ie,Ye)=>Ie.concat([Ye.id,Ye.icon]),[])).concat([_(r,g)]),await Promise.all(Le.map(Ie=>Ie.icon).map(Ie=>Lp(Ie,n))))}if(r&&!(r!=null&&r.includes("{"))){const Me=e!=null&&e.colorAttr?_(r,g):r;await Lp(Me,n)}const k=r!=null&&r.includes("sdf")?["interpolate",["linear"],["zoom"],14,.1,18,.2]:["interpolate",["linear"],["zoom"],14,.7,16,1];return e.iconOffset=r!=null&&r.includes("pin")?[0,r!=null&&r.includes("+sdf")?-96:-20]:null,[{id:`${t.id}`,source:t.id,type:"circle",cluster:!0,lsource:e==null?void 0:e.lsource,minzoom:(e==null?void 0:e.minzoom)!==void 0?+(e==null?void 0:e.minzoom):4,maxzoom:(r!=null&&r.includes("+sdf")||!(r!=null&&r.includes("circle"))&&!(r!=null&&r.includes("none"))?+e.iconZoom:null)||+(e==null?void 0:e.maxzoom)||24,filter:["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]],paint:{"circle-stroke-width":["case",["boolean",["feature-state","select"],!1],(e==null?void 0:e.strokeWidth)||1,["boolean",["feature-state","hover"],!1],2,(e==null?void 0:e.strokeWidth)||1],"circle-stroke-color":["case",["boolean",["feature-state","select"],!1],(e==null?void 0:e.stroke)||(e==null?void 0:e.color)||"#fff",["boolean",["feature-state","hover"],!1],"maroon",(e==null?void 0:e.stroke)||(e==null?void 0:e.color)||"#fff"],"circle-opacity":(e.iconZoom?["interpolate",["exponential",.5],["zoom"],+e.iconZoom-1,1,+e.iconZoom,r!=null&&r.includes("none")?.3:0]:null)||e.opacity||1,"circle-color":e.color||["case",["boolean",["feature-state","hover"],!1],"red","blue"],"circle-radius":(Array.isArray(e.width)?{stops:e.width}:null)||e.width||{stops:e.iconZoom?[[+e.iconZoom,4],[+e.iconZoom,8],[18,16]]:[[13,4],[15,8],[18,12]]}}}].concat(e.iconArr||e.icon?[{id:`${t.id}-5`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",minzoom:+e.iconZoom||16,filter:["all",["!",["has","point_count"]]],layout:{"icon-image":e!=null&&e.colorAttr&&e.iconArr||r,"icon-allow-overlap":!0,...e.iconOffset?{"icon-offset":e.iconOffset||!1}:{},...k?{"icon-size":k||!1}:{}},paint:{"icon-opacity":["case",["boolean",["feature-state","hover"],!1],.5,["boolean",["feature-state","select"],!1],.5,(r!=null&&r.includes("+sdf")?1:null)||(r!=null&&r.includes("circle")?.6:1)],...r!=null&&r.includes("+sdf")?{"icon-color":["case",["boolean",["feature-state","hover"],!1],"#cd0bbf",["boolean",["feature-state","select"],!1],"#8517cf",e.color||"#aa0000"]}:{}}}]:[]).concat(e.label?[{id:`${t.id}-4`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",minzoom:14,filter:["!",["has","point_count"]],layout:{"text-field":e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||8},paint:{"text-color":e["text-color"]||"#ffffff","text-halo-color":e["text-halo-color"]||"black"}}]:[]).concat(t.cluster||e.clusterMaxZoom?[{id:`${t.id}-1`,source:t.id,lsource:e==null?void 0:e.lsource,type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#51bbd6",100,"#f1f075",750,"#f28cb1"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}},{id:`${t.id}-2`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Open Sans Regular"],"text-size":12}}]:[])},Er.label=(t={})=>[{id:t.id,source:t.id,type:"line",layout:{"text-field":"{str_name}","text-font":["DIN Offc Pro Italic","Arial Unicode MS Regular"],"symbol-placement":"line","text-pitch-alignment":"viewport","text-max-angle":30,"text-size":{base:1,stops:[[13,12],[18,16]]}},paint:{"text-halo-width":0,"text-halo-blur":0,"text-color":"#78888a"}}],Er.polygon=async(t={},e={},n=null)=>{var a,u,l,g;const{colorAttr:i}=e,r=((a=t.style)==null?void 0:a.color)||"blue";if(e.colorAttr){n.getSource(t.id)&&n.getSource(n.getSource(t.id).setData(`${n.getSource(t.id)._data.split("&props")[0]}&props=${i}`));const _=((l=(u=t.meta)==null?void 0:u.columns.find(k=>k.name===i))==null?void 0:l.values)||await wt.get(`/api-user/gis-ir/${t.id}/${i}`).then(k=>k.data.rows);t.legendAuto={color:[]},_.forEach(k=>t.legendAuto.color.push(k)),t.legendAuto.color.push({color:"#aaa",text:"Не визначено"}),t.style.color=_?["match",["get",i]].concat(_.filter(k=>k.id).reduce((k,E,T)=>k.concat([E.id,E.color||Rp[T]]),[])).concat(["#aaa"]):r}return[{id:`${t.id}`,source:`${t.id}`,lsource:e==null?void 0:e.lsource,minzoom:(+(e==null?void 0:e.minzoom)||+(e==null?void 0:e.pointZoom)||0)-0,maxzoom:+(e==null?void 0:e.maxzoom)||24,type:"fill",filter:["all",["match",["geometry-type"],["Polygon","MultiPolygon"],!0,!1]],paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],"red",["boolean",["feature-state","select"],!1],"#c356c1",(e==null?void 0:e.color)||"#0080ff"],"fill-opacity":.5}}].concat(e!=null&&e.pointZoom?[{id:`${t.id}-5`,source:(g=t.url)!=null&&g.includes(".vmt")?`${t.id}`:`${t.id}-point`,type:"circle",minzoom:0,maxzoom:((e==null?void 0:e.pointZoom)||1)-0,paint:{"circle-color":["case",["boolean",["feature-state","hover"],!1],"red",(e==null?void 0:e.color)||"blue"],"circle-stroke-width":1,"circle-stroke-color":"#fff"}}]:[]).concat(e!=null&&e.label?[{id:`${t.id}-1`,source:t.id,type:"symbol",lsource:e==null?void 0:e.lsource,minzoom:15,layout:{"text-field":e==null?void 0:e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||{stops:[[14,4],[18,16]]}},paint:{"text-color":e["text-color"]||"#ffffff","text-halo-color":e["text-halo-color"]||"#fff","text-halo-width":e["text-halo-width"]||0}}]:[]).concat(e!=null&&e.stroke?[{id:`${t.id}-2`,source:t.id,lsource:e==null?void 0:e.lsource,minzoom:(+(e==null?void 0:e.minzoom)||+(e==null?void 0:e.pointZoom)||0)-0,maxzoom:+(e==null?void 0:e.maxzoom)||24,type:"line",paint:{"line-color":["case",["boolean",["feature-state","select"],!1],"#c356c1",e.stroke],"line-width":["case",["boolean",["feature-state","select"],!1],3,(e.width||e["line-width"]||1)-0]}}]:[])},Er.line=(t={},e={})=>[{id:t.id,source:t.id,lsource:e.lsource,type:"line",filter1:["all",["match",["geometry-type"],["LineString","MultiLineString","MultiPolygon","Polygon"],!0,!1]],minzoom:(e==null?void 0:e.minzoom)||t.minzoom||5,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":["case",["boolean",["feature-state","select"],!1],4,e.width||e["line-width"]||1],"line-color":["case",["boolean",["feature-state","select"],!1],"#c356c1",e.color||e["line-color"]||"#c71ccb"],"line-gap-width":e["line-gap-width"]||0}}].concat(e.label?[{id:`${t.id}-4`,source:t.id,lsource:e.lsource,type:"symbol",minzoom:14,paint:{"text-color":"#111","text-halo-color":"#fff","text-halo-width":2},layout:{"symbol-placement":"line","text-letter-spacing":.2,"text-field":e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||15}}]:[]),Er.linestring=Er.line,Er.circle=Er.point;async function ZO(t,e,n){var l,g,_,k,E,T,I,z,V,H,Z,ee;typeof e.style=="string"&&(e.style=e.style[0]==="{"?JSON.parse(e.style):(l=window.YAML.parse(e.style))==null?void 0:l.style),(_=(g=e.style)==null?void 0:g.filter)==null||_.call(g,oe=>oe.source).forEach(oe=>{oe.lsource=`${e.id}-${oe.source}`});const i=((k=e==null?void 0:e.style)==null?void 0:k.type)||((Z=((I=(T=(E=e==null?void 0:e.meta)==null?void 0:E.geom)==null?void 0:T.geometry)==null?void 0:I.length)>2?["point"]:[((H=(V=(z=e==null?void 0:e.meta)==null?void 0:z.geom)==null?void 0:V.geometry)==null?void 0:H[0].toLowerCase())||"point"])==null?void 0:Z.map(oe=>{var J;return(J=oe==null?void 0:oe.replace)==null?void 0:J.call(oe,"multi","")})),r=Array.isArray(i)?i:[i],a=(await Promise.all(Array.isArray(e==null?void 0:e.style)?e.style.map(async oe=>{var J;return(J=Er[oe.type])==null?void 0:J.call(Er,e,oe,n)}):r.map(async oe=>{var J;return(J=Er[oe])==null?void 0:J.call(Er,e,e.style,n)}))).reduce((oe,J)=>J?oe.concat(J):oe,[]);a.forEach((oe,J)=>{oe.id=`${oe.id}-${J}`});const u=a;return(e.service==="vtile"||(ee=e.url)!=null&&ee.includes(".vmt"))&&u.forEach(oe=>{oe.layout||(oe.layout={}),oe.layout.visibility="visible",oe["source-layer"]=oe.lsource||e.data||t}),u}const YO={data(){return{layerList:[],layerObj:{},colors:Rp,activeLayer:"",addedLayersSettings:[],hoveredFeatureId:null}},computed:{interactiveSources(){return this.layerList.filter(t=>t==null?void 0:t.interactive).map(t=>t.id)}},methods:{moveLayers(t,e=this.map){e.getStyle().layers.forEach(n=>{n.id.match(t)&&e.moveLayer(n.id)})},getLayersBySourceId(t,e){return e.getStyle().layers.filter(i=>i.id.match(t))},async setVisible(t,e=!0,n={}){const i=typeof t=="object";try{const{style:r,map:a=this.map}=n,u=(t==null?void 0:t.id)||t,l=i?t:await this.getLayerById(u);if(!(l!=null&&l.id))throw new Error("MixinError: Layer has no id");const g=a.getStyle().layers.filter(_=>_.id.match(u));!g.length||r?await this.addToLayers({...l,...(n==null?void 0:n.data)||{},interactive:(l==null?void 0:l.interactive)!==void 0?l==null?void 0:l.interactive:!0,visible:e},{map:a,cb:n==null?void 0:n.onAddLayer}):(this.layerList=this.layerList.map(_=>_.id===l.id?{..._,visible:e}:_),g.forEach(_=>{a.setLayoutProperty(_.id,"visibility",e?"visible":"none")})),n!=null&&n.cb&&await(n==null?void 0:n.cb(l))}catch(r){console.error(r),!n.onAddLayer||n.onAddLayer({data:i?t:{id:t},message:r.message,type:"error"})}},async addToLayers(t,e={}){try{const{map:n=this==null?void 0:this.map}=e;this.layerList.find(r=>r.id===t.id)||(this.layerList=this.layerList.concat(t)),this.layerObj={...this.layerObj,[t.id]:t},t.visible?t!=null&&t.layer?await this.addVectorLayer(t,n):t.service==="vtile"?await this.addVtileLayer(t,n):t.service==="geojson"?await this.addGeojsonLayers(t,n):this.addRasterLayer(t,n):n.getStyle().layers.forEach(async r=>{r.source===t.id&&await n.setLayoutProperty(r.id,"visibility","none")}),!(e!=null&&e.cb&&(t!=null&&t.visible))||await e.cb({data:t,type:"success"}),this.moveLayers("gl-draw")}catch(n){!e.cb||e.cb({data:t,message:n.message,type:"error"}),console.error(n)}},addRasterLayer(t,e){e.addSource(t.id,{type:"raster",tiles:[(t==null?void 0:t.url)||(t==null?void 0:t.url1)],tileSize:256,...t!=null&&t.scheme?{scheme:t==null?void 0:t.scheme}:{}}),e.addLayer({id:t.id,type:"raster",source:t.id,minzoom:0,maxzoom:(t==null?void 0:t.maxzoom)||22})},async addVtileLayer(t){await this.createGeometryLayer({data:t},"vector")},async addVectorLayer(t,e){const{data:n}=await wt.get(t.layer),i={...t,source:t.id,layers:[]};Object.keys(n.sources).forEach(async r=>{await e.addSource(t.id,{type:n.sources[r].type,maxzoom:n.sources[r].maxzoom,url:n.sources[r].url})}),await n.layers.forEach(async r=>{await e.addLayer({...r,source:t.id,id:`${r.id}-${t.id}`}),i.layers=await i.layers.concat(`${r.id}-${t.id}`)})},async addGeojsonLayers(t){const e=n=>{throw this.$notify({type:"error",title:"Відсутня геометрія у обраному шарі",message:n,position:"bottom-right"}),this.layerList=this.layerList.filter(i=>i.id!==t.id),new Error(n)};if(typeof(t==null?void 0:t.geojson)=="object"){this.createGeometryLayer({data:t,geojson:t.geojson},"geojson");return}try{const n=await wt.get((t==null?void 0:t.geojson)||(t==null?void 0:t.url)),i=await n.data;if(n.statusText==="OK")this.createGeometryLayer({data:t,geojson:i},"geojson");else throw new Error((i==null?void 0:i.message)||(n==null?void 0:n.statusText)||"Error addGeojson layer")}catch(n){e(n.message),console.error(n)}},async createGeometryLayer({data:t,geojson:e},n){var l,g,_,k,E;const{map:i}=this,r=await ZO(t.id,this.layerList.find(T=>T.id==t.id),i),a={type:n,cluster:((l=t==null?void 0:t.style)==null?void 0:l.cluster)||!1,clusterMaxZoom:((g=t==null?void 0:t.style)==null?void 0:g.clusterMaxZoom)||14};n==="vector"&&(a.tiles=[`${window.location.origin}${(t==null?void 0:t.geojson)||(t==null?void 0:t.url)}${t!=null&&t.version?`?ver=${t.version}`:""}${t.props?`&props=${t.props}`:""}${(_=t==null?void 0:t.style)!=null&&_.pointZoom?`&pointZoom=${t.style.pointZoom}`:""}`]),n==="geojson"&&(a.data=e||`${window.location.origin}${(t==null?void 0:t.geojson)||(t==null?void 0:t.url)}`),i.addSource(t.id,a),r.forEach(T=>{var z;const I={...T,source:t.id,maxzoom:+(T==null?void 0:T.maxzoom)||24,minzoom:+(T==null?void 0:T.minzoom)||0,cluster:!1,clusterMaxZoom:2};i.addLayer(I),i.moveLayer(T.id),(z=T==null?void 0:T.layout)!=null&&z["text-field"]||this.apiLayersHover(T.id,t.id,i),this.addedLayersSettings=this.addedLayersSettings.concat(I)});const u=r.map(T=>T.type).filter(T=>T&&T!=="symbol");(E=(k=t==null?void 0:t.meta)==null?void 0:k.geom)!=null&&E.geometry&&t.meta.geom.geometry.filter(I=>!u.includes(this.geometryByType(I,!0))).forEach(I=>{this.createStyleObj({type:I,style:t.style},t.id)})},async setStyle(t,e,n=this.map){const i=(t==null?void 0:t.id)||t;n.getStyle().layers.forEach(a=>{a.source===i&&n.removeLayer(a.id)}),n.getSource(i)&&(n==null||n.removeSource(i)),this.layerList=this.layerList.map(a=>(a.id===i&&(a.style=e),a));const r=this.layerList.find(a=>a.id===i);this.addToLayers(r)},setLayerData({source:t,data:e}){const n=(t==null?void 0:t.id)||t;this.layerList=this.layerList.map(i=>i.id===n?{...i,...e}:i),this.layerObj={...this.layerObj,[t]:{...this.layerObj[t],...e}}},geometryByType(t,e=!1){if(t==="fill"||t==="Polygon"||t==="MultiPolygon")return e?"fill":"Polygon";if(t==="circle"||t==="Point"||t==="MultiPoint")return e?"circle":"Point";if(t==="line"||t==="LineString"||t==="MultiLineString")return e?"line":"LineString"},async removeLayer(t,e=this.map){const n=(t==null?void 0:t.id)||t;this.layerList=this.layerList.filter(i=>i.id!==n),await e.getStyle().layers.forEach(async i=>{i.source===n&&await e.removeLayer(i.id)}),await e.removeSource(n)},async reloadUrl(t,e=this.map){const n=(t==null?void 0:t.id)||t;await e.getStyle().layers.forEach(i=>{i.id===n&&e.removeLayer(i.id)}),await e.removeSource(n),await this.setVisible(t,!0)},async setFilter(t,e){const n=this.layerObj[t],i=await this.map.getSource(t);if(n.service==="vtile")await i.setTiles([`${window.location.origin}${n.geojson||n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);else if(n.service==="geojson"){const{data:r}=await wt.get((n==null?void 0:n.geojson)||`${n==null?void 0:n.url}?filter=${e}`);await this.map.getSource(t).setData(r)}},async getLayerById(t,e=null){var i;const n=(t==null?void 0:t.id)||t;try{const r=(i=this.layerList)==null?void 0:i.find(u=>u.id===n);if(r)return r;const a=await wt.get(`/api-user/gis-ir/${n}${t!=null&&t.service?`?service=${t==null?void 0:t.service}`:""}`);if(a.statusText==="OK"){const u=await a.data;return!e||await e(u),u}return this.$notify({type:"warning",message:`Шар ${n} не було знайдено!`}),null}catch(r){this.$notify({type:"warning",message:`Шар ${n} не було знайдено!`}),console.error(r)}},createStyleObj({type:t,style:e},n){const i=this.geometryByType(t,!0);if(!i)throw Error("Geomery type ERROR: Error adding missing layers");const r=`${n}-${i}`;if(this.map.getStyle().layers.find(u=>u.id===r))return;const a={id:r,type:i,source:n,"source-layer":n,layout:{},paint:{[`${i}-color`]:["case",["boolean",["feature-state","hover"],!1],"red",(e==null?void 0:e.color)||"#444e3d"],[`${i}-opacity`]:e!=null&&e.opacity||i==="fill"?.5:1},filter:["all",["==",["geometry-type"],this.geometryByType(t)]]};this.map.addLayer(a),this.addedLayersSettings=this.addedLayersSettings.concat(a),this.apiLayersHover(r,n,this.map)},apiLayersHover(t,e,n){const i=n.getSource(e),r=()=>{const a={source:e,id:this.hoveredFeatureId};return i.type==="vector"&&(a.sourceLayer=e),a};n.on("mousemove",t,a=>{a.features.length>0&&(this.hoveredFeatureId!==null&&n.setFeatureState(r(),{hover:!1}),this.hoveredFeatureId=a.features[0].id,n.setFeatureState(r(),{hover:!0}))}),n.on("mouseleave",t,()=>{this.hoveredFeatureId!==null&&n.setFeatureState(r(),{hover:!1}),this.hoveredFeatureId=null})},async changeBaseLayer(t,e=!0,n=!0){await this.setVisible(t,e);const i=(t==null?void 0:t.id)||t;i!==this.activeLayer&&(n&&this.activeLayer&&await this.setVisible(this.activeLayer,!1),this.map.getStyle().layers.forEach(r=>{r.source!==i&&r.type!=="background"&&this.map.moveLayer(r.id)}),this.activeLayer=i)},async refreshLayer(t,e=this.map){const n=(t==null?void 0:t.id)||t;await e.getStyle().layers.forEach(i=>{i.source===n&&e.removeLayer(i.id)}),await e.removeSource(n),this.layers=await this.layers.filter(i=>i.id!==n),await this.setVisible(typeof t=="object"?t:n)}}},XO={props:{objectData:{type:Array,default:()=>[]},object:{type:Object,default:()=>null},mapRef:{type:Object,default:()=>null}},computed:{currentLayer(){var n;const t=(n=this.object)==null?void 0:n.source;return this.mapRef.layerObj[t]},popupPosition(){var e,n,i;return((i=(n=(e=this.currentLayer)==null?void 0:e.setting)==null?void 0:n.popup)==null?void 0:i.position)||"horizontal"},popupWidth(){var e,n,i;return`${((i=(n=(e=this.currentLayer)==null?void 0:e.setting)==null?void 0:n.popup)==null?void 0:i.width)||240}px`},popupRows(){return this.objectData.filter(t=>t.column!=="image")},positionIsVertical(){return this.popupPosition==="vertical"}},methods:{rowValue(t){return t.value},rowTitle(t){return t.title}}},KO={key:0,class:"vsTailwind map-popup__vertical"},JO={class:"mb-1"},QO={class:"text-sm"},ez={key:1,class:"map__popup-body"},tz=["innerHTML"],nz={key:1};function iz(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",{class:"map-popup",style:S.normalizeStyle({"max-width":a.popupWidth,width:a.popupWidth})},[a.positionIsVertical?(S.openBlock(),S.createElementBlock("div",KO,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.popupRows,u=>(S.openBlock(),S.createElementBlock("div",{class:"border-b py-1 last:border-none last:pt-1 last:pb-0",key:a.rowTitle(u)},[S.createElementVNode("strong",JO,S.toDisplayString(a.rowTitle(u)),1),S.createElementVNode("div",QO,S.toDisplayString(a.rowValue(u)),1)]))),128))])):(S.openBlock(),S.createElementBlock("table",ez,[S.createElementVNode("tbody",null,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.popupRows,u=>S.withDirectives((S.openBlock(),S.createElementBlock("tr",{key:a.rowTitle(u),class:"map__popup-body-item"},[S.createElementVNode("td",null,S.toDisplayString(a.rowTitle(u)),1),a.rowValue(u)?(S.openBlock(),S.createElementBlock("td",{key:0,innerHTML:a.rowValue(u)},null,8,tz)):(S.openBlock(),S.createElementBlock("td",nz,e[0]||(e[0]=[S.createElementVNode("div",{class:"text-red-500"}," Не визначено ",-1)])))])),[[S.vShow,!a.rowValue(u).includes("id")]])),128))])]))],4)}const rz=_t(XO,[["render",iz],["__scopeId","data-v-3f5a9aff"]]),N1={width:200,show:!0,position:"horizontal"},sz={components:{VsPopupBody:rz},props:{aviableFields:{type:Array,default:()=>[]},mapRef:{type:[Object,Array],default:()=>{}},object:{type:[Object,Array],default:()=>{}}},data(){return{objectData:[],popupSettings:N1}},computed:{getImage(){return this.objectData.find(t=>t.column==="image")||null},currentLayer(){var t;return(t=this.$parent.layerList)==null?void 0:t.find(e=>{var n;return(e==null?void 0:e.id)===((n=this.object)==null?void 0:n.source)})}},watch:{async object(t,e){t!==null&&(t==null?void 0:t.id)!==(e==null?void 0:e.id)||!(t!=null&&t.id)?await this.getFormatObject(t):t===null&&(this.objectData=[])}},methods:{async getFormatObject(t){var g,_,k,E,T,I;if(!t)return;const e=Object.keys(t.properties).filter(z=>!z.match("__text")&&!["id"].includes(z)),{currentLayer:n}=this;if((g=n==null?void 0:n.setting)!=null&&g.popup&&(this.popupSettings=(n==null?void 0:n.setting.popup)||N1),!(n!=null&&n.meta)){const z=e.map(V=>({title:V,value:t.properties[V]}));this.objectData=[...z,{value:((_=t.properties)==null?void 0:_.image)||"",title:"Фото",column:"image"}];return}const i=n.meta.columns,r=e.map(z=>{var oe,J,Ae,ke;const V={},Z=Object.assign({values:[]},i.find(Me=>Me.name===z));typeof Z.values!="object"&&console.warn(`Warning: Layer ${t.source} has key "values" which is not an object in meta!`);const ee=Z!=null&&Z.values&&((oe=Z==null?void 0:Z.values)==null?void 0:oe.find(Me=>(Me==null?void 0:Me.id)==t.properties[z]))||null;return V.value=(Z==null?void 0:Z.format)==="select"?this.formatBadge({text:(ee==null?void 0:ee.text)||((J=t.properties)==null?void 0:J[`${z}__text`])||((Ae=t.properties)==null?void 0:Ae[z])||"-",color:(ee==null?void 0:ee.color)||"#1989FA"}):(ee==null?void 0:ee.text)||((ke=t.properties)==null?void 0:ke[`${z}__text`])||t.properties[z],V.column=z,V.title=(Z==null?void 0:Z[window==null?void 0:window.lang])||(Z==null?void 0:Z.ua)||(Z==null?void 0:Z.title)||z,V});this.objectData=[...r,{value:((k=t.properties)==null?void 0:k.image)||"",title:"Фото",column:"image"}];const a=(T=(E=n==null?void 0:n.setting)==null?void 0:E.popup)==null?void 0:T.popup,u=typeof a=="string"?a==null?void 0:a.split(","):a,l=[...this.aviableFields,...((I=n==null?void 0:n.popup)==null?void 0:I.split(","))||[],...u||[]];this.objectData=l.length?this.objectData.filter(z=>l.includes(z.column)||l.includes(z.title)):[]},noInfoObject(){var i,r,a,u,l;if(!this.object)return"Інформація відсутня";const{currentLayer:t}=this,e=((r=(i=t==null?void 0:t.meta)==null?void 0:i.columns)==null?void 0:r.find(g=>(g==null?void 0:g.meta)==="title"))||((a=t==null?void 0:t.meta)==null?void 0:a.columns[0])||null;return{title:(t==null?void 0:t.name)||(t==null?void 0:t.id)||((u=this.object)==null?void 0:u.sourceLayer)||((l=this.object)==null?void 0:l.source)||"Дані по шару не знайдено",column:e}},formatBadge(t){const e=(t==null?void 0:t.text)||"-";return t!=null&&t.color?`<span >${e}</span>`:e}}},oz={key:0},az={key:0},lz=["src","alt"],cz={key:1},uz={class:"text-left text-sm m-b-sm"},hz={key:1,class:"text-center"};function dz(t,e,n,i,r,a){var l,g,_,k,E,T,I,z,V,H,Z;const u=S.resolveComponent("VsPopupBody");return S.openBlock(),S.createElementBlock("div",{class:S.normalizeClass((((l=r.popupSettings)==null?void 0:l.position)||"horizontal")+"-position")},[r.objectData.filter(ee=>ee.column!=="image").length?(S.openBlock(),S.createElementBlock("div",oz,[a.getImage&&((g=a.getImage)!=null&&g.value)?(S.openBlock(),S.createElementBlock("div",az,[S.createElementVNode("img",{class:"popup-image",src:"files/"+a.getImage.value,alt:a.getImage.column},null,8,lz)])):S.createCommentVNode("",!0),S.createVNode(u,{"object-data":r.objectData,object:n.object,mapRef:n.mapRef},null,8,["object-data","object","mapRef"])])):(S.openBlock(),S.createElementBlock("div",cz,[(_=a.noInfoObject())!=null&&_.column?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[S.createElementVNode("b",uz,S.toDisplayString(a.noInfoObject().title),1),S.createElementVNode("div",null,[S.createElementVNode("b",null,S.toDisplayString(((E=(k=a.noInfoObject())==null?void 0:k.column)==null?void 0:E.ua)||((I=(T=a.noInfoObject())==null?void 0:T.column)==null?void 0:I.title))+":",1),S.createTextVNode(" "+S.toDisplayString(((Z=(z=n.object)==null?void 0:z.properties)==null?void 0:Z[(H=(V=a.noInfoObject())==null?void 0:V.column)==null?void 0:H.name])||"-"),1)])],64)):(S.openBlock(),S.createElementBlock("div",hz,S.toDisplayString(a.noInfoObject().title),1))]))],2)}const pz=_t(sz,[["render",dz],["__scopeId","data-v-deb51e0a"]]),{Map:fz,NavigationControl:mz,Popup:gz}=WO,yz={mixins:[YO],components:{VsMapPopup:pz},props:{popupVisible:{type:Boolean,default:()=>!0},map:{type:Object,default:()=>null},height:{type:String,default:()=>"400px"}},data(){var t,e,n,i;return{mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,features:[],katottg:((e=(t=window==null?void 0:window.setting)==null?void 0:t.map)==null?void 0:e.katottg)||((i=(n=window==null?void 0:window.setting)==null?void 0:n.map)==null?void 0:i.city_katottg),popup:{geometry:null,map:null},cityBbox:null}},async mounted(){this.initMap()},computed:{mapRef(){return this}},methods:{initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]},e=new fz({container:this.mapId,style:t,center:[0,0],zoom:1,interactive:!0});e.addControl(new mz({visualizePitch:!0})),window==null||window.addEventListener("resize",()=>{e.resize()}),e.on("load",this.onMapLoad)},async onMapLoad(t){const e=t.target;e.resize();const n={id:"graymap",name:"Сіра карта",url:"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",service:"TMS",category:"Базові карти",attribution:"© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>, © <a href='https://carto.com/attributions'>CARTO</a>",bounds1:"ua",image:"https://basemaps.cartocdn.com/light_all/10/601/348.png",position:0,owner:"OSM",basemap:!0};await this.$emit("update:map",e),await this.setVisible(n,!0),this.$emit("load",e),this.createPopup(),this.createBoundsLayers(),this.createAtuLayer()},createPopup(){var n,i,r,a,u,l;const{map:t}=this,e=["measure","katottg","geometry","mapbox-gl-draw-hot","mapbox-gl-draw-cold"];this.popup.map=new gz({closeOnClick:!1}).setDOMContent((i=(n=this==null?void 0:this.$refs)==null?void 0:n.popup)==null?void 0:i.$el),t&&(t.on("mousemove",g=>{var k,E;const _=t.queryRenderedFeatures(g.point).filter(T=>{var V,H,Z;const I=this.layerList.find(ee=>ee.id===T.source),z=((H=(V=I==null?void 0:I.setting)==null?void 0:V.popup)==null?void 0:H.show)===void 0?!0:I.setting.popup.show;if((this.interactiveSources.includes(T.source)&&!((Z=T.properties)!=null&&Z.cluster)&&z||!I&&Object.keys(T.properties).length)&&!e.includes(T.source))return T}).filter(T=>{var I,z;return!((z=(I=T.layer)==null?void 0:I.layout)!=null&&z["text-field"])});_.length&&this.popupVisible?(this.features=(_==null?void 0:_[0])||null,(k=this.popup.map)==null||k.setLngLat(Object.values(g.lngLat)).addTo(t),t.getCanvas().style.cursor=_.length?"pointer":"grab"):(this.features=null,(E=this.popup.map)==null||E.remove()),this.$emit("mouseMove",{event:g,features:_})}),t.on("touchend",this.handleMapClick),t.on("click",this.handleMapClick),t.on("dblclick",g=>{const _=t.queryRenderedFeatures(g.point);this.$emit("dbclick",{features:_,event:g})}),(l=(u=(a=(r=this==null?void 0:this.$refs)==null?void 0:r.popup)==null?void 0:a.$el)==null?void 0:u.parentElement)==null||l.addEventListener("mouseenter",()=>{var g;(g=this.popup.map)==null||g.remove()}))},createBoundsLayers(){const{map:t}=this;t&&(t.addSource("bounds-dataset",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.addLayer({id:"bounds-dataset-line",type:"line",source:"bounds-dataset",layout:{},paint:{"line-color":"#a91a9e","line-width":2}}))},handleMapClick(t){if(!this.map)return;const e=this.map.queryRenderedFeatures(t.point);if(!e.length)return;const n=e.filter(i=>this.interactiveSources.includes(i==null?void 0:i.source));this.$emit("mapClick",n)},homeZoom(){const{map:t}=this,e=this.cityBbox?this.cityBbox:[22.1352,44.3909,40.2276,52.3791];t==null||t.fitBounds(e,{duration:0,padding:10})},async createAtuLayer(){try{const t=this.katottg,{map:e}=this;if(!e){console.warn("Map error: Map hasn't loaded");return}const{data:n}=await wt.get(`https://data.gki.com.ua/api-user/atu/${t}`),i=z1(n);this.cityBbox=i,e.addSource("atu",{type:"geojson",data:n}),e.addLayer({id:"atu",type:"line",source:"atu",paint:{"line-color":"#3b82f6","line-width":2}})}catch(t){console.error(t)}}}},_z={class:"relative"},bz=["id"];function xz(t,e,n,i,r,a){const u=S.resolveComponent("VsMapPopup");return S.openBlock(),S.createElementBlock("div",_z,[S.createElementVNode("div",{id:r.mapId,style:S.normalizeStyle({height:n.height})},null,12,bz),S.createVNode(u,{ref:"popup",object:r.features,"map-ref":a.mapRef},null,8,["object","map-ref"])])}const vz=_t(yz,[["render",xz]]),Qs="widget-map-source",wz={components:{VsMap:vz},props:{geometry:{type:Object,default:()=>null},zoom:{type:String,default:()=>"50"}},data(){return{map:null}},mounted(){this.geometry&&this.initGeometryLayer()},watch:{geometry(){console.log(this.zoom),this.initGeometryLayer()}},methods:{initMap(){this.geometry&&this.map&&this.initGeometryLayer()},handleMapLoad(){this.initMap()},initGeometryLayer(){const{map:t}=this;if(!t)return;const e=this.formatGeojson(this.geometry),n=t.getSource(Qs);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(Qs,{type:"geojson",data:e}),t.addLayer({id:`${Qs}-point`,type:"circle",source:Qs,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${Qs}-polygon`,type:"fill",source:Qs,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Qs}-polygon-line`,type:"line",source:Qs,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Qs}-line`,type:"line",source:Qs,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return R1(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[HO(t)]),R1(e))},zoomToGeometry(t){const{map:e}=this,n=z1(t);e.fitBounds(n,{zoom:this.zoom,padding:30,duration:0})}}};function kz(t,e,n,i,r,a){const u=S.resolveComponent("VsMap");return S.openBlock(),S.createElementBlock("div",null,[S.createVNode(u,{map:r.map,"onUpdate:map":e[0]||(e[0]=l=>r.map=l),onLoad:a.handleMapLoad},null,8,["map","onLoad"])])}const Sz=_t(wz,[["render",kz]]),st=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),ny=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY,i=n.indexOf("hidden")!==-1,r=n.indexOf("visible")!==-1;return e&&!i&&!r},Np=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(ny(t)?t:Np(t.parentElement,e))},eo=function(t){var e=new DOMParser().parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var n=document.createElement("div");e.firstChild;)n.appendChild(e.firstChild);return n}return e.firstChild},iy=t=>`${t||""}`.split(" ").filter(e=>!!e),to=(t,e,n)=>{t&&iy(e).forEach(i=>{t.classList.toggle(i,n||!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 Ez{constructor(e,{start:n=()=>!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=n,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 n=new Sc(e);this.currentPointers.some(i=>i.id===n.id)||this.triggerPointerStart(n,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerStart(new Sc(n),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const n=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(),n)}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 n of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new Sc(n))}triggerPointerStart(e,n){return!!this.startCallback(n,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,n){const i=this.currentPointers.findIndex(r=>r.id===n.id);i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(e,n,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 B1(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function F1(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const ry=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Cr=(t,...e)=>{const n=e.length;for(let i=0;i<n;i++){const r=e[i]||{};Object.entries(r).forEach(([a,u])=>{const l=Array.isArray(u)?[]:{};t[a]||Object.assign(t,{[a]:l}),ry(u)?Object.assign(t[a],Cr(l,u)):Array.isArray(u)?Object.assign(t,{[a]:[...u]}):Object.assign(t,{[a]:u})})}return t},sy=function(t,e){return t.split(".").reduce((n,i)=>typeof n=="object"?n[i]:void 0,e)};class Bp{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 n of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))n.startsWith("on")&&typeof this[n]=="function"&&(this[n]=this[n].bind(this))}setOptions(e){this.options=e?Cr({},this.constructor.defaults,e):{};for(const[n,i]of Object.entries(this.option("on")||{}))this.on(n,i)}option(e,...n){let i=sy(e,this.options);return i&&typeof i=="function"&&(i=i.call(this,this,...n)),i}optionFor(e,n,i,...r){let a=sy(n,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=sy(n,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 n=this.options.classes;return n&&n[e]||""}localize(e,n=[]){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<n.length;i++)e=e.split(n[i][0]).join(n[i][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(i,r)=>r)}on(e,n){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(n)||a.push(n),this.events.set(r,a)})}off(e,n){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(n);u>-1&&a.splice(u,1)}})}emit(e,...n){[...this.events.get(e)||[]].forEach(i=>i(this,...n)),e!=="*"&&this.emit("*",e,...n)}}Object.defineProperty(Bp,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(Bp,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class oy extends Bp{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const n=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]):n.set(i,new r(this,a||{}))}for(const[i,r]of n)this.plugins[i]=r,r.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const n of e){const i=this.plugins[n];i&&i.detach(),delete this.plugins[n]}return this.emit("detachPlugins"),this}}var An;(function(t){t[t.Init=0]="Init",t[t.Error=1]="Error",t[t.Ready=2]="Ready",t[t.Panning=3]="Panning",t[t.Mousemove=4]="Mousemove",t[t.Destroy=5]="Destroy"})(An||(An={}));const Po=["a","b","c","d","e","f"],V1={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"},Cz={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:V1},$1='<circle cx="25" cy="25" r="20"></circle>',ay='<div class="f-spinner"><svg viewBox="0 0 50 50">'+$1+$1+"</svg></div>",Tr=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,kn=(t,e)=>{t&&iy(e).forEach(n=>{t.classList.remove(n)})},Ct=(t,e)=>{t&&iy(e).forEach(n=>{t.classList.add(n)})},Fp={a:1,b:0,c:0,d:1,e:0,f:0},Tz=1e5,Vp=1e4,ps="mousemove",j1="drag",U1="content",fs="auto";let ly=null,cy=null;class ua extends oy{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return cy===null&&(cy=window.matchMedia("(hover: none)").matches),cy}get isMobile(){return ly===null&&(ly=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),ly}get panMode(){return this.options.panMode!==ps||this.isTouchDevice?j1:ps}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===fs?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:n}=this.current;return Math.sqrt(e*e+n*n)||1}get targetScale(){const{a:e,b:n}=this.target;return Math.sqrt(e*e+n*n)||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:n}=this,i=Math.max(e.height/n.fitHeight,e.width/n.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 n=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>n)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,n={},i={}){var r;if(super(n),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:An.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=eo(ay);!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,n=this.cn(U1);let i=this.option(U1)||e.querySelector(`.${n}`);if(i||(i=e.querySelector("img,picture")||e.firstElementChild,i&&Ct(i,n)),i instanceof HTMLPictureElement&&(i=i.querySelector("img")),!i)throw new Error("No content found");this.content=i}onLoad(){const{spinner:e,container:n,state:i}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&n.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),i===An.Init?this.enable():this.updateMetrics()}onError(){this.state!==An.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=An.Error,this.emit("error"))}getNextScale(e){const{fullScale:n,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*(n-u)?n:u;break;case"iterateZoom":let g=[1,n,a].sort((k,E)=>k-E),_=g.findIndex(k=>k>i+1e-5);l=g[_]||1}return l}attachObserver(){var e;const n=()=>{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||(n()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{n()&&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 Ez(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(ps,this.onMouseMove)}detachEvents(){var e;const{container:n}=this;n.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),n.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(ps,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,n=this.option("maxVelocity");for(const i of Po)e?(this.velocity[i]*=1-e,n&&!this.isScaling&&(this.velocity[i]=Math.max(Math.min(this.velocity[i],n),-1*n)),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,n=0){const{current:i}=this,r=i.e+e,a=i.f+n,u=this.getBounds(),{x:l,y:g}=u,_=l.min,k=l.max,E=g.min,T=g.max;let I=0,z=0;return _!==1/0&&r<_?I=_-r:k!==1/0&&r>k&&(I=k-r),E!==1/0&&a<E?z=E-a:T!==1/0&&a>T&&(z=T-a),Math.abs(I)<1e-4&&(I=0),Math.abs(z)<1e-4&&(z=0),Object.assign(Object.assign({},u),{xDiff:I,yDiff:z,inBounds:!I&&!z})}clampTargetBounds(){const{target:e}=this,{x:n,y:i}=this.getBounds();n.min!==1/0&&(e.e=Math.max(e.e,n.min)),n.max!==1/0&&(e.e=Math.min(e.e,n.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:n,contentRect:i}=this,{fitWidth:r,fitHeight:a,fullWidth:u,fullHeight:l}=i;let g=u,_=l;if(this.option("zoom")||this.angle!==0){const k=!(n instanceof HTMLImageElement)&&(window.getComputedStyle(n).maxWidth==="none"||window.getComputedStyle(n).maxHeight==="none"),E=k?u:r,T=k?l:a,I=this.getMatrix(e),z=new DOMPoint(0,0).matrixTransform(I),V=new DOMPoint(0+E,0).matrixTransform(I),H=new DOMPoint(0+E,0+T).matrixTransform(I),Z=new DOMPoint(0,0+T).matrixTransform(I),ee=Math.abs(H.x-z.x),oe=Math.abs(H.y-z.y),J=Math.abs(Z.x-V.x),Ae=Math.abs(Z.y-V.y);g=Math.max(ee,J),_=Math.max(oe,Ae)}return{contentWidth:g,contentHeight:_}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===ps||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:n,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,n.min!==1/0&&(this.target.e=Math.max(e.e,n.min)),n.max!==1/0&&(this.target.e=Math.min(e.e,n.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,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const i of Po)this.current[i]=this.target[i]=n[i];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=An.Ready,this.emit("ready")}onClick(e){var n;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((n=this.pointerTracker)===null||n===void 0||n.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&&Tr(u)?u.dataset:null;if(l){const I=l.panzoomChange,z=l.panzoomAction;if((I||z)&&e.preventDefault(),I){let V={};try{V=JSON.parse(I)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(V)}if(z)return void(this[z]&&this[z]())}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(),_=this.dragStart;if(_.time&&!this.canZoomOut()&&(Math.abs(g.x-_.x)>2||Math.abs(g.y-_.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),T=this.option("dblClick",e);T?(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(T)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&E&&k(E))}addTrackingPoint(e){const n=this.trackingPoints.filter(i=>i.time>Date.now()-100);n.push(e),this.trackingPoints=n}onPointerDown(e,n,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===ps&&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(n),this.emit("touchStart",e)),!0}onPointerMove(e,n,i){if(this.option("touch",e)===!1||!this.isDragging||n.length<2&&this.panOnlyZoomed&&st(this.targetScale)<=st(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:r}=this,a=F1(i[0],i[1]),u=F1(n[0],n[1]);let l=0,g=0;if(n.length>1){const oe=r.getBoundingClientRect();l=a.clientX-oe.left-.5*oe.width,g=a.clientY-oe.top-.5*oe.height}const _=B1(i[0],i[1]),k=B1(n[0],n[1]);let E=_?k/_:1,T=u.clientX-a.clientX,I=u.clientY-a.clientY;this.dragOffset.x+=T,this.dragOffset.y+=I,this.dragOffset.time=Date.now()-this.dragStart.time;let z=st(this.targetScale)===st(this.minScale)&&this.option("lockAxis");if(z&&!this.lockedAxis)if(z==="xy"||z==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const oe=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=oe>45&&oe<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,T=0,I=0}else this.lockedAxis=z;if(Np(e.target,this.content)&&(z="x",this.dragOffset.y=0),z&&z!=="xy"&&this.lockedAxis!==z&&st(this.targetScale)===st(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const V=this.checkBounds(T,I);this.option("rubberband")?(this.isInfinite!=="x"&&(V.xDiff>0&&T<0||V.xDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*V.xDiff))),this.isInfinite!=="y"&&(V.yDiff>0&&I<0||V.yDiff<0&&I>0)&&(I*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*V.yDiff)))):(V.xDiff&&(T=0),V.yDiff&&(I=0));const H=this.targetScale,Z=this.minScale,ee=this.maxScale;H<.5*Z&&(E=Math.max(E,Z)),H>1.5*ee&&(E=Math.min(E,ee)),this.lockedAxis==="y"&&st(H)===st(Z)&&(T=0),this.lockedAxis==="x"&&st(H)===st(Z)&&(I=0),this.applyChange({originX:l,originY:g,panX:T,panY:I,scale:E,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,n,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(n),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),Np(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==An.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const n=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const oe of Po)this.velocity[oe]=0;this.target.e=this.current.e,this.target.f=this.current.f,kn(this.container,"is-scaling"),kn(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 _=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;_!==1&&(u*=_,l*=_);let k=0,E=0,T=0,I=0,z=this.option("decelFriction");const V=this.targetScale;if(g>0){T=Math.abs(u)>3?u/(g/30):0,I=Math.abs(l)>3?l/(g/30):0;const oe=this.option("maxVelocity");oe&&(T=Math.max(Math.min(T,oe),-1*oe),I=Math.max(Math.min(I,oe),-1*oe))}T&&(k=T/(1/(1-z)-1)),I&&(E=I/(1/(1-z)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&st(V)===this.minScale)&&(k=T=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&st(V)===this.minScale)&&(E=I=0);const H=this.dragOffset.x,Z=this.dragOffset.y,ee=this.option("dragMinThreshold")||0;Math.abs(H)<ee&&Math.abs(Z)<ee&&(k=E=0,T=I=0),(this.option("zoom")&&(V<this.minScale-1e-5||V>this.maxScale+1e-5)||n&&!k&&!E)&&(z=.35),this.applyChange({panX:k,panY:E,friction:z}),this.emit("decel",T,I,H,Z)}onWheel(e){var n=[-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,n));if(this.emit("wheel",e,i),this.panMode===ps||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:n,content:i,contentRect:r}=this,a=Object.assign({},Fp);for(const H of Po){const Z=H=="e"||H==="f"?Vp:Tz;a[H]=st(e[H],Z),Math.abs(n[H]-e[H])<(H=="e"||H==="f"?.51:.001)&&(e[H]=n[H])}let{a:u,b:l,c:g,d:_,e:k,f:E}=a,T=`matrix(${u}, ${l}, ${g}, ${_}, ${k}, ${E})`,I=i.parentElement instanceof HTMLPictureElement?i.parentElement:i;if(this.option("transformParent")&&(I=I.parentElement||I),I.style.transform===T)return;I.style.transform=T;const{contentWidth:z,contentHeight:V}=this.calculateContentDim();r.width=z,r.height=V,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===An.Destroy||this.isContentLoading)return;const i=Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1),{container:r,content:a}=this,u=a instanceof HTMLImageElement,l=r.getBoundingClientRect(),g=getComputedStyle(this.container);let _=l.width*i,k=l.height*i;const E=parseFloat(g.paddingTop)+parseFloat(g.paddingBottom),T=_-(parseFloat(g.paddingLeft)+parseFloat(g.paddingRight)),I=k-E;this.containerRect={width:_,height:k,innerWidth:T,innerHeight:I};const z=parseFloat(a.dataset.width||"")||(ht=>{let Rt=0;return Rt=ht instanceof HTMLImageElement?ht.naturalWidth:ht instanceof SVGElement?ht.width.baseVal.value:Math.max(ht.offsetWidth,ht.scrollWidth),Rt||0})(a),V=parseFloat(a.dataset.height||"")||(ht=>{let Rt=0;return Rt=ht instanceof HTMLImageElement?ht.naturalHeight:ht instanceof SVGElement?ht.height.baseVal.value:Math.max(ht.offsetHeight,ht.scrollHeight),Rt||0})(a);let H=this.option("width",z)||fs,Z=this.option("height",V)||fs;const ee=H===fs,oe=Z===fs;typeof H!="number"&&(H=z),typeof Z!="number"&&(Z=V),ee&&(H=z*(Z/V)),oe&&(Z=V/(z/H));let J=a.parentElement instanceof HTMLPictureElement?a.parentElement:a;this.option("transformParent")&&(J=J.parentElement||J);const Ae=J.getAttribute("style")||"";J.style.setProperty("transform","none","important"),u&&(J.style.width="",J.style.height=""),J.offsetHeight;const ke=a.getBoundingClientRect();let Me=ke.width*i,Le=ke.height*i,Ie=Me,Ye=Le;Me=Math.min(Me,H),Le=Math.min(Le,Z),u?{width:Me,height:Le}=((ht,Rt,Xt,nn)=>{const jt=Xt/ht,Mt=nn/Rt,Sn=Math.min(jt,Mt);return{width:ht*=Sn,height:Rt*=Sn}})(H,Z,Me,Le):(Me=Math.min(Me,H),Le=Math.min(Le,Z));let it=.5*(Ye-Le),Nt=.5*(Ie-Me);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ke.top-l.top+it,bottom:l.bottom-ke.bottom+it,left:ke.left-l.left+Nt,right:l.right-ke.right+Nt,fitWidth:Me,fitHeight:Le,width:Me,height:Le,fullWidth:H,fullHeight:Z}),J.style.cssText=Ae,u&&(J.style.width=`${Me}px`,J.style.height=`${Le}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(st(this.targetScale)<st(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===An.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:n}=this.calculateContentDim(this.target),{targetScale:i,lockedAxis:r}=this,{fitWidth:a,fitHeight:u}=this.contentRect;let l=0,g=0,_=0,k=0;const E=this.option("infinite");if(E===!0||r&&E===r)l=-1/0,_=1/0,g=-1/0,k=1/0;else{let{containerRect:T,contentRect:I}=this,z=st(a*i,Vp),V=st(u*i,Vp),{innerWidth:H,innerHeight:Z}=T;if(T.width===z&&(H=T.width),T.width===V&&(Z=T.height),e>H){_=.5*(e-H),l=-1*_;let ee=.5*(I.right-I.left);l+=ee,_+=ee}if(a>H&&e<H&&(l-=.5*(a-H),_-=.5*(a-H)),n>Z){k=.5*(n-Z),g=-1*k;let ee=.5*(I.bottom-I.top);g+=ee,k+=ee}u>Z&&n<Z&&(l-=.5*(u-Z),_-=.5*(u-Z))}return{x:{min:l,max:_},y:{min:g,max:k}}}getBounds(){const e=this.option("bounds");return e!==fs?e:this.calculateBounds()}updateControls(){const e=this,n=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 _=e.canZoomIn(),k=e.canZoomOut(),E=i===j1&&!!this.option("touch"),T=k&&E;if(E&&(st(a)<st(u)&&!this.panOnlyZoomed&&(T=!0),(st(r.width,1)>st(r.fitWidth,1)||st(r.height,1)>st(r.fitHeight,1))&&(T=!0)),st(r.width*a,1)<st(r.fitWidth,1)&&(T=!1),i===ps&&(T=!1),to(n,this.cn("isDraggable"),T),!this.option("zoom"))return;let I=_&&st(l)>st(a),z=!I&&!T&&k&&st(l)<st(a);to(n,this.cn("canZoomIn"),I),to(n,this.cn("canZoomOut"),z);for(const V of n.querySelectorAll("[data-panzoom-action]")){let H=!1,Z=!1;switch(V.dataset.panzoomAction){case"zoomIn":_?H=!0:Z=!0;break;case"zoomOut":k?H=!0:Z=!0;break;case"toggleZoom":case"iterateZoom":_||k?H=!0:Z=!0;const ee=V.querySelector("g");ee&&(ee.style.display=_?"":"none")}H?(V.removeAttribute("disabled"),V.removeAttribute("tabindex")):Z&&(V.setAttribute("disabled",""),V.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:n=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:_=!1,ignoreBounds:k=!1}){this.state!==An.Destroy&&this.applyChange({panX:e-this.target.e,panY:n-this.target.f,scale:i/this.targetScale,angle:a,originX:u,originY:l,friction:r,flipX:g,flipY:_,ignoreBounds:k})}applyChange({panX:e=0,panY:n=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:_=!1,ignoreBounds:k=!1,bounce:E=this.option("bounce")}){const T=this.state;if(T===An.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=l||0,this.ignoreBounds=k;const{current:I}=this,z=I.e,V=I.f,H=this.getMatrix(this.target);let Z=new DOMMatrix().translate(z,V).translate(a,u).translate(e,n);if(this.option("zoom")){if(!k){const ee=this.targetScale,oe=this.minScale,J=this.maxScale;ee*i<oe&&(i=oe/ee),ee*i>J&&(i=J/ee)}Z=Z.scale(i)}Z=Z.translate(-a,-u).translate(-z,-V).multiply(H),r&&(Z=Z.rotate(r)),g&&(Z=Z.scale(-1,1)),_&&(Z=Z.scale(1,-1));for(const ee of Po)ee!=="e"&&ee!=="f"&&(Z[ee]>this.minScale+1e-5||Z[ee]<this.minScale-1e-5)?this.target[ee]=Z[ee]:this.target[ee]=st(Z[ee],Vp);(this.targetScale<this.scale||Math.abs(i-1)>.1||this.panMode===ps||E===!1)&&!k&&this.clampTargetBounds(),T===An.Init?this.animate():this.isResting||(this.state=An.Panning,this.requestTick())}stop(e=!1){if(this.state===An.Init||this.state===An.Destroy)return;const n=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(),kn(this.container,"is-scaling"),kn(this.container,"is-animating"),this.isTicking=!1,this.state=An.Ready,n&&(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,n=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==ps||!e||st(this.targetScale)<=st(this.minScale))return;this.emit("mouseMove",e);const{container:i,containerRect:r,contentRect:a}=this,u=r.width,l=r.height,g=i.getBoundingClientRect(),_=(e.clientX||0)-g.left,k=(e.clientY||0)-g.top;let{contentWidth:E,contentHeight:T}=this.calculateContentDim(this.target);const I=this.option("mouseMoveFactor");I>1&&(E!==u&&(E*=I),T!==l&&(T*=I));let z=.5*(E-u)-_/u*100/100*(E-u);z+=.5*(a.right-a.left);let V=.5*(T-l)-k/l*100/100*(T-l);V+=.5*(a.bottom-a.top),this.applyChange({panX:z-this.target.e,panY:V-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===An.Destroy||this.state===An.Init)return;const n=Date.now();if(n-this.pwt<45)return void e.preventDefault();this.pwt=n;var i=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(_,k){return Math.abs(k)>Math.abs(_)?k:_});const r=Math.max(-1,Math.min(1,i)),{targetScale:a,maxScale:u,minScale:l}=this;let g=a*(100+45*r)/100;st(g)<st(l)&&st(a)<=st(l)?(this.cwd+=Math.abs(r),g=l):st(g)>st(u)&&st(a)>=st(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(),st(g)!==st(a)&&this.zoomTo(g,{event:e}))}canZoomIn(){return this.option("zoom")&&(st(this.contentRect.width,1)<st(this.contentRect.fitWidth,1)||st(this.targetScale)<st(this.maxScale))}canZoomOut(){return this.option("zoom")&&st(this.targetScale)>st(this.minScale)}zoomIn(e=1.25,n){this.zoomTo(this.targetScale*e,n)}zoomOut(e=.8,n){this.zoomTo(this.targetScale*e,n)}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:n=fs,originX:i=fs,originY:r=fs,event:a}={}){if(this.isContentLoading||this.state===An.Destroy)return;const{targetScale:u,fullScale:l,maxScale:g,coverScale:_}=this;if(this.stop(),this.panMode===ps&&(a=this.pmme||a),a||i===fs||r===fs){const E=this.content.getBoundingClientRect(),T=this.container.getBoundingClientRect(),I=a?a.clientX:T.left+.5*T.width,z=a?a.clientY:T.top+.5*T.height;i=I-E.left-.5*E.width,r=z-E.top-.5*E.height}let k=1;typeof e=="number"?k=e:e==="full"?k=l:e==="cover"?k=_:e==="max"?k=g:e==="fit"?k=1:e==="next"&&(k=this.getNextScale("iterateZoom")),k=k/u||1,n=n===fs?k>1?.15:.25:n,this.applyChange({scale:k,originX:i,originY:r,friction:n}),a&&this.panMode===ps&&this.panWithMouse(a,n)}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:n,target:i}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-i.e,panY:.5*e.height-(n.top+.5*n.fitHeight)-i.f,scale:e.width/n.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:n,target:i}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-i.e,panY:.5*e.innerHeight-(n.top+.5*n.fitHeight)-i.f,scale:e.height/n.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,n=this.cn("inFullscreen"),i=this.cn("htmlHasFullscreen");e.classList.toggle(n);const r=e.classList.contains(n);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:n,b:i,c:r,d:a,e:u,f:l}=e;return new DOMMatrix([n,i,r,a,u,l])}reset(e){if(this.state!==An.Init&&this.state!==An.Destroy){this.stop("current");for(const n of Po)this.target[n]=Fp[n];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=An.Panning,this.requestTick())}}destroy(){this.stop(),this.state=An.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:n}=this,i=this.option("classes")||{};for(const r of Object.values(i))e.classList.remove(r+"");n&&(n.removeEventListener("load",this.onLoad),n.removeEventListener("error",this.onError)),this.detachPlugins()}}Object.defineProperty(ua,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Cz}),Object.defineProperty(ua,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const H1=function(t,e){let n=!0;return(...i)=>{n&&(n=!1,t(...i),setTimeout(()=>{n=!0},e))}},q1=(t,e)=>{let n=[];return t.childNodes.forEach(i=>{i.nodeType!==Node.ELEMENT_NODE||e&&!i.matches(e)||n.push(i)}),n},Mz={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 ci;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(ci||(ci={}));const uy=t=>{if(typeof t=="string"||t instanceof HTMLElement)t={html:t};else{const e=t.thumb;e!==void 0&&(typeof e=="string"&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},Az=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);class Fs extends Bp{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}}const Pz={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 W1 extends Fs{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 n=this.instance.container;n.appendChild(e),Ct(n,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const n=this.instance.pages.length,i=Math.min(2,this.option("minCount")),r=Math.max(2e3,this.option("maxCount")),a=this.option("dynamicFrom");if(n<i||n>r)return void this.cleanup();const u=typeof a=="number"&&n>5&&n>=a,l=!this.list||this.isDynamic!==u||this.list.children.length!==n;l&&this.cleanup();const g=this.build();if(to(g,this.cn("isDynamic"),!!u),l)for(let E=0;E<n;E++)g.append(this.createItem(E));let _,k=0;for(const E of[...g.children]){const T=k===this.instance.page;T&&(_=E),to(E,this.cn("isCurrent"),T),(e=E.children[0])===null||e===void 0||e.setAttribute("aria-selected",T?"true":"false");for(const I of["isBeforePrev","isPrev","isNext","isAfterNext"])kn(E,this.cn(I));k++}if(_=_||g.firstChild,u&&_){const E=_.previousElementSibling,T=E&&E.previousElementSibling;Ct(E,this.cn("isPrev")),Ct(T,this.cn("isBeforePrev"));const I=_.nextElementSibling,z=I&&I.nextElementSibling;Ct(I,this.cn("isNext")),Ct(z,this.cn("isAfterNext"))}this.isDynamic=u}createItem(e=0){var n;const i=document.createElement("li");i.setAttribute("role","presentation");const r=eo(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return i.appendChild(r),(n=i.children[0])===null||n===void 0||n.setAttribute("role","tab"),i}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,kn(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(W1,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Pz});const $p="disabled",jp="next",G1="prev";class Z1 extends Fs{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,n=e.pages.length,i=e.page;if(n<2)return void this.cleanup();this.build();let r=this.prev,a=this.next;r&&a&&(r.removeAttribute($p),a.removeAttribute($p),e.isInfinite||(i<=0&&r.setAttribute($p,""),i>=n-1&&a.setAttribute($p,"")))}addBtn(e){var n;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===jp?"isNext":"isPrev"));const a=i.isRTL?e===jp?G1:jp: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",(n=this.container)===null||n===void 0||n.appendChild(r),r}build(){const e=this.instance.container,n=this.cn("container");let{container:i,prev:r,next:a}=this;i||(i=e.querySelector("."+n),this.isDom=!!i),i||(i=document.createElement("div"),Ct(i,n),e.appendChild(i)),this.container=i,a||(a=i.querySelector("[data-carousel-next]")),a||(a=this.addBtn(jp)),this.next=a,r||(r=i.querySelector("[data-carousel-prev]")),r||(r=this.addBtn(G1)),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(Z1,"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 Y1 extends Fs{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:n}=this;e&&n&&(e.options.initialSlide=n.options.initialPage,e.state===ci.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===ci.Ready?this.onTargetReady(n):n.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,n,i){this.onNavTouch(e,e.panzoom,i)}onNavTouch(e,n,i){var r,a;if(Math.abs(n.dragOffset.x)>3||Math.abs(n.dragOffset.y)>3)return;const u=i.target,{nav:l,target:g}=this;if(!l||!g||!u)return;const _=u.closest("[data-index]");if(i.stopPropagation(),i.preventDefault(),!_)return;const k=parseInt(_.dataset.index||"",10)||0,E=g.getPageForSlide(k),T=l.getPageForSlide(k);l.slideTo(T),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,n){n.index===this.selectedIndex&&this.markSelectedSlide(n.index)}onTargetChange(){var e,n;const{target:i,nav:r}=this;if(!i||!r||r.state!==ci.Ready||i.state!==ci.Ready)return;const a=(n=(e=i.pages[i.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index,u=r.getPageForSlide(a);this.markSelectedSlide(a),r.slideTo(u,r.prevPage===null&&i.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const n=this.nav;n&&n.state===ci.Ready&&(this.selectedIndex=e,[...n.slides].map(i=>{i.el&&i.el.classList[i.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let n=e.options.target,i=e.options.nav;n?e.addAsNavFor(n):i&&e.addAsTargetFor(i)}detach(){const e=this,n=e.nav,i=e.target;n&&(n.off("ready",e.onNavReady),n.off("createSlide",e.onNavCreateSlide),n.off("Panzoom.click",e.onNavClick),n.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(Y1,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const Iz={Navigation:Z1,Dots:W1,Sync:Y1},Up="animationend",X1="isSelected",Hp="slide";class ha extends oy{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===ci.Ready}get isInfinite(){let e=!1;const{contentDim:n,viewportDim:i,pages:r,slides:a}=this,u=a[0];return r.length>=2&&u&&n+u.dim>=i&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,n={},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:ci.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||!Tr(e))throw new Error("No Element found");this.container=e,this.slideNext=H1(this.slideNext.bind(this),150),this.slidePrev=H1(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=i,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const i=Cr({},ha.defaults,this.userOptions);let r="";const a=i.breakpoints;if(a&&ry(a))for(const[u,l]of Object.entries(a))window.matchMedia(u).matches&&ry(l)&&(r+=u,Cr(i,l));r===this.bp&&this.state!==ci.Init||(this.bp=r,this.state===ci.Ready&&(i.initialSlide=((n=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index)||0),this.state!==ci.Init&&this.destroy(),super.setOptions(i),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=ci.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=ci.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");Ct(e,this.cn("container")),to(e,n.isLTR,!this.isRTL),to(e,n.isRTL,this.isRTL),to(e,n.isVertical,!this.isHorizontal),to(e,n.isHorizontal,this.isHorizontal);let i=this.option("viewport")||e.querySelector(`.${n.viewport}`);i||(i=document.createElement("div"),Ct(i,n.viewport),i.append(...q1(e,`.${n.slide}`)),e.prepend(i)),i.addEventListener("scroll",this.onScroll);let r=this.option("track")||e.querySelector(`.${n.track}`);r||(r=document.createElement("div"),Ct(r,n.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 n=[...this.slides],i=[];[...q1(e,`.${this.cn(Hp)}`)].forEach(r=>{if(Tr(r)){const a=uy({el:r,isDom:!0,index:this.slides.length});i.push(a)}});for(let r of[...this.option("slides",[])||[],...n])i.push(uy(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:n,isHorizontal:i}=this;if(!e||!n.length)return;let r=this.page;n[r]||(this.page=r=0);const a=(n[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,Cr({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:n=>!(this.pages.length<2&&!n.options.infinite),bounds:()=>this.getBounds(),maxVelocity:n=>Math.abs(n.target[this.axis]-n.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(n,i,...r)=>{this.emit(`Panzoom.${i}`,n,...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:n,viewportDim:i}=this;let r=this.option("slidesPerPage");r=(r==="auto"||n<=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(Az()),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:n,viewportDim:i,isInfinite:r}=this,a=this.option("center"),u=this.option("fill"),l=u&&a&&n>i&&!r;if(e.forEach((k,E)=>{var T;k.index=E,k.pos=((T=k.slides[0])===null||T===void 0?void 0:T.pos)||0,k.dim=0;for(const[I,z]of k.slides.entries())k.dim+=z.dim,I<k.slides.length-1&&(k.dim+=z.gap);l&&k.pos+.5*k.dim<.5*i?k.pos=0:l&&k.pos+.5*k.dim>=n-.5*i?k.pos=n-i:a&&(k.pos+=-.5*(i-k.dim))}),e.forEach(k=>{u&&!r&&n>i&&(k.pos=Math.max(k.pos,0),k.pos=Math.min(k.pos,n-i)),k.pos=st(k.pos,1e3),k.dim=st(k.dim,1e3),Math.abs(k.pos)<=.1&&(k.pos=0)}),r)return e;const g=[];let _;return e.forEach(k=>{const E=Object.assign({},k);_&&E.pos===_.pos?(_.dim+=E.dim,_.slides=[..._.slides,...E.slides]):(E.index=g.length,_=E,g.push(E))}),g}getPageFromIndex(e=0){const n=this.pages.length;let i;return e=parseInt((e||0).toString())||0,i=this.isInfinite?(e%n+n)%n:Math.max(Math.min(e,n-1),0),i}getSlideMetrics(e){var n,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(Hp)+" "+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,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1);let k=l[this.isHorizontal?"offsetWidth":"offsetHeight"];k-1>a&&(a=k)}const _=getComputedStyle(l);return _.boxSizing==="content-box"&&(this.isHorizontal?(a+=parseFloat(_.paddingLeft)||0,a+=parseFloat(_.paddingRight)||0):(a+=parseFloat(_.paddingTop)||0,a+=parseFloat(_.paddingBottom)||0)),u=parseFloat(_[this.isHorizontal?"marginRight":"marginBottom"])||0,g?(i=l.parentElement)===null||i===void 0||i.removeChild(l):e.el||l.remove(),{dim:st(a,1e3),gap:st(u,1e3)}}getBounds(){const{isInfinite:e,isRTL:n,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=n&&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:n,isRTL:i,isInfinite:r,viewport:a,viewportDim:u,contentDim:l,page:g,pages:_,slides:k,panzoom:E}=this,T=0,I=0,z=0,V=0;E?V=-1*E.current[this.axis]:_[g]&&(V=_[g].pos||0),e=n?i?"right":"left":"top",i&&n&&(V*=-1);for(const oe of k){const J=oe.el;J?(e==="top"?(J.style.right="",J.style.left=""):J.style.top="",oe.index!==T?J.style[e]=I===0?"":`${st(I,1e3)}px`:J.style[e]="",z+=oe.dim+oe.gap,T++):I+=oe.dim+oe.gap}if(r&&z&&a){let oe=getComputedStyle(a),J="padding",Ae=n?"Right":"Bottom",ke=parseFloat(oe[J+(n?"Left":"Top")]);V-=ke,u+=ke,u+=parseFloat(oe[J+Ae]);for(const Me of k)Me.el&&(st(Me.pos)<st(u)&&st(Me.pos+Me.dim+Me.gap)<st(V)&&st(V)>st(l-u)&&(Me.el.style[e]=`${st(I+z,1e3)}px`),st(Me.pos+Me.gap)>=st(l-u)&&st(Me.pos)>st(V+u)&&st(V)<st(u)&&(Me.el.style[e]=`-${st(z,1e3)}px`))}let H,Z,ee=[...this.inTransition];if(ee.length>1&&(H=_[ee[0]],Z=_[ee[1]]),H&&Z){let oe=0;for(const J of k)J.el?this.inTransition.has(J.index)&&H.slides.indexOf(J)<0&&(J.el.style[e]=`${st(oe+(H.pos-Z.pos),1e3)}px`):oe+=J.dim+J.gap}}createSlideEl(e){const{track:n,slides:i}=this;if(!n||!e||e.el&&e.el.parentNode)return;const r=e.el||document.createElement("div");Ct(r,this.cn(Hp)),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 _=g&&g.el&&g.el.parentNode?g.index<e.index?g.el.nextSibling:g.el:null;n.insertBefore(r,n.contains(_)?_:null),e.el=r,this.emit("createSlide",e)}removeSlideEl(e,n=!1){const i=e==null?void 0:e.el;if(!i||!i.parentNode)return;const r=this.cn(X1);if(i.classList.contains(r)&&(kn(i,r),this.emit("unselectSlide",e)),e.isDom&&!n)return i.removeAttribute("aria-hidden"),i.removeAttribute("data-index"),void(i.style.left="");this.emit("removeSlide",e);const a=new CustomEvent(Up);i.dispatchEvent(a),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,n=this.option("transition")){var i,r,a,u;if(!n)return!1;const l=this.page,{pages:g,panzoom:_}=this;e=parseInt((e||0).toString())||0;const k=this.getPageFromIndex(e);if(!_||!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 T=g[k].pos*(this.isRTL?1:-1);if(l===k&&Math.abs(T-_.target[this.axis])<1)return!1;this.clearTransitions();const I=_.isResting;Ct(this.container,this.cn("inTransition"));const z=((a=g[l])===null||a===void 0?void 0:a.slides[0])||null,V=((u=g[k])===null||u===void 0?void 0:u.slides[0])||null;this.inTransition.add(V.index),this.createSlideEl(V);let H=z.el,Z=V.el;I||n===Hp||(n="fadeFast",H=null);const ee=this.isRTL?"next":"prev",oe=this.isRTL?"prev":"next";return H&&(this.inTransition.add(z.index),z.transition=n,H.addEventListener(Up,this.onAnimationEnd),H.classList.add(`f-${n}Out`,`to-${E>0?oe:ee}`)),Z&&(V.transition=n,Z.addEventListener(Up,this.onAnimationEnd),Z.classList.add(`f-${n}In`,`from-${E>0?ee:oe}`)),_.current[this.axis]=T,_.target[this.axis]=T,_.requestTick(),this.onChange(k),!0}manageSlideVisiblity(){const e=new Set,n=new Set,i=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const r of this.slides)i.has(r)?e.add(r):n.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 n)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 n=this.cn(X1);if(n)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(n)||(Ct(r,n),this.emit("selectSlide",i)),r.removeAttribute(e)):(r.classList.contains(n)&&(kn(r,n),this.emit("unselectSlide",i)),r.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:n,isInfinite:i,isRTL:r,viewportDim:a,contentDim:u}=this,l=this.panzoom;if(!l||!i)return;let g=l.current[e],_=l.target[e]-g,k=0,E=.5*a;r&&n?(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+_)}lazyLoadImg(e,n){const i=this,r="f-fadeIn",a="is-preloading";let u=!1,l=null;const g=()=>{u||(u=!0,l&&(l.remove(),l=null),kn(n,a),n.complete&&(Ct(n,r),setTimeout(()=>{kn(n,r)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(i.updateMetrics(),i.setViewportHeight()),this.emit("load",e))};Ct(n,a),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{g()}),n.addEventListener("load",()=>{g()}),setTimeout(()=>{const _=n.parentNode;_&&e.el&&(n.complete?g():u||(l=eo(ay),_.insertBefore(l,n)))},300)}lazyLoadSlide(e){const n=e&&e.el;if(!n)return;const i=new Set;let r=Array.from(n.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));n.dataset.lazySrc&&r.push(n),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 n;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&&(!((n=this.panzoom)===null||n===void 0)&&n.isResting)&&this.emit("settle")}onDecel(e,n=0,i=0,r=0,a=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:u,isHorizontal:l,axis:g,pages:_}=this,k=_.length,E=Math.abs(Math.atan2(i,n)/(Math.PI/180));let T=0;if(T=E>45&&E<135?l?0:i:l?n:0,!k)return;let I=this.page,z=u&&l?1:-1;const V=e.current[g]*z;let{pageIndex:H}=this.getPageFromPosition(V);Math.abs(T)>5?(_[I].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(I=H),I=u&&l?T<0?I-1:I+1:T<0?I+1:I-1):I=r===0&&a===0?I:H,this.slideTo(I,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const n=e.target,i=n&&Tr(n)?n.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(),n&&!n.hasAttribute("disabled")&&this[a](r)):this.emit("click",e)}onSlideTo(e){const n=e.detail||0;this.slideTo(this.getPageForSlide(n),{friction:0})}onChange(e,n=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,n))}onRefresh(){let e=this.contentDim,n=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===n||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,n=null){this.destroy(),this.state=ci.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=n||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:n=this.option("friction"),transition:i=this.option("transition")}={}){if(this.state===ci.Destroy)return;e=parseInt((e||0).toString())||0;const r=this.getPageFromIndex(e),{axis:a,isHorizontal:u,isRTL:l,pages:g,panzoom:_}=this,k=g.length,E=l&&u?1:-1;if(!_||!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 T=g[r].pos;if(this.isInfinite){const I=this.contentDim,z=_.target[a]*E;k===2?T+=I*Math.floor(parseFloat(e+"")/2):T=[T,T-I,T+I].reduce(function(V,H){return Math.abs(H-z)<Math.abs(V-z)?H:V})}T*=E,Math.abs(_.target[a]-T)<1||(_.panTo({x:u?T:0,y:u?0:T,friction:n}),this.onChange(r))}slideToClosest(e){if(this.panzoom){const{pageIndex:n}=this.getPageFromPosition();this.slideTo(n,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),kn(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const n of this.slides){const i=n.el;if(i){i.removeEventListener(Up,this.onAnimationEnd),i.classList.remove(...e);const r=n.transition;r&&i.classList.remove(`f-${r}Out`,`f-${r}In`)}}this.manageSlideVisiblity()}addSlide(e,n){var i,r,a,u;const l=this.panzoom,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.pos)||0,_=((r=this.pages[this.page])===null||r===void 0?void 0:r.dim)||0,k=this.contentDim<this.viewportDim;let E=Array.isArray(n)?n:[n];const T=[];for(const I of E)T.push(uy(I));this.slides.splice(e,0,...T);for(let I=0;I<this.slides.length;I++)this.slides[I].index=I;for(const I of T)this.emit("beforeInitSlide",I,I.index);if(this.page>=e&&(this.page+=T.length),this.updateMetrics(),l){const I=((a=this.pages[this.page])===null||a===void 0?void 0:a.pos)||0,z=((u=this.pages[this.page])===null||u===void 0?void 0:u.dim)||0,V=this.pages.length||1,H=this.isRTL?_-z:z-_,Z=this.isRTL?g-I:I-g;k&&V===1?(e<=this.page&&(l.current[this.axis]-=H,l.target[this.axis]-=H),l.panTo({[this.isHorizontal?"x":"y"]:-1*I})):Z&&e<=this.page&&(l.target[this.axis]-=Z,l.current[this.axis]-=Z,l.requestTick())}for(const I of T)this.emit("initSlide",I,I.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const n=this.slides.length;e=(e%n+n)%n;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:n,track:i,slides:r,isHorizontal:a,isInfinite:u}=this;if(!i)return;const l=a?"width":"height",g=a?"offsetWidth":"offsetHeight";if(n){let E=Math.max(n[g],st(n.getBoundingClientRect()[l],1e3)),T=getComputedStyle(n),I="padding",z=a?"Right":"Bottom";E-=parseFloat(T[I+(a?"Left":"Top")])+parseFloat(T[I+z]),this.viewportDim=E}let _,k=0;for(const[E,T]of r.entries()){let I=0,z=0;!T.el&&_?(I=_.dim,z=_.gap):({dim:I,gap:z}=this.getSlideMetrics(T),_=T),I=st(I,1e3),z=st(z,1e3),T.dim=I,T.gap=z,T.pos=k,k+=I,(u||E<r.length-1)&&(k+=z)}k=st(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===ci.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,n=!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,_=st((g-l.pos)/(1*l.dim),1e3),k=_,E=_;this.isInfinite&&i!==!0&&(k=st((g-l.pos+u)/(1*l.dim),1e3),E=st((g-l.pos-u)/(1*l.dim),1e3));let T=[_,k,E].reduce(function(I,z){return Math.abs(z)<Math.abs(I)?z:I});return n?T:T>1?1:T<-1?-1:T}setViewportHeight(){const{page:e,pages:n,viewport:i,isHorizontal:r}=this;if(!i||!n[e])return;let a=0;r&&this.track&&(this.track.style.height="auto",n[e].slides.forEach(u=>{u.el&&(a=Math.max(a,u.el.offsetHeight))})),i.style.height=a?`${a}px`:""}getPageForSlide(e){for(const n of this.pages)for(const i of n.slides)if(i.index===e)return n.index;return-1}getVisibleSlides(e=0){var n;const i=new Set;let{panzoom:r,contentDim:a,viewportDim:u,pages:l,page:g}=this;if(u){a=a+((n=this.slides[this.slides.length-1])===null||n===void 0?void 0:n.gap)||0;let _=0;_=r&&r.state!==An.Init&&r.state!==An.Destroy?-1*r.current[this.axis]:l[g]&&l[g].pos||0,this.isInfinite&&(_-=Math.floor(_/a)*a),this.isRTL&&this.isHorizontal&&(_*=-1);const k=_-u*e,E=_+u*(e+1),T=this.isInfinite?[-1,0,1]:[0];for(const I of this.slides)for(const z of T){const V=I.pos+z*a,H=V+I.dim+I.gap;V<E&&H>k&&i.add(I)}}return i}getPageFromPosition(e){const{viewportDim:n,contentDim:i,slides:r,pages:a,panzoom:u}=this,l=a.length,g=r.length,_=r[0],k=r[g-1],E=this.option("center");let T=0,I=0,z=0,V=e===void 0?-1*((u==null?void 0:u.target[this.axis])||0):e;E&&(V+=.5*n),this.isInfinite?(V<_.pos-.5*k.gap&&(V-=i,z=-1),V>k.pos+k.dim+.5*k.gap&&(V-=i,z=1)):V=Math.max(_.pos||0,Math.min(V,k.pos));let H=k,Z=r.find(ee=>{const oe=ee.pos-.5*H.gap,J=ee.pos+ee.dim+.5*ee.gap;return H=ee,V>=oe&&V<J});return Z||(Z=k),I=this.getPageForSlide(Z.index),T=I+z*l,{page:T,pageIndex:I}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([ci.Destroy].includes(this.state))return;this.state=ci.Destroy;const{container:e,viewport:n,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(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&i&&i.offsetParent&&n.replaceWith(...i.childNodes));for(const[g,_]of Object.entries(u))g!=="container"&&_&&e.classList.remove(_);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:Mz}),Object.defineProperty(ha,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:Iz});const K1=function(t){if(!Tr(t))return 0;const e=window.scrollY,n=window.innerHeight,i=e+n,r=t.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 _=g/n*100;return Math.round(_)},fh=!(typeof window>"u"||!window.document||!window.document.createElement);let hy;const dy=["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(","),J1=t=>{if(t&&fh){hy===void 0&&document.createElement("div").focus({get preventScroll(){return hy=!0,!1}});try{if(hy)t.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,n=window.scrollX||document.body.scrollLeft;t.focus(),document.body.scrollTo({top:e,left:n,behavior:"auto"})}}catch{}}},Q1=()=>{const t=document;let e,n="",i="",r="";return t.fullscreenEnabled?(n="requestFullscreen",i="exitFullscreen",r="fullscreenElement"):t.webkitFullscreenEnabled&&(n="webkitRequestFullscreen",i="webkitExitFullscreen",r="webkitFullscreenElement"),n&&(e={request:function(a=t.documentElement){return n==="webkitRequestFullscreen"?a[n](Element.ALLOW_KEYBOARD_INPUT):a[n]()},exit:function(){return t[r]&&t[i]()},isFullscreen:function(){return t[r]}}),e},py={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({},V1),{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
|
+
`),te=P.createShader(P.FRAGMENT_SHADER);if(P.isContextLost())return void(this.failedToCreate=!0);if(P.shaderSource(te,ce),P.compileShader(te),!P.getShaderParameter(te,P.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${P.getShaderInfoLog(te)}`);P.attachShader(this.program,te);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=B.length;for(let xe=0;xe<this.numAttributes;xe++)B[xe]&&(P.bindAttribLocation(this.program,xe,B[xe]),this.attributes[B[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(te);for(let xe=0;xe<re.length;xe++){const Oe=re[xe];if(Oe&&!ge[Oe]){const Fe=P.getUniformLocation(this.program,Oe);Fe&&(ge[Oe]=Fe)}}this.fixedUniforms=m(s,ge),this.terrainUniforms=((xe,Oe)=>({u_depth:new l.aH(xe,Oe.u_depth),u_terrain:new l.aH(xe,Oe.u_terrain),u_terrain_dim:new l.aI(xe,Oe.u_terrain_dim),u_terrain_matrix:new l.aJ(xe,Oe.u_terrain_matrix),u_terrain_unpack:new l.aK(xe,Oe.u_terrain_unpack),u_terrain_exaggeration:new l.aI(xe,Oe.u_terrain_exaggeration)}))(s,ge),this.binderUniforms=f?f.getUniforms(s,ge):[]}draw(s,d,f,m,b,M,P,D,L,B,F,W,K,Q,re,le,ce,he){const te=s.gl;if(this.failedToCreate)return;if(s.program.set(this.program),s.setDepthMode(f),s.setStencilMode(m),s.setColorMode(b),s.setCullFace(M),D){s.activeTexture.set(te.TEXTURE2),te.bindTexture(te.TEXTURE_2D,D.depthTexture),s.activeTexture.set(te.TEXTURE3),te.bindTexture(te.TEXTURE_2D,D.texture);for(const ge in this.terrainUniforms)this.terrainUniforms[ge].set(D[ge])}for(const ge in this.fixedUniforms)this.fixedUniforms[ge].set(P[ge]);re&&re.setUniforms(s,this.binderUniforms,K,{zoom:Q});let me=0;switch(d){case te.LINES:me=2;break;case te.TRIANGLES:me=3;break;case te.LINE_STRIP:me=1}for(const ge of W.get()){const xe=ge.vaos||(ge.vaos={});(xe[L]||(xe[L]=new Kh)).bind(s,this,B,re?re.getPaintVertexBuffers():[],F,ge.vertexOffset,le,ce,he),te.drawElements(d,ge.primitiveLength*me,te.UNSIGNED_SHORT,ge.primitiveOffset*me*2)}}}function nu(x,s,d){const f=1/Zt(d,1,s.transform.tileZoom),m=Math.pow(2,d.tileID.overscaledZ),b=d.tileSize*Math.pow(2,s.transform.tileZoom)/m,M=b*(d.tileID.canonical.x+d.tileID.wrap*m),P=b*d.tileID.canonical.y;return{u_image:0,u_texsize:d.imageAtlasTexture.size,u_scale:[f,x.fromScale,x.toScale],u_fade:x.t,u_pixel_coord_upper:[M>>16,P>>16],u_pixel_coord_lower:[65535&M,65535&P]}}const Bl=(x,s,d,f)=>{const m=s.style.light,b=m.properties.get("position"),M=[b.x,b.y,b.z],P=function(){var L=new l.A(9);return l.A!=Float32Array&&(L[1]=0,L[2]=0,L[3]=0,L[5]=0,L[6]=0,L[7]=0),L[0]=1,L[4]=1,L[8]=1,L}();m.properties.get("anchor")==="viewport"&&function(L,B){var F=Math.sin(B),W=Math.cos(B);L[0]=W,L[1]=F,L[2]=0,L[3]=-F,L[4]=W,L[5]=0,L[6]=0,L[7]=0,L[8]=1}(P,-s.transform.angle),function(L,B,F){var W=B[0],K=B[1],Q=B[2];L[0]=W*F[0]+K*F[3]+Q*F[6],L[1]=W*F[1]+K*F[4]+Q*F[7],L[2]=W*F[2]+K*F[5]+Q*F[8]}(M,M,P);const D=m.properties.get("color");return{u_matrix:x,u_lightpos:M,u_lightintensity:m.properties.get("intensity"),u_lightcolor:[D.r,D.g,D.b],u_vertical_gradient:+d,u_opacity:f}},iu=(x,s,d,f,m,b,M)=>l.e(Bl(x,s,d,f),nu(b,s,M),{u_height_factor:-Math.pow(2,m.overscaledZ)/M.tileSize/8}),Ia=x=>({u_matrix:x}),Gf=(x,s,d,f)=>l.e(Ia(x),nu(d,s,f)),X0=(x,s)=>({u_matrix:x,u_world:s}),Zf=(x,s,d,f,m)=>l.e(Gf(x,s,d,f),{u_world:m}),K0=(x,s,d,f)=>{const m=x.transform;let b,M;if(f.paint.get("circle-pitch-alignment")==="map"){const P=Zt(d,1,m.zoom);b=!0,M=[P,P]}else b=!1,M=m.pixelsToGLUnits;return{u_camera_to_center_distance:m.cameraToCenterDistance,u_scale_with_map:+(f.paint.get("circle-pitch-scale")==="map"),u_matrix:x.translatePosMatrix(s.posMatrix,d,f.paint.get("circle-translate"),f.paint.get("circle-translate-anchor")),u_pitch_with_map:+b,u_device_pixel_ratio:x.pixelRatio,u_extrude_scale:M}},jo=(x,s,d)=>({u_matrix:x,u_inv_matrix:s,u_camera_to_center_distance:d.cameraToCenterDistance,u_viewport_size:[d.width,d.height]}),Fl=(x,s,d=1)=>({u_matrix:x,u_color:s,u_overlay:0,u_overlay_scale:d}),nr=x=>({u_matrix:x}),ir=(x,s,d,f)=>({u_matrix:x,u_extrude_scale:Zt(s,1,d),u_intensity:f}),ru=(x,s,d,f)=>{const m=l.H();l.aP(m,0,x.width,x.height,0,0,1);const b=x.context.gl;return{u_matrix:m,u_world:[b.drawingBufferWidth,b.drawingBufferHeight],u_image:d,u_color_ramp:f,u_opacity:s.paint.get("heatmap-opacity")}};function su(x,s){const d=Math.pow(2,s.canonical.z),f=s.canonical.y;return[new l.Z(0,f/d).toLngLat().lat,new l.Z(0,(f+1)/d).toLngLat().lat]}const ou=(x,s,d,f)=>{const m=x.transform;return{u_matrix:Kf(x,s,d,f),u_ratio:1/Zt(s,1,m.zoom),u_device_pixel_ratio:x.pixelRatio,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},Yf=(x,s,d,f,m)=>l.e(ou(x,s,d,m),{u_image:0,u_image_height:f}),Da=(x,s,d,f,m)=>{const b=x.transform,M=Xf(s,b);return{u_matrix:Kf(x,s,d,m),u_texsize:s.imageAtlasTexture.size,u_ratio:1/Zt(s,1,b.zoom),u_device_pixel_ratio:x.pixelRatio,u_image:0,u_scale:[M,f.fromScale,f.toScale],u_fade:f.t,u_units_to_pixels:[1/b.pixelsToGLUnits[0],1/b.pixelsToGLUnits[1]]}},J0=(x,s,d,f,m,b)=>{const M=x.lineAtlas,P=Xf(s,x.transform),D=d.layout.get("line-cap")==="round",L=M.getDash(f.from,D),B=M.getDash(f.to,D),F=L.width*m.fromScale,W=B.width*m.toScale;return l.e(ou(x,s,d,b),{u_patternscale_a:[P/F,-L.height/2],u_patternscale_b:[P/W,-B.height/2],u_sdfgamma:M.width/(256*Math.min(F,W)*x.pixelRatio)/2,u_image:0,u_tex_y_a:L.y,u_tex_y_b:B.y,u_mix:m.t})};function Xf(x,s){return 1/Zt(x,1,s.tileZoom)}function Kf(x,s,d,f){return x.translatePosMatrix(f?f.posMatrix:s.tileID.posMatrix,s,d.paint.get("line-translate"),d.paint.get("line-translate-anchor"))}const Q0=(x,s,d,f,m)=>{return{u_matrix:x,u_tl_parent:s,u_scale_parent:d,u_buffer_scale:1,u_fade_t:f.mix,u_opacity:f.opacity*m.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:m.paint.get("raster-brightness-min"),u_brightness_high:m.paint.get("raster-brightness-max"),u_saturation_factor:(M=m.paint.get("raster-saturation"),M>0?1-1/(1.001-M):-M),u_contrast_factor:(b=m.paint.get("raster-contrast"),b>0?1/(1-b):1+b),u_spin_weights:e_(m.paint.get("raster-hue-rotate"))};var b,M};function e_(x){x*=Math.PI/180;const s=Math.sin(x),d=Math.cos(x);return[(2*d+1)/3,(-Math.sqrt(3)*s-d+1)/3,(Math.sqrt(3)*s-d+1)/3]}const Jf=(x,s,d,f,m,b,M,P,D,L,B,F,W,K)=>{const Q=M.transform;return{u_is_size_zoom_constant:+(x==="constant"||x==="source"),u_is_size_feature_constant:+(x==="constant"||x==="camera"),u_size_t:s?s.uSizeT:0,u_size:s?s.uSize:0,u_camera_to_center_distance:Q.cameraToCenterDistance,u_pitch:Q.pitch/360*2*Math.PI,u_rotate_symbol:+d,u_aspect_ratio:Q.width/Q.height,u_fade_change:M.options.fadeDuration?M.symbolFadeChange:1,u_matrix:P,u_label_plane_matrix:D,u_coord_matrix:L,u_is_text:+F,u_pitch_with_map:+f,u_is_along_line:m,u_is_variable_anchor:b,u_texsize:W,u_texture:0,u_translation:B,u_pitched_scale:K}},Vl=(x,s,d,f,m,b,M,P,D,L,B,F,W,K,Q)=>{const re=M.transform;return l.e(Jf(x,s,d,f,m,b,M,P,D,L,B,F,W,Q),{u_gamma_scale:f?Math.cos(re._pitch)*re.cameraToCenterDistance:1,u_device_pixel_ratio:M.pixelRatio,u_is_halo:+K})},ed=(x,s,d,f,m,b,M,P,D,L,B,F,W,K)=>l.e(Vl(x,s,d,f,m,b,M,P,D,L,B,!0,F,!0,K),{u_texsize_icon:W,u_texture_icon:1}),au=(x,s,d)=>({u_matrix:x,u_opacity:s,u_color:d}),td=(x,s,d,f,m,b)=>l.e(function(M,P,D,L){const B=D.imageManager.getPattern(M.from.toString()),F=D.imageManager.getPattern(M.to.toString()),{width:W,height:K}=D.imageManager.getPixelSize(),Q=Math.pow(2,L.tileID.overscaledZ),re=L.tileSize*Math.pow(2,D.transform.tileZoom)/Q,le=re*(L.tileID.canonical.x+L.tileID.wrap*Q),ce=re*L.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:B.tl,u_pattern_br_a:B.br,u_pattern_tl_b:F.tl,u_pattern_br_b:F.br,u_texsize:[W,K],u_mix:P.t,u_pattern_size_a:B.displaySize,u_pattern_size_b:F.displaySize,u_scale_a:P.fromScale,u_scale_b:P.toScale,u_tile_units_to_pixels:1/Zt(L,1,D.transform.tileZoom),u_pixel_coord_upper:[le>>16,ce>>16],u_pixel_coord_lower:[65535&le,65535&ce]}}(f,b,d,m),{u_matrix:x,u_opacity:s}),nd={fillExtrusion:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_lightpos:new l.aN(x,s.u_lightpos),u_lightintensity:new l.aI(x,s.u_lightintensity),u_lightcolor:new l.aN(x,s.u_lightcolor),u_vertical_gradient:new l.aI(x,s.u_vertical_gradient),u_opacity:new l.aI(x,s.u_opacity)}),fillExtrusionPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_lightpos:new l.aN(x,s.u_lightpos),u_lightintensity:new l.aI(x,s.u_lightintensity),u_lightcolor:new l.aN(x,s.u_lightcolor),u_vertical_gradient:new l.aI(x,s.u_vertical_gradient),u_height_factor:new l.aI(x,s.u_height_factor),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade),u_opacity:new l.aI(x,s.u_opacity)}),fill:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix)}),fillPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),fillOutline:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world)}),fillOutlinePattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world),u_image:new l.aH(x,s.u_image),u_texsize:new l.aO(x,s.u_texsize),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),circle:(x,s)=>({u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_scale_with_map:new l.aH(x,s.u_scale_with_map),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_extrude_scale:new l.aO(x,s.u_extrude_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_matrix:new l.aJ(x,s.u_matrix)}),collisionBox:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_pixel_extrude_scale:new l.aO(x,s.u_pixel_extrude_scale)}),collisionCircle:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_inv_matrix:new l.aJ(x,s.u_inv_matrix),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_viewport_size:new l.aO(x,s.u_viewport_size)}),debug:(x,s)=>({u_color:new l.aL(x,s.u_color),u_matrix:new l.aJ(x,s.u_matrix),u_overlay:new l.aH(x,s.u_overlay),u_overlay_scale:new l.aI(x,s.u_overlay_scale)}),clippingMask:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix)}),heatmap:(x,s)=>({u_extrude_scale:new l.aI(x,s.u_extrude_scale),u_intensity:new l.aI(x,s.u_intensity),u_matrix:new l.aJ(x,s.u_matrix)}),heatmapTexture:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_world:new l.aO(x,s.u_world),u_image:new l.aH(x,s.u_image),u_color_ramp:new l.aH(x,s.u_color_ramp),u_opacity:new l.aI(x,s.u_opacity)}),hillshade:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_latrange:new l.aO(x,s.u_latrange),u_light:new l.aO(x,s.u_light),u_shadow:new l.aL(x,s.u_shadow),u_highlight:new l.aL(x,s.u_highlight),u_accent:new l.aL(x,s.u_accent)}),hillshadePrepare:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_image:new l.aH(x,s.u_image),u_dimension:new l.aO(x,s.u_dimension),u_zoom:new l.aI(x,s.u_zoom),u_unpack:new l.aK(x,s.u_unpack)}),line:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels)}),lineGradient:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_image:new l.aH(x,s.u_image),u_image_height:new l.aI(x,s.u_image_height)}),linePattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texsize:new l.aO(x,s.u_texsize),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_image:new l.aH(x,s.u_image),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_scale:new l.aN(x,s.u_scale),u_fade:new l.aI(x,s.u_fade)}),lineSDF:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ratio:new l.aI(x,s.u_ratio),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_units_to_pixels:new l.aO(x,s.u_units_to_pixels),u_patternscale_a:new l.aO(x,s.u_patternscale_a),u_patternscale_b:new l.aO(x,s.u_patternscale_b),u_sdfgamma:new l.aI(x,s.u_sdfgamma),u_image:new l.aH(x,s.u_image),u_tex_y_a:new l.aI(x,s.u_tex_y_a),u_tex_y_b:new l.aI(x,s.u_tex_y_b),u_mix:new l.aI(x,s.u_mix)}),raster:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_tl_parent:new l.aO(x,s.u_tl_parent),u_scale_parent:new l.aI(x,s.u_scale_parent),u_buffer_scale:new l.aI(x,s.u_buffer_scale),u_fade_t:new l.aI(x,s.u_fade_t),u_opacity:new l.aI(x,s.u_opacity),u_image0:new l.aH(x,s.u_image0),u_image1:new l.aH(x,s.u_image1),u_brightness_low:new l.aI(x,s.u_brightness_low),u_brightness_high:new l.aI(x,s.u_brightness_high),u_saturation_factor:new l.aI(x,s.u_saturation_factor),u_contrast_factor:new l.aI(x,s.u_contrast_factor),u_spin_weights:new l.aN(x,s.u_spin_weights)}),symbolIcon:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texture:new l.aH(x,s.u_texture),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),symbolSDF:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texture:new l.aH(x,s.u_texture),u_gamma_scale:new l.aI(x,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_is_halo:new l.aH(x,s.u_is_halo),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),symbolTextAndIcon:(x,s)=>({u_is_size_zoom_constant:new l.aH(x,s.u_is_size_zoom_constant),u_is_size_feature_constant:new l.aH(x,s.u_is_size_feature_constant),u_size_t:new l.aI(x,s.u_size_t),u_size:new l.aI(x,s.u_size),u_camera_to_center_distance:new l.aI(x,s.u_camera_to_center_distance),u_pitch:new l.aI(x,s.u_pitch),u_rotate_symbol:new l.aH(x,s.u_rotate_symbol),u_aspect_ratio:new l.aI(x,s.u_aspect_ratio),u_fade_change:new l.aI(x,s.u_fade_change),u_matrix:new l.aJ(x,s.u_matrix),u_label_plane_matrix:new l.aJ(x,s.u_label_plane_matrix),u_coord_matrix:new l.aJ(x,s.u_coord_matrix),u_is_text:new l.aH(x,s.u_is_text),u_pitch_with_map:new l.aH(x,s.u_pitch_with_map),u_is_along_line:new l.aH(x,s.u_is_along_line),u_is_variable_anchor:new l.aH(x,s.u_is_variable_anchor),u_texsize:new l.aO(x,s.u_texsize),u_texsize_icon:new l.aO(x,s.u_texsize_icon),u_texture:new l.aH(x,s.u_texture),u_texture_icon:new l.aH(x,s.u_texture_icon),u_gamma_scale:new l.aI(x,s.u_gamma_scale),u_device_pixel_ratio:new l.aI(x,s.u_device_pixel_ratio),u_is_halo:new l.aH(x,s.u_is_halo),u_translation:new l.aO(x,s.u_translation),u_pitched_scale:new l.aI(x,s.u_pitched_scale)}),background:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_opacity:new l.aI(x,s.u_opacity),u_color:new l.aL(x,s.u_color)}),backgroundPattern:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_opacity:new l.aI(x,s.u_opacity),u_image:new l.aH(x,s.u_image),u_pattern_tl_a:new l.aO(x,s.u_pattern_tl_a),u_pattern_br_a:new l.aO(x,s.u_pattern_br_a),u_pattern_tl_b:new l.aO(x,s.u_pattern_tl_b),u_pattern_br_b:new l.aO(x,s.u_pattern_br_b),u_texsize:new l.aO(x,s.u_texsize),u_mix:new l.aI(x,s.u_mix),u_pattern_size_a:new l.aO(x,s.u_pattern_size_a),u_pattern_size_b:new l.aO(x,s.u_pattern_size_b),u_scale_a:new l.aI(x,s.u_scale_a),u_scale_b:new l.aI(x,s.u_scale_b),u_pixel_coord_upper:new l.aO(x,s.u_pixel_coord_upper),u_pixel_coord_lower:new l.aO(x,s.u_pixel_coord_lower),u_tile_units_to_pixels:new l.aI(x,s.u_tile_units_to_pixels)}),terrain:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texture:new l.aH(x,s.u_texture),u_ele_delta:new l.aI(x,s.u_ele_delta),u_fog_matrix:new l.aJ(x,s.u_fog_matrix),u_fog_color:new l.aL(x,s.u_fog_color),u_fog_ground_blend:new l.aI(x,s.u_fog_ground_blend),u_fog_ground_blend_opacity:new l.aI(x,s.u_fog_ground_blend_opacity),u_horizon_color:new l.aL(x,s.u_horizon_color),u_horizon_fog_blend:new l.aI(x,s.u_horizon_fog_blend)}),terrainDepth:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_ele_delta:new l.aI(x,s.u_ele_delta)}),terrainCoords:(x,s)=>({u_matrix:new l.aJ(x,s.u_matrix),u_texture:new l.aH(x,s.u_texture),u_terrain_coords_id:new l.aI(x,s.u_terrain_coords_id),u_ele_delta:new l.aI(x,s.u_ele_delta)}),sky:(x,s)=>({u_sky_color:new l.aL(x,s.u_sky_color),u_horizon_color:new l.aL(x,s.u_horizon_color),u_horizon:new l.aI(x,s.u_horizon),u_sky_horizon_blend:new l.aI(x,s.u_sky_horizon_blend)})};class Ms{constructor(s,d,f){this.context=s;const m=s.gl;this.buffer=m.createBuffer(),this.dynamicDraw=!!f,this.context.unbindVAO(),s.bindElementBuffer.set(this.buffer),m.bufferData(m.ELEMENT_ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.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 t_={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class id{constructor(s,d,f,m){this.length=d.length,this.attributes=f,this.itemSize=d.bytesPerElement,this.dynamicDraw=m,this.context=s;const b=s.gl;this.buffer=b.createBuffer(),s.bindVertexBuffer.set(this.buffer),b.bufferData(b.ARRAY_BUFFER,d.arrayBuffer,this.dynamicDraw?b.DYNAMIC_DRAW:b.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 f=0;f<this.attributes.length;f++){const m=d.attributes[this.attributes[f].name];m!==void 0&&s.enableVertexAttribArray(m)}}setVertexAttribPointers(s,d,f){for(let m=0;m<this.attributes.length;m++){const b=this.attributes[m],M=d.attributes[b.name];M!==void 0&&s.vertexAttribPointer(M,b.components,s[t_[b.type]],!1,this.itemSize,b.offset+this.itemSize*(f||0))}}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Uo=new WeakMap;function ho(x){var s;if(Uo.has(x))return Uo.get(x);{const d=(s=x.getParameter(x.VERSION))===null||s===void 0?void 0:s.startsWith("WebGL 2.0");return Uo.set(x,d),d}}class gn{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 gn{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 n_ extends gn{getDefault(){return 1}set(s){(s!==this.current||this.dirty)&&(this.gl.clearDepth(s),this.current=s,this.dirty=!1)}}class Oa extends gn{getDefault(){return 0}set(s){(s!==this.current||this.dirty)&&(this.gl.clearStencil(s),this.current=s,this.dirty=!1)}}class i_ extends gn{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 Qf extends gn{getDefault(){return!0}set(s){(s!==this.current||this.dirty)&&(this.gl.depthMask(s),this.current=s,this.dirty=!1)}}class r_ extends gn{getDefault(){return 255}set(s){(s!==this.current||this.dirty)&&(this.gl.stencilMask(s),this.current=s,this.dirty=!1)}}class em extends gn{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 gn{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 tm extends gn{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 nm extends gn{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 im extends gn{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 rm extends gn{getDefault(){return this.gl.LESS}set(s){(s!==this.current||this.dirty)&&(this.gl.depthFunc(s),this.current=s,this.dirty=!1)}}class Ho extends gn{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 sm extends gn{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 s_ extends gn{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 om extends gn{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 gn{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 o_ extends gn{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 gn{getDefault(){return this.gl.CCW}set(s){(s!==this.current||this.dirty)&&(this.gl.frontFace(s),this.current=s,this.dirty=!1)}}class a_ extends gn{getDefault(){return null}set(s){(s!==this.current||this.dirty)&&(this.gl.useProgram(s),this.current=s,this.dirty=!1)}}class l_ extends gn{getDefault(){return this.gl.TEXTURE0}set(s){(s!==this.current||this.dirty)&&(this.gl.activeTexture(s),this.current=s,this.dirty=!1)}}class am extends gn{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 lm extends gn{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 cm extends gn{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 gn{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 um extends gn{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 gn{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 gn{getDefault(){return null}set(s){var d;if(s===this.current&&!this.dirty)return;const f=this.gl;ho(f)?f.bindVertexArray(s):(d=f.getExtension("OES_vertex_array_object"))===null||d===void 0||d.bindVertexArrayOES(s),this.current=s,this.dirty=!1}}class od extends gn{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 gn{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 gn{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 gn{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 qo 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 c_{constructor(s,d,f,m,b){this.context=s,this.width=d,this.height=f;const M=s.gl,P=this.framebuffer=M.createFramebuffer();if(this.colorAttachment=new cd(s,P),m)this.depthAttachment=b?new ud(s,P):new qo(s,P);else if(b)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 f=this.depthAttachment.get();f&&s.deleteRenderbuffer(f)}s.deleteFramebuffer(this.framebuffer)}}class Jn{constructor(s,d,f){this.blendFunction=s,this.blendColor=d,this.mask=f}}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 u_{constructor(s){var d,f;if(this.gl=s,this.clearColor=new lu(this),this.clearDepth=new n_(this),this.clearStencil=new Oa(this),this.colorMask=new i_(this),this.depthMask=new Qf(this),this.stencilMask=new r_(this),this.stencilFunc=new em(this),this.stencilOp=new rd(this),this.stencilTest=new tm(this),this.depthRange=new nm(this),this.depthTest=new im(this),this.depthFunc=new rm(this),this.blend=new Ho(this),this.blendFunc=new sm(this),this.blendColor=new s_(this),this.blendEquation=new om(this),this.cullFace=new $l(this),this.cullFaceSide=new o_(this),this.frontFace=new cu(this),this.program=new a_(this),this.activeTexture=new l_(this),this.viewport=new am(this),this.bindFramebuffer=new lm(this),this.bindRenderbuffer=new cm(this),this.bindTexture=new sd(this),this.bindVertexBuffer=new um(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 m=s.getExtension("EXT_color_buffer_half_float");this.RGBA16F=(d=s.RGBA16F)!==null&&d!==void 0?d:m==null?void 0:m.RGBA16F_EXT,this.RGB16F=(f=s.RGB16F)!==null&&f!==void 0?f:m==null?void 0:m.RGB16F_EXT,s.getExtension("EXT_color_buffer_float")}else{s.getExtension("EXT_color_buffer_half_float"),s.getExtension("OES_texture_half_float_linear");const m=s.getExtension("OES_texture_half_float");this.HALF_FLOAT=m==null?void 0:m.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,f){return new id(this,s,d,f)}createRenderbuffer(s,d,f){const m=this.gl,b=m.createRenderbuffer();return this.bindRenderbuffer.set(b),m.renderbufferStorage(m.RENDERBUFFER,s,d,f),this.bindRenderbuffer.set(null),b}createFramebuffer(s,d,f,m){return new c_(this,s,d,f,m)}clear({color:s,depth:d,stencil:f}){const m=this.gl;let b=0;s&&(b|=m.COLOR_BUFFER_BIT,this.clearColor.set(s),this.colorMask.set([!0,!0,!0,!0])),d!==void 0&&(b|=m.DEPTH_BUFFER_BIT,this.depthRange.set([0,1]),this.clearDepth.set(d),this.depthMask.set(!0)),f!==void 0&&(b|=m.STENCIL_BUFFER_BIT,this.clearStencil.set(f),this.stencilMask.set(255)),m.clear(b)}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 Ht{constructor(s,d,f){this.func=s,this.mask=d,this.range=f}}Ht.ReadOnly=!1,Ht.ReadWrite=!0,Ht.disabled=new Ht(519,Ht.ReadOnly,[0,1]);const du=7680;class Dn{constructor(s,d,f,m,b,M){this.test=s,this.ref=d,this.mask=f,this.fail=m,this.depthFail=b,this.pass=M}}Dn.disabled=new Dn({func:519,mask:0},0,0,du,du,du);class Cn{constructor(s,d,f){this.enable=s,this.mode=d,this.frontFace=f}}let Wo;function jl(x,s,d,f,m){const b=x.context,M=b.gl,P=x.useProgram("collisionBox"),D=[];let L=0,B=0;for(let ce=0;ce<f.length;ce++){const he=f[ce],te=s.getTile(he).getBucket(d);if(!te)continue;const me=m?te.textCollisionBox:te.iconCollisionBox,ge=te.collisionCircleArray;if(ge.length>0){const xe=l.H();l.aQ(xe,te.placementInvProjMatrix,x.transform.glCoordMatrix),l.aQ(xe,xe,te.placementViewportMatrix),D.push({circleArray:ge,circleOffset:B,transform:he.posMatrix,invTransform:xe,coord:he}),L+=ge.length/4,B=L}me&&P.draw(b,M.LINES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,{u_matrix:he.posMatrix,u_pixel_extrude_scale:[1/(F=x.transform).width,1/F.height]},x.style.map.terrain&&x.style.map.terrain.getTerrainData(he),d.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,x.transform.zoom,null,null,me.collisionVertexBuffer)}var F;if(!m||!D.length)return;const W=x.useProgram("collisionCircle"),K=new l.aR;K.resize(4*L),K._trim();let Q=0;for(const ce of D)for(let he=0;he<ce.circleArray.length/4;he++){const te=4*he,me=ce.circleArray[te+0],ge=ce.circleArray[te+1],xe=ce.circleArray[te+2],Oe=ce.circleArray[te+3];K.emplace(Q++,me,ge,xe,Oe,0),K.emplace(Q++,me,ge,xe,Oe,1),K.emplace(Q++,me,ge,xe,Oe,2),K.emplace(Q++,me,ge,xe,Oe,3)}(!Wo||Wo.length<2*L)&&(Wo=function(ce){const he=2*ce,te=new l.aT;te.resize(he),te._trim();for(let me=0;me<he;me++){const ge=6*me;te.uint16[ge+0]=4*me+0,te.uint16[ge+1]=4*me+1,te.uint16[ge+2]=4*me+2,te.uint16[ge+3]=4*me+2,te.uint16[ge+4]=4*me+3,te.uint16[ge+5]=4*me+0}return te}(L));const re=b.createIndexBuffer(Wo,!0),le=b.createVertexBuffer(K,l.aS.members,!0);for(const ce of D){const he=jo(ce.transform,ce.invTransform,x.transform);W.draw(b,M.TRIANGLES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,he,x.style.map.terrain&&x.style.map.terrain.getTerrainData(ce.coord),d.id,le,re,l.a0.simpleSegment(0,2*ce.circleOffset,ce.circleArray.length,ce.circleArray.length/2),null,x.transform.zoom,null,null,null)}le.destroy(),re.destroy()}Cn.disabled=new Cn(!1,1029,2305),Cn.backCCW=new Cn(!0,1029,2305);const Ul=l.an(new Float32Array(16));function hd(x,s,d,f,m,b){const{horizontalAlign:M,verticalAlign:P}=l.au(x);return new l.P((-(M-.5)*s/m+f[0])*b,(-(P-.5)*d/m+f[1])*b)}function Go(x,s,d,f,m,b){const M=s.tileAnchorPoint.add(new l.P(s.translation[0],s.translation[1]));if(s.pitchWithMap){let P=f.mult(b);d||(P=P.rotate(-m));const D=M.add(P);return se(D.x,D.y,s.labelPlaneMatrix,s.getElevation).point}if(d){const P=Te(s.tileAnchorPoint.x+1,s.tileAnchorPoint.y,s).point.sub(x),D=Math.atan(P.y/P.x)+(P.x<0?Math.PI:0);return x.add(f.rotate(D))}return x.add(f)}function za(x,s,d,f,m,b,M,P,D,L,B,F,W,K){const Q=x.text.placedSymbolArray,re=x.text.dynamicLayoutVertexArray,le=x.icon.dynamicLayoutVertexArray,ce={};re.clear();for(let he=0;he<Q.length;he++){const te=Q.get(he),me=te.hidden||!te.crossTileID||x.allowVerticalPlacement&&!te.placedOrientation?null:f[te.crossTileID];if(me){const ge=new l.P(te.anchorX,te.anchorY),xe={getElevation:K,width:m.width,height:m.height,labelPlaneMatrix:b,lineVertexArray:null,pitchWithMap:d,projection:B,projectionCache:null,tileAnchorPoint:ge,translation:F,unwrappedTileID:W},Oe=d?se(ge.x,ge.y,M,K):Te(ge.x,ge.y,xe),Fe=U(m.cameraToCenterDistance,Oe.signedDistanceFromCamera);let Ke=l.ai(x.textSizeData,D,te)*Fe/l.ap;d&&(Ke*=x.tilePixelRatio/P);const{width:nt,height:We,anchor:He,textOffset:pt,textBoxScale:Ot}=me,Ge=hd(He,nt,We,pt,Ot,Ke),et=B.getPitchedTextCorrection(m,ge.add(new l.P(F[0],F[1])),W),Pt=Go(Oe.point,xe,s,Ge,m.angle,et),Nn=x.allowVerticalPlacement&&te.placedOrientation===l.ah.vertical?Math.PI/2:0;for(let Ft=0;Ft<te.numGlyphs;Ft++)l.aj(re,Pt,Nn);L&&te.associatedIconIndex>=0&&(ce[te.associatedIconIndex]={shiftedAnchor:Pt,angle:Nn})}else kt(te.numGlyphs,re)}if(L){le.clear();const he=x.icon.placedSymbolArray;for(let te=0;te<he.length;te++){const me=he.get(te);if(me.hidden)kt(me.numGlyphs,le);else{const ge=ce[te];if(ge)for(let xe=0;xe<me.numGlyphs;xe++)l.aj(le,ge.shiftedAnchor,ge.angle);else kt(me.numGlyphs,le)}}x.icon.dynamicLayoutVertexBuffer.updateData(le)}x.text.dynamicLayoutVertexBuffer.updateData(re)}function Lr(x,s,d){return d.iconsInText&&s?"symbolTextAndIcon":x?"symbolSDF":"symbolIcon"}function dd(x,s,d,f,m,b,M,P,D,L,B,F){const W=x.context,K=W.gl,Q=x.transform,re=Vo(),le=P==="map",ce=D==="map",he=P!=="viewport"&&d.layout.get("symbol-placement")!=="point",te=le&&!ce&&!he,me=!ce&&he,ge=!d.layout.get("symbol-sort-key").isConstant();let xe=!1;const Oe=x.depthModeForSublayer(0,Ht.ReadOnly),Fe=d._unevaluatedLayout.hasValue("text-variable-anchor")||d._unevaluatedLayout.hasValue("text-variable-anchor-offset"),Ke=[],nt=re.getCircleRadiusCorrection(Q);for(const We of f){const He=s.getTile(We),pt=He.getBucket(d);if(!pt)continue;const Ot=m?pt.text:pt.icon;if(!Ot||!Ot.segments.get().length||!Ot.hasVisibleVertices)continue;const Ge=Ot.programConfigurations.get(d.id),et=m||pt.sdfIcons,Pt=m?pt.textSizeData:pt.iconSizeData,Nn=ce||Q.pitch!==0,Ft=x.useProgram(Lr(et,m,pt),Ge),Yt=l.ag(Pt,Q.zoom),Bn=x.style.map.terrain&&x.style.map.terrain.getTerrainData(We);let Ii,ns,Fn,rr,qi=[0,0],Di=null;if(m)ns=He.glyphAtlasTexture,Fn=K.LINEAR,Ii=He.glyphAtlasTexture.size,pt.iconsInText&&(qi=He.imageAtlasTexture.size,Di=He.imageAtlasTexture,rr=Nn||x.options.rotating||x.options.zooming||Pt.kind==="composite"||Pt.kind==="camera"?K.LINEAR:K.NEAREST);else{const Qt=d.layout.get("icon-size").constantOr(0)!==1||pt.iconsNeedLinear;ns=He.imageAtlasTexture,Fn=et||x.options.rotating||x.options.zooming||Qt||Nn?K.LINEAR:K.NEAREST,Ii=He.imageAtlasTexture.size}const Wi=Zt(He,1,x.transform.zoom),Is=me?We.posMatrix:Ul,Xa=Ui(Is,ce,le,x.transform,Wi),Iu=pr(Is,ce,le,x.transform,Wi),Ka=pr(We.posMatrix,ce,le,x.transform,Wi),Fr=re.translatePosition(x.transform,He,b,M),Du=Fe&&pt.hasTextData(),Nd=d.layout.get("icon-text-fit")!=="none"&&Du&&pt.hasIconData();if(he){const Qt=x.style.map.terrain?(Ja,Qa)=>x.style.map.terrain.getElevation(We,Ja,Qa):null,Jo=d.layout.get("text-rotation-alignment")==="map";Y(pt,We.posMatrix,x,m,Xa,Ka,ce,L,Jo,re,We.toUnwrapped(),Q.width,Q.height,Fr,Qt)}const Vr=We.posMatrix,$r=m&&Fe||Nd,po=he||$r?Ul:Xa,is=Iu,ki=et&&d.paint.get(m?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let Oi;Oi=et?pt.iconsInText?ed(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,Ii,qi,nt):Vl(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,m,Ii,!0,nt):Jf(Pt.kind,Yt,te,ce,he,$r,x,Vr,po,is,Fr,m,Ii,nt);const br={program:Ft,buffers:Ot,uniformValues:Oi,atlasTexture:ns,atlasTextureIcon:Di,atlasInterpolation:Fn,atlasInterpolationIcon:rr,isSDF:et,hasHalo:ki};if(ge&&pt.canOverlap){xe=!0;const Qt=Ot.segments.get();for(const Jo of Qt)Ke.push({segments:new l.a0([Jo]),sortKey:Jo.sortKey,state:br,terrainData:Bn})}else Ke.push({segments:Ot.segments,sortKey:0,state:br,terrainData:Bn})}xe&&Ke.sort((We,He)=>We.sortKey-He.sortKey);for(const We of Ke){const He=We.state;if(W.activeTexture.set(K.TEXTURE0),He.atlasTexture.bind(He.atlasInterpolation,K.CLAMP_TO_EDGE),He.atlasTextureIcon&&(W.activeTexture.set(K.TEXTURE1),He.atlasTextureIcon&&He.atlasTextureIcon.bind(He.atlasInterpolationIcon,K.CLAMP_TO_EDGE)),He.isSDF){const pt=He.uniformValues;He.hasHalo&&(pt.u_is_halo=1,pd(He.buffers,We.segments,d,x,He.program,Oe,B,F,pt,We.terrainData)),pt.u_is_halo=0}pd(He.buffers,We.segments,d,x,He.program,Oe,B,F,He.uniformValues,We.terrainData)}}function pd(x,s,d,f,m,b,M,P,D,L){const B=f.context;m.draw(B,B.gl.TRIANGLES,b,M,P,Cn.disabled,D,L,d.id,x.layoutVertexBuffer,x.indexBuffer,s,d.paint,f.transform.zoom,x.programConfigurations.get(d.id),x.dynamicLayoutVertexBuffer,x.opacityVertexBuffer)}function fd(x,s,d,f){const m=x.context,b=m.gl,M=Dn.disabled,P=new Jn([b.ONE,b.ONE],l.aM.transparent,[!0,!0,!0,!0]),D=s.getBucket(d);if(!D)return;const L=f.key;let B=d.heatmapFbos.get(L);B||(B=Hl(m,s.tileSize,s.tileSize),d.heatmapFbos.set(L,B)),m.bindFramebuffer.set(B.framebuffer),m.viewport.set([0,0,s.tileSize,s.tileSize]),m.clear({color:l.aM.transparent});const F=D.programConfigurations.get(d.id),W=x.useProgram("heatmap",F),K=x.style.map.terrain.getTerrainData(f);W.draw(m,b.TRIANGLES,Ht.disabled,M,P,Cn.disabled,ir(f.posMatrix,s,x.transform.zoom,d.paint.get("heatmap-intensity")),K,d.id,D.layoutVertexBuffer,D.indexBuffer,D.segments,d.paint,x.transform.zoom,F)}function Zo(x,s,d){const f=x.context,m=f.gl;f.setColorMode(x.colorModeForRenderPass());const b=ql(f,s),M=d.key,P=s.heatmapFbos.get(M);P&&(f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,P.colorAttachment.get()),f.activeTexture.set(m.TEXTURE1),b.bind(m.LINEAR,m.CLAMP_TO_EDGE),x.useProgram("heatmapTexture").draw(f,m.TRIANGLES,Ht.disabled,Dn.disabled,x.colorModeForRenderPass(),Cn.disabled,ru(x,s,0,1),null,s.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments,s.paint,x.transform.zoom),P.destroy(),s.heatmapFbos.delete(M))}function Hl(x,s,d){var f,m;const b=x.gl,M=b.createTexture();b.bindTexture(b.TEXTURE_2D,M),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_S,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_WRAP_T,b.CLAMP_TO_EDGE),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MIN_FILTER,b.LINEAR),b.texParameteri(b.TEXTURE_2D,b.TEXTURE_MAG_FILTER,b.LINEAR);const P=(f=x.HALF_FLOAT)!==null&&f!==void 0?f:b.UNSIGNED_BYTE,D=(m=x.RGBA16F)!==null&&m!==void 0?m:b.RGBA;b.texImage2D(b.TEXTURE_2D,0,D,s,d,0,b.RGBA,P,null);const L=x.createFramebuffer(s,d,!1,!1);return L.colorAttachment.set(M),L}function ql(x,s){return s.colorRampTexture||(s.colorRampTexture=new it(x,s.colorRamp,x.gl.RGBA)),s.colorRampTexture}function Ra(x,s,d,f,m){if(!d||!f||!f.imageAtlas)return;const b=f.imageAtlas.patternPositions;let M=b[d.to.toString()],P=b[d.from.toString()];if(!M&&P&&(M=P),!P&&M&&(P=M),!M||!P){const D=m.getPaintProperty(s);M=b[D],P=b[D]}M&&P&&x.setConstantPatternPositions(M,P)}function Wl(x,s,d,f,m,b,M){const P=x.context.gl,D="fill-pattern",L=d.paint.get(D),B=L&&L.constantOr(1),F=d.getCrossfadeParameters();let W,K,Q,re,le;M?(K=B&&!d.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",W=P.LINES):(K=B?"fillPattern":"fill",W=P.TRIANGLES);const ce=L.constantOr(null);for(const he of f){const te=s.getTile(he);if(B&&!te.patternsLoaded())continue;const me=te.getBucket(d);if(!me)continue;const ge=me.programConfigurations.get(d.id),xe=x.useProgram(K,ge),Oe=x.style.map.terrain&&x.style.map.terrain.getTerrainData(he);B&&(x.context.activeTexture.set(P.TEXTURE0),te.imageAtlasTexture.bind(P.LINEAR,P.CLAMP_TO_EDGE),ge.updatePaintBuffers(F)),Ra(ge,D,ce,te,d);const Fe=Oe?he:null,Ke=x.translatePosMatrix(Fe?Fe.posMatrix:he.posMatrix,te,d.paint.get("fill-translate"),d.paint.get("fill-translate-anchor"));if(M){re=me.indexBuffer2,le=me.segments2;const nt=[P.drawingBufferWidth,P.drawingBufferHeight];Q=K==="fillOutlinePattern"&&B?Zf(Ke,x,F,te,nt):X0(Ke,nt)}else re=me.indexBuffer,le=me.segments,Q=B?Gf(Ke,x,F,te):Ia(Ke);xe.draw(x.context,W,m,x.stencilModeForClipping(he),b,Cn.disabled,Q,Oe,d.id,me.layoutVertexBuffer,re,le,d.paint,x.transform.zoom,ge)}}function pu(x,s,d,f,m,b,M){const P=x.context,D=P.gl,L="fill-extrusion-pattern",B=d.paint.get(L),F=B.constantOr(1),W=d.getCrossfadeParameters(),K=d.paint.get("fill-extrusion-opacity"),Q=B.constantOr(null);for(const re of f){const le=s.getTile(re),ce=le.getBucket(d);if(!ce)continue;const he=x.style.map.terrain&&x.style.map.terrain.getTerrainData(re),te=ce.programConfigurations.get(d.id),me=x.useProgram(F?"fillExtrusionPattern":"fillExtrusion",te);F&&(x.context.activeTexture.set(D.TEXTURE0),le.imageAtlasTexture.bind(D.LINEAR,D.CLAMP_TO_EDGE),te.updatePaintBuffers(W)),Ra(te,L,Q,le,d);const ge=x.translatePosMatrix(re.posMatrix,le,d.paint.get("fill-extrusion-translate"),d.paint.get("fill-extrusion-translate-anchor")),xe=d.paint.get("fill-extrusion-vertical-gradient"),Oe=F?iu(ge,x,xe,K,re,W,le):Bl(ge,x,xe,K);me.draw(P,P.gl.TRIANGLES,m,b,M,Cn.backCCW,Oe,he,d.id,ce.layoutVertexBuffer,ce.indexBuffer,ce.segments,d.paint,x.transform.zoom,te,x.style.map.terrain&&ce.centroidVertexBuffer)}}function La(x,s,d,f,m,b,M){const P=x.context,D=P.gl,L=d.fbo;if(!L)return;const B=x.useProgram("hillshade"),F=x.style.map.terrain&&x.style.map.terrain.getTerrainData(s);P.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,L.colorAttachment.get()),B.draw(P,D.TRIANGLES,m,b,M,Cn.disabled,((W,K,Q,re)=>{const le=Q.paint.get("hillshade-shadow-color"),ce=Q.paint.get("hillshade-highlight-color"),he=Q.paint.get("hillshade-accent-color");let te=Q.paint.get("hillshade-illumination-direction")*(Math.PI/180);Q.paint.get("hillshade-illumination-anchor")==="viewport"&&(te-=W.transform.angle);const me=!W.options.moving;return{u_matrix:re?re.posMatrix:W.transform.calculatePosMatrix(K.tileID.toUnwrapped(),me),u_image:0,u_latrange:su(0,K.tileID),u_light:[Q.paint.get("hillshade-exaggeration"),te],u_shadow:le,u_highlight:ce,u_accent:he}})(x,d,f,F?s:null),F,f.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments)}function Na(x,s,d,f,m,b){const M=x.context,P=M.gl,D=s.dem;if(D&&D.data){const L=D.dim,B=D.stride,F=D.getPixels();if(M.activeTexture.set(P.TEXTURE1),M.pixelStoreUnpackPremultiplyAlpha.set(!1),s.demTexture=s.demTexture||x.getTileTexture(B),s.demTexture){const K=s.demTexture;K.update(F,{premultiply:!1}),K.bind(P.NEAREST,P.CLAMP_TO_EDGE)}else s.demTexture=new it(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 K=new it(M,{width:L,height:L,data:null},P.RGBA);K.bind(P.LINEAR,P.CLAMP_TO_EDGE),W=s.fbo=M.createFramebuffer(L,L,!0,!1),W.colorAttachment.set(K.texture)}M.bindFramebuffer.set(W.framebuffer),M.viewport.set([0,0,L,L]),x.useProgram("hillshadePrepare").draw(M,P.TRIANGLES,f,m,b,Cn.disabled,((K,Q)=>{const re=Q.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:[re,re],u_zoom:K.overscaledZ,u_unpack:Q.getUnpackVector()}})(s.tileID,D),null,d.id,x.rasterBoundsBuffer,x.quadTriangleIndexBuffer,x.rasterBoundsSegments),s.needsHillshadePrepare=!1}}function hm(x,s,d,f,m,b){const M=f.paint.get("raster-fade-duration");if(!b&&M>0){const P=E.now(),D=(P-x.timeAdded)/M,L=s?(P-s.timeAdded)/M:-1,B=d.getSource(),F=m.coveringZoomLevel({tileSize:B.tileSize,roundZoom:B.roundZoom}),W=!s||Math.abs(s.tileID.overscaledZ-F)>Math.abs(x.tileID.overscaledZ-F),K=W&&x.refreshedUponExpiration?1:l.ac(W?D:1-L,0,1);return x.refreshedUponExpiration&&D>=1&&(x.refreshedUponExpiration=!1),s?{opacity:1,mix:1-K}:{opacity:K,mix:0}}return{opacity:1,mix:0}}const md=new l.aM(1,0,0,1),cn=new l.aM(0,1,0,1),fu=new l.aM(0,0,1,1),h_=new l.aM(1,0,1,1),dm=new l.aM(0,1,1,1);function Ba(x,s,d,f){mu(x,0,s+d/2,x.transform.width,d,f)}function pm(x,s,d,f){mu(x,s-d/2,0,d,x.transform.height,f)}function mu(x,s,d,f,m,b){const M=x.context,P=M.gl;P.enable(P.SCISSOR_TEST),P.scissor(s*x.pixelRatio,d*x.pixelRatio,f*x.pixelRatio,m*x.pixelRatio),M.clear({color:b}),P.disable(P.SCISSOR_TEST)}function fm(x,s,d){const f=x.context,m=f.gl,b=d.posMatrix,M=x.useProgram("debug"),P=Ht.disabled,D=Dn.disabled,L=x.colorModeForRenderPass(),B="$debug",F=x.style.map.terrain&&x.style.map.terrain.getTerrainData(d);f.activeTexture.set(m.TEXTURE0);const W=s.getTileByID(d.key).latestRawTileData,K=Math.floor((W&&W.byteLength||0)/1024),Q=s.getTile(d).tileSize,re=512/Math.min(Q,512)*(d.overscaledZ/x.transform.zoom)*.5;let le=d.canonical.toString();d.overscaledZ!==d.canonical.z&&(le+=` => ${d.overscaledZ}`),function(ce,he){ce.initDebugOverlayCanvas();const te=ce.debugOverlayCanvas,me=ce.context.gl,ge=ce.debugOverlayCanvas.getContext("2d");ge.clearRect(0,0,te.width,te.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(te),ce.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(x,`${le} ${K}kB`),M.draw(f,m.TRIANGLES,P,D,Jn.alphaBlended,Cn.disabled,Fl(b,l.aM.transparent,re),null,B,x.debugBuffer,x.quadTriangleIndexBuffer,x.debugSegments),M.draw(f,m.LINE_STRIP,P,D,L,Cn.disabled,Fl(b,l.aM.red),F,B,x.debugBuffer,x.tileBorderIndexBuffer,x.debugSegments)}function mm(x,s,d){const f=x.context,m=f.gl,b=x.colorModeForRenderPass(),M=new Ht(m.LEQUAL,Ht.ReadWrite,x.depthRangeFor3D),P=x.useProgram("terrain"),D=s.getTerrainMesh();f.bindFramebuffer.set(null),f.viewport.set([0,0,x.width,x.height]);for(const L of d){const B=x.renderToTexture.getTexture(L),F=s.getTerrainData(L.tileID);f.activeTexture.set(m.TEXTURE0),m.bindTexture(m.TEXTURE_2D,B.texture);const W=x.transform.calculatePosMatrix(L.tileID.toUnwrapped()),K=s.getMeshFrameDelta(x.transform.zoom),Q=x.transform.calculateFogMatrix(L.tileID.toUnwrapped()),re=Jh(W,K,Q,x.style.sky,x.transform.pitch);P.draw(f,m.TRIANGLES,M,Dn.disabled,b,Cn.backCCW,re,F,"terrain",D.vertexBuffer,D.indexBuffer,D.segments)}}class gu{constructor(s,d,f){this.vertexBuffer=s,this.indexBuffer=d,this.segments=f}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 u_(s),this.transform=d,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:l.an(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Re.maxUnderzooming+Re.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new Xh}resize(s,d,f){if(this.width=Math.floor(s*f),this.height=Math.floor(d*f),this.pixelRatio=f,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const m of this.style._order)this.style._layers[m].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,$o.members),this.tileExtentSegments=l.a0.simpleSegment(0,0,4,2);const f=new l.aX;f.emplaceBack(0,0),f.emplaceBack(l.X,0),f.emplaceBack(0,l.X),f.emplaceBack(l.X,l.X),this.debugBuffer=s.createVertexBuffer(f,$o.members),this.debugSegments=l.a0.simpleSegment(0,0,4,5);const m=new l.$;m.emplaceBack(0,0,0,0),m.emplaceBack(l.X,0,l.X,0),m.emplaceBack(0,l.X,0,l.X),m.emplaceBack(l.X,l.X,l.X,l.X),this.rasterBoundsBuffer=s.createVertexBuffer(m,tr.members),this.rasterBoundsSegments=l.a0.simpleSegment(0,0,4,2);const b=new l.aX;b.emplaceBack(0,0),b.emplaceBack(1,0),b.emplaceBack(0,1),b.emplaceBack(1,1),this.viewportBuffer=s.createVertexBuffer(b,$o.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 D=this.context.gl;this.stencilClearMode=new Dn({func:D.ALWAYS,mask:0},0,255,D.ZERO,D.ZERO,D.ZERO)}clearStencil(){const s=this.context,d=s.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const f=l.H();l.aP(f,0,this.width,this.height,0,0,1),l.K(f,f,[d.drawingBufferWidth,d.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(s,d.TRIANGLES,Ht.disabled,this.stencilClearMode,Jn.disabled,Cn.disabled,nr(f),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 f=this.context,m=f.gl;this.nextStencilID+d.length>256&&this.clearStencil(),f.setColorMode(Jn.disabled),f.setDepthMode(Ht.disabled);const b=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const M of d){const P=this._tileClippingMaskIDs[M.key]=this.nextStencilID++,D=this.style.map.terrain&&this.style.map.terrain.getTerrainData(M);b.draw(f,m.TRIANGLES,Ht.disabled,new Dn({func:m.ALWAYS,mask:0},P,255,m.KEEP,m.KEEP,m.REPLACE),Jn.disabled,Cn.disabled,nr(M.posMatrix),D,"$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 Dn({func:d.NOTEQUAL,mask:255},s,255,d.KEEP,d.KEEP,d.REPLACE)}stencilModeForClipping(s){const d=this.context.gl;return new Dn({func:d.EQUAL,mask:255},this._tileClippingMaskIDs[s.key],0,d.KEEP,d.KEEP,d.REPLACE)}stencilConfigForOverlap(s){const d=this.context.gl,f=s.sort((M,P)=>P.overscaledZ-M.overscaledZ),m=f[f.length-1].overscaledZ,b=f[0].overscaledZ-m+1;if(b>1){this.currentStencilSource=void 0,this.nextStencilID+b>256&&this.clearStencil();const M={};for(let P=0;P<b;P++)M[P+m]=new Dn({func:d.GEQUAL,mask:255},P+this.nextStencilID,255,d.KEEP,d.KEEP,d.REPLACE);return this.nextStencilID+=b,[M,f]}return[{[m]:Dn.disabled},f]}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,f){if(!this.opaquePassEnabledForLayer())return Ht.disabled;const m=1-((1+this.currentLayer)*this.numSublayers+s)*this.depthEpsilon;return new Ht(f||this.context.gl.LEQUAL,d,[m,m])}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 f=this.style._order,m=this.style.sourceCaches,b={},M={},P={};for(const D in m){const L=m[D];L.used&&L.prepare(this.context),b[D]=L.getVisibleCoordinates(),M[D]=b[D].slice().reverse(),P[D]=L.getVisibleCoordinates(!0).reverse()}this.opaquePassCutoff=1/0;for(let D=0;D<f.length;D++)if(this.style._layers[f[D]].is3D()){this.opaquePassCutoff=D;break}this.maybeDrawDepthAndCoords(!1),this.renderToTexture&&(this.renderToTexture.prepareForRender(this.style,this.transform.zoom),this.opaquePassCutoff=0),this.renderPass="offscreen";for(const D of f){const L=this.style._layers[D];if(!L.hasOffscreenPass()||L.isHidden(this.transform.zoom))continue;const B=M[L.source];(L.type==="custom"||B.length)&&this.renderLayer(this,m[L.source],L,B)}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(D,L){const B=D.context,F=B.gl,W=((ce,he,te)=>({u_sky_color:ce.properties.get("sky-color"),u_horizon_color:ce.properties.get("horizon-color"),u_horizon:(he.height/2+he.getHorizon())*te,u_sky_horizon_blend:ce.properties.get("sky-horizon-blend")*he.height/2*te}))(L,D.style.map.transform,D.pixelRatio),K=new Ht(F.LEQUAL,Ht.ReadWrite,[0,1]),Q=Dn.disabled,re=D.colorModeForRenderPass(),le=D.useProgram("sky");if(!L.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),L.mesh=new gu(B.createVertexBuffer(ce,$o.members),B.createIndexBuffer(he),l.a0.simpleSegment(0,0,ce.length,he.length))}le.draw(B,F.TRIANGLES,K,Q,re,Cn.disabled,W,void 0,"sky",L.mesh.vertexBuffer,L.mesh.indexBuffer,L.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=f.length-1;this.currentLayer>=0;this.currentLayer--){const D=this.style._layers[f[this.currentLayer]],L=m[D.source],B=b[D.source];this._renderTileClippingMasks(D,B),this.renderLayer(this,L,D,B)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<f.length;this.currentLayer++){const D=this.style._layers[f[this.currentLayer]],L=m[D.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(D))continue;const B=(D.type==="symbol"?P:M)[D.source];this._renderTileClippingMasks(D,b[D.source]),this.renderLayer(this,L,D,B)}if(this.options.showTileBoundaries){const D=function(L,B){let F=null;const W=Object.values(L._layers).flatMap(le=>le.source&&!le.isHidden(B)?[L.sourceCaches[le.source]]:[]),K=W.filter(le=>le.getSource().type==="vector"),Q=W.filter(le=>le.getSource().type!=="vector"),re=le=>{(!F||F.getSource().maxzoom<le.getSource().maxzoom)&&(F=le)};return K.forEach(le=>re(le)),F||Q.forEach(le=>re(le)),F}(this.style,this.transform.zoom);D&&function(L,B,F){for(let W=0;W<F.length;W++)fm(L,B,F[W])}(this,D,D.getVisibleCoordinates())}this.options.showPadding&&function(D){const L=D.transform.padding;Ba(D,D.transform.height-(L.top||0),3,md),Ba(D,L.bottom||0,3,cn),pm(D,L.left||0,3,fu),pm(D,D.transform.width-(L.right||0),3,h_);const B=D.transform.centerPoint;(function(F,W,K,Q){mu(F,W-1,K-10,2,20,Q),mu(F,W-10,K-1,20,2,Q)})(D,B.x,D.transform.height-B.y,dm)}(this),this.context.setDefault()}maybeDrawDepthAndCoords(s){if(!this.style||!this.style.map||!this.style.map.terrain)return;const d=this.terrainFacilitator.matrix,f=this.transform.modelViewProjectionMatrix;let m=this.terrainFacilitator.dirty;m||(m=s?!l.a_(d,f):!l.a$(d,f)),m||(m=this.style.map.terrain.sourceCache.tilesAfterTime(this.terrainFacilitator.renderTime).length>0),m&&(l.b0(d,f),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(b,M){const P=b.context,D=P.gl,L=Jn.unblended,B=new Ht(D.LEQUAL,Ht.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.sourceCache.getRenderableTiles(),K=b.useProgram("terrainDepth");P.bindFramebuffer.set(M.getFramebuffer("depth").framebuffer),P.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1});for(const Q of W){const re=M.getTerrainData(Q.tileID),le={u_matrix:b.transform.calculatePosMatrix(Q.tileID.toUnwrapped()),u_ele_delta:M.getMeshFrameDelta(b.transform.zoom)};K.draw(P,D.TRIANGLES,B,Dn.disabled,L,Cn.backCCW,le,re,"terrain",F.vertexBuffer,F.indexBuffer,F.segments)}P.bindFramebuffer.set(null),P.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain),function(b,M){const P=b.context,D=P.gl,L=Jn.unblended,B=new Ht(D.LEQUAL,Ht.ReadWrite,[0,1]),F=M.getTerrainMesh(),W=M.getCoordsTexture(),K=M.sourceCache.getRenderableTiles(),Q=b.useProgram("terrainCoords");P.bindFramebuffer.set(M.getFramebuffer("coords").framebuffer),P.viewport.set([0,0,b.width/devicePixelRatio,b.height/devicePixelRatio]),P.clear({color:l.aM.transparent,depth:1}),M.coordsIndex=[];for(const re of K){const le=M.getTerrainData(re.tileID);P.activeTexture.set(D.TEXTURE0),D.bindTexture(D.TEXTURE_2D,W.texture);const ce={u_matrix:b.transform.calculatePosMatrix(re.tileID.toUnwrapped()),u_terrain_coords_id:(255-M.coordsIndex.length)/255,u_texture:0,u_ele_delta:M.getMeshFrameDelta(b.transform.zoom)};Q.draw(P,D.TRIANGLES,B,Dn.disabled,L,Cn.backCCW,ce,le,"terrain",F.vertexBuffer,F.indexBuffer,F.segments),M.coordsIndex.push(re.tileID.key)}P.bindFramebuffer.set(null),P.viewport.set([0,0,b.width,b.height])}(this,this.style.map.terrain))}renderLayer(s,d,f,m){if(!f.isHidden(this.transform.zoom)&&(f.type==="background"||f.type==="custom"||(m||[]).length))switch(this.id=f.id,f.type){case"symbol":(function(b,M,P,D,L){if(b.renderPass!=="translucent")return;const B=Dn.disabled,F=b.colorModeForRenderPass();(P._unevaluatedLayout.hasValue("text-variable-anchor")||P._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(W,K,Q,re,le,ce,he,te,me){const ge=K.transform,xe=Vo(),Oe=le==="map",Fe=ce==="map";for(const Ke of W){const nt=re.getTile(Ke),We=nt.getBucket(Q);if(!We||!We.text||!We.text.segments.get().length)continue;const He=l.ag(We.textSizeData,ge.zoom),pt=Zt(nt,1,K.transform.zoom),Ot=Ui(Ke.posMatrix,Fe,Oe,K.transform,pt),Ge=Q.layout.get("icon-text-fit")!=="none"&&We.hasIconData();if(He){const et=Math.pow(2,ge.zoom-nt.tileID.overscaledZ),Pt=K.style.map.terrain?(Ft,Yt)=>K.style.map.terrain.getElevation(Ke,Ft,Yt):null,Nn=xe.translatePosition(ge,nt,he,te);za(We,Oe,Fe,me,ge,Ot,Ke.posMatrix,et,He,Ge,xe,Nn,Ke.toUnwrapped(),Pt)}}}(D,b,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"),L),P.paint.get("icon-opacity").constantOr(1)!==0&&dd(b,M,P,D,!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"),B,F),P.paint.get("text-opacity").constantOr(1)!==0&&dd(b,M,P,D,!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"),B,F),M.map.showCollisionBoxes&&(jl(b,M,P,D,!0),jl(b,M,P,D,!1))})(s,d,f,m,this.style.placement.variableOffsets);break;case"circle":(function(b,M,P,D){if(b.renderPass!=="translucent")return;const L=P.paint.get("circle-opacity"),B=P.paint.get("circle-stroke-width"),F=P.paint.get("circle-stroke-opacity"),W=!P.layout.get("circle-sort-key").isConstant();if(L.constantOr(1)===0&&(B.constantOr(1)===0||F.constantOr(1)===0))return;const K=b.context,Q=K.gl,re=b.depthModeForSublayer(0,Ht.ReadOnly),le=Dn.disabled,ce=b.colorModeForRenderPass(),he=[];for(let te=0;te<D.length;te++){const me=D[te],ge=M.getTile(me),xe=ge.getBucket(P);if(!xe)continue;const Oe=xe.programConfigurations.get(P.id),Fe=b.useProgram("circle",Oe),Ke=xe.layoutVertexBuffer,nt=xe.indexBuffer,We=b.style.map.terrain&&b.style.map.terrain.getTerrainData(me),He={programConfiguration:Oe,program:Fe,layoutVertexBuffer:Ke,indexBuffer:nt,uniformValues:K0(b,me,ge,P),terrainData:We};if(W){const pt=xe.segments.get();for(const Ot of pt)he.push({segments:new l.a0([Ot]),sortKey:Ot.sortKey,state:He})}else he.push({segments:xe.segments,sortKey:0,state:He})}W&&he.sort((te,me)=>te.sortKey-me.sortKey);for(const te of he){const{programConfiguration:me,program:ge,layoutVertexBuffer:xe,indexBuffer:Oe,uniformValues:Fe,terrainData:Ke}=te.state;ge.draw(K,Q.TRIANGLES,re,le,ce,Cn.disabled,Fe,Ke,P.id,xe,Oe,te.segments,P.paint,b.transform.zoom,me)}})(s,d,f,m);break;case"heatmap":(function(b,M,P,D){if(P.paint.get("heatmap-opacity")===0)return;const L=b.context;if(b.style.map.terrain){for(const B of D){const F=M.getTile(B);M.hasRenderableParent(B)||(b.renderPass==="offscreen"?fd(b,F,P,B):b.renderPass==="translucent"&&Zo(b,P,B))}L.viewport.set([0,0,b.width,b.height])}else b.renderPass==="offscreen"?function(B,F,W,K){const Q=B.context,re=Q.gl,le=Dn.disabled,ce=new Jn([re.ONE,re.ONE],l.aM.transparent,[!0,!0,!0,!0]);(function(he,te,me){const ge=he.gl;he.activeTexture.set(ge.TEXTURE1),he.viewport.set([0,0,te.width/4,te.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,te.width/4,te.height/4),me.heatmapFbos.set(l.aU,xe))})(Q,B,W),Q.clear({color:l.aM.transparent});for(let he=0;he<K.length;he++){const te=K[he];if(F.hasRenderableParent(te))continue;const me=F.getTile(te),ge=me.getBucket(W);if(!ge)continue;const xe=ge.programConfigurations.get(W.id),Oe=B.useProgram("heatmap",xe),{zoom:Fe}=B.transform;Oe.draw(Q,re.TRIANGLES,Ht.disabled,le,ce,Cn.disabled,ir(te.posMatrix,me,Fe,W.paint.get("heatmap-intensity")),null,W.id,ge.layoutVertexBuffer,ge.indexBuffer,ge.segments,W.paint,B.transform.zoom,xe)}Q.viewport.set([0,0,B.width,B.height])}(b,M,P,D):b.renderPass==="translucent"&&function(B,F){const W=B.context,K=W.gl;W.setColorMode(B.colorModeForRenderPass());const Q=F.heatmapFbos.get(l.aU);Q&&(W.activeTexture.set(K.TEXTURE0),K.bindTexture(K.TEXTURE_2D,Q.colorAttachment.get()),W.activeTexture.set(K.TEXTURE1),ql(W,F).bind(K.LINEAR,K.CLAMP_TO_EDGE),B.useProgram("heatmapTexture").draw(W,K.TRIANGLES,Ht.disabled,Dn.disabled,B.colorModeForRenderPass(),Cn.disabled,ru(B,F,0,1),null,F.id,B.viewportBuffer,B.quadTriangleIndexBuffer,B.viewportSegments,F.paint,B.transform.zoom))}(b,P)})(s,d,f,m);break;case"line":(function(b,M,P,D){if(b.renderPass!=="translucent")return;const L=P.paint.get("line-opacity"),B=P.paint.get("line-width");if(L.constantOr(1)===0||B.constantOr(1)===0)return;const F=b.depthModeForSublayer(0,Ht.ReadOnly),W=b.colorModeForRenderPass(),K=P.paint.get("line-dasharray"),Q=P.paint.get("line-pattern"),re=Q.constantOr(1),le=P.paint.get("line-gradient"),ce=P.getCrossfadeParameters(),he=re?"linePattern":K?"lineSDF":le?"lineGradient":"line",te=b.context,me=te.gl;let ge=!0;for(const xe of D){const Oe=M.getTile(xe);if(re&&!Oe.patternsLoaded())continue;const Fe=Oe.getBucket(P);if(!Fe)continue;const Ke=Fe.programConfigurations.get(P.id),nt=b.context.program.get(),We=b.useProgram(he,Ke),He=ge||We.program!==nt,pt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(xe),Ot=Q.constantOr(null);if(Ot&&Oe.imageAtlas){const Pt=Oe.imageAtlas,Nn=Pt.patternPositions[Ot.to.toString()],Ft=Pt.patternPositions[Ot.from.toString()];Nn&&Ft&&Ke.setConstantPatternPositions(Nn,Ft)}const Ge=pt?xe:null,et=re?Da(b,Oe,P,ce,Ge):K?J0(b,Oe,P,K,ce,Ge):le?Yf(b,Oe,P,Fe.lineClipsArray.length,Ge):ou(b,Oe,P,Ge);if(re)te.activeTexture.set(me.TEXTURE0),Oe.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),Ke.updatePaintBuffers(ce);else if(K&&(He||b.lineAtlas.dirty))te.activeTexture.set(me.TEXTURE0),b.lineAtlas.bind(te);else if(le){const Pt=Fe.gradients[P.id];let Nn=Pt.texture;if(P.gradientVersion!==Pt.version){let Ft=256;if(P.stepInterpolant){const Yt=M.getSource().maxzoom,Bn=xe.canonical.z===Yt?Math.ceil(1<<b.transform.maxZoom-xe.canonical.z):1;Ft=l.ac(l.aV(Fe.maxLineLength/l.X*1024*Bn),256,te.maxTextureSize)}Pt.gradient=l.aW({expression:P.gradientExpression(),evaluationKey:"lineProgress",resolution:Ft,image:Pt.gradient||void 0,clips:Fe.lineClipsArray}),Pt.texture?Pt.texture.update(Pt.gradient):Pt.texture=new it(te,Pt.gradient,me.RGBA),Pt.version=P.gradientVersion,Nn=Pt.texture}te.activeTexture.set(me.TEXTURE0),Nn.bind(P.stepInterpolant?me.NEAREST:me.LINEAR,me.CLAMP_TO_EDGE)}We.draw(te,me.TRIANGLES,F,b.stencilModeForClipping(xe),W,Cn.disabled,et,pt,P.id,Fe.layoutVertexBuffer,Fe.indexBuffer,Fe.segments,P.paint,b.transform.zoom,Ke,Fe.layoutVertexBuffer2),ge=!1}})(s,d,f,m);break;case"fill":(function(b,M,P,D){const L=P.paint.get("fill-color"),B=P.paint.get("fill-opacity");if(B.constantOr(1)===0)return;const F=b.colorModeForRenderPass(),W=P.paint.get("fill-pattern"),K=b.opaquePassEnabledForLayer()&&!W.constantOr(1)&&L.constantOr(l.aM.transparent).a===1&&B.constantOr(0)===1?"opaque":"translucent";if(b.renderPass===K){const Q=b.depthModeForSublayer(1,b.renderPass==="opaque"?Ht.ReadWrite:Ht.ReadOnly);Wl(b,M,P,D,Q,F,!1)}if(b.renderPass==="translucent"&&P.paint.get("fill-antialias")){const Q=b.depthModeForSublayer(P.getPaintProperty("fill-outline-color")?2:0,Ht.ReadOnly);Wl(b,M,P,D,Q,F,!0)}})(s,d,f,m);break;case"fill-extrusion":(function(b,M,P,D){const L=P.paint.get("fill-extrusion-opacity");if(L!==0&&b.renderPass==="translucent"){const B=new Ht(b.context.gl.LEQUAL,Ht.ReadWrite,b.depthRangeFor3D);if(L!==1||P.paint.get("fill-extrusion-pattern").constantOr(1))pu(b,M,P,D,B,Dn.disabled,Jn.disabled),pu(b,M,P,D,B,b.stencilModeFor3D(),b.colorModeForRenderPass());else{const F=b.colorModeForRenderPass();pu(b,M,P,D,B,Dn.disabled,F)}}})(s,d,f,m);break;case"hillshade":(function(b,M,P,D){if(b.renderPass!=="offscreen"&&b.renderPass!=="translucent")return;const L=b.context,B=b.depthModeForSublayer(0,Ht.ReadOnly),F=b.colorModeForRenderPass(),[W,K]=b.renderPass==="translucent"?b.stencilConfigForOverlap(D):[{},D];for(const Q of K){const re=M.getTile(Q);re.needsHillshadePrepare!==void 0&&re.needsHillshadePrepare&&b.renderPass==="offscreen"?Na(b,re,P,B,Dn.disabled,F):b.renderPass==="translucent"&&La(b,Q,re,P,B,W[Q.overscaledZ],F)}L.viewport.set([0,0,b.width,b.height])})(s,d,f,m);break;case"raster":(function(b,M,P,D){if(b.renderPass!=="translucent"||P.paint.get("raster-opacity")===0||!D.length)return;const L=b.context,B=L.gl,F=M.getSource(),W=b.useProgram("raster"),K=b.colorModeForRenderPass(),[Q,re]=F instanceof bi?[{},D]:b.stencilConfigForOverlap(D),le=re[re.length-1].overscaledZ,ce=!b.options.moving;for(const he of re){const te=b.depthModeForSublayer(he.overscaledZ-le,P.paint.get("raster-opacity")===1?Ht.ReadWrite:Ht.ReadOnly,B.LESS),me=M.getTile(he);me.registerFadeDuration(P.paint.get("raster-fade-duration"));const ge=M.findLoadedParent(he,0),xe=M.findLoadedSibling(he),Oe=hm(me,ge||xe||null,M,P,b.transform,b.style.map.terrain);let Fe,Ke;const nt=P.paint.get("raster-resampling")==="nearest"?B.NEAREST:B.LINEAR;L.activeTexture.set(B.TEXTURE0),me.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),L.activeTexture.set(B.TEXTURE1),ge?(ge.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),Fe=Math.pow(2,ge.tileID.overscaledZ-me.tileID.overscaledZ),Ke=[me.tileID.canonical.x*Fe%1,me.tileID.canonical.y*Fe%1]):me.texture.bind(nt,B.CLAMP_TO_EDGE,B.LINEAR_MIPMAP_NEAREST),me.texture.useMipmap&&L.extTextureFilterAnisotropic&&b.transform.pitch>20&&B.texParameterf(B.TEXTURE_2D,L.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,L.extTextureFilterAnisotropicMax);const We=b.style.map.terrain&&b.style.map.terrain.getTerrainData(he),He=We?he:null,pt=He?He.posMatrix:b.transform.calculatePosMatrix(he.toUnwrapped(),ce),Ot=Q0(pt,Ke||[0,0],Fe||1,Oe,P);F instanceof bi?W.draw(L,B.TRIANGLES,te,Dn.disabled,K,Cn.disabled,Ot,We,P.id,F.boundsBuffer,b.quadTriangleIndexBuffer,F.boundsSegments):W.draw(L,B.TRIANGLES,te,Q[he.overscaledZ],K,Cn.disabled,Ot,We,P.id,b.rasterBoundsBuffer,b.quadTriangleIndexBuffer,b.rasterBoundsSegments)}})(s,d,f,m);break;case"background":(function(b,M,P,D){const L=P.paint.get("background-color"),B=P.paint.get("background-opacity");if(B===0)return;const F=b.context,W=F.gl,K=b.transform,Q=K.tileSize,re=P.paint.get("background-pattern");if(b.isPatternMissing(re))return;const le=!re&&L.a===1&&B===1&&b.opaquePassEnabledForLayer()?"opaque":"translucent";if(b.renderPass!==le)return;const ce=Dn.disabled,he=b.depthModeForSublayer(0,le==="opaque"?Ht.ReadWrite:Ht.ReadOnly),te=b.colorModeForRenderPass(),me=b.useProgram(re?"backgroundPattern":"background"),ge=D||K.coveringTiles({tileSize:Q,terrain:b.style.map.terrain});re&&(F.activeTexture.set(W.TEXTURE0),b.imageManager.bind(b.context));const xe=P.getCrossfadeParameters();for(const Oe of ge){const Fe=D?Oe.posMatrix:b.transform.calculatePosMatrix(Oe.toUnwrapped()),Ke=re?td(Fe,B,b,re,{tileID:Oe,tileSize:Q},xe):au(Fe,B,L),nt=b.style.map.terrain&&b.style.map.terrain.getTerrainData(Oe);me.draw(F,W.TRIANGLES,he,ce,te,Cn.disabled,Ke,nt,P.id,b.tileExtentBuffer,b.quadTriangleIndexBuffer,b.tileExtentSegments)}})(s,0,f,m);break;case"custom":(function(b,M,P){const D=b.context,L=P.implementation;if(b.renderPass==="offscreen"){const B=L.prerender;B&&(b.setCustomLayerDefaults(),D.setColorMode(b.colorModeForRenderPass()),B.call(L,D.gl,b.transform.customLayerMatrix()),D.setDirty(),b.setBaseState())}else if(b.renderPass==="translucent"){b.setCustomLayerDefaults(),D.setColorMode(b.colorModeForRenderPass()),D.setStencilMode(Dn.disabled);const B=L.renderingMode==="3d"?new Ht(b.context.gl.LEQUAL,Ht.ReadWrite,b.depthRangeFor3D):b.depthModeForSublayer(0,Ht.ReadOnly);D.setDepthMode(B),L.render(D.gl,b.transform.customLayerMatrix(),{farZ:b.transform.farZ,nearZ:b.transform.nearZ,fov:b.transform._fov,modelViewProjectionMatrix:b.transform.modelViewProjectionMatrix,projectionMatrix:b.transform.projectionMatrix}),D.setDirty(),b.setBaseState(),D.bindFramebuffer.set(null)}})(s,0,f)}}translatePosMatrix(s,d,f,m,b){if(!f[0]&&!f[1])return s;const M=b?m==="map"?this.transform.angle:0:m==="viewport"?-this.transform.angle:0;if(M){const L=Math.sin(M),B=Math.cos(M);f=[f[0]*B-f[1]*L,f[0]*L+f[1]*B]}const P=[b?f[0]:Zt(d,f[0],this.transform.zoom),b?f[1]:Zt(d,f[1],this.transform.zoom),0],D=new Float32Array(16);return l.J(D,s,P),D}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()),f=this.imageManager.getPattern(s.to.toString());return!d||!f}useProgram(s,d){this.cache=this.cache||{};const f=s+(d?d.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[f]||(this.cache[f]=new Qh(this.context,uo[s],d,nd[s],this._showOverdrawInspector,this.style.map.terrain)),this.cache[f]}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 it(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 Fa{constructor(s,d){this.points=s,this.planes=d}static fromInvProjectionMatrix(s,d,f){const m=Math.pow(2,f),b=[[-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 D=1/(P=l.af([],P,s))[3]/d*m;return l.b1(P,P,[D,D,1/P[3],D])}),M=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(P=>{const D=function(W,K){var Q=K[0],re=K[1],le=K[2],ce=Q*Q+re*re+le*le;return ce>0&&(ce=1/Math.sqrt(ce)),W[0]=K[0]*ce,W[1]=K[1]*ce,W[2]=K[2]*ce,W}([],function(W,K,Q){var re=K[0],le=K[1],ce=K[2],he=Q[0],te=Q[1],me=Q[2];return W[0]=le*me-ce*te,W[1]=ce*he-re*me,W[2]=re*te-le*he,W}([],Me([],b[P[0]],b[P[1]]),Me([],b[P[2]],b[P[1]]))),L=-((B=D)[0]*(F=b[P[1]])[0]+B[1]*F[1]+B[2]*F[2]);var B,F;return D.concat(L)});return new Fa(b,M)}}class Va{constructor(s,d){this.min=s,this.max=d,this.center=function(f,m,b){return f[0]=.5*m[0],f[1]=.5*m[1],f[2]=.5*m[2],f}([],function(f,m,b){return f[0]=m[0]+b[0],f[1]=m[1]+b[1],f[2]=m[2]+b[2],f}([],this.min,this.max))}quadrant(s){const d=[s%2==0,s<2],f=Ae(this.min),m=Ae(this.max);for(let b=0;b<d.length;b++)f[b]=d[b]?this.min[b]:this.center[b],m[b]=d[b]?this.center[b]:this.max[b];return m[2]=this.max[2],new Va(f,m)}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 f=!0;for(let m=0;m<s.planes.length;m++){const b=s.planes[m];let M=0;for(let P=0;P<d.length;P++)l.b2(b,d[P])>=0&&M++;if(M===0)return 0;M!==d.length&&(f=!1)}if(f)return 2;for(let m=0;m<3;m++){let b=Number.MAX_VALUE,M=-Number.MAX_VALUE;for(let P=0;P<s.points.length;P++){const D=s.points[P][m]-this.min[m];b=Math.min(b,D),M=Math.max(M,D)}if(M<0||b>this.max[m]-this.min[m])return 0}return 1}}class $a{constructor(s=0,d=0,f=0,m=0){if(isNaN(s)||s<0||isNaN(d)||d<0||isNaN(f)||f<0||isNaN(m)||m<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=f,this.right=m}interpolate(s,d,f){return d.top!=null&&s.top!=null&&(this.top=l.y.number(s.top,d.top,f)),d.bottom!=null&&s.bottom!=null&&(this.bottom=l.y.number(s.bottom,d.bottom,f)),d.left!=null&&s.left!=null&&(this.left=l.y.number(s.left,d.left,f)),d.right!=null&&s.right!=null&&(this.right=l.y.number(s.right,d.right,f)),this}getCenter(s,d){const f=l.ac((this.left+s-this.right)/2,0,s),m=l.ac((this.top+d-this.bottom)/2,0,d);return new l.P(f,m)}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,f,m,b){this.tileSize=512,this._renderWorldCopies=b===void 0||!!b,this._minZoom=s||0,this._maxZoom=d||22,this._minPitch=f??0,this._maxPitch=m??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 f=new l.A(4);return l.A!=Float32Array&&(f[1]=0,f[2]=0),f[0]=1,f[3]=1,f}(),function(f,m,b){var M=m[0],P=m[1],D=m[2],L=m[3],B=Math.sin(b),F=Math.cos(b);f[0]=M*F+D*B,f[1]=P*F+L*B,f[2]=M*-B+D*F,f[3]=P*-B+L*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,f){this._unmodified=!1,this._edgeInsets.interpolate(s,d,f),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 f=this.pointCoordinate(new l.P(0,0)),m=this.pointCoordinate(new l.P(this.width,0)),b=this.pointCoordinate(new l.P(this.width,this.height)),M=this.pointCoordinate(new l.P(0,this.height)),P=Math.floor(Math.min(f.x,m.x,b.x,M.x)),D=Math.floor(Math.max(f.x,m.x,b.x,M.x)),L=1;for(let B=P-L;B<=D+L;B++)B!==0&&d.push(new l.b4(B,s))}return d}coveringTiles(s){var d,f;let m=this.coveringZoomLevel(s);const b=m;if(s.minzoom!==void 0&&m<s.minzoom)return[];s.maxzoom!==void 0&&m>s.maxzoom&&(m=s.maxzoom);const M=this.pointCoordinate(this.getCameraPoint()),P=l.Z.fromLngLat(this.center),D=Math.pow(2,m),L=[D*M.x,D*M.y,0],B=[D*P.x,D*P.y,0],F=Fa.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,m);let W=s.minzoom||0;!s.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(W=m);const K=s.terrain?2/Math.min(this.tileSize,s.tileSize)*this.tileSize:3,Q=te=>({aabb:new Va([te*D,0,0],[(te+1)*D,D,0]),zoom:0,x:0,y:0,wrap:te,fullyVisible:!1}),re=[],le=[],ce=m,he=s.reparseOverscaled?b:m;if(this._renderWorldCopies)for(let te=1;te<=3;te++)re.push(Q(-te)),re.push(Q(te));for(re.push(Q(0));re.length>0;){const te=re.pop(),me=te.x,ge=te.y;let xe=te.fullyVisible;if(!xe){const We=te.aabb.intersects(F);if(We===0)continue;xe=We===2}const Oe=s.terrain?L:B,Fe=te.aabb.distanceX(Oe),Ke=te.aabb.distanceY(Oe),nt=Math.max(Math.abs(Fe),Math.abs(Ke));if(te.zoom===ce||nt>K+(1<<ce-te.zoom)-2&&te.zoom>=W){const We=ce-te.zoom,He=L[0]-.5-(me<<We),pt=L[1]-.5-(ge<<We);le.push({tileID:new l.S(te.zoom===ce?he:te.zoom,te.wrap,te.zoom,me,ge),distanceSq:Le([B[0]-.5-me,B[1]-.5-ge]),tileDistanceToCamera:Math.sqrt(He*He+pt*pt)})}else for(let We=0;We<4;We++){const He=(me<<1)+We%2,pt=(ge<<1)+(We>>1),Ot=te.zoom+1;let Ge=te.aabb.quadrant(We);if(s.terrain){const et=new l.S(Ot,te.wrap,Ot,He,pt),Pt=s.terrain.getMinMaxElevation(et),Nn=(d=Pt.minElevation)!==null&&d!==void 0?d:this.elevation,Ft=(f=Pt.maxElevation)!==null&&f!==void 0?f:this.elevation;Ge=new Va([Ge.min[0],Ge.min[1],Nn],[Ge.max[0],Ge.max[1],Ft])}re.push({aabb:Ge,zoom:Ot,x:He,y:pt,wrap:te.wrap,fullyVisible:xe})}}return le.sort((te,me)=>te.distanceSq-me.distanceSq).map(te=>te.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,f=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,m=this.pointLocation(this.centerPoint,s),b=s.getElevationForLngLatZoom(m,this.tileZoom);if(!(this.elevation-b))return;const M=f+d-b,P=Math.cos(this._pitch)*this.cameraToCenterDistance/M/l.b5(1,m.lat),D=this.scaleZoom(P/this.tileSize);this._elevation=b,this._center=m,this.zoom=D}setLocationAtPoint(s,d){const f=this.pointCoordinate(d),m=this.pointCoordinate(this.centerPoint),b=this.locationCoordinate(s),M=new l.Z(b.x-(f.x-m.x),b.y-(f.y-m.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 f=[s.x,s.y,0,1],m=[s.x,s.y,1,1];l.af(f,f,this.pixelMatrixInverse),l.af(m,m,this.pixelMatrixInverse);const b=f[3],M=m[3],P=f[1]/b,D=m[1]/M,L=f[2]/b,B=m[2]/M,F=L===B?0:(0-L)/(B-L);return new l.Z(l.y.number(f[0]/b,m[0]/M,F)/this.worldSize,l.y.number(P,D,F)/this.worldSize)}coordinatePoint(s,d=0,f=this.pixelMatrix){const m=[s.x*this.worldSize,s.y*this.worldSize,d,1];return l.af(m,m,f),new l.P(m[0]/m[3],m[1]/m[3])}getBounds(){const s=Math.max(0,this.height/2-this.getHorizon());return new we().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 we([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,f=this.worldSize/this.zoomScale(d.z),m=d.x+Math.pow(2,d.z)*s.wrap,b=l.an(new Float64Array(16));return l.J(b,b,[m*f,d.y*f,0]),l.K(b,b,[f/l.X,f/l.X,1]),b}calculatePosMatrix(s,d=!1){const f=s.key,m=d?this._alignedPosMatrixCache:this._posMatrixCache;if(m[f])return m[f];const b=this.calculateTileMatrix(s);return l.L(b,d?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,b),m[f]=new Float32Array(b),m[f]}calculateFogMatrix(s){const d=s.key,f=this._fogMatrixCache;if(f[d])return f[d];const m=this.calculateTileMatrix(s);return l.L(m,this.fogMatrix,m),f[d]=new Float32Array(m),f[d]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(s,d){d=l.ac(+d,this.minZoom,this.maxZoom);const f={center:new l.N(s.lng,s.lat),zoom:d};let m=this.lngRange;if(!this._renderWorldCopies&&m===null){const te=179.9999999999;m=[-te,te]}const b=this.tileSize*this.zoomScale(f.zoom);let M=0,P=b,D=0,L=b,B=0,F=0;const{x:W,y:K}=this.size;if(this.latRange){const te=this.latRange;M=l.Q(te[1])*b,P=l.Q(te[0])*b,P-M<K&&(B=K/(P-M))}m&&(D=l.b3(l.O(m[0])*b,0,b),L=l.b3(l.O(m[1])*b,0,b),L<D&&(L+=b),L-D<W&&(F=W/(L-D)));const{x:Q,y:re}=this.project.call({worldSize:b},s);let le,ce;const he=Math.max(F||0,B||0);if(he){const te=new l.P(F?(L+D)/2:Q,B?(P+M)/2:re);return f.center=this.unproject.call({worldSize:b},te).wrap(),f.zoom+=this.scaleZoom(he),f}if(this.latRange){const te=K/2;re-te<M&&(ce=M+te),re+te>P&&(ce=P-te)}if(m){const te=(D+L)/2;let me=Q;this._renderWorldCopies&&(me=l.b3(Q,te-b/2,te+b/2));const ge=W/2;me-ge<D&&(le=D+ge),me+ge>L&&(le=L-ge)}if(le!==void 0||ce!==void 0){const te=new l.P(le??Q,ce??re);f.center=this.unproject.call({worldSize:b},te).wrap()}return f}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const s=this._unmodified,{center:d,zoom:f}=this.getConstrained(this.center,this.zoom);this.center=d,this.zoom=f,this._unmodified=s,this._constraining=!1}_calcMatrices(){if(!this.height)return;const s=this.centerOffset,d=this.point.x,f=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=l.b5(1,this.center.lat)*this.worldSize;let m=l.an(new Float64Array(16));l.K(m,m,[this.width/2,-this.height/2,1]),l.J(m,m,[1,-1,0]),this.labelPlaneMatrix=m,m=l.an(new Float64Array(16)),l.K(m,m,[1,-1,1]),l.J(m,m,[-1,-1,0]),l.K(m,m,[2/this.width,2/this.height,1]),this.glCoordMatrix=m;const b=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),M=Math.min(this.elevation,this.minElevationForCurrentTile),P=b-M*this._pixelPerMeter/Math.cos(this._pitch),D=M<0?P:b,L=Math.PI/2+this._pitch,B=this._fov*(.5+s.y/this.height),F=Math.sin(B)*D/Math.sin(l.ac(Math.PI-L-B,.01,Math.PI-.01)),W=this.getHorizon(),K=2*Math.atan(W/this.cameraToCenterDistance)*(.5+s.y/(2*W)),Q=Math.sin(K)*D/Math.sin(l.ac(Math.PI-L-K,.01,Math.PI-.01)),re=Math.min(F,Q);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*re+D),this.nearZ=this.height/50,m=new Float64Array(16),l.b6(m,this._fov,this.width/this.height,this.nearZ,this.farZ),m[8]=2*-s.x/this.width,m[9]=2*s.y/this.height,this.projectionMatrix=l.ae(m),l.K(m,m,[1,-1,1]),l.J(m,m,[0,0,-this.cameraToCenterDistance]),l.b7(m,m,this._pitch),l.ad(m,m,this.angle),l.J(m,m,[-d,-f,0]),this.mercatorMatrix=l.K([],m,[this.worldSize,this.worldSize,this.worldSize]),l.K(m,m,[1,1,this._pixelPerMeter]),this.pixelMatrix=l.L(new Float64Array(16),this.labelPlaneMatrix,m),l.J(m,m,[0,0,-this.elevation]),this.modelViewProjectionMatrix=m,this.invModelViewProjectionMatrix=l.as([],m),this.fogMatrix=new Float64Array(16),l.b6(this.fogMatrix,this._fov,this.width/this.height,b,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,-f,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,m);const le=this.width%2/2,ce=this.height%2/2,he=Math.cos(this.angle),te=Math.sin(this.angle),me=d-Math.round(d)+he*le+te*ce,ge=f-Math.round(f)+he*ce+te*le,xe=new Float64Array(m);if(l.J(xe,xe,[me>.5?me-1:me,ge>.5?ge-1:ge,0]),this.alignedModelViewProjectionMatrix=xe,m=l.as(new Float64Array(16),this.pixelMatrix),!m)throw new Error("failed to invert matrix");this.pixelMatrixInverse=m,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 f=d.x,m=d.y,b=d.x,M=d.y;for(const P of s)f=Math.min(f,P.x),m=Math.min(m,P.y),b=Math.max(b,P.x),M=Math.max(M,P.y);return[new l.P(f,m),new l.P(b,m),new l.P(b,M),new l.P(f,M),new l.P(f,m)]}}lngLatToCameraDepth(s,d){const f=this.locationCoordinate(s),m=[f.x*this.worldSize,f.y*this.worldSize,d,1];return l.af(m,m,this.modelViewProjectionMatrix),m[2]/m[3]}}function Gl(x,s){let d,f=!1,m=null,b=null;const M=()=>{m=null,f&&(x.apply(b,d),m=setTimeout(M,s),f=!1)};return(...P)=>(f=!0,b=this,d=P,m||M(),m)}class _u{constructor(s){this._getCurrentHash=()=>{const d=window.location.hash.replace("#","");if(this._hashName){let f;return d.split("&").map(m=>m.split("=")).forEach(m=>{m[0]===this._hashName&&(f=m)}),(f&&f[1]||"").split("/")}return d.split("/")},this._onHashChange=()=>{const d=this._getCurrentHash();if(d.length>=3&&!d.some(f=>isNaN(f))){const f=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:f,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 f=d.join("/");let m=f;m.split("&").length>0&&(m=m.split("&")[0]),this._hashName&&(m=`${this._hashName}=${f}`);let b=window.location.hash.replace(m,"");b.startsWith("#&")?b=b.slice(0,1)+b.slice(2):b==="#"&&(b="");let M=window.location.href.replace(/(#.+)?$/,b);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(),f=Math.round(100*this._map.getZoom())/100,m=Math.ceil((f*Math.LN2+Math.log(512/360/.5))/Math.LN10),b=Math.pow(10,m),M=Math.round(d.lng*b)/b,P=Math.round(d.lat*b)/b,D=this._map.getBearing(),L=this._map.getPitch();let B="";if(B+=s?`/${M}/${P}/${f}`:`${f}/${P}/${M}`,(D||L)&&(B+="/"+Math.round(10*D)/10),L&&(B+=`/${Math.round(L)}`),this._hashName){const F=this._hashName;let W=!1;const K=window.location.hash.slice(1).split("&").map(Q=>{const re=Q.split("=")[0];return re===F?(W=!0,`${re}=${B}`):Q}).filter(Q=>Q);return W||K.push(`${F}=${B}`),`#${K.join("&")}`}return`#${B}`}}const bu={linearity:.3,easing:l.b8(0,0,.3,1)},yd=l.e({deceleration:2500,maxSpeed:1400},bu),d_=l.e({deceleration:20,maxSpeed:1400},bu),gm=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:b}of this._inertiaBuffer)d.zoom+=b.zoomDelta||0,d.bearing+=b.bearingDelta||0,d.pitch+=b.pitchDelta||0,b.panDelta&&d.pan._add(b.panDelta),b.around&&(d.around=b.around),b.pinchAround&&(d.pinchAround=b.pinchAround);const f=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,m={};if(d.pan.mag()){const b=Yl(d.pan.mag(),f,l.e({},yd,s||{}));m.offset=d.pan.mult(b.amount/d.pan.mag()),m.center=this._map.transform.center,Zl(m,b)}if(d.zoom){const b=Yl(d.zoom,f,d_);m.zoom=this._map.transform.zoom+b.amount,Zl(m,b)}if(d.bearing){const b=Yl(d.bearing,f,gm);m.bearing=this._map.transform.bearing+l.ac(b.amount,-179,179),Zl(m,b)}if(d.pitch){const b=Yl(d.pitch,f,xu);m.pitch=this._map.transform.pitch+b.amount,Zl(m,b)}if(m.zoom||m.bearing){const b=d.pinchAround===void 0?d.around:d.pinchAround;m.around=b?this._map.unproject(b):this._map.getCenter()}return this.clear(),l.e(m,{noMoveStart:!0})}}function Zl(x,s){(!x.duration||x.duration<s.duration)&&(x.duration=s.duration,x.easing=s.easing)}function Yl(x,s,d){const{maxSpeed:f,linearity:m,deceleration:b}=d,M=l.ac(x*m/(s/1e3),-f,f),P=Math.abs(M)/(b*m);return{easing:d.easing,duration:1e3*P,amount:M*(P/2)}}class Pi extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f,m={}){const b=T.mousePos(d.getCanvas(),f),M=d.unproject(b);super(s,l.e({point:b,lngLat:M,originalEvent:f},m)),this._defaultPrevented=!1,this.target=d}}class Yo extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f){const m=s==="touchend"?f.changedTouches:f.touches,b=T.touchPos(d.getCanvasContainer(),m),M=b.map(D=>d.unproject(D)),P=b.reduce((D,L,B,F)=>D.add(L.div(F.length)),new l.P(0,0));super(s,{points:b,point:P,lngLats:M,lngLat:d.unproject(P),originalEvent:f}),this._defaultPrevented=!1}}class ym extends l.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(s,d,f){super(s,{originalEvent:f}),this._defaultPrevented=!1}}class _m{constructor(s,d){this._map=s,this._clickTolerance=d.clickTolerance}reset(){delete this._mousedownPos}wheel(s){return this._firePreventable(new ym(s.type,this._map,s))}mousedown(s,d){return this._mousedownPos=d,this._firePreventable(new Pi(s.type,this._map,s))}mouseup(s){this._map.fire(new Pi(s.type,this._map,s))}click(s,d){this._mousedownPos&&this._mousedownPos.dist(d)>=this._clickTolerance||this._map.fire(new Pi(s.type,this._map,s))}dblclick(s){return this._firePreventable(new Pi(s.type,this._map,s))}mouseover(s){this._map.fire(new Pi(s.type,this._map,s))}mouseout(s){this._map.fire(new Pi(s.type,this._map,s))}touchstart(s){return this._firePreventable(new Yo(s.type,this._map,s))}touchmove(s){this._map.fire(new Yo(s.type,this._map,s))}touchend(s){this._map.fire(new Yo(s.type,this._map,s))}touchcancel(s){this._map.fire(new Yo(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 Pi(s.type,this._map,s))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Pi("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(s){this._delayContextMenu?this._contextMenuEvent=s:this._ignoreContextMenu||this._map.fire(new Pi(s.type,this._map,s)),this._map.listens("contextmenu")&&s.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class es{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 yr{constructor(s,d){this._map=s,this._tr=new es(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&&(T.disableDrag(),this._startPos=this._lastPos=d,this._active=!0)}mousemoveWindow(s,d){if(!this._active)return;const f=d;if(this._lastPos.equals(f)||!this._box&&f.dist(this._startPos)<this._clickTolerance)return;const m=this._startPos;this._lastPos=f,this._box||(this._box=T.create("div","maplibregl-boxzoom",this._container),this._container.classList.add("maplibregl-crosshair"),this._fireEvent("boxzoomstart",s));const b=Math.min(m.x,f.x),M=Math.max(m.x,f.x),P=Math.min(m.y,f.y),D=Math.max(m.y,f.y);T.setTransform(this._box,`translate(${b}px,${P}px)`),this._box.style.width=M-b+"px",this._box.style.height=D-P+"px"}mouseupWindow(s,d){if(!this._active||s.button!==0)return;const f=this._startPos,m=d;if(this.reset(),T.suppressClick(),f.x!==m.x||f.y!==m.y)return this._map.fire(new l.k("boxzoomend",{originalEvent:s})),{cameraAnimation:b=>b.fitScreenCoordinates(f,m,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&&(T.remove(this._box),this._box=null),T.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(s,d){return this._map.fire(new l.k(s,{originalEvent:d}))}}function Xl(x,s){if(x.length!==s.length)throw new Error(`The number of touches and points are not equal - touches ${x.length}, points ${s.length}`);const d={};for(let f=0;f<x.length;f++)d[x[f].identifier]=s[f];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,f){(this.centroid||f.length>this.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=s.timeStamp),f.length===this.numTouches&&(this.centroid=function(m){const b=new l.P(0,0);for(const M of m)b._add(M);return b.div(m.length)}(d),this.touches=Xl(f,d)))}touchmove(s,d,f){if(this.aborted||!this.centroid)return;const m=Xl(f,d);for(const b in this.touches){const M=m[b];(!M||M.dist(this.touches[b])>30)&&(this.aborted=!0)}}touchend(s,d,f){if((!this.centroid||s.timeStamp-this.startTime>500)&&(this.aborted=!0),f.length===0){const m=!this.aborted&&this.centroid;if(this.reset(),m)return m}}}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,f){this.singleTap.touchstart(s,d,f)}touchmove(s,d,f){this.singleTap.touchmove(s,d,f)}touchend(s,d,f){const m=this.singleTap.touchend(s,d,f);if(m){const b=s.timeStamp-this.lastTime<500,M=!this.lastTap||this.lastTap.dist(m)<30;if(b&&M||this.reset(),this.count++,this.lastTime=s.timeStamp,this.lastTap=m,this.count===this.numTaps)return this.reset(),m}}}class Ua{constructor(s){this._tr=new es(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,f){this._zoomIn.touchstart(s,d,f),this._zoomOut.touchstart(s,d,f)}touchmove(s,d,f){this._zoomIn.touchmove(s,d,f),this._zoomOut.touchmove(s,d,f)}touchend(s,d,f){const m=this._zoomIn.touchend(s,d,f),b=this._zoomOut.touchend(s,d,f),M=this._tr;return m?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom+1,around:M.unproject(m)},{originalEvent:s})}):b?(this._active=!0,s.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:P=>P.easeTo({duration:300,zoom:M.zoom-1,around:M.unproject(b)},{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 f=this._lastPoint;if(!f)return;if(s.preventDefault(),!this._moveStateManager.isValidMoveEvent(s))return void this.reset(s);const m=d.length?d[0]:d;return!this._moved&&m.dist(f)<this._clickTolerance?void 0:(this._moved=!0,this._lastPoint=m,this._move(f,m))}dragEnd(s){this.isEnabled()&&this._lastPoint&&this._moveStateManager.isValidEndEvent(s)&&(this._moved&&T.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=T.mouseButton(s);this._eventButton=d}endMove(s){delete this._eventButton}isValidStartEvent(s){return this._correctEvent(s)}isValidMoveEvent(s){return!function(d,f){const m=xd[f];return d.buttons===void 0||(d.buttons&m)!==m}(s,this._eventButton)}isValidEndEvent(s){return T.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=x=>{x.mousedown=x.dragStart,x.mousemoveWindow=x.dragMove,x.mouseup=x.dragEnd,x.contextmenu=s=>{s.preventDefault()}},wd=({enable:x,clickTolerance:s,bearingDegreesPerPixelMoved:d=.8})=>{const f=new wu({checkCorrectEvent:m=>T.mouseButton(m)===0&&m.ctrlKey||T.mouseButton(m)===2});return new qs({clickTolerance:s,move:(m,b)=>({bearingDelta:(b.x-m.x)*d}),moveStateManager:f,enable:x,assignEvents:ku})},kd=({enable:x,clickTolerance:s,pitchDegreesPerPixelMoved:d=-.5})=>{const f=new wu({checkCorrectEvent:m=>T.mouseButton(m)===0&&m.ctrlKey||T.mouseButton(m)===2});return new qs({clickTolerance:s,move:(m,b)=>({pitchDelta:(b.y-m.y)*d}),moveStateManager:f,enable:x,assignEvents:ku})};class Xo{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,f){return this._calculateTransform(s,d,f)}touchmove(s,d,f){if(this._active){if(!this._shouldBePrevented(f.length))return s.preventDefault(),this._calculateTransform(s,d,f);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",s)}}touchend(s,d,f){this._calculateTransform(s,d,f),this._active&&this._shouldBePrevented(f.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(s,d,f){f.length>0&&(this._active=!0);const m=Xl(f,d),b=new l.P(0,0),M=new l.P(0,0);let P=0;for(const L in m){const B=m[L],F=this._touches[L];F&&(b._add(B),M._add(B.sub(F)),P++,m[L]=B)}if(this._touches=m,this._shouldBePrevented(P)||!M.mag())return;const D=M.div(P);return this._sum._add(D),this._sum.mag()<this._clickTolerance?void 0:{around:b.div(P),panDelta:D}}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,f){this._firstTwoTouches||f.length<2||(this._firstTwoTouches=[f[0].identifier,f[1].identifier],this._start([d[0],d[1]]))}touchmove(s,d,f){if(!this._firstTwoTouches)return;s.preventDefault();const[m,b]=this._firstTwoTouches,M=Kl(f,d,m),P=Kl(f,d,b);if(!M||!P)return;const D=this._aroundCenter?null:M.add(P).div(2);return this._move([M,P],D,s)}touchend(s,d,f){if(!this._firstTwoTouches)return;const[m,b]=this._firstTwoTouches,M=Kl(f,d,m),P=Kl(f,d,b);M&&P||(this._active&&T.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(x,s,d){for(let f=0;f<x.length;f++)if(x[f].identifier===d)return s[f]}function Sd(x,s){return Math.log(x/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 f=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,f),pinchAround:d}}}function Cd(x,s){return 180*x.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,f){const m=this._vector;if(this._vector=s[0].sub(s[1]),this._active||!this._isBelowThreshold(this._vector))return this._active=!0,{bearingDelta:Cd(this._vector,m),pinchAround:d}}_isBelowThreshold(s){this._minDiameter=Math.min(this._minDiameter,s.mag());const d=25/(Math.PI*this._minDiameter)*360,f=Cd(s,this._startVector);return Math.abs(f)<d}}function Eu(x){return Math.abs(x.y)>Math.abs(x.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,f){super.touchstart(s,d,f),this._currentTouchCount=f.length}_start(s){this._lastPoints=s,Eu(s[0].sub(s[1]))&&(this._valid=!1)}_move(s,d,f){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const m=s[0].sub(this._lastPoints[0]),b=s[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(m,b,f.timeStamp),this._valid?(this._lastPoints=s,this._active=!0,{pitchDelta:(m.y+b.y)/2*-.5}):void 0}gestureBeginsVertically(s,d,f){if(this._valid!==void 0)return this._valid;const m=s.mag()>=2,b=d.mag()>=2;if(!m&&!b)return;if(!m||!b)return this._firstMove===void 0&&(this._firstMove=f),f-this._firstMove<100&&void 0;const M=s.y>0==d.y>0;return Eu(s)&&Eu(d)&&M}}const bm={panStep:100,bearingStep:15,pitchStep:10};class Nr{constructor(s){this._tr=new es(s);const d=bm;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,f=0,m=0,b=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?f=-1:(s.preventDefault(),b=-1);break;case 39:s.shiftKey?f=1:(s.preventDefault(),b=1);break;case 38:s.shiftKey?m=1:(s.preventDefault(),M=-1);break;case 40:s.shiftKey?m=-1:(s.preventDefault(),M=1);break;default:return}return this._rotationDisabled&&(f=0,m=0),{cameraAnimation:P=>{const D=this._tr;P.easeTo({duration:300,easeId:"keyboardHandler",easing:As,zoom:d?Math.round(D.zoom)+d*(s.shiftKey?2:1):D.zoom,bearing:D.bearing+f*this._bearingStep,pitch:D.pitch+m*this._pitchStep,offset:[-b*this._panStep,-M*this._panStep],center:D.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(x){return x*(2-x)}const Md=4.000244140625;class ts{constructor(s,d){this._onTimeout=f=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(f)},this._map=s,this._tr=new es(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 f=E.now(),m=f-(this._lastWheelEventTime||0);this._lastWheelEventTime=f,d!==0&&d%Md==0?this._type="wheel":d!==0&&Math.abs(d)<4?this._type="trackpad":m>400?(this._type=null,this._lastValue=d,this._timeout=setTimeout(this._onTimeout,40,s)):this._type||(this._type=Math.abs(m*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=T.mousePos(this._map.getCanvas(),s),f=this._tr;this._around=d.y>f.transform.height/2-f.transform.getHorizon()?l.N.convert(this._aroundCenter?f.center:f.unproject(d)):l.N.convert(f.center),this._aroundPoint=f.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 D=this._type==="wheel"&&Math.abs(this._delta)>Md?this._wheelZoomRate:this._defaultZoomRate;let L=2/(1+Math.exp(-Math.abs(this._delta*D)));this._delta<0&&L!==0&&(L=1/L);const B=typeof this._targetZoom=="number"?s.zoomScale(this._targetZoom):s.scale;this._targetZoom=Math.min(s.maxZoom,Math.max(s.minZoom,s.scaleZoom(B*L))),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,f=this._startZoom,m=this._easing;let b,M=!1;const P=E.now()-this._lastWheelEventTime;if(this._type==="wheel"&&f&&m&&P){const D=Math.min(P/200,1),L=m(D);b=l.y.number(f,d,L),D<1?this._frameId||(this._frameId=!0):M=!0}else b=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:b-s.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(s){let d=l.b9;if(this._prevEase){const f=this._prevEase,m=(E.now()-f.start)/f.duration,b=f.easing(m+.01)-f.easing(m),M=.27/Math.sqrt(b*b+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 Ko{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 p_{constructor(s){this._tr=new es(s),this.reset()}reset(){this._active=!1}dblclick(s,d){return s.preventDefault(),{cameraAnimation:f=>{f.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 f_{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,f){if(!this._swipePoint)if(this._tapTime){const m=d[0],b=s.timeStamp-this._tapTime<500,M=this._tapPoint.dist(m)<30;b&&M?f.length>0&&(this._swipePoint=m,this._swipeTouch=f[0].identifier):this.reset()}else this._tap.touchstart(s,d,f)}touchmove(s,d,f){if(this._tapTime){if(this._swipePoint){if(f[0].identifier!==this._swipeTouch)return;const m=d[0],b=m.y-this._swipePoint.y;return this._swipePoint=m,s.preventDefault(),this._active=!0,{zoomDelta:b/128}}}else this._tap.touchmove(s,d,f)}touchend(s,d,f){if(this._tapTime)this._swipePoint&&f.length===0&&this.reset();else{const m=this._tap.touchend(s,d,f);m&&(this._tapTime=s.timeStamp,this._tapPoint=m)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class xm{constructor(s,d,f){this._el=s,this._mousePan=d,this._touchPan=f}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 vm{constructor(s,d,f){this._pitchWithRotate=s.pitchWithRotate,this._mouseRotate=d,this._mousePitch=f}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,f,m){this._el=s,this._touchZoom=d,this._touchRotate=f,this._tapDragZoom=m,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=T.create("div","maplibregl-cooperative-gesture-screen",s);let d=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(d=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const f=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),m=document.createElement("div");m.className="maplibregl-desktop-message",m.textContent=d,this._container.appendChild(m);const b=document.createElement("div");b.className="maplibregl-mobile-message",b.textContent=f,this._container.appendChild(b),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(T.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 Br=x=>x.zoom||x.drag||x.pitch||x.rotate;class ot extends l.k{}function Cu(x){return x.panDelta&&x.panDelta.mag()||x.zoomDelta||x.bearingDelta||x.pitchDelta}class Pd{constructor(s,d){this.handleWindowEvent=m=>{this.handleEvent(m,`${m.type}Window`)},this.handleEvent=(m,b)=>{if(m.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const M=m.type==="renderFrame"?void 0:m,P={needsRenderFrame:!1},D={},L={},B=m.touches,F=B?this._getMapTouches(B):void 0,W=F?T.touchPos(this._map.getCanvas(),F):T.mousePos(this._map.getCanvas(),m);for(const{handlerName:re,handler:le,allowed:ce}of this._handlers){if(!le.isEnabled())continue;let he;this._blockedByActive(L,ce,re)?le.reset():le[b||m.type]&&(he=le[b||m.type](m,W,F),this.mergeHandlerResult(P,D,he,re,M),he&&he.needsRenderFrame&&this._triggerRenderFrame()),(he||le.isActive())&&(L[re]=le)}const K={};for(const re in this._previousActiveHandlers)L[re]||(K[re]=M);this._previousActiveHandlers=L,(Object.keys(K).length||Cu(P))&&(this._changes.push([P,D,K]),this._triggerRenderFrame()),(Object.keys(L).length||Cu(P))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:Q}=P;Q&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],Q(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 f=this._el;this._listeners=[[f,"touchstart",{passive:!0}],[f,"touchmove",{passive:!1}],[f,"touchend",void 0],[f,"touchcancel",void 0],[f,"mousedown",void 0],[f,"mousemove",void 0],[f,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[f,"mouseover",void 0],[f,"mouseout",void 0],[f,"dblclick",void 0],[f,"click",void 0],[f,"keydown",{capture:!1}],[f,"keyup",void 0],[f,"wheel",{passive:!1}],[f,"contextmenu",void 0],[window,"blur",void 0]];for(const[m,b,M]of this._listeners)T.addEventListener(m,b,m===document?this.handleWindowEvent:this.handleEvent,M)}destroy(){for(const[s,d,f]of this._listeners)T.removeEventListener(s,d,s===document?this.handleWindowEvent:this.handleEvent,f)}_addDefaultHandlers(s){const d=this._map,f=d.getCanvasContainer();this._add("mapEvent",new _m(d,s));const m=d.boxZoom=new yr(d,s);this._add("boxZoom",m),s.interactive&&s.boxZoom&&m.enable();const b=d.cooperativeGestures=new qa(d,s.cooperativeGestures);this._add("cooperativeGestures",b),s.cooperativeGestures&&b.enable();const M=new Ua(d),P=new p_(d);d.doubleClickZoom=new Ko(P,M),this._add("tapZoom",M),this._add("clickZoom",P),s.interactive&&s.doubleClickZoom&&d.doubleClickZoom.enable();const D=new f_;this._add("tapDragZoom",D);const L=d.touchPitch=new Ha(d);this._add("touchPitch",L),s.interactive&&s.touchPitch&&d.touchPitch.enable(s.touchPitch);const B=wd(s),F=kd(s);d.dragRotate=new vm(s,B,F),this._add("mouseRotate",B,["mousePitch"]),this._add("mousePitch",F,["mouseRotate"]),s.interactive&&s.dragRotate&&d.dragRotate.enable();const W=(({enable:he,clickTolerance:te})=>{const me=new wu({checkCorrectEvent:ge=>T.mouseButton(ge)===0&&!ge.ctrlKey});return new qs({clickTolerance:te,move:(ge,xe)=>({around:xe,panDelta:xe.sub(ge)}),activateOnStart:!0,moveStateManager:me,enable:he,assignEvents:ku})})(s),K=new Xo(s,d);d.dragPan=new xm(f,W,K),this._add("mousePan",W),this._add("touchPan",K,["touchZoom","touchRotate"]),s.interactive&&s.dragPan&&d.dragPan.enable(s.dragPan);const Q=new Td,re=new Ed;d.touchZoomRotate=new Ad(f,re,Q,D),this._add("touchRotate",Q,["touchPan","touchZoom"]),this._add("touchZoom",re,["touchPan","touchRotate"]),s.interactive&&s.touchZoomRotate&&d.touchZoomRotate.enable(s.touchZoomRotate);const le=d.scrollZoom=new ts(d,()=>this._triggerRenderFrame());this._add("scrollZoom",le,["mousePan"]),s.interactive&&s.scrollZoom&&d.scrollZoom.enable(s.scrollZoom);const ce=d.keyboard=new Nr(d);this._add("keyboard",ce),s.interactive&&s.keyboard&&d.keyboard.enable(),this._add("blockableMapEvent",new Qn(d))}_add(s,d,f){this._handlers.push({handlerName:s,handler:d,allowed:f}),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!!Br(this._eventsInProgress)||this.isZooming()}_blockedByActive(s,d,f){for(const m in s)if(m!==f&&(!d||d.indexOf(m)<0))return!0;return!1}_getMapTouches(s){const d=[];for(const f of s)this._el.contains(f.target)&&d.push(f);return d}mergeHandlerResult(s,d,f,m,b){if(!f)return;l.e(s,f);const M={handlerName:m,originalEvent:f.originalEvent||b};f.zoomDelta!==void 0&&(d.zoom=M),f.panDelta!==void 0&&(d.drag=M),f.pitchDelta!==void 0&&(d.pitch=M),f.bearingDelta!==void 0&&(d.rotate=M)}_applyChanges(){const s={},d={},f={};for(const[m,b,M]of this._changes)m.panDelta&&(s.panDelta=(s.panDelta||new l.P(0,0))._add(m.panDelta)),m.zoomDelta&&(s.zoomDelta=(s.zoomDelta||0)+m.zoomDelta),m.bearingDelta&&(s.bearingDelta=(s.bearingDelta||0)+m.bearingDelta),m.pitchDelta&&(s.pitchDelta=(s.pitchDelta||0)+m.pitchDelta),m.around!==void 0&&(s.around=m.around),m.pinchAround!==void 0&&(s.pinchAround=m.pinchAround),m.noInertia&&(s.noInertia=m.noInertia),l.e(d,b),l.e(f,M);this._updateMapTransform(s,d,f),this._changes=[]}_updateMapTransform(s,d,f){const m=this._map,b=m._getTransformForUpdate(),M=m.terrain;if(!(Cu(s)||M&&this._terrainMovement))return this._fireEvents(d,f,!0);let{panDelta:P,zoomDelta:D,bearingDelta:L,pitchDelta:B,around:F,pinchAround:W}=s;W!==void 0&&(F=W),m._stop(!0),F=F||m.transform.centerPoint;const K=b.pointLocation(P?F.sub(P):F);L&&(b.bearing+=L),B&&(b.pitch+=B),D&&(b.zoom+=D),M?this._terrainMovement||!d.drag&&!d.zoom?d.drag&&this._terrainMovement?b.center=b.pointLocation(b.centerPoint.sub(P)):b.setLocationAtPoint(K,F):(this._terrainMovement=!0,this._map._elevationFreeze=!0,b.setLocationAtPoint(K,F)):b.setLocationAtPoint(K,F),m._applyUpdatedTransform(b),this._map._update(),s.noInertia||this._inertia.record(s),this._fireEvents(d,f,!0)}_fireEvents(s,d,f){const m=Br(this._eventsInProgress),b=Br(s),M={};for(const F in s){const{originalEvent:W}=s[F];this._eventsInProgress[F]||(M[`${F}start`]=W),this._eventsInProgress[F]=s[F]}!m&&b&&this._fireEvent("movestart",b.originalEvent);for(const F in M)this._fireEvent(F,M[F]);b&&this._fireEvent("move",b.originalEvent);for(const F in s){const{originalEvent:W}=s[F];this._fireEvent(F,W)}const P={};let D;for(const F in this._eventsInProgress){const{handlerName:W,originalEvent:K}=this._eventsInProgress[F];this._handlersById[W].isActive()||(delete this._eventsInProgress[F],D=d[W]||K,P[`${F}end`]=D)}for(const F in P)this._fireEvent(F,P[F]);const L=Br(this._eventsInProgress),B=(m||b)&&!L;if(B&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const F=this._map._getTransformForUpdate();F.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(F)}if(f&&B){this._updatingCamera=!0;const F=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),W=K=>K!==0&&-this._bearingSnap<K&&K<this._bearingSnap;!F||!F.essential&&E.prefersReducedMotion?(this._map.fire(new l.k("moveend",{originalEvent:D})),W(this._map.getBearing())&&this._map.resetNorth()):(W(F.bearing||this._map.getBearing())&&(F.bearing=0),F.freezeElevation=!0,this._map.easeTo(F,{originalEvent:D})),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 ot("renderFrame",{timeStamp:s})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class wm extends l.E{constructor(s,d){super(),this._renderFrameCallback=()=>{const f=Math.min((E.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(f)),f<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,f){return s=l.P.convert(s).mult(-1),this.panTo(this.transform.center,l.e({offset:s},d),f)}panTo(s,d,f){return this.easeTo(l.e({center:s},d),f)}getZoom(){return this.transform.zoom}setZoom(s,d){return this.jumpTo({zoom:s},d),this}zoomTo(s,d,f){return this.easeTo(l.e({zoom:s},d),f)}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,f){return this.easeTo(l.e({bearing:s},d),f)}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=we.convert(s).adjustAntiMeridian();const f=d&&d.bearing||0;return this._cameraForBoxAndBearing(s.getNorthWest(),s.getSouthEast(),f,d)}_cameraForBoxAndBearing(s,d,f,m){const b={top:0,bottom:0,right:0,left:0};if(typeof(m=l.e({padding:b,offset:[0,0],maxZoom:this.transform.maxZoom},m)).padding=="number"){const We=m.padding;m.padding={top:We,bottom:We,right:We,left:We}}m.padding=l.e(b,m.padding);const M=this.transform,P=M.padding,D=new we(s,d),L=M.project(D.getNorthWest()),B=M.project(D.getNorthEast()),F=M.project(D.getSouthEast()),W=M.project(D.getSouthWest()),K=l.ba(-f),Q=L.rotate(K),re=B.rotate(K),le=F.rotate(K),ce=W.rotate(K),he=new l.P(Math.max(Q.x,re.x,ce.x,le.x),Math.max(Q.y,re.y,ce.y,le.y)),te=new l.P(Math.min(Q.x,re.x,ce.x,le.x),Math.min(Q.y,re.y,ce.y,le.y)),me=he.sub(te),ge=(M.width-(P.left+P.right+m.padding.left+m.padding.right))/me.x,xe=(M.height-(P.top+P.bottom+m.padding.top+m.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 Oe=Math.min(M.scaleZoom(M.scale*Math.min(ge,xe)),m.maxZoom),Fe=l.P.convert(m.offset),Ke=new l.P((m.padding.left-m.padding.right)/2,(m.padding.top-m.padding.bottom)/2).rotate(l.ba(f)),nt=Fe.add(Ke).mult(M.scale/M.zoomScale(Oe));return{center:M.unproject(L.add(F).div(2).sub(nt)),zoom:Oe,bearing:f}}fitBounds(s,d,f){return this._fitInternal(this.cameraForBounds(s,d),d,f)}fitScreenCoordinates(s,d,f,m,b){return this._fitInternal(this._cameraForBoxAndBearing(this.transform.pointLocation(l.P.convert(s)),this.transform.pointLocation(l.P.convert(d)),f,m),m,b)}_fitInternal(s,d,f){return s?(delete(d=l.e(s,d)).padding,d.linear?this.easeTo(d,f):this.flyTo(d,f)):this}jumpTo(s,d){this.stop();const f=this._getTransformForUpdate();let m=!1,b=!1,M=!1;return"zoom"in s&&f.zoom!==+s.zoom&&(m=!0,f.zoom=+s.zoom),s.center!==void 0&&(f.center=l.N.convert(s.center)),"bearing"in s&&f.bearing!==+s.bearing&&(b=!0,f.bearing=+s.bearing),"pitch"in s&&f.pitch!==+s.pitch&&(M=!0,f.pitch=+s.pitch),s.padding==null||f.isPaddingEqual(s.padding)||(f.padding=s.padding),this._applyUpdatedTransform(f),this.fire(new l.k("movestart",d)).fire(new l.k("move",d)),m&&this.fire(new l.k("zoomstart",d)).fire(new l.k("zoom",d)).fire(new l.k("zoomend",d)),b&&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,f,m=0){const b=l.Z.fromLngLat(s,d),M=l.Z.fromLngLat(f,m),P=M.x-b.x,D=M.y-b.y,L=M.z-b.z,B=Math.hypot(P,D,L);if(B===0)throw new Error("Can't calculate camera options with same From and To");const F=Math.hypot(P,D),W=this.transform.scaleZoom(this.transform.cameraToCenterDistance/B/this.transform.tileSize),K=180*Math.atan2(P,-D)/Math.PI;let Q=180*Math.acos(F/B)/Math.PI;return Q=L<0?90-Q:90+Q,{center:M.toLngLat(),zoom:W,pitch:Q,bearing:K}}easeTo(s,d){var f;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 m=this._getTransformForUpdate(),b=m.zoom,M=m.bearing,P=m.pitch,D=m.padding,L="bearing"in s?this._normalizeBearing(s.bearing,M):M,B="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:m.padding,W=l.P.convert(s.offset);let K=m.centerPoint.add(W);const Q=m.pointLocation(K),{center:re,zoom:le}=m.getConstrained(l.N.convert(s.center||Q),(f=s.zoom)!==null&&f!==void 0?f:b);this._normalizeCenter(re,m);const ce=m.project(Q),he=m.project(re).sub(ce),te=m.zoomScale(le-b);let me,ge;s.around&&(me=l.N.convert(s.around),ge=m.locationPoint(me));const xe={moving:this._moving,zooming:this._zooming,rotating:this._rotating,pitching:this._pitching};return this._zooming=this._zooming||le!==b,this._rotating=this._rotating||M!==L,this._pitching=this._pitching||B!==P,this._padding=!m.isPaddingEqual(F),this._easeId=s.easeId,this._prepareEase(d,s.noMoveStart,xe),this.terrain&&this._prepareElevation(re),this._ease(Oe=>{if(this._zooming&&(m.zoom=l.y.number(b,le,Oe)),this._rotating&&(m.bearing=l.y.number(M,L,Oe)),this._pitching&&(m.pitch=l.y.number(P,B,Oe)),this._padding&&(m.interpolatePadding(D,F,Oe),K=m.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(Oe),me)m.setLocationAtPoint(me,ge);else{const Fe=m.zoomScale(m.zoom-b),Ke=le>b?Math.min(2,te):Math.max(.5,te),nt=Math.pow(Ke,1-Oe),We=m.unproject(ce.add(he.mult(Oe*nt)).mult(Fe));m.setLocationAtPoint(m.renderWorldCopies?We.wrap():We,K)}this._applyUpdatedTransform(m),this._fireMoveEvents(d)},Oe=>{this.terrain&&s.freezeElevation&&this._finalizeElevation(),this._afterEase(d,Oe)},s),this}_prepareEase(s,d,f={}){this._moving=!0,d||f.moving||this.fire(new l.k("movestart",s)),this._zooming&&!f.zooming&&this.fire(new l.k("zoomstart",s)),this._rotating&&!f.rotating&&this.fire(new l.k("rotatestart",s)),this._pitching&&!f.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 f=this._elevationTarget-this._elevationStart;this._elevationStart+=s*(f-(d-(f*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(),f=this.terrain.getElevationForLngLatZoom(d.lngLat,s.zoom);if(d.altitude<f){const m=this.calculateCameraOptionsFromTo(d.lngLat,f,s.center,s.elevation);return{pitch:m.pitch,zoom:m.zoom}}return{}}_applyUpdatedTransform(s){const d=[];if(this.terrain&&d.push(m=>this._elevateCameraIfInsideTerrain(m)),this.transformCameraUpdate&&d.push(m=>this.transformCameraUpdate(m)),!d.length)return;const f=s.clone();for(const m of d){const b=f.clone(),{center:M,zoom:P,pitch:D,bearing:L,elevation:B}=m(b);M&&(b.center=M),P!==void 0&&(b.zoom=P),D!==void 0&&(b.pitch=D),L!==void 0&&(b.bearing=L),B!==void 0&&(b.elevation=B),f.apply(b)}this.transform.apply(f)}_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 f=this._zooming,m=this._rotating,b=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,f&&this.fire(new l.k("zoomend",s)),m&&this.fire(new l.k("rotateend",s)),b&&this.fire(new l.k("pitchend",s)),this.fire(new l.k("moveend",s))}flyTo(s,d){var f;if(!s.essential&&E.prefersReducedMotion){const et=l.M(s,["center","zoom","bearing","pitch","around"]);return this.jumpTo(et,d)}this.stop(),s=l.e({offset:[0,0],speed:1.2,curve:1.42,easing:l.b9},s);const m=this._getTransformForUpdate(),b=m.zoom,M=m.bearing,P=m.pitch,D=m.padding,L="bearing"in s?this._normalizeBearing(s.bearing,M):M,B="pitch"in s?+s.pitch:P,F="padding"in s?s.padding:m.padding,W=l.P.convert(s.offset);let K=m.centerPoint.add(W);const Q=m.pointLocation(K),{center:re,zoom:le}=m.getConstrained(l.N.convert(s.center||Q),(f=s.zoom)!==null&&f!==void 0?f:b);this._normalizeCenter(re,m);const ce=m.zoomScale(le-b),he=m.project(Q),te=m.project(re).sub(he);let me=s.curve;const ge=Math.max(m.width,m.height),xe=ge/ce,Oe=te.mag();if("minZoom"in s){const et=l.ac(Math.min(s.minZoom,b,le),m.minZoom,m.maxZoom),Pt=ge/m.zoomScale(et-b);me=Math.sqrt(Pt/Oe*2)}const Fe=me*me;function Ke(et){const Pt=(xe*xe-ge*ge+(et?-1:1)*Fe*Fe*Oe*Oe)/(2*(et?xe:ge)*Fe*Oe);return Math.log(Math.sqrt(Pt*Pt+1)-Pt)}function nt(et){return(Math.exp(et)-Math.exp(-et))/2}function We(et){return(Math.exp(et)+Math.exp(-et))/2}const He=Ke(!1);let pt=function(et){return We(He)/We(He+me*et)},Ot=function(et){return ge*((We(He)*(nt(Pt=He+me*et)/We(Pt))-nt(He))/Fe)/Oe;var Pt},Ge=(Ke(!0)-He)/me;if(Math.abs(Oe)<1e-6||!isFinite(Ge)){if(Math.abs(ge-xe)<1e-6)return this.easeTo(s,d);const et=xe<ge?-1:1;Ge=Math.abs(Math.log(xe/ge))/me,Ot=()=>0,pt=Pt=>Math.exp(et*me*Pt)}return s.duration="duration"in s?+s.duration:1e3*Ge/("screenSpeed"in s?+s.screenSpeed/me:+s.speed),s.maxDuration&&s.duration>s.maxDuration&&(s.duration=0),this._zooming=!0,this._rotating=M!==L,this._pitching=B!==P,this._padding=!m.isPaddingEqual(F),this._prepareEase(d,!1),this.terrain&&this._prepareElevation(re),this._ease(et=>{const Pt=et*Ge,Nn=1/pt(Pt);m.zoom=et===1?le:b+m.scaleZoom(Nn),this._rotating&&(m.bearing=l.y.number(M,L,et)),this._pitching&&(m.pitch=l.y.number(P,B,et)),this._padding&&(m.interpolatePadding(D,F,et),K=m.centerPoint.add(W)),this.terrain&&!s.freezeElevation&&this._updateElevation(et);const Ft=et===1?re:m.unproject(he.add(te.mult(Ot(Pt))).mult(Nn));m.setLocationAtPoint(m.renderWorldCopies?Ft.wrap():Ft,K),this._applyUpdatedTransform(m),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 f;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const m=this._onEaseEnd;delete this._onEaseEnd,m.call(this,d)}return s||(f=this.handlers)===null||f===void 0||f.stop(!1),this}_ease(s,d,f){f.animate===!1||f.duration===0?(s(1),d()):(this._easeStart=E.now(),this._easeOptions=f,this._onEaseFrame=s,this._onEaseEnd=d,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(s,d){s=l.b3(s,-180,180);const f=Math.abs(s-d);return Math.abs(s-360-d)<f&&(s-=360),Math.abs(s+360-d)<f&&(s+=360),s}_normalizeCenter(s,d){if(!d.renderWorldCopies||d.lngRange)return;const f=s.lng-d.center.lng;s.lng+=f>180?-360:f<-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=T.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=T.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=T.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(){T.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 f=this._map._getUIString(`AttributionControl.${d}`);s.title=f,s.setAttribute("aria-label",f)}_updateAttributions(){if(!this._map.style)return;let s=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?s=s.concat(this.options.customAttribution.map(m=>typeof m!="string"?"":m)):typeof this.options.customAttribution=="string"&&s.push(this.options.customAttribution)),this._map.style.stylesheet){const m=this._map.style.stylesheet;this.styleOwner=m.owner,this.styleId=m.id}const d=this._map.style.sourceCaches;for(const m in d){const b=d[m];if(b.used||b.usedForTerrain){const M=b.getSource();M.attribution&&s.indexOf(M.attribution)<0&&s.push(M.attribution)}}s=s.filter(m=>String(m).trim()),s.sort((m,b)=>m.length-b.length),s=s.filter((m,b)=>{for(let M=b+1;M<s.length;M++)if(s[M].indexOf(m)>=0)return!1;return!0});const f=s.join(" | ");f!==this._attribHTML&&(this._attribHTML=f,s.length?(this._innerContainer.innerHTML=f,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 f=d[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&f.classList.add("maplibregl-compact"):f.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=T.create("div","maplibregl-ctrl");const d=T.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(){T.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class Jt{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,f=d?this._queue.concat(d):this._queue;for(const m of f)if(m.id===s)return void(m.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 f of d)if(!f.cancelled&&(f.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 m_ 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 f={};for(const m of s.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:d}))f[m.key]=!0,this._renderableTilesKeys.push(m.key),this._tiles[m.key]||(m.posMatrix=new Float64Array(16),l.aP(m.posMatrix,0,l.X,0,l.X,0,1),this._tiles[m.key]=new Ts(m,this.tileSize));for(const m in this._tiles)f[m]||delete this._tiles[m]}freeRtt(s){for(const d in this._tiles){const f=this._tiles[d];(!s||f.tileID.equals(s)||f.tileID.isChildOf(s)||s.isChildOf(f.tileID))&&(f.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(s=>this.getTileByID(s))}getTileByID(s){return this._tiles[s]}getTerrainCoords(s){const d={};for(const f of this._renderableTilesKeys){const m=this._tiles[f].tileID;if(m.canonical.equals(s.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16),l.aP(b.posMatrix,0,l.X,0,l.X,0,1),d[f]=b}else if(m.canonical.isChildOf(s.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16);const M=m.canonical.z-s.canonical.z,P=m.canonical.x-(m.canonical.x>>M<<M),D=m.canonical.y-(m.canonical.y>>M<<M),L=l.X>>M;l.aP(b.posMatrix,0,L,0,L,0,1),l.J(b.posMatrix,b.posMatrix,[-P*L,-D*L,0]),d[f]=b}else if(s.canonical.isChildOf(m.canonical)){const b=s.clone();b.posMatrix=new Float64Array(16);const M=s.canonical.z-m.canonical.z,P=s.canonical.x-(s.canonical.x>>M<<M),D=s.canonical.y-(s.canonical.y>>M<<M),L=l.X>>M;l.aP(b.posMatrix,0,l.X,0,l.X,0,1),l.J(b.posMatrix,b.posMatrix,[P*L,D*L,0]),l.K(b.posMatrix,b.posMatrix,[1/2**M,1/2**M,0]),d[f]=b}}return d}getSourceTile(s,d){const f=this.sourceCache._source;let m=s.overscaledZ-this.deltaZoom;if(m>f.maxzoom&&(m=f.maxzoom),m<f.minzoom)return null;this._sourceTileCache[s.key]||(this._sourceTileCache[s.key]=s.scaledTo(m).key);let b=this.sourceCache.getTileByID(this._sourceTileCache[s.key]);if((!b||!b.dem)&&d)for(;m>=f.minzoom&&(!b||!b.dem);)b=this.sourceCache.getTileByID(s.scaledTo(m--).key);return b}tilesAfterTime(s=Date.now()){return Object.values(this._tiles).filter(d=>d.timeAdded>=s)}}class Od{constructor(s,d,f){this.painter=s,this.sourceCache=new m_(d),this.options=f,this.exaggeration=typeof f.exaggeration=="number"?f.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(s,d,f,m=l.X){var b;if(!(d>=0&&d<m&&f>=0&&f<m))return 0;const M=this.getTerrainData(s),P=(b=M.tile)===null||b===void 0?void 0:b.dem;if(!P)return 0;const D=function(Q,re,le){var ce=re[0],he=re[1];return Q[0]=le[0]*ce+le[4]*he+le[12],Q[1]=le[1]*ce+le[5]*he+le[13],Q}([],[d/m*l.X,f/m*l.X],M.u_terrain_matrix),L=[D[0]*P.dim,D[1]*P.dim],B=Math.floor(L[0]),F=Math.floor(L[1]),W=L[0]-B,K=L[1]-F;return P.get(B,F)*(1-W)*(1-K)+P.get(B+1,F)*W*(1-K)+P.get(B,F+1)*(1-W)*K+P.get(B+1,F+1)*W*K}getElevationForLngLatZoom(s,d){if(!l.bb(d,s.wrap()))return 0;const{tileID:f,mercatorX:m,mercatorY:b}=this._getOverscaledTileIDFromLngLatZoom(s,d);return this.getElevation(f,m%l.X,b%l.X,l.X)}getElevation(s,d,f,m=l.X){return this.getDEMElevation(s,d,f,m)*this.exaggeration}getTerrainData(s){if(!this._emptyDemTexture){const m=this.painter.context,b=new l.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new it(m,b,m.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new it(m,new l.R({width:1,height:1}),m.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(m.gl.NEAREST,m.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=l.an([])}const d=this.sourceCache.getSourceTile(s,!0);if(d&&d.dem&&(!d.demTexture||d.needsTerrainPrepare)){const m=this.painter.context;d.demTexture=this.painter.getTileTexture(d.dem.stride),d.demTexture?d.demTexture.update(d.dem.getPixels(),{premultiply:!1}):d.demTexture=new it(m,d.dem.getPixels(),m.gl.RGBA,{premultiply:!1}),d.demTexture.bind(m.gl.NEAREST,m.gl.CLAMP_TO_EDGE),d.needsTerrainPrepare=!1}const f=d&&d+d.tileID.key+s.key;if(f&&!this._demMatrixCache[f]){const m=this.sourceCache.sourceCache._source.maxzoom;let b=s.canonical.z-d.tileID.canonical.z;s.overscaledZ>s.canonical.z&&(s.canonical.z>=m?b=s.canonical.z-m:l.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const M=s.canonical.x-(s.canonical.x>>b<<b),P=s.canonical.y-(s.canonical.y>>b<<b),D=l.bc(new Float64Array(16),[1/(l.X<<b),1/(l.X<<b),0]);l.J(D,D,[M*l.X,P*l.X,0]),this._demMatrixCache[s.key]={matrix:D,coord:s}}return{u_depth:2,u_terrain:3,u_terrain_dim:d&&d.dem&&d.dem.dim||1,u_terrain_matrix:f?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,f=d.width/devicePixelRatio,m=d.height/devicePixelRatio;return!this._fbo||this._fbo.width===f&&this._fbo.height===m||(this._fbo.destroy(),this._fboCoordsTexture.destroy(),this._fboDepthTexture.destroy(),delete this._fbo,delete this._fboDepthTexture,delete this._fboCoordsTexture),this._fboCoordsTexture||(this._fboCoordsTexture=new it(d.context,{width:f,height:m,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 it(d.context,{width:f,height:m,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(f,m,!0,!1),this._fbo.depthAttachment.set(d.context.createRenderbuffer(d.context.gl.DEPTH_COMPONENT16,f,m))),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 b=0,M=0;b<this._coordsTextureSize;b++)for(let P=0;P<this._coordsTextureSize;P++,M+=4)d[M+0]=255&P,d[M+1]=255&b,d[M+2]=P>>8<<4|b>>8,d[M+3]=0;const f=new l.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(d.buffer)),m=new it(s,f,s.gl.RGBA,{premultiply:!1});return m.bind(s.gl.NEAREST,s.gl.CLAMP_TO_EDGE),this._coordsTexture=m,m}pointCoordinate(s){this.painter.maybeDrawDepthAndCoords(!0);const d=new Uint8Array(4),f=this.painter.context,m=f.gl,b=Math.round(s.x*this.painter.pixelRatio/devicePixelRatio),M=Math.round(s.y*this.painter.pixelRatio/devicePixelRatio),P=Math.round(this.painter.height/devicePixelRatio);f.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),m.readPixels(b,P-M-1,1,1,m.RGBA,m.UNSIGNED_BYTE,d),f.bindFramebuffer.set(null);const D=d[0]+(d[2]>>4<<8),L=d[1]+((15&d[2])<<8),B=this.coordsIndex[255-d[3]],F=B&&this.sourceCache.getTileByID(B);if(!F)return null;const W=this._coordsTextureSize,K=(1<<F.tileID.canonical.z)*W;return new l.Z((F.tileID.canonical.x*W+D)/K+F.tileID.wrap,(F.tileID.canonical.y*W+L)/K,this.getElevation(F.tileID,D,L,W))}depthAtPoint(s){const d=new Uint8Array(4),f=this.painter.context,m=f.gl;return f.bindFramebuffer.set(this.getFramebuffer("depth").framebuffer),m.readPixels(s.x,this.painter.height/devicePixelRatio-s.y-1,1,1,m.RGBA,m.UNSIGNED_BYTE,d),f.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,f=new l.aY,m=this.meshSize,b=l.X/m,M=m*m;for(let F=0;F<=m;F++)for(let W=0;W<=m;W++)d.emplaceBack(W*b,F*b,0);for(let F=0;F<M;F+=m+1)for(let W=0;W<m;W++)f.emplaceBack(W+F,m+W+F+1,m+W+F+2),f.emplaceBack(W+F,m+W+F+2,W+F+1);const P=d.length,D=P+2*(m+1);for(const F of[0,1])for(let W=0;W<=m;W++)for(const K of[0,1])d.emplaceBack(W*b,F*l.X,K);for(let F=0;F<2*m;F+=2)f.emplaceBack(D+F,D+F+1,D+F+3),f.emplaceBack(D+F,D+F+3,D+F+2),f.emplaceBack(P+F,P+F+3,P+F+1),f.emplaceBack(P+F,P+F+2,P+F+3);const L=d.length,B=L+2*(m+1);for(const F of[0,1])for(let W=0;W<=m;W++)for(const K of[0,1])d.emplaceBack(F*l.X,W*b,K);for(let F=0;F<2*m;F+=2)f.emplaceBack(L+F,L+F+1,L+F+3),f.emplaceBack(L+F,L+F+3,L+F+2),f.emplaceBack(B+F,B+F+3,B+F+1),f.emplaceBack(B+F,B+F+2,B+F+3);return this._mesh=new gu(s.createVertexBuffer(d,Dd.members),s.createIndexBuffer(f),l.a0.simpleSegment(0,0,d.length,f.length)),this._mesh}getMeshFrameDelta(s){return 2*Math.PI*l.be/Math.pow(2,s)/5}getMinTileElevationForLngLatZoom(s,d){var f;const{tileID:m}=this._getOverscaledTileIDFromLngLatZoom(s,d);return(f=this.getMinMaxElevation(m).minElevation)!==null&&f!==void 0?f:0}getMinMaxElevation(s){const d=this.getTerrainData(s).tile,f={minElevation:null,maxElevation:null};return d&&d.dem&&(f.minElevation=d.dem.min*this.exaggeration,f.maxElevation=d.dem.max*this.exaggeration),f}_getOverscaledTileIDFromLngLatZoom(s,d){const f=l.Z.fromLngLat(s.wrap()),m=(1<<d)*l.X,b=f.x*m,M=f.y*m,P=Math.floor(b/l.X),D=Math.floor(M/l.X);return{tileID:new l.S(d,0,d,P,D),mercatorX:b,mercatorY:M}}}class g_{constructor(s,d,f){this._context=s,this._size=d,this._tileSize=f,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),f=new it(this._context,{width:this._tileSize,height:this._tileSize,data:null},this._context.gl.RGBA);return f.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(f.texture),{id:s,fbo:d,texture:f,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 km{constructor(s,d){this.painter=s,this.terrain=d,this.pool=new g_(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(f=>!s._layers[f].isHidden(d)),this._coordsDescendingInv={};for(const f in s.sourceCaches){this._coordsDescendingInv[f]={};const m=s.sourceCaches[f].getVisibleCoordinates();for(const b of m){const M=this.terrain.sourceCache.getTerrainCoords(b);for(const P in M)this._coordsDescendingInv[f][P]||(this._coordsDescendingInv[f][P]=[]),this._coordsDescendingInv[f][P].push(M[P])}}this._coordsDescendingInvStr={};for(const f of s._order){const m=s._layers[f],b=m.source;if(Za[m.type]&&!this._coordsDescendingInvStr[b]){this._coordsDescendingInvStr[b]={};for(const M in this._coordsDescendingInv[b])this._coordsDescendingInvStr[b][M]=this._coordsDescendingInv[b][M].map(P=>P.key).sort().join()}}for(const f of this._renderableTiles)for(const m in this._coordsDescendingInvStr){const b=this._coordsDescendingInvStr[m][f.tileID.key];b&&b!==f.rttCoords[m]&&(f.rtt=[])}}renderLayer(s){if(s.isHidden(this.painter.transform.zoom))return!1;const d=s.type,f=this.painter,m=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),!m))return!0;if(Za[this._prevType]||Za[d]&&m){this._prevType=d;const b=this._stacks.length-1,M=this._stacks[b]||[];for(const P of this._renderableTiles){if(this.pool.isFull()&&(mm(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(P),P.rtt[b]){const L=this.pool.getObjectForId(P.rtt[b].id);if(L.stamp===P.rtt[b].stamp){this.pool.useObject(L);continue}}const D=this.pool.getOrCreateFreeObject();this.pool.useObject(D),this.pool.stampObject(D),P.rtt[b]={id:D.id,stamp:D.stamp},f.context.bindFramebuffer.set(D.fbo.framebuffer),f.context.clear({color:l.aM.transparent,stencil:0}),f.currentStencilSource=void 0;for(let L=0;L<M.length;L++){const B=f.style._layers[M[L]],F=B.source?this._coordsDescendingInv[B.source][P.tileID.key]:[P.tileID];f.context.viewport.set([0,0,D.fbo.width,D.fbo.height]),f._renderTileClippingMasks(B,F),f.renderLayer(f,f.style.sourceCaches[B.source],B,F),B.source&&(P.rttCoords[B.source]=this._coordsDescendingInvStr[B.source][P.tileID.key])}}return mm(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects(),Za[d]}return!1}}const zd={"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"},Sm=g,y_={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},Rd=x=>{x.touchstart=x.dragStart,x.touchmoveWindow=x.dragMove,x.touchend=x.dragEnd},__={showCompass:!0,showZoom:!0,visualizePitch:!1};class b_{constructor(s,d,f=!1){this.mousedown=M=>{this.startMouse(l.e({},M,{ctrlKey:!0,preventDefault:()=>M.preventDefault()}),T.mousePos(this.element,M)),T.addEventListener(window,"mousemove",this.mousemove),T.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=M=>{this.moveMouse(M,T.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=T.touchPos(this.element,M.targetTouches)[0],this.startTouch(M,this._startPos),T.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.addEventListener(window,"touchend",this.touchend))},this.touchmove=M=>{M.targetTouches.length!==1?this.reset():(this._lastPos=T.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 m=s.dragRotate._mouseRotate.getClickTolerance(),b=s.dragRotate._mousePitch.getClickTolerance();this.element=d,this.mouseRotate=wd({clickTolerance:m,enable:!0}),this.touchRotate=(({enable:M,clickTolerance:P,bearingDegreesPerPixelMoved:D=.8})=>{const L=new vd;return new qs({clickTolerance:P,move:(B,F)=>({bearingDelta:(F.x-B.x)*D}),moveStateManager:L,enable:M,assignEvents:Rd})})({clickTolerance:m,enable:!0}),this.map=s,f&&(this.mousePitch=kd({clickTolerance:b,enable:!0}),this.touchPitch=(({enable:M,clickTolerance:P,pitchDegreesPerPixelMoved:D=-.5})=>{const L=new vd;return new qs({clickTolerance:P,move:(B,F)=>({pitchDelta:(F.y-B.y)*D}),moveStateManager:L,enable:M,assignEvents:Rd})})({clickTolerance:b,enable:!0})),T.addEventListener(d,"mousedown",this.mousedown),T.addEventListener(d,"touchstart",this.touchstart,{passive:!1}),T.addEventListener(d,"touchcancel",this.reset)}startMouse(s,d){this.mouseRotate.dragStart(s,d),this.mousePitch&&this.mousePitch.dragStart(s,d),T.disableDrag()}startTouch(s,d){this.touchRotate.dragStart(s,d),this.touchPitch&&this.touchPitch.dragStart(s,d),T.disableDrag()}moveMouse(s,d){const f=this.map,{bearingDelta:m}=this.mouseRotate.dragMove(s,d)||{};if(m&&f.setBearing(f.getBearing()+m),this.mousePitch){const{pitchDelta:b}=this.mousePitch.dragMove(s,d)||{};b&&f.setPitch(f.getPitch()+b)}}moveTouch(s,d){const f=this.map,{bearingDelta:m}=this.touchRotate.dragMove(s,d)||{};if(m&&f.setBearing(f.getBearing()+m),this.touchPitch){const{pitchDelta:b}=this.touchPitch.dragMove(s,d)||{};b&&f.setPitch(f.getPitch()+b)}}off(){const s=this.element;T.removeEventListener(s,"mousedown",this.mousedown),T.removeEventListener(s,"touchstart",this.touchstart,{passive:!1}),T.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.removeEventListener(window,"touchend",this.touchend),T.removeEventListener(s,"touchcancel",this.reset),this.offTemp()}offTemp(){T.enableDrag(),T.removeEventListener(window,"mousemove",this.mousemove),T.removeEventListener(window,"mouseup",this.mouseup),T.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),T.removeEventListener(window,"touchend",this.touchend)}}let _r;function Ln(x,s,d){const f=new l.N(x.lng,x.lat);if(x=new l.N(x.lng,x.lat),s){const m=new l.N(x.lng-360,x.lat),b=new l.N(x.lng+360,x.lat),M=d.locationPoint(x).distSqr(s);d.locationPoint(m).distSqr(s)<M?x=m:d.locationPoint(b).distSqr(s)<M&&(x=b)}for(;Math.abs(x.lng-d.center.lng)>180;){const m=d.locationPoint(x);if(m.x>=0&&m.y>=0&&m.x<=d.width&&m.y<=d.height)break;x.lng>d.center.lng?x.lng-=360:x.lng+=360}return x.lng!==f.lng&&d.locationPoint(x).y>d.height/2-d.getHorizon()?x:f}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(x,s,d){const f=x.classList;for(const m in Ya)f.remove(`maplibregl-${d}-anchor-${m}`);f.add(`maplibregl-${d}-anchor-${s}`)}class Mu extends l.E{constructor(s){if(super(),this._onKeyPress=d=>{const f=d.code,m=d.charCode||d.keyCode;f!=="Space"&&f!=="Enter"&&m!==32&&m!==13||this.togglePopup()},this._onMapClick=d=>{const f=d.originalEvent.target,m=this._element;this._popup&&(f===m||m.contains(f))&&this.togglePopup()},this._update=d=>{var f;if(!this._map)return;const m=this._map.loaded()&&!this._map.isMoving();((d==null?void 0:d.type)==="terrain"||(d==null?void 0:d.type)==="render"&&!m)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Ln(this._lngLat,this._flatPos,this._map.transform):(f=this._lngLat)===null||f===void 0?void 0:f.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 b="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?b=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(b=`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()),T.setTransform(this._element,`${Ya[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${M} ${b}`),E.frameAsync(new AbortController).then(()=>{this._updateOpacity(d&&d.type==="moveend")}).catch(()=>{})},this._onMove=d=>{if(!this._isDragging){const f=this._clickTolerance||this._map._clickTolerance;this._isDragging=d.point.dist(this._pointerdownPos)>=f}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=T.create("div");const d=T.createNS("http://www.w3.org/2000/svg","svg"),f=41,m=27;d.setAttributeNS(null,"display","block"),d.setAttributeNS(null,"height",`${f}px`),d.setAttributeNS(null,"width",`${m}px`),d.setAttributeNS(null,"viewBox",`0 0 ${m} ${f}`);const b=T.createNS("http://www.w3.org/2000/svg","g");b.setAttributeNS(null,"stroke","none"),b.setAttributeNS(null,"stroke-width","1"),b.setAttributeNS(null,"fill","none"),b.setAttributeNS(null,"fill-rule","evenodd");const M=T.createNS("http://www.w3.org/2000/svg","g");M.setAttributeNS(null,"fill-rule","nonzero");const P=T.createNS("http://www.w3.org/2000/svg","g");P.setAttributeNS(null,"transform","translate(3.0, 29.0)"),P.setAttributeNS(null,"fill","#000000");const D=[{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 D){const he=T.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 L=T.createNS("http://www.w3.org/2000/svg","g");L.setAttributeNS(null,"fill",this._color);const B=T.createNS("http://www.w3.org/2000/svg","path");B.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"),L.appendChild(B);const F=T.createNS("http://www.w3.org/2000/svg","g");F.setAttributeNS(null,"opacity","0.25"),F.setAttributeNS(null,"fill","#000000");const W=T.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 K=T.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(6.0, 7.0)"),K.setAttributeNS(null,"fill","#FFFFFF");const Q=T.createNS("http://www.w3.org/2000/svg","g");Q.setAttributeNS(null,"transform","translate(8.0, 8.0)");const re=T.createNS("http://www.w3.org/2000/svg","circle");re.setAttributeNS(null,"fill","#000000"),re.setAttributeNS(null,"opacity","0.25"),re.setAttributeNS(null,"cx","5.5"),re.setAttributeNS(null,"cy","5.5"),re.setAttributeNS(null,"r","5.4999962");const le=T.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"),Q.appendChild(re),Q.appendChild(le),M.appendChild(P),M.appendChild(L),M.appendChild(F),M.appendChild(K),M.appendChild(Q),d.appendChild(M),d.setAttributeNS(null,"height",f*this._scale+"px"),d.setAttributeNS(null,"width",m*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),T.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 m=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":[m,-1*(38.1-13.5+m)],"bottom-right":[-m,-1*(38.1-13.5+m)],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,f;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 m=this._map,b=m.terrain.depthAtPoint(this._pos),M=m.terrain.getElevationForLngLatZoom(this._lngLat,m.transform.tileZoom);if(m.transform.lngLatToCameraDepth(this._lngLat,M)-b<.006)return void(this._element.style.opacity=this._opacity);const P=-this._offset.y/m.transform._pixelPerMeter,D=Math.sin(m.getPitch()*Math.PI/180)*P,L=m.terrain.depthAtPoint(new l.P(this._pos.x,this._pos.y-this._offset.y)),B=m.transform.lngLatToCameraDepth(this._lngLat,M+D)-L>.006;!((f=this._popup)===null||f===void 0)&&f.isOpen()&&B&&this._popup.remove(),this._element.style.opacity=B?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 Em={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(x,s,d){const f=d&&d.maxWidth||100,m=x._container.clientHeight/2,b=x.unproject([0,m]),M=x.unproject([f,m]),P=b.distanceTo(M);if(d&&d.unit==="imperial"){const D=3.2808*P;D>5280?dt(s,f,D/5280,x._getUIString("ScaleControl.Miles")):dt(s,f,D,x._getUIString("ScaleControl.Feet"))}else d&&d.unit==="nautical"?dt(s,f,P/1852,x._getUIString("ScaleControl.NauticalMiles")):P>=1e3?dt(s,f,P/1e3,x._getUIString("ScaleControl.Kilometers")):dt(s,f,P,x._getUIString("ScaleControl.Meters"))}function dt(x,s,d,f){const m=function(b){const M=Math.pow(10,`${Math.floor(b)}`.length-1);let P=b/M;return P=P>=10?10:P>=5?5:P>=3?3:P>=2?2:P>=1?1:function(D){const L=Math.pow(10,Math.ceil(-Math.log(D)/Math.LN10));return Math.round(D*L)/L}(P),M*P}(d);x.style.width=s*(m/d)+"px",x.innerHTML=`${m} ${f}`}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(x){if(x){if(typeof x=="number"){const s=Math.round(Math.abs(x)/Math.SQRT2);return{center:new l.P(0,0),top:new l.P(0,x),"top-left":new l.P(s,s),"top-right":new l.P(-s,s),bottom:new l.P(0,-x),"bottom-left":new l.P(s,-s),"bottom-right":new l.P(-s,-s),left:new l.P(x,0),right:new l.P(-x,0)}}if(x instanceof l.P||Array.isArray(x)){const s=l.P.convert(x);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(x.center||[0,0]),top:l.P.convert(x.top||[0,0]),"top-left":l.P.convert(x["top-left"]||[0,0]),"top-right":l.P.convert(x["top-right"]||[0,0]),bottom:l.P.convert(x.bottom||[0,0]),"bottom-left":l.P.convert(x["bottom-left"]||[0,0]),"bottom-right":l.P.convert(x["bottom-right"]||[0,0]),left:l.P.convert(x.left||[0,0]),right:l.P.convert(x.right||[0,0])}}return Pu(new l.P(0,0))}const Ld=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=yr,u.CanvasSource=xi,u.CooperativeGesturesHandler=qa,u.DoubleClickZoomHandler=Ko,u.DragPanHandler=xm,u.DragRotateHandler=vm,u.EdgeInsets=$a,u.FullscreenControl=class extends l.E{constructor(x={}){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,x&&x.container&&(x.container instanceof HTMLElement?this._container=x.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(x){return this._map=x,this._container||(this._container=this._map.getContainer()),this._controlContainer=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){T.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const x=this._fullscreenButton=T.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);T.create("span","maplibregl-ctrl-icon",x).setAttribute("aria-hidden","true"),x.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const x=this._getTitle();this._fullscreenButton.setAttribute("aria-label",x),this._fullscreenButton.title=x}_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=er,u.GeolocateControl=class extends l.E{constructor(x){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),f=s.coords.accuracy,m=this._map.getBearing(),b=l.e({bearing:m},this.options.fitBoundsOptions),M=we.fromLngLat(d,f);this._map.fitBounds(M,b,{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=T.create("button","maplibregl-ctrl-geolocate",this._container),T.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=T.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Mu({element:this._dotElement}),this._circleElement=T.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({},Em,x)}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return l._(this,arguments,void 0,function*(s=!1){if(_r!==void 0&&!s)return _r;if(window.navigator.permissions===void 0)return _r=!!window.navigator.geolocation,_r;try{_r=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{_r=!!window.navigator.geolocation}return _r})}().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(),T.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Jl=0,Ql=!1}_isOutOfMapMaxBounds(x){const s=this._map.getMaxBounds(),d=x.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 x=this._map.getBounds(),s=x.getSouthEast(),d=x.getNorthEast(),f=s.distanceTo(d),m=Math.ceil(this._accuracy/(f/this._map._container.clientHeight)*2);this._circleElement.style.width=`${m}px`,this._circleElement.style.height=`${m}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 x;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Jl++,Jl>1?(x={maximumAge:6e5,timeout:0},Ql=!0):(x=this.options.positionOptions,Ql=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,x)}}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=bi,u.KeyboardHandler=Nr,u.LngLatBounds=we,u.LogoControl=Id,u.Map=class extends wm{constructor(x){l.bf.mark(l.bg.create);const s=Object.assign(Object.assign({},y_),x);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 Jt,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({},zd),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=oe.addThrottleControl(()=>this.isMoving()),this._requestManager=new J(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 f=Gl(m=>{this._trackResize&&!this._removed&&(this.resize(m),this.redraw())},50);this._resizeObserver=new ResizeObserver(m=>{d?f(m):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(x,s){if(s===void 0&&(s=x.getDefaultPosition?x.getDefaultPosition():"top-right"),!x||!x.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=x.onAdd(this);this._controls.push(x);const f=this._controlPositions[s];return s.indexOf("bottom")!==-1?f.insertBefore(d,f.firstChild):f.appendChild(d),this}removeControl(x){if(!x||!x.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(x);return s>-1&&this._controls.splice(s,1),x.onRemove(this),this}hasControl(x){return this._controls.indexOf(x)>-1}calculateCameraOptionsFromTo(x,s,d,f){return f==null&&this.terrain&&(f=this.terrain.getElevationForLngLatZoom(d,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(x,s,d,f)}resize(x){var s;const d=this._containerDimensions(),f=d[0],m=d[1],b=this._getClampedPixelRatio(f,m);if(this._resizeCanvas(f,m,b),this.painter.resize(f,m,b),this.painter.overLimit()){const P=this.painter.context.gl;this._maxCanvasSize=[P.drawingBufferWidth,P.drawingBufferHeight];const D=this._getClampedPixelRatio(f,m);this._resizeCanvas(f,m,D),this.painter.resize(f,m,D)}this.transform.resize(f,m),(s=this._requestedCameraState)===null||s===void 0||s.resize(f,m);const M=!this._moving;return M&&(this.stop(),this.fire(new l.k("movestart",x)).fire(new l.k("move",x))),this.fire(new l.k("resize",x)),M&&this.fire(new l.k("moveend",x)),this}_getClampedPixelRatio(x,s){const{0:d,1:f}=this._maxCanvasSize,m=this.getPixelRatio(),b=x*m,M=s*m;return Math.min(b>d?d/b:1,M>f?f/M:1)*m}getPixelRatio(){var x;return(x=this._overridePixelRatio)!==null&&x!==void 0?x:devicePixelRatio}setPixelRatio(x){this._overridePixelRatio=x,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(x){return this.transform.setMaxBounds(we.convert(x)),this._update()}setMinZoom(x){if((x=x??-2)>=-2&&x<=this.transform.maxZoom)return this.transform.minZoom=x,this._update(),this.getZoom()<x&&this.setZoom(x),this;throw new Error("minZoom must be between -2 and the current maxZoom, inclusive")}getMinZoom(){return this.transform.minZoom}setMaxZoom(x){if((x=x??22)>=this.transform.minZoom)return this.transform.maxZoom=x,this._update(),this.getZoom()>x&&this.setZoom(x),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(x){if((x=x??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(x>=0&&x<=this.transform.maxPitch)return this.transform.minPitch=x,this._update(),this.getPitch()<x&&this.setPitch(x),this;throw new Error("minPitch must be between 0 and the current maxPitch, inclusive")}getMinPitch(){return this.transform.minPitch}setMaxPitch(x){if((x=x??60)>85)throw new Error("maxPitch must be less than or equal to 85");if(x>=this.transform.minPitch)return this.transform.maxPitch=x,this._update(),this.getPitch()>x&&this.setPitch(x),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(x){return this.transform.renderWorldCopies=x,this._update()}project(x){return this.transform.locationPoint(l.N.convert(x),this.style&&this.terrain)}unproject(x){return this.transform.pointLocation(l.P.convert(x),this.terrain)}isMoving(){var x;return this._moving||((x=this.handlers)===null||x===void 0?void 0:x.isMoving())}isZooming(){var x;return this._zooming||((x=this.handlers)===null||x===void 0?void 0:x.isZooming())}isRotating(){var x;return this._rotating||((x=this.handlers)===null||x===void 0?void 0:x.isRotating())}_createDelegatedListener(x,s,d){if(x==="mouseenter"||x==="mouseover"){let f=!1;return{layers:s,listener:d,delegates:{mousemove:b=>{const M=s.filter(D=>this.getLayer(D)),P=M.length!==0?this.queryRenderedFeatures(b.point,{layers:M}):[];P.length?f||(f=!0,d.call(this,new Pi(x,this,b.originalEvent,{features:P}))):f=!1},mouseout:()=>{f=!1}}}}if(x==="mouseleave"||x==="mouseout"){let f=!1;return{layers:s,listener:d,delegates:{mousemove:M=>{const P=s.filter(D=>this.getLayer(D));(P.length!==0?this.queryRenderedFeatures(M.point,{layers:P}):[]).length?f=!0:f&&(f=!1,d.call(this,new Pi(x,this,M.originalEvent)))},mouseout:M=>{f&&(f=!1,d.call(this,new Pi(x,this,M.originalEvent)))}}}}{const f=m=>{const b=s.filter(P=>this.getLayer(P)),M=b.length!==0?this.queryRenderedFeatures(m.point,{layers:b}):[];M.length&&(m.features=M,d.call(this,m),delete m.features)};return{layers:s,listener:d,delegates:{[x]:f}}}}_saveDelegatedListener(x,s){this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[x]=this._delegatedListeners[x]||[],this._delegatedListeners[x].push(s)}_removeDelegatedListener(x,s,d){if(!this._delegatedListeners||!this._delegatedListeners[x])return;const f=this._delegatedListeners[x];for(let m=0;m<f.length;m++){const b=f[m];if(b.listener===d&&b.layers.length===s.length&&b.layers.every(M=>s.includes(M))){for(const M in b.delegates)this.off(M,b.delegates[M]);return void f.splice(m,1)}}}on(x,s,d){if(d===void 0)return super.on(x,s);const f=this._createDelegatedListener(x,typeof s=="string"?[s]:s,d);this._saveDelegatedListener(x,f);for(const m in f.delegates)this.on(m,f.delegates[m]);return this}once(x,s,d){if(d===void 0)return super.once(x,s);const f=typeof s=="string"?[s]:s,m=this._createDelegatedListener(x,f,d);for(const b in m.delegates){const M=m.delegates[b];m.delegates[b]=(...P)=>{this._removeDelegatedListener(x,f,d),M(...P)}}this._saveDelegatedListener(x,m);for(const b in m.delegates)this.once(b,m.delegates[b]);return this}off(x,s,d){return d===void 0?super.off(x,s):(this._removeDelegatedListener(x,typeof s=="string"?[s]:s,d),this)}queryRenderedFeatures(x,s){if(!this.style)return[];let d;const f=x instanceof l.P||Array.isArray(x),m=f?x:[[0,0],[this.transform.width,this.transform.height]];if(s=s||(f?{}:x)||{},m instanceof l.P||typeof m[0]=="number")d=[l.P.convert(m)];else{const b=l.P.convert(m[0]),M=l.P.convert(m[1]);d=[b,new l.P(M.x,b.y),M,new l.P(b.x,M.y),b]}return this.style.queryRenderedFeatures(d,s,this.transform)}querySourceFeatures(x,s){return this.style.querySourceFeatures(x,s)}setStyle(x,s){return(s=l.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},s)).diff!==!1&&s.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&x?(this._diffStyle(x,s),this):(this._localIdeographFontFamily=s.localIdeographFontFamily,this._updateStyle(x,s))}setTransformRequest(x){return this._requestManager.setTransformRequest(x),this}_getUIString(x){const s=this._locale[x];if(s==null)throw new Error(`Missing UI string '${x}'`);return s}_updateStyle(x,s){if(s.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(x,s));const d=this.style&&s.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!x)),x?(this.style=new tu(this,s||{}),this.style.setEventedParent(this,{style:this.style}),typeof x=="string"?this.style.loadURL(x,s,d):this.style.loadJSON(x,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(x,s){if(typeof x=="string"){const d=this._requestManager.transformRequest(x,"Style");l.h(d,new AbortController).then(f=>{this._updateDiff(f.data,s)}).catch(f=>{f&&this.fire(new l.j(f))})}else typeof x=="object"&&this._updateDiff(x,s)}_updateDiff(x,s){try{this.style.setState(x,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(x,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(x,s){return this._lazyInitEmptyStyle(),this.style.addSource(x,s),this._update(!0)}isSourceLoaded(x){const s=this.style&&this.style.sourceCaches[x];if(s!==void 0)return s.loaded();this.fire(new l.j(new Error(`There is no source with ID '${x}'`)))}setTerrain(x){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),x){const s=this.style.sourceCaches[x.source];if(!s)throw new Error(`cannot load terrain, because there exists no source with ID: ${x.source}`);this.terrain===null&&s.reload();for(const d in this.style._layers){const f=this.style._layers[d];f.type==="hillshade"&&f.source===x.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,x),this.painter.renderToTexture=new km(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!==x.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:x})),this}getTerrain(){var x,s;return(s=(x=this.terrain)===null||x===void 0?void 0:x.options)!==null&&s!==void 0?s:null}areTilesLoaded(){const x=this.style&&this.style.sourceCaches;for(const s in x){const d=x[s]._tiles;for(const f in d){const m=d[f];if(m.state!=="loaded"&&m.state!=="errored")return!1}}return!0}removeSource(x){return this.style.removeSource(x),this._update(!0)}getSource(x){return this.style.getSource(x)}addImage(x,s,d={}){const{pixelRatio:f=1,sdf:m=!1,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L}=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:B,height:F,data:W}=s,K=s;return this.style.addImage(x,{data:new l.R({width:B,height:F},new Uint8Array(W)),pixelRatio:f,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L,sdf:m,version:0,userImage:K}),K.onAdd&&K.onAdd(this,x),this}}{const{width:B,height:F,data:W}=E.getImageData(s);this.style.addImage(x,{data:new l.R({width:B,height:F},W),pixelRatio:f,stretchX:b,stretchY:M,content:P,textFitWidth:D,textFitHeight:L,sdf:m,version:0})}}updateImage(x,s){const d=this.style.getImage(x);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 f=s instanceof HTMLImageElement||l.b(s)?E.getImageData(s):s,{width:m,height:b,data:M}=f;if(m===void 0||b===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(m!==d.data.width||b!==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(x,d),this}getImage(x){return this.style.getImage(x)}hasImage(x){return x?!!this.style.getImage(x):(this.fire(new l.j(new Error("Missing required image id"))),!1)}removeImage(x){this.style.removeImage(x)}loadImage(x){return oe.getImage(this._requestManager.transformRequest(x,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(x,s){return this._lazyInitEmptyStyle(),this.style.addLayer(x,s),this._update(!0)}moveLayer(x,s){return this.style.moveLayer(x,s),this._update(!0)}removeLayer(x){return this.style.removeLayer(x),this._update(!0)}getLayer(x){return this.style.getLayer(x)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(x,s,d){return this.style.setLayerZoomRange(x,s,d),this._update(!0)}setFilter(x,s,d={}){return this.style.setFilter(x,s,d),this._update(!0)}getFilter(x){return this.style.getFilter(x)}setPaintProperty(x,s,d,f={}){return this.style.setPaintProperty(x,s,d,f),this._update(!0)}getPaintProperty(x,s){return this.style.getPaintProperty(x,s)}setLayoutProperty(x,s,d,f={}){return this.style.setLayoutProperty(x,s,d,f),this._update(!0)}getLayoutProperty(x,s){return this.style.getLayoutProperty(x,s)}setGlyphs(x,s={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(x,s),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(x,s,d={}){return this._lazyInitEmptyStyle(),this.style.addSprite(x,s,d,f=>{f||this._update(!0)}),this}removeSprite(x){return this._lazyInitEmptyStyle(),this.style.removeSprite(x),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(x,s={}){return this._lazyInitEmptyStyle(),this.style.setSprite(x,s,d=>{d||this._update(!0)}),this}setLight(x,s={}){return this._lazyInitEmptyStyle(),this.style.setLight(x,s),this._update(!0)}getLight(){return this.style.getLight()}setSky(x){return this._lazyInitEmptyStyle(),this.style.setSky(x),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(x,s){return this.style.setFeatureState(x,s),this._update()}removeFeatureState(x,s){return this.style.removeFeatureState(x,s),this._update()}getFeatureState(x){return this.style.getFeatureState(x)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let x=0,s=0;return this._container&&(x=this._container.clientWidth||400,s=this._container.clientHeight||300),[x,s]}_setupContainer(){const x=this._container;x.classList.add("maplibregl-map");const s=this._canvasContainer=T.create("div","maplibregl-canvas-container",x);this._interactive&&s.classList.add("maplibregl-interactive"),this._canvas=T.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(),f=this._getClampedPixelRatio(d[0],d[1]);this._resizeCanvas(d[0],d[1],f);const m=this._controlContainer=T.create("div","maplibregl-control-container",x),b=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(M=>{b[M]=T.create("div",`maplibregl-ctrl-${M} `,m)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(x,s,d){this._canvas.width=Math.floor(d*x),this._canvas.height=Math.floor(d*s),this._canvas.style.width=`${x}px`,this._canvas.style.height=`${s}px`}_setupPainter(){const x={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let s=null;this._canvas.addEventListener("webglcontextcreationerror",f=>{s={requestedAttributes:x},f&&(s.statusMessage=f.statusMessage,s.type=f.type)},{once:!0});const d=this._canvas.getContext("webgl2",x)||this._canvas.getContext("webgl",x);if(!d){const f="Failed to initialize WebGL";throw s?(s.message=f,new Error(JSON.stringify(s))):new Error(f)}this.painter=new yu(d,this.transform),I.testSupport(d)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(x){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||x,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(x){return this._update(),this._renderTaskQueue.add(x)}_cancelRenderFrame(x){this._renderTaskQueue.remove(x)}_render(x){const s=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(x),this._removed)return;let d=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const m=this.transform.zoom,b=E.now();this.style.zoomHistory.update(m,b);const M=new l.z(m,{now:b,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 f=this._sourcesDirty||this._styleDirty||this._placementDirty;return f||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new l.k("idle")),!this._loaded||this._fullyLoaded||f||(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 x;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),oe.removeThrottleControl(this._imageQueueHandle),(x=this._resizeObserver)===null||x===void 0||x.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),T.remove(this._canvasContainer),T.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(x=>{l.bf.frame(x),this._frameRequest=null,this._render(x)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(x){this._showTileBoundaries!==x&&(this._showTileBoundaries=x,this._update())}get showPadding(){return!!this._showPadding}set showPadding(x){this._showPadding!==x&&(this._showPadding=x,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(x){this._showCollisionBoxes!==x&&(this._showCollisionBoxes=x,x?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(x){this._showOverdrawInspector!==x&&(this._showOverdrawInspector=x,this._update())}get repaint(){return!!this._repaint}set repaint(x){this._repaint!==x&&(this._repaint=x,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(x){this._vertices=x,this._update()}get version(){return Sm}getCameraTargetElevation(){return this.transform.elevation}},u.MapMouseEvent=Pi,u.MapTouchEvent=Yo,u.MapWheelEvent=ym,u.Marker=Mu,u.NavigationControl=class{constructor(x){this._updateZoomButtons=()=>{const s=this._map.getZoom(),d=s===this._map.getMaxZoom(),f=s===this._map.getMinZoom();this._zoomInButton.disabled=d,this._zoomOutButton.disabled=f,this._zoomInButton.setAttribute("aria-disabled",d.toString()),this._zoomOutButton.setAttribute("aria-disabled",f.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 f=this._map._getUIString(`NavigationControl.${d}`);s.title=f,s.setAttribute("aria-label",f)},this.options=l.e({},__,x),this._container=T.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})),T.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})),T.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=T.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(x){return this._map=x,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 b_(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){T.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(x,s){const d=T.create("button",x,this._container);return d.type="button",d.addEventListener("click",s),d}},u.Popup=class extends l.E{constructor(x){super(),this.remove=()=>(this._content&&T.remove(this._content),this._container&&(T.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=T.create("div","maplibregl-popup",this._map.getContainer()),this._tip=T.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?Ln(this._lngLat,this._flatPos,this._map.transform):(d=this._lngLat)===null||d===void 0?void 0:d.wrap(),this._trackPointer&&!s)return;const f=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 m=this.options.anchor;const b=Pu(this.options.offset);if(!m){const P=this._container.offsetWidth,D=this._container.offsetHeight;let L;L=f.y+b.bottom.y<D?["top"]:f.y>this._map.transform.height-D?["bottom"]:[],f.x<P/2?L.push("left"):f.x>this._map.transform.width-P/2&&L.push("right"),m=L.length===0?"bottom":L.join("-")}let M=f.add(b[m]);this.options.subpixelPositioning||(M=M.round()),T.setTransform(this._container,`${Ya[m]} translate(${M.x}px,${M.y}px)`),Tu(this._container,m,"popup")},this._onClose=()=>{this.remove()},this.options=l.e(Object.create(Et),x)}addTo(x){return this._map&&this.remove(),this._map=x,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(x){return this._lngLat=l.N.convert(x),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(x){return this.setDOMContent(document.createTextNode(x))}setHTML(x){const s=document.createDocumentFragment(),d=document.createElement("body");let f;for(d.innerHTML=x;f=d.firstChild,f;)s.appendChild(f);return this.setDOMContent(s)}getMaxWidth(){var x;return(x=this._container)===null||x===void 0?void 0:x.style.maxWidth}setMaxWidth(x){return this.options.maxWidth=x,this._update(),this}setDOMContent(x){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=T.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(x),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(x){return this._container&&this._container.classList.add(x),this}removeClassName(x){return this._container&&this._container.classList.remove(x),this}setOffset(x){return this.options.offset=x,this._update(),this}toggleClassName(x){if(this._container)return this._container.classList.toggle(x)}setSubpixelPositioning(x){this.options.subpixelPositioning=x}_createCloseButton(){this.options.closeButton&&(this._closeButton=T.create("button","maplibregl-popup-close-button",this._content),this._closeButton.type="button",this._closeButton.innerHTML="×",this._closeButton.addEventListener("click",this._onClose))}_focusFirstElement(){if(!this.options.focusAfterOpen||!this._container)return;const x=this._container.querySelector(Au);x&&x.focus()}},u.RasterDEMTileSource=dn,u.RasterTileSource=Kt,u.ScaleControl=class{constructor(x){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),x)}getDefaultPosition(){return"bottom-left"}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-scale",x.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){T.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},u.ScrollZoomHandler=ts,u.Style=tu,u.TerrainControl=class{constructor(x){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=x}onAdd(x){return this._map=x,this._container=T.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=T.create("button","maplibregl-ctrl-terrain",this._container),T.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(){T.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=Ss,u.VideoSource=Dr,u.addSourceType=(x,s)=>l._(void 0,void 0,void 0,function*(){if(Cs(x))throw new Error(`A source type called "${x}" already exists.`);((d,f)=>{Es[d]=f})(x,s)}),u.clearPrewarmedResources=function(){const x=Ce;x&&(x.isPreloaded()&&x.numActive()===1?(x.release(Wn),Ce=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 zr().getRTLTextPluginStatus()},u.getVersion=function(){return Ld},u.getWorkerCount=function(){return jn.workerCount},u.getWorkerUrl=function(){return l.a.WORKER_URL},u.importScriptInWorkers=function(x){return Bt().broadcast("IS",x)},u.prewarm=function(){Xe().acquire(Wn)},u.setMaxParallelImageRequests=function(x){l.a.MAX_PARALLEL_IMAGE_REQUESTS=x},u.setRTLTextPlugin=function(x,s){return zr().setRTLTextPlugin(x,s)},u.setWorkerCount=function(x){jn.workerCount=x},u.setWorkerUrl=function(x){l.a.WORKER_URL=x}});var a=n;return a})})(L1);var qO=L1.exports;const WO=UO(qO),Rp=["#FF6633","#FFB399","#FF33FF","#00B3E6","#E6B333","#3366E6","#999966","#99FF99","#B34D4D","#80B300","#809900","#E6B3B3","#6680B3","#66991A","#FF99E6","#CCFF1A","#FF1A66","#E6331A","#33FFCC","#66994D","#B366CC","#4D8000","#B33300","#CC80CC","#66664D","#991AFF","#E666FF","#4DB3FF","#1AB399","#E666B3","#33991A","#CC9999","#B3B31A","#00E680","#4D8066","#809980","#E6FF80","#1AFF33","#999933","#FF3380","#CCCC00","#66E64D","#4D80CC","#9900B3","#E64D66","#4DB380","#FF4D4D","#99E6E6","#6666FF","#FFFF99"],Er={};async function Lp(t="pin4-sm-mi-plumber+f45942.png",e=null){try{const i=t!=null&&t.includes("/")?t:`/api-user/marker_icon/${t}`,r=await e.loadImage(i);if(e.hasImage(t))return;e==null||e.addImage(t,r.data,{sdf:t==null?void 0:t.includes("+sdf")})}catch(n){console.error(n)}}function GO(t){if(!(t!=null&&t.startsWith("rgba")))return t;const e=t.replace(/^rgba?\(|\s+|\)$/g,"").split(",");return`${((1<<24)+(parseInt(e[0],10)<<16)+(parseInt(e[1],10)<<8)+parseInt(e[2],10)).toString(16).slice(1)}`}Er.point=async(t={},e={},n=null)=>{var E,T,I,z,V,H,Z,ee,oe,J,Ae,ke;e||(e={}),((E=e==null?void 0:e.width)==null?void 0:E[0])==="["&&(e.width={stops:JSON.parse(e.width)}),typeof(e==null?void 0:e.width)=="string"&&(e.width-=0),typeof(e==null?void 0:e.opacity)=="string"&&(e.opacity=(e.opacity-0)*100);const i=((T=t.style)==null?void 0:T.colorAttr)||((I=t.style)==null?void 0:I.iconCls);let r={circle:"none-xl-{{marker}}+222.png",circle2:"circle-xl-{{marker}}+222.png",pin2:"pin2-xl-{{marker}}+sdf.png",pin:"pin-xl-{{marker}}+sdf.png"}[e.iconType]||(e==null?void 0:e.icon);const[a,u]=(r==null?void 0:r.split("-"))||[],l=((z=t.style)==null?void 0:z.color)||"blue";!((V=t.style)!=null&&V.iconAttr)&&(r!=null&&r.includes("{{marker}}"))&&(r=r.replace("{{marker}}","fa-star"));const g="gray",_=(Me,Le)=>`${Me==null?void 0:Me.split("+")[0]}+${Le.replace("#","")}.png`;if(t.legendAuto={icon:[],color:[]},(H=t.style)!=null&&H.iconAttr&&r){const Me=(ee=(Z=t.meta)==null?void 0:Z.columns)==null?void 0:ee.find(Ie=>{var Ye;return Ie.name===((Ye=t==null?void 0:t.style)==null?void 0:Ye.iconAttr)}),Le=(Me==null?void 0:Me.values)||await wt.get(`/api-user/gis-ir/${t.id}/${(oe=t.style)==null?void 0:oe.iconAttr}`).then(Ie=>Ie.data.rows);if(Le!=null&&Le.length){const Ie=r.replace("{{color}}",l.length?l:GO(l)||[0]).split("+")[1].split(/[.-]/)[0];Le.forEach((Ye,it)=>{var Nt;return Ye.icon=(Nt=Ye.icon)!=null&&Nt.includes("png")?Ye.icon:`${a}-${u}-${Ye.data||Ye.icon||`ub-${it}`}+${r!=null&&r.includes("circle")?"ddd-222":Ie}.png`}),r=r!=null&&r.includes("{{")?`${a}-${u}-fa-question+0c53ad.png`:r,t.legendAuto.iconText=(Me==null?void 0:Me.title)||t.style.iconAttr,Le.forEach(Ye=>t.legendAuto.icon.push(Ye)),t.legendAuto.icon.push({icon:r,text:"Не визначено"}),t.style.iconArr=["match",["get",t.style.iconAttr]].concat(Le.filter(Ye=>Ye.id).reduce((Ye,it)=>Ye.concat([it.id,it.icon]),[])).concat([r]),await Promise.all(Le.map(Ye=>Ye.icon).map(Ye=>Lp(Ye,n))),await Lp(r,n)}else r=i?"pin6-m-fa-star+{{color}}.png":`pin6-m-fa-star+${l==null?void 0:l.replace("#","")}.png`}if(r!=null&&r.includes("{{color}}")?r=r.replace("{{color}}","222"):e!=null&&e.icon&&e.iconAttr,i){const Me=(Ae=(J=t.meta)==null?void 0:J.columns)==null?void 0:Ae.find(Ie=>Ie.name===i),Le=(Me==null?void 0:Me.values)||await wt.get(`/api-user/gis-ir/${t.id}/${i}`).then(Ie=>Ie.data.rows);t.style.color=Le!=null&&Le.length?["match",["get",i]].concat(Le.filter(Ie=>Ie.id).reduce((Ie,Ye,it)=>Ie.concat([Ye.id,Ye.color||Rp[it]]),[])).concat(["#aaa"]):l,t.style.colorArr=t.style.color,t.legendAuto.colorText=(Me==null?void 0:Me.title)||i,Le.forEach(Ie=>t.legendAuto.color.push(Ie)),t.legendAuto.color.push({color:"#aaa",text:"Не визначено"}),!((ke=t.style)!=null&&ke.iconAttr)&&!(r!=null&&r.includes("+sdf"))&&r&&(Le.forEach((Ie,Ye)=>Ie.icon=_(r,Ie.color||Rp[Ye])),t.style.iconArr=["match",["get",i]].concat(Le.filter(Ie=>Ie.id).reduce((Ie,Ye)=>Ie.concat([Ye.id,Ye.icon]),[])).concat([_(r,g)]),await Promise.all(Le.map(Ie=>Ie.icon).map(Ie=>Lp(Ie,n))))}if(r&&!(r!=null&&r.includes("{"))){const Me=e!=null&&e.colorAttr?_(r,g):r;await Lp(Me,n)}const k=r!=null&&r.includes("sdf")?["interpolate",["linear"],["zoom"],14,.1,18,.2]:["interpolate",["linear"],["zoom"],14,.7,16,1];return e.iconOffset=r!=null&&r.includes("pin")?[0,r!=null&&r.includes("+sdf")?-96:-20]:null,[{id:`${t.id}`,source:t.id,type:"circle",cluster:!0,lsource:e==null?void 0:e.lsource,minzoom:(e==null?void 0:e.minzoom)!==void 0?+(e==null?void 0:e.minzoom):4,maxzoom:(r!=null&&r.includes("+sdf")||!(r!=null&&r.includes("circle"))&&!(r!=null&&r.includes("none"))?+e.iconZoom:null)||+(e==null?void 0:e.maxzoom)||24,filter:["all",["==",["geometry-type"],"Point"],["!",["has","point_count"]]],paint:{"circle-stroke-width":["case",["boolean",["feature-state","select"],!1],(e==null?void 0:e.strokeWidth)||1,["boolean",["feature-state","hover"],!1],2,(e==null?void 0:e.strokeWidth)||1],"circle-stroke-color":["case",["boolean",["feature-state","select"],!1],(e==null?void 0:e.stroke)||(e==null?void 0:e.color)||"#fff",["boolean",["feature-state","hover"],!1],"maroon",(e==null?void 0:e.stroke)||(e==null?void 0:e.color)||"#fff"],"circle-opacity":(e.iconZoom?["interpolate",["exponential",.5],["zoom"],+e.iconZoom-1,1,+e.iconZoom,r!=null&&r.includes("none")?.3:0]:null)||e.opacity||1,"circle-color":e.color||["case",["boolean",["feature-state","hover"],!1],"red","blue"],"circle-radius":(Array.isArray(e.width)?{stops:e.width}:null)||e.width||{stops:e.iconZoom?[[+e.iconZoom,4],[+e.iconZoom,8],[18,16]]:[[13,4],[15,8],[18,12]]}}}].concat(e.iconArr||e.icon?[{id:`${t.id}-5`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",minzoom:+e.iconZoom||16,filter:["all",["!",["has","point_count"]]],layout:{"icon-image":e!=null&&e.colorAttr&&e.iconArr||r,"icon-allow-overlap":!0,...e.iconOffset?{"icon-offset":e.iconOffset||!1}:{},...k?{"icon-size":k||!1}:{}},paint:{"icon-opacity":["case",["boolean",["feature-state","hover"],!1],.5,["boolean",["feature-state","select"],!1],.5,(r!=null&&r.includes("+sdf")?1:null)||(r!=null&&r.includes("circle")?.6:1)],...r!=null&&r.includes("+sdf")?{"icon-color":["case",["boolean",["feature-state","hover"],!1],"#cd0bbf",["boolean",["feature-state","select"],!1],"#8517cf",e.color||"#aa0000"]}:{}}}]:[]).concat(e.label?[{id:`${t.id}-4`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",minzoom:14,filter:["!",["has","point_count"]],layout:{"text-field":e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||8},paint:{"text-color":e["text-color"]||"#ffffff","text-halo-color":e["text-halo-color"]||"black"}}]:[]).concat(t.cluster||e.clusterMaxZoom?[{id:`${t.id}-1`,source:t.id,lsource:e==null?void 0:e.lsource,type:"circle",filter:["has","point_count"],paint:{"circle-color":["step",["get","point_count"],"#51bbd6",100,"#f1f075",750,"#f28cb1"],"circle-radius":["step",["get","point_count"],20,100,30,750,40]}},{id:`${t.id}-2`,source:t.id,lsource:e==null?void 0:e.lsource,type:"symbol",filter:["has","point_count"],layout:{"text-field":"{point_count_abbreviated}","text-font":["Open Sans Regular"],"text-size":12}}]:[])},Er.label=(t={})=>[{id:t.id,source:t.id,type:"line",layout:{"text-field":"{str_name}","text-font":["DIN Offc Pro Italic","Arial Unicode MS Regular"],"symbol-placement":"line","text-pitch-alignment":"viewport","text-max-angle":30,"text-size":{base:1,stops:[[13,12],[18,16]]}},paint:{"text-halo-width":0,"text-halo-blur":0,"text-color":"#78888a"}}],Er.polygon=async(t={},e={},n=null)=>{var a,u,l,g;const{colorAttr:i}=e,r=((a=t.style)==null?void 0:a.color)||"blue";if(e.colorAttr){n.getSource(t.id)&&n.getSource(n.getSource(t.id).setData(`${n.getSource(t.id)._data.split("&props")[0]}&props=${i}`));const _=((l=(u=t.meta)==null?void 0:u.columns.find(k=>k.name===i))==null?void 0:l.values)||await wt.get(`/api-user/gis-ir/${t.id}/${i}`).then(k=>k.data.rows);t.legendAuto={color:[]},_.forEach(k=>t.legendAuto.color.push(k)),t.legendAuto.color.push({color:"#aaa",text:"Не визначено"}),t.style.color=_?["match",["get",i]].concat(_.filter(k=>k.id).reduce((k,E,T)=>k.concat([E.id,E.color||Rp[T]]),[])).concat(["#aaa"]):r}return[{id:`${t.id}`,source:`${t.id}`,lsource:e==null?void 0:e.lsource,minzoom:(+(e==null?void 0:e.minzoom)||+(e==null?void 0:e.pointZoom)||0)-0,maxzoom:+(e==null?void 0:e.maxzoom)||24,type:"fill",filter:["all",["match",["geometry-type"],["Polygon","MultiPolygon"],!0,!1]],paint:{"fill-color":["case",["boolean",["feature-state","hover"],!1],"red",["boolean",["feature-state","select"],!1],"#c356c1",(e==null?void 0:e.color)||"#0080ff"],"fill-opacity":.5}}].concat(e!=null&&e.pointZoom?[{id:`${t.id}-5`,source:(g=t.url)!=null&&g.includes(".vmt")?`${t.id}`:`${t.id}-point`,type:"circle",minzoom:0,maxzoom:((e==null?void 0:e.pointZoom)||1)-0,paint:{"circle-color":["case",["boolean",["feature-state","hover"],!1],"red",(e==null?void 0:e.color)||"blue"],"circle-stroke-width":1,"circle-stroke-color":"#fff"}}]:[]).concat(e!=null&&e.label?[{id:`${t.id}-1`,source:t.id,type:"symbol",lsource:e==null?void 0:e.lsource,minzoom:15,layout:{"text-field":e==null?void 0:e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||{stops:[[14,4],[18,16]]}},paint:{"text-color":e["text-color"]||"#ffffff","text-halo-color":e["text-halo-color"]||"#fff","text-halo-width":e["text-halo-width"]||0}}]:[]).concat(e!=null&&e.stroke?[{id:`${t.id}-2`,source:t.id,lsource:e==null?void 0:e.lsource,minzoom:(+(e==null?void 0:e.minzoom)||+(e==null?void 0:e.pointZoom)||0)-0,maxzoom:+(e==null?void 0:e.maxzoom)||24,type:"line",paint:{"line-color":["case",["boolean",["feature-state","select"],!1],"#c356c1",e.stroke],"line-width":["case",["boolean",["feature-state","select"],!1],3,(e.width||e["line-width"]||1)-0]}}]:[])},Er.line=(t={},e={})=>[{id:t.id,source:t.id,lsource:e.lsource,type:"line",filter1:["all",["match",["geometry-type"],["LineString","MultiLineString","MultiPolygon","Polygon"],!0,!1]],minzoom:(e==null?void 0:e.minzoom)||t.minzoom||5,layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":["case",["boolean",["feature-state","select"],!1],4,e.width||e["line-width"]||1],"line-color":["case",["boolean",["feature-state","select"],!1],"#c356c1",e.color||e["line-color"]||"#c71ccb"],"line-gap-width":e["line-gap-width"]||0}}].concat(e.label?[{id:`${t.id}-4`,source:t.id,lsource:e.lsource,type:"symbol",minzoom:14,paint:{"text-color":"#111","text-halo-color":"#fff","text-halo-width":2},layout:{"symbol-placement":"line","text-letter-spacing":.2,"text-field":e.label,"text-font":["Open Sans Regular"],"text-size":e["text-size"]||15}}]:[]),Er.linestring=Er.line,Er.circle=Er.point;async function ZO(t,e,n){var l,g,_,k,E,T,I,z,V,H,Z,ee;typeof e.style=="string"&&(e.style=e.style[0]==="{"?JSON.parse(e.style):(l=window.YAML.parse(e.style))==null?void 0:l.style),(_=(g=e.style)==null?void 0:g.filter)==null||_.call(g,oe=>oe.source).forEach(oe=>{oe.lsource=`${e.id}-${oe.source}`});const i=((k=e==null?void 0:e.style)==null?void 0:k.type)||((Z=((I=(T=(E=e==null?void 0:e.meta)==null?void 0:E.geom)==null?void 0:T.geometry)==null?void 0:I.length)>2?["point"]:[((H=(V=(z=e==null?void 0:e.meta)==null?void 0:z.geom)==null?void 0:V.geometry)==null?void 0:H[0].toLowerCase())||"point"])==null?void 0:Z.map(oe=>{var J;return(J=oe==null?void 0:oe.replace)==null?void 0:J.call(oe,"multi","")})),r=Array.isArray(i)?i:[i],a=(await Promise.all(Array.isArray(e==null?void 0:e.style)?e.style.map(async oe=>{var J;return(J=Er[oe.type])==null?void 0:J.call(Er,e,oe,n)}):r.map(async oe=>{var J;return(J=Er[oe])==null?void 0:J.call(Er,e,e.style,n)}))).reduce((oe,J)=>J?oe.concat(J):oe,[]);a.forEach((oe,J)=>{oe.id=`${oe.id}-${J}`});const u=a;return(e.service==="vtile"||(ee=e.url)!=null&&ee.includes(".vmt"))&&u.forEach(oe=>{oe.layout||(oe.layout={}),oe.layout.visibility="visible",oe["source-layer"]=oe.lsource||e.data||t}),u}const YO={data(){return{layerList:[],layerObj:{},colors:Rp,activeLayer:"",addedLayersSettings:[],hoveredFeatureId:null}},computed:{interactiveSources(){return this.layerList.filter(t=>t==null?void 0:t.interactive).map(t=>t.id)}},methods:{moveLayers(t,e=this.map){e.getStyle().layers.forEach(n=>{n.id.match(t)&&e.moveLayer(n.id)})},getLayersBySourceId(t,e){return e.getStyle().layers.filter(i=>i.id.match(t))},async setVisible(t,e=!0,n={}){const i=typeof t=="object";try{const{style:r,map:a=this.map}=n,u=(t==null?void 0:t.id)||t,l=i?t:await this.getLayerById(u);if(!(l!=null&&l.id))throw new Error("MixinError: Layer has no id");const g=a.getStyle().layers.filter(_=>_.id.match(u));!g.length||r?await this.addToLayers({...l,...(n==null?void 0:n.data)||{},interactive:(l==null?void 0:l.interactive)!==void 0?l==null?void 0:l.interactive:!0,visible:e},{map:a,cb:n==null?void 0:n.onAddLayer}):(this.layerList=this.layerList.map(_=>_.id===l.id?{..._,visible:e}:_),g.forEach(_=>{a.setLayoutProperty(_.id,"visibility",e?"visible":"none")})),n!=null&&n.cb&&await(n==null?void 0:n.cb(l))}catch(r){console.error(r),!n.onAddLayer||n.onAddLayer({data:i?t:{id:t},message:r.message,type:"error"})}},async addToLayers(t,e={}){try{const{map:n=this==null?void 0:this.map}=e;this.layerList.find(r=>r.id===t.id)||(this.layerList=this.layerList.concat(t)),this.layerObj={...this.layerObj,[t.id]:t},t.visible?t!=null&&t.layer?await this.addVectorLayer(t,n):t.service==="vtile"?await this.addVtileLayer(t,n):t.service==="geojson"?await this.addGeojsonLayers(t,n):this.addRasterLayer(t,n):n.getStyle().layers.forEach(async r=>{r.source===t.id&&await n.setLayoutProperty(r.id,"visibility","none")}),!(e!=null&&e.cb&&(t!=null&&t.visible))||await e.cb({data:t,type:"success"}),this.moveLayers("gl-draw")}catch(n){!e.cb||e.cb({data:t,message:n.message,type:"error"}),console.error(n)}},addRasterLayer(t,e){e.addSource(t.id,{type:"raster",tiles:[(t==null?void 0:t.url)||(t==null?void 0:t.url1)],tileSize:256,...t!=null&&t.scheme?{scheme:t==null?void 0:t.scheme}:{}}),e.addLayer({id:t.id,type:"raster",source:t.id,minzoom:0,maxzoom:(t==null?void 0:t.maxzoom)||22})},async addVtileLayer(t){await this.createGeometryLayer({data:t},"vector")},async addVectorLayer(t,e){const{data:n}=await wt.get(t.layer),i={...t,source:t.id,layers:[]};Object.keys(n.sources).forEach(async r=>{await e.addSource(t.id,{type:n.sources[r].type,maxzoom:n.sources[r].maxzoom,url:n.sources[r].url})}),await n.layers.forEach(async r=>{await e.addLayer({...r,source:t.id,id:`${r.id}-${t.id}`}),i.layers=await i.layers.concat(`${r.id}-${t.id}`)})},async addGeojsonLayers(t){const e=n=>{throw this.$notify({type:"error",title:"Відсутня геометрія у обраному шарі",message:n,position:"bottom-right"}),this.layerList=this.layerList.filter(i=>i.id!==t.id),new Error(n)};if(typeof(t==null?void 0:t.geojson)=="object"){this.createGeometryLayer({data:t,geojson:t.geojson},"geojson");return}try{const n=await wt.get((t==null?void 0:t.geojson)||(t==null?void 0:t.url)),i=await n.data;if(n.statusText==="OK")this.createGeometryLayer({data:t,geojson:i},"geojson");else throw new Error((i==null?void 0:i.message)||(n==null?void 0:n.statusText)||"Error addGeojson layer")}catch(n){e(n.message),console.error(n)}},async createGeometryLayer({data:t,geojson:e},n){var l,g,_,k,E;const{map:i}=this,r=await ZO(t.id,this.layerList.find(T=>T.id==t.id),i),a={type:n,cluster:((l=t==null?void 0:t.style)==null?void 0:l.cluster)||!1,clusterMaxZoom:((g=t==null?void 0:t.style)==null?void 0:g.clusterMaxZoom)||14};n==="vector"&&(a.tiles=[`${window.location.origin}${(t==null?void 0:t.geojson)||(t==null?void 0:t.url)}${t!=null&&t.version?`?ver=${t.version}`:""}${t.props?`&props=${t.props}`:""}${(_=t==null?void 0:t.style)!=null&&_.pointZoom?`&pointZoom=${t.style.pointZoom}`:""}`]),n==="geojson"&&(a.data=e||`${window.location.origin}${(t==null?void 0:t.geojson)||(t==null?void 0:t.url)}`),i.addSource(t.id,a),r.forEach(T=>{var z;const I={...T,source:t.id,maxzoom:+(T==null?void 0:T.maxzoom)||24,minzoom:+(T==null?void 0:T.minzoom)||0,cluster:!1,clusterMaxZoom:2};i.addLayer(I),i.moveLayer(T.id),(z=T==null?void 0:T.layout)!=null&&z["text-field"]||this.apiLayersHover(T.id,t.id,i),this.addedLayersSettings=this.addedLayersSettings.concat(I)});const u=r.map(T=>T.type).filter(T=>T&&T!=="symbol");(E=(k=t==null?void 0:t.meta)==null?void 0:k.geom)!=null&&E.geometry&&t.meta.geom.geometry.filter(I=>!u.includes(this.geometryByType(I,!0))).forEach(I=>{this.createStyleObj({type:I,style:t.style},t.id)})},async setStyle(t,e,n=this.map){const i=(t==null?void 0:t.id)||t;n.getStyle().layers.forEach(a=>{a.source===i&&n.removeLayer(a.id)}),n.getSource(i)&&(n==null||n.removeSource(i)),this.layerList=this.layerList.map(a=>(a.id===i&&(a.style=e),a));const r=this.layerList.find(a=>a.id===i);this.addToLayers(r)},setLayerData({source:t,data:e}){const n=(t==null?void 0:t.id)||t;this.layerList=this.layerList.map(i=>i.id===n?{...i,...e}:i),this.layerObj={...this.layerObj,[t]:{...this.layerObj[t],...e}}},geometryByType(t,e=!1){if(t==="fill"||t==="Polygon"||t==="MultiPolygon")return e?"fill":"Polygon";if(t==="circle"||t==="Point"||t==="MultiPoint")return e?"circle":"Point";if(t==="line"||t==="LineString"||t==="MultiLineString")return e?"line":"LineString"},async removeLayer(t,e=this.map){const n=(t==null?void 0:t.id)||t;this.layerList=this.layerList.filter(i=>i.id!==n),await e.getStyle().layers.forEach(async i=>{i.source===n&&await e.removeLayer(i.id)}),await e.removeSource(n)},async reloadUrl(t,e=this.map){const n=(t==null?void 0:t.id)||t;await e.getStyle().layers.forEach(i=>{i.id===n&&e.removeLayer(i.id)}),await e.removeSource(n),await this.setVisible(t,!0)},async setFilter(t,e){const n=this.layerObj[t],i=await this.map.getSource(t);if(n.service==="vtile")await i.setTiles([`${window.location.origin}${n.geojson||n.url}${n.url.includes("?")?"&":"?"}filter=${e}${n.props?`&props=${n.props}`:""}`]);else if(n.service==="geojson"){const{data:r}=await wt.get((n==null?void 0:n.geojson)||`${n==null?void 0:n.url}?filter=${e}`);await this.map.getSource(t).setData(r)}},async getLayerById(t,e=null){var i;const n=(t==null?void 0:t.id)||t;try{const r=(i=this.layerList)==null?void 0:i.find(u=>u.id===n);if(r)return r;const a=await wt.get(`/api-user/gis-ir/${n}${t!=null&&t.service?`?service=${t==null?void 0:t.service}`:""}`);if(a.statusText==="OK"){const u=await a.data;return!e||await e(u),u}return this.$notify({type:"warning",message:`Шар ${n} не було знайдено!`}),null}catch(r){this.$notify({type:"warning",message:`Шар ${n} не було знайдено!`}),console.error(r)}},createStyleObj({type:t,style:e},n){const i=this.geometryByType(t,!0);if(!i)throw Error("Geomery type ERROR: Error adding missing layers");const r=`${n}-${i}`;if(this.map.getStyle().layers.find(u=>u.id===r))return;const a={id:r,type:i,source:n,"source-layer":n,layout:{},paint:{[`${i}-color`]:["case",["boolean",["feature-state","hover"],!1],"red",(e==null?void 0:e.color)||"#444e3d"],[`${i}-opacity`]:e!=null&&e.opacity||i==="fill"?.5:1},filter:["all",["==",["geometry-type"],this.geometryByType(t)]]};this.map.addLayer(a),this.addedLayersSettings=this.addedLayersSettings.concat(a),this.apiLayersHover(r,n,this.map)},apiLayersHover(t,e,n){const i=n.getSource(e),r=()=>{const a={source:e,id:this.hoveredFeatureId};return i.type==="vector"&&(a.sourceLayer=e),a};n.on("mousemove",t,a=>{a.features.length>0&&(this.hoveredFeatureId!==null&&n.setFeatureState(r(),{hover:!1}),this.hoveredFeatureId=a.features[0].id,n.setFeatureState(r(),{hover:!0}))}),n.on("mouseleave",t,()=>{this.hoveredFeatureId!==null&&n.setFeatureState(r(),{hover:!1}),this.hoveredFeatureId=null})},async changeBaseLayer(t,e=!0,n=!0){await this.setVisible(t,e);const i=(t==null?void 0:t.id)||t;i!==this.activeLayer&&(n&&this.activeLayer&&await this.setVisible(this.activeLayer,!1),this.map.getStyle().layers.forEach(r=>{r.source!==i&&r.type!=="background"&&this.map.moveLayer(r.id)}),this.activeLayer=i)},async refreshLayer(t,e=this.map){const n=(t==null?void 0:t.id)||t;await e.getStyle().layers.forEach(i=>{i.source===n&&e.removeLayer(i.id)}),await e.removeSource(n),this.layers=await this.layers.filter(i=>i.id!==n),await this.setVisible(typeof t=="object"?t:n)}}},XO={props:{objectData:{type:Array,default:()=>[]},object:{type:Object,default:()=>null},mapRef:{type:Object,default:()=>null}},computed:{currentLayer(){var n;const t=(n=this.object)==null?void 0:n.source;return this.mapRef.layerObj[t]},popupPosition(){var e,n,i;return((i=(n=(e=this.currentLayer)==null?void 0:e.setting)==null?void 0:n.popup)==null?void 0:i.position)||"horizontal"},popupWidth(){var e,n,i;return`${((i=(n=(e=this.currentLayer)==null?void 0:e.setting)==null?void 0:n.popup)==null?void 0:i.width)||240}px`},popupRows(){return this.objectData.filter(t=>t.column!=="image")},positionIsVertical(){return this.popupPosition==="vertical"}},methods:{rowValue(t){return t.value},rowTitle(t){return t.title}}},KO={key:0,class:"vsTailwind map-popup__vertical"},JO={class:"mb-1"},QO={class:"text-sm"},ez={key:1,class:"map__popup-body"},tz=["innerHTML"],nz={key:1};function iz(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",{class:"map-popup",style:S.normalizeStyle({"max-width":a.popupWidth,width:a.popupWidth})},[a.positionIsVertical?(S.openBlock(),S.createElementBlock("div",KO,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.popupRows,u=>(S.openBlock(),S.createElementBlock("div",{class:"border-b py-1 last:border-none last:pt-1 last:pb-0",key:a.rowTitle(u)},[S.createElementVNode("strong",JO,S.toDisplayString(a.rowTitle(u)),1),S.createElementVNode("div",QO,S.toDisplayString(a.rowValue(u)),1)]))),128))])):(S.openBlock(),S.createElementBlock("table",ez,[S.createElementVNode("tbody",null,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.popupRows,u=>S.withDirectives((S.openBlock(),S.createElementBlock("tr",{key:a.rowTitle(u),class:"map__popup-body-item"},[S.createElementVNode("td",null,S.toDisplayString(a.rowTitle(u)),1),a.rowValue(u)?(S.openBlock(),S.createElementBlock("td",{key:0,innerHTML:a.rowValue(u)},null,8,tz)):(S.openBlock(),S.createElementBlock("td",nz,e[0]||(e[0]=[S.createElementVNode("div",{class:"text-red-500"}," Не визначено ",-1)])))])),[[S.vShow,!a.rowValue(u).includes("id")]])),128))])]))],4)}const rz=_t(XO,[["render",iz],["__scopeId","data-v-14698eb6"]]),N1={width:200,show:!0,position:"horizontal"},sz={components:{VsPopupBody:rz},props:{aviableFields:{type:Array,default:()=>[]},mapRef:{type:[Object,Array],default:()=>{}},object:{type:[Object,Array],default:()=>{}}},data(){return{objectData:[],popupSettings:N1}},computed:{getImage(){return this.objectData.find(t=>t.column==="image")||null},currentLayer(){var t;return(t=this.$parent.layerList)==null?void 0:t.find(e=>{var n;return(e==null?void 0:e.id)===((n=this.object)==null?void 0:n.source)})}},watch:{async object(t,e){t!==null&&(t==null?void 0:t.id)!==(e==null?void 0:e.id)||!(t!=null&&t.id)?await this.getFormatObject(t):t===null&&(this.objectData=[])}},methods:{async getFormatObject(t){var g,_,k,E,T,I;if(!t)return;const e=Object.keys(t.properties).filter(z=>!z.match("__text")&&!["id"].includes(z)),{currentLayer:n}=this;if((g=n==null?void 0:n.setting)!=null&&g.popup&&(this.popupSettings=(n==null?void 0:n.setting.popup)||N1),!(n!=null&&n.meta)){const z=e.map(V=>({title:V,value:t.properties[V]}));this.objectData=[...z,{value:((_=t.properties)==null?void 0:_.image)||"",title:"Фото",column:"image"}];return}const i=n.meta.columns,r=e.map(z=>{var oe,J,Ae,ke;const V={},Z=Object.assign({values:[]},i.find(Me=>Me.name===z));typeof Z.values!="object"&&console.warn(`Warning: Layer ${t.source} has key "values" which is not an object in meta!`);const ee=Z!=null&&Z.values&&((oe=Z==null?void 0:Z.values)==null?void 0:oe.find(Me=>(Me==null?void 0:Me.id)==t.properties[z]))||null;return V.value=(Z==null?void 0:Z.format)==="select"?this.formatBadge({text:(ee==null?void 0:ee.text)||((J=t.properties)==null?void 0:J[`${z}__text`])||((Ae=t.properties)==null?void 0:Ae[z])||"-",color:(ee==null?void 0:ee.color)||"#1989FA"}):(ee==null?void 0:ee.text)||((ke=t.properties)==null?void 0:ke[`${z}__text`])||t.properties[z],V.column=z,V.title=(Z==null?void 0:Z[window==null?void 0:window.lang])||(Z==null?void 0:Z.ua)||(Z==null?void 0:Z.title)||z,V});this.objectData=[...r,{value:((k=t.properties)==null?void 0:k.image)||"",title:"Фото",column:"image"}];const a=(T=(E=n==null?void 0:n.setting)==null?void 0:E.popup)==null?void 0:T.popup,u=typeof a=="string"?a==null?void 0:a.split(","):a,l=[...this.aviableFields,...((I=n==null?void 0:n.popup)==null?void 0:I.split(","))||[],...u||[]];this.objectData=l.length?this.objectData.filter(z=>l.includes(z.column)||l.includes(z.title)):[]},noInfoObject(){var i,r,a,u,l;if(!this.object)return"Інформація відсутня";const{currentLayer:t}=this,e=((r=(i=t==null?void 0:t.meta)==null?void 0:i.columns)==null?void 0:r.find(g=>(g==null?void 0:g.meta)==="title"))||((a=t==null?void 0:t.meta)==null?void 0:a.columns[0])||null;return{title:(t==null?void 0:t.name)||(t==null?void 0:t.id)||((u=this.object)==null?void 0:u.sourceLayer)||((l=this.object)==null?void 0:l.source)||"Дані по шару не знайдено",column:e}},formatBadge(t){const e=(t==null?void 0:t.text)||"-";return t!=null&&t.color?`<span >${e}</span>`:e}}},oz={key:0},az={key:0},lz=["src","alt"],cz={key:1},uz={class:"text-left text-sm m-b-sm"},hz={key:1,class:"text-center"};function dz(t,e,n,i,r,a){var l,g,_,k,E,T,I,z,V,H,Z;const u=S.resolveComponent("VsPopupBody");return S.openBlock(),S.createElementBlock("div",{class:S.normalizeClass((((l=r.popupSettings)==null?void 0:l.position)||"horizontal")+"-position")},[r.objectData.filter(ee=>ee.column!=="image").length?(S.openBlock(),S.createElementBlock("div",oz,[a.getImage&&((g=a.getImage)!=null&&g.value)?(S.openBlock(),S.createElementBlock("div",az,[S.createElementVNode("img",{class:"popup-image",src:"files/"+a.getImage.value,alt:a.getImage.column},null,8,lz)])):S.createCommentVNode("",!0),S.createVNode(u,{"object-data":r.objectData,object:n.object,mapRef:n.mapRef},null,8,["object-data","object","mapRef"])])):(S.openBlock(),S.createElementBlock("div",cz,[(_=a.noInfoObject())!=null&&_.column?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[S.createElementVNode("b",uz,S.toDisplayString(a.noInfoObject().title),1),S.createElementVNode("div",null,[S.createElementVNode("b",null,S.toDisplayString(((E=(k=a.noInfoObject())==null?void 0:k.column)==null?void 0:E.ua)||((I=(T=a.noInfoObject())==null?void 0:T.column)==null?void 0:I.title))+":",1),S.createTextVNode(" "+S.toDisplayString(((Z=(z=n.object)==null?void 0:z.properties)==null?void 0:Z[(H=(V=a.noInfoObject())==null?void 0:V.column)==null?void 0:H.name])||"-"),1)])],64)):(S.openBlock(),S.createElementBlock("div",hz,S.toDisplayString(a.noInfoObject().title),1))]))],2)}const pz=_t(sz,[["render",dz],["__scopeId","data-v-180f4367"]]),{Map:fz,NavigationControl:mz,Popup:gz}=WO,yz={mixins:[YO],components:{VsMapPopup:pz},props:{popupVisible:{type:Boolean,default:()=>!0},map:{type:Object,default:()=>null},height:{type:String,default:()=>"400px"}},data(){var t,e,n,i;return{mapId:`gis-map-${Math.floor(Math.random()*1e3)}`,features:[],katottg:((e=(t=window==null?void 0:window.setting)==null?void 0:t.map)==null?void 0:e.katottg)||((i=(n=window==null?void 0:window.setting)==null?void 0:n.map)==null?void 0:i.city_katottg),popup:{geometry:null,map:null},cityBbox:null}},async mounted(){this.initMap()},computed:{mapRef(){return this}},methods:{initMap(){const t={version:8,glyphs:"https://fonts.openmaptiles.org/{fontstack}/{range}.pbf",sources:{},layers:[]},e=new fz({container:this.mapId,style:t,center:[0,0],zoom:1,interactive:!0});e.addControl(new mz({visualizePitch:!0})),window==null||window.addEventListener("resize",()=>{e.resize()}),e.on("load",this.onMapLoad)},async onMapLoad(t){const e=t.target;e.resize();const n={id:"graymap",name:"Сіра карта",url:"https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png",service:"TMS",category:"Базові карти",attribution:"© <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a>, © <a href='https://carto.com/attributions'>CARTO</a>",bounds1:"ua",image:"https://basemaps.cartocdn.com/light_all/10/601/348.png",position:0,owner:"OSM",basemap:!0};await this.$emit("update:map",e),await this.setVisible(n,!0),this.$emit("load",e),this.createPopup(),this.createBoundsLayers(),this.createAtuLayer()},createPopup(){var n,i,r,a,u,l;const{map:t}=this,e=["measure","katottg","geometry","mapbox-gl-draw-hot","mapbox-gl-draw-cold"];this.popup.map=new gz({closeOnClick:!1}).setDOMContent((i=(n=this==null?void 0:this.$refs)==null?void 0:n.popup)==null?void 0:i.$el),t&&(t.on("mousemove",g=>{var k,E;const _=t.queryRenderedFeatures(g.point).filter(T=>{var V,H,Z;const I=this.layerList.find(ee=>ee.id===T.source),z=((H=(V=I==null?void 0:I.setting)==null?void 0:V.popup)==null?void 0:H.show)===void 0?!0:I.setting.popup.show;if((this.interactiveSources.includes(T.source)&&!((Z=T.properties)!=null&&Z.cluster)&&z||!I&&Object.keys(T.properties).length)&&!e.includes(T.source))return T}).filter(T=>{var I,z;return!((z=(I=T.layer)==null?void 0:I.layout)!=null&&z["text-field"])});_.length&&this.popupVisible?(this.features=(_==null?void 0:_[0])||null,(k=this.popup.map)==null||k.setLngLat(Object.values(g.lngLat)).addTo(t),t.getCanvas().style.cursor=_.length?"pointer":"grab"):(this.features=null,(E=this.popup.map)==null||E.remove()),this.$emit("mouseMove",{event:g,features:_})}),t.on("touchend",this.handleMapClick),t.on("click",this.handleMapClick),t.on("dblclick",g=>{const _=t.queryRenderedFeatures(g.point);this.$emit("dbclick",{features:_,event:g})}),(l=(u=(a=(r=this==null?void 0:this.$refs)==null?void 0:r.popup)==null?void 0:a.$el)==null?void 0:u.parentElement)==null||l.addEventListener("mouseenter",()=>{var g;(g=this.popup.map)==null||g.remove()}))},createBoundsLayers(){const{map:t}=this;t&&(t.addSource("bounds-dataset",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),t.addLayer({id:"bounds-dataset-line",type:"line",source:"bounds-dataset",layout:{},paint:{"line-color":"#a91a9e","line-width":2}}))},handleMapClick(t){if(!this.map)return;const e=this.map.queryRenderedFeatures(t.point);if(!e.length)return;const n=e.filter(i=>this.interactiveSources.includes(i==null?void 0:i.source));this.$emit("mapClick",n)},homeZoom(){const{map:t}=this,e=this.cityBbox?this.cityBbox:[22.1352,44.3909,40.2276,52.3791];t==null||t.fitBounds(e,{duration:0,padding:10})},async createAtuLayer(){try{const t=this.katottg,{map:e}=this;if(!e){console.warn("Map error: Map hasn't loaded");return}const{data:n}=await wt.get(`https://data.gki.com.ua/api-user/atu/${t}`),i=z1(n);this.cityBbox=i,e.addSource("atu",{type:"geojson",data:n}),e.addLayer({id:"atu",type:"line",source:"atu",paint:{"line-color":"#3b82f6","line-width":2}})}catch(t){console.error(t)}}}},_z={class:"relative"},bz=["id"];function xz(t,e,n,i,r,a){const u=S.resolveComponent("VsMapPopup");return S.openBlock(),S.createElementBlock("div",_z,[S.createElementVNode("div",{id:r.mapId,style:S.normalizeStyle({height:n.height})},null,12,bz),S.createVNode(u,{ref:"popup",object:r.features,"map-ref":a.mapRef},null,8,["object","map-ref"])])}const vz=_t(yz,[["render",xz]]),Qs="widget-map-source",wz={components:{VsMap:vz},props:{geometry:{type:Object,default:()=>null},zoom:{type:String,default:()=>"50"}},data(){return{map:null}},mounted(){this.geometry&&this.initGeometryLayer()},watch:{geometry(){console.log(this.zoom),this.initGeometryLayer()}},methods:{initMap(){this.geometry&&this.map&&this.initGeometryLayer()},handleMapLoad(){this.initMap()},initGeometryLayer(){const{map:t}=this;if(!t)return;const e=this.formatGeojson(this.geometry),n=t.getSource(Qs);if(this.zoomToGeometry(e),n){n.setData(e);return}t.addSource(Qs,{type:"geojson",data:e}),t.addLayer({id:`${Qs}-point`,type:"circle",source:Qs,paint:{"circle-radius":10,"circle-color":"#F84C4C"},filter:["==","$type","Point"]}),t.addLayer({id:`${Qs}-polygon`,type:"fill",source:Qs,layout:{},paint:{"fill-color":"#0080ff","fill-opacity":.5},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Qs}-polygon-line`,type:"line",source:Qs,layout:{},paint:{"line-color":"#0080ff","line-width":2},filter:["==","$type","Polygon"]}),t.addLayer({id:`${Qs}-line`,type:"line",source:Qs,layout:{},paint:{"line-color":"#0080ff","line-width":3},filter:["==","$type","LineString"]})},formatGeojson(t){let e=t;const n=t==null?void 0:t.type;if(Array.isArray(t))return R1(t);if(!n)throw new Error("Unknown geometry type!");return n==="FeatureCollection"?t:(n==="Feature"&&(e=[t]),!["FeatureCollection","Feature"].includes(n)&&(e=[HO(t)]),R1(e))},zoomToGeometry(t){const{map:e}=this,n=z1(t);e.fitBounds(n,{zoom:this.zoom,padding:30,duration:0})}}};function kz(t,e,n,i,r,a){const u=S.resolveComponent("VsMap");return S.openBlock(),S.createElementBlock("div",null,[S.createVNode(u,{map:r.map,"onUpdate:map":e[0]||(e[0]=l=>r.map=l),onLoad:a.handleMapLoad},null,8,["map","onLoad"])])}const Sz=_t(wz,[["render",kz]]),st=(t,e=1e4)=>(t=parseFloat(t+"")||0,Math.round((t+Number.EPSILON)*e)/e),ny=function(t){if(!(t&&t instanceof Element&&t.offsetParent))return!1;const e=t.scrollHeight>t.clientHeight,n=window.getComputedStyle(t).overflowY,i=n.indexOf("hidden")!==-1,r=n.indexOf("visible")!==-1;return e&&!i&&!r},Np=function(t,e=void 0){return!(!t||t===document.body||e&&t===e)&&(ny(t)?t:Np(t.parentElement,e))},eo=function(t){var e=new DOMParser().parseFromString(t,"text/html").body;if(e.childElementCount>1){for(var n=document.createElement("div");e.firstChild;)n.appendChild(e.firstChild);return n}return e.firstChild},iy=t=>`${t||""}`.split(" ").filter(e=>!!e),to=(t,e,n)=>{t&&iy(e).forEach(i=>{t.classList.toggle(i,n||!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 Ez{constructor(e,{start:n=()=>!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=n,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 n=new Sc(e);this.currentPointers.some(i=>i.id===n.id)||this.triggerPointerStart(n,e)&&(window.addEventListener("mousemove",this.onMove),window.addEventListener("mouseup",this.onPointerEnd),window.addEventListener("blur",this.onWindowBlur))}onTouchStart(e){for(const n of Array.from(e.changedTouches||[]))this.triggerPointerStart(new Sc(n),e);window.addEventListener("blur",this.onWindowBlur)}onMove(e){const n=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(),n)}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 n of Array.from(e.changedTouches||[]))this.triggerPointerEnd(e,new Sc(n))}triggerPointerStart(e,n){return!!this.startCallback(n,e,this.currentPointers.slice())&&(this.currentPointers.push(e),this.startPointers.push(e),!0)}triggerPointerEnd(e,n){const i=this.currentPointers.findIndex(r=>r.id===n.id);i<0||(this.currentPointers.splice(i,1),this.startPointers.splice(i,1),this.endCallback(e,n,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 B1(t,e){return e?Math.sqrt(Math.pow(e.clientX-t.clientX,2)+Math.pow(e.clientY-t.clientY,2)):0}function F1(t,e){return e?{clientX:(t.clientX+e.clientX)/2,clientY:(t.clientY+e.clientY)/2}:t}const ry=t=>typeof t=="object"&&t!==null&&t.constructor===Object&&Object.prototype.toString.call(t)==="[object Object]",Cr=(t,...e)=>{const n=e.length;for(let i=0;i<n;i++){const r=e[i]||{};Object.entries(r).forEach(([a,u])=>{const l=Array.isArray(u)?[]:{};t[a]||Object.assign(t,{[a]:l}),ry(u)?Object.assign(t[a],Cr(l,u)):Array.isArray(u)?Object.assign(t,{[a]:[...u]}):Object.assign(t,{[a]:u})})}return t},sy=function(t,e){return t.split(".").reduce((n,i)=>typeof n=="object"?n[i]:void 0,e)};class Bp{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 n of Object.getOwnPropertyNames(Object.getPrototypeOf(this)))n.startsWith("on")&&typeof this[n]=="function"&&(this[n]=this[n].bind(this))}setOptions(e){this.options=e?Cr({},this.constructor.defaults,e):{};for(const[n,i]of Object.entries(this.option("on")||{}))this.on(n,i)}option(e,...n){let i=sy(e,this.options);return i&&typeof i=="function"&&(i=i.call(this,this,...n)),i}optionFor(e,n,i,...r){let a=sy(n,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=sy(n,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 n=this.options.classes;return n&&n[e]||""}localize(e,n=[]){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<n.length;i++)e=e.split(n[i][0]).join(n[i][1]);return e=e.replace(/\{\{(.*?)\}\}/g,(i,r)=>r)}on(e,n){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(n)||a.push(n),this.events.set(r,a)})}off(e,n){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(n);u>-1&&a.splice(u,1)}})}emit(e,...n){[...this.events.get(e)||[]].forEach(i=>i(this,...n)),e!=="*"&&this.emit("*",e,...n)}}Object.defineProperty(Bp,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(Bp,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{}});class oy extends Bp{constructor(e={}){super(e),Object.defineProperty(this,"plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}})}attachPlugins(e={}){const n=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]):n.set(i,new r(this,a||{}))}for(const[i,r]of n)this.plugins[i]=r,r.attach()}detachPlugins(e){e=e||Object.keys(this.plugins);for(const n of e){const i=this.plugins[n];i&&i.detach(),delete this.plugins[n]}return this.emit("detachPlugins"),this}}var An;(function(t){t[t.Init=0]="Init",t[t.Error=1]="Error",t[t.Ready=2]="Ready",t[t.Panning=3]="Panning",t[t.Mousemove=4]="Mousemove",t[t.Destroy=5]="Destroy"})(An||(An={}));const Po=["a","b","c","d","e","f"],V1={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"},Cz={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:V1},$1='<circle cx="25" cy="25" r="20"></circle>',ay='<div class="f-spinner"><svg viewBox="0 0 50 50">'+$1+$1+"</svg></div>",Tr=t=>t&&t!==null&&t instanceof Element&&"nodeType"in t,kn=(t,e)=>{t&&iy(e).forEach(n=>{t.classList.remove(n)})},Ct=(t,e)=>{t&&iy(e).forEach(n=>{t.classList.add(n)})},Fp={a:1,b:0,c:0,d:1,e:0,f:0},Tz=1e5,Vp=1e4,ps="mousemove",j1="drag",U1="content",fs="auto";let ly=null,cy=null;class ua extends oy{get fits(){return this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1}get isTouchDevice(){return cy===null&&(cy=window.matchMedia("(hover: none)").matches),cy}get isMobile(){return ly===null&&(ly=/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)),ly}get panMode(){return this.options.panMode!==ps||this.isTouchDevice?j1:ps}get panOnlyZoomed(){const e=this.options.panOnlyZoomed;return e===fs?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:n}=this.current;return Math.sqrt(e*e+n*n)||1}get targetScale(){const{a:e,b:n}=this.target;return Math.sqrt(e*e+n*n)||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:n}=this,i=Math.max(e.height/n.fitHeight,e.width/n.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 n=e=="e"||e==="f"?1e-4:1e-5;if(Math.abs(this.target[e]-this.current[e])>n)return!1}return!(!this.ignoreBounds&&!this.checkBounds().inBounds)}constructor(e,n={},i={}){var r;if(super(n),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:An.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=eo(ay);!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,n=this.cn(U1);let i=this.option(U1)||e.querySelector(`.${n}`);if(i||(i=e.querySelector("img,picture")||e.firstElementChild,i&&Ct(i,n)),i instanceof HTMLPictureElement&&(i=i.querySelector("img")),!i)throw new Error("No content found");this.content=i}onLoad(){const{spinner:e,container:n,state:i}=this;e&&(e.remove(),this.spinner=null),this.option("spinner")&&n.classList.remove(this.cn("isLoading")),this.emit("afterLoad"),i===An.Init?this.enable():this.updateMetrics()}onError(){this.state!==An.Destroy&&(this.spinner&&(this.spinner.remove(),this.spinner=null),this.stop(),this.detachEvents(),this.state=An.Error,this.emit("error"))}getNextScale(e){const{fullScale:n,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*(n-u)?n:u;break;case"iterateZoom":let g=[1,n,a].sort((k,E)=>k-E),_=g.findIndex(k=>k>i+1e-5);l=g[_]||1}return l}attachObserver(){var e;const n=()=>{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||(n()?(this.onResize(),this.isMobile&&(this.updateTimer=setTimeout(()=>{n()&&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 Ez(e,{start:this.onPointerDown,move:this.onPointerMove,end:this.onPointerUp}),document.addEventListener(ps,this.onMouseMove)}detachEvents(){var e;const{container:n}=this;n.removeEventListener("click",this.onClick,{passive:!1,capture:!1}),n.removeEventListener("wheel",this.onWheel,{passive:!1}),(e=this.pointerTracker)===null||e===void 0||e.stop(),this.pointerTracker=null,document.removeEventListener(ps,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,n=this.option("maxVelocity");for(const i of Po)e?(this.velocity[i]*=1-e,n&&!this.isScaling&&(this.velocity[i]=Math.max(Math.min(this.velocity[i],n),-1*n)),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,n=0){const{current:i}=this,r=i.e+e,a=i.f+n,u=this.getBounds(),{x:l,y:g}=u,_=l.min,k=l.max,E=g.min,T=g.max;let I=0,z=0;return _!==1/0&&r<_?I=_-r:k!==1/0&&r>k&&(I=k-r),E!==1/0&&a<E?z=E-a:T!==1/0&&a>T&&(z=T-a),Math.abs(I)<1e-4&&(I=0),Math.abs(z)<1e-4&&(z=0),Object.assign(Object.assign({},u),{xDiff:I,yDiff:z,inBounds:!I&&!z})}clampTargetBounds(){const{target:e}=this,{x:n,y:i}=this.getBounds();n.min!==1/0&&(e.e=Math.max(e.e,n.min)),n.max!==1/0&&(e.e=Math.min(e.e,n.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:n,contentRect:i}=this,{fitWidth:r,fitHeight:a,fullWidth:u,fullHeight:l}=i;let g=u,_=l;if(this.option("zoom")||this.angle!==0){const k=!(n instanceof HTMLImageElement)&&(window.getComputedStyle(n).maxWidth==="none"||window.getComputedStyle(n).maxHeight==="none"),E=k?u:r,T=k?l:a,I=this.getMatrix(e),z=new DOMPoint(0,0).matrixTransform(I),V=new DOMPoint(0+E,0).matrixTransform(I),H=new DOMPoint(0+E,0+T).matrixTransform(I),Z=new DOMPoint(0,0+T).matrixTransform(I),ee=Math.abs(H.x-z.x),oe=Math.abs(H.y-z.y),J=Math.abs(Z.x-V.x),Ae=Math.abs(Z.y-V.y);g=Math.max(ee,J),_=Math.max(oe,Ae)}return{contentWidth:g,contentHeight:_}}setEdgeForce(){if(this.ignoreBounds||this.isDragging||this.panMode===ps||this.targetScale<this.scale)return this.isBouncingX=!1,void(this.isBouncingY=!1);const{target:e}=this,{x:n,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,n.min!==1/0&&(this.target.e=Math.max(e.e,n.min)),n.max!==1/0&&(this.target.e=Math.min(e.e,n.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,n=new DOMMatrixReadOnly(window.getComputedStyle(e).transform);for(const i of Po)this.current[i]=this.target[i]=n[i];this.updateMetrics(),this.attachObserver(),this.attachEvents(),this.state=An.Ready,this.emit("ready")}onClick(e){var n;e.type==="click"&&e.detail===0&&(this.dragOffset.x=0,this.dragOffset.y=0),this.isDragging&&((n=this.pointerTracker)===null||n===void 0||n.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&&Tr(u)?u.dataset:null;if(l){const I=l.panzoomChange,z=l.panzoomAction;if((I||z)&&e.preventDefault(),I){let V={};try{V=JSON.parse(I)}catch{console&&console.warn("The given data was not valid JSON")}return void this.applyChange(V)}if(z)return void(this[z]&&this[z]())}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(),_=this.dragStart;if(_.time&&!this.canZoomOut()&&(Math.abs(g.x-_.x)>2||Math.abs(g.y-_.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),T=this.option("dblClick",e);T?(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(T)),this.clicks=0,this.clickTimer=null},350))):(this.emit("click",e),!e.defaultPrevented&&E&&k(E))}addTrackingPoint(e){const n=this.trackingPoints.filter(i=>i.time>Date.now()-100);n.push(e),this.trackingPoints=n}onPointerDown(e,n,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===ps&&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(n),this.emit("touchStart",e)),!0}onPointerMove(e,n,i){if(this.option("touch",e)===!1||!this.isDragging||n.length<2&&this.panOnlyZoomed&&st(this.targetScale)<=st(this.minScale)||(this.emit("touchMove",e),e.defaultPrevented))return;this.addTrackingPoint(n[0]);const{content:r}=this,a=F1(i[0],i[1]),u=F1(n[0],n[1]);let l=0,g=0;if(n.length>1){const oe=r.getBoundingClientRect();l=a.clientX-oe.left-.5*oe.width,g=a.clientY-oe.top-.5*oe.height}const _=B1(i[0],i[1]),k=B1(n[0],n[1]);let E=_?k/_:1,T=u.clientX-a.clientX,I=u.clientY-a.clientY;this.dragOffset.x+=T,this.dragOffset.y+=I,this.dragOffset.time=Date.now()-this.dragStart.time;let z=st(this.targetScale)===st(this.minScale)&&this.option("lockAxis");if(z&&!this.lockedAxis)if(z==="xy"||z==="y"||e.type==="touchmove"){if(Math.abs(this.dragOffset.x)<6&&Math.abs(this.dragOffset.y)<6)return void e.preventDefault();const oe=Math.abs(180*Math.atan2(this.dragOffset.y,this.dragOffset.x)/Math.PI);this.lockedAxis=oe>45&&oe<135?"y":"x",this.dragOffset.x=0,this.dragOffset.y=0,T=0,I=0}else this.lockedAxis=z;if(Np(e.target,this.content)&&(z="x",this.dragOffset.y=0),z&&z!=="xy"&&this.lockedAxis!==z&&st(this.targetScale)===st(this.minScale))return;e.cancelable&&e.preventDefault(),this.container.classList.add(this.cn("isDragging"));const V=this.checkBounds(T,I);this.option("rubberband")?(this.isInfinite!=="x"&&(V.xDiff>0&&T<0||V.xDiff<0&&T>0)&&(T*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitWidth*V.xDiff))),this.isInfinite!=="y"&&(V.yDiff>0&&I<0||V.yDiff<0&&I>0)&&(I*=Math.max(0,.5-Math.abs(.75/this.contentRect.fitHeight*V.yDiff)))):(V.xDiff&&(T=0),V.yDiff&&(I=0));const H=this.targetScale,Z=this.minScale,ee=this.maxScale;H<.5*Z&&(E=Math.max(E,Z)),H>1.5*ee&&(E=Math.min(E,ee)),this.lockedAxis==="y"&&st(H)===st(Z)&&(T=0),this.lockedAxis==="x"&&st(H)===st(Z)&&(I=0),this.applyChange({originX:l,originY:g,panX:T,panY:I,scale:E,friction:this.option("dragFriction"),ignoreBounds:!0})}onPointerUp(e,n,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(n),this.panOnlyZoomed&&this.contentRect.width-this.contentRect.fitWidth<1&&this.contentRect.height-this.contentRect.fitHeight<1&&(this.trackingPoints=[]),Np(e.target,this.content)&&this.lockedAxis==="y"&&(this.trackingPoints=[]),this.emit("touchEnd",e),this.isDragging=!1,this.lockedAxis=!1,this.state!==An.Destroy&&(e.defaultPrevented||this.startDecelAnim()))}startDecelAnim(){var e;const n=this.isScaling;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.isBouncingX=!1,this.isBouncingY=!1;for(const oe of Po)this.velocity[oe]=0;this.target.e=this.current.e,this.target.f=this.current.f,kn(this.container,"is-scaling"),kn(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 _=((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1;_!==1&&(u*=_,l*=_);let k=0,E=0,T=0,I=0,z=this.option("decelFriction");const V=this.targetScale;if(g>0){T=Math.abs(u)>3?u/(g/30):0,I=Math.abs(l)>3?l/(g/30):0;const oe=this.option("maxVelocity");oe&&(T=Math.max(Math.min(T,oe),-1*oe),I=Math.max(Math.min(I,oe),-1*oe))}T&&(k=T/(1/(1-z)-1)),I&&(E=I/(1/(1-z)-1)),(this.option("lockAxis")==="y"||this.option("lockAxis")==="xy"&&this.lockedAxis==="y"&&st(V)===this.minScale)&&(k=T=0),(this.option("lockAxis")==="x"||this.option("lockAxis")==="xy"&&this.lockedAxis==="x"&&st(V)===this.minScale)&&(E=I=0);const H=this.dragOffset.x,Z=this.dragOffset.y,ee=this.option("dragMinThreshold")||0;Math.abs(H)<ee&&Math.abs(Z)<ee&&(k=E=0,T=I=0),(this.option("zoom")&&(V<this.minScale-1e-5||V>this.maxScale+1e-5)||n&&!k&&!E)&&(z=.35),this.applyChange({panX:k,panY:E,friction:z}),this.emit("decel",T,I,H,Z)}onWheel(e){var n=[-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,n));if(this.emit("wheel",e,i),this.panMode===ps||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:n,content:i,contentRect:r}=this,a=Object.assign({},Fp);for(const H of Po){const Z=H=="e"||H==="f"?Vp:Tz;a[H]=st(e[H],Z),Math.abs(n[H]-e[H])<(H=="e"||H==="f"?.51:.001)&&(e[H]=n[H])}let{a:u,b:l,c:g,d:_,e:k,f:E}=a,T=`matrix(${u}, ${l}, ${g}, ${_}, ${k}, ${E})`,I=i.parentElement instanceof HTMLPictureElement?i.parentElement:i;if(this.option("transformParent")&&(I=I.parentElement||I),I.style.transform===T)return;I.style.transform=T;const{contentWidth:z,contentHeight:V}=this.calculateContentDim();r.width=z,r.height=V,this.emit("afterTransform")}updateMetrics(e=!1){var n;if(!this||this.state===An.Destroy||this.isContentLoading)return;const i=Math.max(1,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1),{container:r,content:a}=this,u=a instanceof HTMLImageElement,l=r.getBoundingClientRect(),g=getComputedStyle(this.container);let _=l.width*i,k=l.height*i;const E=parseFloat(g.paddingTop)+parseFloat(g.paddingBottom),T=_-(parseFloat(g.paddingLeft)+parseFloat(g.paddingRight)),I=k-E;this.containerRect={width:_,height:k,innerWidth:T,innerHeight:I};const z=parseFloat(a.dataset.width||"")||(ht=>{let Rt=0;return Rt=ht instanceof HTMLImageElement?ht.naturalWidth:ht instanceof SVGElement?ht.width.baseVal.value:Math.max(ht.offsetWidth,ht.scrollWidth),Rt||0})(a),V=parseFloat(a.dataset.height||"")||(ht=>{let Rt=0;return Rt=ht instanceof HTMLImageElement?ht.naturalHeight:ht instanceof SVGElement?ht.height.baseVal.value:Math.max(ht.offsetHeight,ht.scrollHeight),Rt||0})(a);let H=this.option("width",z)||fs,Z=this.option("height",V)||fs;const ee=H===fs,oe=Z===fs;typeof H!="number"&&(H=z),typeof Z!="number"&&(Z=V),ee&&(H=z*(Z/V)),oe&&(Z=V/(z/H));let J=a.parentElement instanceof HTMLPictureElement?a.parentElement:a;this.option("transformParent")&&(J=J.parentElement||J);const Ae=J.getAttribute("style")||"";J.style.setProperty("transform","none","important"),u&&(J.style.width="",J.style.height=""),J.offsetHeight;const ke=a.getBoundingClientRect();let Me=ke.width*i,Le=ke.height*i,Ie=Me,Ye=Le;Me=Math.min(Me,H),Le=Math.min(Le,Z),u?{width:Me,height:Le}=((ht,Rt,Xt,nn)=>{const jt=Xt/ht,Mt=nn/Rt,Sn=Math.min(jt,Mt);return{width:ht*=Sn,height:Rt*=Sn}})(H,Z,Me,Le):(Me=Math.min(Me,H),Le=Math.min(Le,Z));let it=.5*(Ye-Le),Nt=.5*(Ie-Me);this.contentRect=Object.assign(Object.assign({},this.contentRect),{top:ke.top-l.top+it,bottom:l.bottom-ke.bottom+it,left:ke.left-l.left+Nt,right:l.right-ke.right+Nt,fitWidth:Me,fitHeight:Le,width:Me,height:Le,fullWidth:H,fullHeight:Z}),J.style.cssText=Ae,u&&(J.style.width=`${Me}px`,J.style.height=`${Le}px`),this.setTransform(),e!==!0&&this.emit("refresh"),this.ignoreBounds||(st(this.targetScale)<st(this.minScale)?this.zoomTo(this.minScale,{friction:0}):this.targetScale>this.maxScale?this.zoomTo(this.maxScale,{friction:0}):this.state===An.Init||this.checkBounds().inBounds||this.requestTick()),this.updateControls()}calculateBounds(){const{contentWidth:e,contentHeight:n}=this.calculateContentDim(this.target),{targetScale:i,lockedAxis:r}=this,{fitWidth:a,fitHeight:u}=this.contentRect;let l=0,g=0,_=0,k=0;const E=this.option("infinite");if(E===!0||r&&E===r)l=-1/0,_=1/0,g=-1/0,k=1/0;else{let{containerRect:T,contentRect:I}=this,z=st(a*i,Vp),V=st(u*i,Vp),{innerWidth:H,innerHeight:Z}=T;if(T.width===z&&(H=T.width),T.width===V&&(Z=T.height),e>H){_=.5*(e-H),l=-1*_;let ee=.5*(I.right-I.left);l+=ee,_+=ee}if(a>H&&e<H&&(l-=.5*(a-H),_-=.5*(a-H)),n>Z){k=.5*(n-Z),g=-1*k;let ee=.5*(I.bottom-I.top);g+=ee,k+=ee}u>Z&&n<Z&&(l-=.5*(u-Z),_-=.5*(u-Z))}return{x:{min:l,max:_},y:{min:g,max:k}}}getBounds(){const e=this.option("bounds");return e!==fs?e:this.calculateBounds()}updateControls(){const e=this,n=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 _=e.canZoomIn(),k=e.canZoomOut(),E=i===j1&&!!this.option("touch"),T=k&&E;if(E&&(st(a)<st(u)&&!this.panOnlyZoomed&&(T=!0),(st(r.width,1)>st(r.fitWidth,1)||st(r.height,1)>st(r.fitHeight,1))&&(T=!0)),st(r.width*a,1)<st(r.fitWidth,1)&&(T=!1),i===ps&&(T=!1),to(n,this.cn("isDraggable"),T),!this.option("zoom"))return;let I=_&&st(l)>st(a),z=!I&&!T&&k&&st(l)<st(a);to(n,this.cn("canZoomIn"),I),to(n,this.cn("canZoomOut"),z);for(const V of n.querySelectorAll("[data-panzoom-action]")){let H=!1,Z=!1;switch(V.dataset.panzoomAction){case"zoomIn":_?H=!0:Z=!0;break;case"zoomOut":k?H=!0:Z=!0;break;case"toggleZoom":case"iterateZoom":_||k?H=!0:Z=!0;const ee=V.querySelector("g");ee&&(ee.style.display=_?"":"none")}H?(V.removeAttribute("disabled"),V.removeAttribute("tabindex")):Z&&(V.setAttribute("disabled",""),V.setAttribute("tabindex","-1"))}}panTo({x:e=this.target.e,y:n=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:_=!1,ignoreBounds:k=!1}){this.state!==An.Destroy&&this.applyChange({panX:e-this.target.e,panY:n-this.target.f,scale:i/this.targetScale,angle:a,originX:u,originY:l,friction:r,flipX:g,flipY:_,ignoreBounds:k})}applyChange({panX:e=0,panY:n=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:_=!1,ignoreBounds:k=!1,bounce:E=this.option("bounce")}){const T=this.state;if(T===An.Destroy)return;this.rAF&&(cancelAnimationFrame(this.rAF),this.rAF=null),this.friction=l||0,this.ignoreBounds=k;const{current:I}=this,z=I.e,V=I.f,H=this.getMatrix(this.target);let Z=new DOMMatrix().translate(z,V).translate(a,u).translate(e,n);if(this.option("zoom")){if(!k){const ee=this.targetScale,oe=this.minScale,J=this.maxScale;ee*i<oe&&(i=oe/ee),ee*i>J&&(i=J/ee)}Z=Z.scale(i)}Z=Z.translate(-a,-u).translate(-z,-V).multiply(H),r&&(Z=Z.rotate(r)),g&&(Z=Z.scale(-1,1)),_&&(Z=Z.scale(1,-1));for(const ee of Po)ee!=="e"&&ee!=="f"&&(Z[ee]>this.minScale+1e-5||Z[ee]<this.minScale-1e-5)?this.target[ee]=Z[ee]:this.target[ee]=st(Z[ee],Vp);(this.targetScale<this.scale||Math.abs(i-1)>.1||this.panMode===ps||E===!1)&&!k&&this.clampTargetBounds(),T===An.Init?this.animate():this.isResting||(this.state=An.Panning,this.requestTick())}stop(e=!1){if(this.state===An.Init||this.state===An.Destroy)return;const n=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(),kn(this.container,"is-scaling"),kn(this.container,"is-animating"),this.isTicking=!1,this.state=An.Ready,n&&(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,n=this.option("mouseMoveFriction")){if(this.pmme=e,this.panMode!==ps||!e||st(this.targetScale)<=st(this.minScale))return;this.emit("mouseMove",e);const{container:i,containerRect:r,contentRect:a}=this,u=r.width,l=r.height,g=i.getBoundingClientRect(),_=(e.clientX||0)-g.left,k=(e.clientY||0)-g.top;let{contentWidth:E,contentHeight:T}=this.calculateContentDim(this.target);const I=this.option("mouseMoveFactor");I>1&&(E!==u&&(E*=I),T!==l&&(T*=I));let z=.5*(E-u)-_/u*100/100*(E-u);z+=.5*(a.right-a.left);let V=.5*(T-l)-k/l*100/100*(T-l);V+=.5*(a.bottom-a.top),this.applyChange({panX:z-this.target.e,panY:V-this.target.f,friction:n})}zoomWithWheel(e){if(this.state===An.Destroy||this.state===An.Init)return;const n=Date.now();if(n-this.pwt<45)return void e.preventDefault();this.pwt=n;var i=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(_,k){return Math.abs(k)>Math.abs(_)?k:_});const r=Math.max(-1,Math.min(1,i)),{targetScale:a,maxScale:u,minScale:l}=this;let g=a*(100+45*r)/100;st(g)<st(l)&&st(a)<=st(l)?(this.cwd+=Math.abs(r),g=l):st(g)>st(u)&&st(a)>=st(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(),st(g)!==st(a)&&this.zoomTo(g,{event:e}))}canZoomIn(){return this.option("zoom")&&(st(this.contentRect.width,1)<st(this.contentRect.fitWidth,1)||st(this.targetScale)<st(this.maxScale))}canZoomOut(){return this.option("zoom")&&st(this.targetScale)>st(this.minScale)}zoomIn(e=1.25,n){this.zoomTo(this.targetScale*e,n)}zoomOut(e=.8,n){this.zoomTo(this.targetScale*e,n)}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:n=fs,originX:i=fs,originY:r=fs,event:a}={}){if(this.isContentLoading||this.state===An.Destroy)return;const{targetScale:u,fullScale:l,maxScale:g,coverScale:_}=this;if(this.stop(),this.panMode===ps&&(a=this.pmme||a),a||i===fs||r===fs){const E=this.content.getBoundingClientRect(),T=this.container.getBoundingClientRect(),I=a?a.clientX:T.left+.5*T.width,z=a?a.clientY:T.top+.5*T.height;i=I-E.left-.5*E.width,r=z-E.top-.5*E.height}let k=1;typeof e=="number"?k=e:e==="full"?k=l:e==="cover"?k=_:e==="max"?k=g:e==="fit"?k=1:e==="next"&&(k=this.getNextScale("iterateZoom")),k=k/u||1,n=n===fs?k>1?.15:.25:n,this.applyChange({scale:k,originX:i,originY:r,friction:n}),a&&this.panMode===ps&&this.panWithMouse(a,n)}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:n,target:i}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-i.e,panY:.5*e.height-(n.top+.5*n.fitHeight)-i.f,scale:e.width/n.fitWidth/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}fitY(){this.stop("target");const{containerRect:e,contentRect:n,target:i}=this;this.applyChange({panX:.5*e.width-(n.left+.5*n.fitWidth)-i.e,panY:.5*e.innerHeight-(n.top+.5*n.fitHeight)-i.f,scale:e.height/n.fitHeight/this.targetScale,originX:0,originY:0,ignoreBounds:!0})}toggleFS(){const{container:e}=this,n=this.cn("inFullscreen"),i=this.cn("htmlHasFullscreen");e.classList.toggle(n);const r=e.classList.contains(n);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:n,b:i,c:r,d:a,e:u,f:l}=e;return new DOMMatrix([n,i,r,a,u,l])}reset(e){if(this.state!==An.Init&&this.state!==An.Destroy){this.stop("current");for(const n of Po)this.target[n]=Fp[n];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=An.Panning,this.requestTick())}}destroy(){this.stop(),this.state=An.Destroy,this.detachEvents(),this.detachObserver();const{container:e,content:n}=this,i=this.option("classes")||{};for(const r of Object.values(i))e.classList.remove(r+"");n&&(n.removeEventListener("load",this.onLoad),n.removeEventListener("error",this.onError)),this.detachPlugins()}}Object.defineProperty(ua,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Cz}),Object.defineProperty(ua,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:{}});const H1=function(t,e){let n=!0;return(...i)=>{n&&(n=!1,t(...i),setTimeout(()=>{n=!0},e))}},q1=(t,e)=>{let n=[];return t.childNodes.forEach(i=>{i.nodeType!==Node.ELEMENT_NODE||e&&!i.matches(e)||n.push(i)}),n},Mz={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 ci;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Destroy=2]="Destroy"})(ci||(ci={}));const uy=t=>{if(typeof t=="string"||t instanceof HTMLElement)t={html:t};else{const e=t.thumb;e!==void 0&&(typeof e=="string"&&(t.thumbSrc=e),e instanceof HTMLImageElement&&(t.thumbEl=e,t.thumbElSrc=e.src,t.thumbSrc=e.src),delete t.thumb)}return Object.assign({html:"",el:null,isDom:!1,class:"",customClass:"",index:-1,dim:0,gap:0,pos:0,transition:!1},t)},Az=(t={})=>Object.assign({index:-1,slides:[],dim:0,pos:-1},t);class Fs extends Bp{constructor(e,n){super(n),Object.defineProperty(this,"instance",{enumerable:!0,configurable:!0,writable:!0,value:e})}attach(){}detach(){}}const Pz={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 W1 extends Fs{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 n=this.instance.container;n.appendChild(e),Ct(n,this.cn("hasDots")),this.list=e}return e}refresh(){var e;const n=this.instance.pages.length,i=Math.min(2,this.option("minCount")),r=Math.max(2e3,this.option("maxCount")),a=this.option("dynamicFrom");if(n<i||n>r)return void this.cleanup();const u=typeof a=="number"&&n>5&&n>=a,l=!this.list||this.isDynamic!==u||this.list.children.length!==n;l&&this.cleanup();const g=this.build();if(to(g,this.cn("isDynamic"),!!u),l)for(let E=0;E<n;E++)g.append(this.createItem(E));let _,k=0;for(const E of[...g.children]){const T=k===this.instance.page;T&&(_=E),to(E,this.cn("isCurrent"),T),(e=E.children[0])===null||e===void 0||e.setAttribute("aria-selected",T?"true":"false");for(const I of["isBeforePrev","isPrev","isNext","isAfterNext"])kn(E,this.cn(I));k++}if(_=_||g.firstChild,u&&_){const E=_.previousElementSibling,T=E&&E.previousElementSibling;Ct(E,this.cn("isPrev")),Ct(T,this.cn("isBeforePrev"));const I=_.nextElementSibling,z=I&&I.nextElementSibling;Ct(I,this.cn("isNext")),Ct(z,this.cn("isAfterNext"))}this.isDynamic=u}createItem(e=0){var n;const i=document.createElement("li");i.setAttribute("role","presentation");const r=eo(this.instance.localize(this.option("dotTpl"),[["%d",e+1]]).replace(/\%i/g,e+""));return i.appendChild(r),(n=i.children[0])===null||n===void 0||n.setAttribute("role","tab"),i}cleanup(){this.list&&(this.list.remove(),this.list=null),this.isDynamic=!1,kn(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(W1,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Pz});const $p="disabled",jp="next",G1="prev";class Z1 extends Fs{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,n=e.pages.length,i=e.page;if(n<2)return void this.cleanup();this.build();let r=this.prev,a=this.next;r&&a&&(r.removeAttribute($p),a.removeAttribute($p),e.isInfinite||(i<=0&&r.setAttribute($p,""),i>=n-1&&a.setAttribute($p,"")))}addBtn(e){var n;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===jp?"isNext":"isPrev"));const a=i.isRTL?e===jp?G1:jp: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",(n=this.container)===null||n===void 0||n.appendChild(r),r}build(){const e=this.instance.container,n=this.cn("container");let{container:i,prev:r,next:a}=this;i||(i=e.querySelector("."+n),this.isDom=!!i),i||(i=document.createElement("div"),Ct(i,n),e.appendChild(i)),this.container=i,a||(a=i.querySelector("[data-carousel-next]")),a||(a=this.addBtn(jp)),this.next=a,r||(r=i.querySelector("[data-carousel-prev]")),r||(r=this.addBtn(G1)),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(Z1,"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 Y1 extends Fs{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:n}=this;e&&n&&(e.options.initialSlide=n.options.initialPage,e.state===ci.Ready?this.onNavReady(e):e.on("ready",this.onNavReady),n.state===ci.Ready?this.onTargetReady(n):n.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,n,i){this.onNavTouch(e,e.panzoom,i)}onNavTouch(e,n,i){var r,a;if(Math.abs(n.dragOffset.x)>3||Math.abs(n.dragOffset.y)>3)return;const u=i.target,{nav:l,target:g}=this;if(!l||!g||!u)return;const _=u.closest("[data-index]");if(i.stopPropagation(),i.preventDefault(),!_)return;const k=parseInt(_.dataset.index||"",10)||0,E=g.getPageForSlide(k),T=l.getPageForSlide(k);l.slideTo(T),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,n){n.index===this.selectedIndex&&this.markSelectedSlide(n.index)}onTargetChange(){var e,n;const{target:i,nav:r}=this;if(!i||!r||r.state!==ci.Ready||i.state!==ci.Ready)return;const a=(n=(e=i.pages[i.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index,u=r.getPageForSlide(a);this.markSelectedSlide(a),r.slideTo(u,r.prevPage===null&&i.prevPage===null?{friction:0}:void 0)}markSelectedSlide(e){const n=this.nav;n&&n.state===ci.Ready&&(this.selectedIndex=e,[...n.slides].map(i=>{i.el&&i.el.classList[i.index===e?"add":"remove"]("is-nav-selected")}))}attach(){const e=this;let n=e.options.target,i=e.options.nav;n?e.addAsNavFor(n):i&&e.addAsTargetFor(i)}detach(){const e=this,n=e.nav,i=e.target;n&&(n.off("ready",e.onNavReady),n.off("createSlide",e.onNavCreateSlide),n.off("Panzoom.click",e.onNavClick),n.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(Y1,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{friction:.35}});const Iz={Navigation:Z1,Dots:W1,Sync:Y1},Up="animationend",X1="isSelected",Hp="slide";class ha extends oy{get axis(){return this.isHorizontal?"e":"f"}get isEnabled(){return this.state===ci.Ready}get isInfinite(){let e=!1;const{contentDim:n,viewportDim:i,pages:r,slides:a}=this,u=a[0];return r.length>=2&&u&&n+u.dim>=i&&(e=this.option("infinite")),e}get isRTL(){return this.option("direction")==="rtl"}get isHorizontal(){return this.option("axis")==="x"}constructor(e,n={},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:ci.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||!Tr(e))throw new Error("No Element found");this.container=e,this.slideNext=H1(this.slideNext.bind(this),150),this.slidePrev=H1(this.slidePrev.bind(this),150),this.userOptions=n,this.userPlugins=i,queueMicrotask(()=>{this.processOptions()})}processOptions(){var e,n;const i=Cr({},ha.defaults,this.userOptions);let r="";const a=i.breakpoints;if(a&&ry(a))for(const[u,l]of Object.entries(a))window.matchMedia(u).matches&&ry(l)&&(r+=u,Cr(i,l));r===this.bp&&this.state!==ci.Init||(this.bp=r,this.state===ci.Ready&&(i.initialSlide=((n=(e=this.pages[this.page])===null||e===void 0?void 0:e.slides[0])===null||n===void 0?void 0:n.index)||0),this.state!==ci.Init&&this.destroy(),super.setOptions(i),this.option("enabled")===!1?this.attachEvents():setTimeout(()=>{this.init()},0))}init(){this.state=ci.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=ci.Ready,this.emit("ready")}initLayout(){const{container:e}=this,n=this.option("classes");Ct(e,this.cn("container")),to(e,n.isLTR,!this.isRTL),to(e,n.isRTL,this.isRTL),to(e,n.isVertical,!this.isHorizontal),to(e,n.isHorizontal,this.isHorizontal);let i=this.option("viewport")||e.querySelector(`.${n.viewport}`);i||(i=document.createElement("div"),Ct(i,n.viewport),i.append(...q1(e,`.${n.slide}`)),e.prepend(i)),i.addEventListener("scroll",this.onScroll);let r=this.option("track")||e.querySelector(`.${n.track}`);r||(r=document.createElement("div"),Ct(r,n.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 n=[...this.slides],i=[];[...q1(e,`.${this.cn(Hp)}`)].forEach(r=>{if(Tr(r)){const a=uy({el:r,isDom:!0,index:this.slides.length});i.push(a)}});for(let r of[...this.option("slides",[])||[],...n])i.push(uy(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:n,isHorizontal:i}=this;if(!e||!n.length)return;let r=this.page;n[r]||(this.page=r=0);const a=(n[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,Cr({},{content:this.track,zoom:!1,panOnlyZoomed:!1,lockAxis:this.isHorizontal?"x":"y",infinite:this.isInfinite,click:!1,dblClick:!1,touch:n=>!(this.pages.length<2&&!n.options.infinite),bounds:()=>this.getBounds(),maxVelocity:n=>Math.abs(n.target[this.axis]-n.current[this.axis])<2*this.viewportDim?100:0},e)),this.panzoom.on("*",(n,i,...r)=>{this.emit(`Panzoom.${i}`,n,...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:n,viewportDim:i}=this;let r=this.option("slidesPerPage");r=(r==="auto"||n<=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(Az()),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:n,viewportDim:i,isInfinite:r}=this,a=this.option("center"),u=this.option("fill"),l=u&&a&&n>i&&!r;if(e.forEach((k,E)=>{var T;k.index=E,k.pos=((T=k.slides[0])===null||T===void 0?void 0:T.pos)||0,k.dim=0;for(const[I,z]of k.slides.entries())k.dim+=z.dim,I<k.slides.length-1&&(k.dim+=z.gap);l&&k.pos+.5*k.dim<.5*i?k.pos=0:l&&k.pos+.5*k.dim>=n-.5*i?k.pos=n-i:a&&(k.pos+=-.5*(i-k.dim))}),e.forEach(k=>{u&&!r&&n>i&&(k.pos=Math.max(k.pos,0),k.pos=Math.min(k.pos,n-i)),k.pos=st(k.pos,1e3),k.dim=st(k.dim,1e3),Math.abs(k.pos)<=.1&&(k.pos=0)}),r)return e;const g=[];let _;return e.forEach(k=>{const E=Object.assign({},k);_&&E.pos===_.pos?(_.dim+=E.dim,_.slides=[..._.slides,...E.slides]):(E.index=g.length,_=E,g.push(E))}),g}getPageFromIndex(e=0){const n=this.pages.length;let i;return e=parseInt((e||0).toString())||0,i=this.isInfinite?(e%n+n)%n:Math.max(Math.min(e,n-1),0),i}getSlideMetrics(e){var n,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(Hp)+" "+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,((n=window.visualViewport)===null||n===void 0?void 0:n.scale)||1);let k=l[this.isHorizontal?"offsetWidth":"offsetHeight"];k-1>a&&(a=k)}const _=getComputedStyle(l);return _.boxSizing==="content-box"&&(this.isHorizontal?(a+=parseFloat(_.paddingLeft)||0,a+=parseFloat(_.paddingRight)||0):(a+=parseFloat(_.paddingTop)||0,a+=parseFloat(_.paddingBottom)||0)),u=parseFloat(_[this.isHorizontal?"marginRight":"marginBottom"])||0,g?(i=l.parentElement)===null||i===void 0||i.removeChild(l):e.el||l.remove(),{dim:st(a,1e3),gap:st(u,1e3)}}getBounds(){const{isInfinite:e,isRTL:n,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=n&&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:n,isRTL:i,isInfinite:r,viewport:a,viewportDim:u,contentDim:l,page:g,pages:_,slides:k,panzoom:E}=this,T=0,I=0,z=0,V=0;E?V=-1*E.current[this.axis]:_[g]&&(V=_[g].pos||0),e=n?i?"right":"left":"top",i&&n&&(V*=-1);for(const oe of k){const J=oe.el;J?(e==="top"?(J.style.right="",J.style.left=""):J.style.top="",oe.index!==T?J.style[e]=I===0?"":`${st(I,1e3)}px`:J.style[e]="",z+=oe.dim+oe.gap,T++):I+=oe.dim+oe.gap}if(r&&z&&a){let oe=getComputedStyle(a),J="padding",Ae=n?"Right":"Bottom",ke=parseFloat(oe[J+(n?"Left":"Top")]);V-=ke,u+=ke,u+=parseFloat(oe[J+Ae]);for(const Me of k)Me.el&&(st(Me.pos)<st(u)&&st(Me.pos+Me.dim+Me.gap)<st(V)&&st(V)>st(l-u)&&(Me.el.style[e]=`${st(I+z,1e3)}px`),st(Me.pos+Me.gap)>=st(l-u)&&st(Me.pos)>st(V+u)&&st(V)<st(u)&&(Me.el.style[e]=`-${st(z,1e3)}px`))}let H,Z,ee=[...this.inTransition];if(ee.length>1&&(H=_[ee[0]],Z=_[ee[1]]),H&&Z){let oe=0;for(const J of k)J.el?this.inTransition.has(J.index)&&H.slides.indexOf(J)<0&&(J.el.style[e]=`${st(oe+(H.pos-Z.pos),1e3)}px`):oe+=J.dim+J.gap}}createSlideEl(e){const{track:n,slides:i}=this;if(!n||!e||e.el&&e.el.parentNode)return;const r=e.el||document.createElement("div");Ct(r,this.cn(Hp)),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 _=g&&g.el&&g.el.parentNode?g.index<e.index?g.el.nextSibling:g.el:null;n.insertBefore(r,n.contains(_)?_:null),e.el=r,this.emit("createSlide",e)}removeSlideEl(e,n=!1){const i=e==null?void 0:e.el;if(!i||!i.parentNode)return;const r=this.cn(X1);if(i.classList.contains(r)&&(kn(i,r),this.emit("unselectSlide",e)),e.isDom&&!n)return i.removeAttribute("aria-hidden"),i.removeAttribute("data-index"),void(i.style.left="");this.emit("removeSlide",e);const a=new CustomEvent(Up);i.dispatchEvent(a),e.el&&(e.el.remove(),e.el=null)}transitionTo(e=0,n=this.option("transition")){var i,r,a,u;if(!n)return!1;const l=this.page,{pages:g,panzoom:_}=this;e=parseInt((e||0).toString())||0;const k=this.getPageFromIndex(e);if(!_||!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 T=g[k].pos*(this.isRTL?1:-1);if(l===k&&Math.abs(T-_.target[this.axis])<1)return!1;this.clearTransitions();const I=_.isResting;Ct(this.container,this.cn("inTransition"));const z=((a=g[l])===null||a===void 0?void 0:a.slides[0])||null,V=((u=g[k])===null||u===void 0?void 0:u.slides[0])||null;this.inTransition.add(V.index),this.createSlideEl(V);let H=z.el,Z=V.el;I||n===Hp||(n="fadeFast",H=null);const ee=this.isRTL?"next":"prev",oe=this.isRTL?"prev":"next";return H&&(this.inTransition.add(z.index),z.transition=n,H.addEventListener(Up,this.onAnimationEnd),H.classList.add(`f-${n}Out`,`to-${E>0?oe:ee}`)),Z&&(V.transition=n,Z.addEventListener(Up,this.onAnimationEnd),Z.classList.add(`f-${n}In`,`from-${E>0?ee:oe}`)),_.current[this.axis]=T,_.target[this.axis]=T,_.requestTick(),this.onChange(k),!0}manageSlideVisiblity(){const e=new Set,n=new Set,i=this.getVisibleSlides(parseFloat(this.option("preload",0)+"")||0);for(const r of this.slides)i.has(r)?e.add(r):n.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 n)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 n=this.cn(X1);if(n)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(n)||(Ct(r,n),this.emit("selectSlide",i)),r.removeAttribute(e)):(r.classList.contains(n)&&(kn(r,n),this.emit("unselectSlide",i)),r.setAttribute(e,"true")))}}flipInfiniteTrack(){const{axis:e,isHorizontal:n,isInfinite:i,isRTL:r,viewportDim:a,contentDim:u}=this,l=this.panzoom;if(!l||!i)return;let g=l.current[e],_=l.target[e]-g,k=0,E=.5*a;r&&n?(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+_)}lazyLoadImg(e,n){const i=this,r="f-fadeIn",a="is-preloading";let u=!1,l=null;const g=()=>{u||(u=!0,l&&(l.remove(),l=null),kn(n,a),n.complete&&(Ct(n,r),setTimeout(()=>{kn(n,r)},350)),this.option("adaptiveHeight")&&e.el&&this.pages[this.page].slides.indexOf(e)>-1&&(i.updateMetrics(),i.setViewportHeight()),this.emit("load",e))};Ct(n,a),n.src=n.dataset.lazySrcset||n.dataset.lazySrc||"",delete n.dataset.lazySrc,delete n.dataset.lazySrcset,n.addEventListener("error",()=>{g()}),n.addEventListener("load",()=>{g()}),setTimeout(()=>{const _=n.parentNode;_&&e.el&&(n.complete?g():u||(l=eo(ay),_.insertBefore(l,n)))},300)}lazyLoadSlide(e){const n=e&&e.el;if(!n)return;const i=new Set;let r=Array.from(n.querySelectorAll("[data-lazy-src],[data-lazy-srcset]"));n.dataset.lazySrc&&r.push(n),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 n;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&&(!((n=this.panzoom)===null||n===void 0)&&n.isResting)&&this.emit("settle")}onDecel(e,n=0,i=0,r=0,a=0){if(this.option("dragFree"))return void this.setPageFromPosition();const{isRTL:u,isHorizontal:l,axis:g,pages:_}=this,k=_.length,E=Math.abs(Math.atan2(i,n)/(Math.PI/180));let T=0;if(T=E>45&&E<135?l?0:i:l?n:0,!k)return;let I=this.page,z=u&&l?1:-1;const V=e.current[g]*z;let{pageIndex:H}=this.getPageFromPosition(V);Math.abs(T)>5?(_[I].dim<document.documentElement["client"+(this.isHorizontal?"Width":"Height")]-1&&(I=H),I=u&&l?T<0?I-1:I+1:T<0?I+1:I-1):I=r===0&&a===0?I:H,this.slideTo(I,{transition:!1,friction:e.option("decelFriction")})}onClick(e){const n=e.target,i=n&&Tr(n)?n.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(),n&&!n.hasAttribute("disabled")&&this[a](r)):this.emit("click",e)}onSlideTo(e){const n=e.detail||0;this.slideTo(this.getPageForSlide(n),{friction:0})}onChange(e,n=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,n))}onRefresh(){let e=this.contentDim,n=this.viewportDim;this.updateMetrics(),this.contentDim===e&&this.viewportDim===n||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,n=null){this.destroy(),this.state=ci.Init,this.prevPage=null,this.userOptions=e||this.userOptions,this.userPlugins=n||this.userPlugins,this.processOptions()}slideTo(e=0,{friction:n=this.option("friction"),transition:i=this.option("transition")}={}){if(this.state===ci.Destroy)return;e=parseInt((e||0).toString())||0;const r=this.getPageFromIndex(e),{axis:a,isHorizontal:u,isRTL:l,pages:g,panzoom:_}=this,k=g.length,E=l&&u?1:-1;if(!_||!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 T=g[r].pos;if(this.isInfinite){const I=this.contentDim,z=_.target[a]*E;k===2?T+=I*Math.floor(parseFloat(e+"")/2):T=[T,T-I,T+I].reduce(function(V,H){return Math.abs(H-z)<Math.abs(V-z)?H:V})}T*=E,Math.abs(_.target[a]-T)<1||(_.panTo({x:u?T:0,y:u?0:T,friction:n}),this.onChange(r))}slideToClosest(e){if(this.panzoom){const{pageIndex:n}=this.getPageFromPosition();this.slideTo(n,e)}}slideNext(){this.slideTo(this.page+1)}slidePrev(){this.slideTo(this.page-1)}clearTransitions(){this.inTransition.clear(),kn(this.container,this.cn("inTransition"));const e=["to-prev","to-next","from-prev","from-next"];for(const n of this.slides){const i=n.el;if(i){i.removeEventListener(Up,this.onAnimationEnd),i.classList.remove(...e);const r=n.transition;r&&i.classList.remove(`f-${r}Out`,`f-${r}In`)}}this.manageSlideVisiblity()}addSlide(e,n){var i,r,a,u;const l=this.panzoom,g=((i=this.pages[this.page])===null||i===void 0?void 0:i.pos)||0,_=((r=this.pages[this.page])===null||r===void 0?void 0:r.dim)||0,k=this.contentDim<this.viewportDim;let E=Array.isArray(n)?n:[n];const T=[];for(const I of E)T.push(uy(I));this.slides.splice(e,0,...T);for(let I=0;I<this.slides.length;I++)this.slides[I].index=I;for(const I of T)this.emit("beforeInitSlide",I,I.index);if(this.page>=e&&(this.page+=T.length),this.updateMetrics(),l){const I=((a=this.pages[this.page])===null||a===void 0?void 0:a.pos)||0,z=((u=this.pages[this.page])===null||u===void 0?void 0:u.dim)||0,V=this.pages.length||1,H=this.isRTL?_-z:z-_,Z=this.isRTL?g-I:I-g;k&&V===1?(e<=this.page&&(l.current[this.axis]-=H,l.target[this.axis]-=H),l.panTo({[this.isHorizontal?"x":"y"]:-1*I})):Z&&e<=this.page&&(l.target[this.axis]-=Z,l.current[this.axis]-=Z,l.requestTick())}for(const I of T)this.emit("initSlide",I,I.index)}prependSlide(e){this.addSlide(0,e)}appendSlide(e){this.addSlide(this.slides.length,e)}removeSlide(e){const n=this.slides.length;e=(e%n+n)%n;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:n,track:i,slides:r,isHorizontal:a,isInfinite:u}=this;if(!i)return;const l=a?"width":"height",g=a?"offsetWidth":"offsetHeight";if(n){let E=Math.max(n[g],st(n.getBoundingClientRect()[l],1e3)),T=getComputedStyle(n),I="padding",z=a?"Right":"Bottom";E-=parseFloat(T[I+(a?"Left":"Top")])+parseFloat(T[I+z]),this.viewportDim=E}let _,k=0;for(const[E,T]of r.entries()){let I=0,z=0;!T.el&&_?(I=_.dim,z=_.gap):({dim:I,gap:z}=this.getSlideMetrics(T),_=T),I=st(I,1e3),z=st(z,1e3),T.dim=I,T.gap=z,T.pos=k,k+=I,(u||E<r.length-1)&&(k+=z)}k=st(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===ci.Init&&this.setInitialPage(),this.page=Math.max(0,Math.min(this.page,this.pages.length-1)),this.manageSlideVisiblity(),this.emit("refresh")}getProgress(e,n=!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,_=st((g-l.pos)/(1*l.dim),1e3),k=_,E=_;this.isInfinite&&i!==!0&&(k=st((g-l.pos+u)/(1*l.dim),1e3),E=st((g-l.pos-u)/(1*l.dim),1e3));let T=[_,k,E].reduce(function(I,z){return Math.abs(z)<Math.abs(I)?z:I});return n?T:T>1?1:T<-1?-1:T}setViewportHeight(){const{page:e,pages:n,viewport:i,isHorizontal:r}=this;if(!i||!n[e])return;let a=0;r&&this.track&&(this.track.style.height="auto",n[e].slides.forEach(u=>{u.el&&(a=Math.max(a,u.el.offsetHeight))})),i.style.height=a?`${a}px`:""}getPageForSlide(e){for(const n of this.pages)for(const i of n.slides)if(i.index===e)return n.index;return-1}getVisibleSlides(e=0){var n;const i=new Set;let{panzoom:r,contentDim:a,viewportDim:u,pages:l,page:g}=this;if(u){a=a+((n=this.slides[this.slides.length-1])===null||n===void 0?void 0:n.gap)||0;let _=0;_=r&&r.state!==An.Init&&r.state!==An.Destroy?-1*r.current[this.axis]:l[g]&&l[g].pos||0,this.isInfinite&&(_-=Math.floor(_/a)*a),this.isRTL&&this.isHorizontal&&(_*=-1);const k=_-u*e,E=_+u*(e+1),T=this.isInfinite?[-1,0,1]:[0];for(const I of this.slides)for(const z of T){const V=I.pos+z*a,H=V+I.dim+I.gap;V<E&&H>k&&i.add(I)}}return i}getPageFromPosition(e){const{viewportDim:n,contentDim:i,slides:r,pages:a,panzoom:u}=this,l=a.length,g=r.length,_=r[0],k=r[g-1],E=this.option("center");let T=0,I=0,z=0,V=e===void 0?-1*((u==null?void 0:u.target[this.axis])||0):e;E&&(V+=.5*n),this.isInfinite?(V<_.pos-.5*k.gap&&(V-=i,z=-1),V>k.pos+k.dim+.5*k.gap&&(V-=i,z=1)):V=Math.max(_.pos||0,Math.min(V,k.pos));let H=k,Z=r.find(ee=>{const oe=ee.pos-.5*H.gap,J=ee.pos+ee.dim+.5*ee.gap;return H=ee,V>=oe&&V<J});return Z||(Z=k),I=this.getPageForSlide(Z.index),T=I+z*l,{page:T,pageIndex:I}}setPageFromPosition(){const{pageIndex:e}=this.getPageFromPosition();this.onChange(e)}destroy(){if([ci.Destroy].includes(this.state))return;this.state=ci.Destroy;const{container:e,viewport:n,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(),n&&(n.removeEventListener("scroll",this.onScroll),n.offsetParent&&i&&i.offsetParent&&n.replaceWith(...i.childNodes));for(const[g,_]of Object.entries(u))g!=="container"&&_&&e.classList.remove(_);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:Mz}),Object.defineProperty(ha,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:Iz});const K1=function(t){if(!Tr(t))return 0;const e=window.scrollY,n=window.innerHeight,i=e+n,r=t.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 _=g/n*100;return Math.round(_)},fh=!(typeof window>"u"||!window.document||!window.document.createElement);let hy;const dy=["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(","),J1=t=>{if(t&&fh){hy===void 0&&document.createElement("div").focus({get preventScroll(){return hy=!0,!1}});try{if(hy)t.focus({preventScroll:!0});else{const e=window.scrollY||document.body.scrollTop,n=window.scrollX||document.body.scrollLeft;t.focus(),document.body.scrollTo({top:e,left:n,behavior:"auto"})}}catch{}}},Q1=()=>{const t=document;let e,n="",i="",r="";return t.fullscreenEnabled?(n="requestFullscreen",i="exitFullscreen",r="fullscreenElement"):t.webkitFullscreenEnabled&&(n="webkitRequestFullscreen",i="webkitExitFullscreen",r="webkitFullscreenElement"),n&&(e={request:function(a=t.documentElement){return n==="webkitRequestFullscreen"?a[n](Element.ALLOW_KEYBOARD_INPUT):a[n]()},exit:function(){return t[r]&&t[i]()},isFullscreen:function(){return t[r]}}),e},py={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({},V1),{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>
|
|
628
628
|
</div>`},trapFocus:!0,wheel:"zoom"};var Ei,Xi;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Closing=2]="Closing",t[t.CustomClosing=3]="CustomClosing",t[t.Destroy=4]="Destroy"})(Ei||(Ei={})),function(t){t[t.Loading=0]="Loading",t[t.Opening=1]="Opening",t[t.Ready=2]="Ready",t[t.Closing=3]="Closing"}(Xi||(Xi={}));let ev="",mh=!1,qp=!1,ml=null;const tv=()=>{let t="",e="";const n=mn.getInstance();if(n){const i=n.carousel,r=n.getSlide();if(i&&r){let a=r.slug||void 0,u=r.triggerEl||void 0;e=a||n.option("slug")||"",!e&&u&&u.dataset&&(e=u.dataset.fancybox||""),e&&e!=="true"&&(t="#"+e+(!a&&i.slides.length>1?"-"+(r.index+1):""))}}return{hash:t,slug:e,index:1}},Wp=()=>{const t=new URL(document.URL).hash,e=t.slice(1).split("-"),n=e[e.length-1],i=n&&/^\+?\d+$/.test(n)&&parseInt(e.pop()||"1",10)||1;return{hash:t,slug:e.join("-"),index:i}},nv=()=>{const{slug:t,index:e}=Wp();if(!t)return;let n=document.querySelector(`[data-slug="${t}"]`);if(n&&n.dispatchEvent(new CustomEvent("click",{bubbles:!0,cancelable:!0})),mn.getInstance())return;const i=document.querySelectorAll(`[data-fancybox="${t}"]`);i.length&&(n=i[e-1],n&&n.dispatchEvent(new CustomEvent("click",{bubbles:!0,cancelable:!0})))},iv=()=>{if(mn.defaults.Hash===!1)return;const t=mn.getInstance();if((t==null?void 0:t.options.Hash)===!1)return;const{slug:e,index:n}=Wp(),{slug:i}=tv();t&&(e===i?t.jumpTo(n-1):(mh=!0,t.close())),nv()},rv=()=>{ml&&clearTimeout(ml),queueMicrotask(()=>{iv()})},sv=()=>{window.addEventListener("hashchange",rv,!1),setTimeout(()=>{iv()},500)};fh&&(/complete|interactive|loaded/.test(document.readyState)?sv():document.addEventListener("DOMContentLoaded",sv));const Gp="is-zooming-in";class ov extends Fs{onCreateSlide(e,n,i){const r=this.instance.optionFor(i,"src")||"";i.el&&i.type==="image"&&typeof r=="string"&&this.setImage(i,r)}onRemoveSlide(e,n,i){i.panzoom&&i.panzoom.destroy(),i.panzoom=void 0,i.imageEl=void 0}onChange(e,n,i,r){kn(this.instance.container,Gp);for(const a of n.slides){const u=a.panzoom;u&&a.index!==i&&u.reset(.35)}}onClose(){var e;const n=this.instance,i=n.container,r=n.getSlide();if(!i||!i.parentElement||!r)return;const{el:a,contentEl:u,panzoom:l,thumbElSrc:g}=r;if(!a||!g||!u||!l||l.isContentLoading||l.state===An.Init||l.state===An.Destroy)return;l.updateMetrics();let _=this.getZoomInfo(r);if(!_)return;this.instance.state=Ei.CustomClosing,i.classList.remove(Gp),i.classList.add("is-zooming-out"),u.style.backgroundImage=`url('${g}')`;const k=i.getBoundingClientRect();(((e=window.visualViewport)===null||e===void 0?void 0:e.scale)||1)===1&&Object.assign(i.style,{position:"absolute",top:`${i.offsetTop+window.scrollY}px`,left:`${i.offsetLeft+window.scrollX}px`,bottom:"auto",right:"auto",width:`${k.width}px`,height:`${k.height}px`,overflow:"hidden"});const{x:E,y:T,scale:I,opacity:z}=_;if(z){const V=((H,Z,ee,oe)=>{const J=Z-H,Ae=oe-ee;return ke=>ee+((ke-H)/J*Ae||0)})(l.scale,I,1,0);l.on("afterTransform",()=>{u.style.opacity=V(l.scale)+""})}l.on("endAnimation",()=>{n.destroy()}),l.target.a=I,l.target.b=0,l.target.c=0,l.target.d=I,l.panTo({x:E,y:T,scale:I,friction:z?.2:.33,ignoreBounds:!0}),l.isResting&&n.destroy()}setImage(e,n){const i=this.instance;e.src=n,this.process(e,n).then(r=>{const{contentEl:a,imageEl:u,thumbElSrc:l,el:g}=e;if(i.isClosing()||!a||!u)return;a.offsetHeight;const _=!!i.isOpeningSlide(e)&&this.getZoomInfo(e);if(this.option("protected")&&g){g.addEventListener("contextmenu",T=>{T.preventDefault()});const E=document.createElement("div");Ct(E,"fancybox-protected"),a.appendChild(E)}if(l&&_){const E=r.contentRect,T=Math.max(E.fullWidth,E.fullHeight);let I=null;!_.opacity&&T>1200&&(I=document.createElement("img"),Ct(I,"fancybox-ghost"),I.src=l,a.appendChild(I));const z=()=>{I&&(Ct(I,"f-fadeFastOut"),setTimeout(()=>{I&&(I.remove(),I=null)},200))};(k=l,new Promise((V,H)=>{const Z=new Image;Z.onload=V,Z.onerror=H,Z.src=k})).then(()=>{i.hideLoading(e),e.state=Xi.Opening,this.instance.emit("reveal",e),this.zoomIn(e).then(()=>{z(),this.instance.done(e)},()=>{}),I&&setTimeout(()=>{z()},T>2500?800:200)},()=>{i.hideLoading(e),i.revealContent(e)})}else{const E=this.optionFor(e,"initialSize"),T=this.optionFor(e,"zoom"),I={event:i.prevMouseMoveEvent||i.options.event,friction:T?.12:0};let z=i.optionFor(e,"showClass")||void 0,V=!0;i.isOpeningSlide(e)&&(E==="full"?r.zoomToFull(I):E==="cover"?r.zoomToCover(I):E==="max"?r.zoomToMax(I):V=!1,r.stop("current")),V&&z&&(z=r.isDragging?"f-fadeIn":""),i.hideLoading(e),i.revealContent(e,z)}var k},()=>{i.setError(e,"{{IMAGE_ERROR}}")})}process(e,n){return new Promise((i,r)=>{var a;const u=this.instance,l=e.el;u.clearContent(e),u.showLoading(e);let g=this.optionFor(e,"content");if(typeof g=="string"&&(g=eo(g)),!g||!Tr(g)){if(g=document.createElement("img"),g instanceof HTMLImageElement){let _="",k=e.caption;_=typeof k=="string"&&k?k.replace(/<[^>]+>/gi,"").substring(0,1e3):`Image ${e.index+1} of ${((a=u.carousel)===null||a===void 0?void 0:a.pages.length)||1}`,g.src=n||"",g.alt=_,g.draggable=!1,e.srcset&&g.setAttribute("srcset",e.srcset),this.instance.isOpeningSlide(e)&&(g.fetchPriority="high")}e.sizes&&g.setAttribute("sizes",e.sizes)}Ct(g,"fancybox-image"),e.imageEl=g,u.setContent(e,g,!1),e.panzoom=new ua(l,Cr({transformParent:!0},this.option("Panzoom")||{},{content:g,width:(_,k)=>u.optionFor(e,"width","auto",k)||"auto",height:(_,k)=>u.optionFor(e,"height","auto",k)||"auto",wheel:()=>{const _=u.option("wheel");return(_==="zoom"||_=="pan")&&_},click:(_,k)=>{var E,T;if(u.isCompact||u.isClosing()||e.index!==((E=u.getSlide())===null||E===void 0?void 0:E.index))return!1;if(k){const z=k.composedPath()[0];if(["A","BUTTON","TEXTAREA","OPTION","INPUT","SELECT","VIDEO"].includes(z.nodeName))return!1}let I=!k||k.target&&((T=e.contentEl)===null||T===void 0?void 0:T.contains(k.target));return u.option(I?"contentClick":"backdropClick")||!1},dblClick:()=>u.isCompact?"toggleZoom":u.option("contentDblClick")||!1,spinner:!1,panOnlyZoomed:!0,wheelLimit:1/0,on:{ready:_=>{i(_)},error:()=>{r()},destroy:()=>{r()}}}))})}zoomIn(e){return new Promise((n,i)=>{const r=this.instance,a=r.container,{panzoom:u,contentEl:l,el:g}=e;u&&u.updateMetrics();const _=this.getZoomInfo(e);if(!(_&&g&&l&&u&&a))return void i();const{x:k,y:E,scale:T,opacity:I}=_,z=()=>{e.state!==Xi.Closing&&(I&&(l.style.opacity=Math.max(Math.min(1,1-(1-u.scale)/(1-T)),0)+""),u.scale>=1&&u.scale>u.targetScale-.1&&n(u))},V=ee=>{(ee.scale<.99||ee.scale>1.01)&&!ee.isDragging||(kn(a,Gp),l.style.opacity="",ee.off("endAnimation",V),ee.off("touchStart",V),ee.off("afterTransform",z),n(ee))};u.on("endAnimation",V),u.on("touchStart",V),u.on("afterTransform",z),u.on(["error","destroy"],()=>{i()}),u.panTo({x:k,y:E,scale:T,friction:0,ignoreBounds:!0}),u.stop("current");const H={event:u.panMode==="mousemove"?r.prevMouseMoveEvent||r.options.event:void 0},Z=this.optionFor(e,"initialSize");Ct(a,Gp),r.hideLoading(e),Z==="full"?u.zoomToFull(H):Z==="cover"?u.zoomToCover(H):Z==="max"?u.zoomToMax(H):u.reset(.172)})}getZoomInfo(e){const{el:n,imageEl:i,thumbEl:r,panzoom:a}=e,u=this.instance,l=u.container;if(!n||!i||!r||!a||K1(r)<3||!this.optionFor(e,"zoom")||!l||u.state===Ei.Destroy||getComputedStyle(l).getPropertyValue("--f-images-zoom")==="0")return!1;const g=window.visualViewport||null;if((g?g.scale:1)!==1)return!1;let{top:_,left:k,width:E,height:T}=r.getBoundingClientRect(),{top:I,left:z,fitWidth:V,fitHeight:H}=a.contentRect;if(!(E&&T&&V&&H))return!1;const Z=a.container.getBoundingClientRect();z+=Z.left,I+=Z.top;const ee=-1*(z+.5*V-(k+.5*E)),oe=-1*(I+.5*H-(_+.5*T)),J=E/V;let Ae=this.option("zoomOpacity")||!1;return Ae==="auto"&&(Ae=Math.abs(E/T-V/H)>.1),{x:ee,y:oe,scale:J,opacity:Ae}}attach(){const e=this,n=e.instance;n.on("Carousel.change",e.onChange),n.on("Carousel.createSlide",e.onCreateSlide),n.on("Carousel.removeSlide",e.onRemoveSlide),n.on("close",e.onClose)}detach(){const e=this,n=e.instance;n.off("Carousel.change",e.onChange),n.off("Carousel.createSlide",e.onCreateSlide),n.off("Carousel.removeSlide",e.onRemoveSlide),n.off("close",e.onClose)}}Object.defineProperty(ov,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{initialSize:"fit",Panzoom:{maxScale:1},protected:!1,zoom:!0,zoomOpacity:"auto"}}),typeof SuppressedError=="function"&&SuppressedError;const fy="html",av="image",my="map",Io="youtube",gl="vimeo",gh="html5video",lv=(t,e={})=>{const n=new URL(t),i=new URLSearchParams(n.search),r=new URLSearchParams;for(const[l,g]of[...i,...Object.entries(e)]){let _=g+"";if(l==="t"){let k=_.match(/((\d*)m)?(\d*)s?/);k&&r.set("start",60*parseInt(k[2]||"0")+parseInt(k[3]||"0")+"")}else r.set(l,_)}let a=r+"",u=t.match(/#t=((.*)?\d+s)/);return u&&(a+=`#t=${u[1]}`),a},Dz={ajax:null,autoSize:!0,iframeAttr:{allow:"autoplay; fullscreen",scrolling:"auto"},preload:!0,videoAutoplay:!0,videoRatio:16/9,videoTpl:`<video class="fancybox__html5video" playsinline controls controlsList="nodownload" poster="{{poster}}">
|
|
629
629
|
<source src="{{src}}" type="{{format}}" />Sorry, your browser doesn't support embedded videos.</video>`,videoFormat:"",vimeo:{byline:1,color:"00adef",controls:1,dnt:1,muted:0},youtube:{controls:1,enablejsapi:1,nocookie:1,rel:0,fs:1}},Oz=["image","html","ajax","inline","clone","iframe","map","pdf","html5video","youtube","vimeo"];class cv extends Fs{onBeforeInitSlide(e,n,i){this.processType(i)}onCreateSlide(e,n,i){this.setContent(i)}onClearContent(e,n){n.xhr&&(n.xhr.abort(),n.xhr=null);const i=n.iframeEl;i&&(i.onload=i.onerror=null,i.src="//about:blank",n.iframeEl=null);const r=n.contentEl,a=n.placeholderEl;if(n.type==="inline"&&r&&a)r.classList.remove("fancybox__content"),getComputedStyle(r).getPropertyValue("display")!=="none"&&(r.style.display="none"),setTimeout(()=>{a&&(r&&a.parentNode&&a.parentNode.insertBefore(r,a),a.remove())},0),n.contentEl=void 0,n.placeholderEl=void 0;else for(;n.el&&n.el.firstChild;)n.el.removeChild(n.el.firstChild)}onSelectSlide(e,n,i){i.state===Xi.Ready&&this.playVideo()}onUnselectSlide(e,n,i){var r,a;if(i.type===gh){try{(a=(r=i.el)===null||r===void 0?void 0:r.querySelector("video"))===null||a===void 0||a.pause()}catch{}return}let u;i.type===gl?u={method:"pause",value:"true"}:i.type===Io&&(u={event:"command",func:"pauseVideo"}),u&&i.iframeEl&&i.iframeEl.contentWindow&&i.iframeEl.contentWindow.postMessage(JSON.stringify(u),"*"),i.poller&&clearTimeout(i.poller)}onDone(e,n){e.isCurrentSlide(n)&&!e.isClosing()&&this.playVideo()}onRefresh(e,n){n.slides.forEach(i=>{i.el&&(this.resizeIframe(i),this.setAspectRatio(i))})}onMessage(e){try{let n=JSON.parse(e.data);if(e.origin==="https://player.vimeo.com"){if(n.event==="ready")for(let i of Array.from(document.getElementsByClassName("fancybox__iframe")))i instanceof HTMLIFrameElement&&i.contentWindow===e.source&&(i.dataset.ready="true")}else if(e.origin.match(/^https:\/\/(www.)?youtube(-nocookie)?.com$/)&&n.event==="onReady"){const i=document.getElementById(n.id);i&&(i.dataset.ready="true")}}catch{}}loadAjaxContent(e){const n=this.instance.optionFor(e,"src")||"";this.instance.showLoading(e);const i=this.instance,r=new XMLHttpRequest;i.showLoading(e),r.onreadystatechange=function(){r.readyState===XMLHttpRequest.DONE&&i.state===Ei.Ready&&(i.hideLoading(e),r.status===200?i.setContent(e,r.responseText):i.setError(e,r.status===404?"{{AJAX_NOT_FOUND}}":"{{AJAX_FORBIDDEN}}"))};const a=e.ajax||null;r.open(a?"POST":"GET",n+""),r.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),r.setRequestHeader("X-Requested-With","XMLHttpRequest"),r.send(a),e.xhr=r}setInlineContent(e){let n=null;if(Tr(e.src))n=e.src;else if(typeof e.src=="string"){const i=e.src.split("#",2).pop();n=i?document.getElementById(i):null}if(n){if(e.type==="clone"||n.closest(".fancybox__slide")){n=n.cloneNode(!0);const i=n.dataset.animationName;i&&(n.classList.remove(i),delete n.dataset.animationName);let r=n.getAttribute("id");r=r?`${r}--clone`:`clone-${this.instance.id}-${e.index}`,n.setAttribute("id",r)}else if(n.parentNode){const i=document.createElement("div");i.classList.add("fancybox-placeholder"),n.parentNode.insertBefore(i,n),e.placeholderEl=i}this.instance.setContent(e,n)}else this.instance.setError(e,"{{ELEMENT_NOT_FOUND}}")}setIframeContent(e){const{src:n,el:i}=e;if(!n||typeof n!="string"||!i)return;i.classList.add("is-loading");const r=this.instance,a=document.createElement("iframe");a.className="fancybox__iframe",a.setAttribute("id",`fancybox__iframe_${r.id}_${e.index}`);for(const[l,g]of Object.entries(this.optionFor(e,"iframeAttr")||{}))a.setAttribute(l,g);a.onerror=()=>{r.setError(e,"{{IFRAME_ERROR}}")},e.iframeEl=a;const u=this.optionFor(e,"preload");if(e.type!=="iframe"||u===!1)return a.setAttribute("src",e.src+""),r.setContent(e,a,!1),this.resizeIframe(e),void r.revealContent(e);r.showLoading(e),a.onload=()=>{if(!a.src.length)return;const l=a.dataset.ready!=="true";a.dataset.ready="true",this.resizeIframe(e),l?r.revealContent(e):r.hideLoading(e)},a.setAttribute("src",n),r.setContent(e,a,!1)}resizeIframe(e){const{type:n,iframeEl:i}=e;if(n===Io||n===gl)return;const r=i==null?void 0:i.parentElement;if(!i||!r)return;let a=e.autoSize;a===void 0&&(a=this.optionFor(e,"autoSize"));let u=e.width||0,l=e.height||0;u&&l&&(a=!1);const g=r&&r.style;if(e.preload!==!1&&a!==!1&&g)try{const _=window.getComputedStyle(r),k=parseFloat(_.paddingLeft)+parseFloat(_.paddingRight),E=parseFloat(_.paddingTop)+parseFloat(_.paddingBottom),T=i.contentWindow;if(T){const I=T.document,z=I.getElementsByTagName(fy)[0],V=I.body;g.width="",V.style.overflow="hidden",u=u||z.scrollWidth+k,g.width=`${u}px`,V.style.overflow="",g.flex="0 0 auto",g.height=`${V.scrollHeight}px`,l=z.scrollHeight+E}}catch{}if(u||l){const _={flex:"0 1 auto",width:"",height:""};u&&u!=="auto"&&(_.width=`${u}px`),l&&l!=="auto"&&(_.height=`${l}px`),Object.assign(g,_)}}playVideo(){const e=this.instance.getSlide();if(!e)return;const{el:n}=e;if(!n||!n.offsetParent||!this.optionFor(e,"videoAutoplay"))return;if(e.type===gh)try{const r=n.querySelector("video");if(r){const a=r.play();a!==void 0&&a.then(()=>{}).catch(u=>{r.muted=!0,r.play()})}}catch{}if(e.type!==Io&&e.type!==gl)return;const i=()=>{if(e.iframeEl&&e.iframeEl.contentWindow){let r;if(e.iframeEl.dataset.ready==="true")return r=e.type===Io?{event:"command",func:"playVideo"}:{method:"play",value:"true"},r&&e.iframeEl.contentWindow.postMessage(JSON.stringify(r),"*"),void(e.poller=void 0);e.type===Io&&(r={event:"listening",id:e.iframeEl.getAttribute("id")},e.iframeEl.contentWindow.postMessage(JSON.stringify(r),"*"))}e.poller=setTimeout(i,250)};i()}processType(e){if(e.html)return e.type=fy,e.src=e.html,void(e.html="");const n=this.instance.optionFor(e,"src","");if(!n||typeof n!="string")return;let i=e.type,r=null;if(r=n.match(/(youtube\.com|youtu\.be|youtube\-nocookie\.com)\/(?:watch\?(?:.*&)?v=|v\/|u\/|shorts\/|embed\/?)?(videoseries\?list=(?:.*)|[\w-]{11}|\?listType=(?:.*)&list=(?:.*))(?:.*)/i)){const a=this.optionFor(e,Io),{nocookie:u}=a,l=function(E,T){var I={};for(var z in E)Object.prototype.hasOwnProperty.call(E,z)&&T.indexOf(z)<0&&(I[z]=E[z]);if(E!=null&&typeof Object.getOwnPropertySymbols=="function"){var V=0;for(z=Object.getOwnPropertySymbols(E);V<z.length;V++)T.indexOf(z[V])<0&&Object.prototype.propertyIsEnumerable.call(E,z[V])&&(I[z[V]]=E[z[V]])}return I}(a,["nocookie"]),g=`www.youtube${u?"-nocookie":""}.com`,_=lv(n,l),k=encodeURIComponent(r[2]);e.videoId=k,e.src=`https://${g}/embed/${k}?${_}`,e.thumbSrc=e.thumbSrc||`https://i.ytimg.com/vi/${k}/mqdefault.jpg`,i=Io}else if(r=n.match(/^.+vimeo.com\/(?:\/)?([\d]+)((\/|\?h=)([a-z0-9]+))?(.*)?/)){const a=lv(n,this.optionFor(e,gl)),u=encodeURIComponent(r[1]),l=r[4]||"";e.videoId=u,e.src=`https://player.vimeo.com/video/${u}?${l?`h=${l}${a?"&":""}`:""}${a}`,i=gl}if(!i&&e.triggerEl){const a=e.triggerEl.dataset.type;Oz.includes(a)&&(i=a)}i||typeof n=="string"&&(n.charAt(0)==="#"?i="inline":(r=n.match(/\.(mp4|mov|ogv|webm)((\?|#).*)?$/i))?(i=gh,e.videoFormat=e.videoFormat||"video/"+(r[1]==="ogv"?"ogg":r[1])):n.match(/(^data:image\/[a-z0-9+\/=]*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp|svg|ico)((\?|#).*)?$)/i)?i=av:n.match(/\.(pdf)((\?|#).*)?$/i)&&(i="pdf")),(r=n.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:(?:(?:maps\/(?:place\/(?:.*)\/)?\@(.*),(\d+.?\d+?)z))|(?:\?ll=))(.*)?/i))?(e.src=`https://maps.google.${r[1]}/?ll=${(r[2]?r[2]+"&z="+Math.floor(parseFloat(r[3]))+(r[4]?r[4].replace(/^\//,"&"):""):r[4]+"").replace(/\?/,"&")}&output=${r[4]&&r[4].indexOf("layer=c")>0?"svembed":"embed"}`,i=my):(r=n.match(/(?:maps\.)?google\.([a-z]{2,3}(?:\.[a-z]{2})?)\/(?:maps\/search\/)(.*)/i))&&(e.src=`https://maps.google.${r[1]}/maps?q=${r[2].replace("query=","q=").replace("api=1","")}&output=embed`,i=my),i=i||this.instance.option("defaultType"),e.type=i,i===av&&(e.thumbSrc=e.thumbSrc||e.src)}setContent(e){const n=this.instance.optionFor(e,"src")||"";if(e&&e.type&&n){switch(e.type){case fy:this.instance.setContent(e,n);break;case gh:const i=this.option("videoTpl");i&&this.instance.setContent(e,i.replace(/\{\{src\}\}/gi,n+"").replace(/\{\{format\}\}/gi,this.optionFor(e,"videoFormat")||"").replace(/\{\{poster\}\}/gi,e.poster||e.thumbSrc||""));break;case"inline":case"clone":this.setInlineContent(e);break;case"ajax":this.loadAjaxContent(e);break;case"pdf":case my:case Io:case gl:e.preload=!1;case"iframe":this.setIframeContent(e)}this.setAspectRatio(e)}}setAspectRatio(e){const n=e.contentEl;if(!(e.el&&n&&e.type&&[Io,gl,gh].includes(e.type)))return;let i,r=e.width||"auto",a=e.height||"auto";if(r==="auto"||a==="auto"){i=this.optionFor(e,"videoRatio");const _=(i+"").match(/(\d+)\s*\/\s?(\d+)/);i=_&&_.length>2?parseFloat(_[1])/parseFloat(_[2]):parseFloat(i+"")}else r&&a&&(i=r/a);if(!i)return;n.style.aspectRatio="",n.style.width="",n.style.height="",n.offsetHeight;const u=n.getBoundingClientRect(),l=u.width||1,g=u.height||1;n.style.aspectRatio=i+"",i<l/g?(a=a==="auto"?g:Math.min(g,a),n.style.width="auto",n.style.height=`${a}px`):(r=r==="auto"?l:Math.min(l,r),n.style.width=`${r}px`,n.style.height="auto")}attach(){const e=this,n=e.instance;n.on("Carousel.beforeInitSlide",e.onBeforeInitSlide),n.on("Carousel.createSlide",e.onCreateSlide),n.on("Carousel.selectSlide",e.onSelectSlide),n.on("Carousel.unselectSlide",e.onUnselectSlide),n.on("Carousel.Panzoom.refresh",e.onRefresh),n.on("done",e.onDone),n.on("clearContent",e.onClearContent),window.addEventListener("message",e.onMessage)}detach(){const e=this,n=e.instance;n.off("Carousel.beforeInitSlide",e.onBeforeInitSlide),n.off("Carousel.createSlide",e.onCreateSlide),n.off("Carousel.selectSlide",e.onSelectSlide),n.off("Carousel.unselectSlide",e.onUnselectSlide),n.off("Carousel.Panzoom.refresh",e.onRefresh),n.off("done",e.onDone),n.off("clearContent",e.onClearContent),window.removeEventListener("message",e.onMessage)}}Object.defineProperty(cv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Dz});const Zp="play",Yp="pause",yh="ready";class uv extends Fs{constructor(){super(...arguments),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:yh}),Object.defineProperty(this,"inHover",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"timer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"progressBar",{enumerable:!0,configurable:!0,writable:!0,value:null})}get isActive(){return this.state!==yh}onReady(e){this.option("autoStart")&&(e.isInfinite||e.page<e.pages.length-1)&&this.start()}onChange(){this.removeProgressBar(),this.pause()}onSettle(){this.resume()}onVisibilityChange(){document.visibilityState==="visible"?this.resume():this.pause()}onMouseEnter(){this.inHover=!0,this.pause()}onMouseLeave(){var e;this.inHover=!1,!((e=this.instance.panzoom)===null||e===void 0)&&e.isResting&&this.resume()}onTimerEnd(){const e=this.instance;this.state==="play"&&(e.isInfinite||e.page!==e.pages.length-1?e.slideNext():e.slideTo(0))}removeProgressBar(){this.progressBar&&(this.progressBar.remove(),this.progressBar=null)}createProgressBar(){var e;if(!this.option("showProgress"))return null;this.removeProgressBar();const n=this.instance,i=((e=n.pages[n.page])===null||e===void 0?void 0:e.slides)||[];let r=this.option("progressParentEl");if(r||(r=(i.length===1?i[0].el:null)||n.viewport),!r)return null;const a=document.createElement("div");return Ct(a,"f-progress"),r.prepend(a),this.progressBar=a,a.offsetHeight,a}set(){const e=this,n=e.instance;if(n.pages.length<2||e.timer)return;const i=e.option("timeout");e.state=Zp,Ct(n.container,"has-autoplay");let r=e.createProgressBar();r&&(r.style.transitionDuration=`${i}ms`,r.style.transform="scaleX(1)"),e.timer=setTimeout(()=>{e.timer=null,e.inHover||e.onTimerEnd()},i),e.emit("set")}clear(){const e=this;e.timer&&(clearTimeout(e.timer),e.timer=null),e.removeProgressBar()}start(){const e=this;if(e.set(),e.state!==yh){if(e.option("pauseOnHover")){const n=e.instance.container;n.addEventListener("mouseenter",e.onMouseEnter,!1),n.addEventListener("mouseleave",e.onMouseLeave,!1)}document.addEventListener("visibilitychange",e.onVisibilityChange,!1),e.emit("start")}}stop(){const e=this,n=e.state,i=e.instance.container;e.clear(),e.state=yh,i.removeEventListener("mouseenter",e.onMouseEnter,!1),i.removeEventListener("mouseleave",e.onMouseLeave,!1),document.removeEventListener("visibilitychange",e.onVisibilityChange,!1),kn(i,"has-autoplay"),n!==yh&&e.emit("stop")}pause(){const e=this;e.state===Zp&&(e.state=Yp,e.clear(),e.emit(Yp))}resume(){const e=this,n=e.instance;if(n.isInfinite||n.page!==n.pages.length-1)if(e.state!==Zp){if(e.state===Yp&&!e.inHover){const i=new Event("resume",{bubbles:!0,cancelable:!0});e.emit("resume",i),i.defaultPrevented||e.set()}}else e.set();else e.stop()}toggle(){this.state===Zp||this.state===Yp?this.stop():this.start()}attach(){const e=this,n=e.instance;n.on("ready",e.onReady),n.on("Panzoom.startAnimation",e.onChange),n.on("Panzoom.endAnimation",e.onSettle),n.on("Panzoom.touchMove",e.onChange)}detach(){const e=this,n=e.instance;n.off("ready",e.onReady),n.off("Panzoom.startAnimation",e.onChange),n.off("Panzoom.endAnimation",e.onSettle),n.off("Panzoom.touchMove",e.onChange),e.stop()}}Object.defineProperty(uv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{autoStart:!0,pauseOnHover:!0,progressParentEl:null,showProgress:!0,timeout:3e3}});class hv extends Fs{constructor(){super(...arguments),Object.defineProperty(this,"ref",{enumerable:!0,configurable:!0,writable:!0,value:null})}onPrepare(e){const n=e.carousel;if(!n)return;const i=e.container;i&&(n.options.Autoplay=Cr({autoStart:!1},this.option("Autoplay")||{},{pauseOnHover:!1,timeout:this.option("timeout"),progressParentEl:()=>this.option("progressParentEl")||null,on:{start:()=>{e.emit("startSlideshow")},set:r=>{var a;i.classList.add("has-slideshow"),((a=e.getSlide())===null||a===void 0?void 0:a.state)!==Xi.Ready&&r.pause()},stop:()=>{i.classList.remove("has-slideshow"),e.isCompact||e.endIdle(),e.emit("endSlideshow")},resume:(r,a)=>{var u,l,g;!a||!a.cancelable||((u=e.getSlide())===null||u===void 0?void 0:u.state)===Xi.Ready&&(!((g=(l=e.carousel)===null||l===void 0?void 0:l.panzoom)===null||g===void 0)&&g.isResting)||a.preventDefault()}}}),n.attachPlugins({Autoplay:uv}),this.ref=n.plugins.Autoplay)}onReady(e){const n=e.carousel,i=this.ref;i&&n&&this.option("playOnStart")&&(n.isInfinite||n.page<n.pages.length-1)&&i.start()}onDone(e,n){const i=this.ref,r=e.carousel;if(!i||!r)return;const a=n.panzoom;a&&a.on("startAnimation",()=>{e.isCurrentSlide(n)&&i.stop()}),e.isCurrentSlide(n)&&i.resume()}onKeydown(e,n){var i;const r=this.ref;r&&n===this.option("key")&&((i=document.activeElement)===null||i===void 0?void 0:i.nodeName)!=="BUTTON"&&r.toggle()}attach(){const e=this,n=e.instance;n.on("Carousel.init",e.onPrepare),n.on("Carousel.ready",e.onReady),n.on("done",e.onDone),n.on("keydown",e.onKeydown)}detach(){const e=this,n=e.instance;n.off("Carousel.init",e.onPrepare),n.off("Carousel.ready",e.onReady),n.off("done",e.onDone),n.off("keydown",e.onKeydown)}}Object.defineProperty(hv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:{key:" ",playOnStart:!1,progressParentEl:t=>{var e;return((e=t.instance.container)===null||e===void 0?void 0:e.querySelector(".fancybox__toolbar [data-fancybox-toggle-slideshow]"))||t.instance.container},timeout:3e3}});const dv={classes:{container:"f-thumbs f-carousel__thumbs",viewport:"f-thumbs__viewport",track:"f-thumbs__track",slide:"f-thumbs__slide",isResting:"is-resting",isSelected:"is-selected",isLoading:"is-loading",hasThumbs:"has-thumbs"},minCount:2,parentEl:null,thumbTpl:'<button class="f-thumbs__slide__button" tabindex="0" type="button" aria-label="{{GOTO}}" data-carousel-index="%i"><img class="f-thumbs__slide__img" data-lazy-src="{{%s}}" alt="" /></button>',type:"modern"};var Do;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Hidden=2]="Hidden"})(Do||(Do={}));const pv="isResting",Xp="thumbWidth",Cc="thumbHeight",no="thumbClipWidth";let fv=class extends Fs{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"modern"}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"track",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"carousel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"thumbWidth",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"thumbClipWidth",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"thumbHeight",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"thumbGap",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"thumbExtraGap",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Do.Init})}get isModern(){return this.type==="modern"}onInitSlide(t,e){const n=e.el?e.el.dataset:void 0;n&&(e.thumbSrc=n.thumbSrc||e.thumbSrc||"",e[no]=parseFloat(n[no]||"")||e[no]||0,e[Cc]=parseFloat(n.thumbHeight||"")||e[Cc]||0),this.addSlide(e)}onInitSlides(){this.build()}onChange(){var t;if(!this.isModern)return;const e=this.container,n=this.instance,i=n.panzoom,r=this.carousel,a=r?r.panzoom:null,u=n.page;if(i&&r&&a){if(i.isDragging){kn(e,this.cn(pv));let l=((t=r.pages[u])===null||t===void 0?void 0:t.pos)||0;l+=n.getProgress(u)*(this[no]+this.thumbGap);let g=a.getBounds();-1*l>g.x.min&&-1*l<g.x.max&&a.panTo({x:-1*l,friction:.12})}else to(e,this.cn(pv),i.isResting);this.shiftModern()}}onRefresh(){this.updateProps();for(const t of this.instance.slides||[])this.resizeModernSlide(t);this.shiftModern()}isDisabled(){const t=this.option("minCount")||0;if(t){const n=this.instance;let i=0;for(const r of n.slides||[])r.thumbSrc&&i++;if(i<t)return!0}const e=this.option("type");return["modern","classic"].indexOf(e)<0}getThumb(t){const e=this.option("thumbTpl")||"";return{html:this.instance.localize(e,[["%i",t.index],["%d",t.index+1],["%s",t.thumbSrc||"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"]])}}addSlide(t){const e=this.carousel;e&&e.addSlide(t.index,this.getThumb(t))}getSlides(){const t=[];for(const e of this.instance.slides||[])t.push(this.getThumb(e));return t}resizeModernSlide(t){this.isModern&&(t[Xp]=t[no]&&t[Cc]?Math.round(this[Cc]*(t[no]/t[Cc])):this[Xp])}updateProps(){const t=this.container;if(!t)return;const e=n=>parseFloat(getComputedStyle(t).getPropertyValue("--f-thumb-"+n))||0;this.thumbGap=e("gap"),this.thumbExtraGap=e("extra-gap"),this[Xp]=e("width")||40,this[no]=e("clip-width")||40,this[Cc]=e("height")||40}build(){const t=this;if(t.state!==Do.Init)return;if(t.isDisabled())return void t.emit("disabled");const e=t.instance,n=e.container,i=t.getSlides(),r=t.option("type");t.type=r;const a=t.option("parentEl"),u=t.cn("container"),l=t.cn("track");let g=a==null?void 0:a.querySelector("."+u);g||(g=document.createElement("div"),Ct(g,u),a?a.appendChild(g):n.after(g)),Ct(g,`is-${r}`),Ct(n,t.cn("hasThumbs")),t.container=g,t.updateProps();let _=g.querySelector("."+l);_||(_=document.createElement("div"),Ct(_,t.cn("track")),g.appendChild(_)),t.track=_;const k=Cr({},{track:_,infinite:!1,center:!0,fill:r==="classic",dragFree:!0,slidesPerPage:1,transition:!1,preload:.25,friction:.12,Panzoom:{maxVelocity:0},Dots:!1,Navigation:!1,classes:{container:"f-thumbs",viewport:"f-thumbs__viewport",track:"f-thumbs__track",slide:"f-thumbs__slide"}},t.option("Carousel")||{},{Sync:{target:e},slides:i}),E=new e.constructor(g,k);E.on("createSlide",(T,I)=>{t.setProps(I.index),t.emit("createSlide",I,I.el)}),E.on("ready",()=>{t.shiftModern(),t.emit("ready")}),E.on("refresh",()=>{t.shiftModern()}),E.on("Panzoom.click",(T,I,z)=>{t.onClick(z)}),t.carousel=E,t.state=Do.Ready}onClick(t){t.preventDefault(),t.stopPropagation();const e=this.instance,{pages:n,page:i}=e,r=V=>{if(V){const H=V.closest("[data-carousel-index]");if(H)return[parseInt(H.dataset.carouselIndex||"",10)||0,H]}return[-1,void 0]},a=(V,H)=>{const Z=document.elementFromPoint(V,H);return Z?r(Z):[-1,void 0]};let[u,l]=r(t.target);if(u>-1)return;const g=this[no],_=t.clientX,k=t.clientY;let[E,T]=a(_-g,k),[I,z]=a(_+g,k);T&&z?(u=Math.abs(_-T.getBoundingClientRect().right)<Math.abs(_-z.getBoundingClientRect().left)?E:I,u===i&&(u=u===E?I:E)):T?u=E:z&&(u=I),u>-1&&n[u]&&e.slideTo(u)}getShift(t){var e;const n=this,{instance:i}=n,r=n.carousel;if(!i||!r)return 0;const a=n[Xp],u=n[no],l=n.thumbGap,g=n.thumbExtraGap;if(!(!((e=r.slides[t])===null||e===void 0)&&e.el))return 0;const _=.5*(a-u),k=i.pages.length-1;let E=i.getProgress(0),T=i.getProgress(k),I=i.getProgress(t,!1,!0),z=0,V=_+g+l;const H=E<0&&E>-1,Z=T>0&&T<1;return t===0?(z=V*Math.abs(E),Z&&E===1&&(z-=V*Math.abs(T))):t===k?(z=V*Math.abs(T)*-1,H&&T===-1&&(z+=V*Math.abs(E))):H||Z?(z=-1*V,z+=V*Math.abs(E),z+=V*(1-Math.abs(T))):z=V*I,z}setProps(t){var e;const n=this;if(!n.isModern)return;const{instance:i}=n,r=n.carousel;if(i&&r){const a=(e=r.slides[t])===null||e===void 0?void 0:e.el;if(a&&a.childNodes.length){let u=st(1-Math.abs(i.getProgress(t))),l=st(n.getShift(t));a.style.setProperty("--progress",u?u+"":""),a.style.setProperty("--shift",l+"")}}}shiftModern(){const t=this;if(!t.isModern)return;const{instance:e,track:n}=t,i=e.panzoom,r=t.carousel;if(!(e&&n&&i&&r)||i.state===An.Init||i.state===An.Destroy)return;for(const u of e.slides)t.setProps(u.index);let a=(t[no]+t.thumbGap)*(r.slides.length||0);n.style.setProperty("--width",a+"")}cleanup(){const t=this;t.carousel&&t.carousel.destroy(),t.carousel=null,t.container&&t.container.remove(),t.container=null,t.track&&t.track.remove(),t.track=null,t.state=Do.Init,kn(t.instance.container,t.cn("hasThumbs"))}attach(){const t=this,e=t.instance;e.on("initSlide",t.onInitSlide),e.state===ci.Init?e.on("initSlides",t.onInitSlides):t.onInitSlides(),e.on(["change","Panzoom.afterTransform"],t.onChange),e.on("Panzoom.refresh",t.onRefresh)}detach(){const t=this,e=t.instance;e.off("initSlide",t.onInitSlide),e.off("initSlides",t.onInitSlides),e.off(["change","Panzoom.afterTransform"],t.onChange),e.off("Panzoom.refresh",t.onRefresh),t.cleanup()}};Object.defineProperty(fv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:dv});const zz=Object.assign(Object.assign({},dv),{key:"t",showOnStart:!0,parentEl:null}),mv="is-masked",gv="aria-hidden";class yv extends Fs{constructor(){super(...arguments),Object.defineProperty(this,"ref",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"hidden",{enumerable:!0,configurable:!0,writable:!0,value:!1})}get isEnabled(){const e=this.ref;return e&&!e.isDisabled()}get isHidden(){return this.hidden}onClick(e,n){n.stopPropagation()}onCreateSlide(e,n){var i,r,a;const u=((a=(r=(i=this.instance)===null||i===void 0?void 0:i.carousel)===null||r===void 0?void 0:r.slides[n.index])===null||a===void 0?void 0:a.type)||"",l=n.el;if(l&&u){let g=`for-${u}`;["video","youtube","vimeo","html5video"].includes(u)&&(g+=" for-video"),Ct(l,g)}}onInit(){var e;const n=this,i=n.instance,r=i.carousel;if(n.ref||!r)return;const a=n.option("parentEl")||i.footer||i.container;if(!a)return;const u=Cr({},n.options,{parentEl:a,classes:{container:"f-thumbs fancybox__thumbs"},Carousel:{Sync:{friction:i.option("Carousel.friction")||0}},on:{ready:l=>{const g=l.container;g&&this.hidden&&(n.refresh(),g.style.transition="none",n.hide(),g.offsetHeight,queueMicrotask(()=>{g.style.transition="",n.show()}))}}});u.Carousel=u.Carousel||{},u.Carousel.on=Cr(((e=n.options.Carousel)===null||e===void 0?void 0:e.on)||{},{click:this.onClick,createSlide:this.onCreateSlide}),r.options.Thumbs=u,r.attachPlugins({Thumbs:fv}),n.ref=r.plugins.Thumbs,n.option("showOnStart")||(n.ref.state=Do.Hidden,n.hidden=!0)}onResize(){var e;const n=(e=this.ref)===null||e===void 0?void 0:e.container;n&&(n.style.maxHeight="")}onKeydown(e,n){const i=this.option("key");i&&i===n&&this.toggle()}toggle(){const e=this.ref;if(e&&!e.isDisabled())return e.state===Do.Hidden?(e.state=Do.Init,void e.build()):void(this.hidden?this.show():this.hide())}show(){const e=this.ref;if(!e||e.isDisabled())return;const n=e.container;n&&(this.refresh(),n.offsetHeight,n.removeAttribute(gv),n.classList.remove(mv),this.hidden=!1)}hide(){const e=this.ref,n=e&&e.container;n&&(this.refresh(),n.offsetHeight,n.classList.add(mv),n.setAttribute(gv,"true")),this.hidden=!0}refresh(){const e=this.ref;if(!e||!e.state)return;const n=e.container,i=(n==null?void 0:n.firstChild)||null;n&&i&&i.childNodes.length&&(n.style.maxHeight=`${i.getBoundingClientRect().height}px`)}attach(){const e=this,n=e.instance;n.state===Ei.Init?n.on("Carousel.init",e.onInit):e.onInit(),n.on("resize",e.onResize),n.on("keydown",e.onKeydown)}detach(){var e;const n=this,i=n.instance;i.off("Carousel.init",n.onInit),i.off("resize",n.onResize),i.off("keydown",n.onKeydown),(e=i.carousel)===null||e===void 0||e.detachPlugins(["Thumbs"]),n.ref=null}}Object.defineProperty(yv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:zz});const gy={panLeft:{icon:'<svg><path d="M5 12h14M5 12l6 6M5 12l6-6"/></svg>',change:{panX:-100}},panRight:{icon:'<svg><path d="M5 12h14M13 18l6-6M13 6l6 6"/></svg>',change:{panX:100}},panUp:{icon:'<svg><path d="M12 5v14M18 11l-6-6M6 11l6-6"/></svg>',change:{panY:-100}},panDown:{icon:'<svg><path d="M12 5v14M18 13l-6 6M6 13l6 6"/></svg>',change:{panY:100}},zoomIn:{icon:'<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M11 8v6M8 11h6"/></svg>',action:"zoomIn"},zoomOut:{icon:'<svg><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',action:"zoomOut"},toggle1to1:{icon:'<svg><path d="M3.51 3.07c5.74.02 11.48-.02 17.22.02 1.37.1 2.34 1.64 2.18 3.13 0 4.08.02 8.16 0 12.23-.1 1.54-1.47 2.64-2.79 2.46-5.61-.01-11.24.02-16.86-.01-1.36-.12-2.33-1.65-2.17-3.14 0-4.07-.02-8.16 0-12.23.1-1.36 1.22-2.48 2.42-2.46Z"/><path d="M5.65 8.54h1.49v6.92m8.94-6.92h1.49v6.92M11.5 9.4v.02m0 5.18v0"/></svg>',action:"toggleZoom"},toggleZoom:{icon:'<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',action:"toggleZoom"},iterateZoom:{icon:'<svg><g><line x1="11" y1="8" x2="11" y2="14"></line></g><circle cx="11" cy="11" r="7.5"/><path d="m21 21-4.35-4.35M8 11h6"/></svg>',action:"iterateZoom"},rotateCCW:{icon:'<svg><path d="M15 4.55a8 8 0 0 0-6 14.9M9 15v5H4M18.37 7.16v.01M13 19.94v.01M16.84 18.37v.01M19.37 15.1v.01M19.94 11v.01"/></svg>',action:"rotateCCW"},rotateCW:{icon:'<svg><path d="M9 4.55a8 8 0 0 1 6 14.9M15 15v5h5M5.63 7.16v.01M4.06 11v.01M4.63 15.1v.01M7.16 18.37v.01M11 19.94v.01"/></svg>',action:"rotateCW"},flipX:{icon:'<svg style="stroke-width: 1.3"><path d="M12 3v18M16 7v10h5L16 7M8 7v10H3L8 7"/></svg>',action:"flipX"},flipY:{icon:'<svg style="stroke-width: 1.3"><path d="M3 12h18M7 16h10L7 21v-5M7 8h10L7 3v5"/></svg>',action:"flipY"},fitX:{icon:'<svg><path d="M4 12V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v6M10 18H3M21 18h-7M6 15l-3 3 3 3M18 15l3 3-3 3"/></svg>',action:"fitX"},fitY:{icon:'<svg><path d="M12 20H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h6M18 14v7M18 3v7M15 18l3 3 3-3M15 6l3-3 3 3"/></svg>',action:"fitY"},reset:{icon:'<svg><path d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4M4 13a8.1 8.1 0 0 0 15.5 2m.5 4v-4h-4"/></svg>',action:"reset"},toggleFS:{icon:'<svg><g><path d="M14.5 9.5 21 3m0 0h-6m6 0v6M3 21l6.5-6.5M3 21v-6m0 6h6"/></g><g><path d="m14 10 7-7m-7 7h6m-6 0V4M3 21l7-7m0 0v6m0-6H4"/></g></svg>',action:"toggleFS"}};var yl;(function(t){t[t.Init=0]="Init",t[t.Ready=1]="Ready",t[t.Disabled=2]="Disabled"})(yl||(yl={}));const Rz={absolute:"auto",display:{left:["infobar"],middle:[],right:["iterateZoom","slideshow","fullscreen","thumbs","close"]},enabled:"auto",items:{infobar:{tpl:'<div class="fancybox__infobar" tabindex="-1"><span data-fancybox-current-index></span>/<span data-fancybox-count></span></div>'},download:{tpl:'<a class="f-button" title="{{DOWNLOAD}}" data-fancybox-download href="javasript:;"><svg><path d="M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2M7 11l5 5 5-5M12 4v12"/></svg></a>'},prev:{tpl:'<button class="f-button" title="{{PREV}}" data-fancybox-prev><svg><path d="m15 6-6 6 6 6"/></svg></button>'},next:{tpl:'<button class="f-button" title="{{NEXT}}" data-fancybox-next><svg><path d="m9 6 6 6-6 6"/></svg></button>'},slideshow:{tpl:'<button class="f-button" title="{{TOGGLE_SLIDESHOW}}" data-fancybox-toggle-slideshow><svg><g><path d="M8 4v16l13 -8z"></path></g><g><path d="M8 4v15M17 4v15"/></g></svg></button>'},fullscreen:{tpl:'<button class="f-button" title="{{TOGGLE_FULLSCREEN}}" data-fancybox-toggle-fullscreen><svg><g><path d="M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2M16 4h2a2 2 0 0 1 2 2v2M16 20h2a2 2 0 0 0 2-2v-2"/></g><g><path d="M15 19v-2a2 2 0 0 1 2-2h2M15 5v2a2 2 0 0 0 2 2h2M5 15h2a2 2 0 0 1 2 2v2M5 9h2a2 2 0 0 0 2-2V5"/></g></svg></button>'},thumbs:{tpl:'<button class="f-button" title="{{TOGGLE_THUMBS}}" data-fancybox-toggle-thumbs><svg><circle cx="5.5" cy="5.5" r="1"/><circle cx="12" cy="5.5" r="1"/><circle cx="18.5" cy="5.5" r="1"/><circle cx="5.5" cy="12" r="1"/><circle cx="12" cy="12" r="1"/><circle cx="18.5" cy="12" r="1"/><circle cx="5.5" cy="18.5" r="1"/><circle cx="12" cy="18.5" r="1"/><circle cx="18.5" cy="18.5" r="1"/></svg></button>'},close:{tpl:'<button class="f-button" title="{{CLOSE}}" data-fancybox-close><svg><path d="m19.5 4.5-15 15M4.5 4.5l15 15"/></svg></button>'}},parentEl:null},Lz={tabindex:"-1",width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},_v="has-toolbar",yy="fancybox__toolbar";class bv extends Fs{constructor(){super(...arguments),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:yl.Init}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null})}onReady(e){var n;if(!e.carousel)return;let i=this.option("display"),r=this.option("absolute"),a=this.option("enabled");if(a==="auto"){const _=this.instance.carousel;let k=0;if(_)for(const E of _.slides)(E.panzoom||E.type==="image")&&k++;k||(a=!1)}a||(i=void 0);let u=0;const l={left:[],middle:[],right:[]};if(i)for(const _ of["left","middle","right"])for(const k of i[_]){const E=this.createEl(k);E&&((n=l[_])===null||n===void 0||n.push(E),u++)}let g=null;if(u&&(g=this.createContainer()),g){for(const[_,k]of Object.entries(l)){const E=document.createElement("div");Ct(E,yy+"__column is-"+_);for(const T of k)E.appendChild(T);r!=="auto"||_!=="middle"||k.length||(r=!0),g.appendChild(E)}r===!0&&Ct(g,"is-absolute"),this.state=yl.Ready,this.onRefresh()}else this.state=yl.Disabled}onClick(e){var n,i;const r=this.instance,a=r.getSlide(),u=a==null?void 0:a.panzoom,l=e.target,g=l&&Tr(l)?l.dataset:null;if(!g)return;if(g.fancyboxToggleThumbs!==void 0)return e.preventDefault(),e.stopPropagation(),void((n=r.plugins.Thumbs)===null||n===void 0||n.toggle());if(g.fancyboxToggleFullscreen!==void 0)return e.preventDefault(),e.stopPropagation(),void this.instance.toggleFullscreen();if(g.fancyboxToggleSlideshow!==void 0){e.preventDefault(),e.stopPropagation();const E=(i=r.carousel)===null||i===void 0?void 0:i.plugins.Autoplay;let T=E.isActive;return u&&u.panMode==="mousemove"&&!T&&u.reset(),void(T?E.stop():E.start())}const _=g.panzoomAction,k=g.panzoomChange;if((k||_)&&(e.preventDefault(),e.stopPropagation()),k){let E={};try{E=JSON.parse(k)}catch{}u&&u.applyChange(E)}else _&&u&&u[_]&&u[_]()}onChange(){this.onRefresh()}onRefresh(){if(this.instance.isClosing())return;const e=this.container;if(!e)return;const n=this.instance.getSlide();if(!n||n.state!==Xi.Ready)return;const i=n&&!n.error&&n.panzoom;for(const u of e.querySelectorAll("[data-panzoom-action]"))i?(u.removeAttribute("disabled"),u.removeAttribute("tabindex")):(u.setAttribute("disabled",""),u.setAttribute("tabindex","-1"));let r=i&&i.canZoomIn(),a=i&&i.canZoomOut();for(const u of e.querySelectorAll('[data-panzoom-action="zoomIn"]'))r?(u.removeAttribute("disabled"),u.removeAttribute("tabindex")):(u.setAttribute("disabled",""),u.setAttribute("tabindex","-1"));for(const u of e.querySelectorAll('[data-panzoom-action="zoomOut"]'))a?(u.removeAttribute("disabled"),u.removeAttribute("tabindex")):(u.setAttribute("disabled",""),u.setAttribute("tabindex","-1"));for(const u of e.querySelectorAll('[data-panzoom-action="toggleZoom"],[data-panzoom-action="iterateZoom"]')){a||r?(u.removeAttribute("disabled"),u.removeAttribute("tabindex")):(u.setAttribute("disabled",""),u.setAttribute("tabindex","-1"));const l=u.querySelector("g");l&&(l.style.display=r?"":"none")}}onDone(e,n){var i;(i=n.panzoom)===null||i===void 0||i.on("afterTransform",()=>{this.instance.isCurrentSlide(n)&&this.onRefresh()}),this.instance.isCurrentSlide(n)&&this.onRefresh()}createContainer(){const e=this.instance.container;if(!e)return null;const n=this.option("parentEl")||e;let i=n.querySelector("."+yy);return i||(i=document.createElement("div"),Ct(i,yy),n.prepend(i)),i.addEventListener("click",this.onClick,{passive:!1,capture:!0}),e&&Ct(e,_v),this.container=i,i}createEl(e){const n=this.instance,i=n.carousel;if(!i||e==="toggleFS"||e==="fullscreen"&&!Q1())return null;let r=null;const a=i.slides.length||0;let u=0,l=0;for(const _ of i.slides)(_.panzoom||_.type==="image")&&u++,(_.type==="image"||_.downloadSrc)&&l++;if(a<2&&["infobar","prev","next"].includes(e))return r;if(gy[e]!==void 0&&!u||e==="download"&&!l)return null;if(e==="thumbs"){const _=n.plugins.Thumbs;if(!_||!_.isEnabled)return null}if(e==="slideshow"&&(!i.plugins.Autoplay||a<2))return null;if(gy[e]!==void 0){const _=gy[e];r=document.createElement("button"),r.setAttribute("title",this.instance.localize(`{{${e.toUpperCase()}}}`)),Ct(r,"f-button"),_.action&&(r.dataset.panzoomAction=_.action),_.change&&(r.dataset.panzoomChange=JSON.stringify(_.change)),r.appendChild(eo(this.instance.localize(_.icon)))}else{const _=(this.option("items")||[])[e];_&&(r=eo(this.instance.localize(_.tpl)),typeof _.click=="function"&&r.addEventListener("click",k=>{k.preventDefault(),k.stopPropagation(),typeof _.click=="function"&&_.click.call(this,this,k)}))}const g=r==null?void 0:r.querySelector("svg");if(g)for(const[_,k]of Object.entries(Lz))g.getAttribute(_)||g.setAttribute(_,String(k));return r}removeContainer(){const e=this.container;e&&e.remove(),this.container=null,this.state=yl.Disabled;const n=this.instance.container;n&&kn(n,_v)}attach(){const e=this,n=e.instance;n.on("Carousel.initSlides",e.onReady),n.on("done",e.onDone),n.on(["reveal","Carousel.change"],e.onChange),e.onReady(e.instance)}detach(){const e=this,n=e.instance;n.off("Carousel.initSlides",e.onReady),n.off("done",e.onDone),n.off(["reveal","Carousel.change"],e.onChange),e.removeContainer()}}Object.defineProperty(bv,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:Rz});const Nz={Hash:class extends Fs{onReady(){mh=!1}onChange(t){ml&&clearTimeout(ml);const{hash:e}=tv(),{hash:n}=Wp(),i=t.isOpeningSlide(t.getSlide());i&&(ev=n===e?"":n),e&&e!==n&&(ml=setTimeout(()=>{try{if(t.state===Ei.Ready){let r="replaceState";i&&!qp&&(r="pushState",qp=!0),window.history[r]({},document.title,window.location.pathname+window.location.search+e)}}catch{}},300))}onClose(t){if(ml&&clearTimeout(ml),!mh&&qp)return qp=!1,mh=!1,void window.history.back();if(!mh)try{window.history.replaceState({},document.title,window.location.pathname+window.location.search+(ev||""))}catch{}}attach(){const t=this.instance;t.on("ready",this.onReady),t.on(["Carousel.ready","Carousel.change"],this.onChange),t.on("close",this.onClose)}detach(){const t=this.instance;t.off("ready",this.onReady),t.off(["Carousel.ready","Carousel.change"],this.onChange),t.off("close",this.onClose)}static parseURL(){return Wp()}static startFromUrl(){nv()}static destroy(){window.removeEventListener("hashchange",rv,!1)}},Html:cv,Images:ov,Slideshow:hv,Thumbs:yv,Toolbar:bv},xv="with-fancybox",_y="hide-scrollbar",vv="--fancybox-scrollbar-compensate",wv="--fancybox-body-margin",by="aria-hidden",xy="is-using-tab",vy="is-animated",kv="is-compact",Sv="is-loading",wy="is-opening",Kp="has-caption",Tc="disabled",_l="tabindex",Ev="download",ky="href",Mc="src",da=t=>typeof t=="string",Cv=function(){var t=window.getSelection();return!!t&&t.type==="Range"};let ms,gs=null,bl=null,Tv=0,Mv=0,Av=0,Pv=0;const Ac=new Map;let Bz=0;class mn extends oy{get isIdle(){return this.idle}get isCompact(){return this.option("compact")}constructor(e=[],n={},i={}){super(n),Object.defineProperty(this,"userSlides",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"userPlugins",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"idle",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"idleTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"clickTimer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"pwt",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"ignoreFocusChange",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"startedFs",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:Ei.Init}),Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:0}),Object.defineProperty(this,"container",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"caption",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"footer",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"carousel",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"lastFocus",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"prevMouseMoveEvent",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),ms||(ms=Q1()),this.id=n.id||++Bz,Ac.set(this.id,this),this.userSlides=e,this.userPlugins=i,queueMicrotask(()=>{this.init()})}init(){if(this.state===Ei.Destroy)return;this.state=Ei.Init,this.attachPlugins(Object.assign(Object.assign({},mn.Plugins),this.userPlugins)),this.emit("init"),this.emit("attachPlugins"),this.option("hideScrollbar")===!0&&(()=>{if(!fh)return;const n=document,i=n.body,r=n.documentElement;if(i.classList.contains(_y))return;let a=window.innerWidth-r.getBoundingClientRect().width;const u=parseFloat(window.getComputedStyle(i).marginRight);a<0&&(a=0),r.style.setProperty(vv,`${a}px`),u&&i.style.setProperty(wv,`${u}px`),i.classList.add(_y)})(),this.initLayout(),this.scale();const e=()=>{this.initCarousel(this.userSlides),this.state=Ei.Ready,this.attachEvents(),this.emit("ready"),setTimeout(()=>{this.container&&this.container.setAttribute(by,"false")},16)};this.option("Fullscreen.autoStart")&&ms&&!ms.isFullscreen()?ms.request().then(()=>{this.startedFs=!0,e()}).catch(()=>e()):e()}initLayout(){var e,n;const i=this.option("parentEl")||document.body,r=eo(this.localize(this.option("tpl.main")||""));if(r){if(r.setAttribute("id",`fancybox-${this.id}`),r.setAttribute("aria-label",this.localize("{{MODAL}}")),r.classList.toggle(kv,this.isCompact),Ct(r,this.option("mainClass")||""),Ct(r,wy),this.container=r,this.footer=r.querySelector(".fancybox__footer"),i.appendChild(r),Ct(document.documentElement,xv),gs&&bl||(gs=document.createElement("span"),Ct(gs,"fancybox-focus-guard"),gs.setAttribute(_l,"0"),gs.setAttribute(by,"true"),gs.setAttribute("aria-label","Focus guard"),bl=gs.cloneNode(),(e=r.parentElement)===null||e===void 0||e.insertBefore(gs,r),(n=r.parentElement)===null||n===void 0||n.append(bl)),r.addEventListener("mousedown",a=>{Tv=a.pageX,Mv=a.pageY,kn(r,xy)}),this.option("closeExisting"))for(const a of Ac.values())a.id!==this.id&&a.close();else this.option("animated")&&(Ct(r,vy),setTimeout(()=>{this.isClosing()||kn(r,vy)},350));this.emit("initLayout")}}initCarousel(e){const n=this.container;if(!n)return;const i=n.querySelector(".fancybox__carousel");if(!i)return;const r=this.carousel=new ha(i,Cr({},{slides:e,transition:"fade",Panzoom:{lockAxis:this.option("dragToClose")?"xy":"x",infinite:!!this.option("dragToClose")&&"y"},Dots:!1,Navigation:{classes:{container:"fancybox__nav",button:"f-button",isNext:"is-next",isPrev:"is-prev"}},initialPage:this.option("startIndex"),l10n:this.option("l10n")},this.option("Carousel")||{}));r.on("*",(a,u,...l)=>{this.emit(`Carousel.${u}`,a,...l)}),r.on(["ready","change"],()=>{this.manageCaption()}),this.on("Carousel.removeSlide",(a,u,l)=>{this.clearContent(l),l.state=void 0}),r.on("Panzoom.touchStart",()=>{var a,u;this.isCompact||this.endIdle(),!((a=document.activeElement)===null||a===void 0)&&a.closest(".f-thumbs")&&((u=this.container)===null||u===void 0||u.focus())}),r.on("settle",()=>{this.idleTimer||this.isCompact||!this.option("idle")||this.setIdle(),this.option("autoFocus")&&!this.isClosing&&this.checkFocus()}),this.option("dragToClose")&&(r.on("Panzoom.afterTransform",(a,u)=>{const l=this.getSlide();if(l&&ny(l.el))return;const g=this.container;if(g){const _=Math.abs(u.current.f),k=_<1?"":Math.max(.5,Math.min(1,1-_/u.contentRect.fitHeight*1.5));g.style.setProperty("--fancybox-ts",k?"0s":""),g.style.setProperty("--fancybox-opacity",k+"")}}),r.on("Panzoom.touchEnd",(a,u,l)=>{var g;const _=this.getSlide();if(_&&ny(_.el)||u.isMobile&&document.activeElement&&["TEXTAREA","INPUT"].indexOf((g=document.activeElement)===null||g===void 0?void 0:g.nodeName)!==-1)return;const k=Math.abs(u.dragOffset.y);u.lockedAxis==="y"&&(k>=200||k>=50&&u.dragOffset.time<300)&&(l&&l.cancelable&&l.preventDefault(),this.close(l,"f-throwOut"+(u.current.f<0?"Up":"Down")))})),r.on("change",a=>{var u;let l=(u=this.getSlide())===null||u===void 0?void 0:u.triggerEl;if(l){const g=new CustomEvent("slideTo",{bubbles:!0,cancelable:!0,detail:a.page});l.dispatchEvent(g)}}),r.on(["refresh","change"],a=>{const u=this.container;if(!u)return;for(const _ of u.querySelectorAll("[data-fancybox-current-index]"))_.innerHTML=a.page+1;for(const _ of u.querySelectorAll("[data-fancybox-count]"))_.innerHTML=a.pages.length;if(!a.isInfinite){for(const _ of u.querySelectorAll("[data-fancybox-next]"))a.page<a.pages.length-1?(_.removeAttribute(Tc),_.removeAttribute(_l)):(_.setAttribute(Tc,""),_.setAttribute(_l,"-1"));for(const _ of u.querySelectorAll("[data-fancybox-prev]"))a.page>0?(_.removeAttribute(Tc),_.removeAttribute(_l)):(_.setAttribute(Tc,""),_.setAttribute(_l,"-1"))}const l=this.getSlide();if(!l)return;let g=l.downloadSrc||"";g||l.type!=="image"||l.error||!da(l[Mc])||(g=l[Mc]);for(const _ of u.querySelectorAll("[data-fancybox-download]")){const k=l.downloadFilename;g?(_.removeAttribute(Tc),_.removeAttribute(_l),_.setAttribute(ky,g),_.setAttribute(Ev,k||g),_.setAttribute("target","_blank")):(_.setAttribute(Tc,""),_.setAttribute(_l,"-1"),_.removeAttribute(ky),_.removeAttribute(Ev))}}),this.emit("initCarousel")}attachEvents(){const e=this,n=e.container;if(!n)return;n.addEventListener("click",e.onClick,{passive:!1,capture:!1}),n.addEventListener("wheel",e.onWheel,{passive:!1,capture:!1}),document.addEventListener("keydown",e.onKeydown,{passive:!1,capture:!0}),document.addEventListener("visibilitychange",e.onVisibilityChange,!1),document.addEventListener("mousemove",e.onMousemove),e.option("trapFocus")&&document.addEventListener("focus",e.onFocus,!0),window.addEventListener("resize",e.onResize);const i=window.visualViewport;i&&(i.addEventListener("scroll",e.onResize),i.addEventListener("resize",e.onResize))}detachEvents(){const e=this,n=e.container;if(!n)return;document.removeEventListener("keydown",e.onKeydown,{passive:!1,capture:!0}),n.removeEventListener("wheel",e.onWheel,{passive:!1,capture:!1}),n.removeEventListener("click",e.onClick,{passive:!1,capture:!1}),document.removeEventListener("mousemove",e.onMousemove),window.removeEventListener("resize",e.onResize);const i=window.visualViewport;i&&(i.removeEventListener("resize",e.onResize),i.removeEventListener("scroll",e.onResize)),document.removeEventListener("visibilitychange",e.onVisibilityChange,!1),document.removeEventListener("focus",e.onFocus,!0)}scale(){const e=this.container;if(!e)return;const n=window.visualViewport,i=Math.max(1,(n==null?void 0:n.scale)||1);let r="",a="",u="";if(n&&i>1){let l=`${n.offsetLeft}px`,g=`${n.offsetTop}px`;r=n.width*i+"px",a=n.height*i+"px",u=`translate3d(${l}, ${g}, 0) scale(${1/i})`}e.style.transform=u,e.style.width=r,e.style.height=a}onClick(e){var n;const{container:i,isCompact:r}=this;if(!i||this.isClosing())return;!r&&this.option("idle")&&this.resetIdle();const a=e.composedPath()[0];if(a.closest(".fancybox-spinner")||a.closest("[data-fancybox-close]"))return e.preventDefault(),void this.close(e);if(a.closest("[data-fancybox-prev]"))return e.preventDefault(),void this.prev();if(a.closest("[data-fancybox-next]"))return e.preventDefault(),void this.next();if(e.type==="click"&&e.detail===0||Math.abs(e.pageX-Tv)>30||Math.abs(e.pageY-Mv)>30)return;const u=document.activeElement;if(Cv()&&u&&i.contains(u))return;if(r&&((n=this.getSlide())===null||n===void 0?void 0:n.type)==="image")return void(this.clickTimer?(clearTimeout(this.clickTimer),this.clickTimer=null):this.clickTimer=setTimeout(()=>{this.toggleIdle(),this.clickTimer=null},350));if(this.emit("click",e),e.defaultPrevented)return;let l=!1;if(a.closest(".fancybox__content")){if(u){if(u.closest("[contenteditable]"))return;a.matches(dy)||u.blur()}if(Cv())return;l=this.option("contentClick")}else a.closest(".fancybox__carousel")&&!a.matches(dy)&&(l=this.option("backdropClick"));l==="close"?(e.preventDefault(),this.close(e)):l==="next"?(e.preventDefault(),this.next()):l==="prev"&&(e.preventDefault(),this.prev())}onWheel(e){const n=e.target;let i=this.option("wheel",e);n.closest(".fancybox__thumbs")&&(i="slide");const r=i==="slide",a=[-e.deltaX||0,-e.deltaY||0,-e.detail||0].reduce(function(g,_){return Math.abs(_)>Math.abs(g)?_:g}),u=Math.max(-1,Math.min(1,a)),l=Date.now();this.pwt&&l-this.pwt<300?r&&e.preventDefault():(this.pwt=l,this.emit("wheel",e,u),e.defaultPrevented||(i==="close"?(e.preventDefault(),this.close(e)):i==="slide"&&(Np(n)||(e.preventDefault(),this[u>0?"prev":"next"]()))))}onScroll(){window.scrollTo(Av,Pv)}onKeydown(e){if(!this.isTopmost())return;this.isCompact||!this.option("idle")||this.isClosing()||this.resetIdle();const n=e.key,i=this.option("keyboard");if(!i)return;const r=e.composedPath()[0],a=document.activeElement&&document.activeElement.classList,u=a&&a.contains("f-button")||r.dataset.carouselPage||r.dataset.carouselIndex;if(n!=="Escape"&&!u&&Tr(r)&&(r.isContentEditable||["TEXTAREA","OPTION","INPUT","SELECT","VIDEO"].indexOf(r.nodeName)!==-1)||(e.key==="Tab"?Ct(this.container,xy):kn(this.container,xy),e.ctrlKey||e.altKey||e.shiftKey))return;this.emit("keydown",n,e);const l=i[n];l&&typeof this[l]=="function"&&(e.preventDefault(),this[l]())}onResize(){const e=this.container;if(!e)return;const n=this.isCompact;e.classList.toggle(kv,n),this.manageCaption(this.getSlide()),this.isCompact?this.clearIdle():this.endIdle(),this.scale(),this.emit("resize")}onFocus(e){this.isTopmost()&&this.checkFocus(e)}onMousemove(e){this.prevMouseMoveEvent=e,!this.isCompact&&this.option("idle")&&this.resetIdle()}onVisibilityChange(){document.visibilityState==="visible"?this.checkFocus():this.endIdle()}manageCloseBtn(e){const n=this.optionFor(e,"closeButton")||!1;if(n==="auto"){const r=this.plugins.Toolbar;if(r&&r.state===yl.Ready)return}if(!n||!e.contentEl||e.closeBtnEl)return;const i=this.option("tpl.closeButton");if(i){const r=eo(this.localize(i));e.closeBtnEl=e.contentEl.appendChild(r),e.el&&Ct(e.el,"has-close-btn")}}manageCaption(e=void 0){var n,i;const r="fancybox__caption",a=this.container;if(!a)return;kn(a,Kp);const u=this.isCompact||this.option("commonCaption"),l=!u;if(this.caption&&this.stop(this.caption),l&&this.caption&&(this.caption.remove(),this.caption=null),u&&!this.caption)for(const E of((n=this.carousel)===null||n===void 0?void 0:n.slides)||[])E.captionEl&&(E.captionEl.remove(),E.captionEl=void 0,kn(E.el,Kp),(i=E.el)===null||i===void 0||i.removeAttribute("aria-labelledby"));if(e||(e=this.getSlide()),!e||u&&!this.isCurrentSlide(e))return;const g=e.el;let _=this.optionFor(e,"caption","");if(!_)return void(u&&this.caption&&this.animate(this.caption,"f-fadeOut",()=>{this.caption&&(this.caption.innerHTML="")}));let k=null;if(l){if(k=e.captionEl||null,g&&!k){const E=r+`_${this.id}_${e.index}`;k=document.createElement("div"),Ct(k,r),k.setAttribute("id",E),e.captionEl=g.appendChild(k),Ct(g,Kp),g.setAttribute("aria-labelledby",E)}}else k=this.caption,k||(k=a.querySelector("."+r)),!k&&(k=document.createElement("div"),k.dataset.fancyboxCaption="",Ct(k,r),(this.footer||a).prepend(k)),Ct(a,Kp),this.caption=k;k&&(k.innerHTML="",da(_)||typeof _=="number"?k.innerHTML=_+"":_ instanceof HTMLElement&&k.appendChild(_))}checkFocus(e){this.focus(e)}focus(e){var n;if(this.ignoreFocusChange)return;const i=document.activeElement||null,r=(e==null?void 0:e.target)||null,a=this.container,u=(n=this.carousel)===null||n===void 0?void 0:n.viewport;if(!a||!u||!e&&i&&a.contains(i))return;const l=this.getSlide(),g=l&&l.state===Xi.Ready?l.el:null;if(!g||g.contains(i)||a===i)return;e&&e.cancelable&&e.preventDefault(),this.ignoreFocusChange=!0;const _=Array.from(a.querySelectorAll(dy));let k=[],E=null;for(let I of _){const z=!I.offsetParent||!!I.closest('[aria-hidden="true"]'),V=g&&g.contains(I),H=!u.contains(I);if(I===a||(V||H)&&!z){k.push(I);const Z=I.dataset.origTabindex;Z!==void 0&&Z&&(I.tabIndex=parseFloat(Z)),I.removeAttribute("data-orig-tabindex"),!I.hasAttribute("autoFocus")&&E||(E=I)}else{const Z=I.dataset.origTabindex===void 0?I.getAttribute("tabindex")||"":I.dataset.origTabindex;Z&&(I.dataset.origTabindex=Z),I.tabIndex=-1}}let T=null;e?(!r||k.indexOf(r)<0)&&(T=E||a,k.length&&(i===bl?T=k[0]:this.lastFocus!==a&&i!==gs||(T=k[k.length-1]))):T=l&&l.type==="image"?a:E||a,T&&J1(T),this.lastFocus=document.activeElement,this.ignoreFocusChange=!1}next(){const e=this.carousel;e&&e.pages.length>1&&e.slideNext()}prev(){const e=this.carousel;e&&e.pages.length>1&&e.slidePrev()}jumpTo(...e){this.carousel&&this.carousel.slideTo(...e)}isTopmost(){var e;return((e=mn.getInstance())===null||e===void 0?void 0:e.id)==this.id}animate(e=null,n="",i){if(!e||!n)return void(i&&i());this.stop(e);const r=a=>{a.target===e&&e.dataset.animationName&&(e.removeEventListener("animationend",r),delete e.dataset.animationName,i&&i(),kn(e,n))};e.dataset.animationName=n,e.addEventListener("animationend",r),Ct(e,n)}stop(e){e&&e.dispatchEvent(new CustomEvent("animationend",{bubbles:!1,cancelable:!0,currentTarget:e}))}setContent(e,n="",i=!0){if(this.isClosing())return;const r=e.el;if(!r)return;let a=null;if(Tr(n)?a=n:(a=eo(n+""),Tr(a)||(a=document.createElement("div"),a.innerHTML=n+"")),["img","picture","iframe","video","audio"].includes(a.nodeName.toLowerCase())){const u=document.createElement("div");u.appendChild(a),a=u}Tr(a)&&e.filter&&!e.error&&(a=a.querySelector(e.filter)),a&&Tr(a)?(Ct(a,"fancybox__content"),e.id&&a.setAttribute("id",e.id),r.classList.add(`has-${e.error?"error":e.type||"unknown"}`),r.prepend(a),a.style.display==="none"&&(a.style.display=""),getComputedStyle(a).getPropertyValue("display")==="none"&&(a.style.display=e.display||this.option("defaultDisplay")||"flex"),e.contentEl=a,i&&this.revealContent(e),this.manageCloseBtn(e),this.manageCaption(e)):this.setError(e,"{{ELEMENT_NOT_FOUND}}")}revealContent(e,n){const i=e.el,r=e.contentEl;i&&r&&(this.emit("reveal",e),this.hideLoading(e),e.state=Xi.Opening,(n=this.isOpeningSlide(e)?n===void 0?this.optionFor(e,"showClass"):n:"f-fadeIn")?this.animate(r,n,()=>{this.done(e)}):this.done(e))}done(e){this.isClosing()||(e.state=Xi.Ready,this.emit("done",e),Ct(e.el,"is-done"),this.isCurrentSlide(e)&&this.option("autoFocus")&&queueMicrotask(()=>{var n;(n=e.panzoom)===null||n===void 0||n.updateControls(),this.option("autoFocus")&&this.focus()}),this.isOpeningSlide(e)&&(kn(this.container,wy),!this.isCompact&&this.option("idle")&&this.setIdle()))}isCurrentSlide(e){const n=this.getSlide();return!(!e||!n)&&n.index===e.index}isOpeningSlide(e){var n,i;return((n=this.carousel)===null||n===void 0?void 0:n.prevPage)===null&&e&&e.index===((i=this.getSlide())===null||i===void 0?void 0:i.index)}showLoading(e){e.state=Xi.Loading;const n=e.el;n&&(Ct(n,Sv),this.emit("loading",e),e.spinnerEl||setTimeout(()=>{if(!this.isClosing()&&!e.spinnerEl&&e.state===Xi.Loading){let i=eo(ay);Ct(i,"fancybox-spinner"),e.spinnerEl=i,n.prepend(i),this.animate(i,"f-fadeIn")}},250))}hideLoading(e){const n=e.el;if(!n)return;const i=e.spinnerEl;this.isClosing()?i==null||i.remove():(kn(n,Sv),i&&this.animate(i,"f-fadeOut",()=>{i.remove()}),e.state===Xi.Loading&&(this.emit("loaded",e),e.state=Xi.Ready))}setError(e,n){if(this.isClosing())return;const i=new Event("error",{bubbles:!0,cancelable:!0});if(this.emit("error",i,e),i.defaultPrevented)return;e.error=n,this.hideLoading(e),this.clearContent(e);const r=document.createElement("div");r.classList.add("fancybox-error"),r.innerHTML=this.localize(n||"<p>{{ERROR}}</p>"),this.setContent(e,r)}clearContent(e){if(e.state===void 0)return;this.emit("clearContent",e),e.contentEl&&(e.contentEl.remove(),e.contentEl=void 0);const n=e.el;n&&(kn(n,"has-error"),kn(n,"has-unknown"),kn(n,`has-${e.type||"unknown"}`)),e.closeBtnEl&&e.closeBtnEl.remove(),e.closeBtnEl=void 0,e.captionEl&&e.captionEl.remove(),e.captionEl=void 0,e.spinnerEl&&e.spinnerEl.remove(),e.spinnerEl=void 0}getSlide(){var e;const n=this.carousel;return((e=n==null?void 0:n.pages[n==null?void 0:n.page])===null||e===void 0?void 0:e.slides[0])||void 0}close(e,n){if(this.isClosing())return;const i=new Event("shouldClose",{bubbles:!0,cancelable:!0});if(this.emit("shouldClose",i,e),i.defaultPrevented)return;e&&e.cancelable&&(e.preventDefault(),e.stopPropagation());const r=()=>{this.proceedClose(e,n)};this.startedFs&&ms&&ms.isFullscreen()?Promise.resolve(ms.exit()).then(()=>r()):r()}clearIdle(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=null}setIdle(e=!1){const n=()=>{this.clearIdle(),this.idle=!0,Ct(this.container,"is-idle"),this.emit("setIdle")};if(this.clearIdle(),!this.isClosing())if(e)n();else{const i=this.option("idle");i&&(this.idleTimer=setTimeout(n,i))}}endIdle(){this.clearIdle(),this.idle&&!this.isClosing()&&(this.idle=!1,kn(this.container,"is-idle"),this.emit("endIdle"))}resetIdle(){this.endIdle(),this.setIdle()}toggleIdle(){this.idle?this.endIdle():this.setIdle(!0)}toggleFullscreen(){ms&&(ms.isFullscreen()?ms.exit():ms.request().then(()=>{this.startedFs=!0}))}isClosing(){return[Ei.Closing,Ei.CustomClosing,Ei.Destroy].includes(this.state)}proceedClose(e,n){var i,r;this.state=Ei.Closing,this.clearIdle(),this.detachEvents();const a=this.container,u=this.carousel,l=this.getSlide(),g=l&&this.option("placeFocusBack")?l.triggerEl||this.option("triggerEl"):null;if(g&&(K1(g)?J1(g):g.focus()),a&&(kn(a,wy),Ct(a,"is-closing"),a.setAttribute(by,"true"),this.option("animated")&&Ct(a,vy),a.style.pointerEvents="none"),u){u.clearTransitions(),(i=u.panzoom)===null||i===void 0||i.destroy(),(r=u.plugins.Navigation)===null||r===void 0||r.detach();for(const _ of u.slides){_.state=Xi.Closing,this.hideLoading(_);const k=_.contentEl;k&&this.stop(k);const E=_==null?void 0:_.panzoom;E&&(E.stop(),E.detachEvents(),E.detachObserver()),this.isCurrentSlide(_)||u.emit("removeSlide",_)}}Av=window.scrollX,Pv=window.scrollY,window.addEventListener("scroll",this.onScroll),this.emit("close",e),this.state!==Ei.CustomClosing?(n===void 0&&l&&(n=this.optionFor(l,"hideClass")),n&&l?(this.animate(l.contentEl,n,()=>{u&&u.emit("removeSlide",l)}),setTimeout(()=>{this.destroy()},500)):this.destroy()):setTimeout(()=>{this.destroy()},500)}destroy(){var e;if(this.state===Ei.Destroy)return;window.removeEventListener("scroll",this.onScroll),this.state=Ei.Destroy,(e=this.carousel)===null||e===void 0||e.destroy();const n=this.container;n&&n.remove(),Ac.delete(this.id);const i=mn.getInstance();i?i.focus():(gs&&(gs.remove(),gs=null),bl&&(bl.remove(),bl=null),kn(document.documentElement,xv),(()=>{if(!fh)return;const r=document,a=r.body;a.classList.remove(_y),a.style.setProperty(wv,""),r.documentElement.style.setProperty(vv,"")})(),this.emit("destroy"))}static bind(e,n,i){if(!fh)return;let r,a="",u={};if(e===void 0?r=document.body:da(e)?(r=document.body,a=e,typeof n=="object"&&(u=n||{})):(r=e,da(n)&&(a=n),typeof i=="object"&&(u=i||{})),!r||!Tr(r))return;a=a||"[data-fancybox]";const l=mn.openers.get(r)||new Map;l.set(a,u),mn.openers.set(r,l),l.size===1&&r.addEventListener("click",mn.fromEvent)}static unbind(e,n){let i,r="";if(da(e)?(i=document.body,r=e):(i=e,da(n)&&(r=n)),!i)return;const a=mn.openers.get(i);a&&r&&a.delete(r),r&&a||(mn.openers.delete(i),i.removeEventListener("click",mn.fromEvent))}static destroy(){let e;for(;e=mn.getInstance();)e.destroy();for(const n of mn.openers.keys())n.removeEventListener("click",mn.fromEvent);mn.openers=new Map}static fromEvent(e){if(e.defaultPrevented||e.button&&e.button!==0||e.ctrlKey||e.metaKey||e.shiftKey)return;let n=e.composedPath()[0];const i=n.closest("[data-fancybox-trigger]");if(i){const z=i.dataset.fancyboxTrigger||"",V=document.querySelectorAll(`[data-fancybox="${z}"]`),H=parseInt(i.dataset.fancyboxIndex||"",10)||0;n=V[H]||n}if(!(n&&n instanceof Element))return;let r,a,u,l;if([...mn.openers].reverse().find(([z,V])=>!(!z.contains(n)||![...V].reverse().find(([H,Z])=>{let ee=n.closest(H);return!!ee&&(r=z,a=H,u=ee,l=Z,!0)}))),!r||!a||!u)return;l=l||{},e.preventDefault(),n=u;let g=[],_=Cr({},py,l);_.event=e,_.triggerEl=n,_.delegate=i;const k=_.groupAll,E=_.groupAttr,T=E&&n?n.getAttribute(`${E}`):"";if((!n||T||k)&&(g=[].slice.call(r.querySelectorAll(a))),n&&!k&&(g=T?g.filter(z=>z.getAttribute(`${E}`)===T):[n]),!g.length)return;const I=mn.getInstance();return I&&I.options.triggerEl&&g.indexOf(I.options.triggerEl)>-1?void 0:(n&&(_.startIndex=g.indexOf(n)),mn.fromNodes(g,_))}static fromSelector(e,n,i){let r=null,a="",u={};if(da(e)?(r=document.body,a=e,typeof n=="object"&&(u=n||{})):e instanceof HTMLElement&&da(n)&&(r=e,a=n,typeof i=="object"&&(u=i||{})),!r||!a)return!1;const l=mn.openers.get(r);return!!l&&(u=Cr({},l.get(a)||{},u),!!u&&mn.fromNodes(Array.from(r.querySelectorAll(a)),u))}static fromNodes(e,n){n=Cr({},py,n||{});const i=[];for(const r of e){const a=r.dataset||{},u=a[Mc]||r.getAttribute(ky)||r.getAttribute("currentSrc")||r.getAttribute(Mc)||void 0;let l;const g=n.delegate;let _;g&&i.length===n.startIndex&&(l=g instanceof HTMLImageElement?g:g.querySelector("img:not([aria-hidden])")),l||(l=r instanceof HTMLImageElement?r:r.querySelector("img:not([aria-hidden])")),l&&(_=l.currentSrc||l[Mc]||void 0,!_&&l.dataset&&(_=l.dataset.lazySrc||l.dataset[Mc]||void 0));const k={src:u,triggerEl:r,thumbEl:l,thumbElSrc:_,thumbSrc:_};for(const E in a){let T=a[E]+"";T=T!=="false"&&(T==="true"||T),k[E]=T}i.push(k)}return new mn(i,n)}static getInstance(e){return e?Ac.get(e):Array.from(Ac.values()).reverse().find(n=>!n.isClosing()&&n)||null}static getSlide(){var e;return((e=mn.getInstance())===null||e===void 0?void 0:e.getSlide())||null}static show(e=[],n={}){return new mn(e,n)}static next(){const e=mn.getInstance();e&&e.next()}static prev(){const e=mn.getInstance();e&&e.prev()}static close(e=!0,...n){if(e)for(const i of Ac.values())i.close(...n);else{const i=mn.getInstance();i&&i.close(...n)}}}Object.defineProperty(mn,"version",{enumerable:!0,configurable:!0,writable:!0,value:"5.0.36"}),Object.defineProperty(mn,"defaults",{enumerable:!0,configurable:!0,writable:!0,value:py}),Object.defineProperty(mn,"Plugins",{enumerable:!0,configurable:!0,writable:!0,value:Nz}),Object.defineProperty(mn,"openers",{enumerable:!0,configurable:!0,writable:!0,value:new Map});const Fz=Object.freeze(Object.defineProperty({__proto__:null,Carousel:ha,Fancybox:mn,Panzoom:ua},Symbol.toStringTag,{value:"Module"})),{Fancybox:Jp}=Fz,Vz={props:{options:Object},mounted(){Jp.defaults={...this.options||{}}},updated(){Jp.close(),Jp.defaults={...this.options||{}}},unmounted(){Jp.close()}},$z={ref:"container"};function jz(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",$z,[S.renderSlot(t.$slots,"default")],512)}const Iv=_t(Vz,[["render",jz]]),Uz={},Hz={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-file"};function qz(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",Hz,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M14 3v4a1 1 0 0 0 1 1h4"},null,-1),S.createElementVNode("path",{d:"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"},null,-1)]))}const Wz={componens:{IconFile:_t(Uz,[["render",qz]])},props:{item:null},computed:{createDate(){try{const t=at(this.item.cdate,"YYYY-MM-DD");return new Date(t).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}}},Gz={style:{"max-width":"calc(50vw - 300px)"}},Zz={class:"truncate text-sm font-semibold text-gray-800 dark:text-neutral-200"},Yz={class:"block truncate text-xs text-gray-500 dark:text-neutral-500"};function Xz(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock(S.Fragment,null,[e[0]||(e[0]=S.createStaticVNode('<div class="flex items-center justify-center h-[30px] w-[30px]"><svg xmlns="http://www.w3.org/2000/svg" height="24" width="24" 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-file"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M14 3v4a1 1 0 0 0 1 1h4"></path><path d="M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z"></path></svg></div>',1)),S.createElementVNode("div",Gz,[S.createElementVNode("p",Zz,S.toDisplayString(n.item.uploaded_name),1),S.createElementVNode("p",Yz,[S.createElementVNode("span",null,S.toDisplayString(n.item.username),1),S.createTextVNode(" "+S.toDisplayString(a.createDate),1)])])],64)}const Kz={components:{Fancybox:Iv,VsWidgetFileInfo:_t(Wz,[["render",Xz]])},props:{item:null},data(){return{optionsFile:{defaultType:"iframe"}}},computed:{createDate(){try{const t=at(this.item.cdate,"YYYY-MM-DD");return new Date(t).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}},methods:{isSupportedFile(t){return["pdf","txt","json"].includes(t.ext)&&parseInt(t.size,10)<=10485760},async downloadFile(t){const e=document.createElement("a");e.setAttribute("download",t.uploaded_name),e.href=t.file_path,e.click()},confirnDeleteFile(){this.$emit("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей файл?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:this.deleteFile,updateListOnConfirm:!0})},async deleteFile(){try{await wt.delete(`/api/widget/file/${this.item.entity_id}/${this.item.file_id}`),this.$emit("update")}catch(t){console.error(t)}}}},Jz={class:"p-3 relative group flex items-center gap-x-3 border border-gray-200 bg-white rounded-xl w-full"},Qz={key:0,class:"flex"},eR=["href"],tR={key:1,class:"flex"},nR=["href"],iR={key:2,class:"flex gap-x-3 w-full"},rR={class:"lg:absolute lg:top-3 lg:end-3 group-hover:opacity-100 lg:opacity-0"},sR={class:"p-0.5 sm:p-1 inline-flex items-center gap-0.5 bg-white border border-gray-200 lg:shadow rounded-lg dark:bg-neutral-800 dark:border-neutral-700"},oR={class:"hs-tooltip inline-block"},aR={class:"hs-tooltip inline-block"};function lR(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetFileInfo"),l=S.resolveComponent("Fancybox");return S.openBlock(),S.createElementBlock("div",Jz,[n.item.ext==="jpg"||n.item.ext==="png"?(S.openBlock(),S.createElementBlock("div",Qz,[S.createVNode(l,null,{default:S.withCtx(()=>[S.createElementVNode("a",{"data-fancybox":"gallery",href:n.item.file_path,class:"flex gap-x-3 w-full"},[S.createVNode(u,{item:n.item},null,8,["item"])],8,eR)]),_:1})])):a.isSupportedFile(n.item)?(S.openBlock(),S.createElementBlock("div",tR,[S.createVNode(l,{options:r.optionsFile},{default:S.withCtx(()=>[S.createElementVNode("a",{"data-fancybox":"gallery",href:n.item.file_path,class:"flex gap-x-3 w-full"},[S.createVNode(u,{item:n.item},null,8,["item"])],8,nR)]),_:1},8,["options"])])):(S.openBlock(),S.createElementBlock("div",iR,[S.createVNode(u,{item:n.item},null,8,["item"])])),S.createElementVNode("div",rR,[S.createElementVNode("div",sR,[S.createElementVNode("div",oR,[S.createElementVNode("button",{class:"hs-tooltip-toggle size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none dark:text-neutral-400 focus:outline-none focus:bg-gray-100 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[0]||(e[0]=g=>a.downloadFile(n.item))},e[2]||(e[2]=[S.createElementVNode("i",{class:"ti ti-download"},null,-1)]))]),e[4]||(e[4]=S.createElementVNode("div",{class:"w-px h-5 mx-1 bg-gray-200 dark:bg-neutral-700"},null,-1)),S.createElementVNode("div",aR,[S.createElementVNode("button",{type:"button",class:"hs-tooltip-toggle size-[30px] inline-flex justify-center items-center gap-x-2 rounded-lg border border-transparent text-red-600 hover:bg-red-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-red-100 dark:text-red-500 dark:hover:bg-red-500/20 dark:focus:bg-red-500/20","data-hs-overlay":"#hs-pro-dupfmdl",onClick:e[1]||(e[1]=g=>a.confirnDeleteFile())},e[3]||(e[3]=[S.createElementVNode("i",{class:"ti ti-trash"},null,-1)]))])])])])}const cR=_t(Kz,[["render",lR]]),uR={props:["text"]},hR={class:"pl-3 text-sm font-medium text-gray-600"};function dR(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",null,[S.createElementVNode("p",hR,S.toDisplayString(n.text),1)])}const Sy=_t(uR,[["render",dR]]),pR={components:{VsWidgetFileItem:cR,VsEmptyWidget:Sy},props:{id:{type:String,default(){return""}},prefilledData:{}},data(){return{isModalVisible:!1,modal:{},files:"",searchValue:""}},mounted(){this.getFileList()},computed:{filteredFiles(){return this.searchValue===""?this.files:this.files.filter(e=>e.uploaded_name.includes(this.searchValue))}},methods:{async getFileList(){if(this.prefilledData){this.files=this.prefilledData.rows;return}try{const{data:t}=await wt.get(`/api/widget/file/${this.id}`);this.files=t==null?void 0:t.rows}catch(t){console.error(t)}},async addFile(t){console.log(t),await Promise.all(Array.from(t.target.files).map(async e=>{const n=new FormData;n.append("file",e);try{const i=`/api/widget/file/${this.id}`;return await wt.post(i,n),this.$emit("update","file-list"),e}catch(i){return console.error(i),null}})),await this.getFileList()},prepareModal(t){const e={...t};return t.cancel||(e.cancel=()=>{this.isModalVisible=!1}),t.updateListOnConfirm&&(e.confirm=async()=>{await t.confirm(),this.isModalVisible=!1,this.getFileList()}),e},handleOpenModal(t){this.modal=this.prepareModal(t),this.isModalVisible=!0}}},fR={class:"widget-file flex flex-col xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700"},mR={class:"flex justify-between items-center gap-x-2 mb-4"},gR={class:"flex justify-end items-center gap-x-2"},yR={key:0,class:"font-semibold text-gray-800 dark:text-neutral-200"},_R={key:1,class:"py-4 space-y-4 mb-4 border-y border-gray-200 dark:border-neutral-700"},bR={class:"relative"},xR={key:2,class:"space-y-3 max-h-[300px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},vR={key:0},wR={class:"p-4"},kR={class:"mt-1 text-gray-500 dark:text-neutral-500"},SR={class:"mt-4 flex justify-end gap-x-3"};function ER(t,e,n,i,r,a){var _,k,E;const u=S.resolveComponent("VsWidgetFileItem"),l=S.resolveComponent("VsEmptyWidget"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock("div",fR,[S.createElementVNode("div",mR,[e[8]||(e[8]=S.createElementVNode("h2",{class:"inline-block font-semibold text-gray-800 dark:text-neutral-200"},null,-1)),S.createElementVNode("div",gR,[S.createElementVNode("div",null,[S.createElementVNode("label",null,[S.createElementVNode("input",{type:"file",class:"hidden",onChange:e[0]||(e[0]=T=>a.addFile(T))},null,32),e[7]||(e[7]=S.createElementVNode("div",{class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},[S.createElementVNode("i",{class:"ti ti-upload"}),S.createTextVNode(" Завантажити файл ")],-1))])])])]),(_=r.files)!=null&&_.length?(S.openBlock(),S.createElementBlock("h2",yR," Кількість: "+S.toDisplayString(r.files.length),1)):S.createCommentVNode("",!0),(k=r.files)!=null&&k.length?(S.openBlock(),S.createElementBlock("div",_R,[S.createElementVNode("div",null,[S.createElementVNode("div",bR,[e[9]||(e[9]=S.createElementVNode("div",{class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-20 ps-3.5"},[S.createElementVNode("svg",{class:"flex-shrink-0 size-4 text-gray-500 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("circle",{cx:"11",cy:"11",r:"8"}),S.createElementVNode("path",{d:"m21 21-4.3-4.3"})])],-1)),S.withDirectives(S.createElementVNode("input",{type:"text","onUpdate:modelValue":e[1]||(e[1]=T=>r.searchValue=T),class:"py-2 px-3 ps-10 pe-16 block w-full bg-gray-200 xl:bg-gray-100 rounded-lg text-sm focus:border-blue-500 h-[40px] focus:border-2 focus:outline-none disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Введіть назву файлу"},null,512),[[S.vModelText,r.searchValue,void 0,{trim:!0}]])])])])):S.createCommentVNode("",!0),(E=r.files)!=null&&E.length?(S.openBlock(),S.createElementBlock("div",xR,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.filteredFiles,(T,I)=>(S.openBlock(),S.createBlock(u,{key:I,id:n.id,item:T,onUpdate:e[2]||(e[2]=z=>t.$emit("update","file-list")),onOpenModal:e[3]||(e[3]=z=>a.handleOpenModal(z))},null,8,["id","item"]))),128)),a.filteredFiles.length?S.createCommentVNode("",!0):(S.openBlock(),S.createElementBlock("div",vR,e[10]||(e[10]=[S.createElementVNode("p",{class:"text-sm font-sm text-gray-600"}," Файлів з такою назвою не існує, введіть інше пошукове слово ",-1)])))])):(S.openBlock(),S.createBlock(l,{key:3,text:"Файли відсутні"})),S.createVNode(g,{title:r.modal.title,size:"small",visible:r.isModalVisible,"onUpdate:visible":e[6]||(e[6]=T=>r.isModalVisible=T)},{default:S.withCtx(()=>[S.createElementVNode("div",wR,[S.createElementVNode("p",kR,S.toDisplayString(r.modal.message),1),S.createElementVNode("div",SR,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[4]||(e[4]=(...T)=>r.modal.cancel&&r.modal.cancel(...T))},S.toDisplayString(r.modal.cancelButtonText),1),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[5]||(e[5]=(...T)=>r.modal.confirm&&r.modal.confirm(...T))},S.toDisplayString(r.modal.confirmButtonText),1)])])]),_:1},8,["title","visible"])])}const CR=_t(pR,[["render",ER]]),TR={components:{Fancybox:Iv,VsEmptyWidget:Sy},props:{id:{type:String,default:""},readonly:{type:Boolean,default:!1},prefilledData:{type:Array,default:()=>null}},data(){return{carouselOptions:{Carousel:{infinite:!1}},isModalVisible:!1,modal:{},images:[],editAction:!1,selectedFile:null,imageExtensions:["png","jpg","jpeg","gif"]}},watch:{id(){this.getFiles()}},mounted(){this.getFiles()},methods:{async downloadFile(t){const e=document.createElement("a");e.setAttribute("download",t.uploaded_name),e.href=t.file_path,e.click()},handleOpenModal(t){this.selectedFile=t,this.modal=this.prepareModal({title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити це зображення?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:this.deleteFile,updateListOnConfirm:!0}),this.isModalVisible=!0},prepareModal(t){const e={...t};return t.cancel||(e.cancel=()=>{this.isModalVisible=!1}),t.updateListOnConfirm&&(e.confirm=async()=>{await t.confirm(),this.isModalVisible=!1,this.getFiles()}),e},async deleteFile(){try{await wt.delete(`/api/widget/gallery/${this.selectedFile.entity_id}/${this.selectedFile.file_id}`),this.isModalVisible=!1,this.selectedFile="",this.$emit("update","images"),this.getFiles()}catch(t){console.log(t)}},async addFile(t){console.log(t),await Promise.all(Array.from(t.target.files).map(async e=>{const n=new FormData;n.append("file",e);try{const i=`/api/widget/file/${this.id}`;return await wt.post(i,n),this.$emit("update","file-list"),e}catch(i){return console.error(i),null}})),await this.getFiles()},async getFiles(){if(this.prefilledData){this.images=this.prefilledData;return}try{const{data:t}=await wt.get(`/api/widget/gallery/${this.id}`);this.images=t.rows}catch(t){console.error(t)}},size(t,e=2){if(t===0)return"0 Bytes";const n=1024,i=e<0?0:e,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],a=Math.floor(Math.log(t)/Math.log(n));return`${parseFloat((t/n**a).toFixed(i))} ${r[a]}`},dateFormat(t){const e={day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric"};return new Date(t).toLocaleDateString("uk-UK",e)}}},MR={class:"vs-widget-images flex flex-col xl:bg-white xl:rounded-xl dark:xl:bg-neutral-800 dark:xl:border-neutral-700"},AR={class:"flex justify-between items-center gap-x-2 mb-4"},PR={class:"flex justify-end items-center gap-x-2"},IR=["href"],DR=["src","alt"],OR={class:"item__text-content bg-white opacity-0 rounded-b-lg absolute w-full bottom-0 p-3 flex gap-2.5 items-center justify-between"},zR={class:"text-xs w-[180px] block overflow-hidden overflow-ellipsis"},RR={class:"widget-images__item-desc flex items-center text-xs text-gray-600 flex-wrap"},LR={class:"flex items-center"},NR={class:"text-xs"},BR=["onClick"],FR=["onClick"],VR={class:"p-4"},$R={class:"mt-1 text-gray-500 dark:text-neutral-500"},jR={class:"mt-4 flex justify-end gap-x-3"};function UR(t,e,n,i,r,a){var _;const u=S.resolveComponent("Fancybox"),l=S.resolveComponent("VsEmptyWidget"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock("div",MR,[S.createElementVNode("div",AR,[e[5]||(e[5]=S.createElementVNode("h2",{class:"inline-block font-semibold text-gray-800 dark:text-neutral-200"}," Зображення ",-1)),S.createElementVNode("div",PR,[S.createElementVNode("div",null,[S.createElementVNode("label",null,[S.createElementVNode("input",{type:"file",class:"hidden",onChange:e[0]||(e[0]=k=>a.addFile(k))},null,32),e[4]||(e[4]=S.createElementVNode("div",{class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},[S.createElementVNode("i",{class:"ti ti-upload"}),S.createTextVNode(" Завантажити файл ")],-1))])])])]),(_=r.images)!=null&&_.length?(S.openBlock(),S.createBlock(u,{key:0,options:r.carouselOptions,class:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-4 overflow-auto max-h-[400px] [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},{default:S.withCtx(()=>[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(r.images,k=>(S.openBlock(),S.createElementBlock("div",{key:k.file_path,class:"relative cursor-pointer rounded-b-lg item hover:shadow-lg h-[200px]"},[S.createElementVNode("a",{"data-fancybox":"gallery",href:k.file_path},[S.createElementVNode("img",{class:"h-full w-full rounded-lg",src:k.file_path||"/icons/no-image.jpg",alt:k.uploaded_name,width:"100%",height:"100%"},null,8,DR),S.createElementVNode("div",OR,[S.createElementVNode("div",null,[S.createElementVNode("span",zR,S.toDisplayString(k.uploaded_name),1),S.createElementVNode("div",RR,[S.createElementVNode("span",LR,S.toDisplayString(a.size(k.size)),1),S.createElementVNode("span",null,S.toDisplayString(a.dateFormat(k.cdate)),1)]),S.createElementVNode("span",NR,S.toDisplayString(k.username),1)]),S.createElementVNode("div",null,[S.createElementVNode("div",{class:S.normalizeClass(["flex items-center justify-center gap-2 hover:bg-gray-200 p-1 rounded",{disabled:n.readonly,"hover:cursor-pointer":!n.readonly}]),onClick:S.withModifiers(E=>a.downloadFile(k),["prevent"])},e[6]||(e[6]=[S.createElementVNode("i",{class:"ti ti-download"},null,-1)]),10,BR),S.createElementVNode("div",{class:"flex items-center gap-2 hover:bg-gray-200 p-1 rounded hover:cursor-pointer",onClick:S.withModifiers(E=>a.handleOpenModal(k),["prevent"])},e[7]||(e[7]=[S.createElementVNode("i",{class:"ti ti-trash"},null,-1)]),8,FR)])])],8,IR)]))),128))]),_:1},8,["options"])):(S.openBlock(),S.createBlock(l,{key:1,text:"Зображення відсутні"})),S.createVNode(g,{title:r.modal.title,size:"small",visible:r.isModalVisible,"onUpdate:visible":e[3]||(e[3]=k=>r.isModalVisible=k)},{default:S.withCtx(()=>[S.createElementVNode("div",VR,[S.createElementVNode("p",$R,S.toDisplayString(r.modal.message),1),S.createElementVNode("div",jR,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[1]||(e[1]=(...k)=>r.modal.cancel&&r.modal.cancel(...k))},S.toDisplayString(r.modal.cancelButtonText),1),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[2]||(e[2]=(...k)=>r.modal.confirm&&r.modal.confirm(...k))},S.toDisplayString(r.modal.confirmButtonText),1)])])]),_:1},8,["title","visible"])])}const HR=_t(TR,[["render",UR]]);function Bi(t){this.content=t}Bi.prototype={constructor:Bi,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var i=n&&n!=t?this.remove(n):this,r=i.find(t),a=i.content.slice();return r==-1?a.push(n||t,e):(a[r+1]=e,n&&(a[r]=n)),new Bi(a)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Bi(n)},addToStart:function(t,e){return new Bi([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Bi(n)},addBefore:function(t,e,n){var i=this.remove(e),r=i.content.slice(),a=i.find(t);return r.splice(a==-1?r.length:a,0,e,n),new Bi(r)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Bi.from(t),t.size?new Bi(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Bi.from(t),t.size?new Bi(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Bi.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}},Bi.from=function(t){if(t instanceof Bi)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Bi(e)};function Dv(t,e,n){for(let i=0;;i++){if(i==t.childCount||i==e.childCount)return t.childCount==e.childCount?null:n;let r=t.child(i),a=e.child(i);if(r==a){n+=r.nodeSize;continue}if(!r.sameMarkup(a))return n;if(r.isText&&r.text!=a.text){for(let u=0;r.text[u]==a.text[u];u++)n++;return n}if(r.content.size||a.content.size){let u=Dv(r.content,a.content,n+1);if(u!=null)return u}n+=r.nodeSize}}function Ov(t,e,n,i){for(let r=t.childCount,a=e.childCount;;){if(r==0||a==0)return r==a?null:{a:n,b:i};let u=t.child(--r),l=e.child(--a),g=u.nodeSize;if(u==l){n-=g,i-=g;continue}if(!u.sameMarkup(l))return{a:n,b:i};if(u.isText&&u.text!=l.text){let _=0,k=Math.min(u.text.length,l.text.length);for(;_<k&&u.text[u.text.length-_-1]==l.text[l.text.length-_-1];)_++,n--,i--;return{a:n,b:i}}if(u.content.size||l.content.size){let _=Ov(u.content,l.content,n-1,i-1);if(_)return _}n-=g,i-=g}}class Ve{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let i=0;i<e.length;i++)this.size+=e[i].nodeSize}nodesBetween(e,n,i,r=0,a){for(let u=0,l=0;l<n;u++){let g=this.content[u],_=l+g.nodeSize;if(_>e&&i(g,r+l,a||null,u)!==!1&&g.content.size){let k=l+1;g.nodesBetween(Math.max(0,e-k),Math.min(g.content.size,n-k),i,r+k)}l=_}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,i,r){let a="",u=!0;return this.nodesBetween(e,n,(l,g)=>{let _=l.isText?l.text.slice(Math.max(e,g)-g,n-g):l.isLeaf?r?typeof r=="function"?r(l):r:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&_||l.isTextblock)&&i&&(u?u=!1:a+=i),a+=_},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,i=e.firstChild,r=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(i)&&(r[r.length-1]=n.withText(n.text+i.text),a=1);a<e.content.length;a++)r.push(e.content[a]);return new Ve(r,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let i=[],r=0;if(n>e)for(let a=0,u=0;u<n;a++){let l=this.content[a],g=u+l.nodeSize;g>e&&((u<e||g>n)&&(l.isText?l=l.cut(Math.max(0,e-u),Math.min(l.text.length,n-u)):l=l.cut(Math.max(0,e-u-1),Math.min(l.content.size,n-u-1))),i.push(l),r+=l.nodeSize),u=g}return new Ve(i,r)}cutByIndex(e,n){return e==n?Ve.empty:e==0&&n==this.content.length?this:new Ve(this.content.slice(e,n))}replaceChild(e,n){let i=this.content[e];if(i==n)return this;let r=this.content.slice(),a=this.size+n.nodeSize-i.nodeSize;return r[e]=n,new Ve(r,a)}addToStart(e){return new Ve([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Ve(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,i=0;n<this.content.length;n++){let r=this.content[n];e(r,i,n),i+=r.nodeSize}}findDiffStart(e,n=0){return Dv(this,e,n)}findDiffEnd(e,n=this.size,i=e.size){return Ov(this,e,n,i)}findIndex(e,n=-1){if(e==0)return Qp(0,e);if(e==this.size)return Qp(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let i=0,r=0;;i++){let a=this.child(i),u=r+a.nodeSize;if(u>=e)return u==e||n>0?Qp(i+1,u):Qp(i,r);r=u}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Ve.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Ve(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Ve.empty;let n,i=0;for(let r=0;r<e.length;r++){let a=e[r];i+=a.nodeSize,r&&a.isText&&e[r-1].sameMarkup(a)?(n||(n=e.slice(0,r)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new Ve(n||e,i)}static from(e){if(!e)return Ve.empty;if(e instanceof Ve)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new Ve([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}Ve.empty=new Ve([],0);const Ey={index:0,offset:0};function Qp(t,e){return Ey.index=t,Ey.offset=e,Ey}function ef(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let i=0;i<t.length;i++)if(!ef(t[i],e[i]))return!1}else{for(let i in t)if(!(i in e)||!ef(t[i],e[i]))return!1;for(let i in e)if(!(i in t))return!1}return!0}let $n=class cb{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,i=!1;for(let r=0;r<e.length;r++){let a=e[r];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,r));else{if(a.type.excludes(this.type))return e;!i&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,r)),n.push(this),i=!0),n&&n.push(a)}}return n||(n=e.slice()),i||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ef(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let i=e.marks[n.type];if(!i)throw new RangeError(`There is no mark type ${n.type} in this schema`);let r=i.create(n.attrs);return i.checkAttrs(r.attrs),r}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let i=0;i<e.length;i++)if(!e[i].eq(n[i]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return cb.none;if(e instanceof cb)return[e];let n=e.slice();return n.sort((i,r)=>i.type.rank-r.type.rank),n}};$n.none=[];class tf extends Error{}class ut{constructor(e,n,i){this.content=e,this.openStart=n,this.openEnd=i}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let i=Rv(this.content,e+this.openStart,n);return i&&new ut(i,this.openStart,this.openEnd)}removeBetween(e,n){return new ut(zv(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ut.empty;let i=n.openStart||0,r=n.openEnd||0;if(typeof i!="number"||typeof r!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ut(Ve.fromJSON(e,n.content),i,r)}static maxOpen(e,n=!0){let i=0,r=0;for(let a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)i++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)r++;return new ut(e,i,r)}}ut.empty=new ut(Ve.empty,0,0);function zv(t,e,n){let{index:i,offset:r}=t.findIndex(e),a=t.maybeChild(i),{index:u,offset:l}=t.findIndex(n);if(r==e||a.isText){if(l!=n&&!t.child(u).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(i!=u)throw new RangeError("Removing non-flat range");return t.replaceChild(i,a.copy(zv(a.content,e-r-1,n-r-1)))}function Rv(t,e,n,i){let{index:r,offset:a}=t.findIndex(e),u=t.maybeChild(r);if(a==e||u.isText)return t.cut(0,e).append(n).append(t.cut(e));let l=Rv(u.content,e-a-1,n);return l&&t.replaceChild(r,u.copy(l))}function qR(t,e,n){if(n.openStart>t.depth)throw new tf("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new tf("Inconsistent open depths");return Lv(t,e,n,0)}function Lv(t,e,n,i){let r=t.index(i),a=t.node(i);if(r==e.index(i)&&i<t.depth-n.openStart){let u=Lv(t,e,n,i+1);return a.copy(a.content.replaceChild(r,u))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==i&&e.depth==i){let u=t.parent,l=u.content;return vl(u,l.cut(0,t.parentOffset).append(n.content).append(l.cut(e.parentOffset)))}else{let{start:u,end:l}=WR(n,t);return vl(a,Bv(t,u,l,e,i))}else return vl(a,nf(t,e,i))}function Nv(t,e){if(!e.type.compatibleContent(t.type))throw new tf("Cannot join "+e.type.name+" onto "+t.type.name)}function Cy(t,e,n){let i=t.node(n);return Nv(i,e.node(n)),i}function xl(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function _h(t,e,n,i){let r=(e||t).node(n),a=0,u=e?e.index(n):r.childCount;t&&(a=t.index(n),t.depth>n?a++:t.textOffset&&(xl(t.nodeAfter,i),a++));for(let l=a;l<u;l++)xl(r.child(l),i);e&&e.depth==n&&e.textOffset&&xl(e.nodeBefore,i)}function vl(t,e){return t.type.checkContent(e),t.copy(e)}function Bv(t,e,n,i,r){let a=t.depth>r&&Cy(t,e,r+1),u=i.depth>r&&Cy(n,i,r+1),l=[];return _h(null,t,r,l),a&&u&&e.index(r)==n.index(r)?(Nv(a,u),xl(vl(a,Bv(t,e,n,i,r+1)),l)):(a&&xl(vl(a,nf(t,e,r+1)),l),_h(e,n,r,l),u&&xl(vl(u,nf(n,i,r+1)),l)),_h(i,null,r,l),new Ve(l)}function nf(t,e,n){let i=[];if(_h(null,t,n,i),t.depth>n){let r=Cy(t,e,n+1);xl(vl(r,nf(t,e,n+1)),i)}return _h(e,null,n,i),new Ve(i)}function WR(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let a=n-1;a>=0;a--)r=e.node(a).copy(Ve.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}class bh{constructor(e,n,i){this.pos=e,this.path=n,this.parentOffset=i,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let i=this.pos-this.path[this.path.length-1],r=e.child(n);return i?e.child(n).cut(i):r}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let i=this.path[n*3],r=n==0?0:this.path[n*3-1]+1;for(let a=0;a<e;a++)r+=i.child(a).nodeSize;return r}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return $n.none;if(this.textOffset)return e.child(n).marks;let i=e.maybeChild(n-1),r=e.maybeChild(n);if(!i){let l=i;i=r,r=l}let a=i.marks;for(var u=0;u<a.length;u++)a[u].type.spec.inclusive===!1&&(!r||!a[u].isInSet(r.marks))&&(a=a[u--].removeFromSet(a));return a}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let i=n.marks,r=e.parent.maybeChild(e.index());for(var a=0;a<i.length;a++)i[a].type.spec.inclusive===!1&&(!r||!i[a].isInSet(r.marks))&&(i=i[a--].removeFromSet(i));return i}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let i=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);i>=0;i--)if(e.pos<=this.end(i)&&(!n||n(this.node(i))))return new rf(this,e,i);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let i=[],r=0,a=n;for(let u=e;;){let{index:l,offset:g}=u.content.findIndex(a),_=a-g;if(i.push(u,l,r+g),!_||(u=u.child(l),u.isText))break;a=_-1,r+=g+1}return new bh(n,i,a)}static resolveCached(e,n){let i=Fv.get(e);if(i)for(let a=0;a<i.elts.length;a++){let u=i.elts[a];if(u.pos==n)return u}else Fv.set(e,i=new GR);let r=i.elts[i.i]=bh.resolve(e,n);return i.i=(i.i+1)%ZR,r}}class GR{constructor(){this.elts=[],this.i=0}}const ZR=12,Fv=new WeakMap;class rf{constructor(e,n,i){this.$from=e,this.$to=n,this.depth=i}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const YR=Object.create(null);let wl=class ub{constructor(e,n,i,r=$n.none){this.type=e,this.attrs=n,this.marks=r,this.content=i||Ve.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,i,r=0){this.content.nodesBetween(e,n,i,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,i,r){return this.content.textBetween(e,n,i,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,i){return this.type==e&&ef(this.attrs,n||e.defaultAttrs||YR)&&$n.sameSet(this.marks,i||$n.none)}copy(e=null){return e==this.content?this:new ub(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new ub(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,i=!1){if(e==n)return ut.empty;let r=this.resolve(e),a=this.resolve(n),u=i?0:r.sharedDepth(n),l=r.start(u),_=r.node(u).content.cut(r.pos-l,a.pos-l);return new ut(_,r.depth-u,a.depth-u)}replace(e,n,i){return qR(this.resolve(e),this.resolve(n),i)}nodeAt(e){for(let n=this;;){let{index:i,offset:r}=n.content.findIndex(e);if(n=n.maybeChild(i),!n)return null;if(r==e||n.isText)return n;e-=r+1}}childAfter(e){let{index:n,offset:i}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:i}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:i}=this.content.findIndex(e);if(i<e)return{node:this.content.child(n),index:n,offset:i};let r=this.content.child(n-1);return{node:r,index:n-1,offset:i-r.nodeSize}}resolve(e){return bh.resolveCached(this,e)}resolveNoCache(e){return bh.resolve(this,e)}rangeHasMark(e,n,i){let r=!1;return n>e&&this.nodesBetween(e,n,a=>(i.isInSet(a.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Vv(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,i=Ve.empty,r=0,a=i.childCount){let u=this.contentMatchAt(e).matchFragment(i,r,a),l=u&&u.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let g=r;g<a;g++)if(!this.type.allowsMarks(i.child(g).marks))return!1;return!0}canReplaceWith(e,n,i,r){if(r&&!this.type.allowsMarks(r))return!1;let a=this.contentMatchAt(e).matchType(i),u=a&&a.matchFragment(this.content,n);return u?u.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=$n.none;for(let n=0;n<this.marks.length;n++){let i=this.marks[n];i.type.checkAttrs(i.attrs),e=i.addToSet(e)}if(!$n.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let i;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");i=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,i)}let r=Ve.fromJSON(e,n.content),a=e.nodeType(n.type).create(n.attrs,r,i);return a.type.checkAttrs(a.attrs),a}};wl.prototype.text=void 0;class sf extends wl{constructor(e,n,i,r){if(super(e,n,null,r),!i)throw new RangeError("Empty text nodes are not allowed");this.text=i}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Vv(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new sf(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new sf(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Vv(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class kl{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let i=new XR(e,n);if(i.next==null)return kl.empty;let r=$v(i);i.next&&i.err("Unexpected trailing text");let a=iL(nL(r));return rL(a,i),a}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,i=e.childCount){let r=this;for(let a=n;r&&a<i;a++)r=r.matchType(e.child(a).type);return r}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let i=0;i<e.next.length;i++)if(this.next[n].type==e.next[i].type)return!0;return!1}fillBefore(e,n=!1,i=0){let r=[this];function a(u,l){let g=u.matchFragment(e,i);if(g&&(!n||g.validEnd))return Ve.from(l.map(_=>_.createAndFill()));for(let _=0;_<u.next.length;_++){let{type:k,next:E}=u.next[_];if(!(k.isText||k.hasRequiredAttrs())&&r.indexOf(E)==-1){r.push(E);let T=a(E,l.concat(k));if(T)return T}}return null}return a(this,[])}findWrapping(e){for(let i=0;i<this.wrapCache.length;i+=2)if(this.wrapCache[i]==e)return this.wrapCache[i+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),i=[{match:this,type:null,via:null}];for(;i.length;){let r=i.shift(),a=r.match;if(a.matchType(e)){let u=[];for(let l=r;l.type;l=l.via)u.push(l.type);return u.reverse()}for(let u=0;u<a.next.length;u++){let{type:l,next:g}=a.next[u];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in n)&&(!r.type||g.validEnd)&&(i.push({match:l.contentMatch,type:l,via:r}),n[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(i){e.push(i);for(let r=0;r<i.next.length;r++)e.indexOf(i.next[r].next)==-1&&n(i.next[r].next)}return n(this),e.map((i,r)=>{let a=r+(i.validEnd?"*":" ")+" ";for(let u=0;u<i.next.length;u++)a+=(u?", ":"")+i.next[u].type.name+"->"+e.indexOf(i.next[u].next);return a}).join(`
|
|
630
|
-
`)}}kl.empty=new kl(!0);class XR{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $v(t){let e=[];do e.push(KR(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KR(t){let e=[];do e.push(JR(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function JR(t){let e=tL(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=QR(t,e);else break;return e}function jv(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function QR(t,e){let n=jv(t),i=n;return t.eat(",")&&(t.next!="}"?i=jv(t):i=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:e}}function eL(t,e){let n=t.nodeTypes,i=n[e];if(i)return[i];let r=[];for(let a in n){let u=n[a];u.groups.indexOf(e)>-1&&r.push(u)}return r.length==0&&t.err("No node type or group '"+e+"' found"),r}function tL(t){if(t.eat("(")){let e=$v(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=eL(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nL(t){let e=[[]];return r(a(t,0),n()),e;function n(){return e.push([])-1}function i(u,l,g){let _={term:g,to:l};return e[u].push(_),_}function r(u,l){u.forEach(g=>g.to=l)}function a(u,l){if(u.type=="choice")return u.exprs.reduce((g,_)=>g.concat(a(_,l)),[]);if(u.type=="seq")for(let g=0;;g++){let _=a(u.exprs[g],l);if(g==u.exprs.length-1)return _;r(_,l=n())}else if(u.type=="star"){let g=n();return i(l,g),r(a(u.expr,g),g),[i(g)]}else if(u.type=="plus"){let g=n();return r(a(u.expr,l),g),r(a(u.expr,g),g),[i(g)]}else{if(u.type=="opt")return[i(l)].concat(a(u.expr,l));if(u.type=="range"){let g=l;for(let _=0;_<u.min;_++){let k=n();r(a(u.expr,g),k),g=k}if(u.max==-1)r(a(u.expr,g),g);else for(let _=u.min;_<u.max;_++){let k=n();i(g,k),r(a(u.expr,g),k),g=k}return[i(g)]}else{if(u.type=="name")return[i(l,void 0,u.value)];throw new Error("Unknown expr type")}}}}function Uv(t,e){return e-t}function Hv(t,e){let n=[];return i(e),n.sort(Uv);function i(r){let a=t[r];if(a.length==1&&!a[0].term)return i(a[0].to);n.push(r);for(let u=0;u<a.length;u++){let{term:l,to:g}=a[u];!l&&n.indexOf(g)==-1&&i(g)}}}function iL(t){let e=Object.create(null);return n(Hv(t,0));function n(i){let r=[];i.forEach(u=>{t[u].forEach(({term:l,to:g})=>{if(!l)return;let _;for(let k=0;k<r.length;k++)r[k][0]==l&&(_=r[k][1]);Hv(t,g).forEach(k=>{_||r.push([l,_=[]]),_.indexOf(k)==-1&&_.push(k)})})});let a=e[i.join(",")]=new kl(i.indexOf(t.length-1)>-1);for(let u=0;u<r.length;u++){let l=r[u][1].sort(Uv);a.next.push({type:r[u][0],next:e[l.join(",")]||n(l)})}return a}}function rL(t,e){for(let n=0,i=[t];n<i.length;n++){let r=i[n],a=!r.validEnd,u=[];for(let l=0;l<r.next.length;l++){let{type:g,next:_}=r.next[l];u.push(g.name),a&&!(g.isText||g.hasRequiredAttrs())&&(a=!1),i.indexOf(_)==-1&&i.push(_)}a&&e.err("Only non-generatable nodes ("+u.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function qv(t){let e=Object.create(null);for(let n in t){let i=t[n];if(!i.hasDefault)return null;e[n]=i.default}return e}function Wv(t,e){let n=Object.create(null);for(let i in t){let r=e&&e[i];if(r===void 0){let a=t[i];if(a.hasDefault)r=a.default;else throw new RangeError("No value supplied for attribute "+i)}n[i]=r}return n}function Gv(t,e,n,i){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in t){let a=t[r];a.validate&&a.validate(e[r])}}function Zv(t,e){let n=Object.create(null);if(e)for(let i in e)n[i]=new oL(t,i,e[i]);return n}let Yv=class KE{constructor(e,n,i){this.name=e,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Zv(e,i.attrs),this.defaultAttrs=qv(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==kl.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Wv(this.attrs,e)}create(e=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new wl(this,this.computeAttrs(e),Ve.from(n),$n.setFrom(i))}createChecked(e=null,n,i){return n=Ve.from(n),this.checkContent(n),new wl(this,this.computeAttrs(e),n,$n.setFrom(i))}createAndFill(e=null,n,i){if(e=this.computeAttrs(e),n=Ve.from(n),n.size){let u=this.contentMatch.fillBefore(n);if(!u)return null;n=u.append(n)}let r=this.contentMatch.matchFragment(n),a=r&&r.fillBefore(Ve.empty,!0);return a?new wl(this,e,n.append(a),$n.setFrom(i)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Gv(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?n&&n.push(e[i]):n||(n=e.slice(0,i));return n?n.length?n:$n.none:e}static compile(e,n){let i=Object.create(null);e.forEach((a,u)=>i[a]=new KE(a,n,u));let r=n.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let a in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function sL(t,e,n){let i=n.split("|");return r=>{let a=r===null?"null":typeof r;if(i.indexOf(a)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${a}`)}}class oL{constructor(e,n,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?sL(e,n,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class of{constructor(e,n,i,r){this.name=e,this.rank=n,this.schema=i,this.spec=r,this.attrs=Zv(e,r.attrs),this.excluded=null;let a=qv(this.attrs);this.instance=a?new $n(this,a):null}create(e=null){return!e&&this.instance?this.instance:new $n(this,Wv(this.attrs,e))}static compile(e,n){let i=Object.create(null),r=0;return e.forEach((a,u)=>i[a]=new of(a,r++,n,u)),i}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Gv(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Xv{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in e)n[r]=e[r];n.nodes=Bi.from(e.nodes),n.marks=Bi.from(e.marks||{}),this.nodes=Yv.compile(this.spec.nodes,this),this.marks=of.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let a=this.nodes[r],u=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=i[u]||(i[u]=kl.parse(u,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?Kv(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let r in this.marks){let a=this.marks[r],u=a.spec.excludes;a.excluded=u==null?[a]:u==""?[]:Kv(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Yv){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,i,r)}text(e,n){let i=this.nodes.text;return new sf(i,i.defaultAttrs,e,$n.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return wl.fromJSON(this,e)}markFromJSON(e){return $n.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Kv(t,e){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.marks[r],u=a;if(a)n.push(a);else for(let l in t.marks){let g=t.marks[l];(r=="_"||g.spec.group&&g.spec.group.split(" ").indexOf(r)>-1)&&n.push(u=g)}if(!u)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return n}function aL(t){return t.tag!=null}function lL(t){return t.style!=null}let xh=class hb{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(r=>{if(aL(r))this.tags.push(r);else if(lL(r)){let a=/[^=]*/.exec(r.style)[0];i.indexOf(a)<0&&i.push(a),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let i=new tw(this,n,!1);return i.addAll(e,$n.none,n.from,n.to),i.finish()}parseSlice(e,n={}){let i=new tw(this,n,!0);return i.addAll(e,$n.none,n.from,n.to),ut.maxOpen(i.finish())}matchTag(e,n,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let a=this.tags[r];if(hL(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let u=a.getAttrs(e);if(u===!1)continue;a.attrs=u||void 0}return a}}}matchStyle(e,n,i,r){for(let a=r?this.styles.indexOf(r)+1:0;a<this.styles.length;a++){let u=this.styles[a],l=u.style;if(!(l.indexOf(e)!=0||u.context&&!i.matchesContext(u.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(u.getAttrs){let g=u.getAttrs(n);if(g===!1)continue;u.attrs=g||void 0}return u}}}static schemaRules(e){let n=[];function i(r){let a=r.priority==null?50:r.priority,u=0;for(;u<n.length;u++){let l=n[u];if((l.priority==null?50:l.priority)<a)break}n.splice(u,0,r)}for(let r in e.marks){let a=e.marks[r].spec.parseDOM;a&&a.forEach(u=>{i(u=nw(u)),u.mark||u.ignore||u.clearMark||(u.mark=r)})}for(let r in e.nodes){let a=e.nodes[r].spec.parseDOM;a&&a.forEach(u=>{i(u=nw(u)),u.node||u.ignore||u.mark||(u.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new hb(e,hb.schemaRules(e)))}};const Jv={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},cL={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qv={ol:!0,ul:!0},af=1,lf=2,vh=4;function ew(t,e,n){return e!=null?(e?af:0)|(e==="full"?lf:0):t&&t.whitespace=="pre"?af|lf:n&~vh}class cf{constructor(e,n,i,r,a,u){this.type=e,this.attrs=n,this.marks=i,this.solid=r,this.options=u,this.content=[],this.activeMarks=$n.none,this.match=a||(u&vh?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ve.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&af)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let a=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-r[0].length))}}let n=Ve.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ve.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Jv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class tw{constructor(e,n,i){this.parser=e,this.options=n,this.isOpen=i,this.open=0;let r=n.topNode,a,u=ew(null,n.preserveWhitespace,0)|(i?vh:0);r?a=new cf(r.type,r.attrs,$n.none,!0,n.topMatch||r.type.contentMatch,u):i?a=new cf(null,null,$n.none,!0,null,u):a=new cf(e.schema.topNodeType,null,$n.none,!0,null,u),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let i=e.nodeValue,r=this.top;if(r.options&lf||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(r.options&af)r.options&lf?i=i.replace(/\r\n?/g,`
|
|
630
|
+
`)}}kl.empty=new kl(!0);class XR{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $v(t){let e=[];do e.push(KR(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function KR(t){let e=[];do e.push(JR(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function JR(t){let e=tL(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=QR(t,e);else break;return e}function jv(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function QR(t,e){let n=jv(t),i=n;return t.eat(",")&&(t.next!="}"?i=jv(t):i=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:i,expr:e}}function eL(t,e){let n=t.nodeTypes,i=n[e];if(i)return[i];let r=[];for(let a in n){let u=n[a];u.isInGroup(e)&&r.push(u)}return r.length==0&&t.err("No node type or group '"+e+"' found"),r}function tL(t){if(t.eat("(")){let e=$v(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=eL(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nL(t){let e=[[]];return r(a(t,0),n()),e;function n(){return e.push([])-1}function i(u,l,g){let _={term:g,to:l};return e[u].push(_),_}function r(u,l){u.forEach(g=>g.to=l)}function a(u,l){if(u.type=="choice")return u.exprs.reduce((g,_)=>g.concat(a(_,l)),[]);if(u.type=="seq")for(let g=0;;g++){let _=a(u.exprs[g],l);if(g==u.exprs.length-1)return _;r(_,l=n())}else if(u.type=="star"){let g=n();return i(l,g),r(a(u.expr,g),g),[i(g)]}else if(u.type=="plus"){let g=n();return r(a(u.expr,l),g),r(a(u.expr,g),g),[i(g)]}else{if(u.type=="opt")return[i(l)].concat(a(u.expr,l));if(u.type=="range"){let g=l;for(let _=0;_<u.min;_++){let k=n();r(a(u.expr,g),k),g=k}if(u.max==-1)r(a(u.expr,g),g);else for(let _=u.min;_<u.max;_++){let k=n();i(g,k),r(a(u.expr,g),k),g=k}return[i(g)]}else{if(u.type=="name")return[i(l,void 0,u.value)];throw new Error("Unknown expr type")}}}}function Uv(t,e){return e-t}function Hv(t,e){let n=[];return i(e),n.sort(Uv);function i(r){let a=t[r];if(a.length==1&&!a[0].term)return i(a[0].to);n.push(r);for(let u=0;u<a.length;u++){let{term:l,to:g}=a[u];!l&&n.indexOf(g)==-1&&i(g)}}}function iL(t){let e=Object.create(null);return n(Hv(t,0));function n(i){let r=[];i.forEach(u=>{t[u].forEach(({term:l,to:g})=>{if(!l)return;let _;for(let k=0;k<r.length;k++)r[k][0]==l&&(_=r[k][1]);Hv(t,g).forEach(k=>{_||r.push([l,_=[]]),_.indexOf(k)==-1&&_.push(k)})})});let a=e[i.join(",")]=new kl(i.indexOf(t.length-1)>-1);for(let u=0;u<r.length;u++){let l=r[u][1].sort(Uv);a.next.push({type:r[u][0],next:e[l.join(",")]||n(l)})}return a}}function rL(t,e){for(let n=0,i=[t];n<i.length;n++){let r=i[n],a=!r.validEnd,u=[];for(let l=0;l<r.next.length;l++){let{type:g,next:_}=r.next[l];u.push(g.name),a&&!(g.isText||g.hasRequiredAttrs())&&(a=!1),i.indexOf(_)==-1&&i.push(_)}a&&e.err("Only non-generatable nodes ("+u.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function qv(t){let e=Object.create(null);for(let n in t){let i=t[n];if(!i.hasDefault)return null;e[n]=i.default}return e}function Wv(t,e){let n=Object.create(null);for(let i in t){let r=e&&e[i];if(r===void 0){let a=t[i];if(a.hasDefault)r=a.default;else throw new RangeError("No value supplied for attribute "+i)}n[i]=r}return n}function Gv(t,e,n,i){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let r in t){let a=t[r];a.validate&&a.validate(e[r])}}function Zv(t,e){let n=Object.create(null);if(e)for(let i in e)n[i]=new oL(t,i,e[i]);return n}let Yv=class KE{constructor(e,n,i){this.name=e,this.schema=n,this.spec=i,this.markSet=null,this.groups=i.group?i.group.split(" "):[],this.attrs=Zv(e,i.attrs),this.defaultAttrs=qv(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(i.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==kl.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Wv(this.attrs,e)}create(e=null,n,i){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new wl(this,this.computeAttrs(e),Ve.from(n),$n.setFrom(i))}createChecked(e=null,n,i){return n=Ve.from(n),this.checkContent(n),new wl(this,this.computeAttrs(e),n,$n.setFrom(i))}createAndFill(e=null,n,i){if(e=this.computeAttrs(e),n=Ve.from(n),n.size){let u=this.contentMatch.fillBefore(n);if(!u)return null;n=u.append(n)}let r=this.contentMatch.matchFragment(n),a=r&&r.fillBefore(Ve.empty,!0);return a?new wl(this,e,n.append(a),$n.setFrom(i)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let i=0;i<e.childCount;i++)if(!this.allowsMarks(e.child(i).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Gv(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let i=0;i<e.length;i++)this.allowsMarkType(e[i].type)?n&&n.push(e[i]):n||(n=e.slice(0,i));return n?n.length?n:$n.none:e}static compile(e,n){let i=Object.create(null);e.forEach((a,u)=>i[a]=new KE(a,n,u));let r=n.spec.topNode||"doc";if(!i[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!i.text)throw new RangeError("Every schema needs a 'text' type");for(let a in i.text.attrs)throw new RangeError("The text node type should not have attributes");return i}};function sL(t,e,n){let i=n.split("|");return r=>{let a=r===null?"null":typeof r;if(i.indexOf(a)<0)throw new RangeError(`Expected value of type ${i} for attribute ${e} on type ${t}, got ${a}`)}}class oL{constructor(e,n,i){this.hasDefault=Object.prototype.hasOwnProperty.call(i,"default"),this.default=i.default,this.validate=typeof i.validate=="string"?sL(e,n,i.validate):i.validate}get isRequired(){return!this.hasDefault}}class of{constructor(e,n,i,r){this.name=e,this.rank=n,this.schema=i,this.spec=r,this.attrs=Zv(e,r.attrs),this.excluded=null;let a=qv(this.attrs);this.instance=a?new $n(this,a):null}create(e=null){return!e&&this.instance?this.instance:new $n(this,Wv(this.attrs,e))}static compile(e,n){let i=Object.create(null),r=0;return e.forEach((a,u)=>i[a]=new of(a,r++,n,u)),i}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){Gv(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class Xv{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let r in e)n[r]=e[r];n.nodes=Bi.from(e.nodes),n.marks=Bi.from(e.marks||{}),this.nodes=Yv.compile(this.spec.nodes,this),this.marks=of.compile(this.spec.marks,this);let i=Object.create(null);for(let r in this.nodes){if(r in this.marks)throw new RangeError(r+" can not be both a node and a mark");let a=this.nodes[r],u=a.spec.content||"",l=a.spec.marks;if(a.contentMatch=i[u]||(i[u]=kl.parse(u,this.nodes)),a.inlineContent=a.contentMatch.inlineContent,a.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!a.isInline||!a.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=a}a.markSet=l=="_"?null:l?Kv(this,l.split(" ")):l==""||!a.inlineContent?[]:null}for(let r in this.marks){let a=this.marks[r],u=a.spec.excludes;a.excluded=u==null?[a]:u==""?[]:Kv(this,u.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,i,r){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Yv){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,i,r)}text(e,n){let i=this.nodes.text;return new sf(i,i.defaultAttrs,e,$n.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return wl.fromJSON(this,e)}markFromJSON(e){return $n.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function Kv(t,e){let n=[];for(let i=0;i<e.length;i++){let r=e[i],a=t.marks[r],u=a;if(a)n.push(a);else for(let l in t.marks){let g=t.marks[l];(r=="_"||g.spec.group&&g.spec.group.split(" ").indexOf(r)>-1)&&n.push(u=g)}if(!u)throw new SyntaxError("Unknown mark type: '"+e[i]+"'")}return n}function aL(t){return t.tag!=null}function lL(t){return t.style!=null}let xh=class hb{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let i=this.matchedStyles=[];n.forEach(r=>{if(aL(r))this.tags.push(r);else if(lL(r)){let a=/[^=]*/.exec(r.style)[0];i.indexOf(a)<0&&i.push(a),this.styles.push(r)}}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=e.nodes[r.node];return a.contentMatch.matchType(a)})}parse(e,n={}){let i=new tw(this,n,!1);return i.addAll(e,$n.none,n.from,n.to),i.finish()}parseSlice(e,n={}){let i=new tw(this,n,!0);return i.addAll(e,$n.none,n.from,n.to),ut.maxOpen(i.finish())}matchTag(e,n,i){for(let r=i?this.tags.indexOf(i)+1:0;r<this.tags.length;r++){let a=this.tags[r];if(hL(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let u=a.getAttrs(e);if(u===!1)continue;a.attrs=u||void 0}return a}}}matchStyle(e,n,i,r){for(let a=r?this.styles.indexOf(r)+1:0;a<this.styles.length;a++){let u=this.styles[a],l=u.style;if(!(l.indexOf(e)!=0||u.context&&!i.matchesContext(u.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(u.getAttrs){let g=u.getAttrs(n);if(g===!1)continue;u.attrs=g||void 0}return u}}}static schemaRules(e){let n=[];function i(r){let a=r.priority==null?50:r.priority,u=0;for(;u<n.length;u++){let l=n[u];if((l.priority==null?50:l.priority)<a)break}n.splice(u,0,r)}for(let r in e.marks){let a=e.marks[r].spec.parseDOM;a&&a.forEach(u=>{i(u=nw(u)),u.mark||u.ignore||u.clearMark||(u.mark=r)})}for(let r in e.nodes){let a=e.nodes[r].spec.parseDOM;a&&a.forEach(u=>{i(u=nw(u)),u.node||u.ignore||u.mark||(u.node=r)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new hb(e,hb.schemaRules(e)))}};const Jv={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},cL={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Qv={ol:!0,ul:!0},af=1,lf=2,vh=4;function ew(t,e,n){return e!=null?(e?af:0)|(e==="full"?lf:0):t&&t.whitespace=="pre"?af|lf:n&~vh}class cf{constructor(e,n,i,r,a,u){this.type=e,this.attrs=n,this.marks=i,this.solid=r,this.options=u,this.content=[],this.activeMarks=$n.none,this.match=a||(u&vh?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Ve.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let i=this.type.contentMatch,r;return(r=i.findWrapping(e.type))?(this.match=i,r):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&af)){let i=this.content[this.content.length-1],r;if(i&&i.isText&&(r=/[ \t\r\n\u000c]+$/.exec(i.text))){let a=i;i.text.length==r[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-r[0].length))}}let n=Ve.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Ve.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Jv.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class tw{constructor(e,n,i){this.parser=e,this.options=n,this.isOpen=i,this.open=0;let r=n.topNode,a,u=ew(null,n.preserveWhitespace,0)|(i?vh:0);r?a=new cf(r.type,r.attrs,$n.none,!0,n.topMatch||r.type.contentMatch,u):i?a=new cf(null,null,$n.none,!0,null,u):a=new cf(e.schema.topNodeType,null,$n.none,!0,null,u),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let i=e.nodeValue,r=this.top;if(r.options&lf||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(i)){if(r.options&af)r.options&lf?i=i.replace(/\r\n?/g,`
|
|
631
631
|
`):i=i.replace(/\r?\n|\r/g," ");else if(i=i.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(i)&&this.open==this.nodes.length-1){let a=r.content[r.content.length-1],u=e.previousSibling;(!a||u&&u.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(i=i.slice(1))}i&&this.insertNode(this.parser.schema.text(i),n),this.findInText(e)}else this.findInside(e)}addElement(e,n,i){let r=e.nodeName.toLowerCase(),a;Qv.hasOwnProperty(r)&&this.parser.normalizeLists&&uL(e);let u=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,i));if(u?u.ignore:cL.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e,n);else if(!u||u.skip||u.closeParent){u&&u.closeParent?this.open=Math.max(0,this.open-1):u&&u.skip.nodeType&&(e=u.skip);let l,g=this.top,_=this.needsBlock;if(Jv.hasOwnProperty(r))g.content.length&&g.content[0].isInline&&this.open&&(this.open--,g=this.top),l=!0,g.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);return}let k=u&&u.skip?n:this.readStyles(e,n);k&&this.addAll(e,k),l&&this.sync(g),this.needsBlock=_}else{let l=this.readStyles(e,n);l&&this.addElementByRule(e,u,l,u.consuming===!1?a:void 0)}}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
632
|
-
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n)}readStyles(e,n){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let a=this.parser.matchedStyles[r],u=i.getPropertyValue(a);if(u)for(let l=void 0;;){let g=this.parser.matchStyle(a,u,this,l);if(!g)break;if(g.ignore)return null;if(g.clearMark?n=n.filter(_=>!g.clearMark(_)):n=n.concat(this.parser.schema.marks[g.mark].create(g.attrs)),g.consuming===!1)l=g;else break}}return n}addElementByRule(e,n,i,r){let a,u;if(n.node)if(u=this.parser.schema.nodes[n.node],u.isLeaf)this.insertNode(u.create(n.attrs),i)||this.leafFallback(e,i);else{let g=this.enter(u,n.attrs||null,i,n.preserveWhitespace);g&&(a=!0,i=g)}else{let g=this.parser.schema.marks[n.mark];i=i.concat(g.create(n.attrs))}let l=this.top;if(u&&u.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(g=>this.insertNode(g,i));else{let g=e;typeof n.contentElement=="string"?g=e.querySelector(n.contentElement):typeof n.contentElement=="function"?g=n.contentElement(e):n.contentElement&&(g=n.contentElement),this.findAround(e,g,!0),this.addAll(g,i)}a&&this.sync(l)&&this.open--}addAll(e,n,i,r){let a=i||0;for(let u=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];u!=l;u=u.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(u,n);this.findAtPoint(e,a)}findPlace(e,n){let i,r;for(let a=this.open;a>=0;a--){let u=this.nodes[a],l=u.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,r=u,!l.length)||u.solid)break}if(!i)return null;this.sync(r);for(let a=0;a<i.length;a++)n=this.enterInner(i[a],null,n,!1);return n}insertNode(e,n){if(e.isInline&&this.needsBlock&&!this.top.type){let r=this.textblockFromContext();r&&(n=this.enterInner(r,null,n))}let i=this.findPlace(e,n);if(i){this.closeExtra();let r=this.top;r.match&&(r.match=r.match.matchType(e.type));let a=$n.none;for(let u of i.concat(e.marks))(r.type?r.type.allowsMarkType(u.type):iw(u.type,e.type))&&(a=u.addToSet(a));return r.content.push(e.mark(a)),!0}return!1}enter(e,n,i,r){let a=this.findPlace(e.create(n),i);return a&&(a=this.enterInner(e,n,i,!0,r)),a}enterInner(e,n,i,r=!1,a){this.closeExtra();let u=this.top;u.match=u.match&&u.match.matchType(e);let l=ew(e,a,u.options);u.options&vh&&u.content.length==0&&(l|=vh);let g=$n.none;return i=i.filter(_=>(u.type?u.type.allowsMarkType(_.type):iw(_.type,e))?(g=_.addToSet(g),!1):!0),this.nodes.push(new cf(e,n,g,r,null,l)),this.open++,i}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let i=this.nodes[n].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==n&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,i){if(e!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),a=-(i?i.depth+1:0)+(r?0:1),u=(l,g)=>{for(;l>=0;l--){let _=n[l];if(_==""){if(l==n.length-1||l==0)continue;for(;g>=a;g--)if(u(l-1,g))return!0;return!1}else{let k=g>0||g==0&&r?this.nodes[g].type:i&&g>=a?i.node(g-a).type:null;if(!k||k.name!=_&&k.groups.indexOf(_)==-1)return!1;g--}}return!0};return u(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let n in this.parser.schema.nodes){let i=this.parser.schema.nodes[n];if(i.isTextblock&&i.defaultAttrs)return i}}}function uL(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Qv.hasOwnProperty(i)&&n?(n.appendChild(e),e=n):i=="li"?n=e:i&&(n=null)}}function hL(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function nw(t){let e={};for(let n in t)e[n]=t[n];return e}function iw(t,e){let n=e.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(t))continue;let a=[],u=l=>{a.push(l);for(let g=0;g<l.edgeCount;g++){let{type:_,next:k}=l.edge(g);if(_==e||a.indexOf(k)<0&&u(k))return!0}};if(u(r.contentMatch))return!0}}class Sl{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},i){i||(i=Ty(n).createDocumentFragment());let r=i,a=[];return e.forEach(u=>{if(a.length||u.marks.length){let l=0,g=0;for(;l<a.length&&g<u.marks.length;){let _=u.marks[g];if(!this.marks[_.type.name]){g++;continue}if(!_.eq(a[l][0])||_.type.spec.spanning===!1)break;l++,g++}for(;l<a.length;)r=a.pop()[1];for(;g<u.marks.length;){let _=u.marks[g++],k=this.serializeMark(_,u.isInline,n);k&&(a.push([_,r]),r.appendChild(k.dom),r=k.contentDOM||k.dom)}}r.appendChild(this.serializeNodeInner(u,n))}),i}serializeNodeInner(e,n){let{dom:i,contentDOM:r}=uf(Ty(n),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,r)}return i}serializeNode(e,n={}){let i=this.serializeNodeInner(e,n);for(let r=e.marks.length-1;r>=0;r--){let a=this.serializeMark(e.marks[r],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(i),i=a.dom)}return i}serializeMark(e,n,i={}){let r=this.marks[e.type.name];return r&&uf(Ty(i),r(e,n),null,e.attrs)}static renderSpec(e,n,i=null,r){return uf(e,n,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Sl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=rw(e.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(e){return rw(e.marks)}}function rw(t){let e={};for(let n in t){let i=t[n].spec.toDOM;i&&(e[n]=i)}return e}function Ty(t){return t.document||window.document}const sw=new WeakMap;function dL(t){let e=sw.get(t);return e===void 0&&sw.set(t,e=pL(t)),e}function pL(t){let e=null;function n(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)n(i[r]);else for(let r in i)n(i[r])}return n(t),e}function uf(t,e,n,i){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],a;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(a=dL(i))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let u=r.indexOf(" ");u>0&&(n=r.slice(0,u),r=r.slice(u+1));let l,g=n?t.createElementNS(n,r):t.createElement(r),_=e[1],k=1;if(_&&typeof _=="object"&&_.nodeType==null&&!Array.isArray(_)){k=2;for(let E in _)if(_[E]!=null){let T=E.indexOf(" ");T>0?g.setAttributeNS(E.slice(0,T),E.slice(T+1),_[E]):g.setAttribute(E,_[E])}}for(let E=k;E<e.length;E++){let T=e[E];if(T===0){if(E<e.length-1||E>k)throw new RangeError("Content hole must be the only child of its parent node");return{dom:g,contentDOM:g}}else{let{dom:I,contentDOM:z}=uf(t,T,n,i);if(g.appendChild(I),z){if(l)throw new RangeError("Multiple content holes");l=z}}}return{dom:g,contentDOM:l}}const ow=65535,aw=Math.pow(2,16);function fL(t,e){return t+e*aw}function lw(t){return t&ow}function mL(t){return(t-(t&ow))/aw}const cw=1,uw=2,hf=4,hw=8;class My{constructor(e,n,i){this.pos=e,this.delInfo=n,this.recover=i}get deleted(){return(this.delInfo&hw)>0}get deletedBefore(){return(this.delInfo&(cw|hf))>0}get deletedAfter(){return(this.delInfo&(uw|hf))>0}get deletedAcross(){return(this.delInfo&hf)>0}}class Wr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Wr.empty)return Wr.empty}recover(e){let n=0,i=lw(e);if(!this.inverted)for(let r=0;r<i;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+n+mL(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,i){let r=0,a=this.inverted?2:1,u=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let g=this.ranges[l]-(this.inverted?r:0);if(g>e)break;let _=this.ranges[l+a],k=this.ranges[l+u],E=g+_;if(e<=E){let T=_?e==g?-1:e==E?1:n:n,I=g+r+(T<0?0:k);if(i)return I;let z=e==(n<0?g:E)?null:fL(l/3,e-g),V=e==g?uw:e==E?cw:hf;return(n<0?e!=g:e!=E)&&(V|=hw),new My(I,V,z)}r+=k-_}return i?e+r:new My(e+r,0,null)}touches(e,n){let i=0,r=lw(n),a=this.inverted?2:1,u=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let g=this.ranges[l]-(this.inverted?i:0);if(g>e)break;let _=this.ranges[l+a],k=g+_;if(e<=k&&l==r*3)return!0;i+=this.ranges[l+u]-_}return!1}forEach(e){let n=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,a=0;r<this.ranges.length;r+=3){let u=this.ranges[r],l=u-(this.inverted?a:0),g=u+(this.inverted?0:a),_=this.ranges[r+n],k=this.ranges[r+i];e(l,l+_,g,g+k),a+=k-_}}invert(){return new Wr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Wr.empty:new Wr(e<0?[0,-e,0]:[0,0,e])}}Wr.empty=new Wr([]);class Pc{constructor(e=[],n,i=0,r=e.length){this.maps=e,this.mirror=n,this.from=i,this.to=r}slice(e=0,n=this.maps.length){return new Pc(this.maps,this.mirror,e,n)}copy(){return new Pc(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,n){this.to=this.maps.push(e),n!=null&&this.setMirror(this.maps.length-1,n)}appendMapping(e){for(let n=0,i=this.maps.length;n<e.maps.length;n++){let r=e.getMirror(n);this.appendMap(e.maps[n],r!=null&&r<n?i+r:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,i=this.maps.length+e.maps.length;n>=0;n--){let r=e.getMirror(n);this.appendMap(e.maps[n].invert(),r!=null&&r>n?i-r-1:void 0)}}invert(){let e=new Pc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,i){let r=0;for(let a=this.from;a<this.to;a++){let u=this.maps[a],l=u.mapResult(e,n);if(l.recover!=null){let g=this.getMirror(a);if(g!=null&&g>a&&g<this.to){a=g,e=this.maps[g].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return i?e:new My(e,r,null)}}const Ay=Object.create(null);class Ki{getMap(){return Wr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Ay[n.stepType];if(!i)throw new RangeError(`No step type ${n.stepType} defined`);return i.fromJSON(e,n)}static jsonID(e,n){if(e in Ay)throw new RangeError("Duplicate use of step JSON ID "+e);return Ay[e]=n,n.prototype.jsonID=e,n}}class ui{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ui(e,null)}static fail(e){return new ui(null,e)}static fromReplace(e,n,i,r){try{return ui.ok(e.replace(n,i,r))}catch(a){if(a instanceof tf)return ui.fail(a.message);throw a}}}function Py(t,e,n){let i=[];for(let r=0;r<t.childCount;r++){let a=t.child(r);a.content.size&&(a=a.copy(Py(a.content,e,a))),a.isInline&&(a=e(a,n,r)),i.push(a)}return Ve.fromArray(i)}class pa extends Ki{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),a=new ut(Py(n.content,(u,l)=>!u.isAtom||!l.type.allowsMarkType(this.mark.type)?u:u.mark(this.mark.addToSet(u.marks)),r),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,a)}invert(){return new io(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new pa(n.pos,i.pos,this.mark)}merge(e){return e instanceof pa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pa(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new pa(n.from,n.to,e.markFromJSON(n.mark))}}Ki.jsonID("addMark",pa);class io extends Ki{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=new ut(Py(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,i)}invert(){return new pa(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new io(n.pos,i.pos,this.mark)}merge(e){return e instanceof io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new io(n.from,n.to,e.markFromJSON(n.mark))}}Ki.jsonID("removeMark",io);class fa extends Ki{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new ut(Ve.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new fa(this.pos,n.marks[r]);return new fa(this.pos,this.mark)}}return new Ic(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new fa(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new fa(n.pos,e.markFromJSON(n.mark))}}Ki.jsonID("addNodeMark",fa);class Ic extends Ki{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new ut(Ve.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new fa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ic(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ic(n.pos,e.markFromJSON(n.mark))}}Ki.jsonID("removeNodeMark",Ic);class Ci extends Ki{constructor(e,n,i,r=!1){super(),this.from=e,this.to=n,this.slice=i,this.structure=r}apply(e){return this.structure&&Iy(e,this.from,this.to)?ui.fail("Structure replace would overwrite content"):ui.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Wr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ci(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deletedAcross&&i.deletedAcross?null:new Ci(n.pos,Math.max(n.pos,i.pos),this.slice)}merge(e){if(!(e instanceof Ci)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ut.empty:new ut(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ci(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ut.empty:new ut(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ci(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ci(n.from,n.to,ut.fromJSON(e,n.slice),!!n.structure)}}Ki.jsonID("replace",Ci);class Ti extends Ki{constructor(e,n,i,r,a,u,l=!1){super(),this.from=e,this.to=n,this.gapFrom=i,this.gapTo=r,this.slice=a,this.insert=u,this.structure=l}apply(e){if(this.structure&&(Iy(e,this.from,this.gapFrom)||Iy(e,this.gapTo,this.to)))return ui.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ui.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?ui.fromReplace(e,this.from,this.to,i):ui.fail("Content does not fit in gap")}getMap(){return new Wr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ti(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||a>i.pos?null:new Ti(n.pos,i.pos,r,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ti(n.from,n.to,n.gapFrom,n.gapTo,ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ki.jsonID("replaceAround",Ti);function Iy(t,e,n){let i=t.resolve(e),r=n-e,a=i.depth;for(;r>0&&a>0&&i.indexAfter(a)==i.node(a).childCount;)a--,r--;if(r>0){let u=i.node(a).maybeChild(i.indexAfter(a));for(;r>0;){if(!u||u.isLeaf)return!0;u=u.firstChild,r--}}return!1}function gL(t,e,n,i){let r=[],a=[],u,l;t.doc.nodesBetween(e,n,(g,_,k)=>{if(!g.isInline)return;let E=g.marks;if(!i.isInSet(E)&&k.type.allowsMarkType(i.type)){let T=Math.max(_,e),I=Math.min(_+g.nodeSize,n),z=i.addToSet(E);for(let V=0;V<E.length;V++)E[V].isInSet(z)||(u&&u.to==T&&u.mark.eq(E[V])?u.to=I:r.push(u=new io(T,I,E[V])));l&&l.to==T?l.to=I:a.push(l=new pa(T,I,i))}}),r.forEach(g=>t.step(g)),a.forEach(g=>t.step(g))}function yL(t,e,n,i){let r=[],a=0;t.doc.nodesBetween(e,n,(u,l)=>{if(!u.isInline)return;a++;let g=null;if(i instanceof of){let _=u.marks,k;for(;k=i.isInSet(_);)(g||(g=[])).push(k),_=k.removeFromSet(_)}else i?i.isInSet(u.marks)&&(g=[i]):g=u.marks;if(g&&g.length){let _=Math.min(l+u.nodeSize,n);for(let k=0;k<g.length;k++){let E=g[k],T;for(let I=0;I<r.length;I++){let z=r[I];z.step==a-1&&E.eq(r[I].style)&&(T=z)}T?(T.to=_,T.step=a):r.push({style:E,from:Math.max(l,e),to:_,step:a})}}}),r.forEach(u=>t.step(new io(u.from,u.to,u.style)))}function dw(t,e,n,i=n.contentMatch,r=!0){let a=t.doc.nodeAt(e),u=[],l=e+1;for(let g=0;g<a.childCount;g++){let _=a.child(g),k=l+_.nodeSize,E=i.matchType(_.type);if(!E)u.push(new Ci(l,k,ut.empty));else{i=E;for(let T=0;T<_.marks.length;T++)n.allowsMarkType(_.marks[T].type)||t.step(new io(l,k,_.marks[T]));if(r&&_.isText&&n.whitespace!="pre"){let T,I=/\r?\n|\r/g,z;for(;T=I.exec(_.text);)z||(z=new ut(Ve.from(n.schema.text(" ",n.allowedMarks(_.marks))),0,0)),u.push(new Ci(l+T.index,l+T.index+T[0].length,z))}}l=k}if(!i.validEnd){let g=i.fillBefore(Ve.empty,!0);t.replace(l,l,new ut(g,0,0))}for(let g=u.length-1;g>=0;g--)t.step(u[g])}function _L(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Dc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let i=t.depth;;--i){let r=t.$from.node(i),a=t.$from.index(i),u=t.$to.indexAfter(i);if(i<t.depth&&r.canReplace(a,u,n))return i;if(i==0||r.type.spec.isolating||!_L(r,a,u))break}return null}function bL(t,e,n){let{$from:i,$to:r,depth:a}=e,u=i.before(a+1),l=r.after(a+1),g=u,_=l,k=Ve.empty,E=0;for(let z=a,V=!1;z>n;z--)V||i.index(z)>0?(V=!0,k=Ve.from(i.node(z).copy(k)),E++):g--;let T=Ve.empty,I=0;for(let z=a,V=!1;z>n;z--)V||r.after(z+1)<r.end(z)?(V=!0,T=Ve.from(r.node(z).copy(T)),I++):_++;t.step(new Ti(g,_,u,l,new ut(k.append(T),E,I),k.size-E,!0))}function Dy(t,e,n=null,i=t){let r=xL(t,e),a=r&&vL(i,e);return a?r.map(pw).concat({type:e,attrs:n}).concat(a.map(pw)):null}function pw(t){return{type:t,attrs:null}}function xL(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.contentMatchAt(i).findWrapping(e);if(!a)return null;let u=a.length?a[0]:e;return n.canReplaceWith(i,r,u)?a:null}function vL(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.child(i),u=e.contentMatch.findWrapping(a.type);if(!u)return null;let g=(u.length?u[u.length-1]:e).contentMatch;for(let _=i;g&&_<r;_++)g=g.matchType(n.child(_).type);return!g||!g.validEnd?null:u}function wL(t,e,n){let i=Ve.empty;for(let u=n.length-1;u>=0;u--){if(i.size){let l=n[u].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=Ve.from(n[u].type.create(n[u].attrs,i))}let r=e.start,a=e.end;t.step(new Ti(r,a,r,a,new ut(i,0,0),n.length,!0))}function kL(t,e,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(u,l)=>{let g=typeof r=="function"?r(u):r;if(u.isTextblock&&!u.hasMarkup(i,g)&&CL(t.doc,t.mapping.slice(a).map(l),i)){let _=null;if(i.schema.linebreakReplacement){let I=i.whitespace=="pre",z=!!i.contentMatch.matchType(i.schema.linebreakReplacement);I&&!z?_=!1:!I&&z&&(_=!0)}_===!1&&EL(t,u,l,a),dw(t,t.mapping.slice(a).map(l,1),i,void 0,_===null);let k=t.mapping.slice(a),E=k.map(l,1),T=k.map(l+u.nodeSize,1);return t.step(new Ti(E,T,E+1,T-1,new ut(Ve.from(i.create(g,null,u.marks)),0,0),1,!0)),_===!0&&SL(t,u,l,a),!1}})}function SL(t,e,n,i){e.forEach((r,a)=>{if(r.isText){let u,l=/\r?\n|\r/g;for(;u=l.exec(r.text);){let g=t.mapping.slice(i).map(n+1+a+u.index);t.replaceWith(g,g+1,e.type.schema.linebreakReplacement.create())}}})}function EL(t,e,n,i){e.forEach((r,a)=>{if(r.type==r.type.schema.linebreakReplacement){let u=t.mapping.slice(i).map(n+1+a);t.replaceWith(u,u+1,e.type.schema.text(`
|
|
632
|
+
`),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n)}readStyles(e,n){let i=e.style;if(i&&i.length)for(let r=0;r<this.parser.matchedStyles.length;r++){let a=this.parser.matchedStyles[r],u=i.getPropertyValue(a);if(u)for(let l=void 0;;){let g=this.parser.matchStyle(a,u,this,l);if(!g)break;if(g.ignore)return null;if(g.clearMark?n=n.filter(_=>!g.clearMark(_)):n=n.concat(this.parser.schema.marks[g.mark].create(g.attrs)),g.consuming===!1)l=g;else break}}return n}addElementByRule(e,n,i,r){let a,u;if(n.node)if(u=this.parser.schema.nodes[n.node],u.isLeaf)this.insertNode(u.create(n.attrs),i)||this.leafFallback(e,i);else{let g=this.enter(u,n.attrs||null,i,n.preserveWhitespace);g&&(a=!0,i=g)}else{let g=this.parser.schema.marks[n.mark];i=i.concat(g.create(n.attrs))}let l=this.top;if(u&&u.isLeaf)this.findInside(e);else if(r)this.addElement(e,i,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(g=>this.insertNode(g,i));else{let g=e;typeof n.contentElement=="string"?g=e.querySelector(n.contentElement):typeof n.contentElement=="function"?g=n.contentElement(e):n.contentElement&&(g=n.contentElement),this.findAround(e,g,!0),this.addAll(g,i),this.findAround(e,g,!1)}a&&this.sync(l)&&this.open--}addAll(e,n,i,r){let a=i||0;for(let u=i?e.childNodes[i]:e.firstChild,l=r==null?null:e.childNodes[r];u!=l;u=u.nextSibling,++a)this.findAtPoint(e,a),this.addDOM(u,n);this.findAtPoint(e,a)}findPlace(e,n){let i,r;for(let a=this.open;a>=0;a--){let u=this.nodes[a],l=u.findWrapping(e);if(l&&(!i||i.length>l.length)&&(i=l,r=u,!l.length)||u.solid)break}if(!i)return null;this.sync(r);for(let a=0;a<i.length;a++)n=this.enterInner(i[a],null,n,!1);return n}insertNode(e,n){if(e.isInline&&this.needsBlock&&!this.top.type){let r=this.textblockFromContext();r&&(n=this.enterInner(r,null,n))}let i=this.findPlace(e,n);if(i){this.closeExtra();let r=this.top;r.match&&(r.match=r.match.matchType(e.type));let a=$n.none;for(let u of i.concat(e.marks))(r.type?r.type.allowsMarkType(u.type):iw(u.type,e.type))&&(a=u.addToSet(a));return r.content.push(e.mark(a)),!0}return!1}enter(e,n,i,r){let a=this.findPlace(e.create(n),i);return a&&(a=this.enterInner(e,n,i,!0,r)),a}enterInner(e,n,i,r=!1,a){this.closeExtra();let u=this.top;u.match=u.match&&u.match.matchType(e);let l=ew(e,a,u.options);u.options&vh&&u.content.length==0&&(l|=vh);let g=$n.none;return i=i.filter(_=>(u.type?u.type.allowsMarkType(_.type):iw(_.type,e))?(g=_.addToSet(g),!1):!0),this.nodes.push(new cf(e,n,g,r,null,l)),this.open++,i}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let i=this.nodes[n].content;for(let r=i.length-1;r>=0;r--)e+=i[r].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let i=0;i<this.find.length;i++)this.find[i].node==e&&this.find[i].offset==n&&(this.find[i].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,i){if(e!=n&&this.find)for(let r=0;r<this.find.length;r++)this.find[r].pos==null&&e.nodeType==1&&e.contains(this.find[r].node)&&n.compareDocumentPosition(this.find[r].node)&(i?2:4)&&(this.find[r].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),i=this.options.context,r=!this.isOpen&&(!i||i.parent.type==this.nodes[0].type),a=-(i?i.depth+1:0)+(r?0:1),u=(l,g)=>{for(;l>=0;l--){let _=n[l];if(_==""){if(l==n.length-1||l==0)continue;for(;g>=a;g--)if(u(l-1,g))return!0;return!1}else{let k=g>0||g==0&&r?this.nodes[g].type:i&&g>=a?i.node(g-a).type:null;if(!k||k.name!=_&&!k.isInGroup(_))return!1;g--}}return!0};return u(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(i&&i.isTextblock&&i.defaultAttrs)return i}for(let n in this.parser.schema.nodes){let i=this.parser.schema.nodes[n];if(i.isTextblock&&i.defaultAttrs)return i}}}function uL(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let i=e.nodeType==1?e.nodeName.toLowerCase():null;i&&Qv.hasOwnProperty(i)&&n?(n.appendChild(e),e=n):i=="li"?n=e:i&&(n=null)}}function hL(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function nw(t){let e={};for(let n in t)e[n]=t[n];return e}function iw(t,e){let n=e.schema.nodes;for(let i in n){let r=n[i];if(!r.allowsMarkType(t))continue;let a=[],u=l=>{a.push(l);for(let g=0;g<l.edgeCount;g++){let{type:_,next:k}=l.edge(g);if(_==e||a.indexOf(k)<0&&u(k))return!0}};if(u(r.contentMatch))return!0}}class Sl{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},i){i||(i=Ty(n).createDocumentFragment());let r=i,a=[];return e.forEach(u=>{if(a.length||u.marks.length){let l=0,g=0;for(;l<a.length&&g<u.marks.length;){let _=u.marks[g];if(!this.marks[_.type.name]){g++;continue}if(!_.eq(a[l][0])||_.type.spec.spanning===!1)break;l++,g++}for(;l<a.length;)r=a.pop()[1];for(;g<u.marks.length;){let _=u.marks[g++],k=this.serializeMark(_,u.isInline,n);k&&(a.push([_,r]),r.appendChild(k.dom),r=k.contentDOM||k.dom)}}r.appendChild(this.serializeNodeInner(u,n))}),i}serializeNodeInner(e,n){let{dom:i,contentDOM:r}=uf(Ty(n),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,r)}return i}serializeNode(e,n={}){let i=this.serializeNodeInner(e,n);for(let r=e.marks.length-1;r>=0;r--){let a=this.serializeMark(e.marks[r],e.isInline,n);a&&((a.contentDOM||a.dom).appendChild(i),i=a.dom)}return i}serializeMark(e,n,i={}){let r=this.marks[e.type.name];return r&&uf(Ty(i),r(e,n),null,e.attrs)}static renderSpec(e,n,i=null,r){return uf(e,n,i,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Sl(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=rw(e.nodes);return n.text||(n.text=i=>i.text),n}static marksFromSchema(e){return rw(e.marks)}}function rw(t){let e={};for(let n in t){let i=t[n].spec.toDOM;i&&(e[n]=i)}return e}function Ty(t){return t.document||window.document}const sw=new WeakMap;function dL(t){let e=sw.get(t);return e===void 0&&sw.set(t,e=pL(t)),e}function pL(t){let e=null;function n(i){if(i&&typeof i=="object")if(Array.isArray(i))if(typeof i[0]=="string")e||(e=[]),e.push(i);else for(let r=0;r<i.length;r++)n(i[r]);else for(let r in i)n(i[r])}return n(t),e}function uf(t,e,n,i){if(typeof e=="string")return{dom:t.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let r=e[0],a;if(typeof r!="string")throw new RangeError("Invalid array passed to renderSpec");if(i&&(a=dL(i))&&a.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let u=r.indexOf(" ");u>0&&(n=r.slice(0,u),r=r.slice(u+1));let l,g=n?t.createElementNS(n,r):t.createElement(r),_=e[1],k=1;if(_&&typeof _=="object"&&_.nodeType==null&&!Array.isArray(_)){k=2;for(let E in _)if(_[E]!=null){let T=E.indexOf(" ");T>0?g.setAttributeNS(E.slice(0,T),E.slice(T+1),_[E]):g.setAttribute(E,_[E])}}for(let E=k;E<e.length;E++){let T=e[E];if(T===0){if(E<e.length-1||E>k)throw new RangeError("Content hole must be the only child of its parent node");return{dom:g,contentDOM:g}}else{let{dom:I,contentDOM:z}=uf(t,T,n,i);if(g.appendChild(I),z){if(l)throw new RangeError("Multiple content holes");l=z}}}return{dom:g,contentDOM:l}}const ow=65535,aw=Math.pow(2,16);function fL(t,e){return t+e*aw}function lw(t){return t&ow}function mL(t){return(t-(t&ow))/aw}const cw=1,uw=2,hf=4,hw=8;class My{constructor(e,n,i){this.pos=e,this.delInfo=n,this.recover=i}get deleted(){return(this.delInfo&hw)>0}get deletedBefore(){return(this.delInfo&(cw|hf))>0}get deletedAfter(){return(this.delInfo&(uw|hf))>0}get deletedAcross(){return(this.delInfo&hf)>0}}class Wr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Wr.empty)return Wr.empty}recover(e){let n=0,i=lw(e);if(!this.inverted)for(let r=0;r<i;r++)n+=this.ranges[r*3+2]-this.ranges[r*3+1];return this.ranges[i*3]+n+mL(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,i){let r=0,a=this.inverted?2:1,u=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let g=this.ranges[l]-(this.inverted?r:0);if(g>e)break;let _=this.ranges[l+a],k=this.ranges[l+u],E=g+_;if(e<=E){let T=_?e==g?-1:e==E?1:n:n,I=g+r+(T<0?0:k);if(i)return I;let z=e==(n<0?g:E)?null:fL(l/3,e-g),V=e==g?uw:e==E?cw:hf;return(n<0?e!=g:e!=E)&&(V|=hw),new My(I,V,z)}r+=k-_}return i?e+r:new My(e+r,0,null)}touches(e,n){let i=0,r=lw(n),a=this.inverted?2:1,u=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let g=this.ranges[l]-(this.inverted?i:0);if(g>e)break;let _=this.ranges[l+a],k=g+_;if(e<=k&&l==r*3)return!0;i+=this.ranges[l+u]-_}return!1}forEach(e){let n=this.inverted?2:1,i=this.inverted?1:2;for(let r=0,a=0;r<this.ranges.length;r+=3){let u=this.ranges[r],l=u-(this.inverted?a:0),g=u+(this.inverted?0:a),_=this.ranges[r+n],k=this.ranges[r+i];e(l,l+_,g,g+k),a+=k-_}}invert(){return new Wr(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Wr.empty:new Wr(e<0?[0,-e,0]:[0,0,e])}}Wr.empty=new Wr([]);class Pc{constructor(e=[],n,i=0,r=e.length){this.maps=e,this.mirror=n,this.from=i,this.to=r}slice(e=0,n=this.maps.length){return new Pc(this.maps,this.mirror,e,n)}copy(){return new Pc(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,n){this.to=this.maps.push(e),n!=null&&this.setMirror(this.maps.length-1,n)}appendMapping(e){for(let n=0,i=this.maps.length;n<e.maps.length;n++){let r=e.getMirror(n);this.appendMap(e.maps[n],r!=null&&r<n?i+r:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,i=this.maps.length+e.maps.length;n>=0;n--){let r=e.getMirror(n);this.appendMap(e.maps[n].invert(),r!=null&&r>n?i-r-1:void 0)}}invert(){let e=new Pc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let i=this.from;i<this.to;i++)e=this.maps[i].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,i){let r=0;for(let a=this.from;a<this.to;a++){let u=this.maps[a],l=u.mapResult(e,n);if(l.recover!=null){let g=this.getMirror(a);if(g!=null&&g>a&&g<this.to){a=g,e=this.maps[g].recover(l.recover);continue}}r|=l.delInfo,e=l.pos}return i?e:new My(e,r,null)}}const Ay=Object.create(null);class Ki{getMap(){return Wr.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let i=Ay[n.stepType];if(!i)throw new RangeError(`No step type ${n.stepType} defined`);return i.fromJSON(e,n)}static jsonID(e,n){if(e in Ay)throw new RangeError("Duplicate use of step JSON ID "+e);return Ay[e]=n,n.prototype.jsonID=e,n}}class ui{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new ui(e,null)}static fail(e){return new ui(null,e)}static fromReplace(e,n,i,r){try{return ui.ok(e.replace(n,i,r))}catch(a){if(a instanceof tf)return ui.fail(a.message);throw a}}}function Py(t,e,n){let i=[];for(let r=0;r<t.childCount;r++){let a=t.child(r);a.content.size&&(a=a.copy(Py(a.content,e,a))),a.isInline&&(a=e(a,n,r)),i.push(a)}return Ve.fromArray(i)}class pa extends Ki{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=e.resolve(this.from),r=i.node(i.sharedDepth(this.to)),a=new ut(Py(n.content,(u,l)=>!u.isAtom||!l.type.allowsMarkType(this.mark.type)?u:u.mark(this.mark.addToSet(u.marks)),r),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,a)}invert(){return new io(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new pa(n.pos,i.pos,this.mark)}merge(e){return e instanceof pa&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new pa(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new pa(n.from,n.to,e.markFromJSON(n.mark))}}Ki.jsonID("addMark",pa);class io extends Ki{constructor(e,n,i){super(),this.from=e,this.to=n,this.mark=i}apply(e){let n=e.slice(this.from,this.to),i=new ut(Py(n.content,r=>r.mark(this.mark.removeFromSet(r.marks)),e),n.openStart,n.openEnd);return ui.fromReplace(e,this.from,this.to,i)}invert(){return new pa(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deleted&&i.deleted||n.pos>=i.pos?null:new io(n.pos,i.pos,this.mark)}merge(e){return e instanceof io&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new io(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new io(n.from,n.to,e.markFromJSON(n.mark))}}Ki.jsonID("removeMark",io);class fa extends Ki{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new ut(Ve.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let i=this.mark.addToSet(n.marks);if(i.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(i))return new fa(this.pos,n.marks[r]);return new fa(this.pos,this.mark)}}return new Ic(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new fa(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new fa(n.pos,e.markFromJSON(n.mark))}}Ki.jsonID("addNodeMark",fa);class Ic extends Ki{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at mark step's position");let i=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ui.fromReplace(e,this.pos,this.pos+1,new ut(Ve.from(i),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new fa(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Ic(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ic(n.pos,e.markFromJSON(n.mark))}}Ki.jsonID("removeNodeMark",Ic);class Ci extends Ki{constructor(e,n,i,r=!1){super(),this.from=e,this.to=n,this.slice=i,this.structure=r}apply(e){return this.structure&&Iy(e,this.from,this.to)?ui.fail("Structure replace would overwrite content"):ui.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Wr([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ci(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1);return n.deletedAcross&&i.deletedAcross?null:new Ci(n.pos,Math.max(n.pos,i.pos),this.slice)}merge(e){if(!(e instanceof Ci)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ut.empty:new ut(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ci(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ut.empty:new ut(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ci(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ci(n.from,n.to,ut.fromJSON(e,n.slice),!!n.structure)}}Ki.jsonID("replace",Ci);class Ti extends Ki{constructor(e,n,i,r,a,u,l=!1){super(),this.from=e,this.to=n,this.gapFrom=i,this.gapTo=r,this.slice=a,this.insert=u,this.structure=l}apply(e){if(this.structure&&(Iy(e,this.from,this.gapFrom)||Iy(e,this.gapTo,this.to)))return ui.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ui.fail("Gap is not a flat range");let i=this.slice.insertAt(this.insert,n.content);return i?ui.fromReplace(e,this.from,this.to,i):ui.fail("Content does not fit in gap")}getMap(){return new Wr([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new Ti(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),i=e.mapResult(this.to,-1),r=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),a=this.to==this.gapTo?i.pos:e.map(this.gapTo,1);return n.deletedAcross&&i.deletedAcross||r<n.pos||a>i.pos?null:new Ti(n.pos,i.pos,r,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ti(n.from,n.to,n.gapFrom,n.gapTo,ut.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ki.jsonID("replaceAround",Ti);function Iy(t,e,n){let i=t.resolve(e),r=n-e,a=i.depth;for(;r>0&&a>0&&i.indexAfter(a)==i.node(a).childCount;)a--,r--;if(r>0){let u=i.node(a).maybeChild(i.indexAfter(a));for(;r>0;){if(!u||u.isLeaf)return!0;u=u.firstChild,r--}}return!1}function gL(t,e,n,i){let r=[],a=[],u,l;t.doc.nodesBetween(e,n,(g,_,k)=>{if(!g.isInline)return;let E=g.marks;if(!i.isInSet(E)&&k.type.allowsMarkType(i.type)){let T=Math.max(_,e),I=Math.min(_+g.nodeSize,n),z=i.addToSet(E);for(let V=0;V<E.length;V++)E[V].isInSet(z)||(u&&u.to==T&&u.mark.eq(E[V])?u.to=I:r.push(u=new io(T,I,E[V])));l&&l.to==T?l.to=I:a.push(l=new pa(T,I,i))}}),r.forEach(g=>t.step(g)),a.forEach(g=>t.step(g))}function yL(t,e,n,i){let r=[],a=0;t.doc.nodesBetween(e,n,(u,l)=>{if(!u.isInline)return;a++;let g=null;if(i instanceof of){let _=u.marks,k;for(;k=i.isInSet(_);)(g||(g=[])).push(k),_=k.removeFromSet(_)}else i?i.isInSet(u.marks)&&(g=[i]):g=u.marks;if(g&&g.length){let _=Math.min(l+u.nodeSize,n);for(let k=0;k<g.length;k++){let E=g[k],T;for(let I=0;I<r.length;I++){let z=r[I];z.step==a-1&&E.eq(r[I].style)&&(T=z)}T?(T.to=_,T.step=a):r.push({style:E,from:Math.max(l,e),to:_,step:a})}}}),r.forEach(u=>t.step(new io(u.from,u.to,u.style)))}function dw(t,e,n,i=n.contentMatch,r=!0){let a=t.doc.nodeAt(e),u=[],l=e+1;for(let g=0;g<a.childCount;g++){let _=a.child(g),k=l+_.nodeSize,E=i.matchType(_.type);if(!E)u.push(new Ci(l,k,ut.empty));else{i=E;for(let T=0;T<_.marks.length;T++)n.allowsMarkType(_.marks[T].type)||t.step(new io(l,k,_.marks[T]));if(r&&_.isText&&n.whitespace!="pre"){let T,I=/\r?\n|\r/g,z;for(;T=I.exec(_.text);)z||(z=new ut(Ve.from(n.schema.text(" ",n.allowedMarks(_.marks))),0,0)),u.push(new Ci(l+T.index,l+T.index+T[0].length,z))}}l=k}if(!i.validEnd){let g=i.fillBefore(Ve.empty,!0);t.replace(l,l,new ut(g,0,0))}for(let g=u.length-1;g>=0;g--)t.step(u[g])}function _L(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Dc(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let i=t.depth;;--i){let r=t.$from.node(i),a=t.$from.index(i),u=t.$to.indexAfter(i);if(i<t.depth&&r.canReplace(a,u,n))return i;if(i==0||r.type.spec.isolating||!_L(r,a,u))break}return null}function bL(t,e,n){let{$from:i,$to:r,depth:a}=e,u=i.before(a+1),l=r.after(a+1),g=u,_=l,k=Ve.empty,E=0;for(let z=a,V=!1;z>n;z--)V||i.index(z)>0?(V=!0,k=Ve.from(i.node(z).copy(k)),E++):g--;let T=Ve.empty,I=0;for(let z=a,V=!1;z>n;z--)V||r.after(z+1)<r.end(z)?(V=!0,T=Ve.from(r.node(z).copy(T)),I++):_++;t.step(new Ti(g,_,u,l,new ut(k.append(T),E,I),k.size-E,!0))}function Dy(t,e,n=null,i=t){let r=xL(t,e),a=r&&vL(i,e);return a?r.map(pw).concat({type:e,attrs:n}).concat(a.map(pw)):null}function pw(t){return{type:t,attrs:null}}function xL(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.contentMatchAt(i).findWrapping(e);if(!a)return null;let u=a.length?a[0]:e;return n.canReplaceWith(i,r,u)?a:null}function vL(t,e){let{parent:n,startIndex:i,endIndex:r}=t,a=n.child(i),u=e.contentMatch.findWrapping(a.type);if(!u)return null;let g=(u.length?u[u.length-1]:e).contentMatch;for(let _=i;g&&_<r;_++)g=g.matchType(n.child(_).type);return!g||!g.validEnd?null:u}function wL(t,e,n){let i=Ve.empty;for(let u=n.length-1;u>=0;u--){if(i.size){let l=n[u].type.contentMatch.matchFragment(i);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}i=Ve.from(n[u].type.create(n[u].attrs,i))}let r=e.start,a=e.end;t.step(new Ti(r,a,r,a,new ut(i,0,0),n.length,!0))}function kL(t,e,n,i,r){if(!i.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let a=t.steps.length;t.doc.nodesBetween(e,n,(u,l)=>{let g=typeof r=="function"?r(u):r;if(u.isTextblock&&!u.hasMarkup(i,g)&&CL(t.doc,t.mapping.slice(a).map(l),i)){let _=null;if(i.schema.linebreakReplacement){let I=i.whitespace=="pre",z=!!i.contentMatch.matchType(i.schema.linebreakReplacement);I&&!z?_=!1:!I&&z&&(_=!0)}_===!1&&EL(t,u,l,a),dw(t,t.mapping.slice(a).map(l,1),i,void 0,_===null);let k=t.mapping.slice(a),E=k.map(l,1),T=k.map(l+u.nodeSize,1);return t.step(new Ti(E,T,E+1,T-1,new ut(Ve.from(i.create(g,null,u.marks)),0,0),1,!0)),_===!0&&SL(t,u,l,a),!1}})}function SL(t,e,n,i){e.forEach((r,a)=>{if(r.isText){let u,l=/\r?\n|\r/g;for(;u=l.exec(r.text);){let g=t.mapping.slice(i).map(n+1+a+u.index);t.replaceWith(g,g+1,e.type.schema.linebreakReplacement.create())}}})}function EL(t,e,n,i){e.forEach((r,a)=>{if(r.type==r.type.schema.linebreakReplacement){let u=t.mapping.slice(i).map(n+1+a);t.replaceWith(u,u+1,e.type.schema.text(`
|
|
633
633
|
`))}})}function CL(t,e,n){let i=t.resolve(e),r=i.index();return i.parent.canReplaceWith(r,r+1,n)}function TL(t,e,n,i,r){let a=t.doc.nodeAt(e);if(!a)throw new RangeError("No node at given position");n||(n=a.type);let u=n.create(i,null,r||a.marks);if(a.isLeaf)return t.replaceWith(e,e+a.nodeSize,u);if(!n.validContent(a.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ti(e,e+a.nodeSize,e+1,e+a.nodeSize-1,new ut(Ve.from(u),0,0),1,!0))}function Oc(t,e,n=1,i){let r=t.resolve(e),a=r.depth-n,u=i&&i[i.length-1]||r.parent;if(a<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!u.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let _=r.depth-1,k=n-2;_>a;_--,k--){let E=r.node(_),T=r.index(_);if(E.type.spec.isolating)return!1;let I=E.content.cutByIndex(T,E.childCount),z=i&&i[k+1];z&&(I=I.replaceChild(0,z.type.create(z.attrs)));let V=i&&i[k]||E;if(!E.canReplace(T+1,E.childCount)||!V.type.validContent(I))return!1}let l=r.indexAfter(a),g=i&&i[0];return r.node(a).canReplaceWith(l,l,g?g.type:r.node(a+1).type)}function ML(t,e,n=1,i){let r=t.doc.resolve(e),a=Ve.empty,u=Ve.empty;for(let l=r.depth,g=r.depth-n,_=n-1;l>g;l--,_--){a=Ve.from(r.node(l).copy(a));let k=i&&i[_];u=Ve.from(k?k.type.create(k.attrs,u):r.node(l).copy(u))}t.step(new Ci(e,e,new ut(a.append(u),n,n),!0))}function ma(t,e){let n=t.resolve(e),i=n.index();return fw(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(i,i+1)}function fw(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function df(t,e,n=-1){let i=t.resolve(e);for(let r=i.depth;;r--){let a,u,l=i.index(r);if(r==i.depth?(a=i.nodeBefore,u=i.nodeAfter):n>0?(a=i.node(r+1),l++,u=i.node(r).maybeChild(l)):(a=i.node(r).maybeChild(l-1),u=i.node(r+1)),a&&!a.isTextblock&&fw(a,u)&&i.node(r).canReplace(l,l+1))return e;if(r==0)break;e=n<0?i.before(r):i.after(r)}}function AL(t,e,n){let i=new Ci(e-n,e+n,ut.empty,!0);t.step(i)}function PL(t,e,n){let i=t.resolve(e);if(i.parent.canReplaceWith(i.index(),i.index(),n))return e;if(i.parentOffset==0)for(let r=i.depth-1;r>=0;r--){let a=i.index(r);if(i.node(r).canReplaceWith(a,a,n))return i.before(r+1);if(a>0)return null}if(i.parentOffset==i.parent.content.size)for(let r=i.depth-1;r>=0;r--){let a=i.indexAfter(r);if(i.node(r).canReplaceWith(a,a,n))return i.after(r+1);if(a<i.node(r).childCount)return null}return null}function mw(t,e,n){let i=t.resolve(e);if(!n.content.size)return e;let r=n.content;for(let a=0;a<n.openStart;a++)r=r.firstChild.content;for(let a=1;a<=(n.openStart==0&&n.size?2:1);a++)for(let u=i.depth;u>=0;u--){let l=u==i.depth?0:i.pos<=(i.start(u+1)+i.end(u+1))/2?-1:1,g=i.index(u)+(l>0?1:0),_=i.node(u),k=!1;if(a==1)k=_.canReplace(g,g,r);else{let E=_.contentMatchAt(g).findWrapping(r.firstChild.type);k=E&&_.canReplaceWith(g,g,E[0])}if(k)return l==0?i.pos:l<0?i.before(u+1):i.after(u+1)}return null}function pf(t,e,n=e,i=ut.empty){if(e==n&&!i.size)return null;let r=t.resolve(e),a=t.resolve(n);return gw(r,a,i)?new Ci(e,n,i):new IL(r,a,i).fit()}function gw(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class IL{constructor(e,n,i){this.$from=e,this.$to=n,this.unplaced=i,this.frontier=[],this.placed=Ve.empty;for(let r=0;r<=e.depth;r++){let a=e.node(r);this.frontier.push({type:a.type,match:a.contentMatchAt(e.indexAfter(r))})}for(let r=e.depth;r>0;r--)this.placed=Ve.from(e.node(r).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let _=this.findFittable();_?this.placeNodes(_):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,i=this.$from,r=this.close(e<0?this.$to:i.doc.resolve(e));if(!r)return null;let a=this.placed,u=i.depth,l=r.depth;for(;u&&l&&a.childCount==1;)a=a.firstChild.content,u--,l--;let g=new ut(a,u,l);return e>-1?new Ti(i.pos,e,this.$to.pos,this.$to.end(),g,n):g.size||i.pos!=this.$to.pos?new Ci(i.pos,r.pos,g):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,i=0,r=this.unplaced.openEnd;i<e;i++){let a=n.firstChild;if(n.childCount>1&&(r=0),a.type.spec.isolating&&r<=i){e=i;break}n=a.content}for(let n=1;n<=2;n++)for(let i=n==1?e:this.unplaced.openStart;i>=0;i--){let r,a=null;i?(a=Oy(this.unplaced.content,i-1).firstChild,r=a.content):r=this.unplaced.content;let u=r.firstChild;for(let l=this.depth;l>=0;l--){let{type:g,match:_}=this.frontier[l],k,E=null;if(n==1&&(u?_.matchType(u.type)||(E=_.fillBefore(Ve.from(u),!1)):a&&g.compatibleContent(a.type)))return{sliceDepth:i,frontierDepth:l,parent:a,inject:E};if(n==2&&u&&(k=_.findWrapping(u.type)))return{sliceDepth:i,frontierDepth:l,parent:a,wrap:k};if(a&&_.matchType(a.type))break}}}openMore(){let{content:e,openStart:n,openEnd:i}=this.unplaced,r=Oy(e,n);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new ut(e,n+1,Math.max(i,r.size+n>=e.size-i?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:i}=this.unplaced,r=Oy(e,n);if(r.childCount<=1&&n>0){let a=e.size-n<=n+r.size;this.unplaced=new ut(wh(e,n-1,1),n-1,a?n-1:i)}else this.unplaced=new ut(wh(e,n,1),n,i)}placeNodes({sliceDepth:e,frontierDepth:n,parent:i,inject:r,wrap:a}){for(;this.depth>n;)this.closeFrontierNode();if(a)for(let V=0;V<a.length;V++)this.openFrontierNode(a[V]);let u=this.unplaced,l=i?i.content:u.content,g=u.openStart-e,_=0,k=[],{match:E,type:T}=this.frontier[n];if(r){for(let V=0;V<r.childCount;V++)k.push(r.child(V));E=E.matchFragment(r)}let I=l.size+e-(u.content.size-u.openEnd);for(;_<l.childCount;){let V=l.child(_),H=E.matchType(V.type);if(!H)break;_++,(_>1||g==0||V.content.size)&&(E=H,k.push(yw(V.mark(T.allowedMarks(V.marks)),_==1?g:0,_==l.childCount?I:-1)))}let z=_==l.childCount;z||(I=-1),this.placed=kh(this.placed,n,Ve.from(k)),this.frontier[n].match=E,z&&I<0&&i&&i.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let V=0,H=l;V<I;V++){let Z=H.lastChild;this.frontier.push({type:Z.type,match:Z.contentMatchAt(Z.childCount)}),H=Z.content}this.unplaced=z?e==0?ut.empty:new ut(wh(u.content,e-1,1),e-1,I<0?u.openEnd:e-1):new ut(wh(u.content,e,_),u.openStart,u.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],n;if(!e.type.isTextblock||!zy(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(n=this.findCloseLevel(this.$to))&&n.depth==this.depth)return-1;let{depth:i}=this.$to,r=this.$to.after(i);for(;i>1&&r==this.$to.end(--i);)++r;return r}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:i,type:r}=this.frontier[n],a=n<e.depth&&e.end(n+1)==e.pos+(e.depth-(n+1)),u=zy(e,n,r,i,a);if(u){for(let l=n-1;l>=0;l--){let{match:g,type:_}=this.frontier[l],k=zy(e,l,_,g,!0);if(!k||k.childCount)continue e}return{depth:n,fit:u,move:a?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=kh(this.placed,n.depth,n.fit)),e=n.move;for(let i=n.depth+1;i<=e.depth;i++){let r=e.node(i),a=r.type.contentMatch.fillBefore(r.content,!0,e.index(i));this.openFrontierNode(r.type,r.attrs,a)}return e}openFrontierNode(e,n=null,i){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=kh(this.placed,this.depth,Ve.from(e.create(n,i))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Ve.empty,!0);n.childCount&&(this.placed=kh(this.placed,this.frontier.length,n))}}function wh(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(wh(t.firstChild.content,e-1,n)))}function kh(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(kh(t.lastChild.content,e-1,n)))}function Oy(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function yw(t,e,n){if(e<=0)return t;let i=t.content;return e>1&&(i=i.replaceChild(0,yw(i.firstChild,e-1,i.childCount==1?n-1:0))),e>0&&(i=t.type.contentMatch.fillBefore(i).append(i),n<=0&&(i=i.append(t.type.contentMatch.matchFragment(i).fillBefore(Ve.empty,!0)))),t.copy(i)}function zy(t,e,n,i,r){let a=t.node(e),u=r?t.indexAfter(e):t.index(e);if(u==a.childCount&&!n.compatibleContent(a.type))return null;let l=i.fillBefore(a.content,!0,u);return l&&!DL(n,a.content,u)?l:null}function DL(t,e,n){for(let i=n;i<e.childCount;i++)if(!t.allowsMarks(e.child(i).marks))return!0;return!1}function OL(t){return t.spec.defining||t.spec.definingForContent}function zL(t,e,n,i){if(!i.size)return t.deleteRange(e,n);let r=t.doc.resolve(e),a=t.doc.resolve(n);if(gw(r,a,i))return t.step(new Ci(e,n,i));let u=bw(r,t.doc.resolve(n));u[u.length-1]==0&&u.pop();let l=-(r.depth+1);u.unshift(l);for(let T=r.depth,I=r.pos-1;T>0;T--,I--){let z=r.node(T).type.spec;if(z.defining||z.definingAsContext||z.isolating)break;u.indexOf(T)>-1?l=T:r.before(T)==I&&u.splice(1,0,-T)}let g=u.indexOf(l),_=[],k=i.openStart;for(let T=i.content,I=0;;I++){let z=T.firstChild;if(_.push(z),I==i.openStart)break;T=z.content}for(let T=k-1;T>=0;T--){let I=_[T],z=OL(I.type);if(z&&!I.sameMarkup(r.node(Math.abs(l)-1)))k=T;else if(z||!I.type.isTextblock)break}for(let T=i.openStart;T>=0;T--){let I=(T+k+1)%(i.openStart+1),z=_[I];if(z)for(let V=0;V<u.length;V++){let H=u[(V+g)%u.length],Z=!0;H<0&&(Z=!1,H=-H);let ee=r.node(H-1),oe=r.index(H-1);if(ee.canReplaceWith(oe,oe,z.type,z.marks))return t.replace(r.before(H),Z?a.after(H):n,new ut(_w(i.content,0,i.openStart,I),I,i.openEnd))}}let E=t.steps.length;for(let T=u.length-1;T>=0&&(t.replace(e,n,i),!(t.steps.length>E));T--){let I=u[T];I<0||(e=r.before(I),n=a.after(I))}}function _w(t,e,n,i,r){if(e<n){let a=t.firstChild;t=t.replaceChild(0,a.copy(_w(a.content,e+1,n,i,a)))}if(e>i){let a=r.contentMatchAt(0),u=a.fillBefore(t).append(t);t=u.append(a.matchFragment(u).fillBefore(Ve.empty,!0))}return t}function RL(t,e,n,i){if(!i.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let r=PL(t.doc,e,i.type);r!=null&&(e=n=r)}t.replaceRange(e,n,new ut(Ve.from(i),0,0))}function LL(t,e,n){let i=t.doc.resolve(e),r=t.doc.resolve(n),a=bw(i,r);for(let u=0;u<a.length;u++){let l=a[u],g=u==a.length-1;if(g&&l==0||i.node(l).type.contentMatch.validEnd)return t.delete(i.start(l),r.end(l));if(l>0&&(g||i.node(l-1).canReplace(i.index(l-1),r.indexAfter(l-1))))return t.delete(i.before(l),r.after(l))}for(let u=1;u<=i.depth&&u<=r.depth;u++)if(e-i.start(u)==i.depth-u&&n>i.end(u)&&r.end(u)-n!=r.depth-u)return t.delete(i.before(u),n);t.delete(e,n)}function bw(t,e){let n=[],i=Math.min(t.depth,e.depth);for(let r=i;r>=0;r--){let a=t.start(r);if(a<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(a==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==a-1)&&n.push(r)}return n}class zc extends Ki{constructor(e,n,i){super(),this.pos=e,this.attr=n,this.value=i}apply(e){let n=e.nodeAt(this.pos);if(!n)return ui.fail("No node at attribute step's position");let i=Object.create(null);for(let a in n.attrs)i[a]=n.attrs[a];i[this.attr]=this.value;let r=n.type.create(i,null,n.marks);return ui.fromReplace(e,this.pos,this.pos+1,new ut(Ve.from(r),0,n.isLeaf?0:1))}getMap(){return Wr.empty}invert(e){return new zc(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new zc(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new zc(n.pos,n.attr,n.value)}}Ki.jsonID("attr",zc);class Sh extends Ki{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let r in e.attrs)n[r]=e.attrs[r];n[this.attr]=this.value;let i=e.type.create(n,e.content,e.marks);return ui.ok(i)}getMap(){return Wr.empty}invert(e){return new Sh(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Sh(n.attr,n.value)}}Ki.jsonID("docAttr",Sh);let Rc=class extends Error{};Rc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},Rc.prototype=Object.create(Error.prototype),Rc.prototype.constructor=Rc,Rc.prototype.name="TransformError";class NL{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Pc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Rc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,i=ut.empty){let r=pf(this.doc,e,n,i);return r&&this.step(r),this}replaceWith(e,n,i){return this.replace(e,n,new ut(Ve.from(i),0,0))}delete(e,n){return this.replace(e,n,ut.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,i){return zL(this,e,n,i),this}replaceRangeWith(e,n,i){return RL(this,e,n,i),this}deleteRange(e,n){return LL(this,e,n),this}lift(e,n){return bL(this,e,n),this}join(e,n=1){return AL(this,e,n),this}wrap(e,n){return wL(this,e,n),this}setBlockType(e,n=e,i,r=null){return kL(this,e,n,i,r),this}setNodeMarkup(e,n,i=null,r){return TL(this,e,n,i,r),this}setNodeAttribute(e,n,i){return this.step(new zc(e,n,i)),this}setDocAttribute(e,n){return this.step(new Sh(e,n)),this}addNodeMark(e,n){return this.step(new fa(e,n)),this}removeNodeMark(e,n){if(!(n instanceof $n)){let i=this.doc.nodeAt(e);if(!i)throw new RangeError("No node at position "+e);if(n=n.isInSet(i.marks),!n)return this}return this.step(new Ic(e,n)),this}split(e,n=1,i){return ML(this,e,n,i),this}addMark(e,n,i){return gL(this,e,n,i),this}removeMark(e,n,i){return yL(this,e,n,i),this}clearIncompatible(e,n,i){return dw(this,e,n,i),this}}const Ry=Object.create(null);class Gt{constructor(e,n,i){this.$anchor=e,this.$head=n,this.ranges=i||[new BL(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ut.empty){let i=n.content.lastChild,r=null;for(let l=0;l<n.openEnd;l++)r=i,i=i.lastChild;let a=e.steps.length,u=this.ranges;for(let l=0;l<u.length;l++){let{$from:g,$to:_}=u[l],k=e.mapping.slice(a);e.replaceRange(k.map(g.pos),k.map(_.pos),l?ut.empty:n),l==0&&ww(e,a,(i?i.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,n){let i=e.steps.length,r=this.ranges;for(let a=0;a<r.length;a++){let{$from:u,$to:l}=r[a],g=e.mapping.slice(i),_=g.map(u.pos),k=g.map(l.pos);a?e.deleteRange(_,k):(e.replaceRangeWith(_,k,n),ww(e,i,n.isInline?-1:1))}}static findFrom(e,n,i=!1){let r=e.parent.inlineContent?new Vt(e):Lc(e.node(0),e.parent,e.pos,e.index(),n,i);if(r)return r;for(let a=e.depth-1;a>=0;a--){let u=n<0?Lc(e.node(0),e.node(a),e.before(a+1),e.index(a),n,i):Lc(e.node(0),e.node(a),e.after(a+1),e.index(a)+1,n,i);if(u)return u}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Vs(e.node(0))}static atStart(e){return Lc(e,e,0,0,1)||new Vs(e)}static atEnd(e){return Lc(e,e,e.content.size,e.childCount,-1)||new Vs(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let i=Ry[n.type];if(!i)throw new RangeError(`No selection type ${n.type} defined`);return i.fromJSON(e,n)}static jsonID(e,n){if(e in Ry)throw new RangeError("Duplicate use of selection JSON ID "+e);return Ry[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Vt.between(this.$anchor,this.$head).getBookmark()}}Gt.prototype.visible=!0;class BL{constructor(e,n){this.$from=e,this.$to=n}}let xw=!1;function vw(t){!xw&&!t.parent.inlineContent&&(xw=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Vt extends Gt{constructor(e,n=e){vw(e),vw(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let i=e.resolve(n.map(this.head));if(!i.parent.inlineContent)return Gt.near(i);let r=e.resolve(n.map(this.anchor));return new Vt(r.parent.inlineContent?r:i,i)}replace(e,n=ut.empty){if(super.replace(e,n),n==ut.empty){let i=this.$from.marksAcross(this.$to);i&&e.ensureMarks(i)}}eq(e){return e instanceof Vt&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new ff(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Vt(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,i=n){let r=e.resolve(n);return new this(r,i==n?r:e.resolve(i))}static between(e,n,i){let r=e.pos-n.pos;if((!i||r)&&(i=r>=0?1:-1),!n.parent.inlineContent){let a=Gt.findFrom(n,i,!0)||Gt.findFrom(n,-i,!0);if(a)n=a.$head;else return Gt.near(n,i)}return e.parent.inlineContent||(r==0?e=n:(e=(Gt.findFrom(e,-i,!0)||Gt.findFrom(e,i,!0)).$anchor,e.pos<n.pos!=r<0&&(e=n))),new Vt(e,n)}}Gt.jsonID("text",Vt);class ff{constructor(e,n){this.anchor=e,this.head=n}map(e){return new ff(e.map(this.anchor),e.map(this.head))}resolve(e){return Vt.between(e.resolve(this.anchor),e.resolve(this.head))}}class zt extends Gt{constructor(e){let n=e.nodeAfter,i=e.node(0).resolve(e.pos+n.nodeSize);super(e,i),this.node=n}map(e,n){let{deleted:i,pos:r}=n.mapResult(this.anchor),a=e.resolve(r);return i?Gt.near(a):new zt(a)}content(){return new ut(Ve.from(this.node),0,0)}eq(e){return e instanceof zt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Ly(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new zt(e.resolve(n.anchor))}static create(e,n){return new zt(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}zt.prototype.visible=!1,Gt.jsonID("node",zt);class Ly{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:i}=e.mapResult(this.anchor);return n?new ff(i,i):new Ly(i)}resolve(e){let n=e.resolve(this.anchor),i=n.nodeAfter;return i&&zt.isSelectable(i)?new zt(n):Gt.near(n)}}class Vs extends Gt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ut.empty){if(n==ut.empty){e.delete(0,e.doc.content.size);let i=Gt.atStart(e.doc);i.eq(e.selection)||e.setSelection(i)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new Vs(e)}map(e){return new Vs(e)}eq(e){return e instanceof Vs}getBookmark(){return FL}}Gt.jsonID("all",Vs);const FL={map(){return this},resolve(t){return new Vs(t)}};function Lc(t,e,n,i,r,a=!1){if(e.inlineContent)return Vt.create(t,n);for(let u=i-(r>0?0:1);r>0?u<e.childCount:u>=0;u+=r){let l=e.child(u);if(l.isAtom){if(!a&&zt.isSelectable(l))return zt.create(t,n-(r<0?l.nodeSize:0))}else{let g=Lc(t,l,n+r,r<0?l.childCount:0,r,a);if(g)return g}n+=l.nodeSize*r}return null}function ww(t,e,n){let i=t.steps.length-1;if(i<e)return;let r=t.steps[i];if(!(r instanceof Ci||r instanceof Ti))return;let a=t.mapping.maps[i],u;a.forEach((l,g,_,k)=>{u==null&&(u=k)}),t.setSelection(Gt.near(t.doc.resolve(u),n))}const kw=1,mf=2,Sw=4;class VL extends NL{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|kw)&~mf,this.storedMarks=null,this}get selectionSet(){return(this.updated&kw)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=mf,this}ensureMarks(e){return $n.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&mf)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~mf,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let i=this.selection;return n&&(e=e.mark(this.storedMarks||(i.empty?i.$from.marks():i.$from.marksAcross(i.$to)||$n.none))),i.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,i){let r=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(i==null&&(i=n),i=i??n,!e)return this.deleteRange(n,i);let a=this.storedMarks;if(!a){let u=this.doc.resolve(n);a=i==n?u.marks():u.marksAcross(this.doc.resolve(i))}return this.replaceRangeWith(n,i,r.text(e,a)),this.selection.empty||this.setSelection(Gt.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Sw,this}get scrolledIntoView(){return(this.updated&Sw)>0}}function Ew(t,e){return!e||!t?t:t.bind(e)}class Eh{constructor(e,n,i){this.name=e,this.init=Ew(n.init,i),this.apply=Ew(n.apply,i)}}const $L=[new Eh("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Eh("selection",{init(t,e){return t.selection||Gt.atStart(e.doc)},apply(t){return t.selection}}),new Eh("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,i){return i.selection.$cursor?t.storedMarks:null}}),new Eh("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Ny{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=$L.slice(),n&&n.forEach(i=>{if(this.pluginsByKey[i.key])throw new RangeError("Adding different instances of a keyed plugin ("+i.key+")");this.plugins.push(i),this.pluginsByKey[i.key]=i,i.spec.state&&this.fields.push(new Eh(i.key,i.spec.state,i))})}}class Nc{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let i=0;i<this.config.plugins.length;i++)if(i!=n){let r=this.config.plugins[i];if(r.spec.filterTransaction&&!r.spec.filterTransaction.call(r,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let n=[e],i=this.applyInner(e),r=null;for(;;){let a=!1;for(let u=0;u<this.config.plugins.length;u++){let l=this.config.plugins[u];if(l.spec.appendTransaction){let g=r?r[u].n:0,_=r?r[u].state:this,k=g<n.length&&l.spec.appendTransaction.call(l,g?n.slice(g):n,_,i);if(k&&i.filterTransaction(k,u)){if(k.setMeta("appendedTransaction",e),!r){r=[];for(let E=0;E<this.config.plugins.length;E++)r.push(E<u?{state:i,n:n.length}:{state:this,n:0})}n.push(k),i=i.applyInner(k),a=!0}r&&(r[u]={state:i,n:n.length})}}if(!a)return{state:i,transactions:n}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let n=new Nc(this.config),i=this.config.fields;for(let r=0;r<i.length;r++){let a=i[r];n[a.name]=a.apply(e,this[a.name],this,n)}return n}get tr(){return new VL(this)}static create(e){let n=new Ny(e.doc?e.doc.type.schema:e.schema,e.plugins),i=new Nc(n);for(let r=0;r<n.fields.length;r++)i[n.fields[r].name]=n.fields[r].init(e,i);return i}reconfigure(e){let n=new Ny(this.schema,e.plugins),i=n.fields,r=new Nc(n);for(let a=0;a<i.length;a++){let u=i[a].name;r[u]=this.hasOwnProperty(u)?this[u]:i[a].init(e,r)}return r}toJSON(e){let n={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(n.storedMarks=this.storedMarks.map(i=>i.toJSON())),e&&typeof e=="object")for(let i in e){if(i=="doc"||i=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[i],a=r.spec.state;a&&a.toJSON&&(n[i]=a.toJSON.call(r,this[r.key]))}return n}static fromJSON(e,n,i){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new Ny(e.schema,e.plugins),a=new Nc(r);return r.fields.forEach(u=>{if(u.name=="doc")a.doc=wl.fromJSON(e.schema,n.doc);else if(u.name=="selection")a.selection=Gt.fromJSON(a.doc,n.selection);else if(u.name=="storedMarks")n.storedMarks&&(a.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(i)for(let l in i){let g=i[l],_=g.spec.state;if(g.key==u.name&&_&&_.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){a[u.name]=_.fromJSON.call(g,e,n[l],a);return}}a[u.name]=u.init(e,a)}}),a}}function Cw(t,e,n){for(let i in t){let r=t[i];r instanceof Function?r=r.bind(e):i=="handleDOMEvents"&&(r=Cw(r,e,{})),n[i]=r}return n}class Fi{constructor(e){this.spec=e,this.props={},e.props&&Cw(e.props,this,this.props),this.key=e.key?e.key.key:Tw("plugin")}getState(e){return e[this.key]}}const By=Object.create(null);function Tw(t){return t in By?t+"$"+ ++By[t]:(By[t]=0,t+"$")}class Mr{constructor(e="key"){this.key=Tw(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Vi=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ch=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Fy=null;const Oo=function(t,e,n){let i=Fy||(Fy=document.createRange());return i.setEnd(t,n??t.nodeValue.length),i.setStart(t,e||0),i},jL=function(){Fy=null},El=function(t,e,n,i){return n&&(Mw(t,e,n,i,-1)||Mw(t,e,n,i,1))},UL=/^(img|br|input|textarea|hr)$/i;function Mw(t,e,n,i,r){for(;;){if(t==n&&e==i)return!0;if(e==(r<0?0:ys(t))){let a=t.parentNode;if(!a||a.nodeType!=1||Th(t)||UL.test(t.nodeName)||t.contentEditable=="false")return!1;e=Vi(t)+(r<0?0:1),t=a}else if(t.nodeType==1){if(t=t.childNodes[e+(r<0?-1:0)],t.contentEditable=="false")return!1;e=r<0?ys(t):0}else return!1}}function ys(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function HL(t,e){for(;;){if(t.nodeType==3&&e)return t;if(t.nodeType==1&&e>0){if(t.contentEditable=="false")return null;t=t.childNodes[e-1],e=ys(t)}else if(t.parentNode&&!Th(t))e=Vi(t),t=t.parentNode;else return null}}function qL(t,e){for(;;){if(t.nodeType==3&&e<t.nodeValue.length)return t;if(t.nodeType==1&&e<t.childNodes.length){if(t.contentEditable=="false")return null;t=t.childNodes[e],e=0}else if(t.parentNode&&!Th(t))e=Vi(t)+1,t=t.parentNode;else return null}}function WL(t,e,n){for(let i=e==0,r=e==ys(t);i||r;){if(t==n)return!0;let a=Vi(t);if(t=t.parentNode,!t)return!1;i=i&&a==0,r=r&&a==ys(t)}}function Th(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const gf=function(t){return t.focusNode&&El(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Cl(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function GL(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ZL(t,e,n){if(t.caretPositionFromPoint)try{let i=t.caretPositionFromPoint(e,n);if(i)return{node:i.offsetNode,offset:Math.min(ys(i.offsetNode),i.offset)}}catch{}if(t.caretRangeFromPoint){let i=t.caretRangeFromPoint(e,n);if(i)return{node:i.startContainer,offset:Math.min(ys(i.startContainer),i.startOffset)}}}const ro=typeof navigator<"u"?navigator:null,Aw=typeof document<"u"?document:null,ga=ro&&ro.userAgent||"",Vy=/Edge\/(\d+)/.exec(ga),Pw=/MSIE \d/.exec(ga),$y=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ga),Ar=!!(Pw||$y||Vy),ya=Pw?document.documentMode:$y?+$y[1]:Vy?+Vy[1]:0,$s=!Ar&&/gecko\/(\d+)/i.test(ga);$s&&+(/Firefox\/(\d+)/.exec(ga)||[0,0])[1];const jy=!Ar&&/Chrome\/(\d+)/.exec(ga),Ji=!!jy,Iw=jy?+jy[1]:0,ur=!Ar&&!!ro&&/Apple Computer/.test(ro.vendor),Bc=ur&&(/Mobile\/\w+/.test(ga)||!!ro&&ro.maxTouchPoints>2),_s=Bc||(ro?/Mac/.test(ro.platform):!1),YL=ro?/Win/.test(ro.platform):!1,js=/Android \d/.test(ga),Mh=!!Aw&&"webkitFontSmoothing"in Aw.documentElement.style,XL=Mh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function KL(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function zo(t,e){return typeof t=="number"?t:t[e]}function JL(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,i=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*i}}function Dw(t,e,n){let i=t.someProp("scrollThreshold")||0,r=t.someProp("scrollMargin")||5,a=t.dom.ownerDocument;for(let u=n||t.dom;u;u=Ch(u)){if(u.nodeType!=1)continue;let l=u,g=l==a.body,_=g?KL(a):JL(l),k=0,E=0;if(e.top<_.top+zo(i,"top")?E=-(_.top-e.top+zo(r,"top")):e.bottom>_.bottom-zo(i,"bottom")&&(E=e.bottom-e.top>_.bottom-_.top?e.top+zo(r,"top")-_.top:e.bottom-_.bottom+zo(r,"bottom")),e.left<_.left+zo(i,"left")?k=-(_.left-e.left+zo(r,"left")):e.right>_.right-zo(i,"right")&&(k=e.right-_.right+zo(r,"right")),k||E)if(g)a.defaultView.scrollBy(k,E);else{let T=l.scrollLeft,I=l.scrollTop;E&&(l.scrollTop+=E),k&&(l.scrollLeft+=k);let z=l.scrollLeft-T,V=l.scrollTop-I;e={left:e.left-z,top:e.top-V,right:e.right-z,bottom:e.bottom-V}}if(g||/^(fixed|sticky)$/.test(getComputedStyle(u).position))break}}function QL(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),i,r;for(let a=(e.left+e.right)/2,u=n+1;u<Math.min(innerHeight,e.bottom);u+=5){let l=t.root.elementFromPoint(a,u);if(!l||l==t.dom||!t.dom.contains(l))continue;let g=l.getBoundingClientRect();if(g.top>=n-20){i=l,r=g.top;break}}return{refDOM:i,refTop:r,stack:Ow(t.dom)}}function Ow(t){let e=[],n=t.ownerDocument;for(let i=t;i&&(e.push({dom:i,top:i.scrollTop,left:i.scrollLeft}),t!=n);i=Ch(i));return e}function eN({refDOM:t,refTop:e,stack:n}){let i=t?t.getBoundingClientRect().top:0;zw(n,i==0?0:i-e)}function zw(t,e){for(let n=0;n<t.length;n++){let{dom:i,top:r,left:a}=t[n];i.scrollTop!=r+e&&(i.scrollTop=r+e),i.scrollLeft!=a&&(i.scrollLeft=a)}}let Fc=null;function tN(t){if(t.setActive)return t.setActive();if(Fc)return t.focus(Fc);let e=Ow(t);t.focus(Fc==null?{get preventScroll(){return Fc={preventScroll:!0},!0}}:void 0),Fc||(Fc=!1,zw(e,0))}function Rw(t,e){let n,i=2e8,r,a=0,u=e.top,l=e.top,g,_;for(let k=t.firstChild,E=0;k;k=k.nextSibling,E++){let T;if(k.nodeType==1)T=k.getClientRects();else if(k.nodeType==3)T=Oo(k).getClientRects();else continue;for(let I=0;I<T.length;I++){let z=T[I];if(z.top<=u&&z.bottom>=l){u=Math.max(z.bottom,u),l=Math.min(z.top,l);let V=z.left>e.left?z.left-e.left:z.right<e.left?e.left-z.right:0;if(V<i){n=k,i=V,r=V&&n.nodeType==3?{left:z.right<e.left?z.right:z.left,top:e.top}:e,k.nodeType==1&&V&&(a=E+(e.left>=(z.left+z.right)/2?1:0));continue}}else z.top>e.top&&!g&&z.left<=e.left&&z.right>=e.left&&(g=k,_={left:Math.max(z.left,Math.min(z.right,e.left)),top:z.top});!n&&(e.left>=z.right&&e.top>=z.top||e.left>=z.left&&e.top>=z.bottom)&&(a=E+1)}}return!n&&g&&(n=g,r=_,i=0),n&&n.nodeType==3?nN(n,r):!n||i&&n.nodeType==1?{node:t,offset:a}:Rw(n,r)}function nN(t,e){let n=t.nodeValue.length,i=document.createRange();for(let r=0;r<n;r++){i.setEnd(t,r+1),i.setStart(t,r);let a=_a(i,1);if(a.top!=a.bottom&&Uy(e,a))return{node:t,offset:r+(e.left>=(a.left+a.right)/2?1:0)}}return{node:t,offset:0}}function Uy(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function iN(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}function rN(t,e,n){let{node:i,offset:r}=Rw(e,n),a=-1;if(i.nodeType==1&&!i.firstChild){let u=i.getBoundingClientRect();a=u.left!=u.right&&n.left>(u.left+u.right)/2?1:-1}return t.docView.posFromDOM(i,r,a)}function sN(t,e,n,i){let r=-1;for(let a=e,u=!1;a!=t.dom;){let l=t.docView.nearestDesc(a,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)){let g=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&(!u&&g.left>i.left||g.top>i.top?r=l.posBefore:(!u&&g.right<i.left||g.bottom<i.top)&&(r=l.posAfter),u=!0),!l.contentDOM&&r<0&&!l.node.isText)return(l.node.isBlock?i.top<(g.top+g.bottom)/2:i.left<(g.left+g.right)/2)?l.posBefore:l.posAfter}a=l.dom.parentNode}return r>-1?r:t.docView.posFromDOM(e,n,-1)}function Lw(t,e,n){let i=t.childNodes.length;if(i&&n.top<n.bottom)for(let r=Math.max(0,Math.min(i-1,Math.floor(i*(e.top-n.top)/(n.bottom-n.top))-2)),a=r;;){let u=t.childNodes[a];if(u.nodeType==1){let l=u.getClientRects();for(let g=0;g<l.length;g++){let _=l[g];if(Uy(e,_))return Lw(u,e,_)}}if((a=(a+1)%i)==r)break}return t}function oN(t,e){let n=t.dom.ownerDocument,i,r=0,a=ZL(n,e.left,e.top);a&&({node:i,offset:r}=a);let u=(t.root.elementFromPoint?t.root:n).elementFromPoint(e.left,e.top),l;if(!u||!t.dom.contains(u.nodeType!=1?u.parentNode:u)){let _=t.dom.getBoundingClientRect();if(!Uy(e,_)||(u=Lw(t.dom,e,_),!u))return null}if(ur)for(let _=u;i&&_;_=Ch(_))_.draggable&&(i=void 0);if(u=iN(u,e),i){if($s&&i.nodeType==1&&(r=Math.min(r,i.childNodes.length),r<i.childNodes.length)){let k=i.childNodes[r],E;k.nodeName=="IMG"&&(E=k.getBoundingClientRect()).right<=e.left&&E.bottom>e.top&&r++}let _;Mh&&r&&i.nodeType==1&&(_=i.childNodes[r-1]).nodeType==1&&_.contentEditable=="false"&&_.getBoundingClientRect().top>=e.top&&r--,i==t.dom&&r==i.childNodes.length-1&&i.lastChild.nodeType==1&&e.top>i.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(r==0||i.nodeType!=1||i.childNodes[r-1].nodeName!="BR")&&(l=sN(t,i,r,e))}l==null&&(l=rN(t,u,e));let g=t.docView.nearestDesc(u,!0);return{pos:l,inside:g?g.posAtStart-g.border:-1}}function Nw(t){return t.top<t.bottom||t.left<t.right}function _a(t,e){let n=t.getClientRects();if(n.length){let i=n[e<0?0:n.length-1];if(Nw(i))return i}return Array.prototype.find.call(n,Nw)||t.getBoundingClientRect()}const aN=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Bw(t,e,n){let{node:i,offset:r,atom:a}=t.docView.domFromPos(e,n<0?-1:1),u=Mh||$s;if(i.nodeType==3)if(u&&(aN.test(i.nodeValue)||(n<0?!r:r==i.nodeValue.length))){let g=_a(Oo(i,r,r),n);if($s&&r&&/\s/.test(i.nodeValue[r-1])&&r<i.nodeValue.length){let _=_a(Oo(i,r-1,r-1),-1);if(_.top==g.top){let k=_a(Oo(i,r,r+1),-1);if(k.top!=g.top)return Ah(k,k.left<_.left)}}return g}else{let g=r,_=r,k=n<0?1:-1;return n<0&&!r?(_++,k=-1):n>=0&&r==i.nodeValue.length?(g--,k=1):n<0?g--:_++,Ah(_a(Oo(i,g,_),k),k<0)}if(!t.state.doc.resolve(e-(a||0)).parent.inlineContent){if(a==null&&r&&(n<0||r==ys(i))){let g=i.childNodes[r-1];if(g.nodeType==1)return Hy(g.getBoundingClientRect(),!1)}if(a==null&&r<ys(i)){let g=i.childNodes[r];if(g.nodeType==1)return Hy(g.getBoundingClientRect(),!0)}return Hy(i.getBoundingClientRect(),n>=0)}if(a==null&&r&&(n<0||r==ys(i))){let g=i.childNodes[r-1],_=g.nodeType==3?Oo(g,ys(g)-(u?0:1)):g.nodeType==1&&(g.nodeName!="BR"||!g.nextSibling)?g:null;if(_)return Ah(_a(_,1),!1)}if(a==null&&r<ys(i)){let g=i.childNodes[r];for(;g.pmViewDesc&&g.pmViewDesc.ignoreForCoords;)g=g.nextSibling;let _=g?g.nodeType==3?Oo(g,0,u?0:1):g.nodeType==1?g:null:null;if(_)return Ah(_a(_,-1),!0)}return Ah(_a(i.nodeType==3?Oo(i):i,-n),n>=0)}function Ah(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Hy(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Fw(t,e,n){let i=t.state,r=t.root.activeElement;i!=e&&t.updateState(e),r!=t.dom&&t.focus();try{return n()}finally{i!=e&&t.updateState(i),r!=t.dom&&r&&r.focus()}}function lN(t,e,n){let i=e.selection,r=n=="up"?i.$from:i.$to;return Fw(t,e,()=>{let{node:a}=t.docView.domFromPos(r.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(a,!0);if(!l)break;if(l.node.isBlock){a=l.contentDOM||l.dom;break}a=l.dom.parentNode}let u=Bw(t,r.pos,1);for(let l=a.firstChild;l;l=l.nextSibling){let g;if(l.nodeType==1)g=l.getClientRects();else if(l.nodeType==3)g=Oo(l,0,l.nodeValue.length).getClientRects();else continue;for(let _=0;_<g.length;_++){let k=g[_];if(k.bottom>k.top+1&&(n=="up"?u.top-k.top>(k.bottom-u.top)*2:k.bottom-u.bottom>(u.bottom-k.top)*2))return!1}}return!0})}const cN=/[\u0590-\u08ac]/;function uN(t,e,n){let{$head:i}=e.selection;if(!i.parent.isTextblock)return!1;let r=i.parentOffset,a=!r,u=r==i.parent.content.size,l=t.domSelection();return l?!cN.test(i.parent.textContent)||!l.modify?n=="left"||n=="backward"?a:u:Fw(t,e,()=>{let{focusNode:g,focusOffset:_,anchorNode:k,anchorOffset:E}=t.domSelectionRange(),T=l.caretBidiLevel;l.modify("move",n,"character");let I=i.depth?t.docView.domAfterPos(i.before()):t.dom,{focusNode:z,focusOffset:V}=t.domSelectionRange(),H=z&&!I.contains(z.nodeType==1?z:z.parentNode)||g==z&&_==V;try{l.collapse(k,E),g&&(g!=k||_!=E)&&l.extend&&l.extend(g,_)}catch{}return T!=null&&(l.caretBidiLevel=T),H}):i.pos==i.start()||i.pos==i.end()}let Vw=null,$w=null,jw=!1;function hN(t,e,n){return Vw==e&&$w==n?jw:(Vw=e,$w=n,jw=n=="up"||n=="down"?lN(t,e,n):uN(t,e,n))}const bs=0,Uw=1,Tl=2,so=3;class Ph{constructor(e,n,i,r){this.parent=e,this.children=n,this.dom=i,this.contentDOM=r,this.dirty=bs,i.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,i){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;n<this.children.length;n++)e+=this.children[n].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let n=0,i=this.posAtStart;;n++){let r=this.children[n];if(r==e)return i;i+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,n,i){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(i<0){let a,u;if(e==this.contentDOM)a=e.childNodes[n-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.previousSibling}for(;a&&!((u=a.pmViewDesc)&&u.parent==this);)a=a.previousSibling;return a?this.posBeforeChild(u)+u.size:this.posAtStart}else{let a,u;if(e==this.contentDOM)a=e.childNodes[n];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;a=e.nextSibling}for(;a&&!((u=a.pmViewDesc)&&u.parent==this);)a=a.nextSibling;return a?this.posBeforeChild(u):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=n>Vi(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!1;break}if(a.previousSibling)break}if(r==null&&n==e.childNodes.length)for(let a=e;;a=a.parentNode){if(a==this.dom){r=!0;break}if(a.nextSibling)break}}return r??i>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let i=!0,r=e;r;r=r.parentNode){let a=this.getDesc(r),u;if(a&&(!n||a.node))if(i&&(u=a.nodeDOM)&&!(u.nodeType==1?u.contains(e.nodeType==1?e:e.parentNode):u==e))i=!1;else return a}}getDesc(e){let n=e.pmViewDesc;for(let i=n;i;i=i.parent)if(i==this)return n}posFromDOM(e,n,i){for(let r=e;r;r=r.parentNode){let a=this.getDesc(r);if(a)return a.localPosFromDOM(e,n,i)}return-1}descAt(e){for(let n=0,i=0;n<this.children.length;n++){let r=this.children[n],a=i+r.size;if(i==e&&a!=i){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(e<a)return r.descAt(e-i-r.border);i=a}}domFromPos(e,n){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let i=0,r=0;for(let a=0;i<this.children.length;i++){let u=this.children[i],l=a+u.size;if(l>e||u instanceof Ww){r=e-a;break}a=l}if(r)return this.children[i].domFromPos(r-this.children[i].border,n);for(let a;i&&!(a=this.children[i-1]).size&&a instanceof Hw&&a.side>=0;i--);if(n<=0){let a,u=!0;for(;a=i?this.children[i-1]:null,!(!a||a.dom.parentNode==this.contentDOM);i--,u=!1);return a&&n&&u&&!a.border&&!a.domAtom?a.domFromPos(a.size,n):{node:this.contentDOM,offset:a?Vi(a.dom)+1:0}}else{let a,u=!0;for(;a=i<this.children.length?this.children[i]:null,!(!a||a.dom.parentNode==this.contentDOM);i++,u=!1);return a&&u&&!a.border&&!a.domAtom?a.domFromPos(0,n):{node:this.contentDOM,offset:a?Vi(a.dom):this.contentDOM.childNodes.length}}}parseRange(e,n,i=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:n,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,a=-1;for(let u=i,l=0;;l++){let g=this.children[l],_=u+g.size;if(r==-1&&e<=_){let k=u+g.border;if(e>=k&&n<=_-g.border&&g.node&&g.contentDOM&&this.contentDOM.contains(g.contentDOM))return g.parseRange(e,n,k);e=u;for(let E=l;E>0;E--){let T=this.children[E-1];if(T.size&&T.dom.parentNode==this.contentDOM&&!T.emptyChildAt(1)){r=Vi(T.dom)+1;break}e-=T.size}r==-1&&(r=0)}if(r>-1&&(_>n||l==this.children.length-1)){n=_;for(let k=l+1;k<this.children.length;k++){let E=this.children[k];if(E.size&&E.dom.parentNode==this.contentDOM&&!E.emptyChildAt(-1)){a=Vi(E.dom);break}n+=E.size}a==-1&&(a=this.contentDOM.childNodes.length);break}u=_}return{node:this.contentDOM,from:e,to:n,fromOffset:r,toOffset:a}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let n=this.children[e<0?0:this.children.length-1];return n.size==0||n.emptyChildAt(e)}domAfterPos(e){let{node:n,offset:i}=this.domFromPos(e,0);if(n.nodeType!=1||i==n.childNodes.length)throw new RangeError("No node after pos "+e);return n.childNodes[i]}setSelection(e,n,i,r=!1){let a=Math.min(e,n),u=Math.max(e,n);for(let T=0,I=0;T<this.children.length;T++){let z=this.children[T],V=I+z.size;if(a>I&&u<V)return z.setSelection(e-I-z.border,n-I-z.border,i,r);I=V}let l=this.domFromPos(e,e?-1:1),g=n==e?l:this.domFromPos(n,n?-1:1),_=i.getSelection(),k=!1;if(($s||ur)&&e==n){let{node:T,offset:I}=l;if(T.nodeType==3){if(k=!!(I&&T.nodeValue[I-1]==`
|
|
634
634
|
`),k&&I==T.nodeValue.length)for(let z=T,V;z;z=z.parentNode){if(V=z.nextSibling){V.nodeName=="BR"&&(l=g={node:V.parentNode,offset:Vi(V)+1});break}let H=z.pmViewDesc;if(H&&H.node&&H.node.isBlock)break}}else{let z=T.childNodes[I-1];k=z&&(z.nodeName=="BR"||z.contentEditable=="false")}}if($s&&_.focusNode&&_.focusNode!=g.node&&_.focusNode.nodeType==1){let T=_.focusNode.childNodes[_.focusOffset];T&&T.contentEditable=="false"&&(r=!0)}if(!(r||k&&ur)&&El(l.node,l.offset,_.anchorNode,_.anchorOffset)&&El(g.node,g.offset,_.focusNode,_.focusOffset))return;let E=!1;if((_.extend||e==n)&&!k){_.collapse(l.node,l.offset);try{e!=n&&_.extend(g.node,g.offset),E=!0}catch{}}if(!E){if(e>n){let I=l;l=g,g=I}let T=document.createRange();T.setEnd(g.node,g.offset),T.setStart(l.node,l.offset),_.removeAllRanges(),_.addRange(T)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let i=0,r=0;r<this.children.length;r++){let a=this.children[r],u=i+a.size;if(i==u?e<=u&&n>=i:e<u&&n>i){let l=i+a.border,g=u-a.border;if(e>=l&&n<=g){this.dirty=e==i||n==u?Tl:Uw,e==l&&n==g&&(a.contentLost||a.dom.parentNode!=this.contentDOM)?a.dirty=so:a.markDirty(e-l,n-l);return}else a.dirty=a.dom==a.contentDOM&&a.dom.parentNode==this.contentDOM&&!a.children.length?Tl:so}i=u}this.dirty=Tl}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let i=e==1?Tl:Uw;n.dirty<i&&(n.dirty=i)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}}class Hw extends Ph{constructor(e,n,i,r){let a,u=n.type.toDOM;if(typeof u=="function"&&(u=u(i,()=>{if(!a)return r;if(a.parent)return a.parent.posBeforeChild(a)})),!n.type.spec.raw){if(u.nodeType!=1){let l=document.createElement("span");l.appendChild(u),u=l}u.contentEditable="false",u.classList.add("ProseMirror-widget")}super(e,[],u,null),this.widget=n,this.widget=n,a=this}matchesWidget(e){return this.dirty==bs&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class dN extends Ph{constructor(e,n,i,r){super(e,[],n,null),this.textDOM=i,this.text=r}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Ml extends Ph{constructor(e,n,i,r){super(e,[],i,r),this.mark=n}static create(e,n,i,r){let a=r.nodeViews[n.type.name],u=a&&a(n,r,i);return(!u||!u.dom)&&(u=Sl.renderSpec(document,n.type.spec.toDOM(n,i),null,n.attrs)),new Ml(e,n,u.dom,u.contentDOM||u.dom)}parseRule(){return this.dirty&so||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=so&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=bs){let i=this.parent;for(;!i.node;)i=i.parent;i.dirty<this.dirty&&(i.dirty=this.dirty),this.dirty=bs}}slice(e,n,i){let r=Ml.create(this.parent,this.mark,!0,i),a=this.children,u=this.size;n<u&&(a=Wy(a,n,u,i)),e>0&&(a=Wy(a,0,e,i));for(let l=0;l<a.length;l++)a[l].parent=r;return r.children=a,r}}class ba extends Ph{constructor(e,n,i,r,a,u,l,g,_){super(e,[],a,u),this.node=n,this.outerDeco=i,this.innerDeco=r,this.nodeDOM=l}static create(e,n,i,r,a,u){let l=a.nodeViews[n.type.name],g,_=l&&l(n,a,()=>{if(!g)return u;if(g.parent)return g.parent.posBeforeChild(g)},i,r),k=_&&_.dom,E=_&&_.contentDOM;if(n.isText){if(!k)k=document.createTextNode(n.text);else if(k.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else k||({dom:k,contentDOM:E}=Sl.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs));!E&&!n.isText&&k.nodeName!="BR"&&(k.hasAttribute("contenteditable")||(k.contentEditable="false"),n.type.spec.draggable&&(k.draggable=!0));let T=k;return k=Yw(k,i,n),_?g=new pN(e,n,i,r,k,E||null,T,_,a,u+1):n.isText?new yf(e,n,i,r,k,T,a):new ba(e,n,i,r,k,E||null,T,a,u+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let i=this.children[n];if(this.dom.contains(i.dom.parentNode)){e.contentElement=i.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Ve.empty)}return e}matchesNode(e,n,i){return this.dirty==bs&&e.eq(this.node)&&_f(n,this.outerDeco)&&i.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let i=this.node.inlineContent,r=n,a=e.composing?this.localCompositionInfo(e,n):null,u=a&&a.pos>-1?a:null,l=a&&a.pos<0,g=new mN(this,u&&u.node,e);_N(this.node,this.innerDeco,(_,k,E)=>{_.spec.marks?g.syncToMarks(_.spec.marks,i,e):_.type.side>=0&&!E&&g.syncToMarks(k==this.node.childCount?$n.none:this.node.child(k).marks,i,e),g.placeWidget(_,e,r)},(_,k,E,T)=>{g.syncToMarks(_.marks,i,e);let I;g.findNodeMatch(_,k,E,T)||l&&e.state.selection.from>r&&e.state.selection.to<r+_.nodeSize&&(I=g.findIndexWithChild(a.node))>-1&&g.updateNodeAt(_,k,E,I,e)||g.updateNextNode(_,k,E,e,T,r)||g.addNode(_,k,E,e,r),r+=_.nodeSize}),g.syncToMarks([],i,e),this.node.isTextblock&&g.addTextblockHacks(),g.destroyRest(),(g.changed||this.dirty==Tl)&&(u&&this.protectLocalComposition(e,u),Gw(this.contentDOM,this.children,e),Bc&&bN(this.dom))}localCompositionInfo(e,n){let{from:i,to:r}=e.state.selection;if(!(e.state.selection instanceof Vt)||i<n||r>n+this.node.content.size)return null;let a=e.input.compositionNode;if(!a||!this.dom.contains(a.parentNode))return null;if(this.node.inlineContent){let u=a.nodeValue,l=xN(this.node.content,u,i-n,r-n);return l<0?null:{node:a,pos:l,text:u}}else return{node:a,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:i,text:r}){if(this.getDesc(n))return;let a=n;for(;a.parentNode!=this.contentDOM;a=a.parentNode){for(;a.previousSibling;)a.parentNode.removeChild(a.previousSibling);for(;a.nextSibling;)a.parentNode.removeChild(a.nextSibling);a.pmViewDesc&&(a.pmViewDesc=void 0)}let u=new dN(this,a,n,r);e.input.compositionNodes.push(u),this.children=Wy(this.children,i,i+r.length,e,u)}update(e,n,i,r){return this.dirty==so||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,i,r),!0)}updateInner(e,n,i,r){this.updateOuterDeco(n),this.node=e,this.innerDeco=i,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=bs}updateOuterDeco(e){if(_f(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,i=this.dom;this.dom=Zw(this.dom,this.nodeDOM,qy(this.outerDeco,this.node,n),qy(e,this.node,n)),this.dom!=i&&(i.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function qw(t,e,n,i,r){Yw(i,e,t);let a=new ba(void 0,t,e,n,i,i,i,r,0);return a.contentDOM&&a.updateChildren(r,0),a}class yf extends ba{constructor(e,n,i,r,a,u,l){super(e,n,i,r,a,null,u,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,i,r){return this.dirty==so||this.dirty!=bs&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=bs||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=bs,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,i){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,i)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,i){let r=this.node.cut(e,n),a=document.createTextNode(r.text);return new yf(this.parent,r,this.outerDeco,this.innerDeco,a,a,i)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=so)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Ww extends Ph{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==bs&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class pN extends ba{constructor(e,n,i,r,a,u,l,g,_,k){super(e,n,i,r,a,u,l,_,k),this.spec=g}update(e,n,i,r){if(this.dirty==so)return!1;if(this.spec.update){let a=this.spec.update(e,n,i);return a&&this.updateInner(e,n,i,r),a}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,i,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,i,r){this.spec.setSelection?this.spec.setSelection(e,n,i):super.setSelection(e,n,i,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Gw(t,e,n){let i=t.firstChild,r=!1;for(let a=0;a<e.length;a++){let u=e[a],l=u.dom;if(l.parentNode==t){for(;l!=i;)i=Xw(i),r=!0;i=i.nextSibling}else r=!0,t.insertBefore(l,i);if(u instanceof Ml){let g=i?i.previousSibling:t.lastChild;Gw(u.contentDOM,u.children,n),i=g?g.nextSibling:t.firstChild}}for(;i;)i=Xw(i),r=!0;r&&n.trackWrites==t&&(n.trackWrites=null)}const Ih=function(t){t&&(this.nodeName=t)};Ih.prototype=Object.create(null);const Al=[new Ih];function qy(t,e,n){if(t.length==0)return Al;let i=n?Al[0]:new Ih,r=[i];for(let a=0;a<t.length;a++){let u=t[a].type.attrs;if(u){u.nodeName&&r.push(i=new Ih(u.nodeName));for(let l in u){let g=u[l];g!=null&&(n&&r.length==1&&r.push(i=new Ih(e.isInline?"span":"div")),l=="class"?i.class=(i.class?i.class+" ":"")+g:l=="style"?i.style=(i.style?i.style+";":"")+g:l!="nodeName"&&(i[l]=g))}}}return r}function Zw(t,e,n,i){if(n==Al&&i==Al)return e;let r=e;for(let a=0;a<i.length;a++){let u=i[a],l=n[a];if(a){let g;l&&l.nodeName==u.nodeName&&r!=t&&(g=r.parentNode)&&g.nodeName.toLowerCase()==u.nodeName||(g=document.createElement(u.nodeName),g.pmIsDeco=!0,g.appendChild(r),l=Al[0]),r=g}fN(r,l||Al[0],u)}return r}function fN(t,e,n){for(let i in e)i!="class"&&i!="style"&&i!="nodeName"&&!(i in n)&&t.removeAttribute(i);for(let i in n)i!="class"&&i!="style"&&i!="nodeName"&&n[i]!=e[i]&&t.setAttribute(i,n[i]);if(e.class!=n.class){let i=e.class?e.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let a=0;a<i.length;a++)r.indexOf(i[a])==-1&&t.classList.remove(i[a]);for(let a=0;a<r.length;a++)i.indexOf(r[a])==-1&&t.classList.add(r[a]);t.classList.length==0&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let i=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=i.exec(e.style);)t.style.removeProperty(r[1])}n.style&&(t.style.cssText+=n.style)}}function Yw(t,e,n){return Zw(t,t,Al,qy(e,n,t.nodeType!=1))}function _f(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function Xw(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class mN{constructor(e,n,i){this.lock=n,this.view=i,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=gN(e.node.content,e)}destroyBetween(e,n){if(e!=n){for(let i=e;i<n;i++)this.top.children[i].destroy();this.top.children.splice(e,n-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,n,i){let r=0,a=this.stack.length>>1,u=Math.min(a,e.length);for(;r<u&&(r==a-1?this.top:this.stack[r+1<<1]).matchesMark(e[r])&&e[r].type.spec.spanning!==!1;)r++;for(;r<a;)this.destroyRest(),this.top.dirty=bs,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let g=this.index;g<Math.min(this.index+3,this.top.children.length);g++){let _=this.top.children[g];if(_.matchesMark(e[a])&&!this.isLocked(_.dom)){l=g;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let g=Ml.create(this.top,e[a],n,i);this.top.children.splice(this.index,0,g),this.top=g,this.changed=!0}this.index=0,a++}}findNodeMatch(e,n,i,r){let a=-1,u;if(r>=this.preMatch.index&&(u=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&u.matchesNode(e,n,i))a=this.top.children.indexOf(u,this.index);else for(let l=this.index,g=Math.min(this.top.children.length,l+5);l<g;l++){let _=this.top.children[l];if(_.matchesNode(e,n,i)&&!this.preMatch.matched.has(_)){a=l;break}}return a<0?!1:(this.destroyBetween(this.index,a),this.index++,!0)}updateNodeAt(e,n,i,r,a){let u=this.top.children[r];return u.dirty==so&&u.dom==u.contentDOM&&(u.dirty=Tl),u.update(e,n,i,a)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let n=e.parentNode;if(!n)return-1;if(n==this.top.contentDOM){let i=e.pmViewDesc;if(i){for(let r=this.index;r<this.top.children.length;r++)if(this.top.children[r]==i)return r}return-1}e=n}}updateNextNode(e,n,i,r,a,u){for(let l=this.index;l<this.top.children.length;l++){let g=this.top.children[l];if(g instanceof ba){let _=this.preMatch.matched.get(g);if(_!=null&&_!=a)return!1;let k=g.dom,E,T=this.isLocked(k)&&!(e.isText&&g.node&&g.node.isText&&g.nodeDOM.nodeValue==e.text&&g.dirty!=so&&_f(n,g.outerDeco));if(!T&&g.update(e,n,i,r))return this.destroyBetween(this.index,l),g.dom!=k&&(this.changed=!0),this.index++,!0;if(!T&&(E=this.recreateWrapper(g,e,n,i,r,u)))return this.destroyBetween(this.index,l),this.top.children[this.index]=E,E.contentDOM&&(E.dirty=Tl,E.updateChildren(r,u+1),E.dirty=bs),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,n,i,r,a,u){if(e.dirty||n.isAtom||!e.children.length||!e.node.content.eq(n.content)||!_f(i,e.outerDeco)||!r.eq(e.innerDeco))return null;let l=ba.create(this.top,n,i,r,a,u);if(l.contentDOM){l.children=e.children,e.children=[];for(let g of l.children)g.parent=l}return e.destroy(),l}addNode(e,n,i,r,a){let u=ba.create(this.top,e,n,i,r,a);u.contentDOM&&u.updateChildren(r,a+1),this.top.children.splice(this.index++,0,u),this.changed=!0}placeWidget(e,n,i){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let a=new Hw(this.top,e,n,i);this.top.children.splice(this.index++,0,a),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],n=this.top;for(;e instanceof Ml;)n=e,e=n.children[n.children.length-1];(!e||!(e instanceof yf)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ur||Ji)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",n),this.addHackNode("BR",this.top))}addHackNode(e,n){if(n==this.top&&this.index<n.children.length&&n.children[this.index].matchesHack(e))this.index++;else{let i=document.createElement(e);e=="IMG"&&(i.className="ProseMirror-separator",i.alt=""),e=="BR"&&(i.className="ProseMirror-trailingBreak");let r=new Ww(this.top,[],i,null);n!=this.top?n.children.push(r):n.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function gN(t,e){let n=e,i=n.children.length,r=t.childCount,a=new Map,u=[];e:for(;r>0;){let l;for(;;)if(i){let _=n.children[i-1];if(_ instanceof Ml)n=_,i=_.children.length;else{l=_,i--;break}}else{if(n==e)break e;i=n.parent.children.indexOf(n),n=n.parent}let g=l.node;if(g){if(g!=t.child(r-1))break;--r,a.set(l,r),u.push(l)}}return{index:r,matched:a,matches:u.reverse()}}function yN(t,e){return t.type.side-e.type.side}function _N(t,e,n,i){let r=e.locals(t),a=0;if(r.length==0){for(let _=0;_<t.childCount;_++){let k=t.child(_);i(k,r,e.forChild(a,k),_),a+=k.nodeSize}return}let u=0,l=[],g=null;for(let _=0;;){let k,E;for(;u<r.length&&r[u].to==a;){let H=r[u++];H.widget&&(k?(E||(E=[k])).push(H):k=H)}if(k)if(E){E.sort(yN);for(let H=0;H<E.length;H++)n(E[H],_,!!g)}else n(k,_,!!g);let T,I;if(g)I=-1,T=g,g=null;else if(_<t.childCount)I=_,T=t.child(_++);else break;for(let H=0;H<l.length;H++)l[H].to<=a&&l.splice(H--,1);for(;u<r.length&&r[u].from<=a&&r[u].to>a;)l.push(r[u++]);let z=a+T.nodeSize;if(T.isText){let H=z;u<r.length&&r[u].from<H&&(H=r[u].from);for(let Z=0;Z<l.length;Z++)l[Z].to<H&&(H=l[Z].to);H<z&&(g=T.cut(H-a),T=T.cut(0,H-a),z=H,I=-1)}else for(;u<r.length&&r[u].to<z;)u++;let V=T.isInline&&!T.isLeaf?l.filter(H=>!H.inline):l.slice();i(T,V,e.forChild(a,T),I),a=z}}function bN(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function xN(t,e,n,i){for(let r=0,a=0;r<t.childCount&&a<=i;){let u=t.child(r++),l=a;if(a+=u.nodeSize,!u.isText)continue;let g=u.text;for(;r<t.childCount;){let _=t.child(r++);if(a+=_.nodeSize,!_.isText)break;g+=_.text}if(a>=n){if(a>=i&&g.slice(i-e.length-l,i-l)==e)return i-e.length;let _=l<i?g.lastIndexOf(e,i-l-1):-1;if(_>=0&&_+e.length+l>=n)return l+_;if(n==i&&g.length>=i+e.length-l&&g.slice(i-l,i-l+e.length)==e)return i}}return-1}function Wy(t,e,n,i,r){let a=[];for(let u=0,l=0;u<t.length;u++){let g=t[u],_=l,k=l+=g.size;_>=n||k<=e?a.push(g):(_<e&&a.push(g.slice(0,e-_,i)),r&&(a.push(r),r=void 0),k>n&&a.push(g.slice(n-_,g.size,i)))}return a}function Gy(t,e=null){let n=t.domSelectionRange(),i=t.state.doc;if(!n.focusNode)return null;let r=t.docView.nearestDesc(n.focusNode),a=r&&r.size==0,u=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(u<0)return null;let l=i.resolve(u),g,_;if(gf(n)){for(g=u;r&&!r.node;)r=r.parent;let E=r.node;if(r&&E.isAtom&&zt.isSelectable(E)&&r.parent&&!(E.isInline&&WL(n.focusNode,n.focusOffset,r.dom))){let T=r.posBefore;_=new zt(u==T?l:i.resolve(T))}}else{if(n instanceof t.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let E=u,T=u;for(let I=0;I<n.rangeCount;I++){let z=n.getRangeAt(I);E=Math.min(E,t.docView.posFromDOM(z.startContainer,z.startOffset,1)),T=Math.max(T,t.docView.posFromDOM(z.endContainer,z.endOffset,-1))}if(E<0)return null;[g,u]=T==t.state.selection.anchor?[T,E]:[E,T],l=i.resolve(u)}else g=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(g<0)return null}let k=i.resolve(g);if(!_){let E=e=="pointer"||t.state.selection.head<l.pos&&!a?1:-1;_=Yy(t,k,l,E)}return _}function Kw(t){return t.editable?t.hasFocus():rk(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function Ro(t,e=!1){let n=t.state.selection;if(tk(t,n),!!Kw(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&Ji){let i=t.domSelectionRange(),r=t.domObserver.currentSelection;if(i.anchorNode&&r.anchorNode&&El(i.anchorNode,i.anchorOffset,r.anchorNode,r.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)wN(t);else{let{anchor:i,head:r}=n,a,u;Jw&&!(n instanceof Vt)&&(n.$from.parent.inlineContent||(a=Qw(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(u=Qw(t,n.to))),t.docView.setSelection(i,r,t.root,e),Jw&&(a&&ek(a),u&&ek(u)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&vN(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const Jw=ur||Ji&&Iw<63;function Qw(t,e){let{node:n,offset:i}=t.docView.domFromPos(e,0),r=i<n.childNodes.length?n.childNodes[i]:null,a=i?n.childNodes[i-1]:null;if(ur&&r&&r.contentEditable=="false")return Zy(r);if((!r||r.contentEditable=="false")&&(!a||a.contentEditable=="false")){if(r)return Zy(r);if(a)return Zy(a)}}function Zy(t){return t.contentEditable="true",ur&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function ek(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function vN(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),i=n.anchorNode,r=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=i||n.anchorOffset!=r)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Kw(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function wN(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let i=t.cursorWrapper.dom,r=i.nodeName=="IMG";r?n.setStart(i.parentNode,Vi(i)+1):n.setStart(i,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!r&&!t.state.selection.visible&&Ar&&ya<=11&&(i.disabled=!0,i.disabled=!1)}function tk(t,e){if(e instanceof zt){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(nk(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else nk(t)}function nk(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Yy(t,e,n,i){return t.someProp("createSelectionBetween",r=>r(t,e,n))||Vt.between(e,n,i)}function ik(t){return t.editable&&!t.hasFocus()?!1:rk(t)}function rk(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function kN(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return El(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Xy(t,e){let{$anchor:n,$head:i}=t.selection,r=e>0?n.max(i):n.min(i),a=r.parent.inlineContent?r.depth?t.doc.resolve(e>0?r.after():r.before()):null:r;return a&&Gt.findFrom(a,e)}function xa(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function sk(t,e,n){let i=t.state.selection;if(i instanceof Vt)if(n.indexOf("s")>-1){let{$head:r}=i,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter;if(!a||a.isText||!a.isLeaf)return!1;let u=t.state.doc.resolve(r.pos+a.nodeSize*(e<0?-1:1));return xa(t,new Vt(i.$anchor,u))}else if(i.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let r=Xy(t.state,e);return r&&r instanceof zt?xa(t,r):!1}else if(!(_s&&n.indexOf("m")>-1)){let r=i.$head,a=r.textOffset?null:e<0?r.nodeBefore:r.nodeAfter,u;if(!a||a.isText)return!1;let l=e<0?r.pos-a.nodeSize:r.pos;return a.isAtom||(u=t.docView.descAt(l))&&!u.contentDOM?zt.isSelectable(a)?xa(t,new zt(e<0?t.state.doc.resolve(r.pos-a.nodeSize):r)):Mh?xa(t,new Vt(t.state.doc.resolve(e<0?l:l+a.nodeSize))):!1:!1}}else return!1;else{if(i instanceof zt&&i.node.isInline)return xa(t,new Vt(e>0?i.$to:i.$from));{let r=Xy(t.state,e);return r?xa(t,r):!1}}}function bf(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Dh(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Vc(t,e){return e<0?SN(t):EN(t)}function SN(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r,a,u=!1;for($s&&n.nodeType==1&&i<bf(n)&&Dh(n.childNodes[i],-1)&&(u=!0);;)if(i>0){if(n.nodeType!=1)break;{let l=n.childNodes[i-1];if(Dh(l,-1))r=n,a=--i;else if(l.nodeType==3)n=l,i=n.nodeValue.length;else break}}else{if(ok(n))break;{let l=n.previousSibling;for(;l&&Dh(l,-1);)r=n.parentNode,a=Vi(l),l=l.previousSibling;if(l)n=l,i=bf(n);else{if(n=n.parentNode,n==t.dom)break;i=0}}}u?Ky(t,n,i):r&&Ky(t,r,a)}function EN(t){let e=t.domSelectionRange(),n=e.focusNode,i=e.focusOffset;if(!n)return;let r=bf(n),a,u;for(;;)if(i<r){if(n.nodeType!=1)break;let l=n.childNodes[i];if(Dh(l,1))a=n,u=++i;else break}else{if(ok(n))break;{let l=n.nextSibling;for(;l&&Dh(l,1);)a=l.parentNode,u=Vi(l)+1,l=l.nextSibling;if(l)n=l,i=0,r=bf(n);else{if(n=n.parentNode,n==t.dom)break;i=r=0}}}a&&Ky(t,a,u)}function ok(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function CN(t,e){for(;t&&e==t.childNodes.length&&!Th(t);)e=Vi(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=0}}function TN(t,e){for(;t&&!e&&!Th(t);)e=Vi(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable=="false")break;t=n,e=t.childNodes.length}}function Ky(t,e,n){if(e.nodeType!=3){let a,u;(u=CN(e,n))?(e=u,n=0):(a=TN(e,n))&&(e=a,n=a.nodeValue.length)}let i=t.domSelection();if(!i)return;if(gf(i)){let a=document.createRange();a.setEnd(e,n),a.setStart(e,n),i.removeAllRanges(),i.addRange(a)}else i.extend&&i.extend(e,n);t.domObserver.setCurSelection();let{state:r}=t;setTimeout(()=>{t.state==r&&Ro(t)},50)}function ak(t,e){let n=t.state.doc.resolve(e);if(!(Ji||YL)&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let a=t.coordsAtPos(e-1),u=(a.top+a.bottom)/2;if(u>r.top&&u<r.bottom&&Math.abs(a.left-r.left)>1)return a.left<r.left?"ltr":"rtl"}if(e<n.end()){let a=t.coordsAtPos(e+1),u=(a.top+a.bottom)/2;if(u>r.top&&u<r.bottom&&Math.abs(a.left-r.left)>1)return a.left>r.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function lk(t,e,n){let i=t.state.selection;if(i instanceof Vt&&!i.empty||n.indexOf("s")>-1||_s&&n.indexOf("m")>-1)return!1;let{$from:r,$to:a}=i;if(!r.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let u=Xy(t.state,e);if(u&&u instanceof zt)return xa(t,u)}if(!r.parent.inlineContent){let u=e<0?r:a,l=i instanceof Vs?Gt.near(u,e):Gt.findFrom(u,e);return l?xa(t,l):!1}return!1}function ck(t,e){if(!(t.state.selection instanceof Vt))return!0;let{$head:n,$anchor:i,empty:r}=t.state.selection;if(!n.sameParent(i))return!0;if(!r)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let a=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let u=t.state.tr;return e<0?u.delete(n.pos-a.nodeSize,n.pos):u.delete(n.pos,n.pos+a.nodeSize),t.dispatch(u),!0}return!1}function uk(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function MN(t){if(!ur||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let i=e.firstChild;uk(t,i,"true"),setTimeout(()=>uk(t,i,"false"),20)}return!1}function AN(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function PN(t,e){let n=e.keyCode,i=AN(e);if(n==8||_s&&n==72&&i=="c")return ck(t,-1)||Vc(t,-1);if(n==46&&!e.shiftKey||_s&&n==68&&i=="c")return ck(t,1)||Vc(t,1);if(n==13||n==27)return!0;if(n==37||_s&&n==66&&i=="c"){let r=n==37?ak(t,t.state.selection.from)=="ltr"?-1:1:-1;return sk(t,r,i)||Vc(t,r)}else if(n==39||_s&&n==70&&i=="c"){let r=n==39?ak(t,t.state.selection.from)=="ltr"?1:-1:1;return sk(t,r,i)||Vc(t,r)}else{if(n==38||_s&&n==80&&i=="c")return lk(t,-1,i)||Vc(t,-1);if(n==40||_s&&n==78&&i=="c")return MN(t)||lk(t,1,i)||Vc(t,1);if(i==(_s?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function hk(t,e){t.someProp("transformCopied",I=>{e=I(e,t)});let n=[],{content:i,openStart:r,openEnd:a}=e;for(;r>1&&a>1&&i.childCount==1&&i.firstChild.childCount==1;){r--,a--;let I=i.firstChild;n.push(I.type.name,I.attrs!=I.type.defaultAttrs?I.attrs:null),i=I.content}let u=t.someProp("clipboardSerializer")||Sl.fromSchema(t.state.schema),l=bk(),g=l.createElement("div");g.appendChild(u.serializeFragment(i,{document:l}));let _=g.firstChild,k,E=0;for(;_&&_.nodeType==1&&(k=yk[_.nodeName.toLowerCase()]);){for(let I=k.length-1;I>=0;I--){let z=l.createElement(k[I]);for(;g.firstChild;)z.appendChild(g.firstChild);g.appendChild(z),E++}_=g.firstChild}_&&_.nodeType==1&&_.setAttribute("data-pm-slice",`${r} ${a}${E?` -${E}`:""} ${JSON.stringify(n)}`);let T=t.someProp("clipboardTextSerializer",I=>I(e,t))||e.content.textBetween(0,e.content.size,`
|
|
635
635
|
|
|
@@ -738,4 +738,4 @@ img.ProseMirror-separator {
|
|
|
738
738
|
|
|
739
739
|
`);return!a||!u?!1:t.chain().command(({tr:l})=>(l.delete(i.pos-2,i.pos),!0)).exitCode().run()},ArrowDown:({editor:t})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=t,{selection:n,doc:i}=e,{$from:r,empty:a}=n;if(!a||r.parent.type!==this.type||!(r.parentOffset===r.parent.nodeSize-2))return!1;const l=r.after();return l===void 0?!1:i.nodeAt(l)?t.commands.command(({tr:_})=>(_.setSelection(Gt.near(i.resolve(l))),!0)):t.commands.exitCode()}}},addInputRules(){return[E0({find:AF,type:this.type,getAttributes:t=>({language:t[1]})}),E0({find:PF,type:this.type,getAttributes:t=>({language:t[1]})})]},addProseMirrorPlugins(){return[new Fi({key:new Mr("codeBlockVSCodeHandler"),props:{handlePaste:(t,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const n=e.clipboardData.getData("text/plain"),i=e.clipboardData.getData("vscode-editor-data"),r=i?JSON.parse(i):void 0,a=r==null?void 0:r.mode;if(!n||!a)return!1;const{tr:u,schema:l}=t.state,g=l.text(n.replace(/\r\n?/g,`
|
|
740
740
|
`));return u.replaceSelectionWith(this.type.create({language:a},g)),u.selection.$from.parent.type!==this.type&&u.setSelection(Vt.near(u.doc.resolve(Math.max(0,u.selection.from-2)))),u.setMeta("paste",!0),t.dispatch(u),!0}}})]}}),IF=xs.create({name:"doc",topNode:!0,content:"block+"});function DF(t={}){return new Fi({view(e){return new OF(e,t)}})}class OF{constructor(e,n){var i;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(i=n.width)!==null&&i!==void 0?i:1,this.color=n.color===!1?void 0:n.color||"black",this.class=n.class,this.handlers=["dragover","dragend","drop","dragleave"].map(r=>{let a=u=>{this[r](u)};return e.dom.addEventListener(r,a),{name:r,handler:a}})}destroy(){this.handlers.forEach(({name:e,handler:n})=>this.editorView.dom.removeEventListener(e,n))}update(e,n){this.cursorPos!=null&&n.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),n=!e.parent.inlineContent,i;if(n){let l=e.nodeBefore,g=e.nodeAfter;if(l||g){let _=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(_){let k=_.getBoundingClientRect(),E=l?k.bottom:k.top;l&&g&&(E=(E+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),i={left:k.left,right:k.right,top:E-this.width/2,bottom:E+this.width/2}}}}if(!i){let l=this.editorView.coordsAtPos(this.cursorPos);i={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let r=this.editorView.dom.offsetParent;this.element||(this.element=r.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n);let a,u;if(!r||r==document.body&&getComputedStyle(r).position=="static")a=-pageXOffset,u=-pageYOffset;else{let l=r.getBoundingClientRect();a=l.left-r.scrollLeft,u=l.top-r.scrollTop}this.element.style.left=i.left-a+"px",this.element.style.top=i.top-u+"px",this.element.style.width=i.right-i.left+"px",this.element.style.height=i.bottom-i.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let n=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),i=n&&n.inside>=0&&this.editorView.state.doc.nodeAt(n.inside),r=i&&i.type.spec.disableDropCursor,a=typeof r=="function"?r(this.editorView,n,e):r;if(n&&!a){let u=n.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=mw(this.editorView.state.doc,u,this.editorView.dragging.slice);l!=null&&(u=l)}this.setCursor(u),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}}const zF=ji.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[DF(this.options)]}});class ii extends Gt{constructor(e){super(e,e)}map(e,n){let i=e.resolve(n.map(this.head));return ii.valid(i)?new ii(i):Gt.near(i)}content(){return ut.empty}eq(e){return e instanceof ii&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ii(e.resolve(n.pos))}getBookmark(){return new H0(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!RF(e)||!LF(e))return!1;let i=n.type.spec.allowGapCursor;if(i!=null)return i;let r=n.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,n,i=!1){e:for(;;){if(!i&&ii.valid(e))return e;let r=e.pos,a=null;for(let u=e.depth;;u--){let l=e.node(u);if(n>0?e.indexAfter(u)<l.childCount:e.index(u)>0){a=l.child(n>0?e.indexAfter(u):e.index(u)-1);break}else if(u==0)return null;r+=n;let g=e.doc.resolve(r);if(ii.valid(g))return g}for(;;){let u=n>0?a.firstChild:a.lastChild;if(!u){if(a.isAtom&&!a.isText&&!zt.isSelectable(a)){e=e.doc.resolve(r+a.nodeSize*n),i=!1;continue e}break}a=u,r+=n;let l=e.doc.resolve(r);if(ii.valid(l))return l}return null}}}ii.prototype.visible=!1,ii.findFrom=ii.findGapCursorFrom,Gt.jsonID("gapcursor",ii);class H0{constructor(e){this.pos=e}map(e){return new H0(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ii.valid(n)?new ii(n):Gt.near(n)}}function RF(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),i=t.node(e);if(n==0){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(n-1);;r=r.lastChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function LF(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),i=t.node(e);if(n==i.childCount){if(i.type.spec.isolating)return!0;continue}for(let r=i.child(n);;r=r.firstChild){if(r.childCount==0&&!r.inlineContent||r.isAtom||r.type.spec.isolating)return!0;if(r.inlineContent)return!1}}return!0}function NF(){return new Fi({props:{decorations:$F,createSelectionBetween(t,e,n){return e.pos==n.pos&&ii.valid(n)?new ii(n):null},handleClick:FF,handleKeyDown:BF,handleDOMEvents:{beforeinput:VF}}})}const BF=$k({ArrowLeft:Hf("horiz",-1),ArrowRight:Hf("horiz",1),ArrowUp:Hf("vert",-1),ArrowDown:Hf("vert",1)});function Hf(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(i,r,a){let u=i.selection,l=e>0?u.$to:u.$from,g=u.empty;if(u instanceof Vt){if(!a.endOfTextblock(n)||l.depth==0)return!1;g=!1,l=i.doc.resolve(e>0?l.after():l.before())}let _=ii.findGapCursorFrom(l,e,g);return _?(r&&r(i.tr.setSelection(new ii(_))),!0):!1}}function FF(t,e,n){if(!t||!t.editable)return!1;let i=t.state.doc.resolve(e);if(!ii.valid(i))return!1;let r=t.posAtCoords({left:n.clientX,top:n.clientY});return r&&r.inside>-1&&zt.isSelectable(t.state.doc.nodeAt(r.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ii(i))),!0)}function VF(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ii))return!1;let{$from:n}=t.state.selection,i=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!i)return!1;let r=Ve.empty;for(let u=i.length-1;u>=0;u--)r=Ve.from(i[u].createAndFill(null,r));let a=t.state.tr.replace(n.pos,n.pos,new ut(r,0,0));return a.setSelection(Vt.near(a.doc.resolve(n.pos+1))),t.dispatch(a),!1}function $F(t){if(!(t.selection instanceof ii))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",hi.create(t.doc,[Gr.widget(t.selection.head,e,{key:"gapcursor"})])}const jF=ji.create({name:"gapCursor",addProseMirrorPlugins(){return[NF()]},extendNodeSchema(t){var e;const n={name:t.name,options:t.options,storage:t.storage};return{allowGapCursor:(e=tn(vt(t,"allowGapCursor",n)))!==null&&e!==void 0?e:null}}}),UF=xs.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:t}){return["br",di(this.options.HTMLAttributes,t)]},renderText(){return`
|
|
741
|
-
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:i})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:r,storedMarks:a}=n;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:u}=this.options,{splittableMarks:l}=i.extensionManager,g=a||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:_,dispatch:k})=>{if(k&&g&&u){const E=g.filter(T=>l.includes(T.type.name));_.ensureMarks(E)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),HF=xs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,di(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>E0({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var qf=200,Ai=function(){};Ai.prototype.append=function(e){return e.length?(e=Ai.from(e),!this.length&&e||e.length<qf&&this.leafAppend(e)||this.length<qf&&e.leafPrepend(this)||this.appendInner(e)):this},Ai.prototype.prepend=function(e){return e.length?Ai.from(e).append(this):this},Ai.prototype.appendInner=function(e){return new qF(this,e)},Ai.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ai.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},Ai.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ai.prototype.forEach=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length),n<=i?this.forEachInner(e,n,i,0):this.forEachInvertedInner(e,n,i,0)},Ai.prototype.map=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(a,u){return r.push(e(a,u))},n,i),r},Ai.from=function(e){return e instanceof Ai?e:e&&e.length?new nS(e):Ai.empty};var nS=function(t){function e(i){t.call(this),this.values=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,a){return r==0&&a==this.length?this:new e(this.values.slice(r,a))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,a,u,l){for(var g=a;g<u;g++)if(r(this.values[g],l+g)===!1)return!1},e.prototype.forEachInvertedInner=function(r,a,u,l){for(var g=a-1;g>=u;g--)if(r(this.values[g],l+g)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=qf)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=qf)return new e(r.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Ai);Ai.empty=new nS([]);var qF=function(t){function e(n,i){t.call(this),this.left=n,this.right=i,this.length=n.length+i.length,this.depth=Math.max(n.depth,i.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,a,u){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(a,l),u)===!1||a>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,a)-l,u+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,a,u){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(a,l)-l,u+l)===!1||a<l&&this.left.forEachInvertedInner(i,Math.min(r,l),a,u)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var a=this.left.length;return r<=a?this.left.slice(i,r):i>=a?this.right.slice(i-a,r-a):this.left.slice(i,a).append(this.right.slice(0,r-a))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}(Ai);const WF=500;class Us{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,a;n&&(r=this.remapping(i,this.items.length),a=r.maps.length);let u=e.tr,l,g,_=[],k=[];return this.items.forEach((E,T)=>{if(!E.step){r||(r=this.remapping(i,T+1),a=r.maps.length),a--,k.push(E);return}if(r){k.push(new co(E.map));let I=E.step.map(r.slice(a)),z;I&&u.maybeStep(I).doc&&(z=u.mapping.maps[u.mapping.maps.length-1],_.push(new co(z,void 0,void 0,_.length+k.length))),a--,z&&r.appendMap(z,a)}else u.maybeStep(E.step);if(E.selection)return l=r?E.selection.map(r.slice(a)):E.selection,g=new Us(this.items.slice(0,i).append(k.reverse().concat(_)),this.eventCount-1),!1},this.items.length,0),{remaining:g,transform:u,selection:l}}addTransform(e,n,i,r){let a=[],u=this.eventCount,l=this.items,g=!r&&l.length?l.get(l.length-1):null;for(let k=0;k<e.steps.length;k++){let E=e.steps[k].invert(e.docs[k]),T=new co(e.mapping.maps[k],E,n),I;(I=g&&g.merge(T))&&(T=I,k?a.pop():l=l.slice(0,l.length-1)),a.push(T),n&&(u++,n=void 0),r||(g=T)}let _=u-i.depth;return _>ZF&&(l=GF(l,_),u-=_),new Us(l.append(a),u)}remapping(e,n){let i=new Pc;return this.items.forEach((r,a)=>{let u=r.mirrorOffset!=null&&a-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,u)},e,n),i}addMaps(e){return this.eventCount==0?this:new Us(this.items.append(e.map(n=>new co(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-n),a=e.mapping,u=e.steps.length,l=this.eventCount;this.items.forEach(T=>{T.selection&&l--},r);let g=n;this.items.forEach(T=>{let I=a.getMirror(--g);if(I==null)return;u=Math.min(u,I);let z=a.maps[I];if(T.step){let V=e.steps[I].invert(e.docs[I]),H=T.selection&&T.selection.map(a.slice(g+1,I));H&&l++,i.push(new co(z,V,H))}else i.push(new co(z))},r);let _=[];for(let T=n;T<u;T++)_.push(new co(a.maps[T]));let k=this.items.slice(0,r).append(_).append(i),E=new Us(k,l);return E.emptyItemCount()>WF&&(E=E.compress(this.items.length-i.length)),E}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),i=n.maps.length,r=[],a=0;return this.items.forEach((u,l)=>{if(l>=e)r.push(u),u.selection&&a++;else if(u.step){let g=u.step.map(n.slice(i)),_=g&&g.getMap();if(i--,_&&n.appendMap(_,i),g){let k=u.selection&&u.selection.map(n.slice(i));k&&a++;let E=new co(_.invert(),g,k),T,I=r.length-1;(T=r.length&&r[I].merge(E))?r[I]=T:r.push(E)}}else u.map&&i--},this.items.length,0),new Us(Ai.from(r.reverse()),a)}}Us.empty=new Us(Ai.empty,0);function GF(t,e){let n;return t.forEach((i,r)=>{if(i.selection&&e--==0)return n=r,!1}),t.slice(n)}class co{constructor(e,n,i,r){this.map=e,this.step=n,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new co(n.getMap().invert(),n,this.selection)}}}class Ta{constructor(e,n,i,r,a){this.done=e,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=a}}const ZF=20;function YF(t,e,n,i){let r=n.getMeta(Ll),a;if(r)return r.historyState;n.getMeta(JF)&&(t=new Ta(t.done,t.undone,null,0,-1));let u=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(u&&u.getMeta(Ll))return u.getMeta(Ll).redo?new Ta(t.done.addTransform(n,void 0,i,Wf(e)),t.undone,iS(n.mapping.maps),t.prevTime,t.prevComposition):new Ta(t.done,t.undone.addTransform(n,void 0,i,Wf(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(u&&u.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),g=t.prevTime==0||!u&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-i.newGroupDelay||!XF(n,t.prevRanges)),_=u?q0(t.prevRanges,n.mapping):iS(n.mapping.maps);return new Ta(t.done.addTransform(n,g?e.selection.getBookmark():void 0,i,Wf(e)),Us.empty,_,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Ta(t.done.rebased(n,a),t.undone.rebased(n,a),q0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ta(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),q0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function XF(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((i,r)=>{for(let a=0;a<e.length;a+=2)i<=e[a+1]&&r>=e[a]&&(n=!0)}),n}function iS(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((i,r,a,u)=>e.push(a,u));return e}function q0(t,e){if(!t)return null;let n=[];for(let i=0;i<t.length;i+=2){let r=e.map(t[i],1),a=e.map(t[i+1],-1);r<=a&&n.push(r,a)}return n}function KF(t,e,n){let i=Wf(e),r=Ll.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,i);if(!a)return null;let u=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),r,i),g=new Ta(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(u).setMeta(Ll,{redo:n,historyState:g})}let W0=!1,rS=null;function Wf(t){let e=t.plugins;if(rS!=e){W0=!1,rS=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){W0=!0;break}}return W0}const Ll=new Mr("history"),JF=new Mr("closeHistory");function QF(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fi({key:Ll,state:{init(){return new Ta(Us.empty,Us.empty,null,0,-1)},apply(e,n,i){return YF(n,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let i=n.inputType,r=i=="historyUndo"?oS:i=="historyRedo"?aS:null;return r?(n.preventDefault(),r(e.state,e.dispatch)):!1}}}})}function sS(t,e){return(n,i)=>{let r=Ll.getState(n);if(!r||(t?r.undone:r.done).eventCount==0)return!1;if(i){let a=KF(r,n,t);a&&i(e?a.scrollIntoView():a)}return!0}}const oS=sS(!1,!0),aS=sS(!0,!0),eV=ji.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>oS(t,e),redo:()=>({state:t,dispatch:e})=>aS(t,e)}},addProseMirrorPlugins(){return[QF(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),tV=xs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",di(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:i,$to:r}=n,a=t();return i.parentOffset===0?a.insertContentAt({from:Math.max(i.pos-1,0),to:r.pos},{type:this.name}):l2(n)?a.insertContentAt(r.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({tr:u,dispatch:l})=>{var g;if(l){const{$to:_}=u.selection,k=_.end();if(_.nodeAfter)_.nodeAfter.isTextblock?u.setSelection(Vt.create(u.doc,_.pos+1)):_.nodeAfter.isBlock?u.setSelection(zt.create(u.doc,_.pos)):u.setSelection(Vt.create(u.doc,_.pos));else{const E=(g=_.parent.type.contentMatch.defaultType)===null||g===void 0?void 0:g.create();E&&(u.insert(k,E),u.setSelection(Vt.create(u.doc,k+1)))}u.scrollIntoView()}return!0}).run()}}},addInputRules(){return[O5({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),nV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,iV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,rV=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,sV=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,oV=Lo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[qc({find:nV,type:this.type}),qc({find:rV,type:this.type})]},addPasteRules(){return[Wc({find:iV,type:this.type}),Wc({find:sV,type:this.type})]}}),lS=/^(\d+)\.\s$/,aV=xs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",di(this.options.HTMLAttributes,n),0]:["ol",di(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(U0.name,this.editor.getAttributes(Uf.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Nh({find:lS,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Nh({find:lS,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Uf.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),lV=xs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,uV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,hV=Lo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[qc({find:cV,type:this.type})]},addPasteRules(){return[Wc({find:uV,type:this.type})]}}),dV=xs.create({name:"text",group:"inline"}),pV=ji.create({name:"starterKit",addExtensions(){var t,e,n,i,r,a,u,l,g,_,k,E,T,I,z,V,H,Z;const ee=[];return this.options.bold!==!1&&ee.push(SF.configure((t=this.options)===null||t===void 0?void 0:t.bold)),this.options.blockquote!==!1&&ee.push(bF.configure((e=this.options)===null||e===void 0?void 0:e.blockquote)),this.options.bulletList!==!1&&ee.push(EF.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&ee.push(MF.configure((i=this.options)===null||i===void 0?void 0:i.code)),this.options.codeBlock!==!1&&ee.push(tS.configure((r=this.options)===null||r===void 0?void 0:r.codeBlock)),this.options.document!==!1&&ee.push(IF.configure((a=this.options)===null||a===void 0?void 0:a.document)),this.options.dropcursor!==!1&&ee.push(zF.configure((u=this.options)===null||u===void 0?void 0:u.dropcursor)),this.options.gapcursor!==!1&&ee.push(jF.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&ee.push(UF.configure((g=this.options)===null||g===void 0?void 0:g.hardBreak)),this.options.heading!==!1&&ee.push(HF.configure((_=this.options)===null||_===void 0?void 0:_.heading)),this.options.history!==!1&&ee.push(eV.configure((k=this.options)===null||k===void 0?void 0:k.history)),this.options.horizontalRule!==!1&&ee.push(tV.configure((E=this.options)===null||E===void 0?void 0:E.horizontalRule)),this.options.italic!==!1&&ee.push(oV.configure((T=this.options)===null||T===void 0?void 0:T.italic)),this.options.listItem!==!1&&ee.push(U0.configure((I=this.options)===null||I===void 0?void 0:I.listItem)),this.options.orderedList!==!1&&ee.push(aV.configure((z=this.options)===null||z===void 0?void 0:z.orderedList)),this.options.paragraph!==!1&&ee.push(lV.configure((V=this.options)===null||V===void 0?void 0:V.paragraph)),this.options.strike!==!1&&ee.push(hV.configure((H=this.options)===null||H===void 0?void 0:H.strike)),this.options.text!==!1&&ee.push(dV.configure((Z=this.options)===null||Z===void 0?void 0:Z.text)),ee}});function fV(t){var e;const{char:n,allowSpaces:i,allowedPrefixes:r,startOfLine:a,$position:u}=t,l=z5(n),g=new RegExp(`\\s${l}$`),_=a?"^":"",k=i?new RegExp(`${_}${l}.*?(?=\\s${l}|$)`,"gm"):new RegExp(`${_}(?:^)?${l}[^\\s${l}]*`,"gm"),E=((e=u.nodeBefore)===null||e===void 0?void 0:e.isText)&&u.nodeBefore.text;if(!E)return null;const T=u.pos-E.length,I=Array.from(E.matchAll(k)).pop();if(!I||I.input===void 0||I.index===void 0)return null;const z=I.input.slice(Math.max(0,I.index-1),I.index),V=new RegExp(`^[${r==null?void 0:r.join("")}\0]?$`).test(z);if(r!==null&&!V)return null;const H=T+I.index;let Z=H+I[0].length;return i&&g.test(E.slice(Z-1,Z+1))&&(I[0]+=" ",Z+=1),H<u.pos&&Z>=u.pos?{range:{from:H,to:Z},query:I[0].slice(n.length),text:I[0]}:null}const mV=new Mr("suggestion");function gV({pluginKey:t=mV,editor:e,char:n="@",allowSpaces:i=!1,allowedPrefixes:r=[" "],startOfLine:a=!1,decorationTag:u="span",decorationClass:l="suggestion",command:g=()=>null,items:_=()=>[],render:k=()=>({}),allow:E=()=>!0,findSuggestionMatch:T=fV}){let I;const z=k==null?void 0:k(),V=new Fi({key:t,view(){return{update:async(H,Z)=>{var ee,oe,J,Ae,ke,Me,Le;const Ie=(ee=this.key)===null||ee===void 0?void 0:ee.getState(Z),Ye=(oe=this.key)===null||oe===void 0?void 0:oe.getState(H.state),it=Ie.active&&Ye.active&&Ie.range.from!==Ye.range.from,Nt=!Ie.active&&Ye.active,ht=Ie.active&&!Ye.active,Rt=!Nt&&!ht&&Ie.query!==Ye.query,Xt=Nt||it&&Rt,nn=Rt||it,jt=ht||it&&Rt;if(!Xt&&!nn&&!jt)return;const Mt=jt&&!Xt?Ie:Ye,Sn=H.dom.querySelector(`[data-decoration-id="${Mt.decorationId}"]`);I={editor:e,range:Mt.range,query:Mt.query,text:Mt.text,items:[],command:hn=>g({editor:e,range:Mt.range,props:hn}),decorationNode:Sn,clientRect:Sn?()=>{var hn;const{decorationId:In}=(hn=this.key)===null||hn===void 0?void 0:hn.getState(e.state),bn=H.dom.querySelector(`[data-decoration-id="${In}"]`);return(bn==null?void 0:bn.getBoundingClientRect())||null}:null},Xt&&((J=z==null?void 0:z.onBeforeStart)===null||J===void 0||J.call(z,I)),nn&&((Ae=z==null?void 0:z.onBeforeUpdate)===null||Ae===void 0||Ae.call(z,I)),(nn||Xt)&&(I.items=await _({editor:e,query:Mt.query})),jt&&((ke=z==null?void 0:z.onExit)===null||ke===void 0||ke.call(z,I)),nn&&((Me=z==null?void 0:z.onUpdate)===null||Me===void 0||Me.call(z,I)),Xt&&((Le=z==null?void 0:z.onStart)===null||Le===void 0||Le.call(z,I))},destroy:()=>{var H;I&&((H=z==null?void 0:z.onExit)===null||H===void 0||H.call(z,I))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(H,Z,ee,oe){const{isEditable:J}=e,{composing:Ae}=e.view,{selection:ke}=H,{empty:Me,from:Le}=ke,Ie={...Z};if(Ie.composing=Ae,J&&(Me||e.view.composing)){(Le<Z.range.from||Le>Z.range.to)&&!Ae&&!Z.composing&&(Ie.active=!1);const Ye=T({char:n,allowSpaces:i,allowedPrefixes:r,startOfLine:a,$position:ke.$from}),it=`id_${Math.floor(Math.random()*4294967295)}`;Ye&&E({editor:e,state:oe,range:Ye.range,isActive:Z.active})?(Ie.active=!0,Ie.decorationId=Z.decorationId?Z.decorationId:it,Ie.range=Ye.range,Ie.query=Ye.query,Ie.text=Ye.text):Ie.active=!1}else Ie.active=!1;return Ie.active||(Ie.decorationId=null,Ie.range={from:0,to:0},Ie.query=null,Ie.text=null),Ie}},props:{handleKeyDown(H,Z){var ee;const{active:oe,range:J}=V.getState(H.state);return oe&&((ee=z==null?void 0:z.onKeyDown)===null||ee===void 0?void 0:ee.call(z,{view:H,event:Z,range:J}))||!1},decorations(H){const{active:Z,range:ee,decorationId:oe}=V.getState(H);return Z?hi.create(H.doc,[Gr.inline(ee.from,ee.to,{nodeName:u,class:l,"data-decoration-id":oe})]):null}}});return V}const yV=new Mr("mention"),_V=xs.create({name:"mention",addOptions(){return{HTMLAttributes:{},renderText({options:t,node:e}){var n;return`${t.suggestion.char}${(n=e.attrs.label)!==null&&n!==void 0?n:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){var n;return["span",di(this.HTMLAttributes,t.HTMLAttributes),`${t.suggestion.char}${(n=e.attrs.label)!==null&&n!==void 0?n:e.attrs.id}`]},suggestion:{char:"@",pluginKey:yV,command:({editor:t,range:e,props:n})=>{var i,r,a;const u=t.view.state.selection.$to.nodeAfter;((i=u==null?void 0:u.text)===null||i===void 0?void 0:i.startsWith(" "))&&(e.to+=1),t.chain().focus().insertContentAt(e,[{type:this.name,attrs:n},{type:"text",text:" "}]).run(),(a=(r=t.view.dom.ownerDocument.defaultView)===null||r===void 0?void 0:r.getSelection())===null||a===void 0||a.collapseToEnd()},allow:({state:t,range:e})=>{const n=t.doc.resolve(e.from),i=t.schema.nodes[this.name];return!!n.parent.type.contentMatch.matchType(i)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",di({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t})];const n={...this.options};n.HTMLAttributes=di({"data-type":this.name},this.options.HTMLAttributes,e);const i=this.options.renderHTML({options:n,node:t});return typeof i=="string"?["span",di({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},renderText({node:t}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:t})):this.options.renderText({options:this.options,node:t})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:i}=e,{empty:r,anchor:a}=i;return r?(e.doc.nodesBetween(a-1,a,(u,l)=>{if(u.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",l,l+u.nodeSize),!1}),n):!1})}},addProseMirrorPlugins(){return[gV({editor:this.editor,...this.options.suggestion})]}}),bV={props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function xV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBlockquote&&a.toggleBlockquote(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},[S.createElementVNode("path",{"fill-rule":"evenodd",d:"M6 6a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h3a3 3 0 0 1-3 3H5a1 1 0 1 0 0 2h1a5 5 0 0 0 5-5V8a2 2 0 0 0-2-2H6Zm9 0a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h3a3 3 0 0 1-3 3h-1a1 1 0 1 0 0 2h1a5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3Z"})],-1)]))}const vV=_t(bV,[["render",xV]]),wV={props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function kV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBulletList&&a.toggleBulletList(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",d:"M9 8h10M9 12h10M9 16h10M4.99 8H5m-.02 4h.01m0 4H5"})],-1)]))}const SV=_t(wV,[["render",kV]]),EV={props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function CV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleOrderedList&&a.toggleOrderedList(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6h8m-8 6h8m-8 6h8M4 16a2 2 0 1 1 3.321 1.5L4 20h5M4 5l2-1v6m-2 0h4"})],-1)]))}const TV=_t(EV,[["render",CV]]),MV={props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function AV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleCodeBlock&&a.toggleCodeBlock(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m8 8-4 4 4 4m8 0 4-4-4-4m-2-3-4 14"})],-1)]))}const PV=_t(MV,[["render",AV]]),IV={props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.chain().toggleBold().run()}}};function DV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBold&&a.toggleBold(...u)),class:"p-1.5 text-gray-500 rounded cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5h4.5a3.5 3.5 0 1 1 0 7H8m0-7v7m0-7H6m2 7h6.5a3.5 3.5 0 1 1 0 7H8m0-7v7m0 0H6"})],-1),S.createElementVNode("span",{class:"sr-only"},"Bold",-1)]))}const OV=_t(IV,[["render",DV]]),zV={props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function RV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleItalic&&a.toggleItalic(...u)),class:"p-1.5 text-gray-500 rounded cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m8.874 19 6.143-14M6 19h6.33m-.66-14H18"})],-1),S.createElementVNode("span",{class:"sr-only"},"Italic",-1)]))}const LV={bold:OV,italic:_t(zV,[["render",RV]]),bullet_list:SV,ordered_list:TV,blockquote:vV,codeblock:PV},NV={components:{EditorContent:yF},props:{controls:{type:Array,default:()=>["bold","italic","blockquote","bullet_list","ordered_list","codeblock"]},options:{type:Array,default:()=>[]},modelValue:{type:String,default:()=>""}},data(){return{editor:null}},computed:{controlsList(){return Object.entries(LV).filter(([t])=>this.controls.includes(t)).map(([t,e])=>e)}},watch:{modelValue(t){this.editor&&this.editor.getHTML()!==t&&this.editor.commands.setContent(t)},editor(t){t&&this.editor.on("update",({editor:e})=>{const n=e.getHTML();n!==this.modelValue&&this.$emit("update:modelValue",n)})}},mounted(){this.editor&&this.editor.destroy(),this.initEditor()},beforeDestroy(){this.editor&&this.editor.destroy()},methods:{initEditor(){this.editor=new gF({content:this.modelValue,extensions:[pV,tS,_V.configure({HTMLAttributes:{class:"mention"},suggestion:{items:({query:t})=>{const e=this.options.filter(n=>{var i,r;return(r=(i=n==null?void 0:n.email)==null?void 0:i.toLowerCase())==null?void 0:r.includes(t==null?void 0:t.toLowerCase())}).slice(0,5);return e.length?e:[{id:null,text:"Данні відсутні",email:null}]},render:()=>{let t,e;return{onStart:n=>{t=document.createElement("div"),t.className="mention-popup",n.items.forEach(a=>{const u=document.createElement("div");u.className="mention-option",a.id===null?(u.textContent=a.text,u.style.pointerEvents="none",u.style.color="#999"):(u.textContent=a.text,u.addEventListener("click",()=>{n.command({id:a.id,label:a.email})})),t.appendChild(u)}),document.body.appendChild(t);const{from:i}=n.range,r=n.editor.view.coordsAtPos(i);t.style.position="absolute",t.style.left=`${r.left}px`,t.style.top=`${r.top-t.offsetHeight}px`,e=t},onUpdate:n=>{for(;t.firstChild;)t.removeChild(t.firstChild);n.items.forEach(a=>{const u=document.createElement("div");u.className="mention-option",a.id===null?(u.textContent=a.text,u.style.pointerEvents="none",u.style.color="#999"):(u.textContent=a.text,u.addEventListener("click",()=>{n.command({id:a.id,label:a.email})})),t.appendChild(u)});const{from:i}=n.range,r=n.editor.view.coordsAtPos(i);t.style.left=`${r.left}px`,t.style.top=`${r.top-t.offsetHeight}px`},onExit:()=>{e&&e.remove()}}}}})]})}}},BV={class:"editor-container w-full border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-700 dark:border-gray-600"},FV={class:"editor-toolbar px-3 py-2 border-b dark:border-gray-600 flex items-center gap-2"},VV={class:"editor-content px-4 py-2 bg-white rounded-b-lg dark:bg-gray-800 relative"};function $V(t,e,n,i,r,a){const u=S.resolveComponent("EditorContent");return S.openBlock(),S.createElementBlock("div",BV,[S.createElementVNode("div",FV,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.controlsList,(l,g)=>(S.openBlock(),S.createBlock(S.resolveDynamicComponent(l),{key:g,editor:r.editor},null,8,["editor"]))),128))]),S.createElementVNode("div",VV,[S.createVNode(u,{editor:r.editor,class:"relative"},null,8,["editor"])])])}const cS=_t(NV,[["render",$V]]),jV=t=>{const e=/(\b\S)?/g,n=t.match(e);return n?n.join("").toUpperCase():""},UV={props:{name:{type:String,default(){return""}},avatar:{type:String,default(){return""}}},computed:{inItials(){return jV(this.name)}}},HV={class:"mr-2"},qV=["src"],WV={key:1,class:"flex flex-shrink-0 items-center justify-center w-6 h-6 bg-gray-500 text-xs text-white rounded-full"},GV={key:0},ZV={key:1,class:"text-sm"};function YV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",HV,[n.avatar?(S.openBlock(),S.createElementBlock("img",{key:0,src:n.avatar,alt:"avatar",class:"flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full"},null,8,qV)):n.name?(S.openBlock(),S.createElementBlock("div",WV,[a.inItials.length?(S.openBlock(),S.createElementBlock("span",GV,S.toDisplayString(a.inItials),1)):(S.openBlock(),S.createElementBlock("span",ZV,e[0]||(e[0]=[S.createElementVNode("i",{class:"ti ti-user"},null,-1)])))])):S.createCommentVNode("",!0)])}const XV={components:{VsWidgetCommentsAvatar:_t(UV,[["render",YV]]),VsTextEditor:cS},props:{comment:{type:Object,default:()=>({})},user:{type:Object,default:()=>({})},id:{type:String,default:""},options:Array},data(){return{commentContent:this.comment.body,isCommentActionVisible:!1,isOpen:!1,textareaValue:""}},computed:{isUserAutor(){return this.user.uid===this.comment.uid},createDate(){try{const t=at(this.comment.cdate,"YYYY-MM-DD");return new Date(t).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}},watch:{isOpen(t){t&&(this.textareaValue=this.comment.body)}},methods:{confirnDeleteComment(){document.body.click(),this.$emit("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей коментар?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:this.deleteComment,updateListOnConfirm:!0})},async updateComment(){try{await wt.post(`/api/widget/comment/${this.id}/${this.comment.communication_id}`,{body:this.textareaValue}),this.$emit("list-update"),this.isOpen=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}},async deleteComment(){try{await wt.delete(`/api/widget/comment/${this.id}/${this.comment.communication_id}`),this.$emit("list-update"),this.isCommentActionVisible=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}},toggleCommentAction(){this.isCommentActionVisible=!this.isCommentActionVisible}}},KV={class:"p-6 text-base bg-white dark:bg-gray-900"},JV={class:"flex justify-between items-center mb-2"},QV={class:"flex items-center"},e6={class:"inline-flex items-center mr-3 text-sm text-gray-900 dark:text-white font-semibold capitalize"},t6={class:"text-sm text-gray-600 dark:text-gray-400"},n6=["innerHTML"],i6={class:"flex items-center gap-[4px]"},r6={class:"flex flex-col gap-[8px] text-sm font-medium text-gray-500"},s6={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function o6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetCommentsAvatar"),l=S.resolveComponent("VsTextEditor"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",KV,[S.createElementVNode("div",JV,[S.createElementVNode("div",QV,[S.createElementVNode("p",e6,[S.createVNode(u,{name:n.comment.username,avatar:n.comment.avatar},null,8,["name","avatar"]),S.createTextVNode(S.toDisplayString(n.comment.username),1)]),S.createElementVNode("div",t6,S.toDisplayString(a.createDate),1)])]),S.createElementVNode("p",{class:"text-gray-500 dark:text-gray-400",innerHTML:n.comment.body},null,8,n6),S.createElementVNode("div",i6,[S.createElementVNode("button",{type:"button",class:"block py-2 dark:hover:bg-gray-600 hover:underline dark:hover:text-white text-start duration-300",onClick:e[0]||(e[0]=_=>r.isOpen=!0)}," Редагувати "),S.createElementVNode("button",{type:"button",class:"block py-2 dark:hover:bg-gray-600 hover:underline dark:hover:text-white text-start duration-300",onClick:e[1]||(e[1]=_=>a.confirnDeleteComment())}," Видалити ")])]),S.createVNode(g,{visible:r.isOpen,"onUpdate:visible":e[5]||(e[5]=_=>r.isOpen=_),title:"Редагувати",size:"small"},{footer:S.withCtx(()=>[S.createElementVNode("div",s6,[S.createElementVNode("button",{onClick:e[3]||(e[3]=_=>r.isOpen=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Відмінити "),S.createElementVNode("button",{onClick:e[4]||(e[4]=(..._)=>a.updateComment&&a.updateComment(..._)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:S.withCtx(()=>[S.createElementVNode("div",r6,[e[6]||(e[6]=S.createTextVNode(" Коментар ")),S.createVNode(l,{modelValue:r.textareaValue,"onUpdate:modelValue":e[2]||(e[2]=_=>r.textareaValue=_),options:n.options},null,8,["modelValue","options"])])]),_:1},8,["visible"])],64)}const a6={components:{VsWidgetCommentsItem:_t(XV,[["render",o6]])},inject:["activeAddFormEditor"],props:{id:{type:String,default:()=>""},prefilledData:{type:Object,default:null},options:Array},data(){return{isLoaded:!1,isLoadFailed:!1,comments:[],user:{},modal:{title:"",message:"",cancel:"",confirm:"",cancelButtonText:"",confirmButtonText:""},isModalVisible:!1}},async created(){await this.getComments()},methods:{async getComments(){if(this.prefilledData){this.comments=this.prefilledData.rows,this.isLoaded=!0;return}try{const{data:t}=await wt.get(`/api/widget/comment/${this.id}`);this.comments=t.rows,this.user=t.user}catch(t){this.isLoadFailed=!0,console.error(t)}this.isLoaded=!0,this.$emit("update-comment-count")},prepareModal(t){const e={...t};return t.cancel||(e.cancel=()=>{this.isModalVisible=!1}),t.updateListOnConfirm&&(e.confirm=async()=>{await t.confirm(),this.isModalVisible=!1}),e},handleOpenModal(t){this.modal=this.prepareModal(t),this.isModalVisible=!0}}},l6={class:"flex flex-col divide-y"},c6={key:0,class:"max-h-[300px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},u6={key:1},h6={class:"p-4"},d6={class:"mt-1 text-gray-500 dark:text-neutral-500"},p6={class:"mt-4 flex justify-end gap-x-3"};function f6(t,e,n,i,r,a){const u=S.resolveComponent("VsErrorOnLoading"),l=S.resolveComponent("VsWidgetCommentsItem"),g=S.resolveComponent("VsLoader"),_=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock("div",l6,[r.isLoaded?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[r.isLoadFailed?(S.openBlock(),S.createBlock(u,{key:0})):(S.openBlock(),S.createElementBlock(S.Fragment,{key:1},[r.comments.length?(S.openBlock(),S.createElementBlock("div",c6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(r.comments,(k,E)=>(S.openBlock(),S.createBlock(l,{key:E,comment:k,user:r.user,options:n.options,index:E,id:n.id,onListUpdate:a.getComments,class:"border-top",onOpenModal:e[0]||(e[0]=T=>a.handleOpenModal(T))},null,8,["comment","user","options","index","id","onListUpdate"]))),128))])):(S.openBlock(),S.createElementBlock("div",u6,e[4]||(e[4]=[S.createElementVNode("p",{class:"pl-3 text-sm font-medium text-gray-600"}," Коментарі відсутні ",-1)])))],64))],64)):(S.openBlock(),S.createBlock(g,{key:1,class:"justify-center",text:"Please wait..."})),S.createVNode(_,{title:r.modal.title,size:"small",visible:r.isModalVisible,"onUpdate:visible":e[3]||(e[3]=k=>r.isModalVisible=k)},{default:S.withCtx(()=>[S.createElementVNode("div",h6,[S.createElementVNode("p",d6,S.toDisplayString(r.modal.message),1),S.createElementVNode("div",p6,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[1]||(e[1]=(...k)=>r.modal.cancel&&r.modal.cancel(...k))},S.toDisplayString(r.modal.cancelButtonText),1),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[2]||(e[2]=(...k)=>r.modal.confirm&&r.modal.confirm(...k))},S.toDisplayString(r.modal.confirmButtonText),1)])])]),_:1},8,["title","visible"])])}const m6=_t(a6,[["render",f6]]),g6={components:{VsTextEditor:cS},props:{id:{type:String,default:()=>""},autofocus:{type:Boolean,default:()=>!0},options:Array},data(){return{isEditorOpen:!1,commentContent:""}},methods:{async addNewComment(){if(this.commentContent)try{await wt.post(`/api/widget/comment/${this.id}`,{body:this.commentContent}),this.commentContent="",this.$emit("list-update")}catch(t){console.error(t)}},setNewContent(t){this.commentContent=t}}},y6={class:"w-full widget-comment-form"},_6={class:"mb-4 bg-white border-gray-200 dark:bg-gray-800 dark:border-gray-700"},b6={class:"flex justify-end"};function x6(t,e,n,i,r,a){const u=S.resolveComponent("VsTextEditor");return S.openBlock(),S.createElementBlock("div",y6,[S.createElementVNode("div",_6,[S.createVNode(u,{modelValue:r.commentContent,"onUpdate:modelValue":e[0]||(e[0]=l=>r.commentContent=l),options:n.options},null,8,["modelValue","options"])]),S.createElementVNode("div",b6,[S.createElementVNode("button",{ref:"buttonAdd",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300",onClick:e[1]||(e[1]=(...l)=>a.addNewComment&&a.addNewComment(...l))}," Відправити коментар ",512)])])}const v6={components:{VsWidgetCommentsList:m6,VsWidgetCommentsAddForm:_t(g6,[["render",x6]])},props:{id:{type:String,default(){return""}},prefilledData:{type:Object,default:null}},data(){return{activeAddFormEditor:"",comments:[],totalComment:"0",options:[]}},mounted(){this.comments=this.$refs.commentListRef.comments,this.getUsersList()},watch:{comments(t){this.$emit("count-change",t.length)}},methods:{async getUsersList(){try{const{data:t}=await wt.get("/api/suggest/core.user_mentioned");this.options=t}catch(t){console.log(t)}},listUpdate(){this.$refs.commentListRef.getComments()},updateCommentCount(){this.totalComment=this.$refs.commentListRef.comments.length||"0"}}},w6={class:"bg-white-200"};function k6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetCommentsAddForm"),l=S.resolveComponent("VsWidgetCommentsList");return S.openBlock(),S.createElementBlock("div",w6,[e[2]||(e[2]=S.createElementVNode("div",{class:"flex justify-between items-center gap-x-2 mb-4"},null,-1)),S.createVNode(u,{options:r.options,class:"mb-6",id:n.id,onListUpdate:e[0]||(e[0]=g=>a.listUpdate())},null,8,["options","id"]),S.createVNode(l,{options:r.options,id:n.id,onUpdateCommentCount:e[1]||(e[1]=g=>a.updateCommentCount()),"prefilled-data":n.prefilledData,ref:"commentListRef"},null,8,["options","id","prefilled-data"])])}const S6=_t(v6,[["render",k6]]),uS=t=>new Date(t).toLocaleDateString("uk-UK",{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric"}),E6=t=>new Date(t).toLocaleDateString("uk-UK",{day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric"}),C6=t=>{const e=/(\b\S)?/g,n=t.match(e);return n?n.join("").toUpperCase():""},T6=S.defineComponent({props:{username:{type:String,default:()=>""}},computed:{inItials(){return C6(this.username)}}}),M6={class:"flex flex-shrink-0 items-center justify-center w-8 h-8 bg-gray-500 text-xs text-white rounded-full"};function A6(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",M6,S.toDisplayString(t.inItials),1)}const P6=_t(T6,[["render",A6]]),G0={load(){try{const t=Array.from(arguments);window.headLoadedFiles||(window.headLoadedFiles=[]);const e=typeof arguments[arguments.length-1]=="function"?arguments[arguments.length-1]:null,n=t.filter(i=>typeof i!="function").reduce((i,r)=>i.concat(r),[]).filter(i=>i&&!window.headLoadedFiles[i.url||i.split("?")[0]]);Promise.all(n.map(i=>this.loadFile1(i))).then(()=>{e&&e()})}catch(t){console.log(t)}},promise(t){return new Promise((e,n)=>{G0.load(t,()=>{e()})})},loadFile1(t){let e=!1;typeof t=="object"&&(e=t.type,t=t.url);const n=t.split("?")[0];return new Promise((i,r)=>{function a(l){delete window.headLoadedFiles[`_${n}`],window.headLoadedFiles[n]=l.type,i(l.type)}let u;window.headLoadedFiles[`_${n}`]?u=window.headLoadedFiles[`_${n}`]:(n.includes(".css")?(u=document.createElement("link"),u.href=t,u.type="text/css",u.rel="stylesheet"):(u=document.createElement("script"),u.type="text/javascript",u.src=t,e&&(u.type=e)),window.headLoadedFiles[`_${n}`]=u,document.head.appendChild(u)),u.addEventListener("load",a),u.addEventListener("error",a)})}},I6={props:{point:{type:String,default:()=>""}},data(){return{zoom:18}},computed:{parsedPoint(){return JSON.parse(this.point)},tooltipText(){return this.parsedPoint.coordinates.join(", ")},coordinates(){return[...this.parsedPoint.coordinates].reverse()}},async mounted(){typeof window>"u"||(window!=null&&window.L||(await G0.promise("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"),await G0.promise("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js")),this.initMap())},methods:{initMap(){const t=window.L.map("map",{center:this.coordinates,zoom:this.zoom});window.L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png").addTo(t),window.L.circle(this.coordinates,{color:"red",fillColor:"red",fillOpacity:.2,radius:10}).addTo(t).bindTooltip(this.tooltipText)}}},D6={id:"map",style:{height:"9rem",width:"24rem"}};function O6(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",D6)}const z6=_t(I6,[["render",O6]]),R6=S.defineComponent({components:{VsWidgetHistoryItemAvatar:P6,VsWidgetHistoryItemMap:z6},props:{item:{type:Object,default:()=>{}}},methods:{getTitle(t){return t.title||t.attr},getOldValue(t){return t.old||"Не вказано"},getNewValue(t){return t.new||"Не вказано"},getDate(t){return E6(t.cdate)}}}),L6={class:"relative [&_p]:m-0"},N6={class:"flex items-center gap-3"},B6={class:"w-full flex justify-between"},F6={class:"text-gray-500"},V6={class:"text-gray-800 font-medium"},$6={class:"text-gray-500 text-sm"},j6={class:"mt-2 pl-10"},U6={key:0},H6={key:1,class:"flex items-center gap-2 text-gray-700 text-sm"},q6={class:"font-medium"},W6={class:"font-medium"};function G6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetHistoryItemAvatar"),l=S.resolveComponent("VsWidgetHistoryItemMap");return S.openBlock(),S.createElementBlock("div",L6,[S.createElementVNode("div",N6,[S.createVNode(u,{username:t.item.username},null,8,["username"]),S.createElementVNode("div",B6,[S.createElementVNode("p",F6,[S.createElementVNode("span",V6,S.toDisplayString(t.item.username),1),e[0]||(e[0]=S.createTextVNode(" змінив данні: "))]),S.createElementVNode("p",$6,S.toDisplayString(t.getDate(t.item)),1)])]),S.createElementVNode("div",j6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(t.item.changes,(g,_)=>(S.openBlock(),S.createElementBlock("div",{key:_},[g.attr==="geom"?(S.openBlock(),S.createElementBlock("div",U6,[e[1]||(e[1]=S.createElementVNode("p",null,"Додана геометрія:",-1)),g.new?(S.openBlock(),S.createBlock(l,{key:0,point:g.new},null,8,["point"])):S.createCommentVNode("",!0)])):(S.openBlock(),S.createElementBlock("div",H6,[S.createElementVNode("p",null,S.toDisplayString(`- ${t.getTitle(g)}:`),1),S.createElementVNode("p",q6,S.toDisplayString(t.getOldValue(g)),1),e[2]||(e[2]=S.createElementVNode("i",{class:"ti ti-arrow-right"},null,-1)),S.createElementVNode("p",W6,S.toDisplayString(t.getNewValue(g)),1)]))]))),128))])])}const Z6=_t(R6,[["render",G6]]),Y6=S.defineComponent({components:{VsWidgetHistoryItem:Z6,VsEmptyWidget:Sy},props:{id:{type:String,default:""},prefilledData:{type:Object,default:null}},data:()=>({history:{}}),computed:{createdDate(){return this.history.data?uS(this.history.data.cdate):""},lastEditDate(){return this.history.data?uS(this.history.data.edate):""},authorName(){return this.history.data?this.history.data.author:""}},methods:{async getHistoryData(){if(this.prefilledData){this.history=this.prefilledData;return}try{const{data:t}=await wt.get(`/api/widget/history/${this.id}`);this.history=t}catch(t){console.error(t)}}},async mounted(){await this.getHistoryData()},watch:{"history.rows":function(t){this.$emit("count-change",t.length)}}}),X6={class:"bg-white"},K6={key:0,class:"space-y-6 list-none relative !px-0 sm:before:absolute sm:before:top-2 sm:before:bottom-0 sm:before:w-0.5 sm:before:left-4 before:bg-gray-200 max-h-[400px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},J6={key:1,class:"w-full h-[330px] flex items-center justify-center"};function Q6(t,e,n,i,r,a){var l;const u=S.resolveComponent("VsWidgetHistoryItem");return S.openBlock(),S.createElementBlock("div",X6,[e[0]||(e[0]=S.createElementVNode("div",{class:"flex justify-between items-center gap-x-2 mb-4"},null,-1)),(l=t.history.rows)!=null&&l.length?(S.openBlock(),S.createElementBlock("ul",K6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(t.history.rows,g=>(S.openBlock(),S.createElementBlock("li",{class:"list-none",key:g.uid},[S.createVNode(u,{item:g},null,8,["item"])]))),128))])):(S.openBlock(),S.createElementBlock("div",J6," Історія відсутні "))])}const e$={"vs-widget-map":Sz,"vs-widget-gallery":HR,"vs-widget-comments":S6,"vs-widget-file":CR,"vs-widget-history":_t(Y6,[["render",Q6]])},t$={},n$={style:{width:"calc(100vw - 300px)",height:"calc(100vh - 60px)"},class:"bg-gray-50 flex items-center justify-center"},i$={...e$,...t$,"vs-dashboard":{__name:"vs-dashboard",setup(t){return(e,n)=>(S.openBlock(),S.createElementBlock("div",n$,n[0]||(n[0]=[S.createElementVNode("div",{class:"p-5 md:p-8 bg-white border border-gray-200 shadow-sm rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"mb-4 xl:mb-8"},[S.createElementVNode("h1",{class:"text-lg font-semibold text-gray-800 dark:text-neutral-200"}," Members "),S.createElementVNode("p",{class:"text-sm text-gray-500 dark:text-neutral-500"}," Manage members and users of your workspace and set their access level. ")]),S.createElementVNode("div",{class:"space-y-5"},[S.createElementVNode("div",{class:"flex sm:grid sm:grid-cols-2 gap-x-2 sm:gap-x-5"},[S.createElementVNode("div",{class:"relative w-full"},[S.createElementVNode("div",{class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-20 ps-3.5"},[S.createElementVNode("svg",{class:"shrink-0 size-4 text-gray-500 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("circle",{cx:"11",cy:"11",r:"8"}),S.createElementVNode("path",{d:"m21 21-4.3-4.3"})])]),S.createElementVNode("input",{type:"text",class:"py-2 ps-10 pe-8 block w-full bg-gray-100 border-transparent rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Search by name or email"}),S.createElementVNode("div",{class:"hidden absolute inset-y-0 end-0 flex items-center pointer-events-none z-20 pe-1"},[S.createElementVNode("button",{type:"button",class:"inline-flex shrink-0 justify-center items-center size-6 rounded-full text-gray-500 hover:text-blue-600 focus:outline-none focus:text-blue-600 dark:text-neutral-500 dark:hover:text-blue-500 dark:focus:text-blue-500","aria-label":"Close"},[S.createElementVNode("span",{class:"sr-only"},"Close"),S.createElementVNode("svg",{class:"shrink-0 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),S.createElementVNode("path",{d:"m15 9-6 6"}),S.createElementVNode("path",{d:"m9 9 6 6"})])])])]),S.createElementVNode("div",{class:"flex justify-end items-center gap-x-2"},[S.createElementVNode("button",{type:"button",class:"p-2.5 sm:py-2 sm:px-3 inline-flex items-center text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createElementVNode("svg",{class:"shrink-0 sm:me-2 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),S.createElementVNode("polyline",{points:"7 10 12 15 17 10"}),S.createElementVNode("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]),S.createElementVNode("span",{class:"hidden sm:block"}," Download CSV ")]),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-1 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:ring-2 focus:ring-blue-500","data-hs-overlay":"#hs-pro-dshm"},[S.createElementVNode("span",{class:"hidden sm:block"},"Send"),S.createTextVNode("Invite ")])])]),S.createElementVNode("div",{class:"grid sm:grid-cols-2 lg:grid-cols-4 gap-2 xl:gap-4"},[S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("img",{class:"shrink-0 size-7 rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Avatar"})])]),S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Admin")]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 5 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1679412330254-90cb240038c5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1659482634023-2c4fda99ac0c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," O ")])]),S.createElementVNode("div",{class:"inline-flex items-center gap-x-2"},[S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Members"),S.createElementVNode("div",{class:"hs-tooltip inline-block"},[S.createElementVNode("svg",{class:"hs-tooltip-toggle shrink-0 size-3.5 text-gray-500 dark:text-neutral-500",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},[S.createElementVNode("path",{d:"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"}),S.createElementVNode("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"})]),S.createElementVNode("div",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 w-60 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded dark:bg-neutral-700",role:"tooltip","data-popper-placement":"top",style:{position:"fixed",inset:"auto auto 0px 0px",margin:"0px",transform:"translate(689px, -708px)"}}," Limited Access Members can only access the projects, tasks, and messages explicitly shared with them. ")])])]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 2 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," 0 ")])]),S.createElementVNode("div",{class:"inline-flex items-center gap-x-2"},[S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"}," Limited access members "),S.createElementVNode("div",{class:"hs-tooltip inline-block"},[S.createElementVNode("svg",{class:"hs-tooltip-toggle shrink-0 size-3.5 text-gray-500 dark:text-neutral-500",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},[S.createElementVNode("path",{d:"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"}),S.createElementVNode("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"})]),S.createElementVNode("div",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 w-60 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded dark:bg-neutral-700",role:"tooltip","data-popper-placement":"top",style:{position:"fixed",inset:"auto auto 0px 0px",margin:"0px",transform:"translate(1198px, -708px)"}}," Limited Access Members can only access the projects, tasks, and messages explicitly shared with them. ")])])]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 0 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"})]),S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Pending invites")])]),S.createElementVNode("div",{class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},[S.createElementVNode("div",{class:"min-w-full inline-block align-middle"},[S.createElementVNode("table",{class:"min-w-full divide-y divide-gray-200 dark:divide-neutral-700"},[S.createElementVNode("thead",null,[S.createElementVNode("tr",null,[S.createElementVNode("th",{scope:"col",class:"min-w-[250px]"},[S.createElementVNode("div",{class:"pe-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Member ")]),S.createElementVNode("th",{scope:"col",class:"min-w-48"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Role ")]),S.createElementVNode("th",{scope:"col"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Email ")]),S.createElementVNode("th",{scope:"col",class:"min-w-36"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Last activity ")]),S.createElementVNode("th",{scope:"col"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Status ")])])]),S.createElementVNode("tbody",{class:"divide-y divide-gray-200 dark:divide-neutral-700"},[S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," James Collins ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Admin ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," james@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Today ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-x-1.5 py-1.5 px-2.5 text-xs font-medium bg-teal-100 text-teal-800 rounded-full dark:bg-teal-500/10 dark:text-teal-500"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-200"}),S.createTextVNode(" Active ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-[38px] bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," James Collins ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can view ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," liza@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 2 days ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1601935111741-ae98b2b230b0?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Daniel Hobbs ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can edit ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," dhobbs@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Today ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1679412330254-90cb240038c5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Brian Warner ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can edit ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," brian@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 1 months ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-x-1.5 py-1.5 px-2.5 text-xs font-medium bg-teal-100 text-teal-800 rounded-full dark:bg-teal-500/10 dark:text-teal-500"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-200"}),S.createTextVNode(" Active ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-[38px] bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," O "),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Ols Shols ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can view ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," olsshols@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 6 days ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])])])])])])])],-1)])))}}},r$={install(t,{componentsApp:e={},menu:n=[]}){var a;wt.defaults.baseURL&&(wt.defaults.baseURL=wt.defaults.baseURL);const i=(a=D1(n))==null?void 0:a.filter(u=>u==null?void 0:u.component).map(u=>({...u,component:e[u==null?void 0:u.component]})),{router:r}=iA(i);Object.entries({...i$,...e}).forEach(([u,l])=>{t.component(u,l)}),t.component("admin",kT),t.config.globalProperties={...t.config.globalProperties,$componentsConfig:{...$O,componentsApp:e},$router:r},t.use(r)}},Xr=S.ref(null),s$={data(){return{formValues:{},scheme:null,table:""}},mounted(){this.getFormScheme()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getFormScheme(){var i,r;const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(a=>{var u,l;return(a==null?void 0:a.path)==((l=(u=this.$route)==null?void 0:u.query)==null?void 0:l.table)});e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n;try{const{data:{form:a}}=await wt.get(`/api/template/table/${n}`),{data:{rows:u}}=await wt.get(`/api/table-data/${this.table}/${(r=(i=this.$route)==null?void 0:i.query)==null?void 0:r.id}`);this.formValues=u==null?void 0:u[0];const{data:l}=await wt.get(`/api/template/form/${a}`);this.scheme=(l==null?void 0:l.schema)||l}catch{}},async editObject(){var t,e;try{await this.$refs.form.doValidation(),await wt.put(`/api/table/${this.table}/${(e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.id}`,this.formValues),await this.$router.back(),await this.$notify({title:"Успішно!",message:"Об'єкт успішно створено",type:"success"})}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},o$={style:{width:"calc(100vw - 260px)"}},a$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},l$={class:"flex items-center gap-[6px]"},c$={style:{height:"calc(100vh - 140px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex"},u$={class:"bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function h$(t,e,n,i,r,a){const u=S.resolveComponent("VsForm");return S.openBlock(),S.createElementBlock("div",o$,[S.createElementVNode("div",a$,[e[3]||(e[3]=S.createElementVNode("h2",{class:"text-xl font-medium"},"Редагувати",-1)),S.createElementVNode("div",l$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=l=>t.$router.back()),class:"py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"}," Скасувати "),S.createElementVNode("button",{onClick:e[1]||(e[1]=(...l)=>a.editObject&&a.editObject(...l)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"}," Зберегти ")])]),S.createElementVNode("div",c$,[S.createElementVNode("div",u$,[r.scheme?(S.openBlock(),S.createBlock(u,{key:0,ref:"form",scheme:r.scheme,modelValue:r.formValues,"onUpdate:modelValue":e[2]||(e[2]=l=>r.formValues=l),class:"p-0 mt-[20px]"},null,8,["scheme","modelValue"])):S.createCommentVNode("",!0)])])])}const d$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(s$,[["render",h$]])},Symbol.toStringTag,{value:"Module"})),p$={data(){return{formValues:{},scheme:null,table:""}},mounted(){this.getFormScheme()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getFormScheme(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(i=>{var r,a;return(i==null?void 0:i.path)==((a=(r=this.$route)==null?void 0:r.query)==null?void 0:a.table)});e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n;try{const{data:{form:i}}=await wt.get(`/api/template/table/${n}`),{data:r}=await wt.get(`/api/template/form/${i}`);this.scheme=(r==null?void 0:r.schema)||r}catch{}},async createObject(){try{await this.$refs.form.doValidation(),await wt.post(`/api/table/${this.table}`,this.formValues),await this.$router.back(),await this.$notify({title:"Успішно!",message:"Об'єкт успішно створено",type:"success"})}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},f$={style:{width:"calc(100vw - 260px)"}},m$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},g$={class:"flex items-center gap-[6px]"},y$={style:{height:"calc(100vh - 150px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex"},_$={class:"bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function b$(t,e,n,i,r,a){const u=S.resolveComponent("VsForm");return S.openBlock(),S.createElementBlock("div",f$,[S.createElementVNode("div",m$,[e[3]||(e[3]=S.createElementVNode("h2",{class:"text-xl font-medium"},"Створити",-1)),S.createElementVNode("div",g$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=l=>t.$router.back()),class:"py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"}," Скасувати "),S.createElementVNode("button",{onClick:e[1]||(e[1]=(...l)=>a.createObject&&a.createObject(...l)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"}," Зберегти ")])]),S.createElementVNode("div",y$,[S.createElementVNode("div",_$,[r.scheme?(S.openBlock(),S.createBlock(u,{key:0,ref:"form",scheme:r.scheme,modelValue:r.formValues,"onUpdate:modelValue":e[2]||(e[2]=l=>r.formValues=l),class:"p-0 mt-[20px]"},null,8,["scheme","modelValue"])):S.createCommentVNode("",!0)])])])}const x$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(p$,[["render",b$]])},Symbol.toStringTag,{value:"Module"})),v$={};function w$(t,e,n,i,r,a){const u=S.resolveComponent("router-view");return S.openBlock(),S.createBlock(u)}const hS=Object.freeze(Object.defineProperty({__proto__:null,default:_t(v$,[["render",w$]])},Symbol.toStringTag,{value:"Module"})),k$={data(){return{objectData:null,component:""}},computed:{getRoute(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(n=>{var i,r;return(n==null?void 0:n.table)==((r=(i=this.$route)==null?void 0:i.params)==null?void 0:r.table)});return e||this.$router.replace("/404"),e==null?void 0:e.path},getTitle(){var t,e,n,i,r,a,u,l,g,_,k,E,T,I,z;if((n=(e=(t=this.objectData)==null?void 0:t.rows)==null?void 0:e[0])!=null&&n.name)return((u=(a=(r=(i=this.objectData)==null?void 0:i.rows)==null?void 0:r[0])==null?void 0:a.name)==null?void 0:u.length)<35?(_=(g=(l=this.objectData)==null?void 0:l.rows)==null?void 0:g[0])==null?void 0:_.name:((I=(T=(E=(k=this.objectData)==null?void 0:k.rows)==null?void 0:E[0])==null?void 0:T.name)==null?void 0:I.slice(0,35))+" ...";{const V=(z=this.flattenMenu(Xr.value))==null?void 0:z.find(H=>{var Z,ee;return(H==null?void 0:H.table)===((ee=(Z=this.$route)==null?void 0:Z.params)==null?void 0:ee.table)});return V==null?void 0:V.ua}}},async mounted(){await this.getObjectData(),await this.checkActiveComponent()},watch:{component(t){this.$router.replace({...this.$route,query:{tab:t}})}},methods:{async getObjectData(){var n;const{table:t,id:e}=(n=this.$route)==null?void 0:n.params;(!t||!e)&&this.$router.replace("/404");try{const{data:i}=await wt.get(`/api/table-data/${t}/${e}`);this.objectData=i}catch(i){console.error(i)}},getColClass(t){return`col-span-${t||12}`},getGridClass(){return"grid-cols-12"},checkActiveComponent(){var t,e,n,i,r,a,u,l,g;if((e=(t=this.$route)==null?void 0:t.query)!=null&&e.tab)this.component=(i=(n=this.$route)==null?void 0:n.query)==null?void 0:i.tab;else{const _=(a=(r=this.objectData)==null?void 0:r.panels)==null?void 0:a.find(k=>(k==null?void 0:k.type)==="tabs");(u=_==null?void 0:_.items)!=null&&u.length&&(this.component=((l=_.items[0])==null?void 0:l.component)||((g=_.items[0])==null?void 0:g.name))}},flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e}}},S$={style:{width:"calc(100vw - 260px)",height:"calc(100vh - 60px)"},class:"bg-gray-50 overflow-y-auto"},E$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},C$={class:""},T$={class:"text-lg md:text-xl font-semibold text-stone-800 dark:text-neutral-200"},M$={class:"flex items-center gap-[6px]"},A$={key:0,class:"border rounded-xl bg-white"},P$={class:"p-[10px] pl-[20px] text-xl"},I$=["innerHTML"],D$={key:1},O$={class:"p-[10px] pl-[20px] text-xl"},z$={key:0,class:"p-[20px] border-t"},R$={key:1,class:"p-[20px] border-t"},L$=["innerHTML"],N$={class:"flex space-x-1 w-full bg-white border rounded-xl h-[60px] items-center pl-[20px]"},B$=["onClick"],F$={key:0,class:"border rounded-xl bg-white mt-[20px]"},V$={class:"p-[10px] pl-[20px] text-xl"},$$={key:0,class:"p-[20px] border-t"},j$={key:1,class:"p-[20px] border-t"},U$=["innerHTML"];function H$(t,e,n,i,r,a){var l,g,_;const u=S.resolveComponent("router-link");return S.openBlock(),S.createElementBlock("div",S$,[S.createElementVNode("div",E$,[S.createElementVNode("div",C$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=k=>t.$router.back()),class:"text-sm h-[20px] text-blue-600 font-medium hover:border-b hover:border-b-2 hover:border-b-blue-500"}," До таблиці "),S.createElementVNode("h2",T$,S.toDisplayString(a.getTitle),1)]),S.createElementVNode("div",M$,[S.createVNode(u,{to:`/edit?table=${a.getRoute}&id=${(g=(l=t.$route)==null?void 0:l.params)==null?void 0:g.id}`,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},{default:S.withCtx(()=>e[1]||(e[1]=[S.createTextVNode(" Редагувати ")])),_:1},8,["to"])])]),S.createElementVNode("div",{class:S.normalizeClass(["grid gap-[20px]",a.getGridClass()])},[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((_=r.objectData)==null?void 0:_.panels,(k,E)=>{var T;return S.openBlock(),S.createElementBlock("div",{key:E,class:S.normalizeClass([a.getColClass(k.col),"p-4"])},[k!=null&&k.name?(S.openBlock(),S.createElementBlock("div",A$,[S.createElementVNode("h2",P$,S.toDisplayString((k==null?void 0:k.title)||"Панель"),1),S.createElementVNode("div",{class:"p-[20px] border-t",innerHTML:(T=r.objectData)==null?void 0:T.data[k==null?void 0:k.name]},null,8,I$)])):k.type==="container"?(S.openBlock(),S.createElementBlock("div",D$,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k.items,(I,z)=>{var V,H,Z,ee,oe;return S.openBlock(),S.createElementBlock("div",{key:z,class:"border rounded-xl bg-white mb-[20px]"},[S.createElementVNode("h2",O$,S.toDisplayString((I==null?void 0:I.title)||"Панель"),1),I!=null&&I.component?(S.openBlock(),S.createElementBlock("div",z$,[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(I.component),{geometry:(H=(V=r.objectData)==null?void 0:V.rows[0])==null?void 0:H.geom,zoom:16,id:(ee=(Z=t.$route)==null?void 0:Z.params)==null?void 0:ee.id},null,8,["geometry","id"]))])):S.createCommentVNode("",!0),I!=null&&I.name?(S.openBlock(),S.createElementBlock("div",R$,[S.createElementVNode("div",{innerHTML:(oe=r.objectData)==null?void 0:oe.data[I==null?void 0:I.name]},null,8,L$)])):S.createCommentVNode("",!0)])}),128))])):S.createCommentVNode("",!0),(k==null?void 0:k.type)==="tabs"?(S.openBlock(),S.createElementBlock(S.Fragment,{key:2},[S.createElementVNode("nav",N$,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k==null?void 0:k.items,I=>(S.openBlock(),S.createElementBlock("button",{key:(I==null?void 0:I.name)||(I==null?void 0:I.component),onClick:z=>r.component=(I==null?void 0:I.component)||(I==null?void 0:I.name),class:S.normalizeClass(["px-2.5 h-[30px] py-1.5 relative inline-flex items-center gap-x-2 text-gray-500 hover:bg-gray-100 focus:bg-gray-100 hover:text-gray-800 text-sm whitespace-nowrap rounded-lg focus:outline-none",{" font-semibold after:absolute after:bottom-[-14px] after:left-2.5 after:right-2.5 after:z-10 after:h-0.5 after:bg-gray-800":r.component===(I==null?void 0:I.component)||r.component===(I==null?void 0:I.name),"":r.component!==(I==null?void 0:I.component)&&r.component!==(I==null?void 0:I.name)}])},S.toDisplayString(I==null?void 0:I.title),11,B$))),128))]),(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k.items,(I,z)=>{var V,H,Z,ee,oe;return S.openBlock(),S.createElementBlock(S.Fragment,{key:z},[r.component===(I==null?void 0:I.component)||r.component===(I==null?void 0:I.name)?(S.openBlock(),S.createElementBlock("div",F$,[S.createElementVNode("h2",V$,S.toDisplayString((I==null?void 0:I.title)||"Панель"),1),I!=null&&I.component?(S.openBlock(),S.createElementBlock("div",$$,[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(I.component),{geometry:(H=(V=r.objectData)==null?void 0:V.rows[0])==null?void 0:H.geom,zoom:16,id:(ee=(Z=t.$route)==null?void 0:Z.params)==null?void 0:ee.id},null,8,["geometry","id"]))])):S.createCommentVNode("",!0),I!=null&&I.name?(S.openBlock(),S.createElementBlock("div",j$,[S.createElementVNode("div",{innerHTML:(oe=r.objectData)==null?void 0:oe.data[I==null?void 0:I.name]},null,8,U$)])):S.createCommentVNode("",!0)])):S.createCommentVNode("",!0)],64)}),128))],64)):S.createCommentVNode("",!0)],2)}),128))],2)])}const q$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(k$,[["render",H$],["__scopeId","data-v-e7d9ada1"]])},Symbol.toStringTag,{value:"Module"})),W$={},G$={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-logout"};function Z$(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",G$,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"},null,-1),S.createElementVNode("path",{d:"M9 12h12l-3 -3"},null,-1),S.createElementVNode("path",{d:"M18 15l3 -3"},null,-1)]))}const Y$=_t(W$,[["render",Z$]]),X$={},K$={viewBox:"0 0 1823 249",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function J$(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",K$,e[0]||(e[0]=[S.createStaticVNode('<path d="M218.88 96.05C223.55 99.19 228.69 101.56 234.09 103.07V145.42C212.05 151.54 195.83 171.79 195.83 195.75C195.83 200.22 196.41 204.65 197.53 208.94L160.92 230.08C156.82 226.06 152.08 222.73 146.91 220.24V171.62C164.83 163.13 176.59 145.06 176.59 124.48C176.59 123.17 176.54 121.86 176.44 120.56L218.88 96.05ZM220.32 79.09L160.97 113.36C162.04 116.88 162.61 120.61 162.61 124.48C162.61 142.66 149.93 157.87 132.93 161.76V230.05C143.4 232.46 152.23 239.16 157.46 248.21L215 214.99C211.7 209.34 209.81 202.77 209.81 195.75C209.81 174.62 226.94 157.49 248.07 157.49V91.02C237.14 91.02 227.29 86.43 220.32 79.09Z" fill="#CE3936"></path><path d="M161.39 19.13L197.44 39.94C196.39 44.11 195.84 48.42 195.84 52.75C195.84 54.21 195.9 55.65 196.02 57.1L153.9 81.42C145.27 75.5 134.95 72.24 124.36 72.24C113.83 72.24 103.57 75.47 94.96 81.32L52.71 56.93C52.82 55.55 52.88 54.16 52.88 52.76C52.88 48.43 52.34 44.12 51.28 39.95L87.3 19.16C96.98 28.89 110.26 34.58 124.34 34.58C138.42 34.57 151.7 28.87 161.39 19.13ZM157.77 0.919983C151.24 12.66 138.71 20.6 124.33 20.6C109.95 20.6 97.44 12.67 90.9 0.939983L33.9 33.85C37.08 39.43 38.91 45.88 38.91 52.76C38.91 56.71 38.31 60.52 37.2 64.11L96.46 98.32C103.44 90.87 113.36 86.22 124.37 86.22C135.44 86.22 145.41 90.93 152.39 98.44L211.59 64.27C210.45 60.64 209.83 56.78 209.83 52.77C209.83 45.89 211.65 39.44 214.84 33.86L157.77 0.919983Z" fill="#CE3936"></path><path d="M29.97 95.95L72.28 120.38C72.17 121.74 72.12 123.1 72.12 124.47C72.12 145.02 83.86 163.08 101.74 171.58V220.23C96.58 222.71 91.84 226.04 87.75 230.05L51.17 208.93C52.29 204.64 52.87 200.21 52.87 195.74C52.87 171.78 36.65 151.53 14.61 145.41V103.06C20.07 101.55 25.27 99.14 29.97 95.95ZM28.5 78.97C21.52 86.38 11.63 91.02 0.640015 91.02V157.49C21.77 157.49 38.9 174.62 38.9 195.75C38.9 202.77 37 209.33 33.71 214.99L91.2 248.18C96.43 239.14 105.25 232.45 115.71 230.04V161.73C98.74 157.81 86.09 142.62 86.09 124.46C86.09 120.54 86.68 116.75 87.78 113.18L28.5 78.97Z" fill="#CE3936"></path><path d="M498.39 177.5V144.88C498.39 128.55 485.11 115.27 468.78 115.27H343.22C342.69 115.27 342.18 115.32 341.67 115.4H337.19C332.35 115.4 328.42 111.46 328.42 106.63V74C328.42 69.16 332.36 65.23 337.19 65.23H486.33C492.08 65.23 496.75 60.57 496.75 54.81C496.75 49.06 492.08 44.39 486.33 44.39H337.19C320.86 44.39 307.58 57.67 307.58 74V106.62C307.58 122.95 320.86 136.23 337.19 136.23H462.75C463.28 136.23 463.79 136.18 464.3 136.1H468.78C473.62 136.1 477.55 140.04 477.55 144.87V177.49C477.55 182.33 473.61 186.26 468.78 186.26H319.64C313.89 186.26 309.22 190.92 309.22 196.68C309.22 202.43 313.89 207.1 319.64 207.1H468.78C485.11 207.11 498.39 193.83 498.39 177.5Z" fill="#CE3935"></path><path d="M710.7 177.32V75.24C710.7 58.91 697.42 45.63 681.09 45.63H550.05C533.72 45.63 520.44 58.91 520.44 75.24V177.32C520.44 193.65 533.72 206.93 550.05 206.93H681.1C697.42 206.93 710.7 193.65 710.7 177.32ZM541.27 75.24C541.27 70.4 545.21 66.47 550.04 66.47H681.09C685.93 66.47 689.86 70.41 689.86 75.24V177.32C689.86 182.16 685.92 186.09 681.09 186.09H550.05C545.21 186.09 541.28 182.15 541.28 177.32V75.24H541.27Z" fill="#CE3935"></path><path d="M1823 177.32V75.24C1823 58.91 1809.72 45.63 1793.39 45.63H1662.34C1646.01 45.63 1632.73 58.91 1632.73 75.24V177.32C1632.73 193.65 1646.01 206.93 1662.34 206.93H1793.39C1809.72 206.93 1823 193.65 1823 177.32ZM1653.57 75.24C1653.57 70.4 1657.51 66.47 1662.34 66.47H1793.39C1798.23 66.47 1802.16 70.41 1802.16 75.24V177.32C1802.16 182.16 1798.22 186.09 1793.39 186.09H1662.34C1657.5 186.09 1653.57 182.15 1653.57 177.32V75.24Z" fill="#CE3935"></path><path d="M756.76 196.51V152H849.42C855.17 152 859.84 147.34 859.84 141.58C859.84 135.83 855.17 131.16 849.42 131.16H756.76V75.23C756.76 70.39 760.7 66.46 765.53 66.46H893.29C899.04 66.46 903.71 61.8 903.71 56.04C903.71 50.29 899.04 45.62 893.29 45.62H765.53C749.2 45.62 735.92 58.9 735.92 75.23V196.5C735.92 202.25 740.59 206.92 746.34 206.92C752.09 206.93 756.76 202.27 756.76 196.51Z" fill="#CE3935"></path><path d="M933.86 66.47H1006.51V194.32C1006.51 200.07 1011.18 204.74 1016.93 204.74C1022.68 204.74 1027.35 200.07 1027.35 194.32V66.47H1100C1105.75 66.47 1110.42 61.81 1110.42 56.05C1110.42 50.3 1105.76 45.63 1100 45.63H933.86C928.11 45.63 923.44 50.29 923.44 56.05C923.45 61.81 928.11 66.47 933.86 66.47Z" fill="#CE3935"></path><path d="M1218.44 204.19C1224.19 204.19 1228.86 199.53 1228.86 193.77V152H1368.13C1384.46 152 1397.74 138.72 1397.74 122.39V75.24C1397.74 58.91 1384.46 45.63 1368.13 45.63H1237.63C1221.3 45.63 1208.02 58.91 1208.02 75.24V193.77C1208.02 199.53 1212.68 204.19 1218.44 204.19ZM1237.63 66.47H1368.13C1372.97 66.47 1376.9 70.41 1376.9 75.24V122.39C1376.9 127.23 1372.96 131.16 1368.13 131.16H1228.86V75.23C1228.86 70.41 1232.79 66.47 1237.63 66.47Z" fill="#CE3935"></path><path d="M1430.64 204.19C1436.39 204.19 1441.06 199.53 1441.06 193.77V152H1523.95C1524.57 153.18 1525.42 154.26 1526.51 155.17L1581.89 201.23C1583.83 202.85 1586.2 203.64 1588.55 203.64C1591.54 203.64 1594.5 202.36 1596.57 199.88C1600.25 195.46 1599.64 188.89 1595.22 185.21L1555.29 152H1580.33C1596.66 152 1609.94 138.72 1609.94 122.39V75.24C1609.94 58.91 1596.66 45.63 1580.33 45.63H1449.83C1433.5 45.63 1420.22 58.91 1420.22 75.24V193.77C1420.22 199.53 1424.88 204.19 1430.64 204.19ZM1449.83 66.47H1580.33C1585.17 66.47 1589.1 70.41 1589.1 75.24V122.39C1589.1 127.23 1585.17 131.16 1580.33 131.16H1441.06V75.23C1441.05 70.41 1444.99 66.47 1449.83 66.47Z" fill="#CE3935"></path>',10)]))}const Q$=_t(X$,[["render",J$]]),e8={},t8={class:"shrink-0 size-4 text-gray-400 dark:text-white/60",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"};function n8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",t8,e[0]||(e[0]=[S.createElementVNode("circle",{cx:"11",cy:"11",r:"8"},null,-1),S.createElementVNode("path",{d:"m21 21-4.3-4.3"},null,-1)]))}const dS=_t(e8,[["render",n8]]),i8={},r8={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-chevron-down"};function s8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",r8,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M6 9l6 6l6 -6"},null,-1)]))}const o8={components:{IconChevronDown:_t(i8,[["render",s8]])},props:{route:Object},mounted(){var t,e,n;(t=this.route)!=null&&t.menu&&(n=(e=this.route)==null?void 0:e.menu)!=null&&n.some(i=>{var r,a;return(i==null?void 0:i.path)===this.$route.path.replace("/","")||((a=(r=this.$route)==null?void 0:r.params)==null?void 0:a.table)===(i==null?void 0:i.table)&&(i==null?void 0:i.table)})&&(this.isOpen=!0)},data(){return{isOpen:!1}}},a8={key:0,class:""},l8={class:"ml-[30px] py-[6px] before:block before:absolute relative w-[196px] flex flex-col gap-[6px] inline-block before:w-[2px] before:h-[100%] before:bg-gray-100 before:left-[-14px] cursor-pointer"},c8={key:1};function u8(t,e,n,i,r,a){var g,_,k,E,T,I,z,V,H,Z;const u=S.resolveComponent("IconChevronDown"),l=S.resolveComponent("router-link");return(g=n.route)!=null&&g.menu?(S.openBlock(),S.createElementBlock("div",a8,[S.createElementVNode("button",{onClick:e[0]||(e[0]=ee=>r.isOpen=!r.isOpen),class:S.normalizeClass(["flex cursor-pointer gap-x-3 py-2 px-3 text-sm text-gray-800 justify-start w-full border-none focus:outline-none text-gray-800 rounded-lg items-center hover:bg-gray-100 duration-300",[((k=(_=n.route)==null?void 0:_.menu)==null?void 0:k.some(ee=>{var oe,J;return(ee==null?void 0:ee.path)===t.$route.path.replace("/","")||(ee==null?void 0:ee.table)===((J=(oe=t.$route)==null?void 0:oe.params)==null?void 0:J.table)&&(ee==null?void 0:ee.table)}))&&"bg-gray-100"]])},[S.createTextVNode(S.toDisplayString((E=n.route)==null?void 0:E.ua)+" ",1),S.createVNode(u,{class:S.normalizeClass([[r.isOpen&&"-rotate-180"],"ml-auto duration-300"]),width:"14",height:"14"},null,8,["class"])],2),S.createVNode(S.Transition,{name:"fade"},{default:S.withCtx(()=>{var ee;return[S.withDirectives(S.createElementVNode("ul",l8,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((ee=n.route)==null?void 0:ee.menu,(oe,J)=>{var Ae,ke;return S.openBlock(),S.createElementBlock("li",{key:J,class:"w-full"},[S.createVNode(l,{to:"/"+(oe==null?void 0:oe.path),class:S.normalizeClass([[((oe==null?void 0:oe.path)===t.$route.path.replace("/","")||((ke=(Ae=t.$route)==null?void 0:Ae.params)==null?void 0:ke.table)===(oe==null?void 0:oe.table)&&(oe==null?void 0:oe.table))&&"bg-gray-100"],"flex gap-x-4 py-2 px-3 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100"])},{default:S.withCtx(()=>[S.createTextVNode(S.toDisplayString(oe==null?void 0:oe.ua),1)]),_:2},1032,["to","class"])])}),128))],512),[[S.vShow,r.isOpen]])]}),_:1})])):(S.openBlock(),S.createElementBlock("div",c8,[S.createVNode(l,{to:(T=n.route)==null?void 0:T.path,class:S.normalizeClass([[(((I=n.route)==null?void 0:I.path.replace("/",""))===t.$route.path.replace("/","")||((V=(z=t.$route)==null?void 0:z.params)==null?void 0:V.table)===((H=n.route)==null?void 0:H.table)&&((Z=n.route)==null?void 0:Z.table))&&"bg-gray-100"],"flex gap-x-3 py-2 w-full font-[400] px-3 text-sm text-gray-800 rounded-lg items-center hover:bg-gray-100 duration-300 hover:text-gray-800"])},{default:S.withCtx(()=>{var ee;return[S.createTextVNode(S.toDisplayString((ee=n.route)==null?void 0:ee.ua),1)]}),_:1},8,["to","class"])]))}const h8={components:{IconLogout:Y$,NavbarItem:_t(o8,[["render",u8]]),IconLogo:Q$,IconSearch:dS},data(){return{activeIndex:null,data:null,searchValue:""}},computed:{data(){var t,e;return(t=this.searchValue)!=null&&t.trim()?(e=this.flattenMenu(Xr.value))==null?void 0:e.filter(n=>{var i,r,a;return(a=(i=n==null?void 0:n.ua)==null?void 0:i.toLowerCase())==null?void 0:a.includes((r=this.searchValue)==null?void 0:r.toLowerCase())}):Xr.value}},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e}}},d8={class:"flex flex-col h-[100vh] border-r w-[260px] shrink-0"},p8={class:"relative"},f8={class:"p-[16px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},m8={class:"pb-3 w-full flex flex-col flex-wrap"},g8={key:0,class:"flex flex-col gap-[6px]"},y8={key:1,class:"text-gray-800 text-lg mt-[20px]"};function _8(t,e,n,i,r,a){var k;const u=S.resolveComponent("IconLogo"),l=S.resolveComponent("IconSearch"),g=S.resolveComponent("VsText"),_=S.resolveComponent("NavbarItem");return S.openBlock(),S.createElementBlock("div",d8,[S.createVNode(u,{height:"40",width:"200",class:"my-[20px] ml-[20px]"}),S.createElementVNode("div",p8,[S.createVNode(l,{height:"16",width:"16",class:"absolute top-[12px] left-[30px] text-gray-500 z-[1]"}),S.createVNode(g,{type:"text",modelValue:r.searchValue,"onUpdate:modelValue":e[0]||(e[0]=E=>r.searchValue=E),clearable:!0,placeholder:"Пошук по меню",class:"[&>input]:h-[40px] [&>input]:block [&>input]:rounded-none [&>input]:border-x-0 [&>input]:pl-[60px] [&>input:focus]:outline-none [&>input:focus]:focus:ring-0 [&>input:focus]:border-y-gray-200 [&>input:focus]:border-y-1 [&>input:focus]:border-x-0"},null,8,["modelValue"])]),S.createElementVNode("div",f8,[S.createElementVNode("nav",m8,[(k=a.data)!=null&&k.length?(S.openBlock(),S.createElementBlock("ul",g8,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.data,(E,T)=>(S.openBlock(),S.createElementBlock("li",{key:T,class:"flex flex-col gap-[6px]"},[S.createVNode(_,{route:E},null,8,["route"])]))),128))])):(S.openBlock(),S.createElementBlock("div",y8,"Не знайдено"))])])])}const b8=_t(h8,[["render",_8]]),x8={},v8={class:"flex-shrink-0 size-4",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"};function w8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",v8,e[0]||(e[0]=[S.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),S.createElementVNode("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"},null,-1),S.createElementVNode("path",{d:"M12 17h.01"},null,-1)]))}const k8=_t(x8,[["render",w8]]),S8={},E8={class:"flex-shrink-0 size-4",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"};function C8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",E8,e[0]||(e[0]=[S.createElementVNode("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"},null,-1),S.createElementVNode("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"},null,-1)]))}const T8={components:{IconQuestion:k8,IconMessage:_t(S8,[["render",C8]])}},M8={class:"h-[60px] border-b flex justify-end px-[20px]",style:{width:"calc(100vw - 260px)"}},A8={class:"flex items-center gap-[6px]"},P8={href:"docs-softpro.com",class:"size-[38px] inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-100 dark:text-neutral-400 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},I8={class:"hs-tooltip [--placement:bottom] inline-block show"},D8={class:"hs-tooltip-toggle relative size-[38px] inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-100"};function O8(t,e,n,i,r,a){const u=S.resolveComponent("IconQuestion"),l=S.resolveComponent("IconMessage");return S.openBlock(),S.createElementBlock("div",M8,[S.createElementVNode("div",A8,[S.createElementVNode("a",P8,[S.createVNode(u,{height:"24",width:"24"})]),S.createElementVNode("div",I8,[S.createElementVNode("button",D8,[S.createVNode(l,{height:"24",width:"24"}),e[0]||(e[0]=S.createElementVNode("span",{class:"flex absolute top-0 end-0 -mt-1.5 -me-1.5"},[S.createElementVNode("span",{class:"animate-ping absolute inline-flex size-full rounded-full bg-red-400 opacity-75 dark:bg-red-600"}),S.createElementVNode("span",{class:"relative min-w-[18px] min-h-[18px] inline-flex justify-center items-center text-[10px] bg-red-500 text-white rounded-full px-1"}," 1 ")],-1))]),e[1]||(e[1]=S.createElementVNode("span",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded-lg dark:bg-neutral-700 hidden",role:"tooltip","data-popper-placement":"bottom",style:{position:"fixed",inset:"0px auto auto 0px",margin:"0px",transform:"translate(1686px, 53px)"}},null,-1))]),e[2]||(e[2]=S.createElementVNode("div",{class:"h-[30px] w-[1px] bg-gray-200 ml-[10px] mr-[10px]"},null,-1)),e[3]||(e[3]=S.createElementVNode("img",{class:"flex-shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Image Description"},null,-1))])])}const z8={components:{navbar:b8,AdminHeader:_t(T8,[["render",O8]])},mounted(){this.getMenu()},computed:{isMenu(){return Xr.value}},methods:{async getMenu(){try{const{data:t}=await wt.get("/api/user-menu");Xr.value=t}catch{}}}},R8={class:"admin-wrapper"},L8={class:"flex flex-col"};function N8(t,e,n,i,r,a){const u=S.resolveComponent("navbar"),l=S.resolveComponent("admin-header"),g=S.resolveComponent("router-view");return S.openBlock(),S.createElementBlock("div",R8,[S.createVNode(u),S.createElementVNode("div",L8,[a.isMenu?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[S.createVNode(l),S.createVNode(g)],64)):S.createCommentVNode("",!0)])])}const B8=Object.freeze(Object.defineProperty({__proto__:null,default:_t(z8,[["render",N8],["__scopeId","data-v-3d7ecdff"]])},Symbol.toStringTag,{value:"Module"})),F8={},V8={class:"h21yx vs0hq",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function $8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",V8,e[0]||(e[0]=[S.createStaticVNode('<line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line>',9)]))}const j8=_t(F8,[["render",$8]]),U8={data(){return{currentSort:""}},props:{data:{type:Object,default:()=>null},activeColumn:{type:String}},computed:{label(){var t,e;return((t=this.data)==null?void 0:t.ua)||((e=this.data)==null?void 0:e.label)||this.data.title||"null"},selectedSortParam(){var t,e;return(e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.sort},getVisibleIcon(){return this.data.format!=="image"&&this.data.format!=="verify"}},watch:{activeColumn(t){t!==this.data.name&&(this.currentSort="")}},methods:{changeCurrentSort(t){switch(t){case"":return"asc";case"asc":return"desc";case"desc":return"";default:return""}},handleClickSortBtn(t){this.$emit("change-active",this.data.name),this.currentSort=this.changeCurrentSort(t);const e=this.$route.query,{sort:n,...i}=e,r=this.currentSort?`${this.data.name}-${this.currentSort}`:"";this.$router.replace({query:{...i,...r&&{sort:r}}})},isValueEqualToSelected(t){return`${this.data.name}-${t}`===this.selectedSortParam}}},H8={scope:"col",class:"text-start"},q8={class:"flex-shrink-0 size-3.5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},W8={key:0,d:"m7 15 5 5 5-5"},G8={key:1,d:"m7 9 5-5 5 5"},Z8={key:1,class:"text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500"};function Y8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("th",H8,[a.getVisibleIcon?(S.openBlock(),S.createElementBlock("button",{key:0,type:"button",class:"text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500 flex items-center gap-[6px]",onClick:e[0]||(e[0]=u=>a.handleClickSortBtn(r.currentSort))},[S.createTextVNode(S.toDisplayString(a.label)+" ",1),(S.openBlock(),S.createElementBlock("svg",q8,[r.currentSort==="asc"||r.currentSort===""?(S.openBlock(),S.createElementBlock("path",W8)):S.createCommentVNode("",!0),r.currentSort==="desc"||r.currentSort===""?(S.openBlock(),S.createElementBlock("path",G8)):S.createCommentVNode("",!0)]))])):(S.openBlock(),S.createElementBlock("p",Z8,S.toDisplayString(a.label),1))])}const X8=_t(U8,[["render",Y8]]),K8={},J8={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-dots-vertical"};function Q8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",J8,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),S.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),S.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)]))}const ej=_t(K8,[["render",Q8]]),tj={},nj={class:"flex-shrink-0 size-3.5",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"};function ij(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",nj,e[0]||(e[0]=[S.createStaticVNode('<path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" x2="10" y1="11" y2="17"></line><line x1="14" x2="14" y1="11" y2="17"></line>',5)]))}const rj=_t(tj,[["render",ij]]),sj={props:{height:{type:String,default:"16"},width:{type:String,default:"12"},color:{type:String,default:"black"}}},oj={style:{display:"none"}},aj=["height","width","fill"];function lj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock(S.Fragment,null,[(S.openBlock(),S.createElementBlock("svg",oj,e[0]||(e[0]=[S.createElementVNode("symbol",{id:"icon-pencil",viewBox:"0 0 32 32"},[S.createElementVNode("path",{d:"M27 0c2.761 0 5 2.239 5 5 0 1.126-0.372 2.164-1 3l-2 2-7-7 2-2c0.836-0.628 1.874-1 3-1zM2 23l-2 9 9-2 18.5-18.5-7-7-18.5 18.5zM22.362 11.362l-14 14-1.724-1.724 14-14 1.724 1.724z"})],-1)]))),(S.openBlock(),S.createElementBlock("svg",{height:n.height,width:n.width,fill:n.color},e[1]||(e[1]=[S.createElementVNode("use",{"xlink:href":"#icon-pencil"},null,-1)]),8,aj))],64)}const cj={components:{IconMore:ej,IconDelete:rj,IconEdit:_t(sj,[["render",lj]])},emits:["updateTable"],props:{item:Object,table:String,isForm:null},data(){return{formVisible:!1,isDeleteConfirm:!1,formValue:{},top:0,left:0}},methods:{openConfirm(){this.isDeleteConfirm=!0,document.querySelector("body").click()},async getData(){var t;try{const{data:e}=await wt.get(`/api/table/${this.table}/${(t=this.item)==null?void 0:t.id}`);this.formValue=e}catch(e){console.error(e)}},doSomethingOnCancel(){this.formVisible=!1},async deleteElement(){var t;try{wt.delete(`/api/table/${this.table}/${(t=this.item)==null?void 0:t.id}`),this.$notify({title:"Успішно!",message:"Об`єкт успішно видалeно",type:"success"}),await this.$emit("update-table"),this.isDeleteConfirm=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},uj={class:"hs-dropdown [--placement:bottom-right] inline-flex"},hj={class:"gap-x-2 p-[4px] rounded-lg shadow-sm hover:border-transparent border focus:outline-none text-black hover:bg-gray-50"},dj={class:"flex flex-col items-start"},pj={key:1,class:"h-[1px] w-[80%] bg-gray-200 ml-auto mr-auto"},fj={class:"p-4"},mj={class:"mt-4 flex justify-end gap-x-3"};function gj(t,e,n,i,r,a){const u=S.resolveComponent("IconMore"),l=S.resolveComponent("IconEdit"),g=S.resolveComponent("router-link"),_=S.resolveComponent("IconDelete"),k=S.resolveComponent("VsPopover"),E=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",uj,[S.createVNode(k,{trigger:"click",placement:"bottom-left"},{reference:S.withCtx(()=>[S.createElementVNode("button",hj,[S.createVNode(u,{height:"16",width:"16"})])]),default:S.withCtx(()=>{var T,I,z;return[S.createElementVNode("div",dj,[n.isForm?(S.openBlock(),S.createBlock(g,{key:0,to:`/edit?table=${(I=(T=t.$route)==null?void 0:T.params)==null?void 0:I.catchAll}&id=${(z=n.item)==null?void 0:z.id}`,class:"w-full flex items-center gap-x-3 py-1.5 px-2 rounded-lg text-[13px] text-stone-800 hover:bg-stone-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-stone-100"},{default:S.withCtx(()=>[S.createVNode(l,{color:"#000"}),e[4]||(e[4]=S.createTextVNode(" Редагувати "))]),_:1},8,["to"])):S.createCommentVNode("",!0),n.isForm?(S.openBlock(),S.createElementBlock("div",pj)):S.createCommentVNode("",!0),S.createElementVNode("button",{onClick:e[0]||(e[0]=S.withModifiers((...V)=>a.openConfirm&&a.openConfirm(...V),["stop"])),class:"w-full flex items-center gap-x-3 py-1.5 px-2 rounded-lg text-[13px] text-stone-800 hover:bg-stone-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-stone-100"},[S.createVNode(_),e[5]||(e[5]=S.createElementVNode("span",{class:"text-gray-800"},"Видалити",-1))])])]}),_:1})]),S.createVNode(E,{visible:r.isDeleteConfirm,"onUpdate:visible":e[3]||(e[3]=T=>r.isDeleteConfirm=T),title:"Ви впевнені?"},{default:S.withCtx(()=>[S.createElementVNode("div",fj,[e[6]||(e[6]=S.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей об'єкт? ",-1)),S.createElementVNode("div",mj,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[1]||(e[1]=T=>r.isDeleteConfirm=!1)}," Скасувати "),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[2]||(e[2]=(...T)=>a.deleteElement&&a.deleteElement(...T))}," Так, я впевнена/ий ")])])]),_:1},8,["visible"])],64)}const yj=_t(cj,[["render",gj]]),_j={},bj={class:"flex-shrink-0 mt-0.5 size-3.5",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"};function xj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",bj,e[0]||(e[0]=[S.createElementVNode("path",{d:"m3 16 4 4 4-4"},null,-1),S.createElementVNode("path",{d:"M7 20V4"},null,-1),S.createElementVNode("path",{d:"m21 8-4-4-4 4"},null,-1),S.createElementVNode("path",{d:"M17 4v16"},null,-1)]))}const vj={components:{IconExport:_t(_j,[["render",xj]])},props:{table:String,columns:Array},data(){return{isOpen:!1,tableFormats:["json","csv","xlsx"],format:"",cols:[]}},methods:{async exportTable(){try{const t=await wt.get("/api/export",{params:{table:this.table,format:this.format,cols:this.cols.join(",")},responseType:"blob"}),e=new Blob([t.data],{type:"application/octet-stream"}),n=window.URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.setAttribute("download",`${this.table.split(".")[0]}.${this.format}`),document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n),this.$notify({type:"success",title:"Експорт",message:"Файл успішно експортовано!"})}catch(t){console.error("Ошибка при экспорте файла:",t),this.$notify({type:"error",title:"Помилка",message:"Не вдалося експортувати файл."})}},selectFormat(t){this.format=t}}},wj={class:"p-4"},kj={class:"pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700"},Sj={class:"mt-2 flex row flex-wrap gap-y-[5px] gap-x-[10px]"},Ej={class:"pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700"},Cj={class:"mt-2 space-y-2"},Tj=["id","onChange"],Mj=["for"],Aj={class:"flex w-full justify-end p-[20px] gap-[6px] border-t"};function Pj(t,e,n,i,r,a){const u=S.resolveComponent("IconExport"),l=S.resolveComponent("VsCheckbox"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("button",{onClick:e[0]||(e[0]=_=>r.isOpen=!0),class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createVNode(u,{height:"16",width:"16"}),e[4]||(e[4]=S.createTextVNode(" Експорт ")),e[5]||(e[5]=S.createElementVNode("svg",{class:"shrink-0 size-3.5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),S.createVNode(g,{visible:r.isOpen,"onUpdate:visible":e[3]||(e[3]=_=>r.isOpen=_),title:"Експорт таблиці",size:"small"},{footer:S.withCtx(()=>[S.createElementVNode("div",Aj,[e[8]||(e[8]=S.createElementVNode("button",{type:"button",class:"py-2 px-3 text-nowrap inline-flex justify-center items-center text-start bg-white border border-gray-200 text-gray-800 text-sm font-medium rounded-lg shadow-sm align-middle hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700","data-hs-overlay":"#hs-pro-decm"}," Скасувати ",-1)),S.createElementVNode("button",{type:"button",class:"py-2 px-3 text-nowrap inline-flex justify-center items-center gap-x-2 text-start bg-blue-600 border border-blue-600 text-white text-sm font-medium rounded-lg shadow-sm align-middle hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:ring-1 focus:ring-blue-300 dark:focus:ring-blue-500",onClick:e[2]||(e[2]=(..._)=>a.exportTable&&a.exportTable(..._))}," Завантажити таблицю ")])]),default:S.withCtx(()=>[e[9]||(e[9]=S.createElementVNode("div",{class:"dark:border-neutral-700"},null,-1)),S.createElementVNode("div",wj,[S.createElementVNode("div",kj,[e[6]||(e[6]=S.createElementVNode("h2",{class:"text-sm text-gray-500"}," Виберіть стовпці таблиці для експорту: ",-1)),S.createElementVNode("div",Sj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(n.columns,(_,k)=>(S.openBlock(),S.createElementBlock("div",{class:"flex items-center",key:k,style:{width:"calc((100% - 10px) / 2)"}},[S.createVNode(l,{class:"[&>label]:text-sm [&>label]:text-gray-800 [&>label]:ms-3 !gap-x-[1px] !p-0",modelValue:r.cols,"onUpdate:modelValue":e[1]||(e[1]=E=>r.cols=E),value:_==null?void 0:_.name,label:_==null?void 0:_.ua},null,8,["modelValue","value","label"])]))),128))])]),S.createElementVNode("div",Ej,[e[7]||(e[7]=S.createElementVNode("h2",{class:"text-sm text-gray-500"},"Виберіть формат таблиці:",-1)),S.createElementVNode("div",Cj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(r.tableFormats,(_,k)=>(S.openBlock(),S.createElementBlock("div",{class:"flex items-center",key:k},[S.createElementVNode("input",{type:"radio",name:"hs-pro-duecmfm",class:"shrink-0 border-gray-300 rounded-full text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-500 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800",id:_,onChange:E=>a.selectFormat(_)},null,40,Tj),S.createElementVNode("label",{for:_,class:"text-sm text-gray-800 ms-3 dark:text-neutral-400"}," Формат "+S.toDisplayString(_),9,Mj)]))),128))])])])]),_:1},8,["visible"])],64)}const Ij=_t(vj,[["render",Pj]]),Dj={},Oj={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-columns"};function zj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",Oj,e[0]||(e[0]=[S.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M4 6l5.5 0"></path><path d="M4 10l5.5 0"></path><path d="M4 14l5.5 0"></path><path d="M4 18l5.5 0"></path><path d="M14.5 6l5.5 0"></path><path d="M14.5 10l5.5 0"></path><path d="M14.5 14l5.5 0"></path><path d="M14.5 18l5.5 0"></path>',9)]))}const Rj=_t(Dj,[["render",zj]]),Lj={props:{column:Object},emits:["update-column"],data(){return{value:!1}},watch:{value(t){this.$emit("update-column",{...this.column,hidden:!t})}},mounted(){var t;((t=this.column)==null?void 0:t.hidden)!==!0&&(this.value=!0)}},Nj={class:"flex w-full gap-[8px] items-centr"};function Bj(t,e,n,i,r,a){var u,l;return S.openBlock(),S.createElementBlock("label",Nj,[S.withDirectives(S.createElementVNode("input",{"onUpdate:modelValue":e[0]||(e[0]=g=>r.value=g),type:"checkbox"},null,512),[[S.vModelCheckbox,r.value]]),S.createTextVNode(" "+S.toDisplayString(((u=n.column)==null?void 0:u.ua)||((l=n.column)==null?void 0:l.title)),1)])}const Fj={components:{IconColumns:Rj,AdminTableColumnsHiddenItem:_t(Lj,[["render",Bj]])},emits:["update-columns"],props:{columns:Array},methods:{updateColumn(t){const e=this.columns.findIndex(i=>(i==null?void 0:i.name)===(t==null?void 0:t.name)),n=this.columns;n[e]=t,this.$emit("update-columns",[...n])}}},Vj={class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},$j={class:"py-[10px] px-[10px] w-[260px]"},jj={class:"flex flex-col gap-[3px] max-h-[400px] w-full overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function Uj(t,e,n,i,r,a){const u=S.resolveComponent("IconColumns"),l=S.resolveComponent("AdminTableColumnsHiddenItem"),g=S.resolveComponent("VsPopover");return S.openBlock(),S.createBlock(g,{trigger:"click",placement:"bottom"},{reference:S.withCtx(()=>[S.createElementVNode("button",Vj,[S.createVNode(u,{height:"20",width:"16"})])]),default:S.withCtx(()=>[S.createElementVNode("div",$j,[e[0]||(e[0]=S.createElementVNode("h2",{class:"text-sm mb-[8px]"},"Оберіть колонки, щоб приховати",-1)),S.createElementVNode("ul",jj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(n.columns,(_,k)=>(S.openBlock(),S.createElementBlock("li",{key:k},[S.createVNode(l,{column:_,onUpdateColumn:a.updateColumn},null,8,["column","onUpdateColumn"])]))),128))])])]),_:1})}const Hj=_t(Fj,[["render",Uj]]),qj={},Wj={class:"hidden sm:block shrink-0 size-3",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 16"};function Gj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",Wj,e[0]||(e[0]=[S.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 1C8.55228 1 9 1.44772 9 2V7L14 7C14.5523 7 15 7.44771 15 8C15 8.55228 14.5523 9 14 9L9 9V14C9 14.5523 8.55228 15 8 15C7.44772 15 7 14.5523 7 14V9.00001L2 9.00001C1.44772 9.00001 1 8.5523 1 8.00001C0.999999 7.44773 1.44771 7.00001 2 7.00001L7 7.00001V2C7 1.44772 7.44772 1 8 1Z"},null,-1)]))}const Zj=_t(qj,[["render",Gj]]),Yj={},Xj={class:"vs-table-interface__table-wrp w-full rounded h-fit overflow-hidden"};function Kj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",Xj,e[0]||(e[0]=[S.createStaticVNode('<div><div class="p-5 min-h-[500px] flex flex-col justify-center items-center text-center"><svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg><div class="max-w-sm mx-auto mt-6"><p class="font-medium text-gray-800 dark:text-neutral-200"> Дані для відображення відсутні </p><p class="mt-2 text-sm text-gray-500 dark:text-neutral-500"> Змініть параметри пошуку або спробуйте пізніше </p></div></div></div>',1)]))}const Jj={props:{table:String,title:String},components:{IconFilter:j8,AdminTableControl:yj,AdminTableExport:Ij,AdminTableColumnsHidden:Hj,AdminTableColumn:X8,AdminNodata:_t(Yj,[["render",Kj]]),IconPlus:Zj,IconSearch:dS},data(){return{tableData:{},isFilters:!1,filterScheme:[],page:1,searchValue:"",limit:0,filters:null,activeColumn:"",onFilters:0}},mounted(){var t,e,n,i;this.page=((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.page)||1,this.limit=((i=(n=this.$route)==null?void 0:n.query)==null?void 0:i.limit)||20,this.getTableData(),this.getFilters()},computed:{defaultPage(){var t,e;return((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.page)||1},getFilterScheme(){var t;return(t=this.tableData)==null?void 0:t.filters},columns(){var t,e;return(e=(t=this.tableData)==null?void 0:t.columns)==null?void 0:e.filter(n=>(n==null?void 0:n.hidden)!==!0)},isForm(){var t;return(t=this.tableData)==null?void 0:t.form},isNoData(){var t,e;return!((t=this.tableData)!=null&&t.rows)||!((e=this.columns)!=null&&e.length)},rowWidth(){var t;return((t=this.tableData)==null?void 0:t.width)||"100px"}},watch:{async table(){this.tableData=null,await this.getTableData()},searchValue(){this.getTableData()},$route:{handler(t,e){var n,i;((n=t==null?void 0:t.params)==null?void 0:n.catchAll)!==((i=e==null?void 0:e.params)==null?void 0:i.catchAll)&&(this.filterScheme=null,this.filters=null,this.onFilters=0,this.getFilters())},deep:!0},limit(t){var e;this.$router.push({query:{...(e=this.$route)==null?void 0:e.query,limit:t}})}},methods:{async getTableData(){var t,e;try{const{data:n}=await wt.get(`/api/template/table/${this.table}`),i=await wt.get(`/api/table-data/${this.table}`,{params:{page:this.page,search:this.searchValue||null,limit:this.limit,filter:this.filters||null,order:((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.sort)||null}});this.tableData={...n,...(i==null?void 0:i.data)||{}}}catch{}},async getFilters(){var t;try{const{data:e}=await wt.get(`/api/table-filter/${this.table}`);this.filterScheme=(t=e==null?void 0:e.list)==null?void 0:t.map(n=>({...n,label:(n==null?void 0:n.label)||(n==null?void 0:n.ua)}))}catch{}},async handlePageChange(t){const e=this.$route.query;this.page=t,!(!(e!=null&&e.page)&&t===1||e.page===t)&&(await this.$router.replace({query:{...e,page:t}}),await this.getTableData())},async changeLimit(t){this.limit=await t,this.defaultPage=1,await this.getTableData()},closeFilter({target:t}){this.isFilters&&t.classList.contains("filter-container")&&(this.isFilters=!1)},async filterChange({url:t,state:e}){var n;this.filters=t!=="no-url"?t:null,this.onFilters=(n=Object.entries(e))==null?void 0:n.length,this.page=1,await this.getTableData()},changeActiveColumn(t){this.activeColumn=t,this.getTableData()},pushToCard(t){var e;((e=this.tableData)==null?void 0:e.card)===!1||this.$router.push(`/card/${this.table}/${t}`)}}},Qj={class:"w-[calc(100vw - 320px)]"},e7={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},t7={class:"text-xl font-medium h-[20px]"},n7={style:{height:"calc(100vh - 140px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex pt-[10px]"},i7={class:"bg-white w-full rounded-xl border p-[20px]"},r7={class:"flex sm:grid sm:grid-cols-2 gap-x-2 sm:gap-x-5 mb-[10px] relative"},s7={class:"flex gap-[6px] ml-auto"},o7={key:0,class:"font-medium text-[10px] py-0.5 px-[5px] bg-gray-800 text-white leading-3 rounded-full dark:bg-neutral-500"},a7={class:"space-y-5 flex items-start w-full justify-start"},l7={style:{height:"calc(100vh - 310px)"},class:"overflow-x-auto w-full border-t [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},c7={class:"inline-block w-full align-middle"},u7={key:0,class:"divide-y divide-gray-200 min-w-full dark:divide-neutral-700 relative table-fixed"},h7={class:"sticky top-0 bg-white w-full relative after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},d7={class:"border-stone-200 right-0 z-[1]"},p7={class:"divide-y divide-gray-200"},f7=["onClick"],m7={class:"text-center sticky right-0 bg-white w-[80px] px-[10px]"},g7={class:"p-[20px] flex justify-end w-full"},y7={class:"filter-content h-screen bg-white w-[400px] p-[20px] pt-[10px] overflow-x-auto bg-white [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function _7(t,e,n,i,r,a){var ee,oe,J,Ae,ke,Me;const u=S.resolveComponent("IconPlus"),l=S.resolveComponent("router-link"),g=S.resolveComponent("IconSearch"),_=S.resolveComponent("VsText"),k=S.resolveComponent("AdminTableColumnsHidden"),E=S.resolveComponent("AdminTableExport"),T=S.resolveComponent("IconFilter"),I=S.resolveComponent("AdminTableColumn"),z=S.resolveComponent("AdminTableControl"),V=S.resolveComponent("AdminNodata"),H=S.resolveComponent("VsPagination"),Z=S.resolveComponent("VsFilter");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",Qj,[S.createElementVNode("div",e7,[S.createElementVNode("h2",t7,S.toDisplayString(n.title),1),a.isForm?(S.openBlock(),S.createBlock(l,{key:0,to:`/add?table=${(oe=(ee=t.$route)==null?void 0:ee.params)==null?void 0:oe.catchAll}`,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},{default:S.withCtx(()=>[S.createVNode(u,{height:"16",width:"16"}),e[5]||(e[5]=S.createTextVNode(" Додати "))]),_:1},8,["to"])):S.createCommentVNode("",!0)]),S.createElementVNode("div",n7,[S.createElementVNode("div",i7,[S.createElementVNode("div",r7,[S.createVNode(g,{height:"14",width:"14",class:"absolute top-[10px] left-[14px] text-gray-500 z-[1]"}),S.createVNode(_,{modelValue:r.searchValue,"onUpdate:modelValue":e[0]||(e[0]=Le=>r.searchValue=Le),placeholder:"Пошук...",clearable:!0,class:"[&>input]:py-[7px] [&>input]:ps-10 [&>input]:pe-8 [&>input]:block [&>input]:w-full [&>input]:bg-gray-100 [&>input]:border-transparent [&>input]:rounded-lg [&>input]:text-sm [&>input]:focus:bg-white [&>input]:focus:border-blue-500 [&>input]:focus:ring-blue-500 [&>input]:disabled:opacity-50 [&>input]:disabled:pointer-events-none [&>input]:dark:bg-neutral-700 [&>input]:dark:border-transparent [&>input]:dark:text-neutral-400 [&>input]:dark:placeholder:text-neutral-400 dark:focus:bg-neutral-800 dark:focus:ring-neutral-600"},null,8,["modelValue"]),S.createElementVNode("div",s7,[S.createVNode(k,{columns:(J=r.tableData)==null?void 0:J.columns,onUpdateColumns:e[1]||(e[1]=Le=>r.tableData.columns=Le)},null,8,["columns"]),S.createVNode(E,{table:n.table,columns:(Ae=r.tableData)==null?void 0:Ae.columns},null,8,["table","columns"]),S.createElementVNode("button",{onClick:e[2]||(e[2]=Le=>r.isFilters=!r.isFilters),class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createVNode(T,{height:"16",width:"16"}),e[6]||(e[6]=S.createTextVNode(" Фільтри ")),r.onFilters?(S.openBlock(),S.createElementBlock("span",o7,S.toDisplayString(r.onFilters),1)):S.createCommentVNode("",!0)])])]),S.createElementVNode("div",a7,[S.createElementVNode("div",l7,[S.createElementVNode("div",c7,[a.isNoData?(S.openBlock(),S.createBlock(V,{key:1})):(S.openBlock(),S.createElementBlock("table",u7,[S.createElementVNode("thead",h7,[S.createElementVNode("tr",d7,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.columns,Le=>(S.openBlock(),S.createBlock(I,{key:Le.name,style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth}),data:Le,activeColumn:r.activeColumn,onChangeActive:a.changeActiveColumn},null,8,["style","data","activeColumn","onChangeActive"]))),128)),e[7]||(e[7]=S.createElementVNode("th",{class:"w-[70px] sticky right-0 top-0 bg-white"},null,-1))])]),S.createElementVNode("tbody",p7,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((ke=r.tableData)==null?void 0:ke.rows,(Le,Ie)=>{var Ye,it,Nt,ht,Rt,Xt,nn,jt;return S.openBlock(),S.createElementBlock("tr",{key:Ie},[S.createElementVNode("td",{class:"text-sm text-gray-600",style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth})},[S.createElementVNode("button",{onClick:()=>a.pushToCard(Le==null?void 0:Le.id),class:S.normalizeClass(["text-sm font-medium",[((Ye=r.tableData)==null?void 0:Ye.card)===!1?"":"text-blue-600 decoration-2 focus:outline-none focus:underline hover:text-blue-600 hover:underline"]])},[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(((it=a.columns[0])==null?void 0:it.format)==="custom"?(Nt=a.columns[0])==null?void 0:Nt.component:t.$componentsConfig[`table-format-${((Rt=(ht=a.columns[0])==null?void 0:ht.format)==null?void 0:Rt.toLowerCase())||"text"}`]),{name:(Xt=a.columns[0])==null?void 0:Xt.name,data:Le,value:Le==null?void 0:Le[(nn=a.columns[0])==null?void 0:nn.name],table:n.table},null,8,["name","data","value","table"]))],10,f7)],4),(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((jt=a.columns)==null?void 0:jt.slice(1),Mt=>{var Sn,hn;return S.openBlock(),S.createElementBlock("td",{class:"text-start px-[4px] py-3 text-sm text-gray-600",style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth}),key:Mt.name},[(S.openBlock(),S.createBlock(S.resolveDynamicComponent((Mt==null?void 0:Mt.format)==="custom"?Mt==null?void 0:Mt.component:t.$componentsConfig[`table-format-${((Sn=Mt==null?void 0:Mt.format)==null?void 0:Sn.toLowerCase())||"text"}`]),{onUpdateTable:a.getTableData,name:Mt==null?void 0:Mt.name,data:Le,value:Le==null?void 0:Le[Mt==null?void 0:Mt.name],table:n.table,inline:((hn=r.tableData)==null?void 0:hn.inline)||!1},null,40,["onUpdateTable","name","data","value","table","inline"]))],4)}),128)),S.createElementVNode("td",m7,[S.createVNode(z,{isForm:a.isForm,item:Le,table:n.table,onUpdateTable:a.getTableData},null,8,["isForm","item","table","onUpdateTable"])])])}),128))])]))])])]),S.createElementVNode("div",g7,[r.limit?(S.openBlock(),S.createBlock(H,{key:0,goTo:!1,class:"justify-end","default-page":a.defaultPage,total:((Me=r.tableData)==null?void 0:Me.total)||0,pageSize:r.limit,onPageChange:a.handlePageChange,pageSizes:[10,16,20],onPageSizeChange:a.changeLimit},null,8,["default-page","total","pageSize","onPageChange","onPageSizeChange"])):S.createCommentVNode("",!0)])])])]),S.createVNode(S.Transition,{name:"fade"},{default:S.withCtx(()=>{var Le;return[S.withDirectives(S.createElementVNode("div",{onClick:e[4]||(e[4]=(...Ie)=>a.closeFilter&&a.closeFilter(...Ie)),style:{height:"100vh"},class:"fixed filter-container top-0 flex justify-end items-center z-[2] right-0 left-0 bottom-0 bg-[rgba(0,0,0,0.5)]"},[S.createElementVNode("div",y7,[(Le=r.filterScheme)!=null&&Le.length?(S.openBlock(),S.createBlock(Z,{key:0,ref:"filter",scheme:r.filterScheme,layout:"default","apply-vue-router":"",history:"",name:"filter",onFilterChange:a.filterChange,closeFilterBtn:!0,onFilterClose:e[3]||(e[3]=Ie=>r.isFilters=!1)},null,8,["scheme","onFilterChange"])):S.createCommentVNode("",!0)])],512),[[S.vShow,r.isFilters]])]}),_:1})],64)}const b7={components:{AdminTable:_t(Jj,[["render",_7]])},data(){return{table:!1,interface:"",title:""}},watch:{$route:{async handler(){Xr!=null&&Xr.value||await this.getMenu(),await this.checkPageType()},deep:!0},title(t){t&&(document.title=t)}},async mounted(){await this.checkPageType()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getMenu(){try{const{data:t}=await wt.get("/api/user-menu");Xr.value=t}catch{}},async checkPageType(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(i=>{var r,a;return(i==null?void 0:i.path)==((a=(r=this.$route)==null?void 0:r.params)==null?void 0:a.catchAll)});this.title=e==null?void 0:e.ua,e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n||!1,!n&&this.getInterface()},async getInterface(){var t,e;try{const{data:n}=await wt.get(`/api/template/interface/${((e=(t=this.$route)==null?void 0:t.params)==null?void 0:e.catchAll)||""}`);this.interface=n||""}catch{this.interface=""}}}},x7=["innerHTML"];function v7(t,e,n,i,r,a){const u=S.resolveComponent("AdminTable");return r.table?(S.openBlock(),S.createBlock(u,{key:0,table:r.table,title:r.title},null,8,["table","title"])):(S.openBlock(),S.createElementBlock("div",{key:1,class:"w-full bg-gray-50",style:{height:"calc(100vh - 120px)"},innerHTML:r.interface},null,8,x7))}const w7=Object.freeze(Object.defineProperty({__proto__:null,default:_t(b7,[["render",v7]])},Symbol.toStringTag,{value:"Module"}));return r$});
|
|
741
|
+
`},addCommands(){return{setHardBreak:()=>({commands:t,chain:e,state:n,editor:i})=>t.first([()=>t.exitCode(),()=>t.command(()=>{const{selection:r,storedMarks:a}=n;if(r.$from.parent.type.spec.isolating)return!1;const{keepMarks:u}=this.options,{splittableMarks:l}=i.extensionManager,g=a||r.$to.parentOffset&&r.$from.marks();return e().insertContent({type:this.name}).command(({tr:_,dispatch:k})=>{if(k&&g&&u){const E=g.filter(T=>l.includes(T.type.name));_.ensureMarks(E)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),HF=xs.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(t=>({tag:`h${t}`,attrs:{level:t}}))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,di(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.setNode(this.name,t):!1,toggleHeading:t=>({commands:e})=>this.options.levels.includes(t.level)?e.toggleNode(this.name,"paragraph",t):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(t=>E0({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}}))}});var qf=200,Ai=function(){};Ai.prototype.append=function(e){return e.length?(e=Ai.from(e),!this.length&&e||e.length<qf&&this.leafAppend(e)||this.length<qf&&e.leafPrepend(this)||this.appendInner(e)):this},Ai.prototype.prepend=function(e){return e.length?Ai.from(e).append(this):this},Ai.prototype.appendInner=function(e){return new qF(this,e)},Ai.prototype.slice=function(e,n){return e===void 0&&(e=0),n===void 0&&(n=this.length),e>=n?Ai.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,n))},Ai.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Ai.prototype.forEach=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length),n<=i?this.forEachInner(e,n,i,0):this.forEachInvertedInner(e,n,i,0)},Ai.prototype.map=function(e,n,i){n===void 0&&(n=0),i===void 0&&(i=this.length);var r=[];return this.forEach(function(a,u){return r.push(e(a,u))},n,i),r},Ai.from=function(e){return e instanceof Ai?e:e&&e.length?new nS(e):Ai.empty};var nS=function(t){function e(i){t.call(this),this.values=i}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(r,a){return r==0&&a==this.length?this:new e(this.values.slice(r,a))},e.prototype.getInner=function(r){return this.values[r]},e.prototype.forEachInner=function(r,a,u,l){for(var g=a;g<u;g++)if(r(this.values[g],l+g)===!1)return!1},e.prototype.forEachInvertedInner=function(r,a,u,l){for(var g=a-1;g>=u;g--)if(r(this.values[g],l+g)===!1)return!1},e.prototype.leafAppend=function(r){if(this.length+r.length<=qf)return new e(this.values.concat(r.flatten()))},e.prototype.leafPrepend=function(r){if(this.length+r.length<=qf)return new e(r.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(e.prototype,n),e}(Ai);Ai.empty=new nS([]);var qF=function(t){function e(n,i){t.call(this),this.left=n,this.right=i,this.length=n.length+i.length,this.depth=Math.max(n.depth,i.depth)+1}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(i){return i<this.left.length?this.left.get(i):this.right.get(i-this.left.length)},e.prototype.forEachInner=function(i,r,a,u){var l=this.left.length;if(r<l&&this.left.forEachInner(i,r,Math.min(a,l),u)===!1||a>l&&this.right.forEachInner(i,Math.max(r-l,0),Math.min(this.length,a)-l,u+l)===!1)return!1},e.prototype.forEachInvertedInner=function(i,r,a,u){var l=this.left.length;if(r>l&&this.right.forEachInvertedInner(i,r-l,Math.max(a,l)-l,u+l)===!1||a<l&&this.left.forEachInvertedInner(i,Math.min(r,l),a,u)===!1)return!1},e.prototype.sliceInner=function(i,r){if(i==0&&r==this.length)return this;var a=this.left.length;return r<=a?this.left.slice(i,r):i>=a?this.right.slice(i-a,r-a):this.left.slice(i,a).append(this.right.slice(0,r-a))},e.prototype.leafAppend=function(i){var r=this.right.leafAppend(i);if(r)return new e(this.left,r)},e.prototype.leafPrepend=function(i){var r=this.left.leafPrepend(i);if(r)return new e(r,this.right)},e.prototype.appendInner=function(i){return this.left.depth>=Math.max(this.right.depth,i.depth)+1?new e(this.left,new e(this.right,i)):new e(this,i)},e}(Ai);const WF=500;class Us{constructor(e,n){this.items=e,this.eventCount=n}popEvent(e,n){if(this.eventCount==0)return null;let i=this.items.length;for(;;i--)if(this.items.get(i-1).selection){--i;break}let r,a;n&&(r=this.remapping(i,this.items.length),a=r.maps.length);let u=e.tr,l,g,_=[],k=[];return this.items.forEach((E,T)=>{if(!E.step){r||(r=this.remapping(i,T+1),a=r.maps.length),a--,k.push(E);return}if(r){k.push(new co(E.map));let I=E.step.map(r.slice(a)),z;I&&u.maybeStep(I).doc&&(z=u.mapping.maps[u.mapping.maps.length-1],_.push(new co(z,void 0,void 0,_.length+k.length))),a--,z&&r.appendMap(z,a)}else u.maybeStep(E.step);if(E.selection)return l=r?E.selection.map(r.slice(a)):E.selection,g=new Us(this.items.slice(0,i).append(k.reverse().concat(_)),this.eventCount-1),!1},this.items.length,0),{remaining:g,transform:u,selection:l}}addTransform(e,n,i,r){let a=[],u=this.eventCount,l=this.items,g=!r&&l.length?l.get(l.length-1):null;for(let k=0;k<e.steps.length;k++){let E=e.steps[k].invert(e.docs[k]),T=new co(e.mapping.maps[k],E,n),I;(I=g&&g.merge(T))&&(T=I,k?a.pop():l=l.slice(0,l.length-1)),a.push(T),n&&(u++,n=void 0),r||(g=T)}let _=u-i.depth;return _>ZF&&(l=GF(l,_),u-=_),new Us(l.append(a),u)}remapping(e,n){let i=new Pc;return this.items.forEach((r,a)=>{let u=r.mirrorOffset!=null&&a-r.mirrorOffset>=e?i.maps.length-r.mirrorOffset:void 0;i.appendMap(r.map,u)},e,n),i}addMaps(e){return this.eventCount==0?this:new Us(this.items.append(e.map(n=>new co(n))),this.eventCount)}rebased(e,n){if(!this.eventCount)return this;let i=[],r=Math.max(0,this.items.length-n),a=e.mapping,u=e.steps.length,l=this.eventCount;this.items.forEach(T=>{T.selection&&l--},r);let g=n;this.items.forEach(T=>{let I=a.getMirror(--g);if(I==null)return;u=Math.min(u,I);let z=a.maps[I];if(T.step){let V=e.steps[I].invert(e.docs[I]),H=T.selection&&T.selection.map(a.slice(g+1,I));H&&l++,i.push(new co(z,V,H))}else i.push(new co(z))},r);let _=[];for(let T=n;T<u;T++)_.push(new co(a.maps[T]));let k=this.items.slice(0,r).append(_).append(i),E=new Us(k,l);return E.emptyItemCount()>WF&&(E=E.compress(this.items.length-i.length)),E}emptyItemCount(){let e=0;return this.items.forEach(n=>{n.step||e++}),e}compress(e=this.items.length){let n=this.remapping(0,e),i=n.maps.length,r=[],a=0;return this.items.forEach((u,l)=>{if(l>=e)r.push(u),u.selection&&a++;else if(u.step){let g=u.step.map(n.slice(i)),_=g&&g.getMap();if(i--,_&&n.appendMap(_,i),g){let k=u.selection&&u.selection.map(n.slice(i));k&&a++;let E=new co(_.invert(),g,k),T,I=r.length-1;(T=r.length&&r[I].merge(E))?r[I]=T:r.push(E)}}else u.map&&i--},this.items.length,0),new Us(Ai.from(r.reverse()),a)}}Us.empty=new Us(Ai.empty,0);function GF(t,e){let n;return t.forEach((i,r)=>{if(i.selection&&e--==0)return n=r,!1}),t.slice(n)}class co{constructor(e,n,i,r){this.map=e,this.step=n,this.selection=i,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let n=e.step.merge(this.step);if(n)return new co(n.getMap().invert(),n,this.selection)}}}class Ta{constructor(e,n,i,r,a){this.done=e,this.undone=n,this.prevRanges=i,this.prevTime=r,this.prevComposition=a}}const ZF=20;function YF(t,e,n,i){let r=n.getMeta(Ll),a;if(r)return r.historyState;n.getMeta(JF)&&(t=new Ta(t.done,t.undone,null,0,-1));let u=n.getMeta("appendedTransaction");if(n.steps.length==0)return t;if(u&&u.getMeta(Ll))return u.getMeta(Ll).redo?new Ta(t.done.addTransform(n,void 0,i,Wf(e)),t.undone,iS(n.mapping.maps),t.prevTime,t.prevComposition):new Ta(t.done,t.undone.addTransform(n,void 0,i,Wf(e)),null,t.prevTime,t.prevComposition);if(n.getMeta("addToHistory")!==!1&&!(u&&u.getMeta("addToHistory")===!1)){let l=n.getMeta("composition"),g=t.prevTime==0||!u&&t.prevComposition!=l&&(t.prevTime<(n.time||0)-i.newGroupDelay||!XF(n,t.prevRanges)),_=u?q0(t.prevRanges,n.mapping):iS(n.mapping.maps);return new Ta(t.done.addTransform(n,g?e.selection.getBookmark():void 0,i,Wf(e)),Us.empty,_,n.time,l??t.prevComposition)}else return(a=n.getMeta("rebased"))?new Ta(t.done.rebased(n,a),t.undone.rebased(n,a),q0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition):new Ta(t.done.addMaps(n.mapping.maps),t.undone.addMaps(n.mapping.maps),q0(t.prevRanges,n.mapping),t.prevTime,t.prevComposition)}function XF(t,e){if(!e)return!1;if(!t.docChanged)return!0;let n=!1;return t.mapping.maps[0].forEach((i,r)=>{for(let a=0;a<e.length;a+=2)i<=e[a+1]&&r>=e[a]&&(n=!0)}),n}function iS(t){let e=[];for(let n=t.length-1;n>=0&&e.length==0;n--)t[n].forEach((i,r,a,u)=>e.push(a,u));return e}function q0(t,e){if(!t)return null;let n=[];for(let i=0;i<t.length;i+=2){let r=e.map(t[i],1),a=e.map(t[i+1],-1);r<=a&&n.push(r,a)}return n}function KF(t,e,n){let i=Wf(e),r=Ll.get(e).spec.config,a=(n?t.undone:t.done).popEvent(e,i);if(!a)return null;let u=a.selection.resolve(a.transform.doc),l=(n?t.done:t.undone).addTransform(a.transform,e.selection.getBookmark(),r,i),g=new Ta(n?l:a.remaining,n?a.remaining:l,null,0,-1);return a.transform.setSelection(u).setMeta(Ll,{redo:n,historyState:g})}let W0=!1,rS=null;function Wf(t){let e=t.plugins;if(rS!=e){W0=!1,rS=e;for(let n=0;n<e.length;n++)if(e[n].spec.historyPreserveItems){W0=!0;break}}return W0}const Ll=new Mr("history"),JF=new Mr("closeHistory");function QF(t={}){return t={depth:t.depth||100,newGroupDelay:t.newGroupDelay||500},new Fi({key:Ll,state:{init(){return new Ta(Us.empty,Us.empty,null,0,-1)},apply(e,n,i){return YF(n,i,e,t)}},config:t,props:{handleDOMEvents:{beforeinput(e,n){let i=n.inputType,r=i=="historyUndo"?oS:i=="historyRedo"?aS:null;return r?(n.preventDefault(),r(e.state,e.dispatch)):!1}}}})}function sS(t,e){return(n,i)=>{let r=Ll.getState(n);if(!r||(t?r.undone:r.done).eventCount==0)return!1;if(i){let a=KF(r,n,t);a&&i(e?a.scrollIntoView():a)}return!0}}const oS=sS(!1,!0),aS=sS(!0,!0),eV=ji.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:t,dispatch:e})=>oS(t,e),redo:()=>({state:t,dispatch:e})=>aS(t,e)}},addProseMirrorPlugins(){return[QF(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-я":()=>this.editor.commands.undo(),"Shift-Mod-я":()=>this.editor.commands.redo()}}}),tV=xs.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:t}){return["hr",di(this.options.HTMLAttributes,t)]},addCommands(){return{setHorizontalRule:()=>({chain:t,state:e})=>{const{selection:n}=e,{$from:i,$to:r}=n,a=t();return i.parentOffset===0?a.insertContentAt({from:Math.max(i.pos-1,0),to:r.pos},{type:this.name}):l2(n)?a.insertContentAt(r.pos,{type:this.name}):a.insertContent({type:this.name}),a.command(({tr:u,dispatch:l})=>{var g;if(l){const{$to:_}=u.selection,k=_.end();if(_.nodeAfter)_.nodeAfter.isTextblock?u.setSelection(Vt.create(u.doc,_.pos+1)):_.nodeAfter.isBlock?u.setSelection(zt.create(u.doc,_.pos)):u.setSelection(Vt.create(u.doc,_.pos));else{const E=(g=_.parent.type.contentMatch.defaultType)===null||g===void 0?void 0:g.create();E&&(u.insert(k,E),u.setSelection(Vt.create(u.doc,k+1)))}u.scrollIntoView()}return!0}).run()}}},addInputRules(){return[O5({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),nV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,iV=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,rV=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,sV=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,oV=Lo.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:t=>t.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:t}){return["em",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[qc({find:nV,type:this.type}),qc({find:rV,type:this.type})]},addPasteRules(){return[Wc({find:iV,type:this.type}),Wc({find:sV,type:this.type})]}}),lS=/^(\d+)\.\s$/,aV=xs.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return e===1?["ol",di(this.options.HTMLAttributes,n),0]:["ol",di(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(U0.name,this.editor.getAttributes(Uf.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=Nh({find:lS,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=Nh({find:lS,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(Uf.name)}),joinPredicate:(e,n)=>n.childCount+n.attrs.start===+e[1],editor:this.editor})),[t]}}),lV=xs.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:t}){return["p",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),cV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,uV=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,hV=Lo.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:t=>t.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:t}){return["s",di(this.options.HTMLAttributes,t),0]},addCommands(){return{setStrike:()=>({commands:t})=>t.setMark(this.name),toggleStrike:()=>({commands:t})=>t.toggleMark(this.name),unsetStrike:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[qc({find:cV,type:this.type})]},addPasteRules(){return[Wc({find:uV,type:this.type})]}}),dV=xs.create({name:"text",group:"inline"}),pV=ji.create({name:"starterKit",addExtensions(){var t,e,n,i,r,a,u,l,g,_,k,E,T,I,z,V,H,Z;const ee=[];return this.options.bold!==!1&&ee.push(SF.configure((t=this.options)===null||t===void 0?void 0:t.bold)),this.options.blockquote!==!1&&ee.push(bF.configure((e=this.options)===null||e===void 0?void 0:e.blockquote)),this.options.bulletList!==!1&&ee.push(EF.configure((n=this.options)===null||n===void 0?void 0:n.bulletList)),this.options.code!==!1&&ee.push(MF.configure((i=this.options)===null||i===void 0?void 0:i.code)),this.options.codeBlock!==!1&&ee.push(tS.configure((r=this.options)===null||r===void 0?void 0:r.codeBlock)),this.options.document!==!1&&ee.push(IF.configure((a=this.options)===null||a===void 0?void 0:a.document)),this.options.dropcursor!==!1&&ee.push(zF.configure((u=this.options)===null||u===void 0?void 0:u.dropcursor)),this.options.gapcursor!==!1&&ee.push(jF.configure((l=this.options)===null||l===void 0?void 0:l.gapcursor)),this.options.hardBreak!==!1&&ee.push(UF.configure((g=this.options)===null||g===void 0?void 0:g.hardBreak)),this.options.heading!==!1&&ee.push(HF.configure((_=this.options)===null||_===void 0?void 0:_.heading)),this.options.history!==!1&&ee.push(eV.configure((k=this.options)===null||k===void 0?void 0:k.history)),this.options.horizontalRule!==!1&&ee.push(tV.configure((E=this.options)===null||E===void 0?void 0:E.horizontalRule)),this.options.italic!==!1&&ee.push(oV.configure((T=this.options)===null||T===void 0?void 0:T.italic)),this.options.listItem!==!1&&ee.push(U0.configure((I=this.options)===null||I===void 0?void 0:I.listItem)),this.options.orderedList!==!1&&ee.push(aV.configure((z=this.options)===null||z===void 0?void 0:z.orderedList)),this.options.paragraph!==!1&&ee.push(lV.configure((V=this.options)===null||V===void 0?void 0:V.paragraph)),this.options.strike!==!1&&ee.push(hV.configure((H=this.options)===null||H===void 0?void 0:H.strike)),this.options.text!==!1&&ee.push(dV.configure((Z=this.options)===null||Z===void 0?void 0:Z.text)),ee}});function fV(t){var e;const{char:n,allowSpaces:i,allowedPrefixes:r,startOfLine:a,$position:u}=t,l=z5(n),g=new RegExp(`\\s${l}$`),_=a?"^":"",k=i?new RegExp(`${_}${l}.*?(?=\\s${l}|$)`,"gm"):new RegExp(`${_}(?:^)?${l}[^\\s${l}]*`,"gm"),E=((e=u.nodeBefore)===null||e===void 0?void 0:e.isText)&&u.nodeBefore.text;if(!E)return null;const T=u.pos-E.length,I=Array.from(E.matchAll(k)).pop();if(!I||I.input===void 0||I.index===void 0)return null;const z=I.input.slice(Math.max(0,I.index-1),I.index),V=new RegExp(`^[${r==null?void 0:r.join("")}\0]?$`).test(z);if(r!==null&&!V)return null;const H=T+I.index;let Z=H+I[0].length;return i&&g.test(E.slice(Z-1,Z+1))&&(I[0]+=" ",Z+=1),H<u.pos&&Z>=u.pos?{range:{from:H,to:Z},query:I[0].slice(n.length),text:I[0]}:null}const mV=new Mr("suggestion");function gV({pluginKey:t=mV,editor:e,char:n="@",allowSpaces:i=!1,allowedPrefixes:r=[" "],startOfLine:a=!1,decorationTag:u="span",decorationClass:l="suggestion",command:g=()=>null,items:_=()=>[],render:k=()=>({}),allow:E=()=>!0,findSuggestionMatch:T=fV}){let I;const z=k==null?void 0:k(),V=new Fi({key:t,view(){return{update:async(H,Z)=>{var ee,oe,J,Ae,ke,Me,Le;const Ie=(ee=this.key)===null||ee===void 0?void 0:ee.getState(Z),Ye=(oe=this.key)===null||oe===void 0?void 0:oe.getState(H.state),it=Ie.active&&Ye.active&&Ie.range.from!==Ye.range.from,Nt=!Ie.active&&Ye.active,ht=Ie.active&&!Ye.active,Rt=!Nt&&!ht&&Ie.query!==Ye.query,Xt=Nt||it&&Rt,nn=Rt||it,jt=ht||it&&Rt;if(!Xt&&!nn&&!jt)return;const Mt=jt&&!Xt?Ie:Ye,Sn=H.dom.querySelector(`[data-decoration-id="${Mt.decorationId}"]`);I={editor:e,range:Mt.range,query:Mt.query,text:Mt.text,items:[],command:hn=>g({editor:e,range:Mt.range,props:hn}),decorationNode:Sn,clientRect:Sn?()=>{var hn;const{decorationId:In}=(hn=this.key)===null||hn===void 0?void 0:hn.getState(e.state),bn=H.dom.querySelector(`[data-decoration-id="${In}"]`);return(bn==null?void 0:bn.getBoundingClientRect())||null}:null},Xt&&((J=z==null?void 0:z.onBeforeStart)===null||J===void 0||J.call(z,I)),nn&&((Ae=z==null?void 0:z.onBeforeUpdate)===null||Ae===void 0||Ae.call(z,I)),(nn||Xt)&&(I.items=await _({editor:e,query:Mt.query})),jt&&((ke=z==null?void 0:z.onExit)===null||ke===void 0||ke.call(z,I)),nn&&((Me=z==null?void 0:z.onUpdate)===null||Me===void 0||Me.call(z,I)),Xt&&((Le=z==null?void 0:z.onStart)===null||Le===void 0||Le.call(z,I))},destroy:()=>{var H;I&&((H=z==null?void 0:z.onExit)===null||H===void 0||H.call(z,I))}}},state:{init(){return{active:!1,range:{from:0,to:0},query:null,text:null,composing:!1}},apply(H,Z,ee,oe){const{isEditable:J}=e,{composing:Ae}=e.view,{selection:ke}=H,{empty:Me,from:Le}=ke,Ie={...Z};if(Ie.composing=Ae,J&&(Me||e.view.composing)){(Le<Z.range.from||Le>Z.range.to)&&!Ae&&!Z.composing&&(Ie.active=!1);const Ye=T({char:n,allowSpaces:i,allowedPrefixes:r,startOfLine:a,$position:ke.$from}),it=`id_${Math.floor(Math.random()*4294967295)}`;Ye&&E({editor:e,state:oe,range:Ye.range,isActive:Z.active})?(Ie.active=!0,Ie.decorationId=Z.decorationId?Z.decorationId:it,Ie.range=Ye.range,Ie.query=Ye.query,Ie.text=Ye.text):Ie.active=!1}else Ie.active=!1;return Ie.active||(Ie.decorationId=null,Ie.range={from:0,to:0},Ie.query=null,Ie.text=null),Ie}},props:{handleKeyDown(H,Z){var ee;const{active:oe,range:J}=V.getState(H.state);return oe&&((ee=z==null?void 0:z.onKeyDown)===null||ee===void 0?void 0:ee.call(z,{view:H,event:Z,range:J}))||!1},decorations(H){const{active:Z,range:ee,decorationId:oe}=V.getState(H);return Z?hi.create(H.doc,[Gr.inline(ee.from,ee.to,{nodeName:u,class:l,"data-decoration-id":oe})]):null}}});return V}const yV=new Mr("mention"),_V=xs.create({name:"mention",addOptions(){return{HTMLAttributes:{},renderText({options:t,node:e}){var n;return`${t.suggestion.char}${(n=e.attrs.label)!==null&&n!==void 0?n:e.attrs.id}`},deleteTriggerWithBackspace:!1,renderHTML({options:t,node:e}){var n;return["span",di(this.HTMLAttributes,t.HTMLAttributes),`${t.suggestion.char}${(n=e.attrs.label)!==null&&n!==void 0?n:e.attrs.id}`]},suggestion:{char:"@",pluginKey:yV,command:({editor:t,range:e,props:n})=>{var i,r,a;const u=t.view.state.selection.$to.nodeAfter;((i=u==null?void 0:u.text)===null||i===void 0?void 0:i.startsWith(" "))&&(e.to+=1),t.chain().focus().insertContentAt(e,[{type:this.name,attrs:n},{type:"text",text:" "}]).run(),(a=(r=t.view.dom.ownerDocument.defaultView)===null||r===void 0?void 0:r.getSelection())===null||a===void 0||a.collapseToEnd()},allow:({state:t,range:e})=>{const n=t.doc.resolve(e.from),i=t.schema.nodes[this.name];return!!n.parent.type.contentMatch.matchType(i)}}}},group:"inline",inline:!0,selectable:!1,atom:!0,addAttributes(){return{id:{default:null,parseHTML:t=>t.getAttribute("data-id"),renderHTML:t=>t.id?{"data-id":t.id}:{}},label:{default:null,parseHTML:t=>t.getAttribute("data-label"),renderHTML:t=>t.label?{"data-label":t.label}:{}}}},parseHTML(){return[{tag:`span[data-type="${this.name}"]`}]},renderHTML({node:t,HTMLAttributes:e}){if(this.options.renderLabel!==void 0)return console.warn("renderLabel is deprecated use renderText and renderHTML instead"),["span",di({"data-type":this.name},this.options.HTMLAttributes,e),this.options.renderLabel({options:this.options,node:t})];const n={...this.options};n.HTMLAttributes=di({"data-type":this.name},this.options.HTMLAttributes,e);const i=this.options.renderHTML({options:n,node:t});return typeof i=="string"?["span",di({"data-type":this.name},this.options.HTMLAttributes,e),i]:i},renderText({node:t}){return this.options.renderLabel!==void 0?(console.warn("renderLabel is deprecated use renderText and renderHTML instead"),this.options.renderLabel({options:this.options,node:t})):this.options.renderText({options:this.options,node:t})},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:t,state:e})=>{let n=!1;const{selection:i}=e,{empty:r,anchor:a}=i;return r?(e.doc.nodesBetween(a-1,a,(u,l)=>{if(u.type.name===this.name)return n=!0,t.insertText(this.options.deleteTriggerWithBackspace?"":this.options.suggestion.char||"",l,l+u.nodeSize),!1}),n):!1})}},addProseMirrorPlugins(){return[gV({editor:this.editor,...this.options.suggestion})]}}),bV={props:{editor:Object},methods:{toggleBlockquote(){this.editor&&this.editor.chain().toggleBlockquote().run()}}};function xV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBlockquote&&a.toggleBlockquote(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 24 24"},[S.createElementVNode("path",{"fill-rule":"evenodd",d:"M6 6a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h3a3 3 0 0 1-3 3H5a1 1 0 1 0 0 2h1a5 5 0 0 0 5-5V8a2 2 0 0 0-2-2H6Zm9 0a2 2 0 0 0-2 2v3a2 2 0 0 0 2 2h3a3 3 0 0 1-3 3h-1a1 1 0 1 0 0 2h1a5 5 0 0 0 5-5V8a2 2 0 0 0-2-2h-3Z"})],-1)]))}const vV=_t(bV,[["render",xV]]),wV={props:{editor:Object},methods:{toggleBulletList(){this.editor&&this.editor.chain().focus().toggleBulletList().run()}}};function kV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBulletList&&a.toggleBulletList(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-width":"2",d:"M9 8h10M9 12h10M9 16h10M4.99 8H5m-.02 4h.01m0 4H5"})],-1)]))}const SV=_t(wV,[["render",kV]]),EV={props:{editor:Object},methods:{toggleOrderedList(){this.editor&&this.editor.chain().focus().toggleOrderedList().run()}}};function CV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleOrderedList&&a.toggleOrderedList(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 6h8m-8 6h8m-8 6h8M4 16a2 2 0 1 1 3.321 1.5L4 20h5M4 5l2-1v6m-2 0h4"})],-1)]))}const TV=_t(EV,[["render",CV]]),MV={props:{editor:Object},methods:{toggleCodeBlock(){this.editor&&this.editor.chain().focus().toggleCodeBlock().run()}}};function AV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleCodeBlock&&a.toggleCodeBlock(...u)),class:"p-1.5 text-gray-500 rounded hover:text-gray-900 dark:hover:text-white focus:outline-none"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m8 8-4 4 4 4m8 0 4-4-4-4m-2-3-4 14"})],-1)]))}const PV=_t(MV,[["render",AV]]),IV={props:{editor:Object},methods:{toggleBold(){this.editor&&this.editor.chain().toggleBold().run()}}};function DV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleBold&&a.toggleBold(...u)),class:"p-1.5 text-gray-500 rounded cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M8 5h4.5a3.5 3.5 0 1 1 0 7H8m0-7v7m0-7H6m2 7h6.5a3.5 3.5 0 1 1 0 7H8m0-7v7m0 0H6"})],-1),S.createElementVNode("span",{class:"sr-only"},"Bold",-1)]))}const OV=_t(IV,[["render",DV]]),zV={props:{editor:Object},methods:{toggleItalic(){this.editor&&this.editor.chain().toggleItalic().run()}}};function RV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("button",{onClick:e[0]||(e[0]=(...u)=>a.toggleItalic&&a.toggleItalic(...u)),class:"p-1.5 text-gray-500 rounded cursor-pointer hover:text-gray-900 hover:bg-gray-100 dark:text-gray-400 dark:hover:text-white dark:hover:bg-gray-600"},e[1]||(e[1]=[S.createElementVNode("svg",{class:"w-5 h-5","aria-hidden":"true",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",fill:"none",viewBox:"0 0 24 24"},[S.createElementVNode("path",{stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"m8.874 19 6.143-14M6 19h6.33m-.66-14H18"})],-1),S.createElementVNode("span",{class:"sr-only"},"Italic",-1)]))}const LV={bold:OV,italic:_t(zV,[["render",RV]]),bullet_list:SV,ordered_list:TV,blockquote:vV,codeblock:PV},NV={components:{EditorContent:yF},props:{controls:{type:Array,default:()=>["bold","italic","blockquote","bullet_list","ordered_list","codeblock"]},options:{type:Array,default:()=>[]},modelValue:{type:String,default:()=>""}},data(){return{editor:null}},computed:{controlsList(){return Object.entries(LV).filter(([t])=>this.controls.includes(t)).map(([t,e])=>e)}},watch:{modelValue(t){this.editor&&this.editor.getHTML()!==t&&this.editor.commands.setContent(t)},editor(t){t&&this.editor.on("update",({editor:e})=>{const n=e.getHTML();n!==this.modelValue&&this.$emit("update:modelValue",n)})}},mounted(){this.editor&&this.editor.destroy(),this.initEditor()},beforeDestroy(){this.editor&&this.editor.destroy()},methods:{initEditor(){this.editor=new gF({content:this.modelValue,extensions:[pV,tS,_V.configure({HTMLAttributes:{class:"mention"},suggestion:{items:({query:t})=>{const e=this.options.filter(n=>{var i,r;return(r=(i=n==null?void 0:n.email)==null?void 0:i.toLowerCase())==null?void 0:r.includes(t==null?void 0:t.toLowerCase())}).slice(0,5);return e.length?e:[{id:null,text:"Данні відсутні",email:null}]},render:()=>{let t,e;return{onStart:n=>{t=document.createElement("div"),t.className="mention-popup",n.items.forEach(a=>{const u=document.createElement("div");u.className="mention-option",a.id===null?(u.textContent=a.text,u.style.pointerEvents="none",u.style.color="#999"):(u.textContent=a.text,u.addEventListener("click",()=>{n.command({id:a.id,label:a.email})})),t.appendChild(u)}),document.body.appendChild(t);const{from:i}=n.range,r=n.editor.view.coordsAtPos(i);t.style.position="absolute",t.style.left=`${r.left}px`,t.style.top=`${r.top-t.offsetHeight}px`,e=t},onUpdate:n=>{for(;t.firstChild;)t.removeChild(t.firstChild);n.items.forEach(a=>{const u=document.createElement("div");u.className="mention-option",a.id===null?(u.textContent=a.text,u.style.pointerEvents="none",u.style.color="#999"):(u.textContent=a.text,u.addEventListener("click",()=>{n.command({id:a.id,label:a.email})})),t.appendChild(u)});const{from:i}=n.range,r=n.editor.view.coordsAtPos(i);t.style.left=`${r.left}px`,t.style.top=`${r.top-t.offsetHeight}px`},onExit:()=>{e&&e.remove()}}}}})]})}}},BV={class:"editor-container w-full border border-gray-200 rounded-lg bg-gray-50 dark:bg-gray-700 dark:border-gray-600"},FV={class:"editor-toolbar px-3 py-2 border-b dark:border-gray-600 flex items-center gap-2"},VV={class:"editor-content px-4 py-2 bg-white rounded-b-lg dark:bg-gray-800 relative"};function $V(t,e,n,i,r,a){const u=S.resolveComponent("EditorContent");return S.openBlock(),S.createElementBlock("div",BV,[S.createElementVNode("div",FV,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.controlsList,(l,g)=>(S.openBlock(),S.createBlock(S.resolveDynamicComponent(l),{key:g,editor:r.editor},null,8,["editor"]))),128))]),S.createElementVNode("div",VV,[S.createVNode(u,{editor:r.editor,class:"relative"},null,8,["editor"])])])}const cS=_t(NV,[["render",$V]]),jV=t=>{const e=/(\b\S)?/g,n=t.match(e);return n?n.join("").toUpperCase():""},UV={props:{name:{type:String,default(){return""}},avatar:{type:String,default(){return""}}},computed:{inItials(){return jV(this.name)}}},HV={class:"mr-2"},qV=["src"],WV={key:1,class:"flex flex-shrink-0 items-center justify-center w-6 h-6 bg-gray-500 text-xs text-white rounded-full"},GV={key:0},ZV={key:1,class:"text-sm"};function YV(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",HV,[n.avatar?(S.openBlock(),S.createElementBlock("img",{key:0,src:n.avatar,alt:"avatar",class:"flex flex-shrink-0 items-center justify-center w-6 h-6 rounded-full"},null,8,qV)):n.name?(S.openBlock(),S.createElementBlock("div",WV,[a.inItials.length?(S.openBlock(),S.createElementBlock("span",GV,S.toDisplayString(a.inItials),1)):(S.openBlock(),S.createElementBlock("span",ZV,e[0]||(e[0]=[S.createElementVNode("i",{class:"ti ti-user"},null,-1)])))])):S.createCommentVNode("",!0)])}const XV={components:{VsWidgetCommentsAvatar:_t(UV,[["render",YV]]),VsTextEditor:cS},props:{comment:{type:Object,default:()=>({})},user:{type:Object,default:()=>({})},id:{type:String,default:""},options:Array},data(){return{commentContent:this.comment.body,isCommentActionVisible:!1,isOpen:!1,textareaValue:""}},computed:{isUserAutor(){return this.user.uid===this.comment.uid},createDate(){try{const t=at(this.comment.cdate,"YYYY-MM-DD");return new Date(t).toLocaleDateString("uk-UA",{day:"2-digit",month:"long",year:"numeric"})}catch{return""}}},watch:{isOpen(t){t&&(this.textareaValue=this.comment.body)}},methods:{confirnDeleteComment(){document.body.click(),this.$emit("openModal",{title:"Ви впевнені?",message:"Ви впевнені, що хочете видалити цей коментар?",confirmButtonText:"Так, я впевнена/ий",cancelButtonText:"Скасувати",confirm:this.deleteComment,updateListOnConfirm:!0})},async updateComment(){try{await wt.post(`/api/widget/comment/${this.id}/${this.comment.communication_id}`,{body:this.textareaValue}),this.$emit("list-update"),this.isOpen=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}},async deleteComment(){try{await wt.delete(`/api/widget/comment/${this.id}/${this.comment.communication_id}`),this.$emit("list-update"),this.isCommentActionVisible=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}},toggleCommentAction(){this.isCommentActionVisible=!this.isCommentActionVisible}}},KV={class:"p-6 text-base bg-white dark:bg-gray-900"},JV={class:"flex justify-between items-center mb-2"},QV={class:"flex items-center"},e6={class:"inline-flex items-center mr-3 text-sm text-gray-900 dark:text-white font-semibold capitalize"},t6={class:"text-sm text-gray-600 dark:text-gray-400"},n6=["innerHTML"],i6={class:"flex items-center gap-[4px]"},r6={class:"flex flex-col gap-[8px] text-sm font-medium text-gray-500"},s6={class:"flex justify-end p-[20px] gap-[10px] border-t w-full"};function o6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetCommentsAvatar"),l=S.resolveComponent("VsTextEditor"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",KV,[S.createElementVNode("div",JV,[S.createElementVNode("div",QV,[S.createElementVNode("p",e6,[S.createVNode(u,{name:n.comment.username,avatar:n.comment.avatar},null,8,["name","avatar"]),S.createTextVNode(S.toDisplayString(n.comment.username),1)]),S.createElementVNode("div",t6,S.toDisplayString(a.createDate),1)])]),S.createElementVNode("p",{class:"text-gray-500 dark:text-gray-400",innerHTML:n.comment.body},null,8,n6),S.createElementVNode("div",i6,[S.createElementVNode("button",{type:"button",class:"block py-2 dark:hover:bg-gray-600 hover:underline dark:hover:text-white text-start duration-300",onClick:e[0]||(e[0]=_=>r.isOpen=!0)}," Редагувати "),S.createElementVNode("button",{type:"button",class:"block py-2 dark:hover:bg-gray-600 hover:underline dark:hover:text-white text-start duration-300",onClick:e[1]||(e[1]=_=>a.confirnDeleteComment())}," Видалити ")])]),S.createVNode(g,{visible:r.isOpen,"onUpdate:visible":e[5]||(e[5]=_=>r.isOpen=_),title:"Редагувати",size:"small"},{footer:S.withCtx(()=>[S.createElementVNode("div",s6,[S.createElementVNode("button",{onClick:e[3]||(e[3]=_=>r.isOpen=!1),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-black border rounded-lg !border-gray-200 hover:bg-gray-100 duration-300"}," Відмінити "),S.createElementVNode("button",{onClick:e[4]||(e[4]=(..._)=>a.updateComment&&a.updateComment(..._)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-[14px] font-[400] whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"}," Зберегти ")])]),default:S.withCtx(()=>[S.createElementVNode("div",r6,[e[6]||(e[6]=S.createTextVNode(" Коментар ")),S.createVNode(l,{modelValue:r.textareaValue,"onUpdate:modelValue":e[2]||(e[2]=_=>r.textareaValue=_),options:n.options},null,8,["modelValue","options"])])]),_:1},8,["visible"])],64)}const a6={components:{VsWidgetCommentsItem:_t(XV,[["render",o6]])},inject:["activeAddFormEditor"],props:{id:{type:String,default:()=>""},prefilledData:{type:Object,default:null},options:Array},data(){return{isLoaded:!1,isLoadFailed:!1,comments:[],user:{},modal:{title:"",message:"",cancel:"",confirm:"",cancelButtonText:"",confirmButtonText:""},isModalVisible:!1}},async created(){await this.getComments()},methods:{async getComments(){if(this.prefilledData){this.comments=this.prefilledData.rows,this.isLoaded=!0;return}try{const{data:t}=await wt.get(`/api/widget/comment/${this.id}`);this.comments=t.rows,this.user=t.user}catch(t){this.isLoadFailed=!0,console.error(t)}this.isLoaded=!0,this.$emit("update-comment-count")},prepareModal(t){const e={...t};return t.cancel||(e.cancel=()=>{this.isModalVisible=!1}),t.updateListOnConfirm&&(e.confirm=async()=>{await t.confirm(),this.isModalVisible=!1}),e},handleOpenModal(t){this.modal=this.prepareModal(t),this.isModalVisible=!0}}},l6={class:"flex flex-col divide-y"},c6={key:0,class:"max-h-[300px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},u6={key:1},h6={class:"p-4"},d6={class:"mt-1 text-gray-500 dark:text-neutral-500"},p6={class:"mt-4 flex justify-end gap-x-3"};function f6(t,e,n,i,r,a){const u=S.resolveComponent("VsErrorOnLoading"),l=S.resolveComponent("VsWidgetCommentsItem"),g=S.resolveComponent("VsLoader"),_=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock("div",l6,[r.isLoaded?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[r.isLoadFailed?(S.openBlock(),S.createBlock(u,{key:0})):(S.openBlock(),S.createElementBlock(S.Fragment,{key:1},[r.comments.length?(S.openBlock(),S.createElementBlock("div",c6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(r.comments,(k,E)=>(S.openBlock(),S.createBlock(l,{key:E,comment:k,user:r.user,options:n.options,index:E,id:n.id,onListUpdate:a.getComments,class:"border-top",onOpenModal:e[0]||(e[0]=T=>a.handleOpenModal(T))},null,8,["comment","user","options","index","id","onListUpdate"]))),128))])):(S.openBlock(),S.createElementBlock("div",u6,e[4]||(e[4]=[S.createElementVNode("p",{class:"pl-3 text-sm font-medium text-gray-600"}," Коментарі відсутні ",-1)])))],64))],64)):(S.openBlock(),S.createBlock(g,{key:1,class:"justify-center",text:"Please wait..."})),S.createVNode(_,{title:r.modal.title,size:"small",visible:r.isModalVisible,"onUpdate:visible":e[3]||(e[3]=k=>r.isModalVisible=k)},{default:S.withCtx(()=>[S.createElementVNode("div",h6,[S.createElementVNode("p",d6,S.toDisplayString(r.modal.message),1),S.createElementVNode("div",p6,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[1]||(e[1]=(...k)=>r.modal.cancel&&r.modal.cancel(...k))},S.toDisplayString(r.modal.cancelButtonText),1),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[2]||(e[2]=(...k)=>r.modal.confirm&&r.modal.confirm(...k))},S.toDisplayString(r.modal.confirmButtonText),1)])])]),_:1},8,["title","visible"])])}const m6=_t(a6,[["render",f6]]),g6={components:{VsTextEditor:cS},props:{id:{type:String,default:()=>""},autofocus:{type:Boolean,default:()=>!0},options:Array},data(){return{isEditorOpen:!1,commentContent:""}},methods:{async addNewComment(){if(this.commentContent)try{await wt.post(`/api/widget/comment/${this.id}`,{body:this.commentContent}),this.commentContent="",this.$emit("list-update")}catch(t){console.error(t)}},setNewContent(t){this.commentContent=t}}},y6={class:"w-full widget-comment-form"},_6={class:"mb-4 bg-white border-gray-200 dark:bg-gray-800 dark:border-gray-700"},b6={class:"flex justify-end"};function x6(t,e,n,i,r,a){const u=S.resolveComponent("VsTextEditor");return S.openBlock(),S.createElementBlock("div",y6,[S.createElementVNode("div",_6,[S.createVNode(u,{modelValue:r.commentContent,"onUpdate:modelValue":e[0]||(e[0]=l=>r.commentContent=l),options:n.options},null,8,["modelValue","options"])]),S.createElementVNode("div",b6,[S.createElementVNode("button",{ref:"buttonAdd",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300",onClick:e[1]||(e[1]=(...l)=>a.addNewComment&&a.addNewComment(...l))}," Відправити коментар ",512)])])}const v6={components:{VsWidgetCommentsList:m6,VsWidgetCommentsAddForm:_t(g6,[["render",x6]])},props:{id:{type:String,default(){return""}},prefilledData:{type:Object,default:null}},data(){return{activeAddFormEditor:"",comments:[],totalComment:"0",options:[]}},mounted(){this.comments=this.$refs.commentListRef.comments,this.getUsersList()},watch:{comments(t){this.$emit("count-change",t.length)}},methods:{async getUsersList(){try{const{data:t}=await wt.get("/api/suggest/core.user_mentioned");this.options=t}catch(t){console.log(t)}},listUpdate(){this.$refs.commentListRef.getComments()},updateCommentCount(){this.totalComment=this.$refs.commentListRef.comments.length||"0"}}},w6={class:"bg-white-200"};function k6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetCommentsAddForm"),l=S.resolveComponent("VsWidgetCommentsList");return S.openBlock(),S.createElementBlock("div",w6,[e[2]||(e[2]=S.createElementVNode("div",{class:"flex justify-between items-center gap-x-2 mb-4"},null,-1)),S.createVNode(u,{options:r.options,class:"mb-6",id:n.id,onListUpdate:e[0]||(e[0]=g=>a.listUpdate())},null,8,["options","id"]),S.createVNode(l,{options:r.options,id:n.id,onUpdateCommentCount:e[1]||(e[1]=g=>a.updateCommentCount()),"prefilled-data":n.prefilledData,ref:"commentListRef"},null,8,["options","id","prefilled-data"])])}const S6=_t(v6,[["render",k6]]),uS=t=>new Date(t).toLocaleDateString("uk-UK",{day:"numeric",month:"long",year:"numeric",hour:"numeric",minute:"numeric"}),E6=t=>new Date(t).toLocaleDateString("uk-UK",{day:"numeric",month:"numeric",year:"numeric",hour:"numeric",minute:"numeric"}),C6=t=>{const e=/(\b\S)?/g,n=t.match(e);return n?n.join("").toUpperCase():""},T6=S.defineComponent({props:{username:{type:String,default:()=>""}},computed:{inItials(){return C6(this.username)}}}),M6={class:"flex flex-shrink-0 items-center justify-center w-8 h-8 bg-gray-500 text-xs text-white rounded-full"};function A6(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",M6,S.toDisplayString(t.inItials),1)}const P6=_t(T6,[["render",A6]]),G0={load(){try{const t=Array.from(arguments);window.headLoadedFiles||(window.headLoadedFiles=[]);const e=typeof arguments[arguments.length-1]=="function"?arguments[arguments.length-1]:null,n=t.filter(i=>typeof i!="function").reduce((i,r)=>i.concat(r),[]).filter(i=>i&&!window.headLoadedFiles[i.url||i.split("?")[0]]);Promise.all(n.map(i=>this.loadFile1(i))).then(()=>{e&&e()})}catch(t){console.log(t)}},promise(t){return new Promise((e,n)=>{G0.load(t,()=>{e()})})},loadFile1(t){let e=!1;typeof t=="object"&&(e=t.type,t=t.url);const n=t.split("?")[0];return new Promise((i,r)=>{function a(l){delete window.headLoadedFiles[`_${n}`],window.headLoadedFiles[n]=l.type,i(l.type)}let u;window.headLoadedFiles[`_${n}`]?u=window.headLoadedFiles[`_${n}`]:(n.includes(".css")?(u=document.createElement("link"),u.href=t,u.type="text/css",u.rel="stylesheet"):(u=document.createElement("script"),u.type="text/javascript",u.src=t,e&&(u.type=e)),window.headLoadedFiles[`_${n}`]=u,document.head.appendChild(u)),u.addEventListener("load",a),u.addEventListener("error",a)})}},I6={props:{point:{type:String,default:()=>""}},data(){return{zoom:18}},computed:{parsedPoint(){return JSON.parse(this.point)},tooltipText(){return this.parsedPoint.coordinates.join(", ")},coordinates(){return[...this.parsedPoint.coordinates].reverse()}},async mounted(){typeof window>"u"||(window!=null&&window.L||(await G0.promise("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js"),await G0.promise("https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.9.4/leaflet.js")),this.initMap())},methods:{initMap(){const t=window.L.map("map",{center:this.coordinates,zoom:this.zoom});window.L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png").addTo(t),window.L.circle(this.coordinates,{color:"red",fillColor:"red",fillOpacity:.2,radius:10}).addTo(t).bindTooltip(this.tooltipText)}}},D6={id:"map",style:{height:"9rem",width:"24rem"}};function O6(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",D6)}const z6=_t(I6,[["render",O6]]),R6=S.defineComponent({components:{VsWidgetHistoryItemAvatar:P6,VsWidgetHistoryItemMap:z6},props:{item:{type:Object,default:()=>{}}},methods:{getTitle(t){return t.title||t.attr},getOldValue(t){return t.old||"Не вказано"},getNewValue(t){return t.new||"Не вказано"},getDate(t){return E6(t.cdate)}}}),L6={class:"relative [&_p]:m-0"},N6={class:"flex items-center gap-3"},B6={class:"w-full flex justify-between"},F6={class:"text-gray-500"},V6={class:"text-gray-800 font-medium"},$6={class:"text-gray-500 text-sm"},j6={class:"mt-2 pl-10"},U6={key:0},H6={key:1,class:"flex items-center gap-2 text-gray-700 text-sm"},q6={class:"font-medium"},W6={class:"font-medium"};function G6(t,e,n,i,r,a){const u=S.resolveComponent("VsWidgetHistoryItemAvatar"),l=S.resolveComponent("VsWidgetHistoryItemMap");return S.openBlock(),S.createElementBlock("div",L6,[S.createElementVNode("div",N6,[S.createVNode(u,{username:t.item.username},null,8,["username"]),S.createElementVNode("div",B6,[S.createElementVNode("p",F6,[S.createElementVNode("span",V6,S.toDisplayString(t.item.username),1),e[0]||(e[0]=S.createTextVNode(" змінив данні: "))]),S.createElementVNode("p",$6,S.toDisplayString(t.getDate(t.item)),1)])]),S.createElementVNode("div",j6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(t.item.changes,(g,_)=>(S.openBlock(),S.createElementBlock("div",{key:_},[g.attr==="geom"?(S.openBlock(),S.createElementBlock("div",U6,[e[1]||(e[1]=S.createElementVNode("p",null,"Додана геометрія:",-1)),g.new?(S.openBlock(),S.createBlock(l,{key:0,point:g.new},null,8,["point"])):S.createCommentVNode("",!0)])):(S.openBlock(),S.createElementBlock("div",H6,[S.createElementVNode("p",null,S.toDisplayString(`- ${t.getTitle(g)}:`),1),S.createElementVNode("p",q6,S.toDisplayString(t.getOldValue(g)),1),e[2]||(e[2]=S.createElementVNode("i",{class:"ti ti-arrow-right"},null,-1)),S.createElementVNode("p",W6,S.toDisplayString(t.getNewValue(g)),1)]))]))),128))])])}const Z6=_t(R6,[["render",G6]]),Y6=S.defineComponent({components:{VsWidgetHistoryItem:Z6,VsEmptyWidget:Sy},props:{id:{type:String,default:""},prefilledData:{type:Object,default:null}},data:()=>({history:{}}),computed:{createdDate(){return this.history.data?uS(this.history.data.cdate):""},lastEditDate(){return this.history.data?uS(this.history.data.edate):""},authorName(){return this.history.data?this.history.data.author:""}},methods:{async getHistoryData(){if(this.prefilledData){this.history=this.prefilledData;return}try{const{data:t}=await wt.get(`/api/widget/history/${this.id}`);this.history=t}catch(t){console.error(t)}}},async mounted(){await this.getHistoryData()},watch:{"history.rows":function(t){this.$emit("count-change",t.length)}}}),X6={class:"bg-white"},K6={key:0,class:"space-y-6 list-none relative !px-0 sm:before:absolute sm:before:top-2 sm:before:bottom-0 sm:before:w-0.5 sm:before:left-4 before:bg-gray-200 max-h-[400px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},J6={key:1,class:"w-full h-[330px] flex items-center justify-center"};function Q6(t,e,n,i,r,a){var l;const u=S.resolveComponent("VsWidgetHistoryItem");return S.openBlock(),S.createElementBlock("div",X6,[e[0]||(e[0]=S.createElementVNode("div",{class:"flex justify-between items-center gap-x-2 mb-4"},null,-1)),(l=t.history.rows)!=null&&l.length?(S.openBlock(),S.createElementBlock("ul",K6,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(t.history.rows,g=>(S.openBlock(),S.createElementBlock("li",{class:"list-none",key:g.uid},[S.createVNode(u,{item:g},null,8,["item"])]))),128))])):(S.openBlock(),S.createElementBlock("div",J6," Історія відсутні "))])}const e$={"vs-widget-map":Sz,"vs-widget-gallery":HR,"vs-widget-comments":S6,"vs-widget-file":CR,"vs-widget-history":_t(Y6,[["render",Q6]])},t$={},n$={style:{width:"calc(100vw - 300px)",height:"calc(100vh - 60px)"},class:"bg-gray-50 flex items-center justify-center"},i$={...e$,...t$,"vs-dashboard":{__name:"vs-dashboard",setup(t){return(e,n)=>(S.openBlock(),S.createElementBlock("div",n$,n[0]||(n[0]=[S.createElementVNode("div",{class:"p-5 md:p-8 bg-white border border-gray-200 shadow-sm rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"mb-4 xl:mb-8"},[S.createElementVNode("h1",{class:"text-lg font-semibold text-gray-800 dark:text-neutral-200"}," Members "),S.createElementVNode("p",{class:"text-sm text-gray-500 dark:text-neutral-500"}," Manage members and users of your workspace and set their access level. ")]),S.createElementVNode("div",{class:"space-y-5"},[S.createElementVNode("div",{class:"flex sm:grid sm:grid-cols-2 gap-x-2 sm:gap-x-5"},[S.createElementVNode("div",{class:"relative w-full"},[S.createElementVNode("div",{class:"absolute inset-y-0 start-0 flex items-center pointer-events-none z-20 ps-3.5"},[S.createElementVNode("svg",{class:"shrink-0 size-4 text-gray-500 dark:text-neutral-400",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("circle",{cx:"11",cy:"11",r:"8"}),S.createElementVNode("path",{d:"m21 21-4.3-4.3"})])]),S.createElementVNode("input",{type:"text",class:"py-2 ps-10 pe-8 block w-full bg-gray-100 border-transparent rounded-lg text-sm focus:border-blue-500 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-700 dark:border-transparent dark:text-neutral-400 dark:placeholder:text-neutral-400 dark:focus:ring-neutral-600",placeholder:"Search by name or email"}),S.createElementVNode("div",{class:"hidden absolute inset-y-0 end-0 flex items-center pointer-events-none z-20 pe-1"},[S.createElementVNode("button",{type:"button",class:"inline-flex shrink-0 justify-center items-center size-6 rounded-full text-gray-500 hover:text-blue-600 focus:outline-none focus:text-blue-600 dark:text-neutral-500 dark:hover:text-blue-500 dark:focus:text-blue-500","aria-label":"Close"},[S.createElementVNode("span",{class:"sr-only"},"Close"),S.createElementVNode("svg",{class:"shrink-0 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("circle",{cx:"12",cy:"12",r:"10"}),S.createElementVNode("path",{d:"m15 9-6 6"}),S.createElementVNode("path",{d:"m9 9 6 6"})])])])]),S.createElementVNode("div",{class:"flex justify-end items-center gap-x-2"},[S.createElementVNode("button",{type:"button",class:"p-2.5 sm:py-2 sm:px-3 inline-flex items-center text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createElementVNode("svg",{class:"shrink-0 sm:me-2 size-4",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),S.createElementVNode("polyline",{points:"7 10 12 15 17 10"}),S.createElementVNode("line",{x1:"12",x2:"12",y1:"15",y2:"3"})]),S.createElementVNode("span",{class:"hidden sm:block"}," Download CSV ")]),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-1 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:ring-2 focus:ring-blue-500","data-hs-overlay":"#hs-pro-dshm"},[S.createElementVNode("span",{class:"hidden sm:block"},"Send"),S.createTextVNode("Invite ")])])]),S.createElementVNode("div",{class:"grid sm:grid-cols-2 lg:grid-cols-4 gap-2 xl:gap-4"},[S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("img",{class:"shrink-0 size-7 rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Avatar"})])]),S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Admin")]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 5 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1679412330254-90cb240038c5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("img",{class:"shrink-0 size-7 shadow-md rounded-full",src:"https://images.unsplash.com/photo-1659482634023-2c4fda99ac0c?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," O ")])]),S.createElementVNode("div",{class:"inline-flex items-center gap-x-2"},[S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Members"),S.createElementVNode("div",{class:"hs-tooltip inline-block"},[S.createElementVNode("svg",{class:"hs-tooltip-toggle shrink-0 size-3.5 text-gray-500 dark:text-neutral-500",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},[S.createElementVNode("path",{d:"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"}),S.createElementVNode("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"})]),S.createElementVNode("div",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 w-60 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded dark:bg-neutral-700",role:"tooltip","data-popper-placement":"top",style:{position:"fixed",inset:"auto auto 0px 0px",margin:"0px",transform:"translate(689px, -708px)"}}," Limited Access Members can only access the projects, tasks, and messages explicitly shared with them. ")])])]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 2 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-7 bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," 0 ")])]),S.createElementVNode("div",{class:"inline-flex items-center gap-x-2"},[S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"}," Limited access members "),S.createElementVNode("div",{class:"hs-tooltip inline-block"},[S.createElementVNode("svg",{class:"hs-tooltip-toggle shrink-0 size-3.5 text-gray-500 dark:text-neutral-500",xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",fill:"currentColor",viewBox:"0 0 16 16"},[S.createElementVNode("path",{d:"M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14zm0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16z"}),S.createElementVNode("path",{d:"m8.93 6.588-2.29.287-.082.38.45.083c.294.07.352.176.288.469l-.738 3.468c-.194.897.105 1.319.808 1.319.545 0 1.178-.252 1.465-.598l.088-.416c-.2.176-.492.246-.686.246-.275 0-.375-.193-.304-.533L8.93 6.588zM9 4.5a1 1 0 1 1-2 0 1 1 0 0 1 2 0z"})]),S.createElementVNode("div",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 w-60 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded dark:bg-neutral-700",role:"tooltip","data-popper-placement":"top",style:{position:"fixed",inset:"auto auto 0px 0px",margin:"0px",transform:"translate(1198px, -708px)"}}," Limited Access Members can only access the projects, tasks, and messages explicitly shared with them. ")])])]),S.createElementVNode("div",{class:"p-4 flex flex-col bg-white border border-gray-200 rounded-xl dark:bg-neutral-800 dark:border-neutral-700"},[S.createElementVNode("div",{class:"flex justify-between items-center mb-1"},[S.createElementVNode("h2",{class:"text-4xl font-semibold text-gray-800 dark:text-neutral-200"}," 0 "),S.createElementVNode("div",{class:"flex items-center -space-x-2"})]),S.createElementVNode("h3",{class:"text-gray-500 dark:text-neutral-500"},"Pending invites")])]),S.createElementVNode("div",{class:"overflow-x-auto [&::-webkit-scrollbar]:h-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},[S.createElementVNode("div",{class:"min-w-full inline-block align-middle"},[S.createElementVNode("table",{class:"min-w-full divide-y divide-gray-200 dark:divide-neutral-700"},[S.createElementVNode("thead",null,[S.createElementVNode("tr",null,[S.createElementVNode("th",{scope:"col",class:"min-w-[250px]"},[S.createElementVNode("div",{class:"pe-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Member ")]),S.createElementVNode("th",{scope:"col",class:"min-w-48"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Role ")]),S.createElementVNode("th",{scope:"col"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Email ")]),S.createElementVNode("th",{scope:"col",class:"min-w-36"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Last activity ")]),S.createElementVNode("th",{scope:"col"},[S.createElementVNode("div",{class:"px-4 py-3 text-start flex items-center gap-x-1 text-sm font-medium text-gray-800 dark:text-neutral-200"}," Status ")])])]),S.createElementVNode("tbody",{class:"divide-y divide-gray-200 dark:divide-neutral-700"},[S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," James Collins ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Admin ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," james@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Today ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-x-1.5 py-1.5 px-2.5 text-xs font-medium bg-teal-100 text-teal-800 rounded-full dark:bg-teal-500/10 dark:text-teal-500"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-200"}),S.createTextVNode(" Active ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-[38px] bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," L "),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," James Collins ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can view ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," liza@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 2 days ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1601935111741-ae98b2b230b0?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Daniel Hobbs ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can edit ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," dhobbs@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Today ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("img",{class:"shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1679412330254-90cb240038c5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=2.5&w=320&h=320&q=80",alt:"Avatar"}),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Brian Warner ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can edit ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," brian@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 1 months ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-x-1.5 py-1.5 px-2.5 text-xs font-medium bg-teal-100 text-teal-800 rounded-full dark:bg-teal-500/10 dark:text-teal-500"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-200"}),S.createTextVNode(" Active ")])])]),S.createElementVNode("tr",null,[S.createElementVNode("td",{class:"size-px whitespace-nowrap pe-4 py-3"},[S.createElementVNode("div",{class:"w-full flex items-center gap-x-3"},[S.createElementVNode("span",{class:"flex shrink-0 justify-center items-center size-[38px] bg-white border border-gray-200 text-gray-700 text-xs font-medium uppercase rounded-full dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300"}," O "),S.createElementVNode("div",{class:"grow"},[S.createElementVNode("span",{class:"text-sm font-medium text-gray-800 dark:text-neutral-200"}," Ols Shols ")])])]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," Can view ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," olsshols@site.com ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"text-sm text-gray-600 dark:text-neutral-400"}," 6 days ago ")]),S.createElementVNode("td",{class:"size-px whitespace-nowrap px-4 py-3"},[S.createElementVNode("span",{class:"inline-flex items-center gap-1.5 py-1.5 px-2 text-xs font-medium bg-gray-100 text-gray-800 rounded-full dark:bg-neutral-500/20 dark:text-neutral-400"},[S.createElementVNode("span",{class:"size-1.5 inline-block bg-gray-800 rounded-full dark:bg-neutral-400"}),S.createTextVNode(" Inactive ")])])])])])])])])],-1)])))}}},r$={install(t,{componentsApp:e={},menu:n=[]}){var a;wt.defaults.baseURL&&(wt.defaults.baseURL=wt.defaults.baseURL);const i=(a=D1(n))==null?void 0:a.filter(u=>u==null?void 0:u.component).map(u=>({...u,component:e[u==null?void 0:u.component]})),{router:r}=iA(i);Object.entries({...i$,...e}).forEach(([u,l])=>{t.component(u,l)}),t.component("admin",kT),t.config.globalProperties={...t.config.globalProperties,$componentsConfig:{...$O,componentsApp:e},$router:r},t.use(r)}},Xr=S.ref(null),s$={data(){return{formValues:{},scheme:null,table:""}},mounted(){this.getFormScheme()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getFormScheme(){var i,r;const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(a=>{var u,l;return(a==null?void 0:a.path)==((l=(u=this.$route)==null?void 0:u.query)==null?void 0:l.table)});e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n;try{const{data:{form:a}}=await wt.get(`/api/template/table/${n}`),{data:{rows:u}}=await wt.get(`/api/table-data/${this.table}/${(r=(i=this.$route)==null?void 0:i.query)==null?void 0:r.id}`);this.formValues=u==null?void 0:u[0];const{data:l}=await wt.get(`/api/template/form/${a}`);this.scheme=(l==null?void 0:l.schema)||l}catch{}},async editObject(){var t,e;try{await this.$refs.form.doValidation(),await wt.put(`/api/table/${this.table}/${(e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.id}`,this.formValues),await this.$router.back(),await this.$notify({title:"Успішно!",message:"Об'єкт успішно створено",type:"success"})}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},o$={style:{width:"calc(100vw - 260px)"}},a$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},l$={class:"flex items-center gap-[6px]"},c$={style:{height:"calc(100vh - 140px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex"},u$={class:"bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function h$(t,e,n,i,r,a){const u=S.resolveComponent("VsForm");return S.openBlock(),S.createElementBlock("div",o$,[S.createElementVNode("div",a$,[e[3]||(e[3]=S.createElementVNode("h2",{class:"text-xl font-medium"},"Редагувати",-1)),S.createElementVNode("div",l$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=l=>t.$router.back()),class:"py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"}," Скасувати "),S.createElementVNode("button",{onClick:e[1]||(e[1]=(...l)=>a.editObject&&a.editObject(...l)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"}," Зберегти ")])]),S.createElementVNode("div",c$,[S.createElementVNode("div",u$,[r.scheme?(S.openBlock(),S.createBlock(u,{key:0,ref:"form",scheme:r.scheme,modelValue:r.formValues,"onUpdate:modelValue":e[2]||(e[2]=l=>r.formValues=l),class:"p-0 mt-[20px]"},null,8,["scheme","modelValue"])):S.createCommentVNode("",!0)])])])}const d$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(s$,[["render",h$]])},Symbol.toStringTag,{value:"Module"})),p$={data(){return{formValues:{},scheme:null,table:""}},mounted(){this.getFormScheme()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getFormScheme(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(i=>{var r,a;return(i==null?void 0:i.path)==((a=(r=this.$route)==null?void 0:r.query)==null?void 0:a.table)});e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n;try{const{data:{form:i}}=await wt.get(`/api/template/table/${n}`),{data:r}=await wt.get(`/api/template/form/${i}`);this.scheme=(r==null?void 0:r.schema)||r}catch{}},async createObject(){try{await this.$refs.form.doValidation(),await wt.post(`/api/table/${this.table}`,this.formValues),await this.$router.back(),await this.$notify({title:"Успішно!",message:"Об'єкт успішно створено",type:"success"})}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},f$={style:{width:"calc(100vw - 260px)"}},m$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},g$={class:"flex items-center gap-[6px]"},y$={style:{height:"calc(100vh - 150px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex"},_$={class:"bg-white w-full rounded-xl border p-[20px] overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function b$(t,e,n,i,r,a){const u=S.resolveComponent("VsForm");return S.openBlock(),S.createElementBlock("div",f$,[S.createElementVNode("div",m$,[e[3]||(e[3]=S.createElementVNode("h2",{class:"text-xl font-medium"},"Створити",-1)),S.createElementVNode("div",g$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=l=>t.$router.back()),class:"py-2 px-3 flex items-center gap-x-2 text-sm font-medium rounded-lg border bg-white border-gray-100 text-gray-800 shadow focus:outline-none hover:bg-gray-50 hover:border-gray-100 duration-300"}," Скасувати "),S.createElementVNode("button",{onClick:e[1]||(e[1]=(...l)=>a.createObject&&a.createObject(...l)),class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"}," Зберегти ")])]),S.createElementVNode("div",y$,[S.createElementVNode("div",_$,[r.scheme?(S.openBlock(),S.createBlock(u,{key:0,ref:"form",scheme:r.scheme,modelValue:r.formValues,"onUpdate:modelValue":e[2]||(e[2]=l=>r.formValues=l),class:"p-0 mt-[20px]"},null,8,["scheme","modelValue"])):S.createCommentVNode("",!0)])])])}const x$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(p$,[["render",b$]])},Symbol.toStringTag,{value:"Module"})),v$={};function w$(t,e,n,i,r,a){const u=S.resolveComponent("router-view");return S.openBlock(),S.createBlock(u)}const hS=Object.freeze(Object.defineProperty({__proto__:null,default:_t(v$,[["render",w$]])},Symbol.toStringTag,{value:"Module"})),k$={data(){return{objectData:null,component:""}},computed:{getRoute(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(n=>{var i,r;return(n==null?void 0:n.table)==((r=(i=this.$route)==null?void 0:i.params)==null?void 0:r.table)});return e||this.$router.replace("/404"),e==null?void 0:e.path},getTitle(){var t,e,n,i,r,a,u,l,g,_,k,E,T,I,z;if((n=(e=(t=this.objectData)==null?void 0:t.rows)==null?void 0:e[0])!=null&&n.name)return((u=(a=(r=(i=this.objectData)==null?void 0:i.rows)==null?void 0:r[0])==null?void 0:a.name)==null?void 0:u.length)<35?(_=(g=(l=this.objectData)==null?void 0:l.rows)==null?void 0:g[0])==null?void 0:_.name:((I=(T=(E=(k=this.objectData)==null?void 0:k.rows)==null?void 0:E[0])==null?void 0:T.name)==null?void 0:I.slice(0,35))+" ...";{const V=(z=this.flattenMenu(Xr.value))==null?void 0:z.find(H=>{var Z,ee;return(H==null?void 0:H.table)===((ee=(Z=this.$route)==null?void 0:Z.params)==null?void 0:ee.table)});return V==null?void 0:V.ua}}},async mounted(){await this.getObjectData(),await this.checkActiveComponent()},watch:{component(t){this.$router.replace({...this.$route,query:{tab:t}})}},methods:{async getObjectData(){var n;const{table:t,id:e}=(n=this.$route)==null?void 0:n.params;(!t||!e)&&this.$router.replace("/404");try{const{data:i}=await wt.get(`/api/table-data/${t}/${e}`);this.objectData=i}catch(i){console.error(i)}},getColClass(t){return`col-span-${t||12}`},getGridClass(){return"grid-cols-12"},checkActiveComponent(){var t,e,n,i,r,a,u,l,g;if((e=(t=this.$route)==null?void 0:t.query)!=null&&e.tab)this.component=(i=(n=this.$route)==null?void 0:n.query)==null?void 0:i.tab;else{const _=(a=(r=this.objectData)==null?void 0:r.panels)==null?void 0:a.find(k=>(k==null?void 0:k.type)==="tabs");(u=_==null?void 0:_.items)!=null&&u.length&&(this.component=((l=_.items[0])==null?void 0:l.component)||((g=_.items[0])==null?void 0:g.name))}},flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e}}},S$={style:{width:"calc(100vw - 260px)",height:"calc(100vh - 60px)"},class:"bg-gray-50 overflow-y-auto"},E$={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},C$={class:""},T$={class:"text-lg md:text-xl font-semibold text-stone-800 dark:text-neutral-200"},M$={class:"flex items-center gap-[6px]"},A$={key:0,class:"border rounded-xl bg-white"},P$={class:"p-[10px] pl-[20px] text-xl"},I$=["innerHTML"],D$={key:1},O$={class:"p-[10px] pl-[20px] text-xl"},z$={key:0,class:"p-[20px] border-t"},R$={key:1,class:"p-[20px] border-t"},L$=["innerHTML"],N$={class:"flex space-x-1 w-full bg-white border rounded-xl h-[60px] items-center pl-[20px]"},B$=["onClick"],F$={key:0,class:"border rounded-xl bg-white mt-[20px]"},V$={class:"p-[10px] pl-[20px] text-xl"},$$={key:0,class:"p-[20px] border-t"},j$={key:1,class:"p-[20px] border-t"},U$=["innerHTML"];function H$(t,e,n,i,r,a){var l,g,_;const u=S.resolveComponent("router-link");return S.openBlock(),S.createElementBlock("div",S$,[S.createElementVNode("div",E$,[S.createElementVNode("div",C$,[S.createElementVNode("button",{onClick:e[0]||(e[0]=k=>t.$router.back()),class:"text-sm h-[20px] text-blue-600 font-medium hover:border-b hover:border-b-2 hover:border-b-blue-500"}," До таблиці "),S.createElementVNode("h2",T$,S.toDisplayString(a.getTitle),1)]),S.createElementVNode("div",M$,[S.createVNode(u,{to:`/edit?table=${a.getRoute}&id=${(g=(l=t.$route)==null?void 0:l.params)==null?void 0:g.id}`,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},{default:S.withCtx(()=>e[1]||(e[1]=[S.createTextVNode(" Редагувати ")])),_:1},8,["to"])])]),S.createElementVNode("div",{class:S.normalizeClass(["grid gap-[20px]",a.getGridClass()])},[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((_=r.objectData)==null?void 0:_.panels,(k,E)=>{var T;return S.openBlock(),S.createElementBlock("div",{key:E,class:S.normalizeClass([a.getColClass(k.col),"p-4"])},[k!=null&&k.name?(S.openBlock(),S.createElementBlock("div",A$,[S.createElementVNode("h2",P$,S.toDisplayString((k==null?void 0:k.title)||"Панель"),1),S.createElementVNode("div",{class:"p-[20px] border-t",innerHTML:(T=r.objectData)==null?void 0:T.data[k==null?void 0:k.name]},null,8,I$)])):k.type==="container"?(S.openBlock(),S.createElementBlock("div",D$,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k.items,(I,z)=>{var V,H,Z,ee,oe;return S.openBlock(),S.createElementBlock("div",{key:z,class:"border rounded-xl bg-white mb-[20px]"},[S.createElementVNode("h2",O$,S.toDisplayString((I==null?void 0:I.title)||"Панель"),1),I!=null&&I.component?(S.openBlock(),S.createElementBlock("div",z$,[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(I.component),{geometry:(H=(V=r.objectData)==null?void 0:V.rows[0])==null?void 0:H.geom,zoom:16,id:(ee=(Z=t.$route)==null?void 0:Z.params)==null?void 0:ee.id},null,8,["geometry","id"]))])):S.createCommentVNode("",!0),I!=null&&I.name?(S.openBlock(),S.createElementBlock("div",R$,[S.createElementVNode("div",{innerHTML:(oe=r.objectData)==null?void 0:oe.data[I==null?void 0:I.name]},null,8,L$)])):S.createCommentVNode("",!0)])}),128))])):S.createCommentVNode("",!0),(k==null?void 0:k.type)==="tabs"?(S.openBlock(),S.createElementBlock(S.Fragment,{key:2},[S.createElementVNode("nav",N$,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k==null?void 0:k.items,I=>(S.openBlock(),S.createElementBlock("button",{key:(I==null?void 0:I.name)||(I==null?void 0:I.component),onClick:z=>r.component=(I==null?void 0:I.component)||(I==null?void 0:I.name),class:S.normalizeClass(["px-2.5 h-[30px] py-1.5 relative inline-flex items-center gap-x-2 text-gray-500 hover:bg-gray-100 focus:bg-gray-100 hover:text-gray-800 text-sm whitespace-nowrap rounded-lg focus:outline-none",{" font-semibold after:absolute after:bottom-[-14px] after:left-2.5 after:right-2.5 after:z-10 after:h-0.5 after:bg-gray-800":r.component===(I==null?void 0:I.component)||r.component===(I==null?void 0:I.name),"":r.component!==(I==null?void 0:I.component)&&r.component!==(I==null?void 0:I.name)}])},S.toDisplayString(I==null?void 0:I.title),11,B$))),128))]),(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(k.items,(I,z)=>{var V,H,Z,ee,oe;return S.openBlock(),S.createElementBlock(S.Fragment,{key:z},[r.component===(I==null?void 0:I.component)||r.component===(I==null?void 0:I.name)?(S.openBlock(),S.createElementBlock("div",F$,[S.createElementVNode("h2",V$,S.toDisplayString((I==null?void 0:I.title)||"Панель"),1),I!=null&&I.component?(S.openBlock(),S.createElementBlock("div",$$,[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(I.component),{geometry:(H=(V=r.objectData)==null?void 0:V.rows[0])==null?void 0:H.geom,zoom:16,id:(ee=(Z=t.$route)==null?void 0:Z.params)==null?void 0:ee.id},null,8,["geometry","id"]))])):S.createCommentVNode("",!0),I!=null&&I.name?(S.openBlock(),S.createElementBlock("div",j$,[S.createElementVNode("div",{innerHTML:(oe=r.objectData)==null?void 0:oe.data[I==null?void 0:I.name]},null,8,U$)])):S.createCommentVNode("",!0)])):S.createCommentVNode("",!0)],64)}),128))],64)):S.createCommentVNode("",!0)],2)}),128))],2)])}const q$=Object.freeze(Object.defineProperty({__proto__:null,default:_t(k$,[["render",H$],["__scopeId","data-v-fe670fc5"]])},Symbol.toStringTag,{value:"Module"})),W$={},G$={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-logout"};function Z$(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",G$,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M14 8v-2a2 2 0 0 0 -2 -2h-7a2 2 0 0 0 -2 2v12a2 2 0 0 0 2 2h7a2 2 0 0 0 2 -2v-2"},null,-1),S.createElementVNode("path",{d:"M9 12h12l-3 -3"},null,-1),S.createElementVNode("path",{d:"M18 15l3 -3"},null,-1)]))}const Y$=_t(W$,[["render",Z$]]),X$={},K$={viewBox:"0 0 1823 249",fill:"none",xmlns:"http://www.w3.org/2000/svg"};function J$(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",K$,e[0]||(e[0]=[S.createStaticVNode('<path d="M218.88 96.05C223.55 99.19 228.69 101.56 234.09 103.07V145.42C212.05 151.54 195.83 171.79 195.83 195.75C195.83 200.22 196.41 204.65 197.53 208.94L160.92 230.08C156.82 226.06 152.08 222.73 146.91 220.24V171.62C164.83 163.13 176.59 145.06 176.59 124.48C176.59 123.17 176.54 121.86 176.44 120.56L218.88 96.05ZM220.32 79.09L160.97 113.36C162.04 116.88 162.61 120.61 162.61 124.48C162.61 142.66 149.93 157.87 132.93 161.76V230.05C143.4 232.46 152.23 239.16 157.46 248.21L215 214.99C211.7 209.34 209.81 202.77 209.81 195.75C209.81 174.62 226.94 157.49 248.07 157.49V91.02C237.14 91.02 227.29 86.43 220.32 79.09Z" fill="#CE3936"></path><path d="M161.39 19.13L197.44 39.94C196.39 44.11 195.84 48.42 195.84 52.75C195.84 54.21 195.9 55.65 196.02 57.1L153.9 81.42C145.27 75.5 134.95 72.24 124.36 72.24C113.83 72.24 103.57 75.47 94.96 81.32L52.71 56.93C52.82 55.55 52.88 54.16 52.88 52.76C52.88 48.43 52.34 44.12 51.28 39.95L87.3 19.16C96.98 28.89 110.26 34.58 124.34 34.58C138.42 34.57 151.7 28.87 161.39 19.13ZM157.77 0.919983C151.24 12.66 138.71 20.6 124.33 20.6C109.95 20.6 97.44 12.67 90.9 0.939983L33.9 33.85C37.08 39.43 38.91 45.88 38.91 52.76C38.91 56.71 38.31 60.52 37.2 64.11L96.46 98.32C103.44 90.87 113.36 86.22 124.37 86.22C135.44 86.22 145.41 90.93 152.39 98.44L211.59 64.27C210.45 60.64 209.83 56.78 209.83 52.77C209.83 45.89 211.65 39.44 214.84 33.86L157.77 0.919983Z" fill="#CE3936"></path><path d="M29.97 95.95L72.28 120.38C72.17 121.74 72.12 123.1 72.12 124.47C72.12 145.02 83.86 163.08 101.74 171.58V220.23C96.58 222.71 91.84 226.04 87.75 230.05L51.17 208.93C52.29 204.64 52.87 200.21 52.87 195.74C52.87 171.78 36.65 151.53 14.61 145.41V103.06C20.07 101.55 25.27 99.14 29.97 95.95ZM28.5 78.97C21.52 86.38 11.63 91.02 0.640015 91.02V157.49C21.77 157.49 38.9 174.62 38.9 195.75C38.9 202.77 37 209.33 33.71 214.99L91.2 248.18C96.43 239.14 105.25 232.45 115.71 230.04V161.73C98.74 157.81 86.09 142.62 86.09 124.46C86.09 120.54 86.68 116.75 87.78 113.18L28.5 78.97Z" fill="#CE3936"></path><path d="M498.39 177.5V144.88C498.39 128.55 485.11 115.27 468.78 115.27H343.22C342.69 115.27 342.18 115.32 341.67 115.4H337.19C332.35 115.4 328.42 111.46 328.42 106.63V74C328.42 69.16 332.36 65.23 337.19 65.23H486.33C492.08 65.23 496.75 60.57 496.75 54.81C496.75 49.06 492.08 44.39 486.33 44.39H337.19C320.86 44.39 307.58 57.67 307.58 74V106.62C307.58 122.95 320.86 136.23 337.19 136.23H462.75C463.28 136.23 463.79 136.18 464.3 136.1H468.78C473.62 136.1 477.55 140.04 477.55 144.87V177.49C477.55 182.33 473.61 186.26 468.78 186.26H319.64C313.89 186.26 309.22 190.92 309.22 196.68C309.22 202.43 313.89 207.1 319.64 207.1H468.78C485.11 207.11 498.39 193.83 498.39 177.5Z" fill="#CE3935"></path><path d="M710.7 177.32V75.24C710.7 58.91 697.42 45.63 681.09 45.63H550.05C533.72 45.63 520.44 58.91 520.44 75.24V177.32C520.44 193.65 533.72 206.93 550.05 206.93H681.1C697.42 206.93 710.7 193.65 710.7 177.32ZM541.27 75.24C541.27 70.4 545.21 66.47 550.04 66.47H681.09C685.93 66.47 689.86 70.41 689.86 75.24V177.32C689.86 182.16 685.92 186.09 681.09 186.09H550.05C545.21 186.09 541.28 182.15 541.28 177.32V75.24H541.27Z" fill="#CE3935"></path><path d="M1823 177.32V75.24C1823 58.91 1809.72 45.63 1793.39 45.63H1662.34C1646.01 45.63 1632.73 58.91 1632.73 75.24V177.32C1632.73 193.65 1646.01 206.93 1662.34 206.93H1793.39C1809.72 206.93 1823 193.65 1823 177.32ZM1653.57 75.24C1653.57 70.4 1657.51 66.47 1662.34 66.47H1793.39C1798.23 66.47 1802.16 70.41 1802.16 75.24V177.32C1802.16 182.16 1798.22 186.09 1793.39 186.09H1662.34C1657.5 186.09 1653.57 182.15 1653.57 177.32V75.24Z" fill="#CE3935"></path><path d="M756.76 196.51V152H849.42C855.17 152 859.84 147.34 859.84 141.58C859.84 135.83 855.17 131.16 849.42 131.16H756.76V75.23C756.76 70.39 760.7 66.46 765.53 66.46H893.29C899.04 66.46 903.71 61.8 903.71 56.04C903.71 50.29 899.04 45.62 893.29 45.62H765.53C749.2 45.62 735.92 58.9 735.92 75.23V196.5C735.92 202.25 740.59 206.92 746.34 206.92C752.09 206.93 756.76 202.27 756.76 196.51Z" fill="#CE3935"></path><path d="M933.86 66.47H1006.51V194.32C1006.51 200.07 1011.18 204.74 1016.93 204.74C1022.68 204.74 1027.35 200.07 1027.35 194.32V66.47H1100C1105.75 66.47 1110.42 61.81 1110.42 56.05C1110.42 50.3 1105.76 45.63 1100 45.63H933.86C928.11 45.63 923.44 50.29 923.44 56.05C923.45 61.81 928.11 66.47 933.86 66.47Z" fill="#CE3935"></path><path d="M1218.44 204.19C1224.19 204.19 1228.86 199.53 1228.86 193.77V152H1368.13C1384.46 152 1397.74 138.72 1397.74 122.39V75.24C1397.74 58.91 1384.46 45.63 1368.13 45.63H1237.63C1221.3 45.63 1208.02 58.91 1208.02 75.24V193.77C1208.02 199.53 1212.68 204.19 1218.44 204.19ZM1237.63 66.47H1368.13C1372.97 66.47 1376.9 70.41 1376.9 75.24V122.39C1376.9 127.23 1372.96 131.16 1368.13 131.16H1228.86V75.23C1228.86 70.41 1232.79 66.47 1237.63 66.47Z" fill="#CE3935"></path><path d="M1430.64 204.19C1436.39 204.19 1441.06 199.53 1441.06 193.77V152H1523.95C1524.57 153.18 1525.42 154.26 1526.51 155.17L1581.89 201.23C1583.83 202.85 1586.2 203.64 1588.55 203.64C1591.54 203.64 1594.5 202.36 1596.57 199.88C1600.25 195.46 1599.64 188.89 1595.22 185.21L1555.29 152H1580.33C1596.66 152 1609.94 138.72 1609.94 122.39V75.24C1609.94 58.91 1596.66 45.63 1580.33 45.63H1449.83C1433.5 45.63 1420.22 58.91 1420.22 75.24V193.77C1420.22 199.53 1424.88 204.19 1430.64 204.19ZM1449.83 66.47H1580.33C1585.17 66.47 1589.1 70.41 1589.1 75.24V122.39C1589.1 127.23 1585.17 131.16 1580.33 131.16H1441.06V75.23C1441.05 70.41 1444.99 66.47 1449.83 66.47Z" fill="#CE3935"></path>',10)]))}const Q$=_t(X$,[["render",J$]]),e8={},t8={class:"shrink-0 size-4 text-gray-400 dark:text-white/60",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"};function n8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",t8,e[0]||(e[0]=[S.createElementVNode("circle",{cx:"11",cy:"11",r:"8"},null,-1),S.createElementVNode("path",{d:"m21 21-4.3-4.3"},null,-1)]))}const dS=_t(e8,[["render",n8]]),i8={},r8={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-chevron-down"};function s8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",r8,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M6 9l6 6l6 -6"},null,-1)]))}const o8={components:{IconChevronDown:_t(i8,[["render",s8]])},props:{route:Object},mounted(){var t,e,n;(t=this.route)!=null&&t.menu&&(n=(e=this.route)==null?void 0:e.menu)!=null&&n.some(i=>{var r,a;return(i==null?void 0:i.path)===this.$route.path.replace("/","")||((a=(r=this.$route)==null?void 0:r.params)==null?void 0:a.table)===(i==null?void 0:i.table)&&(i==null?void 0:i.table)})&&(this.isOpen=!0)},data(){return{isOpen:!1}}},a8={key:0,class:""},l8={class:"ml-[30px] py-[6px] before:block before:absolute relative w-[196px] flex flex-col gap-[6px] inline-block before:w-[2px] before:h-[100%] before:bg-gray-100 before:left-[-14px] cursor-pointer"},c8={key:1};function u8(t,e,n,i,r,a){var g,_,k,E,T,I,z,V,H,Z;const u=S.resolveComponent("IconChevronDown"),l=S.resolveComponent("router-link");return(g=n.route)!=null&&g.menu?(S.openBlock(),S.createElementBlock("div",a8,[S.createElementVNode("button",{onClick:e[0]||(e[0]=ee=>r.isOpen=!r.isOpen),class:S.normalizeClass(["flex cursor-pointer gap-x-3 py-2 px-3 text-sm text-gray-800 justify-start w-full border-none focus:outline-none text-gray-800 rounded-lg items-center hover:bg-gray-100 duration-300",[((k=(_=n.route)==null?void 0:_.menu)==null?void 0:k.some(ee=>{var oe,J;return(ee==null?void 0:ee.path)===t.$route.path.replace("/","")||(ee==null?void 0:ee.table)===((J=(oe=t.$route)==null?void 0:oe.params)==null?void 0:J.table)&&(ee==null?void 0:ee.table)}))&&"bg-gray-100"]])},[S.createTextVNode(S.toDisplayString((E=n.route)==null?void 0:E.ua)+" ",1),S.createVNode(u,{class:S.normalizeClass([[r.isOpen&&"-rotate-180"],"ml-auto duration-300"]),width:"14",height:"14"},null,8,["class"])],2),S.createVNode(S.Transition,{name:"fade"},{default:S.withCtx(()=>{var ee;return[S.withDirectives(S.createElementVNode("ul",l8,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((ee=n.route)==null?void 0:ee.menu,(oe,J)=>{var Ae,ke;return S.openBlock(),S.createElementBlock("li",{key:J,class:"w-full"},[S.createVNode(l,{to:"/"+(oe==null?void 0:oe.path),class:S.normalizeClass([[((oe==null?void 0:oe.path)===t.$route.path.replace("/","")||((ke=(Ae=t.$route)==null?void 0:Ae.params)==null?void 0:ke.table)===(oe==null?void 0:oe.table)&&(oe==null?void 0:oe.table))&&"bg-gray-100"],"flex gap-x-4 py-2 px-3 text-sm text-gray-800 rounded-lg hover:bg-gray-100 focus:outline-none focus:bg-gray-100"])},{default:S.withCtx(()=>[S.createTextVNode(S.toDisplayString(oe==null?void 0:oe.ua),1)]),_:2},1032,["to","class"])])}),128))],512),[[S.vShow,r.isOpen]])]}),_:1})])):(S.openBlock(),S.createElementBlock("div",c8,[S.createVNode(l,{to:(T=n.route)==null?void 0:T.path,class:S.normalizeClass([[(((I=n.route)==null?void 0:I.path.replace("/",""))===t.$route.path.replace("/","")||((V=(z=t.$route)==null?void 0:z.params)==null?void 0:V.table)===((H=n.route)==null?void 0:H.table)&&((Z=n.route)==null?void 0:Z.table))&&"bg-gray-100"],"flex gap-x-3 py-2 w-full font-[400] px-3 text-sm text-gray-800 rounded-lg items-center hover:bg-gray-100 duration-300 hover:text-gray-800"])},{default:S.withCtx(()=>{var ee;return[S.createTextVNode(S.toDisplayString((ee=n.route)==null?void 0:ee.ua),1)]}),_:1},8,["to","class"])]))}const h8={components:{IconLogout:Y$,NavbarItem:_t(o8,[["render",u8]]),IconLogo:Q$,IconSearch:dS},data(){return{activeIndex:null,data:null,searchValue:""}},computed:{data(){var t,e;return(t=this.searchValue)!=null&&t.trim()?(e=this.flattenMenu(Xr.value))==null?void 0:e.filter(n=>{var i,r,a;return(a=(i=n==null?void 0:n.ua)==null?void 0:i.toLowerCase())==null?void 0:a.includes((r=this.searchValue)==null?void 0:r.toLowerCase())}):Xr.value}},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e}}},d8={class:"flex flex-col h-[100vh] border-r w-[260px] shrink-0"},p8={class:"relative"},f8={class:"p-[16px] overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},m8={class:"pb-3 w-full flex flex-col flex-wrap"},g8={key:0,class:"flex flex-col gap-[6px]"},y8={key:1,class:"text-gray-800 text-lg mt-[20px]"};function _8(t,e,n,i,r,a){var k;const u=S.resolveComponent("IconLogo"),l=S.resolveComponent("IconSearch"),g=S.resolveComponent("VsText"),_=S.resolveComponent("NavbarItem");return S.openBlock(),S.createElementBlock("div",d8,[S.createVNode(u,{height:"40",width:"200",class:"my-[20px] ml-[20px]"}),S.createElementVNode("div",p8,[S.createVNode(l,{height:"16",width:"16",class:"absolute top-[12px] left-[30px] text-gray-500 z-[1]"}),S.createVNode(g,{type:"text",modelValue:r.searchValue,"onUpdate:modelValue":e[0]||(e[0]=E=>r.searchValue=E),clearable:!0,placeholder:"Пошук по меню",class:"[&>input]:h-[40px] [&>input]:block [&>input]:rounded-none [&>input]:border-x-0 [&>input]:pl-[60px] [&>input:focus]:outline-none [&>input:focus]:focus:ring-0 [&>input:focus]:border-y-gray-200 [&>input:focus]:border-y-1 [&>input:focus]:border-x-0"},null,8,["modelValue"])]),S.createElementVNode("div",f8,[S.createElementVNode("nav",m8,[(k=a.data)!=null&&k.length?(S.openBlock(),S.createElementBlock("ul",g8,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.data,(E,T)=>(S.openBlock(),S.createElementBlock("li",{key:T,class:"flex flex-col gap-[6px]"},[S.createVNode(_,{route:E},null,8,["route"])]))),128))])):(S.openBlock(),S.createElementBlock("div",y8,"Не знайдено"))])])])}const b8=_t(h8,[["render",_8]]),x8={},v8={class:"flex-shrink-0 size-4",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"};function w8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",v8,e[0]||(e[0]=[S.createElementVNode("circle",{cx:"12",cy:"12",r:"10"},null,-1),S.createElementVNode("path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"},null,-1),S.createElementVNode("path",{d:"M12 17h.01"},null,-1)]))}const k8=_t(x8,[["render",w8]]),S8={},E8={class:"flex-shrink-0 size-4",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"};function C8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",E8,e[0]||(e[0]=[S.createElementVNode("path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"},null,-1),S.createElementVNode("path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0"},null,-1)]))}const T8={components:{IconQuestion:k8,IconMessage:_t(S8,[["render",C8]])}},M8={class:"h-[60px] border-b flex justify-end px-[20px]",style:{width:"calc(100vw - 260px)"}},A8={class:"flex items-center gap-[6px]"},P8={href:"docs-softpro.com",class:"size-[38px] inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-100 dark:text-neutral-400 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},I8={class:"hs-tooltip [--placement:bottom] inline-block show"},D8={class:"hs-tooltip-toggle relative size-[38px] inline-flex justify-center items-center gap-x-2 rounded-full border border-transparent text-gray-500 hover:bg-gray-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-100"};function O8(t,e,n,i,r,a){const u=S.resolveComponent("IconQuestion"),l=S.resolveComponent("IconMessage");return S.openBlock(),S.createElementBlock("div",M8,[S.createElementVNode("div",A8,[S.createElementVNode("a",P8,[S.createVNode(u,{height:"24",width:"24"})]),S.createElementVNode("div",I8,[S.createElementVNode("button",D8,[S.createVNode(l,{height:"24",width:"24"}),e[0]||(e[0]=S.createElementVNode("span",{class:"flex absolute top-0 end-0 -mt-1.5 -me-1.5"},[S.createElementVNode("span",{class:"animate-ping absolute inline-flex size-full rounded-full bg-red-400 opacity-75 dark:bg-red-600"}),S.createElementVNode("span",{class:"relative min-w-[18px] min-h-[18px] inline-flex justify-center items-center text-[10px] bg-red-500 text-white rounded-full px-1"}," 1 ")],-1))]),e[1]||(e[1]=S.createElementVNode("span",{class:"hs-tooltip-content hs-tooltip-shown:opacity-100 hs-tooltip-shown:visible opacity-0 inline-block absolute invisible z-20 py-1.5 px-2.5 bg-gray-900 text-xs text-white rounded-lg dark:bg-neutral-700 hidden",role:"tooltip","data-popper-placement":"bottom",style:{position:"fixed",inset:"0px auto auto 0px",margin:"0px",transform:"translate(1686px, 53px)"}},null,-1))]),e[2]||(e[2]=S.createElementVNode("div",{class:"h-[30px] w-[1px] bg-gray-200 ml-[10px] mr-[10px]"},null,-1)),e[3]||(e[3]=S.createElementVNode("img",{class:"flex-shrink-0 size-[38px] rounded-full",src:"https://images.unsplash.com/photo-1659482633369-9fe69af50bfb?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=facearea&facepad=3&w=320&h=320&q=80",alt:"Image Description"},null,-1))])])}const z8={components:{navbar:b8,AdminHeader:_t(T8,[["render",O8]])},mounted(){this.getMenu()},computed:{isMenu(){return Xr.value}},methods:{async getMenu(){try{const{data:t}=await wt.get("/api/user-menu");Xr.value=t}catch{}}}},R8={class:"admin-wrapper"},L8={class:"flex flex-col"};function N8(t,e,n,i,r,a){const u=S.resolveComponent("navbar"),l=S.resolveComponent("admin-header"),g=S.resolveComponent("router-view");return S.openBlock(),S.createElementBlock("div",R8,[S.createVNode(u),S.createElementVNode("div",L8,[a.isMenu?(S.openBlock(),S.createElementBlock(S.Fragment,{key:0},[S.createVNode(l),S.createVNode(g)],64)):S.createCommentVNode("",!0)])])}const B8=Object.freeze(Object.defineProperty({__proto__:null,default:_t(z8,[["render",N8],["__scopeId","data-v-c3c91323"]])},Symbol.toStringTag,{value:"Module"})),F8={},V8={class:"h21yx vs0hq",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"};function $8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",V8,e[0]||(e[0]=[S.createStaticVNode('<line x1="21" x2="14" y1="4" y2="4"></line><line x1="10" x2="3" y1="4" y2="4"></line><line x1="21" x2="12" y1="12" y2="12"></line><line x1="8" x2="3" y1="12" y2="12"></line><line x1="21" x2="16" y1="20" y2="20"></line><line x1="12" x2="3" y1="20" y2="20"></line><line x1="14" x2="14" y1="2" y2="6"></line><line x1="8" x2="8" y1="10" y2="14"></line><line x1="16" x2="16" y1="18" y2="22"></line>',9)]))}const j8=_t(F8,[["render",$8]]),U8={data(){return{currentSort:""}},props:{data:{type:Object,default:()=>null},activeColumn:{type:String}},computed:{label(){var t,e;return((t=this.data)==null?void 0:t.ua)||((e=this.data)==null?void 0:e.label)||this.data.title||"null"},selectedSortParam(){var t,e;return(e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.sort},getVisibleIcon(){return this.data.format!=="image"&&this.data.format!=="verify"}},watch:{activeColumn(t){t!==this.data.name&&(this.currentSort="")}},methods:{changeCurrentSort(t){switch(t){case"":return"asc";case"asc":return"desc";case"desc":return"";default:return""}},handleClickSortBtn(t){this.$emit("change-active",this.data.name),this.currentSort=this.changeCurrentSort(t);const e=this.$route.query,{sort:n,...i}=e,r=this.currentSort?`${this.data.name}-${this.currentSort}`:"";this.$router.replace({query:{...i,...r&&{sort:r}}})},isValueEqualToSelected(t){return`${this.data.name}-${t}`===this.selectedSortParam}}},H8={scope:"col",class:"text-start"},q8={class:"flex-shrink-0 size-3.5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},W8={key:0,d:"m7 15 5 5 5-5"},G8={key:1,d:"m7 9 5-5 5 5"},Z8={key:1,class:"text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500"};function Y8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("th",H8,[a.getVisibleIcon?(S.openBlock(),S.createElementBlock("button",{key:0,type:"button",class:"text-sm text-gray-800 px-[4px] py-2.5 text-start font-normal text-gray-500 flex items-center gap-[6px]",onClick:e[0]||(e[0]=u=>a.handleClickSortBtn(r.currentSort))},[S.createTextVNode(S.toDisplayString(a.label)+" ",1),(S.openBlock(),S.createElementBlock("svg",q8,[r.currentSort==="asc"||r.currentSort===""?(S.openBlock(),S.createElementBlock("path",W8)):S.createCommentVNode("",!0),r.currentSort==="desc"||r.currentSort===""?(S.openBlock(),S.createElementBlock("path",G8)):S.createCommentVNode("",!0)]))])):(S.openBlock(),S.createElementBlock("p",Z8,S.toDisplayString(a.label),1))])}const X8=_t(U8,[["render",Y8]]),K8={},J8={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-dots-vertical"};function Q8(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",J8,e[0]||(e[0]=[S.createElementVNode("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"},null,-1),S.createElementVNode("path",{d:"M12 12m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),S.createElementVNode("path",{d:"M12 19m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1),S.createElementVNode("path",{d:"M12 5m-1 0a1 1 0 1 0 2 0a1 1 0 1 0 -2 0"},null,-1)]))}const ej=_t(K8,[["render",Q8]]),tj={},nj={class:"flex-shrink-0 size-3.5",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"};function ij(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",nj,e[0]||(e[0]=[S.createStaticVNode('<path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" x2="10" y1="11" y2="17"></line><line x1="14" x2="14" y1="11" y2="17"></line>',5)]))}const rj=_t(tj,[["render",ij]]),sj={props:{height:{type:String,default:"16"},width:{type:String,default:"12"},color:{type:String,default:"black"}}},oj={style:{display:"none"}},aj=["height","width","fill"];function lj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock(S.Fragment,null,[(S.openBlock(),S.createElementBlock("svg",oj,e[0]||(e[0]=[S.createElementVNode("symbol",{id:"icon-pencil",viewBox:"0 0 32 32"},[S.createElementVNode("path",{d:"M27 0c2.761 0 5 2.239 5 5 0 1.126-0.372 2.164-1 3l-2 2-7-7 2-2c0.836-0.628 1.874-1 3-1zM2 23l-2 9 9-2 18.5-18.5-7-7-18.5 18.5zM22.362 11.362l-14 14-1.724-1.724 14-14 1.724 1.724z"})],-1)]))),(S.openBlock(),S.createElementBlock("svg",{height:n.height,width:n.width,fill:n.color},e[1]||(e[1]=[S.createElementVNode("use",{"xlink:href":"#icon-pencil"},null,-1)]),8,aj))],64)}const cj={components:{IconMore:ej,IconDelete:rj,IconEdit:_t(sj,[["render",lj]])},emits:["updateTable"],props:{item:Object,table:String,isForm:null},data(){return{formVisible:!1,isDeleteConfirm:!1,formValue:{},top:0,left:0}},methods:{openConfirm(){this.isDeleteConfirm=!0,document.querySelector("body").click()},async getData(){var t;try{const{data:e}=await wt.get(`/api/table/${this.table}/${(t=this.item)==null?void 0:t.id}`);this.formValue=e}catch(e){console.error(e)}},doSomethingOnCancel(){this.formVisible=!1},async deleteElement(){var t;try{wt.delete(`/api/table/${this.table}/${(t=this.item)==null?void 0:t.id}`),this.$notify({title:"Успішно!",message:"Об`єкт успішно видалeно",type:"success"}),await this.$emit("update-table"),this.isDeleteConfirm=!1}catch{this.$notify({title:"Помилка!",message:"Сталася помилка",type:"error"})}}}},uj={class:"hs-dropdown [--placement:bottom-right] inline-flex"},hj={class:"gap-x-2 p-[4px] rounded-lg shadow-sm hover:border-transparent border focus:outline-none text-black hover:bg-gray-50"},dj={class:"flex flex-col items-start"},pj={key:1,class:"h-[1px] w-[80%] bg-gray-200 ml-auto mr-auto"},fj={class:"p-4"},mj={class:"mt-4 flex justify-end gap-x-3"};function gj(t,e,n,i,r,a){const u=S.resolveComponent("IconMore"),l=S.resolveComponent("IconEdit"),g=S.resolveComponent("router-link"),_=S.resolveComponent("IconDelete"),k=S.resolveComponent("VsPopover"),E=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",uj,[S.createVNode(k,{trigger:"click",placement:"bottom-left"},{reference:S.withCtx(()=>[S.createElementVNode("button",hj,[S.createVNode(u,{height:"16",width:"16"})])]),default:S.withCtx(()=>{var T,I,z;return[S.createElementVNode("div",dj,[n.isForm?(S.openBlock(),S.createBlock(g,{key:0,to:`/edit?table=${(I=(T=t.$route)==null?void 0:T.params)==null?void 0:I.catchAll}&id=${(z=n.item)==null?void 0:z.id}`,class:"w-full flex items-center gap-x-3 py-1.5 px-2 rounded-lg text-[13px] text-stone-800 hover:bg-stone-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-stone-100"},{default:S.withCtx(()=>[S.createVNode(l,{color:"#000"}),e[4]||(e[4]=S.createTextVNode(" Редагувати "))]),_:1},8,["to"])):S.createCommentVNode("",!0),n.isForm?(S.openBlock(),S.createElementBlock("div",pj)):S.createCommentVNode("",!0),S.createElementVNode("button",{onClick:e[0]||(e[0]=S.withModifiers((...V)=>a.openConfirm&&a.openConfirm(...V),["stop"])),class:"w-full flex items-center gap-x-3 py-1.5 px-2 rounded-lg text-[13px] text-stone-800 hover:bg-stone-100 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-stone-100"},[S.createVNode(_),e[5]||(e[5]=S.createElementVNode("span",{class:"text-gray-800"},"Видалити",-1))])])]}),_:1})]),S.createVNode(E,{visible:r.isDeleteConfirm,"onUpdate:visible":e[3]||(e[3]=T=>r.isDeleteConfirm=T),title:"Ви впевнені?"},{default:S.withCtx(()=>[S.createElementVNode("div",fj,[e[6]||(e[6]=S.createElementVNode("p",{class:"mt-1 text-gray-500 dark:text-neutral-500"}," Ви впевнені, що хочете видалити цей об'єкт? ",-1)),S.createElementVNode("div",mj,[S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700",onClick:e[1]||(e[1]=T=>r.isDeleteConfirm=!1)}," Скасувати "),S.createElementVNode("button",{type:"button",class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-semibold rounded-lg border border-transparent bg-red-500 text-white hover:bg-red-600 disabled:opacity-50 disabled:pointer-events-none",onClick:e[2]||(e[2]=(...T)=>a.deleteElement&&a.deleteElement(...T))}," Так, я впевнена/ий ")])])]),_:1},8,["visible"])],64)}const yj=_t(cj,[["render",gj]]),_j={},bj={class:"flex-shrink-0 mt-0.5 size-3.5",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"};function xj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",bj,e[0]||(e[0]=[S.createElementVNode("path",{d:"m3 16 4 4 4-4"},null,-1),S.createElementVNode("path",{d:"M7 20V4"},null,-1),S.createElementVNode("path",{d:"m21 8-4-4-4 4"},null,-1),S.createElementVNode("path",{d:"M17 4v16"},null,-1)]))}const vj={components:{IconExport:_t(_j,[["render",xj]])},props:{table:String,columns:Array},data(){return{isOpen:!1,tableFormats:["json","csv","xlsx"],format:"",cols:[]}},methods:{async exportTable(){try{const t=await wt.get("/api/export",{params:{table:this.table,format:this.format,cols:this.cols.join(",")},responseType:"blob"}),e=new Blob([t.data],{type:"application/octet-stream"}),n=window.URL.createObjectURL(e),i=document.createElement("a");i.href=n,i.setAttribute("download",`${this.table.split(".")[0]}.${this.format}`),document.body.appendChild(i),i.click(),document.body.removeChild(i),window.URL.revokeObjectURL(n),this.$notify({type:"success",title:"Експорт",message:"Файл успішно експортовано!"})}catch(t){console.error("Ошибка при экспорте файла:",t),this.$notify({type:"error",title:"Помилка",message:"Не вдалося експортувати файл."})}},selectFormat(t){this.format=t}}},wj={class:"p-4"},kj={class:"pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700"},Sj={class:"mt-2 flex row flex-wrap gap-y-[5px] gap-x-[10px]"},Ej={class:"pb-5 mb-5 last:pb-0 last:mb-0 border-b last:border-b-0 border-gray-200 dark:border-neutral-700"},Cj={class:"mt-2 space-y-2"},Tj=["id","onChange"],Mj=["for"],Aj={class:"flex w-full justify-end p-[20px] gap-[6px] border-t"};function Pj(t,e,n,i,r,a){const u=S.resolveComponent("IconExport"),l=S.resolveComponent("VsCheckbox"),g=S.resolveComponent("VsDialog");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("button",{onClick:e[0]||(e[0]=_=>r.isOpen=!0),class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createVNode(u,{height:"16",width:"16"}),e[4]||(e[4]=S.createTextVNode(" Експорт ")),e[5]||(e[5]=S.createElementVNode("svg",{class:"shrink-0 size-3.5",xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},[S.createElementVNode("path",{d:"m6 9 6 6 6-6"})],-1))]),S.createVNode(g,{visible:r.isOpen,"onUpdate:visible":e[3]||(e[3]=_=>r.isOpen=_),title:"Експорт таблиці",size:"small"},{footer:S.withCtx(()=>[S.createElementVNode("div",Aj,[e[8]||(e[8]=S.createElementVNode("button",{type:"button",class:"py-2 px-3 text-nowrap inline-flex justify-center items-center text-start bg-white border border-gray-200 text-gray-800 text-sm font-medium rounded-lg shadow-sm align-middle hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700","data-hs-overlay":"#hs-pro-decm"}," Скасувати ",-1)),S.createElementVNode("button",{type:"button",class:"py-2 px-3 text-nowrap inline-flex justify-center items-center gap-x-2 text-start bg-blue-600 border border-blue-600 text-white text-sm font-medium rounded-lg shadow-sm align-middle hover:bg-blue-700 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:ring-1 focus:ring-blue-300 dark:focus:ring-blue-500",onClick:e[2]||(e[2]=(..._)=>a.exportTable&&a.exportTable(..._))}," Завантажити таблицю ")])]),default:S.withCtx(()=>[e[9]||(e[9]=S.createElementVNode("div",{class:"dark:border-neutral-700"},null,-1)),S.createElementVNode("div",wj,[S.createElementVNode("div",kj,[e[6]||(e[6]=S.createElementVNode("h2",{class:"text-sm text-gray-500"}," Виберіть стовпці таблиці для експорту: ",-1)),S.createElementVNode("div",Sj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(n.columns,(_,k)=>(S.openBlock(),S.createElementBlock("div",{class:"flex items-center",key:k,style:{width:"calc((100% - 10px) / 2)"}},[S.createVNode(l,{class:"[&>label]:text-sm [&>label]:text-gray-800 [&>label]:ms-3 !gap-x-[1px] !p-0",modelValue:r.cols,"onUpdate:modelValue":e[1]||(e[1]=E=>r.cols=E),value:_==null?void 0:_.name,label:_==null?void 0:_.ua},null,8,["modelValue","value","label"])]))),128))])]),S.createElementVNode("div",Ej,[e[7]||(e[7]=S.createElementVNode("h2",{class:"text-sm text-gray-500"},"Виберіть формат таблиці:",-1)),S.createElementVNode("div",Cj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(r.tableFormats,(_,k)=>(S.openBlock(),S.createElementBlock("div",{class:"flex items-center",key:k},[S.createElementVNode("input",{type:"radio",name:"hs-pro-duecmfm",class:"shrink-0 border-gray-300 rounded-full text-blue-600 focus:ring-blue-500 disabled:opacity-50 disabled:pointer-events-none dark:bg-neutral-800 dark:border-neutral-500 dark:checked:bg-blue-500 dark:checked:border-blue-500 dark:focus:ring-offset-gray-800",id:_,onChange:E=>a.selectFormat(_)},null,40,Tj),S.createElementVNode("label",{for:_,class:"text-sm text-gray-800 ms-3 dark:text-neutral-400"}," Формат "+S.toDisplayString(_),9,Mj)]))),128))])])])]),_:1},8,["visible"])],64)}const Ij=_t(vj,[["render",Pj]]),Dj={},Oj={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-columns"};function zj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",Oj,e[0]||(e[0]=[S.createStaticVNode('<path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M4 6l5.5 0"></path><path d="M4 10l5.5 0"></path><path d="M4 14l5.5 0"></path><path d="M4 18l5.5 0"></path><path d="M14.5 6l5.5 0"></path><path d="M14.5 10l5.5 0"></path><path d="M14.5 14l5.5 0"></path><path d="M14.5 18l5.5 0"></path>',9)]))}const Rj=_t(Dj,[["render",zj]]),Lj={props:{column:Object},emits:["update-column"],data(){return{value:!1}},watch:{value(t){this.$emit("update-column",{...this.column,hidden:!t})}},mounted(){var t;((t=this.column)==null?void 0:t.hidden)!==!0&&(this.value=!0)}},Nj={class:"flex w-full gap-[8px] items-centr"};function Bj(t,e,n,i,r,a){var u,l;return S.openBlock(),S.createElementBlock("label",Nj,[S.withDirectives(S.createElementVNode("input",{"onUpdate:modelValue":e[0]||(e[0]=g=>r.value=g),type:"checkbox"},null,512),[[S.vModelCheckbox,r.value]]),S.createTextVNode(" "+S.toDisplayString(((u=n.column)==null?void 0:u.ua)||((l=n.column)==null?void 0:l.title)),1)])}const Fj={components:{IconColumns:Rj,AdminTableColumnsHiddenItem:_t(Lj,[["render",Bj]])},emits:["update-columns"],props:{columns:Array},methods:{updateColumn(t){const e=this.columns.findIndex(i=>(i==null?void 0:i.name)===(t==null?void 0:t.name)),n=this.columns;n[e]=t,this.$emit("update-columns",[...n])}}},Vj={class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},$j={class:"py-[10px] px-[10px] w-[260px]"},jj={class:"flex flex-col gap-[3px] max-h-[400px] w-full overflow-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function Uj(t,e,n,i,r,a){const u=S.resolveComponent("IconColumns"),l=S.resolveComponent("AdminTableColumnsHiddenItem"),g=S.resolveComponent("VsPopover");return S.openBlock(),S.createBlock(g,{trigger:"click",placement:"bottom"},{reference:S.withCtx(()=>[S.createElementVNode("button",Vj,[S.createVNode(u,{height:"20",width:"16"})])]),default:S.withCtx(()=>[S.createElementVNode("div",$j,[e[0]||(e[0]=S.createElementVNode("h2",{class:"text-sm mb-[8px]"},"Оберіть колонки, щоб приховати",-1)),S.createElementVNode("ul",jj,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(n.columns,(_,k)=>(S.openBlock(),S.createElementBlock("li",{key:k},[S.createVNode(l,{column:_,onUpdateColumn:a.updateColumn},null,8,["column","onUpdateColumn"])]))),128))])])]),_:1})}const Hj=_t(Fj,[["render",Uj]]),qj={},Wj={class:"hidden sm:block shrink-0 size-3",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",viewBox:"0 0 16 16"};function Gj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("svg",Wj,e[0]||(e[0]=[S.createElementVNode("path",{"fill-rule":"evenodd","clip-rule":"evenodd",d:"M8 1C8.55228 1 9 1.44772 9 2V7L14 7C14.5523 7 15 7.44771 15 8C15 8.55228 14.5523 9 14 9L9 9V14C9 14.5523 8.55228 15 8 15C7.44772 15 7 14.5523 7 14V9.00001L2 9.00001C1.44772 9.00001 1 8.5523 1 8.00001C0.999999 7.44773 1.44771 7.00001 2 7.00001L7 7.00001V2C7 1.44772 7.44772 1 8 1Z"},null,-1)]))}const Zj=_t(qj,[["render",Gj]]),Yj={},Xj={class:"vs-table-interface__table-wrp w-full rounded h-fit overflow-hidden"};function Kj(t,e,n,i,r,a){return S.openBlock(),S.createElementBlock("div",Xj,e[0]||(e[0]=[S.createStaticVNode('<div><div class="p-5 min-h-[500px] flex flex-col justify-center items-center text-center"><svg class="w-48 mx-auto" viewBox="0 0 178 90" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="27" y="50.5" width="124" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="27" y="50.5" width="124" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-50 dark:stroke-neutral-700/10"></rect><rect x="34.5" y="58" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="61" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="66.5" y="73" width="77" height="6" rx="3" fill="currentColor" class="fill-gray-50 dark:fill-neutral-700/30"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" fill="currentColor" class="fill-white dark:fill-neutral-800"></rect><rect x="19.5" y="28.5" width="139" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/30"></rect><rect x="27" y="36" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="39" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><rect x="59" y="51" width="92" height="6" rx="3" fill="currentColor" class="fill-gray-100 dark:fill-neutral-700/70"></rect><g filter="url(#filter1)"><rect x="12" y="6" width="154" height="40" rx="8" fill="currentColor" class="fill-white dark:fill-neutral-800" shape-rendering="crispEdges"></rect><rect x="12.5" y="6.5" width="153" height="39" rx="7.5" stroke="currentColor" class="stroke-gray-100 dark:stroke-neutral-700/60" shape-rendering="crispEdges"></rect><rect x="20" y="14" width="24" height="24" rx="4" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="17" width="60" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect><rect x="52" y="29" width="106" height="6" rx="3" fill="currentColor" class="fill-gray-200 dark:fill-neutral-700"></rect></g><defs><filter id="filter1" x="0" y="0" width="178" height="64" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB"><feFlood flood-opacity="0" result="BackgroundImageFix"></feFlood><feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0" result="hardAlpha"></feColorMatrix><feOffset dy="6"></feOffset><feGaussianBlur stdDeviation="6"></feGaussianBlur><feComposite in2="hardAlpha" operator="out"></feComposite><feColorMatrix type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.03 0"></feColorMatrix><feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow_1187_14810"></feBlend><feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow_1187_14810" result="shape"></feBlend></filter></defs></svg><div class="max-w-sm mx-auto mt-6"><p class="font-medium text-gray-800 dark:text-neutral-200"> Дані для відображення відсутні </p><p class="mt-2 text-sm text-gray-500 dark:text-neutral-500"> Змініть параметри пошуку або спробуйте пізніше </p></div></div></div>',1)]))}const Jj={props:{table:String,title:String},components:{IconFilter:j8,AdminTableControl:yj,AdminTableExport:Ij,AdminTableColumnsHidden:Hj,AdminTableColumn:X8,AdminNodata:_t(Yj,[["render",Kj]]),IconPlus:Zj,IconSearch:dS},data(){return{tableData:{},isFilters:!1,filterScheme:[],page:1,searchValue:"",limit:0,filters:null,activeColumn:"",onFilters:0}},mounted(){var t,e,n,i;this.page=((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.page)||1,this.limit=((i=(n=this.$route)==null?void 0:n.query)==null?void 0:i.limit)||20,this.getTableData(),this.getFilters()},computed:{defaultPage(){var t,e;return((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.page)||1},getFilterScheme(){var t;return(t=this.tableData)==null?void 0:t.filters},columns(){var t,e;return(e=(t=this.tableData)==null?void 0:t.columns)==null?void 0:e.filter(n=>(n==null?void 0:n.hidden)!==!0)},isForm(){var t;return(t=this.tableData)==null?void 0:t.form},isNoData(){var t,e;return!((t=this.tableData)!=null&&t.rows)||!((e=this.columns)!=null&&e.length)},rowWidth(){var t;return((t=this.tableData)==null?void 0:t.width)||"100px"}},watch:{async table(){this.tableData=null,await this.getTableData()},searchValue(){this.getTableData()},$route:{handler(t,e){var n,i;((n=t==null?void 0:t.params)==null?void 0:n.catchAll)!==((i=e==null?void 0:e.params)==null?void 0:i.catchAll)&&(this.filterScheme=null,this.filters=null,this.onFilters=0,this.getFilters())},deep:!0},limit(t){var e;this.$router.push({query:{...(e=this.$route)==null?void 0:e.query,limit:t}})}},methods:{async getTableData(){var t,e;try{const{data:n}=await wt.get(`/api/template/table/${this.table}`),i=await wt.get(`/api/table-data/${this.table}`,{params:{page:this.page,search:this.searchValue||null,limit:this.limit,filter:this.filters||null,order:((e=(t=this.$route)==null?void 0:t.query)==null?void 0:e.sort)||null}});this.tableData={...n,...(i==null?void 0:i.data)||{}}}catch{}},async getFilters(){var t;try{const{data:e}=await wt.get(`/api/table-filter/${this.table}`);this.filterScheme=(t=e==null?void 0:e.list)==null?void 0:t.map(n=>({...n,label:(n==null?void 0:n.label)||(n==null?void 0:n.ua)}))}catch{}},async handlePageChange(t){const e=this.$route.query;this.page=t,!(!(e!=null&&e.page)&&t===1||e.page===t)&&(await this.$router.replace({query:{...e,page:t}}),await this.getTableData())},async changeLimit(t){this.limit=await t,this.defaultPage=1,await this.getTableData()},closeFilter({target:t}){this.isFilters&&t.classList.contains("filter-container")&&(this.isFilters=!1)},async filterChange({url:t,state:e}){var n;this.filters=t!=="no-url"?t:null,this.onFilters=(n=Object.entries(e))==null?void 0:n.length,this.page=1,await this.getTableData()},changeActiveColumn(t){this.activeColumn=t,this.getTableData()},pushToCard(t){var e;((e=this.tableData)==null?void 0:e.card)===!1||this.$router.push(`/card/${this.table}/${t}`)}}},Qj={class:"w-[calc(100vw - 320px)]"},e7={class:"h-[76px] bg-gray-50 flex items-center justify-between px-[30px]"},t7={class:"text-xl font-medium h-[20px]"},n7={style:{height:"calc(100vh - 140px)",width:"calc(100vw - 260px)"},class:"bg-gray-50 p-[20px] flex pt-[10px]"},i7={class:"bg-white w-full rounded-xl border p-[20px]"},r7={class:"flex sm:grid sm:grid-cols-2 gap-x-2 sm:gap-x-5 mb-[10px] relative"},s7={class:"flex gap-[6px] ml-auto"},o7={key:0,class:"font-medium text-[10px] py-0.5 px-[5px] bg-gray-800 text-white leading-3 rounded-full dark:bg-neutral-500"},a7={class:"space-y-5 flex items-start w-full justify-start"},l7={style:{height:"calc(100vh - 310px)"},class:"overflow-x-auto w-full border-t [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"},c7={class:"inline-block w-full align-middle"},u7={key:0,class:"divide-y divide-gray-200 min-w-full dark:divide-neutral-700 relative table-fixed"},h7={class:"sticky top-0 bg-white w-full relative after:absolute after:content-[''] after:block after:w-full after:h-px after:bg-stone-200"},d7={class:"border-stone-200 right-0 z-[1]"},p7={class:"divide-y divide-gray-200"},f7=["onClick"],m7={class:"text-center sticky right-0 bg-white w-[80px] px-[10px]"},g7={class:"p-[20px] flex justify-end w-full"},y7={class:"filter-content h-screen bg-white w-[400px] p-[20px] pt-[10px] overflow-x-auto bg-white [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar:horizontal]:h-[8px] [&::-webkit-scrollbar-track]:bg-gray-100 [&::-webkit-scrollbar-thumb]:bg-gray-300 dark:[&::-webkit-scrollbar-track]:bg-neutral-700 dark:[&::-webkit-scrollbar-thumb]:bg-neutral-500"};function _7(t,e,n,i,r,a){var ee,oe,J,Ae,ke,Me;const u=S.resolveComponent("IconPlus"),l=S.resolveComponent("router-link"),g=S.resolveComponent("IconSearch"),_=S.resolveComponent("VsText"),k=S.resolveComponent("AdminTableColumnsHidden"),E=S.resolveComponent("AdminTableExport"),T=S.resolveComponent("IconFilter"),I=S.resolveComponent("AdminTableColumn"),z=S.resolveComponent("AdminTableControl"),V=S.resolveComponent("AdminNodata"),H=S.resolveComponent("VsPagination"),Z=S.resolveComponent("VsFilter");return S.openBlock(),S.createElementBlock(S.Fragment,null,[S.createElementVNode("div",Qj,[S.createElementVNode("div",e7,[S.createElementVNode("h2",t7,S.toDisplayString(n.title),1),a.isForm?(S.openBlock(),S.createBlock(l,{key:0,to:`/add?table=${(oe=(ee=t.$route)==null?void 0:ee.params)==null?void 0:oe.catchAll}`,class:"py-2 px-3 inline-flex items-center gap-x-2 text-sm font-medium rounded-lg border border-transparent bg-blue-600 text-white hover:bg-blue-700 hover:text-white duration-300"},{default:S.withCtx(()=>[S.createVNode(u,{height:"16",width:"16"}),e[5]||(e[5]=S.createTextVNode(" Додати "))]),_:1},8,["to"])):S.createCommentVNode("",!0)]),S.createElementVNode("div",n7,[S.createElementVNode("div",i7,[S.createElementVNode("div",r7,[S.createVNode(g,{height:"14",width:"14",class:"absolute top-[10px] left-[14px] text-gray-500 z-[1]"}),S.createVNode(_,{modelValue:r.searchValue,"onUpdate:modelValue":e[0]||(e[0]=Le=>r.searchValue=Le),placeholder:"Пошук...",clearable:!0,class:"[&>input]:py-[7px] [&>input]:ps-10 [&>input]:pe-8 [&>input]:block [&>input]:w-full [&>input]:bg-gray-100 [&>input]:border-transparent [&>input]:rounded-lg [&>input]:text-sm [&>input]:focus:bg-white [&>input]:focus:border-blue-500 [&>input]:focus:ring-blue-500 [&>input]:disabled:opacity-50 [&>input]:disabled:pointer-events-none [&>input]:dark:bg-neutral-700 [&>input]:dark:border-transparent [&>input]:dark:text-neutral-400 [&>input]:dark:placeholder:text-neutral-400 dark:focus:bg-neutral-800 dark:focus:ring-neutral-600"},null,8,["modelValue"]),S.createElementVNode("div",s7,[S.createVNode(k,{columns:(J=r.tableData)==null?void 0:J.columns,onUpdateColumns:e[1]||(e[1]=Le=>r.tableData.columns=Le)},null,8,["columns"]),S.createVNode(E,{table:n.table,columns:(Ae=r.tableData)==null?void 0:Ae.columns},null,8,["table","columns"]),S.createElementVNode("button",{onClick:e[2]||(e[2]=Le=>r.isFilters=!r.isFilters),class:"py-2 px-2.5 inline-flex items-center gap-x-1.5 text-xs font-medium rounded-lg border border-gray-200 bg-white text-gray-800 shadow-sm hover:bg-gray-50 disabled:opacity-50 disabled:pointer-events-none focus:outline-none focus:bg-gray-50 dark:bg-neutral-800 dark:border-neutral-700 dark:text-neutral-300 dark:hover:bg-neutral-700 dark:focus:bg-neutral-700"},[S.createVNode(T,{height:"16",width:"16"}),e[6]||(e[6]=S.createTextVNode(" Фільтри ")),r.onFilters?(S.openBlock(),S.createElementBlock("span",o7,S.toDisplayString(r.onFilters),1)):S.createCommentVNode("",!0)])])]),S.createElementVNode("div",a7,[S.createElementVNode("div",l7,[S.createElementVNode("div",c7,[a.isNoData?(S.openBlock(),S.createBlock(V,{key:1})):(S.openBlock(),S.createElementBlock("table",u7,[S.createElementVNode("thead",h7,[S.createElementVNode("tr",d7,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList(a.columns,Le=>(S.openBlock(),S.createBlock(I,{key:Le.name,style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth}),data:Le,activeColumn:r.activeColumn,onChangeActive:a.changeActiveColumn},null,8,["style","data","activeColumn","onChangeActive"]))),128)),e[7]||(e[7]=S.createElementVNode("th",{class:"w-[70px] sticky right-0 top-0 bg-white"},null,-1))])]),S.createElementVNode("tbody",p7,[(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((ke=r.tableData)==null?void 0:ke.rows,(Le,Ie)=>{var Ye,it,Nt,ht,Rt,Xt,nn,jt;return S.openBlock(),S.createElementBlock("tr",{key:Ie},[S.createElementVNode("td",{class:"text-sm text-gray-600",style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth})},[S.createElementVNode("button",{onClick:()=>a.pushToCard(Le==null?void 0:Le.id),class:S.normalizeClass(["text-sm font-medium",[((Ye=r.tableData)==null?void 0:Ye.card)===!1?"":"text-blue-600 decoration-2 focus:outline-none focus:underline hover:text-blue-600 hover:underline"]])},[(S.openBlock(),S.createBlock(S.resolveDynamicComponent(((it=a.columns[0])==null?void 0:it.format)==="custom"?(Nt=a.columns[0])==null?void 0:Nt.component:t.$componentsConfig[`table-format-${((Rt=(ht=a.columns[0])==null?void 0:ht.format)==null?void 0:Rt.toLowerCase())||"text"}`]),{name:(Xt=a.columns[0])==null?void 0:Xt.name,data:Le,value:Le==null?void 0:Le[(nn=a.columns[0])==null?void 0:nn.name],table:n.table},null,8,["name","data","value","table"]))],10,f7)],4),(S.openBlock(!0),S.createElementBlock(S.Fragment,null,S.renderList((jt=a.columns)==null?void 0:jt.slice(1),Mt=>{var Sn,hn;return S.openBlock(),S.createElementBlock("td",{class:"text-start px-[4px] py-3 text-sm text-gray-600",style:S.normalizeStyle({minWidth:a.rowWidth,maxWidth:a.rowWidth}),key:Mt.name},[(S.openBlock(),S.createBlock(S.resolveDynamicComponent((Mt==null?void 0:Mt.format)==="custom"?Mt==null?void 0:Mt.component:t.$componentsConfig[`table-format-${((Sn=Mt==null?void 0:Mt.format)==null?void 0:Sn.toLowerCase())||"text"}`]),{onUpdateTable:a.getTableData,name:Mt==null?void 0:Mt.name,data:Le,value:Le==null?void 0:Le[Mt==null?void 0:Mt.name],table:n.table,inline:((hn=r.tableData)==null?void 0:hn.inline)||!1},null,40,["onUpdateTable","name","data","value","table","inline"]))],4)}),128)),S.createElementVNode("td",m7,[S.createVNode(z,{isForm:a.isForm,item:Le,table:n.table,onUpdateTable:a.getTableData},null,8,["isForm","item","table","onUpdateTable"])])])}),128))])]))])])]),S.createElementVNode("div",g7,[r.limit?(S.openBlock(),S.createBlock(H,{key:0,goTo:!1,class:"justify-end","default-page":a.defaultPage,total:((Me=r.tableData)==null?void 0:Me.total)||0,pageSize:r.limit,onPageChange:a.handlePageChange,pageSizes:[10,16,20],onPageSizeChange:a.changeLimit},null,8,["default-page","total","pageSize","onPageChange","onPageSizeChange"])):S.createCommentVNode("",!0)])])])]),S.createVNode(S.Transition,{name:"fade"},{default:S.withCtx(()=>{var Le;return[S.withDirectives(S.createElementVNode("div",{onClick:e[4]||(e[4]=(...Ie)=>a.closeFilter&&a.closeFilter(...Ie)),style:{height:"100vh"},class:"fixed filter-container top-0 flex justify-end items-center z-[2] right-0 left-0 bottom-0 bg-[rgba(0,0,0,0.5)]"},[S.createElementVNode("div",y7,[(Le=r.filterScheme)!=null&&Le.length?(S.openBlock(),S.createBlock(Z,{key:0,ref:"filter",scheme:r.filterScheme,layout:"default","apply-vue-router":"",history:"",name:"filter",onFilterChange:a.filterChange,closeFilterBtn:!0,onFilterClose:e[3]||(e[3]=Ie=>r.isFilters=!1)},null,8,["scheme","onFilterChange"])):S.createCommentVNode("",!0)])],512),[[S.vShow,r.isFilters]])]}),_:1})],64)}const b7={components:{AdminTable:_t(Jj,[["render",_7]])},data(){return{table:!1,interface:"",title:""}},watch:{$route:{async handler(){Xr!=null&&Xr.value||await this.getMenu(),await this.checkPageType()},deep:!0},title(t){t&&(document.title=t)}},async mounted(){await this.checkPageType()},methods:{flattenMenu(t){const e=[];return t.forEach(n=>{n.menu?e.push(...this.flattenMenu(n.menu)):e.push(n)}),e},async getMenu(){try{const{data:t}=await wt.get("/api/user-menu");Xr.value=t}catch{}},async checkPageType(){const t=this.flattenMenu(Xr.value);t!=null&&t.length||this.$router.replace("/404");const e=t==null?void 0:t.find(i=>{var r,a;return(i==null?void 0:i.path)==((a=(r=this.$route)==null?void 0:r.params)==null?void 0:a.catchAll)});this.title=e==null?void 0:e.ua,e||this.$router.replace("/404");const n=e==null?void 0:e.table;this.table=n||!1,!n&&this.getInterface()},async getInterface(){var t,e;try{const{data:n}=await wt.get(`/api/template/interface/${((e=(t=this.$route)==null?void 0:t.params)==null?void 0:e.catchAll)||""}`);this.interface=n||""}catch{this.interface=""}}}},x7=["innerHTML"];function v7(t,e,n,i,r,a){const u=S.resolveComponent("AdminTable");return r.table?(S.openBlock(),S.createBlock(u,{key:0,table:r.table,title:r.title},null,8,["table","title"])):(S.openBlock(),S.createElementBlock("div",{key:1,class:"w-full bg-gray-50",style:{height:"calc(100vh - 120px)"},innerHTML:r.interface},null,8,x7))}const w7=Object.freeze(Object.defineProperty({__proto__:null,default:_t(b7,[["render",v7]])},Symbol.toStringTag,{value:"Module"}));return r$});
|