":return this.left.evaluate(e)>this.right.evaluate(e)?1:0;case"<=":return this.left.evaluate(e)<=this.right.evaluate(e)?1:0;case">=":return this.left.evaluate(e)>=this.right.evaluate(e)?1:0;case"&&":return this.left.evaluate(e)&&this.right.evaluate(e)?1:0;case"||":return this.left.evaluate(e)||this.right.evaluate(e)?1:0;default:throw new Error(`Unknown operator ${this.operator}`)}}search(e){this.left.search(e),this.right.search(e)}}class HI extends Ta{constructor(){super()}}class u6 extends HI{constructor(e,i){super(),this.selector=e,this.body=i}get astNodeType(){return"case"}search(e){this.searchBlock(this.body,e)}}class d6 extends HI{constructor(e){super(),this.body=e}get astNodeType(){return"default"}search(e){this.searchBlock(this.body,e)}}class f6 extends Ta{constructor(e,i,r){super(),this.name=e,this.type=i,this.attributes=r}get astNodeType(){return"argument"}}class p6 extends Ta{constructor(e,i){super(),this.condition=e,this.body=i}get astNodeType(){return"elseif"}search(e){this.condition.search(e),this.searchBlock(this.body,e)}}class _6 extends Ta{constructor(e,i,r){super(),this.name=e,this.type=i,this.attributes=r}get astNodeType(){return"member"}}let g6=class extends Ta{constructor(e,i){super(),this.name=e,this.value=i}get astNodeType(){return"attribute"}};var Pe,we;(function(t){t[t.token=0]="token",t[t.keyword=1]="keyword",t[t.reserved=2]="reserved"})(we||(we={}));class Te{constructor(e,i,r){this.name=e,this.type=i,this.rule=r}toString(){return this.name}}class J{}Pe=J;J.none=new Te("",we.reserved,"");J.eof=new Te("EOF",we.token,"");J.reserved={asm:new Te("asm",we.reserved,"asm"),bf16:new Te("bf16",we.reserved,"bf16"),do:new Te("do",we.reserved,"do"),enum:new Te("enum",we.reserved,"enum"),f16:new Te("f16",we.reserved,"f16"),f64:new Te("f64",we.reserved,"f64"),handle:new Te("handle",we.reserved,"handle"),i8:new Te("i8",we.reserved,"i8"),i16:new Te("i16",we.reserved,"i16"),i64:new Te("i64",we.reserved,"i64"),mat:new Te("mat",we.reserved,"mat"),premerge:new Te("premerge",we.reserved,"premerge"),regardless:new Te("regardless",we.reserved,"regardless"),typedef:new Te("typedef",we.reserved,"typedef"),u8:new Te("u8",we.reserved,"u8"),u16:new Te("u16",we.reserved,"u16"),u64:new Te("u64",we.reserved,"u64"),unless:new Te("unless",we.reserved,"unless"),using:new Te("using",we.reserved,"using"),vec:new Te("vec",we.reserved,"vec"),void:new Te("void",we.reserved,"void")};J.keywords={array:new Te("array",we.keyword,"array"),atomic:new Te("atomic",we.keyword,"atomic"),bool:new Te("bool",we.keyword,"bool"),f32:new Te("f32",we.keyword,"f32"),i32:new Te("i32",we.keyword,"i32"),mat2x2:new Te("mat2x2",we.keyword,"mat2x2"),mat2x3:new Te("mat2x3",we.keyword,"mat2x3"),mat2x4:new Te("mat2x4",we.keyword,"mat2x4"),mat3x2:new Te("mat3x2",we.keyword,"mat3x2"),mat3x3:new Te("mat3x3",we.keyword,"mat3x3"),mat3x4:new Te("mat3x4",we.keyword,"mat3x4"),mat4x2:new Te("mat4x2",we.keyword,"mat4x2"),mat4x3:new Te("mat4x3",we.keyword,"mat4x3"),mat4x4:new Te("mat4x4",we.keyword,"mat4x4"),ptr:new Te("ptr",we.keyword,"ptr"),sampler:new Te("sampler",we.keyword,"sampler"),sampler_comparison:new Te("sampler_comparison",we.keyword,"sampler_comparison"),struct:new Te("struct",we.keyword,"struct"),texture_1d:new Te("texture_1d",we.keyword,"texture_1d"),texture_2d:new Te("texture_2d",we.keyword,"texture_2d"),texture_2d_array:new Te("texture_2d_array",we.keyword,"texture_2d_array"),texture_3d:new Te("texture_3d",we.keyword,"texture_3d"),texture_cube:new Te("texture_cube",we.keyword,"texture_cube"),texture_cube_array:new Te("texture_cube_array",we.keyword,"texture_cube_array"),texture_multisampled_2d:new Te("texture_multisampled_2d",we.keyword,"texture_multisampled_2d"),texture_storage_1d:new Te("texture_storage_1d",we.keyword,"texture_storage_1d"),texture_storage_2d:new Te("texture_storage_2d",we.keyword,"texture_storage_2d"),texture_storage_2d_array:new Te("texture_storage_2d_array",we.keyword,"texture_storage_2d_array"),texture_storage_3d:new Te("texture_storage_3d",we.keyword,"texture_storage_3d"),texture_depth_2d:new Te("texture_depth_2d",we.keyword,"texture_depth_2d"),texture_depth_2d_array:new Te("texture_depth_2d_array",we.keyword,"texture_depth_2d_array"),texture_depth_cube:new Te("texture_depth_cube",we.keyword,"texture_depth_cube"),texture_depth_cube_array:new Te("texture_depth_cube_array",we.keyword,"texture_depth_cube_array"),texture_depth_multisampled_2d:new Te("texture_depth_multisampled_2d",we.keyword,"texture_depth_multisampled_2d"),texture_external:new Te("texture_external",we.keyword,"texture_external"),u32:new Te("u32",we.keyword,"u32"),vec2:new Te("vec2",we.keyword,"vec2"),vec3:new Te("vec3",we.keyword,"vec3"),vec4:new Te("vec4",we.keyword,"vec4"),bitcast:new Te("bitcast",we.keyword,"bitcast"),block:new Te("block",we.keyword,"block"),break:new Te("break",we.keyword,"break"),case:new Te("case",we.keyword,"case"),continue:new Te("continue",we.keyword,"continue"),continuing:new Te("continuing",we.keyword,"continuing"),default:new Te("default",we.keyword,"default"),diagnostic:new Te("diagnostic",we.keyword,"diagnostic"),discard:new Te("discard",we.keyword,"discard"),else:new Te("else",we.keyword,"else"),enable:new Te("enable",we.keyword,"enable"),fallthrough:new Te("fallthrough",we.keyword,"fallthrough"),false:new Te("false",we.keyword,"false"),fn:new Te("fn",we.keyword,"fn"),for:new Te("for",we.keyword,"for"),function:new Te("function",we.keyword,"function"),if:new Te("if",we.keyword,"if"),let:new Te("let",we.keyword,"let"),const:new Te("const",we.keyword,"const"),loop:new Te("loop",we.keyword,"loop"),while:new Te("while",we.keyword,"while"),private:new Te("private",we.keyword,"private"),read:new Te("read",we.keyword,"read"),read_write:new Te("read_write",we.keyword,"read_write"),return:new Te("return",we.keyword,"return"),requires:new Te("requires",we.keyword,"requires"),storage:new Te("storage",we.keyword,"storage"),switch:new Te("switch",we.keyword,"switch"),true:new Te("true",we.keyword,"true"),alias:new Te("alias",we.keyword,"alias"),type:new Te("type",we.keyword,"type"),uniform:new Te("uniform",we.keyword,"uniform"),var:new Te("var",we.keyword,"var"),override:new Te("override",we.keyword,"override"),workgroup:new Te("workgroup",we.keyword,"workgroup"),write:new Te("write",we.keyword,"write"),r8unorm:new Te("r8unorm",we.keyword,"r8unorm"),r8snorm:new Te("r8snorm",we.keyword,"r8snorm"),r8uint:new Te("r8uint",we.keyword,"r8uint"),r8sint:new Te("r8sint",we.keyword,"r8sint"),r16uint:new Te("r16uint",we.keyword,"r16uint"),r16sint:new Te("r16sint",we.keyword,"r16sint"),r16float:new Te("r16float",we.keyword,"r16float"),rg8unorm:new Te("rg8unorm",we.keyword,"rg8unorm"),rg8snorm:new Te("rg8snorm",we.keyword,"rg8snorm"),rg8uint:new Te("rg8uint",we.keyword,"rg8uint"),rg8sint:new Te("rg8sint",we.keyword,"rg8sint"),r32uint:new Te("r32uint",we.keyword,"r32uint"),r32sint:new Te("r32sint",we.keyword,"r32sint"),r32float:new Te("r32float",we.keyword,"r32float"),rg16uint:new Te("rg16uint",we.keyword,"rg16uint"),rg16sint:new Te("rg16sint",we.keyword,"rg16sint"),rg16float:new Te("rg16float",we.keyword,"rg16float"),rgba8unorm:new Te("rgba8unorm",we.keyword,"rgba8unorm"),rgba8unorm_srgb:new Te("rgba8unorm_srgb",we.keyword,"rgba8unorm_srgb"),rgba8snorm:new Te("rgba8snorm",we.keyword,"rgba8snorm"),rgba8uint:new Te("rgba8uint",we.keyword,"rgba8uint"),rgba8sint:new Te("rgba8sint",we.keyword,"rgba8sint"),bgra8unorm:new Te("bgra8unorm",we.keyword,"bgra8unorm"),bgra8unorm_srgb:new Te("bgra8unorm_srgb",we.keyword,"bgra8unorm_srgb"),rgb10a2unorm:new Te("rgb10a2unorm",we.keyword,"rgb10a2unorm"),rg11b10float:new Te("rg11b10float",we.keyword,"rg11b10float"),rg32uint:new Te("rg32uint",we.keyword,"rg32uint"),rg32sint:new Te("rg32sint",we.keyword,"rg32sint"),rg32float:new Te("rg32float",we.keyword,"rg32float"),rgba16uint:new Te("rgba16uint",we.keyword,"rgba16uint"),rgba16sint:new Te("rgba16sint",we.keyword,"rgba16sint"),rgba16float:new Te("rgba16float",we.keyword,"rgba16float"),rgba32uint:new Te("rgba32uint",we.keyword,"rgba32uint"),rgba32sint:new Te("rgba32sint",we.keyword,"rgba32sint"),rgba32float:new Te("rgba32float",we.keyword,"rgba32float"),static_assert:new Te("static_assert",we.keyword,"static_assert")};J.tokens={decimal_float_literal:new Te("decimal_float_literal",we.token,/((-?[0-9]*\.[0-9]+|-?[0-9]+\.[0-9]*)((e|E)(\+|-)?[0-9]+)?f?)|(-?[0-9]+(e|E)(\+|-)?[0-9]+f?)|([0-9]+f)/),hex_float_literal:new Te("hex_float_literal",we.token,/-?0x((([0-9a-fA-F]*\.[0-9a-fA-F]+|[0-9a-fA-F]+\.[0-9a-fA-F]*)((p|P)(\+|-)?[0-9]+f?)?)|([0-9a-fA-F]+(p|P)(\+|-)?[0-9]+f?))/),int_literal:new Te("int_literal",we.token,/-?0x[0-9a-fA-F]+|0i?|-?[1-9][0-9]*i?/),uint_literal:new Te("uint_literal",we.token,/0x[0-9a-fA-F]+u|0u|[1-9][0-9]*u/),ident:new Te("ident",we.token,/[_a-zA-Z][0-9a-zA-Z_]*/),and:new Te("and",we.token,"&"),and_and:new Te("and_and",we.token,"&&"),arrow:new Te("arrow ",we.token,"->"),attr:new Te("attr",we.token,"@"),forward_slash:new Te("forward_slash",we.token,"/"),bang:new Te("bang",we.token,"!"),bracket_left:new Te("bracket_left",we.token,"["),bracket_right:new Te("bracket_right",we.token,"]"),brace_left:new Te("brace_left",we.token,"{"),brace_right:new Te("brace_right",we.token,"}"),colon:new Te("colon",we.token,":"),comma:new Te("comma",we.token,","),equal:new Te("equal",we.token,"="),equal_equal:new Te("equal_equal",we.token,"=="),not_equal:new Te("not_equal",we.token,"!="),greater_than:new Te("greater_than",we.token,">"),greater_than_equal:new Te("greater_than_equal",we.token,">="),shift_right:new Te("shift_right",we.token,">>"),less_than:new Te("less_than",we.token,"<"),less_than_equal:new Te("less_than_equal",we.token,"<="),shift_left:new Te("shift_left",we.token,"<<"),modulo:new Te("modulo",we.token,"%"),minus:new Te("minus",we.token,"-"),minus_minus:new Te("minus_minus",we.token,"--"),period:new Te("period",we.token,"."),plus:new Te("plus",we.token,"+"),plus_plus:new Te("plus_plus",we.token,"++"),or:new Te("or",we.token,"|"),or_or:new Te("or_or",we.token,"||"),paren_left:new Te("paren_left",we.token,"("),paren_right:new Te("paren_right",we.token,")"),semicolon:new Te("semicolon",we.token,";"),star:new Te("star",we.token,"*"),tilde:new Te("tilde",we.token,"~"),underscore:new Te("underscore",we.token,"_"),xor:new Te("xor",we.token,"^"),plus_equal:new Te("plus_equal",we.token,"+="),minus_equal:new Te("minus_equal",we.token,"-="),times_equal:new Te("times_equal",we.token,"*="),division_equal:new Te("division_equal",we.token,"/="),modulo_equal:new Te("modulo_equal",we.token,"%="),and_equal:new Te("and_equal",we.token,"&="),or_equal:new Te("or_equal",we.token,"|="),xor_equal:new Te("xor_equal",we.token,"^="),shift_right_equal:new Te("shift_right_equal",we.token,">>="),shift_left_equal:new Te("shift_left_equal",we.token,"<<=")};J.simpleTokens={"@":Pe.tokens.attr,"{":Pe.tokens.brace_left,"}":Pe.tokens.brace_right,":":Pe.tokens.colon,",":Pe.tokens.comma,"(":Pe.tokens.paren_left,")":Pe.tokens.paren_right,";":Pe.tokens.semicolon};J.literalTokens={"&":Pe.tokens.and,"&&":Pe.tokens.and_and,"->":Pe.tokens.arrow,"/":Pe.tokens.forward_slash,"!":Pe.tokens.bang,"[":Pe.tokens.bracket_left,"]":Pe.tokens.bracket_right,"=":Pe.tokens.equal,"==":Pe.tokens.equal_equal,"!=":Pe.tokens.not_equal,">":Pe.tokens.greater_than,">=":Pe.tokens.greater_than_equal,">>":Pe.tokens.shift_right,"<":Pe.tokens.less_than,"<=":Pe.tokens.less_than_equal,"<<":Pe.tokens.shift_left,"%":Pe.tokens.modulo,"-":Pe.tokens.minus,"--":Pe.tokens.minus_minus,".":Pe.tokens.period,"+":Pe.tokens.plus,"++":Pe.tokens.plus_plus,"|":Pe.tokens.or,"||":Pe.tokens.or_or,"*":Pe.tokens.star,"~":Pe.tokens.tilde,_:Pe.tokens.underscore,"^":Pe.tokens.xor,"+=":Pe.tokens.plus_equal,"-=":Pe.tokens.minus_equal,"*=":Pe.tokens.times_equal,"/=":Pe.tokens.division_equal,"%=":Pe.tokens.modulo_equal,"&=":Pe.tokens.and_equal,"|=":Pe.tokens.or_equal,"^=":Pe.tokens.xor_equal,">>=":Pe.tokens.shift_right_equal,"<<=":Pe.tokens.shift_left_equal};J.regexTokens={decimal_float_literal:Pe.tokens.decimal_float_literal,hex_float_literal:Pe.tokens.hex_float_literal,int_literal:Pe.tokens.int_literal,uint_literal:Pe.tokens.uint_literal,ident:Pe.tokens.ident};J.storage_class=[Pe.keywords.function,Pe.keywords.private,Pe.keywords.workgroup,Pe.keywords.uniform,Pe.keywords.storage];J.access_mode=[Pe.keywords.read,Pe.keywords.write,Pe.keywords.read_write];J.sampler_type=[Pe.keywords.sampler,Pe.keywords.sampler_comparison];J.sampled_texture_type=[Pe.keywords.texture_1d,Pe.keywords.texture_2d,Pe.keywords.texture_2d_array,Pe.keywords.texture_3d,Pe.keywords.texture_cube,Pe.keywords.texture_cube_array];J.multisampled_texture_type=[Pe.keywords.texture_multisampled_2d];J.storage_texture_type=[Pe.keywords.texture_storage_1d,Pe.keywords.texture_storage_2d,Pe.keywords.texture_storage_2d_array,Pe.keywords.texture_storage_3d];J.depth_texture_type=[Pe.keywords.texture_depth_2d,Pe.keywords.texture_depth_2d_array,Pe.keywords.texture_depth_cube,Pe.keywords.texture_depth_cube_array,Pe.keywords.texture_depth_multisampled_2d];J.texture_external_type=[Pe.keywords.texture_external];J.any_texture_type=[...Pe.sampled_texture_type,...Pe.multisampled_texture_type,...Pe.storage_texture_type,...Pe.depth_texture_type,...Pe.texture_external_type];J.texel_format=[Pe.keywords.r8unorm,Pe.keywords.r8snorm,Pe.keywords.r8uint,Pe.keywords.r8sint,Pe.keywords.r16uint,Pe.keywords.r16sint,Pe.keywords.r16float,Pe.keywords.rg8unorm,Pe.keywords.rg8snorm,Pe.keywords.rg8uint,Pe.keywords.rg8sint,Pe.keywords.r32uint,Pe.keywords.r32sint,Pe.keywords.r32float,Pe.keywords.rg16uint,Pe.keywords.rg16sint,Pe.keywords.rg16float,Pe.keywords.rgba8unorm,Pe.keywords.rgba8unorm_srgb,Pe.keywords.rgba8snorm,Pe.keywords.rgba8uint,Pe.keywords.rgba8sint,Pe.keywords.bgra8unorm,Pe.keywords.bgra8unorm_srgb,Pe.keywords.rgb10a2unorm,Pe.keywords.rg11b10float,Pe.keywords.rg32uint,Pe.keywords.rg32sint,Pe.keywords.rg32float,Pe.keywords.rgba16uint,Pe.keywords.rgba16sint,Pe.keywords.rgba16float,Pe.keywords.rgba32uint,Pe.keywords.rgba32sint,Pe.keywords.rgba32float];J.const_literal=[Pe.tokens.int_literal,Pe.tokens.uint_literal,Pe.tokens.decimal_float_literal,Pe.tokens.hex_float_literal,Pe.keywords.true,Pe.keywords.false];J.literal_or_ident=[Pe.tokens.ident,Pe.tokens.int_literal,Pe.tokens.uint_literal,Pe.tokens.decimal_float_literal,Pe.tokens.hex_float_literal];J.element_count_expression=[Pe.tokens.int_literal,Pe.tokens.uint_literal,Pe.tokens.ident];J.template_types=[Pe.keywords.vec2,Pe.keywords.vec3,Pe.keywords.vec4,Pe.keywords.mat2x2,Pe.keywords.mat2x3,Pe.keywords.mat2x4,Pe.keywords.mat3x2,Pe.keywords.mat3x3,Pe.keywords.mat3x4,Pe.keywords.mat4x2,Pe.keywords.mat4x3,Pe.keywords.mat4x4,Pe.keywords.atomic,Pe.keywords.bitcast,...Pe.any_texture_type];J.attribute_name=[Pe.tokens.ident,Pe.keywords.block,Pe.keywords.diagnostic];J.assignment_operators=[Pe.tokens.equal,Pe.tokens.plus_equal,Pe.tokens.minus_equal,Pe.tokens.times_equal,Pe.tokens.division_equal,Pe.tokens.modulo_equal,Pe.tokens.and_equal,Pe.tokens.or_equal,Pe.tokens.xor_equal,Pe.tokens.shift_right_equal,Pe.tokens.shift_left_equal];J.increment_operators=[Pe.tokens.plus_plus,Pe.tokens.minus_minus];class WS{constructor(e,i,r){this.type=e,this.lexeme=i,this.line=r}toString(){return this.lexeme}isTemplateType(){return J.template_types.indexOf(this.type)!=-1}isArrayType(){return this.type==J.keywords.array}isArrayOrTemplateType(){return this.isArrayType()||this.isTemplateType()}}class m6{constructor(e){this._tokens=[],this._start=0,this._current=0,this._line=1,this._source=e??""}scanTokens(){for(;!this._isAtEnd();)if(this._start=this._current,!this.scanToken())throw`Invalid syntax at line ${this._line}`;return this._tokens.push(new WS(J.eof,"",this._line)),this._tokens}scanToken(){let e=this._advance();if(e==`
`)return this._line++,!0;if(this._isWhitespace(e))return!0;if(e=="/"){if(this._peekAhead()=="/"){for(;e!=`
`;){if(this._isAtEnd())return!0;e=this._advance()}return this._line++,!0}else if(this._peekAhead()=="*"){this._advance();let d=1;for(;d>0;){if(this._isAtEnd())return!0;if(e=this._advance(),e==`
-`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),d--,d==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),d++)}return!0}}const i=J.simpleTokens[e];if(i)return this._addToken(i),!0;let r=J.none;const o=this._isAlpha(e),h=e==="_";if(this._isAlphaNumeric(e)){let d=this._peekAhead();for(;this._isAlphaNumeric(d);)e+=this._advance(),d=this._peekAhead()}if(o){const d=J.keywords[e];if(d)return this._addToken(d),!0}if(o||h)return this._addToken(J.tokens.ident),!0;for(;;){let d=this._findType(e);const c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let x=!1,S=this._tokens.length-1;for(let P=0;P<5&&S>=0&&J.assignment_operators.indexOf(this._tokens[S].type)===-1;++P,--S)if(this._tokens[S].type===J.tokens.less_than){S>0&&this._tokens[S-1].isArrayOrTemplateType()&&(x=!0);break}if(x)return this._addToken(d),!0}if(d===J.none){let x=e,S=0;const P=2;for(let M=0;M=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let i=this._source[this._current];return e=e||0,e++,this._current+=e,i}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const i=this._source.substring(this._start,this._current);this._tokens.push(new WS(e,i,this._line))}}class yz{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new $4,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const i=[];for(;!this._isAtEnd();){const r=this._global_decl_or_directive();if(!r)break;i.push(r)}if(this._deferArrayCountEval.length>0){for(const r of this._deferArrayCountEval){const o=r.arrayType,h=r.countNode;if(h instanceof $b){const c=h.name,x=this._context.constants.get(c);if(x)try{const S=x.evaluate(this._context);o.count=S}catch{}}}this._deferArrayCountEval.length=0}return i}_initialize(e){if(e)if(typeof e=="string"){const i=new mz(e);this._tokens=i.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,i){return{token:e,message:i,toString:function(){return`${i}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==J.eof}_match(e){if(e instanceof Te)return this._check(e)?(this._advance(),!0):!1;for(let i=0,r=e.length;i'.");const o=this._paren_expression();return new az(r,o)}const e=this._type_decl(),i=this._argument_expression_list();return new lz(e,i)}_argument_expression_list(){if(!this._match(J.tokens.paren_left))return null;const e=[];do{if(this._check(J.tokens.paren_right))break;const i=this._short_circuit_or_expression();e.push(i)}while(this._match(J.tokens.comma));return this._consume(J.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(J.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(J.tokens.paren_right),new $S([e])}_paren_expression(){this._consume(J.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(J.tokens.paren_right,"Expected ')'."),new $S([e])}_struct_decl(){if(!this._match(J.keywords.struct))return null;const e=this._currentLine,i=this._consume(J.tokens.ident,"Expected name for struct.").toString();this._consume(J.tokens.brace_left,"Expected '{' for struct body.");const r=[];for(;!this._check(J.tokens.brace_right);){const d=this._attribute(),c=this._consume(J.tokens.ident,"Expected variable name.").toString();this._consume(J.tokens.colon,"Expected ':' for struct member type.");const x=this._attribute(),S=this._type_decl();S!=null&&(S.attributes=x),this._check(J.tokens.brace_right)?this._match(J.tokens.comma):this._consume(J.tokens.comma,"Expected ',' for struct member."),r.push(new _z(c,S,d))}this._consume(J.tokens.brace_right,"Expected '}' after struct body.");const o=this._currentLine,h=new hc(i,r,e,o);return this._context.structs.set(i,h),h}_global_variable_decl(){const e=this._variable_decl();return e&&this._match(J.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(J.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(J.keywords.const))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const h=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=h)}let r=null;if(this._match(J.tokens.equal)){const h=this._short_circuit_or_expression();if(h instanceof $h)r=h;else if(h instanceof VS&&h.initializer instanceof $h)r=h.initializer;else try{const d=h.evaluate(this._context);r=new jS(d)}catch{r=h}}const o=new LS(e.toString(),i,"","",r);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(J.keywords.let))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const o=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=o)}let r=null;return this._match(J.tokens.equal)&&(r=this._const_expression()),new jb(e.toString(),i,"","",r)}_const_expression(){if(this._match(J.const_literal))return new US(this._previous().toString());const e=this._type_decl();this._consume(J.tokens.paren_left,"Expected '('.");let i=[];for(;!this._check(J.tokens.paren_right)&&(i.push(this._const_expression()),!!this._check(J.tokens.comma));)this._advance();return this._consume(J.tokens.paren_right,"Expected ')'."),new $h(e,i)}_variable_decl(){if(!this._match(J.keywords.var))return null;let e="",i="";this._match(J.tokens.less_than)&&(e=this._consume(J.storage_class,"Expected storage_class.").toString(),this._match(J.tokens.comma)&&(i=this._consume(J.access_mode,"Expected access_mode.").toString()),this._consume(J.tokens.greater_than,"Expected '>'."));const r=this._consume(J.tokens.ident,"Expected variable name");let o=null;if(this._match(J.tokens.colon)){const h=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=h)}return new fc(r.toString(),o,e,i,null)}_override_decl(){if(!this._match(J.keywords.override))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const r=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=r)}return new zI(e.toString(),i,null)}_diagnostic(){this._consume(J.tokens.paren_left,"Expected '('");const e=this._consume(J.tokens.ident,"Expected severity control name.");this._consume(J.tokens.comma,"Expected ','");const i=this._consume(J.tokens.ident,"Expected diagnostic rule name.");return this._consume(J.tokens.paren_right,"Expected ')'"),new iz(e.toString(),i.toString())}_enable_directive(){const e=this._consume(J.tokens.ident,"identity expected.");return new ez(e.toString())}_requires_directive(){const e=[this._consume(J.tokens.ident,"identity expected.").toString()];for(;this._match(J.tokens.comma);){const i=this._consume(J.tokens.ident,"identity expected.");e.push(i.toString())}return new tz(e)}_type_alias(){const e=this._consume(J.tokens.ident,"identity expected.");this._consume(J.tokens.equal,"Expected '=' for type alias.");let i=this._type_decl();if(i===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);const r=new UI(e.toString(),i);return this._context.aliases.set(r.name,r),r}_type_decl(){if(this._check([J.tokens.ident,...J.texel_format,J.keywords.bool,J.keywords.f32,J.keywords.i32,J.keywords.u32])){const r=this._advance(),o=r.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new Bc(r.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(J.template_types)){let r=this._advance().toString(),o=null,h=null;return this._match(J.tokens.less_than)&&(o=this._type_decl(),h=null,this._match(J.tokens.comma)&&(h=this._consume(J.access_mode,"Expected access_mode for pointer").toString()),this._consume(J.tokens.greater_than,"Expected '>' for type.")),new VI(r,o,h)}if(this._match(J.keywords.ptr)){let r=this._previous().toString();this._consume(J.tokens.less_than,"Expected '<' for pointer.");const o=this._consume(J.storage_class,"Expected storage_class for pointer");this._consume(J.tokens.comma,"Expected ',' for pointer.");const h=this._type_decl();let d=null;return this._match(J.tokens.comma)&&(d=this._consume(J.access_mode,"Expected access_mode for pointer").toString()),this._consume(J.tokens.greater_than,"Expected '>' for pointer."),new oz(r,o.toString(),h,d)}const i=this._attribute();if(this._match(J.keywords.array)){let r=null,o=-1;const h=this._previous();let d=null;if(this._match(J.tokens.less_than)){r=this._type_decl(),this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let x="";if(this._match(J.tokens.comma)){d=this._shift_expression();try{x=d.evaluate(this._context).toString(),d=null}catch{x="1"}}this._consume(J.tokens.greater_than,"Expected '>' for array."),o=x?parseInt(x):0}const c=new jI(h.toString(),i,r,o);return d&&this._deferArrayCountEval.push({arrayType:c,countNode:d}),c}return null}_texture_sampler_types(){if(this._match(J.sampler_type))return new cf(this._previous().toString(),null,null);if(this._match(J.depth_texture_type))return new cf(this._previous().toString(),null,null);if(this._match(J.sampled_texture_type)||this._match(J.multisampled_texture_type)){const e=this._previous();this._consume(J.tokens.less_than,"Expected '<' for sampler type.");const i=this._type_decl();return this._consume(J.tokens.greater_than,"Expected '>' for sampler type."),new cf(e.toString(),i,null)}if(this._match(J.storage_texture_type)){const e=this._previous();this._consume(J.tokens.less_than,"Expected '<' for sampler type.");const i=this._consume(J.texel_format,"Invalid texel format.").toString();this._consume(J.tokens.comma,"Expected ',' after texel format.");const r=this._consume(J.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(J.tokens.greater_than,"Expected '>' for sampler type."),new cf(e.toString(),i,r)}return null}_attribute(){let e=[];for(;this._match(J.tokens.attr);){const i=this._consume(J.attribute_name,"Expected attribute name"),r=new gz(i.toString(),null);if(this._match(J.tokens.paren_left)){if(r.value=this._consume(J.literal_or_ident,"Expected attribute value").toString(),this._check(J.tokens.comma)){this._advance();do{const o=this._consume(J.literal_or_ident,"Expected attribute value").toString();r.value instanceof Array||(r.value=[r.value]),r.value.push(o)}while(this._match(J.tokens.comma))}this._consume(J.tokens.paren_right,"Expected ')'")}e.push(r)}return e.length==0?null:e}}class ru{constructor(e,i){this.name=e,this.attributes=i,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}}class HS{constructor(e,i,r){this.name=e,this.type=i,this.attributes=r,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class C_ extends ru{constructor(e,i){super(e,i),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class U0 extends ru{constructor(e,i){super(e,i),this.count=0,this.stride=0}get isArray(){return!0}}class XS extends ru{constructor(e,i,r,o){super(e,r),this.format=i,this.access=o}get isTemplate(){return!0}}var il;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(il||(il={}));class M_{constructor(e,i,r,o,h,d,c){this.name=e,this.type=i,this.group=r,this.binding=o,this.attributes=h,this.resourceType=d,this.access=c}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class bz{constructor(e,i){this.name=e,this.type=i}}class k_{constructor(e,i){this.align=e,this.size=i}}class vz{constructor(e,i,r,o){this.name=e,this.type=i,this.locationType=r,this.location=o,this.interpolation=null}}class qS{constructor(e,i,r,o){this.name=e,this.type=i,this.locationType=r,this.location=o}}class xz{constructor(e,i=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=i}}class wz{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}class Tz{constructor(e,i,r,o){this.name=e,this.type=i,this.attributes=r,this.id=o}}class Sz{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class ga{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new wz,this.functions=[],this._types=new Map,this._functions=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){const r=new yz().parse(e);for(const o of r)o instanceof Vb&&this._functions.set(o.name,new Sz(o));for(const o of r)if(o instanceof hc){const h=this._getTypeInfo(o,null);h instanceof C_&&this.structs.push(h)}for(const o of r){if(o instanceof UI){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof zI){const h=o,d=this._getAttributeNum(h.attributes,"id",0),c=h.type!=null?this._getTypeInfo(h.type,h.attributes):null;this.overrides.push(new Tz(h.name,c,h.attributes,d));continue}if(this._isUniformVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=new M_(h.name,x,d,c,h.attributes,il.Uniform,h.access);this.uniforms.push(S);continue}if(this._isStorageVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=this._isStorageTexture(x),P=new M_(h.name,x,d,c,h.attributes,S?il.StorageTexture:il.Storage,h.access);this.storage.push(P);continue}if(this._isTextureVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=this._isStorageTexture(x),P=new M_(h.name,x,d,c,h.attributes,S?il.StorageTexture:il.Texture,h.access);S?this.storage.push(P):this.textures.push(P);continue}if(this._isSamplerVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=new M_(h.name,x,d,c,h.attributes,il.Sampler,h.access);this.samplers.push(S);continue}if(o instanceof Vb){const h=this._getAttribute(o,"vertex"),d=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),x=h||d||c,S=new xz(o.name,x==null?void 0:x.name);S.startLine=o.startLine,S.endLine=o.endLine,this.functions.push(S),this._functions.get(o.name).info=S,x&&(this._functions.get(o.name).inUse=!0,S.inUse=!0,S.resources=this._findResources(o,!!x),S.inputs=this._getInputs(o.args),S.outputs=this._getOutputs(o.returnType),this.entry[x.name].push(S));continue}}for(const o of this._functions.values())o.info&&(o.info.inUse=o.inUse,this._addCalls(o.node,o.info.calls));for(const o of this.uniforms)this._markStructsInUse(o.type);for(const o of this.storage)this._markStructsInUse(o.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(const i of e.members)this._markStructsInUse(i.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{const i=this._getAlias(e.name);i&&this._markStructsInUse(i)}}_addCalls(e,i){var r;for(const o of e.calls){const h=(r=this._functions.get(o.name))===null||r===void 0?void 0:r.info;h&&i.add(h)}}findResource(e,i){for(const r of this.uniforms)if(r.group==e&&r.binding==i)return r;for(const r of this.storage)if(r.group==e&&r.binding==i)return r;for(const r of this.textures)if(r.group==e&&r.binding==i)return r;for(const r of this.samplers)if(r.group==e&&r.binding==i)return r;return null}_findResource(e){for(const i of this.uniforms)if(i.name==e)return i;for(const i of this.storage)if(i.name==e)return i;for(const i of this.textures)if(i.name==e)return i;for(const i of this.samplers)if(i.name==e)return i;return null}_markStructsFromAST(e){const i=this._getTypeInfo(e,null);this._markStructsInUse(i)}_findResources(e,i){const r=[],o=this,h=[];return e.search(d=>{if(d instanceof wg)h.push({});else if(d instanceof Tg)h.pop();else if(d instanceof fc){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type),h.length>0&&(h[h.length-1][c.name]=c)}else if(d instanceof $h){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type)}else if(d instanceof jb){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type),h.length>0&&(h[h.length-1][c.name]=c)}else if(d instanceof $b){const c=d;if(h.length>0&&h[h.length-1][c.name])return;const x=o._findResource(c.name);x&&r.push(x)}else if(d instanceof $I){const c=d,x=o._functions.get(c.name);x&&(i&&(x.inUse=!0),e.calls.add(x.node),x.resources===null&&(x.resources=o._findResources(x.node,i)),r.push(...x.resources))}else if(d instanceof LI){const c=d,x=o._functions.get(c.name);x&&(i&&(x.inUse=!0),e.calls.add(x.node),x.resources===null&&(x.resources=o._findResources(x.node,i)),r.push(...x.resources))}}),[...new Map(r.map(d=>[d.name,d])).values()]}getBindGroups(){const e=[];function i(r,o){r>=e.length&&(e.length=r+1),e[r]===void 0&&(e[r]=[]),o>=e[r].length&&(e[r].length=o+1)}for(const r of this.uniforms){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.storage){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.textures){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.samplers){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}return e}_getOutputs(e,i=void 0){if(i===void 0&&(i=[]),e instanceof hc)this._getStructOutputs(e,i);else{const r=this._getOutputInfo(e);r!==null&&i.push(r)}return i}_getStructOutputs(e,i){for(const r of e.members)if(r.type instanceof hc)this._getStructOutputs(r.type,i);else{const o=this._getAttribute(r,"location")||this._getAttribute(r,"builtin");if(o!==null){const h=this._getTypeInfo(r.type,r.type.attributes),d=this._parseInt(o.value),c=new qS(r.name,h,o.name,d);i.push(c)}}}_getOutputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const r=this._getTypeInfo(e,e.attributes),o=this._parseInt(i.value);return new qS("",r,i.name,o)}return null}_getInputs(e,i=void 0){i===void 0&&(i=[]);for(const r of e)if(r.type instanceof hc)this._getStructInputs(r.type,i);else{const o=this._getInputInfo(r);o!==null&&i.push(o)}return i}_getStructInputs(e,i){for(const r of e.members)if(r.type instanceof hc)this._getStructInputs(r.type,i);else{const o=this._getInputInfo(r);o!==null&&i.push(o)}}_getInputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const r=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),h=this._parseInt(i.value),d=new vz(e.name,o,i.name,h);return r!==null&&(d.interpolation=this._parseString(r.value)),d}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const i=parseInt(e);return isNaN(i)?e:i}_getAlias(e){for(const i of this.aliases)if(i.name==e)return i.type;return null}_getAliasInfo(e){return new bz(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,i){if(this._types.has(e))return this._types.get(e);if(e instanceof jI){const o=e,h=this._getTypeInfo(o.format,o.attributes),d=new U0(o.name,i);return d.format=h,d.count=o.count,this._types.set(e,d),this._updateTypeInfo(d),d}if(e instanceof hc){const o=e,h=new C_(o.name,i);h.startLine=o.startLine,h.endLine=o.endLine;for(const d of o.members){const c=this._getTypeInfo(d.type,d.attributes);h.members.push(new HS(d.name,c,d.attributes))}return this._types.set(e,h),this._updateTypeInfo(h),h}if(e instanceof cf){const o=e,h=o.format instanceof Bc,d=o.format?h?this._getTypeInfo(o.format,null):new ru(o.format,null):null,c=new XS(o.name,d,i,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof VI){const o=e,h=o.format?this._getTypeInfo(o.format,null):null,d=new XS(o.name,h,i,o.access);return this._types.set(e,d),this._updateTypeInfo(d),d}const r=new ru(e.name,i);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var i,r;const o=this._getTypeSize(e);if(e.size=(i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,e instanceof U0){const h=this._getTypeSize(e.format);e.stride=(r=h==null?void 0:h.size)!==null&&r!==void 0?r:0,this._updateTypeInfo(e.format)}e instanceof C_&&this._updateStructInfo(e)}_updateStructInfo(e){var i;let r=0,o=0,h=0,d=0;for(let c=0,x=e.members.length;ct.name);ga._samplerTypes=J.sampler_type.map(t=>t.name);function Ez(t){var h;const e={attributes:[],bindings:[]};let i;try{i=Az(t)}catch(d){return it.error(d.message)(),e}for(const d of i.uniforms){const c=[];for(const x of((h=d.type)==null?void 0:h.members)||[])c.push({name:x.name,type:ZS(x.type)});e.bindings.push({type:"uniform",name:d.name,location:d.binding,group:d.group,members:c})}const r=i.entry.vertex[0],o=(r==null?void 0:r.inputs.length)||0;for(let d=0;d`:t.name}function Az(t){try{return new ga(t)}catch(e){if(e instanceof Error)throw e;let i="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(i+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(i+=e.token.line||""),new Error(i,{cause:e})}}const Iz=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
+`)this._line++;else if(e=="*"){if(this._peekAhead()=="/"&&(this._advance(),d--,d==0))return!0}else e=="/"&&this._peekAhead()=="*"&&(this._advance(),d++)}return!0}}const i=J.simpleTokens[e];if(i)return this._addToken(i),!0;let r=J.none;const o=this._isAlpha(e),h=e==="_";if(this._isAlphaNumeric(e)){let d=this._peekAhead();for(;this._isAlphaNumeric(d);)e+=this._advance(),d=this._peekAhead()}if(o){const d=J.keywords[e];if(d)return this._addToken(d),!0}if(o||h)return this._addToken(J.tokens.ident),!0;for(;;){let d=this._findType(e);const c=this._peekAhead();if(e==">"&&(c==">"||c=="=")){let x=!1,S=this._tokens.length-1;for(let P=0;P<5&&S>=0&&J.assignment_operators.indexOf(this._tokens[S].type)===-1;++P,--S)if(this._tokens[S].type===J.tokens.less_than){S>0&&this._tokens[S-1].isArrayOrTemplateType()&&(x=!0);break}if(x)return this._addToken(d),!0}if(d===J.none){let x=e,S=0;const P=2;for(let M=0;M=this._source.length}_isAlpha(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"}_isAlphaNumeric(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||e=="_"||e>="0"&&e<="9"}_isWhitespace(e){return e==" "||e==" "||e=="\r"}_advance(e=0){let i=this._source[this._current];return e=e||0,e++,this._current+=e,i}_peekAhead(e=0){return e=e||0,this._current+e>=this._source.length?"\0":this._source[this._current+e]}_addToken(e){const i=this._source.substring(this._start,this._current);this._tokens.push(new WS(e,i,this._line))}}class y6{constructor(){this._tokens=[],this._current=0,this._currentLine=0,this._context=new $4,this._deferArrayCountEval=[]}parse(e){this._initialize(e),this._deferArrayCountEval.length=0;const i=[];for(;!this._isAtEnd();){const r=this._global_decl_or_directive();if(!r)break;i.push(r)}if(this._deferArrayCountEval.length>0){for(const r of this._deferArrayCountEval){const o=r.arrayType,h=r.countNode;if(h instanceof $b){const c=h.name,x=this._context.constants.get(c);if(x)try{const S=x.evaluate(this._context);o.count=S}catch{}}}this._deferArrayCountEval.length=0}return i}_initialize(e){if(e)if(typeof e=="string"){const i=new m6(e);this._tokens=i.scanTokens()}else this._tokens=e;else this._tokens=[];this._current=0}_error(e,i){return{token:e,message:i,toString:function(){return`${i}`}}}_isAtEnd(){return this._current>=this._tokens.length||this._peek().type==J.eof}_match(e){if(e instanceof Te)return this._check(e)?(this._advance(),!0):!1;for(let i=0,r=e.length;i'.");const o=this._paren_expression();return new a6(r,o)}const e=this._type_decl(),i=this._argument_expression_list();return new l6(e,i)}_argument_expression_list(){if(!this._match(J.tokens.paren_left))return null;const e=[];do{if(this._check(J.tokens.paren_right))break;const i=this._short_circuit_or_expression();e.push(i)}while(this._match(J.tokens.comma));return this._consume(J.tokens.paren_right,"Expected ')' for agument list"),e}_optional_paren_expression(){this._match(J.tokens.paren_left);const e=this._short_circuit_or_expression();return this._match(J.tokens.paren_right),new $S([e])}_paren_expression(){this._consume(J.tokens.paren_left,"Expected '('.");const e=this._short_circuit_or_expression();return this._consume(J.tokens.paren_right,"Expected ')'."),new $S([e])}_struct_decl(){if(!this._match(J.keywords.struct))return null;const e=this._currentLine,i=this._consume(J.tokens.ident,"Expected name for struct.").toString();this._consume(J.tokens.brace_left,"Expected '{' for struct body.");const r=[];for(;!this._check(J.tokens.brace_right);){const d=this._attribute(),c=this._consume(J.tokens.ident,"Expected variable name.").toString();this._consume(J.tokens.colon,"Expected ':' for struct member type.");const x=this._attribute(),S=this._type_decl();S!=null&&(S.attributes=x),this._check(J.tokens.brace_right)?this._match(J.tokens.comma):this._consume(J.tokens.comma,"Expected ',' for struct member."),r.push(new _6(c,S,d))}this._consume(J.tokens.brace_right,"Expected '}' after struct body.");const o=this._currentLine,h=new hc(i,r,e,o);return this._context.structs.set(i,h),h}_global_variable_decl(){const e=this._variable_decl();return e&&this._match(J.tokens.equal)&&(e.value=this._const_expression()),e}_override_variable_decl(){const e=this._override_decl();return e&&this._match(J.tokens.equal)&&(e.value=this._const_expression()),e}_global_const_decl(){if(!this._match(J.keywords.const))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const h=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=h)}let r=null;if(this._match(J.tokens.equal)){const h=this._short_circuit_or_expression();if(h instanceof $h)r=h;else if(h instanceof VS&&h.initializer instanceof $h)r=h.initializer;else try{const d=h.evaluate(this._context);r=new jS(d)}catch{r=h}}const o=new LS(e.toString(),i,"","",r);return this._context.constants.set(o.name,o),o}_global_let_decl(){if(!this._match(J.keywords.let))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const o=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=o)}let r=null;return this._match(J.tokens.equal)&&(r=this._const_expression()),new jb(e.toString(),i,"","",r)}_const_expression(){if(this._match(J.const_literal))return new US(this._previous().toString());const e=this._type_decl();this._consume(J.tokens.paren_left,"Expected '('.");let i=[];for(;!this._check(J.tokens.paren_right)&&(i.push(this._const_expression()),!!this._check(J.tokens.comma));)this._advance();return this._consume(J.tokens.paren_right,"Expected ')'."),new $h(e,i)}_variable_decl(){if(!this._match(J.keywords.var))return null;let e="",i="";this._match(J.tokens.less_than)&&(e=this._consume(J.storage_class,"Expected storage_class.").toString(),this._match(J.tokens.comma)&&(i=this._consume(J.access_mode,"Expected access_mode.").toString()),this._consume(J.tokens.greater_than,"Expected '>'."));const r=this._consume(J.tokens.ident,"Expected variable name");let o=null;if(this._match(J.tokens.colon)){const h=this._attribute();o=this._type_decl(),o!=null&&(o.attributes=h)}return new fc(r.toString(),o,e,i,null)}_override_decl(){if(!this._match(J.keywords.override))return null;const e=this._consume(J.tokens.ident,"Expected variable name");let i=null;if(this._match(J.tokens.colon)){const r=this._attribute();i=this._type_decl(),i!=null&&(i.attributes=r)}return new zI(e.toString(),i,null)}_diagnostic(){this._consume(J.tokens.paren_left,"Expected '('");const e=this._consume(J.tokens.ident,"Expected severity control name.");this._consume(J.tokens.comma,"Expected ','");const i=this._consume(J.tokens.ident,"Expected diagnostic rule name.");return this._consume(J.tokens.paren_right,"Expected ')'"),new i6(e.toString(),i.toString())}_enable_directive(){const e=this._consume(J.tokens.ident,"identity expected.");return new e6(e.toString())}_requires_directive(){const e=[this._consume(J.tokens.ident,"identity expected.").toString()];for(;this._match(J.tokens.comma);){const i=this._consume(J.tokens.ident,"identity expected.");e.push(i.toString())}return new t6(e)}_type_alias(){const e=this._consume(J.tokens.ident,"identity expected.");this._consume(J.tokens.equal,"Expected '=' for type alias.");let i=this._type_decl();if(i===null)throw this._error(this._peek(),"Expected Type for Alias.");this._context.aliases.has(i.name)&&(i=this._context.aliases.get(i.name).type);const r=new UI(e.toString(),i);return this._context.aliases.set(r.name,r),r}_type_decl(){if(this._check([J.tokens.ident,...J.texel_format,J.keywords.bool,J.keywords.f32,J.keywords.i32,J.keywords.u32])){const r=this._advance(),o=r.toString();return this._context.structs.has(o)?this._context.structs.get(o):this._context.aliases.has(o)?this._context.aliases.get(o).type:new Bc(r.toString())}let e=this._texture_sampler_types();if(e)return e;if(this._check(J.template_types)){let r=this._advance().toString(),o=null,h=null;return this._match(J.tokens.less_than)&&(o=this._type_decl(),h=null,this._match(J.tokens.comma)&&(h=this._consume(J.access_mode,"Expected access_mode for pointer").toString()),this._consume(J.tokens.greater_than,"Expected '>' for type.")),new VI(r,o,h)}if(this._match(J.keywords.ptr)){let r=this._previous().toString();this._consume(J.tokens.less_than,"Expected '<' for pointer.");const o=this._consume(J.storage_class,"Expected storage_class for pointer");this._consume(J.tokens.comma,"Expected ',' for pointer.");const h=this._type_decl();let d=null;return this._match(J.tokens.comma)&&(d=this._consume(J.access_mode,"Expected access_mode for pointer").toString()),this._consume(J.tokens.greater_than,"Expected '>' for pointer."),new o6(r,o.toString(),h,d)}const i=this._attribute();if(this._match(J.keywords.array)){let r=null,o=-1;const h=this._previous();let d=null;if(this._match(J.tokens.less_than)){r=this._type_decl(),this._context.aliases.has(r.name)&&(r=this._context.aliases.get(r.name).type);let x="";if(this._match(J.tokens.comma)){d=this._shift_expression();try{x=d.evaluate(this._context).toString(),d=null}catch{x="1"}}this._consume(J.tokens.greater_than,"Expected '>' for array."),o=x?parseInt(x):0}const c=new jI(h.toString(),i,r,o);return d&&this._deferArrayCountEval.push({arrayType:c,countNode:d}),c}return null}_texture_sampler_types(){if(this._match(J.sampler_type))return new cf(this._previous().toString(),null,null);if(this._match(J.depth_texture_type))return new cf(this._previous().toString(),null,null);if(this._match(J.sampled_texture_type)||this._match(J.multisampled_texture_type)){const e=this._previous();this._consume(J.tokens.less_than,"Expected '<' for sampler type.");const i=this._type_decl();return this._consume(J.tokens.greater_than,"Expected '>' for sampler type."),new cf(e.toString(),i,null)}if(this._match(J.storage_texture_type)){const e=this._previous();this._consume(J.tokens.less_than,"Expected '<' for sampler type.");const i=this._consume(J.texel_format,"Invalid texel format.").toString();this._consume(J.tokens.comma,"Expected ',' after texel format.");const r=this._consume(J.access_mode,"Expected access mode for storage texture type.").toString();return this._consume(J.tokens.greater_than,"Expected '>' for sampler type."),new cf(e.toString(),i,r)}return null}_attribute(){let e=[];for(;this._match(J.tokens.attr);){const i=this._consume(J.attribute_name,"Expected attribute name"),r=new g6(i.toString(),null);if(this._match(J.tokens.paren_left)){if(r.value=this._consume(J.literal_or_ident,"Expected attribute value").toString(),this._check(J.tokens.comma)){this._advance();do{const o=this._consume(J.literal_or_ident,"Expected attribute value").toString();r.value instanceof Array||(r.value=[r.value]),r.value.push(o)}while(this._match(J.tokens.comma))}this._consume(J.tokens.paren_right,"Expected ')'")}e.push(r)}return e.length==0?null:e}}class ru{constructor(e,i){this.name=e,this.attributes=i,this.size=0}get isArray(){return!1}get isStruct(){return!1}get isTemplate(){return!1}}class HS{constructor(e,i,r){this.name=e,this.type=i,this.attributes=r,this.offset=0,this.size=0}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class C_ extends ru{constructor(e,i){super(e,i),this.members=[],this.align=0,this.startLine=-1,this.endLine=-1,this.inUse=!1}get isStruct(){return!0}}class U0 extends ru{constructor(e,i){super(e,i),this.count=0,this.stride=0}get isArray(){return!0}}class XS extends ru{constructor(e,i,r,o){super(e,r),this.format=i,this.access=o}get isTemplate(){return!0}}var il;(function(t){t[t.Uniform=0]="Uniform",t[t.Storage=1]="Storage",t[t.Texture=2]="Texture",t[t.Sampler=3]="Sampler",t[t.StorageTexture=4]="StorageTexture"})(il||(il={}));class M_{constructor(e,i,r,o,h,d,c){this.name=e,this.type=i,this.group=r,this.binding=o,this.attributes=h,this.resourceType=d,this.access=c}get isArray(){return this.type.isArray}get isStruct(){return this.type.isStruct}get isTemplate(){return this.type.isTemplate}get size(){return this.type.size}get align(){return this.type.isStruct?this.type.align:0}get members(){return this.type.isStruct?this.type.members:null}get format(){return this.type.isArray?this.type.format:this.type.isTemplate?this.type.format:null}get count(){return this.type.isArray?this.type.count:0}get stride(){return this.type.isArray?this.type.stride:this.size}}class b6{constructor(e,i){this.name=e,this.type=i}}class k_{constructor(e,i){this.align=e,this.size=i}}class v6{constructor(e,i,r,o){this.name=e,this.type=i,this.locationType=r,this.location=o,this.interpolation=null}}class qS{constructor(e,i,r,o){this.name=e,this.type=i,this.locationType=r,this.location=o}}class x6{constructor(e,i=null){this.stage=null,this.inputs=[],this.outputs=[],this.resources=[],this.startLine=-1,this.endLine=-1,this.inUse=!1,this.calls=new Set,this.name=e,this.stage=i}}class w6{constructor(){this.vertex=[],this.fragment=[],this.compute=[]}}class T6{constructor(e,i,r,o){this.name=e,this.type=i,this.attributes=r,this.id=o}}class S6{constructor(e){this.resources=null,this.inUse=!1,this.info=null,this.node=e}}class ga{constructor(e){this.uniforms=[],this.storage=[],this.textures=[],this.samplers=[],this.aliases=[],this.overrides=[],this.structs=[],this.entry=new w6,this.functions=[],this._types=new Map,this._functions=new Map,e&&this.update(e)}_isStorageTexture(e){return e.name=="texture_storage_1d"||e.name=="texture_storage_2d"||e.name=="texture_storage_2d_array"||e.name=="texture_storage_3d"}update(e){const r=new y6().parse(e);for(const o of r)o instanceof Vb&&this._functions.set(o.name,new S6(o));for(const o of r)if(o instanceof hc){const h=this._getTypeInfo(o,null);h instanceof C_&&this.structs.push(h)}for(const o of r){if(o instanceof UI){this.aliases.push(this._getAliasInfo(o));continue}if(o instanceof zI){const h=o,d=this._getAttributeNum(h.attributes,"id",0),c=h.type!=null?this._getTypeInfo(h.type,h.attributes):null;this.overrides.push(new T6(h.name,c,h.attributes,d));continue}if(this._isUniformVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=new M_(h.name,x,d,c,h.attributes,il.Uniform,h.access);this.uniforms.push(S);continue}if(this._isStorageVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=this._isStorageTexture(x),P=new M_(h.name,x,d,c,h.attributes,S?il.StorageTexture:il.Storage,h.access);this.storage.push(P);continue}if(this._isTextureVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=this._isStorageTexture(x),P=new M_(h.name,x,d,c,h.attributes,S?il.StorageTexture:il.Texture,h.access);S?this.storage.push(P):this.textures.push(P);continue}if(this._isSamplerVar(o)){const h=o,d=this._getAttributeNum(h.attributes,"group",0),c=this._getAttributeNum(h.attributes,"binding",0),x=this._getTypeInfo(h.type,h.attributes),S=new M_(h.name,x,d,c,h.attributes,il.Sampler,h.access);this.samplers.push(S);continue}if(o instanceof Vb){const h=this._getAttribute(o,"vertex"),d=this._getAttribute(o,"fragment"),c=this._getAttribute(o,"compute"),x=h||d||c,S=new x6(o.name,x==null?void 0:x.name);S.startLine=o.startLine,S.endLine=o.endLine,this.functions.push(S),this._functions.get(o.name).info=S,x&&(this._functions.get(o.name).inUse=!0,S.inUse=!0,S.resources=this._findResources(o,!!x),S.inputs=this._getInputs(o.args),S.outputs=this._getOutputs(o.returnType),this.entry[x.name].push(S));continue}}for(const o of this._functions.values())o.info&&(o.info.inUse=o.inUse,this._addCalls(o.node,o.info.calls));for(const o of this.uniforms)this._markStructsInUse(o.type);for(const o of this.storage)this._markStructsInUse(o.type)}_markStructsInUse(e){if(e.isStruct){e.inUse=!0;for(const i of e.members)this._markStructsInUse(i.type)}else if(e.isArray)this._markStructsInUse(e.format);else if(e.isTemplate)this._markStructsInUse(e.format);else{const i=this._getAlias(e.name);i&&this._markStructsInUse(i)}}_addCalls(e,i){var r;for(const o of e.calls){const h=(r=this._functions.get(o.name))===null||r===void 0?void 0:r.info;h&&i.add(h)}}findResource(e,i){for(const r of this.uniforms)if(r.group==e&&r.binding==i)return r;for(const r of this.storage)if(r.group==e&&r.binding==i)return r;for(const r of this.textures)if(r.group==e&&r.binding==i)return r;for(const r of this.samplers)if(r.group==e&&r.binding==i)return r;return null}_findResource(e){for(const i of this.uniforms)if(i.name==e)return i;for(const i of this.storage)if(i.name==e)return i;for(const i of this.textures)if(i.name==e)return i;for(const i of this.samplers)if(i.name==e)return i;return null}_markStructsFromAST(e){const i=this._getTypeInfo(e,null);this._markStructsInUse(i)}_findResources(e,i){const r=[],o=this,h=[];return e.search(d=>{if(d instanceof wg)h.push({});else if(d instanceof Tg)h.pop();else if(d instanceof fc){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type),h.length>0&&(h[h.length-1][c.name]=c)}else if(d instanceof $h){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type)}else if(d instanceof jb){const c=d;i&&c.type!==null&&this._markStructsFromAST(c.type),h.length>0&&(h[h.length-1][c.name]=c)}else if(d instanceof $b){const c=d;if(h.length>0&&h[h.length-1][c.name])return;const x=o._findResource(c.name);x&&r.push(x)}else if(d instanceof $I){const c=d,x=o._functions.get(c.name);x&&(i&&(x.inUse=!0),e.calls.add(x.node),x.resources===null&&(x.resources=o._findResources(x.node,i)),r.push(...x.resources))}else if(d instanceof LI){const c=d,x=o._functions.get(c.name);x&&(i&&(x.inUse=!0),e.calls.add(x.node),x.resources===null&&(x.resources=o._findResources(x.node,i)),r.push(...x.resources))}}),[...new Map(r.map(d=>[d.name,d])).values()]}getBindGroups(){const e=[];function i(r,o){r>=e.length&&(e.length=r+1),e[r]===void 0&&(e[r]=[]),o>=e[r].length&&(e[r].length=o+1)}for(const r of this.uniforms){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.storage){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.textures){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}for(const r of this.samplers){i(r.group,r.binding);const o=e[r.group];o[r.binding]=r}return e}_getOutputs(e,i=void 0){if(i===void 0&&(i=[]),e instanceof hc)this._getStructOutputs(e,i);else{const r=this._getOutputInfo(e);r!==null&&i.push(r)}return i}_getStructOutputs(e,i){for(const r of e.members)if(r.type instanceof hc)this._getStructOutputs(r.type,i);else{const o=this._getAttribute(r,"location")||this._getAttribute(r,"builtin");if(o!==null){const h=this._getTypeInfo(r.type,r.type.attributes),d=this._parseInt(o.value),c=new qS(r.name,h,o.name,d);i.push(c)}}}_getOutputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const r=this._getTypeInfo(e,e.attributes),o=this._parseInt(i.value);return new qS("",r,i.name,o)}return null}_getInputs(e,i=void 0){i===void 0&&(i=[]);for(const r of e)if(r.type instanceof hc)this._getStructInputs(r.type,i);else{const o=this._getInputInfo(r);o!==null&&i.push(o)}return i}_getStructInputs(e,i){for(const r of e.members)if(r.type instanceof hc)this._getStructInputs(r.type,i);else{const o=this._getInputInfo(r);o!==null&&i.push(o)}}_getInputInfo(e){const i=this._getAttribute(e,"location")||this._getAttribute(e,"builtin");if(i!==null){const r=this._getAttribute(e,"interpolation"),o=this._getTypeInfo(e.type,e.attributes),h=this._parseInt(i.value),d=new v6(e.name,o,i.name,h);return r!==null&&(d.interpolation=this._parseString(r.value)),d}return null}_parseString(e){return e instanceof Array&&(e=e[0]),e}_parseInt(e){e instanceof Array&&(e=e[0]);const i=parseInt(e);return isNaN(i)?e:i}_getAlias(e){for(const i of this.aliases)if(i.name==e)return i.type;return null}_getAliasInfo(e){return new b6(e.name,this._getTypeInfo(e.type,null))}_getTypeInfo(e,i){if(this._types.has(e))return this._types.get(e);if(e instanceof jI){const o=e,h=this._getTypeInfo(o.format,o.attributes),d=new U0(o.name,i);return d.format=h,d.count=o.count,this._types.set(e,d),this._updateTypeInfo(d),d}if(e instanceof hc){const o=e,h=new C_(o.name,i);h.startLine=o.startLine,h.endLine=o.endLine;for(const d of o.members){const c=this._getTypeInfo(d.type,d.attributes);h.members.push(new HS(d.name,c,d.attributes))}return this._types.set(e,h),this._updateTypeInfo(h),h}if(e instanceof cf){const o=e,h=o.format instanceof Bc,d=o.format?h?this._getTypeInfo(o.format,null):new ru(o.format,null):null,c=new XS(o.name,d,i,o.access);return this._types.set(e,c),this._updateTypeInfo(c),c}if(e instanceof VI){const o=e,h=o.format?this._getTypeInfo(o.format,null):null,d=new XS(o.name,h,i,o.access);return this._types.set(e,d),this._updateTypeInfo(d),d}const r=new ru(e.name,i);return this._types.set(e,r),this._updateTypeInfo(r),r}_updateTypeInfo(e){var i,r;const o=this._getTypeSize(e);if(e.size=(i=o==null?void 0:o.size)!==null&&i!==void 0?i:0,e instanceof U0){const h=this._getTypeSize(e.format);e.stride=(r=h==null?void 0:h.size)!==null&&r!==void 0?r:0,this._updateTypeInfo(e.format)}e instanceof C_&&this._updateStructInfo(e)}_updateStructInfo(e){var i;let r=0,o=0,h=0,d=0;for(let c=0,x=e.members.length;ct.name);ga._samplerTypes=J.sampler_type.map(t=>t.name);function E6(t){var h;const e={attributes:[],bindings:[]};let i;try{i=A6(t)}catch(d){return it.error(d.message)(),e}for(const d of i.uniforms){const c=[];for(const x of((h=d.type)==null?void 0:h.members)||[])c.push({name:x.name,type:ZS(x.type)});e.bindings.push({type:"uniform",name:d.name,location:d.binding,group:d.group,members:c})}const r=i.entry.vertex[0],o=(r==null?void 0:r.inputs.length)||0;for(let d=0;d`:t.name}function A6(t){try{return new ga(t)}catch(e){if(e instanceof Error)throw e;let i="WGSL parse error";throw typeof e=="object"&&(e!=null&&e.message)&&(i+=`: ${e.message} `),typeof e=="object"&&(e!=null&&e.token)&&(i+=e.token.line||""),new Error(i,{cause:e})}}const I6=`#ifdef LUMA_FP32_TAN_PRECISION_WORKAROUND
const float TWO_PI = 6.2831854820251465;
const float PI_2 = 1.5707963705062866;
const float PI_16 = 0.1963495463132858;
@@ -230,7 +230,7 @@ return tan_taylor_fp32(a);
return tan(a);
#endif
}
-`,Pz={name:"fp32",vs:Iz},Rz=[0,1,1,1],Cz=`uniform pickingUniforms {
+`,P6={name:"fp32",vs:I6},R6=[0,1,1,1],C6=`uniform pickingUniforms {
float isActive;
float isAttribute;
float isHighlightActive;
@@ -282,7 +282,7 @@ if (bool(picking.isAttribute)) {
picking_vRGBcolor_Avalid.rgb = value;
}
}
-`,Mz=`uniform pickingUniforms {
+`,M6=`uniform pickingUniforms {
float isActive;
float isAttribute;
float isHighlightActive;
@@ -319,7 +319,7 @@ vec4 picking_filterColor(vec4 color) {
vec4 highlightColor = picking_filterHighlightColor(color);
return picking_filterPickingColor(highlightColor);
}
-`,YS={name:"picking",vs:Cz,fs:Mz,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:Rz},getUniforms:kz};function kz(t={},e){const i={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const r=t.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=r}if(t.highlightColor){const r=Array.from(t.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),i.highlightColor=r}return t.isActive!==void 0&&(i.isActive=!!t.isActive,i.isAttribute=!!t.isAttribute),t.useFloatColors!==void 0&&(i.useFloatColors=!!t.useFloatColors),i}function XI(t,e=[],i=0){const r=Math.fround(t),o=t-r;return e[i]=r,e[i+1]=o,e}function Dz(t){return t-Math.fround(t)}function Oz(t){const e=new Float32Array(32);for(let i=0;i<4;++i)for(let r=0;r<4;++r){const o=i*4+r;XI(t[r*4+i],e,o*2)}return e}const Fz=`uniform float ONE;
+`,YS={name:"picking",vs:C6,fs:M6,uniformTypes:{isActive:"f32",isAttribute:"f32",isHighlightActive:"f32",useFloatColors:"f32",highlightedObjectColor:"vec3",highlightColor:"vec4"},defaultUniforms:{isActive:!1,isAttribute:!1,isHighlightActive:!1,useFloatColors:!0,highlightedObjectColor:[0,0,0],highlightColor:R6},getUniforms:k6};function k6(t={},e){const i={};if(t.highlightedObjectColor!==void 0)if(t.highlightedObjectColor===null)i.isHighlightActive=!1;else{i.isHighlightActive=!0;const r=t.highlightedObjectColor.slice(0,3);i.highlightedObjectColor=r}if(t.highlightColor){const r=Array.from(t.highlightColor,o=>o/255);Number.isFinite(r[3])||(r[3]=1),i.highlightColor=r}return t.isActive!==void 0&&(i.isActive=!!t.isActive,i.isAttribute=!!t.isAttribute),t.useFloatColors!==void 0&&(i.useFloatColors=!!t.useFloatColors),i}function XI(t,e=[],i=0){const r=Math.fround(t),o=t-r;return e[i]=r,e[i+1]=o,e}function D6(t){return t-Math.fround(t)}function O6(t){const e=new Float32Array(32);for(let i=0;i<4;++i)for(let r=0;r<4;++r){const o=i*4+r;XI(t[r*4+i],e,o*2)}return e}const F6=`uniform float ONE;
vec2 split(float a) {
const float SPLIT = 4097.0;
float t = a * SPLIT;
@@ -451,7 +451,7 @@ return sum_fp64(split(yn), prod);
return sum_fp64(vec2(yn, 0.0), prod);
#endif
}
-`,Nz={ONE:1};function Bz(){return Nz}const zz={name:"fp64-arithmetic",vs:Fz,getUniforms:Bz,fp64ify:XI,fp64LowPart:Dz,fp64ifyMatrix4:Oz},Lz={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...Lz}};const Nn=globalThis.mathgl.config;function Uz(t,{precision:e=Nn.precision}={}){return t=Vz(t),`${parseFloat(t.toPrecision(e))}`}function du(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function al(t,e,i){return $z(t,r=>Math.max(e,Math.min(i,r)))}function Sg(t,e,i){return du(t)?t.map((r,o)=>Sg(r,e[o],i)):i*e+(1-i)*t}function Df(t,e,i){const r=Nn.EPSILON;try{if(t===e)return!0;if(du(t)&&du(e)){if(t.length!==e.length)return!1;for(let o=0;o0?", ":"")+Uz(this[r],e);return`${e.printTypes?this.constructor.name:""}[${i}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let i=0;i=0&&e=0&&eMath.PI*2)throw Error("expected radians")}function R6(t,e,i,r,o,h){const d=2*h/(i-e),c=2*h/(o-r),x=(i+e)/(i-e),S=(o+r)/(o-r),P=-1,M=-1,D=-2*h;return t[0]=d,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=x,t[9]=S,t[10]=P,t[11]=M,t[12]=0,t[13]=0,t[14]=D,t[15]=0,t}const QI="#define SMOOTH_EDGE_RADIUS 0.5",C6=`
+`,N6={ONE:1};function B6(){return N6}const z6={name:"fp64-arithmetic",vs:F6,getUniforms:B6,fp64ify:XI,fp64LowPart:D6,fp64ifyMatrix4:O6},L6={EPSILON:1e-12,debug:!1,precision:4,printTypes:!1,printDegrees:!1,printRowMajor:!0,_cartographicRadians:!1};globalThis.mathgl=globalThis.mathgl||{config:{...L6}};const Nn=globalThis.mathgl.config;function U6(t,{precision:e=Nn.precision}={}){return t=V6(t),`${parseFloat(t.toPrecision(e))}`}function du(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}function al(t,e,i){return $6(t,r=>Math.max(e,Math.min(i,r)))}function Sg(t,e,i){return du(t)?t.map((r,o)=>Sg(r,e[o],i)):i*e+(1-i)*t}function Df(t,e,i){const r=Nn.EPSILON;try{if(t===e)return!0;if(du(t)&&du(e)){if(t.length!==e.length)return!1;for(let o=0;o0?", ":"")+U6(this[r],e);return`${e.printTypes?this.constructor.name:""}[${i}]`}equals(e){if(!e||this.length!==e.length)return!1;for(let i=0;i=0&&e=0&&eMath.PI*2)throw Error("expected radians")}function Rz(t,e,i,r,o,h){const d=2*h/(i-e),c=2*h/(o-r),x=(i+e)/(i-e),S=(o+r)/(o-r),P=-1,M=-1,D=-2*h;return t[0]=d,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=x,t[9]=S,t[10]=P,t[11]=M,t[12]=0,t[13]=0,t[14]=D,t[15]=0,t}const QI="#define SMOOTH_EDGE_RADIUS 0.5",Cz=`
${QI}
struct VertexGeometry {
@@ -469,7 +469,7 @@ struct VertexGeometry {
vec2(0.0),
vec3(0.0)
);
-`,M6=`
+`,Mz=`
${QI}
struct FragmentGeometry {
@@ -479,9 +479,9 @@ struct FragmentGeometry {
float smoothedge(float edge, float x) {
return smoothstep(edge - SMOOTH_EDGE_RADIUS, edge + SMOOTH_EDGE_RADIUS, x);
}
-`,k6={name:"geometry",vs:C6,fs:M6},Ei={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Ei,"IDENTITY",{get:()=>(Ni.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const Co={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ag={common:0,meters:1,pixels:2},Xb={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},D6=Object.keys(Ei).map(t=>`const int COORDINATE_SYSTEM_${t} = ${Ei[t]};`).join(""),O6=Object.keys(Co).map(t=>`const int PROJECTION_MODE_${t} = ${Co[t]};`).join(""),F6=Object.keys(Ag).map(t=>`const int UNIT_${t.toUpperCase()} = ${Ag[t]};`).join(""),N6=`${D6}
-${O6}
-${F6}
+`,kz={name:"geometry",vs:Cz,fs:Mz},Ei={DEFAULT:-1,LNGLAT:1,METER_OFFSETS:2,LNGLAT_OFFSETS:3,CARTESIAN:0};Object.defineProperty(Ei,"IDENTITY",{get:()=>(Ni.deprecated("COORDINATE_SYSTEM.IDENTITY","COORDINATE_SYSTEM.CARTESIAN")(),0)});const Co={WEB_MERCATOR:1,GLOBE:2,WEB_MERCATOR_AUTO_OFFSET:4,IDENTITY:0},Ag={common:0,meters:1,pixels:2},Xb={click:{handler:"onClick"},panstart:{handler:"onDragStart"},panmove:{handler:"onDrag"},panend:{handler:"onDragEnd"}},Dz=Object.keys(Ei).map(t=>`const int COORDINATE_SYSTEM_${t} = ${Ei[t]};`).join(""),Oz=Object.keys(Co).map(t=>`const int PROJECTION_MODE_${t} = ${Co[t]};`).join(""),Fz=Object.keys(Ag).map(t=>`const int UNIT_${t.toUpperCase()} = ${Ag[t]};`).join(""),Nz=`${Dz}
+${Oz}
+${Fz}
uniform int project_uCoordinateSystem;
uniform int project_uProjectionMode;
uniform float project_uScale;
@@ -668,7 +668,7 @@ return pixels / project_uScale;
vec2 project_pixel_size(vec2 pixels) {
return pixels / project_uScale;
}
-`;function B6(t,e){if(t===e)return!0;if(Array.isArray(t)){const i=t.length;if(!e||e.length!==i)return!1;for(let r=0;r{for(const o in r)if(!B6(r[o],e[o])){i=t(r),e=r;break}return i}}const QS=[0,0,0,0],z6=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],eP=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],L6=[0,0,0],tP=[0,0,0],U6=tp($6);function iP(t,e,i=tP){i.length<3&&(i=[i[0],i[1],0]);let r=i,o,h=!0;switch(e===Ei.LNGLAT_OFFSETS||e===Ei.METER_OFFSETS?o=i:o=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case Co.WEB_MERCATOR:(e===Ei.LNGLAT||e===Ei.CARTESIAN)&&(o=[0,0,0],h=!1);break;case Co.WEB_MERCATOR_AUTO_OFFSET:e===Ei.LNGLAT?r=o:e===Ei.CARTESIAN&&(r=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],o=t.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case Co.IDENTITY:r=t.position.map(Math.fround),r[2]=r[2]||0;break;case Co.GLOBE:h=!1,o=null;break;default:h=!1}return{geospatialOrigin:o,shaderCoordinateOrigin:r,offsetMode:h}}function V6(t,e,i){const{viewMatrixUncentered:r,projectionMatrix:o}=t;let{viewMatrix:h,viewProjectionMatrix:d}=t,c=QS,x=QS,S=t.cameraPosition;const{geospatialOrigin:P,shaderCoordinateOrigin:M,offsetMode:D}=iP(t,e,i);return D&&(x=t.projectPosition(P||M),S=[S[0]-x[0],S[1]-x[1],S[2]-x[2]],x[3]=1,c=ep([],x,d),h=r||h,d=wc([],o,h),d=wc([],d,z6)),{viewMatrix:h,viewProjectionMatrix:d,projectionCenter:c,originCommon:x,cameraPosCommon:S,shaderCoordinateOrigin:M,geospatialOrigin:P}}function j6({viewport:t,devicePixelRatio:e=1,modelMatrix:i=null,coordinateSystem:r=Ei.DEFAULT,coordinateOrigin:o=tP,autoWrapLongitude:h=!1}){r===Ei.DEFAULT&&(r=t.isGeospatial?Ei.LNGLAT:Ei.CARTESIAN);const d=U6({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:o});return d.project_uWrapLongitude=h,d.project_uModelMatrix=i||eP,d}function $6({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r}){const{projectionCenter:o,viewProjectionMatrix:h,originCommon:d,cameraPosCommon:c,shaderCoordinateOrigin:x,geospatialOrigin:S}=V6(t,i,r),P=t.getDistanceScales(),M=[t.width*e,t.height*e],D=ep([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,H={project_uCoordinateSystem:i,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:x,project_uCommonOrigin:d.slice(0,3),project_uCenter:o,project_uPseudoMeters:!!t._pseudoMeters,project_uViewportSize:M,project_uDevicePixelRatio:e,project_uFocalDistance:D,project_uCommonUnitsPerMeter:P.unitsPerMeter,project_uCommonUnitsPerWorldUnit:P.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:L6,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:h,project_uModelMatrix:eP,project_uCameraPosition:c};if(S){const Q=t.getDistanceScales(S);switch(i){case Ei.METER_OFFSETS:H.project_uCommonUnitsPerWorldUnit=Q.unitsPerMeter,H.project_uCommonUnitsPerWorldUnit2=Q.unitsPerMeter2;break;case Ei.LNGLAT:case Ei.LNGLAT_OFFSETS:t._pseudoMeters||(H.project_uCommonUnitsPerMeter=Q.unitsPerMeter),H.project_uCommonUnitsPerWorldUnit=Q.unitsPerDegree,H.project_uCommonUnitsPerWorldUnit2=Q.unitsPerDegree2;break;case Ei.CARTESIAN:H.project_uCommonUnitsPerWorldUnit=[1,1,Q.unitsPerMeter[2]],H.project_uCommonUnitsPerWorldUnit2=[0,0,Q.unitsPerMeter2[2]];break}}return H}const W6={};function H6(t=W6){return"viewport"in t?j6(t):{}}const ix={name:"project",dependencies:[Pz,k6],vs:N6,getUniforms:H6},X6=`
+`;function Bz(t,e){if(t===e)return!0;if(Array.isArray(t)){const i=t.length;if(!e||e.length!==i)return!1;for(let r=0;r{for(const o in r)if(!Bz(r[o],e[o])){i=t(r),e=r;break}return i}}const QS=[0,0,0,0],zz=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0],eP=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],Lz=[0,0,0],tP=[0,0,0],Uz=tp($z);function iP(t,e,i=tP){i.length<3&&(i=[i[0],i[1],0]);let r=i,o,h=!0;switch(e===Ei.LNGLAT_OFFSETS||e===Ei.METER_OFFSETS?o=i:o=t.isGeospatial?[Math.fround(t.longitude),Math.fround(t.latitude),0]:null,t.projectionMode){case Co.WEB_MERCATOR:(e===Ei.LNGLAT||e===Ei.CARTESIAN)&&(o=[0,0,0],h=!1);break;case Co.WEB_MERCATOR_AUTO_OFFSET:e===Ei.LNGLAT?r=o:e===Ei.CARTESIAN&&(r=[Math.fround(t.center[0]),Math.fround(t.center[1]),0],o=t.unprojectPosition(r),r[0]-=i[0],r[1]-=i[1],r[2]-=i[2]);break;case Co.IDENTITY:r=t.position.map(Math.fround),r[2]=r[2]||0;break;case Co.GLOBE:h=!1,o=null;break;default:h=!1}return{geospatialOrigin:o,shaderCoordinateOrigin:r,offsetMode:h}}function Vz(t,e,i){const{viewMatrixUncentered:r,projectionMatrix:o}=t;let{viewMatrix:h,viewProjectionMatrix:d}=t,c=QS,x=QS,S=t.cameraPosition;const{geospatialOrigin:P,shaderCoordinateOrigin:M,offsetMode:D}=iP(t,e,i);return D&&(x=t.projectPosition(P||M),S=[S[0]-x[0],S[1]-x[1],S[2]-x[2]],x[3]=1,c=ep([],x,d),h=r||h,d=wc([],o,h),d=wc([],d,zz)),{viewMatrix:h,viewProjectionMatrix:d,projectionCenter:c,originCommon:x,cameraPosCommon:S,shaderCoordinateOrigin:M,geospatialOrigin:P}}function jz({viewport:t,devicePixelRatio:e=1,modelMatrix:i=null,coordinateSystem:r=Ei.DEFAULT,coordinateOrigin:o=tP,autoWrapLongitude:h=!1}){r===Ei.DEFAULT&&(r=t.isGeospatial?Ei.LNGLAT:Ei.CARTESIAN);const d=Uz({viewport:t,devicePixelRatio:e,coordinateSystem:r,coordinateOrigin:o});return d.project_uWrapLongitude=h,d.project_uModelMatrix=i||eP,d}function $z({viewport:t,devicePixelRatio:e,coordinateSystem:i,coordinateOrigin:r}){const{projectionCenter:o,viewProjectionMatrix:h,originCommon:d,cameraPosCommon:c,shaderCoordinateOrigin:x,geospatialOrigin:S}=Vz(t,i,r),P=t.getDistanceScales(),M=[t.width*e,t.height*e],D=ep([],[0,0,-t.focalDistance,1],t.projectionMatrix)[3]||1,H={project_uCoordinateSystem:i,project_uProjectionMode:t.projectionMode,project_uCoordinateOrigin:x,project_uCommonOrigin:d.slice(0,3),project_uCenter:o,project_uPseudoMeters:!!t._pseudoMeters,project_uViewportSize:M,project_uDevicePixelRatio:e,project_uFocalDistance:D,project_uCommonUnitsPerMeter:P.unitsPerMeter,project_uCommonUnitsPerWorldUnit:P.unitsPerMeter,project_uCommonUnitsPerWorldUnit2:Lz,project_uScale:t.scale,project_uWrapLongitude:!1,project_uViewProjectionMatrix:h,project_uModelMatrix:eP,project_uCameraPosition:c};if(S){const Q=t.getDistanceScales(S);switch(i){case Ei.METER_OFFSETS:H.project_uCommonUnitsPerWorldUnit=Q.unitsPerMeter,H.project_uCommonUnitsPerWorldUnit2=Q.unitsPerMeter2;break;case Ei.LNGLAT:case Ei.LNGLAT_OFFSETS:t._pseudoMeters||(H.project_uCommonUnitsPerMeter=Q.unitsPerMeter),H.project_uCommonUnitsPerWorldUnit=Q.unitsPerDegree,H.project_uCommonUnitsPerWorldUnit2=Q.unitsPerDegree2;break;case Ei.CARTESIAN:H.project_uCommonUnitsPerWorldUnit=[1,1,Q.unitsPerMeter[2]],H.project_uCommonUnitsPerWorldUnit2=[0,0,Q.unitsPerMeter2[2]];break}}return H}const Wz={};function Hz(t=Wz){return"viewport"in t?jz(t):{}}const ix={name:"project",dependencies:[P6,kz],vs:Nz,getUniforms:Hz},Xz=`
vec4 project_position_to_clipspace(
vec3 position, vec3 position64Low, vec3 offset, out vec4 commonPosition
) {
@@ -689,7 +689,7 @@ vec4 project_position_to_clipspace(
vec4 commonPosition;
return project_position_to_clipspace(position, position64Low, offset, commonPosition);
}
-`,q6={name:"project32",dependencies:[ix],vs:X6};function Z6(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function su(t,e){const i=ep([],e,t);return T6(i,i,1/i[3]),i}function eE(t,e){const i=t%e;return i<0?e+i:i}function qb(t,e,i){return ti?i:t}function Y6(t){return Math.log(t)*Math.LOG2E}const rx=Math.log2||Y6;function xa(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const Gn=Math.PI,rP=Gn/4,Bn=Gn/180,Zb=180/Gn,pu=512,Ig=4003e4,N_=85.051129,K6=1.5;function J6(t){return rx(t)}function Of(t){const[e,i]=t;xa(Number.isFinite(e)),xa(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const r=e*Bn,o=i*Bn,h=pu*(r+Gn)/(2*Gn),d=pu*(Gn+Math.log(Math.tan(rP+o*.5)))/(2*Gn);return[h,d]}function _u(t){const[e,i]=t,r=e/pu*(2*Gn)-Gn,o=2*(Math.atan(Math.exp(i/pu*(2*Gn)-Gn))-rP);return[r*Zb,o*Zb]}function G6(t){const{latitude:e}=t;xa(Number.isFinite(e));const i=Math.cos(e*Bn);return J6(Ig*i)-9}function eg(t){const e=Math.cos(t*Bn);return pu/Ig/e}function Yb(t){const{latitude:e,longitude:i,highPrecision:r=!1}=t;xa(Number.isFinite(e)&&Number.isFinite(i));const o=pu,h=Math.cos(e*Bn),d=o/360,c=d/h,x=o/Ig/h,S={unitsPerMeter:[x,x,x],metersPerUnit:[1/x,1/x,1/x],unitsPerDegree:[d,c,x],degreesPerUnit:[1/d,1/c,1/x]};if(r){const P=Bn*Math.tan(e*Bn)/h,M=d*P/2,D=o/Ig*P,H=D/c*x;S.unitsPerDegree2=[0,M,D],S.unitsPerMeter2=[H,0,H]}return S}function sP(t,e){const[i,r,o]=t,[h,d,c]=e,{unitsPerMeter:x,unitsPerMeter2:S}=Yb({longitude:i,latitude:r,highPrecision:!0}),P=Of(t);P[0]+=h*(x[0]+S[0]*d),P[1]+=d*(x[1]+S[1]*d);const M=_u(P),D=(o||0)+(c||0);return Number.isFinite(o)||Number.isFinite(c)?[M[0],M[1],D]:M}function Q6(t){const{height:e,pitch:i,bearing:r,altitude:o,scale:h,center:d}=t,c=Z6();Eg(c,c,[0,0,-o]),JI(c,c,-i*Bn),GI(c,c,r*Bn);const x=h/e;return tx(c,c,[x,x,x]),d&&Eg(c,c,Qz([],d)),c}function eL(t){const{width:e,height:i,altitude:r,pitch:o=0,offset:h,center:d,scale:c,nearZMultiplier:x=1,farZMultiplier:S=1}=t;let{fovy:P=Pg(K6)}=t;r!==void 0&&(P=Pg(r));const M=P*Bn,D=o*Bn,H=nP(P);let Q=H;d&&(Q+=d[2]*c/Math.cos(D)/i);const G=M*(.5+(h?h[1]:0)/i),_e=Math.sin(G)*Q/Math.sin(qb(Math.PI/2-D-G,.01,Math.PI-.01)),ve=Math.sin(D)*_e+Q,be=Q*10,Se=Math.min(ve*S,be);return{fov:M,aspect:e/i,focalDistance:H,near:x,far:Se}}function Pg(t){return 2*Math.atan(.5/t)*Zb}function nP(t){return .5/Math.tan(.5*t*Bn)}function oP(t,e){const[i,r,o=0]=t;return xa(Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(o)),su(e,[i,r,o,1])}function sx(t,e,i=0){const[r,o,h]=t;if(xa(Number.isFinite(r)&&Number.isFinite(o),"invalid pixel coordinate"),Number.isFinite(h))return su(e,[r,o,h,1]);const d=su(e,[r,o,0,1]),c=su(e,[r,o,1,1]),x=d[2],S=c[2],P=x===S?0:((i||0)-x)/(S-x);return ZI([],d,c,P)}function tL(t){const{width:e,height:i,bounds:r,minExtent:o=0,maxZoom:h=24,offset:d=[0,0]}=t,[[c,x],[S,P]]=r,M=iL(t.padding),D=Of([c,qb(P,-N_,N_)]),H=Of([S,qb(x,-N_,N_)]),Q=[Math.max(Math.abs(H[0]-D[0]),o),Math.max(Math.abs(H[1]-D[1]),o)],G=[e-M.left-M.right-Math.abs(d[0])*2,i-M.top-M.bottom-Math.abs(d[1])*2];xa(G[0]>0&&G[1]>0);const _e=G[0]/Q[0],ve=G[1]/Q[1],be=(M.right-M.left)/2/_e,Se=(M.top-M.bottom)/2/ve,Be=[(H[0]+D[0])/2+be,(H[1]+D[1])/2+Se],je=_u(Be),Fe=Math.min(h,rx(Math.abs(Math.min(_e,ve))));return xa(Number.isFinite(Fe)),{longitude:je[0],latitude:je[1],zoom:Fe}}function iL(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(xa(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}const tE=Math.PI/180;function rL(t,e=0){const{width:i,height:r,unproject:o}=t,h={targetZ:e},d=o([0,r],h),c=o([i,r],h);let x,S;const P=t.fovy?.5*t.fovy*tE:Math.atan(.5/t.altitude),M=(90-t.pitch)*tE;return P>M-.01?(x=iE(t,0,e),S=iE(t,i,e)):(x=o([0,0],h),S=o([i,0],h)),[d,c,S,x]}function iE(t,e,i){const{pixelUnprojectionMatrix:r}=t,o=su(r,[e,0,1,1]),h=su(r,[e,t.height,1,1]),c=(i*t.distanceScales.unitsPerMeter[2]-o[2])/(h[2]-o[2]),x=ZI([],o,h,c),S=_u(x);return S.push(i),S}const rE=512;function sL(t){const{width:e,height:i,pitch:r=0}=t;let{longitude:o,latitude:h,zoom:d,bearing:c=0}=t;(o<-180||o>180)&&(o=eE(o+180,360)-180),(c<-180||c>180)&&(c=eE(c+180,360)-180);const x=rx(i/rE);if(d<=x)d=x,h=0;else{const S=i/2/Math.pow(2,d),P=_u([0,S])[1];if(hM&&(h=M)}}return{width:e,height:i,longitude:o,latitude:h,zoom:d,pitch:r,bearing:c}}const nL=`
+`,qz={name:"project32",dependencies:[ix],vs:Xz};function Zz(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function su(t,e){const i=ep([],e,t);return Tz(i,i,1/i[3]),i}function eE(t,e){const i=t%e;return i<0?e+i:i}function qb(t,e,i){return ti?i:t}function Yz(t){return Math.log(t)*Math.LOG2E}const rx=Math.log2||Yz;function xa(t,e){if(!t)throw new Error(e||"@math.gl/web-mercator: assertion failed.")}const Gn=Math.PI,rP=Gn/4,Bn=Gn/180,Zb=180/Gn,pu=512,Ig=4003e4,N_=85.051129,Kz=1.5;function Jz(t){return rx(t)}function Of(t){const[e,i]=t;xa(Number.isFinite(e)),xa(Number.isFinite(i)&&i>=-90&&i<=90,"invalid latitude");const r=e*Bn,o=i*Bn,h=pu*(r+Gn)/(2*Gn),d=pu*(Gn+Math.log(Math.tan(rP+o*.5)))/(2*Gn);return[h,d]}function _u(t){const[e,i]=t,r=e/pu*(2*Gn)-Gn,o=2*(Math.atan(Math.exp(i/pu*(2*Gn)-Gn))-rP);return[r*Zb,o*Zb]}function Gz(t){const{latitude:e}=t;xa(Number.isFinite(e));const i=Math.cos(e*Bn);return Jz(Ig*i)-9}function eg(t){const e=Math.cos(t*Bn);return pu/Ig/e}function Yb(t){const{latitude:e,longitude:i,highPrecision:r=!1}=t;xa(Number.isFinite(e)&&Number.isFinite(i));const o=pu,h=Math.cos(e*Bn),d=o/360,c=d/h,x=o/Ig/h,S={unitsPerMeter:[x,x,x],metersPerUnit:[1/x,1/x,1/x],unitsPerDegree:[d,c,x],degreesPerUnit:[1/d,1/c,1/x]};if(r){const P=Bn*Math.tan(e*Bn)/h,M=d*P/2,D=o/Ig*P,H=D/c*x;S.unitsPerDegree2=[0,M,D],S.unitsPerMeter2=[H,0,H]}return S}function sP(t,e){const[i,r,o]=t,[h,d,c]=e,{unitsPerMeter:x,unitsPerMeter2:S}=Yb({longitude:i,latitude:r,highPrecision:!0}),P=Of(t);P[0]+=h*(x[0]+S[0]*d),P[1]+=d*(x[1]+S[1]*d);const M=_u(P),D=(o||0)+(c||0);return Number.isFinite(o)||Number.isFinite(c)?[M[0],M[1],D]:M}function Qz(t){const{height:e,pitch:i,bearing:r,altitude:o,scale:h,center:d}=t,c=Zz();Eg(c,c,[0,0,-o]),JI(c,c,-i*Bn),GI(c,c,r*Bn);const x=h/e;return tx(c,c,[x,x,x]),d&&Eg(c,c,Q6([],d)),c}function eL(t){const{width:e,height:i,altitude:r,pitch:o=0,offset:h,center:d,scale:c,nearZMultiplier:x=1,farZMultiplier:S=1}=t;let{fovy:P=Pg(Kz)}=t;r!==void 0&&(P=Pg(r));const M=P*Bn,D=o*Bn,H=nP(P);let Q=H;d&&(Q+=d[2]*c/Math.cos(D)/i);const G=M*(.5+(h?h[1]:0)/i),_e=Math.sin(G)*Q/Math.sin(qb(Math.PI/2-D-G,.01,Math.PI-.01)),ve=Math.sin(D)*_e+Q,be=Q*10,Se=Math.min(ve*S,be);return{fov:M,aspect:e/i,focalDistance:H,near:x,far:Se}}function Pg(t){return 2*Math.atan(.5/t)*Zb}function nP(t){return .5/Math.tan(.5*t*Bn)}function oP(t,e){const[i,r,o=0]=t;return xa(Number.isFinite(i)&&Number.isFinite(r)&&Number.isFinite(o)),su(e,[i,r,o,1])}function sx(t,e,i=0){const[r,o,h]=t;if(xa(Number.isFinite(r)&&Number.isFinite(o),"invalid pixel coordinate"),Number.isFinite(h))return su(e,[r,o,h,1]);const d=su(e,[r,o,0,1]),c=su(e,[r,o,1,1]),x=d[2],S=c[2],P=x===S?0:((i||0)-x)/(S-x);return ZI([],d,c,P)}function tL(t){const{width:e,height:i,bounds:r,minExtent:o=0,maxZoom:h=24,offset:d=[0,0]}=t,[[c,x],[S,P]]=r,M=iL(t.padding),D=Of([c,qb(P,-N_,N_)]),H=Of([S,qb(x,-N_,N_)]),Q=[Math.max(Math.abs(H[0]-D[0]),o),Math.max(Math.abs(H[1]-D[1]),o)],G=[e-M.left-M.right-Math.abs(d[0])*2,i-M.top-M.bottom-Math.abs(d[1])*2];xa(G[0]>0&&G[1]>0);const _e=G[0]/Q[0],ve=G[1]/Q[1],be=(M.right-M.left)/2/_e,Se=(M.top-M.bottom)/2/ve,Be=[(H[0]+D[0])/2+be,(H[1]+D[1])/2+Se],je=_u(Be),Fe=Math.min(h,rx(Math.abs(Math.min(_e,ve))));return xa(Number.isFinite(Fe)),{longitude:je[0],latitude:je[1],zoom:Fe}}function iL(t=0){return typeof t=="number"?{top:t,bottom:t,left:t,right:t}:(xa(Number.isFinite(t.top)&&Number.isFinite(t.bottom)&&Number.isFinite(t.left)&&Number.isFinite(t.right)),t)}const tE=Math.PI/180;function rL(t,e=0){const{width:i,height:r,unproject:o}=t,h={targetZ:e},d=o([0,r],h),c=o([i,r],h);let x,S;const P=t.fovy?.5*t.fovy*tE:Math.atan(.5/t.altitude),M=(90-t.pitch)*tE;return P>M-.01?(x=iE(t,0,e),S=iE(t,i,e)):(x=o([0,0],h),S=o([i,0],h)),[d,c,S,x]}function iE(t,e,i){const{pixelUnprojectionMatrix:r}=t,o=su(r,[e,0,1,1]),h=su(r,[e,t.height,1,1]),c=(i*t.distanceScales.unitsPerMeter[2]-o[2])/(h[2]-o[2]),x=ZI([],o,h,c),S=_u(x);return S.push(i),S}const rE=512;function sL(t){const{width:e,height:i,pitch:r=0}=t;let{longitude:o,latitude:h,zoom:d,bearing:c=0}=t;(o<-180||o>180)&&(o=eE(o+180,360)-180),(c<-180||c>180)&&(c=eE(c+180,360)-180);const x=rx(i/rE);if(d<=x)d=x,h=0;else{const S=i/2/Math.pow(2,d),P=_u([0,S])[1];if(hM&&(h=M)}}return{width:e,height:i,longitude:o,latitude:h,zoom:d,pitch:r,bearing:c}}const nL=`
const int max_lights = 2;
uniform mat4 shadow_uViewProjectionMatrices[max_lights];
uniform vec4 shadow_uProjectCenters[max_lights];
@@ -773,7 +773,7 @@ vec4 shadow_filterShadowColor(vec4 color) {
// use picking color if rendering to picking FBO.
color = picking_filterPickingColor(color);
- `}}},gL=[ix],mL=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function yL(){const t=_g.getDefaultShaderAssembler();for(const e of gL)t.addDefaultModule(e);for(const e of mL)t.addShaderHook(e);return t}const bL=[255,255,255],vL=1;let xL=0;class wL{constructor(e={}){this.type="ambient";const{color:i=bL}=e,{intensity:r=vL}=e;this.id=e.id||`ambient-${xL++}`,this.color=i,this.intensity=r}}const TL=[255,255,255],SL=1,EL=[0,0,-1];let AL=0;class nE{constructor(e={}){this.type="directional";const{color:i=TL}=e,{intensity:r=SL}=e,{direction:o=EL}=e,{_shadow:h=!1}=e;this.id=e.id||`directional-${AL++}`,this.color=i,this.intensity=r,this.type="directional",this.direction=new Fo(o).normalize().toArray(),this.shadow=h}getProjectedLight(e){return this}}class IL{constructor(e,i={id:"pass"}){const{id:r}=i;this.id=r,this.device=e,this.props={...i}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}class nx extends IL{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){const[i,r]=this.device.canvasContext.getDrawingBufferSize(),o=e.clearCanvas??!0,h=e.clearColor??(o?[0,0,0,0]:!1),d=o?1:!1,c=o?0:!1,x=e.colorMask??15,S={viewport:[0,0,i,r]};e.colorMask&&(S.colorMask=x),e.scissorRect&&(S.scissorRect=e.scissorRect);const P=this.device.beginRenderPass({framebuffer:e.target,parameters:S,clearColor:h,clearDepth:d,clearStencil:c});try{return this._drawLayers(P,e)}finally{P.end()}}_drawLayers(e,i){const{target:r,moduleParameters:o,viewports:h,views:d,onViewportActive:c,clearStack:x=!0}=i;i.pass=i.pass||"unknown",x&&(this._lastRenderIndex=-1);const S=[];for(const P of h){const M=d&&d[P.id];c==null||c(P);const D=this._getDrawLayerParams(P,i),H=P.subViewports||[P];for(const Q of H){const G=this._drawLayersInViewport(e,{target:r,moduleParameters:o,viewport:Q,view:M,pass:i.pass,layers:i.layers},D);S.push(G)}}return S}_getDrawLayerParams(e,{layers:i,pass:r,isPicking:o=!1,layerFilter:h,cullRect:d,effects:c,moduleParameters:x},S=!1){var Q;const P=[],M=aP(this._lastRenderIndex+1),D={layer:i[0],viewport:e,isPicking:o,renderPass:r,cullRect:d},H={};for(let G=0;Gthis.device.clearWebGL(M))}const P={totalCount:i.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:S});for(let M=0;M{const d=o.props._offset,c=o.id,x=o.parent&&o.parent.id;let S;if(x&&!(x in e)&&r(o.parent,!1),x in i){const P=i[x]=i[x]||aP(e[x],e);S=P(o,h),i[c]=P}else Number.isFinite(d)?(S=d+(e[x]||0),i[c]=null):S=t;return h&&S>=t&&(t=S+1),e[c]=S,S};return r}function PL(t,{moduleParameters:e,target:i,viewport:r}){const o=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,h]=t.canvasContext.getDrawingBufferSize(),d=i?i.height:h,c=r;return[c.x*o,d-(c.y+c.height)*o,c.width*o,c.height*o]}class RL extends nx{constructor(e,i){super(e,i),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const i=this.fbo,r=this.device.canvasContext.cssToDeviceRatio(),o=e.viewports[0],h=o.width*r,d=o.height*r,c=[1,1,1,1];(h!==i.width||d!==i.height)&&i.resize({width:h,height:d}),super.render({...e,clearColor:c,target:i,pass:"shadow"})}getLayerParameters(e,i,r){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const CL={color:[255,255,255],intensity:1},oE=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],ML=[0,0,0,200/255];class lP{constructor(e={}){this.id="lighting-effect",this.shadowColor=ML,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:i,deck:r}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(i),r._addDefaultShaderModule(sE),this.dummyShadowMap=i.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const i in e){const r=e[i];switch(r.type){case"ambient":this.ambientLight=r;break;case"directional":this.directionalLights.push(r);break;case"point":this.pointLights.push(r);break}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(i=>i.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:i,viewports:r,onViewportActive:o,views:h}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let d=0;dr.getProjectedLight({layer:e})),pointLights:this.pointLights.map(r=>r.getProjectedLight({layer:e}))},i}cleanup(e){for(const i of this.shadowPasses)i.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(sE))}_calculateMatrices(){const e=[];for(const i of this.directionalLights){const r=new No().lookAt({eye:new Fo(i.direction).negate()});e.push(r)}return e}_createShadowPasses(e){for(let i=0;io&&(h=o);const d=this._pool,c=e.BYTES_PER_ELEMENT*h,x=d.findIndex(S=>S.byteLength>=c);if(x>=0){const S=new e(d.splice(x,1)[0],0,h);return r&&S.fill(0),S}return new e(h)}_release(e){if(!ArrayBuffer.isView(e))return;const i=this._pool,{buffer:r}=e,{byteLength:o}=r,h=i.findIndex(d=>d.byteLength>=o);h<0?i.push(r):(h>0||i.lengththis.opts.poolSize&&i.shift()}}const Ff=new kL;function hf(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function DL(t){return[t[12],t[13],t[14]]}function OL(t){return{left:Bh(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Bh(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Bh(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Bh(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Bh(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Bh(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}const aE=new Fo;function Bh(t,e,i,r){aE.set(t,e,i);const o=aE.len();return{distance:r/o,normal:new Fo(-t/o,-e/o,-i/o)}}function FL(t){return t-Math.fround(t)}let Gd;function H0(t,e){const{size:i=1,startIndex:r=0}=e,o=e.endIndex!==void 0?e.endIndex:t.length,h=(o-r)/i;Gd=Ff.allocate(Gd,h,{type:Float32Array,size:i*2});let d=r,c=0;for(;d=i.delay+i.duration*i.repeat}getTime(e){if(e===void 0)return this.time;const i=this.channels.get(e);return i===void 0?-1:i.time}setTime(e){this.time=Math.max(0,e);const i=this.channels.values();for(const o of i)this._setChannelTime(o,this.time);const r=this.animations.values();for(const o of r){const{animation:h,channel:d}=o;h.setTime(this.getTime(d))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,i){const r=WL++;return this.animations.set(r,{animation:e,channel:i}),e.setTime(this.getTime(i)),r}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,i){const r=i-e.delay,o=e.duration*e.repeat;r>=o?e.time=e.duration*e.rate:(e.time=Math.max(0,r)%e.duration,e.time*=e.rate)}}let HL=0;const XL={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:iu.stats.get(`animation-loop-${HL++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class qL{constructor(e){Z(this,"device",null);Z(this,"canvas",null);Z(this,"props");Z(this,"animationProps",null);Z(this,"timeline",null);Z(this,"stats");Z(this,"cpuTime");Z(this,"gpuTime");Z(this,"frameRate");Z(this,"display");Z(this,"needsRedraw","initialized");Z(this,"_initialized",!1);Z(this,"_running",!1);Z(this,"_animationFrameId",null);Z(this,"_nextFramePromise",null);Z(this,"_resolveNextFrame",null);Z(this,"_cpuStartTime",0);if(this.props={...XL,...e},e=this.props,!e.device)throw new Error("No device provided");const{useDevicePixels:i=!0}=this.props;this.stats=e.stats||new Tm({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:i}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const i=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(i),i}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){var e;return(e=this.device)!=null&&e.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=V4(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(j4(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){var e,i;if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:(i=(e=this.device)==null?void 0:e.canvasContext)==null?void 0:i.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:i,aspect:r}=this._getSizeAndAspect();(e!==this.animationProps.width||i!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),r!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=i,this.animationProps.aspect=r,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){var e;if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=((e=this.device.canvasContext)==null?void 0:e.canvas)||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const i=document.createElement("div");i.style.position="absolute",i.style.left="10px",i.style.bottom="10px",i.style.width="300px",i.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(i);const r=this.props.onAddHTML(i);r&&(i.innerHTML=r)}}_getSizeAndAspect(){var h,d,c,x;if(!this.device)return{width:1,height:1,aspect:1};const[e,i]=((d=(h=this.device)==null?void 0:h.canvasContext)==null?void 0:d.getPixelSize())||[1,1];let r=1;const o=(x=(c=this.device)==null?void 0:c.canvasContext)==null?void 0:x.canvas;return o&&o.clientHeight?r=o.clientWidth/o.clientHeight:e>0&&i>0&&(r=e/i),{width:e,height:i,aspect:r}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){var e,i;this.props.autoResizeDrawingBuffer&&((i=(e=this.device)==null?void 0:e.canvasContext)==null||i.resize({useDevicePixels:this.props.useDevicePixels}))}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class hE{constructor(e){Z(this,"id");Z(this,"userData",{});Z(this,"topology");Z(this,"bufferLayout",[]);Z(this,"vertexCount");Z(this,"indices");Z(this,"attributes");this.id=e.id||Nc("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&Yi(this.indices.usage===cr.INDEX)}destroy(){var e;(e=this.indices)==null||e.destroy();for(const i of Object.values(this.attributes))i.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function ZL(t,e){if(e instanceof hE)return e;const i=YL(t,e),{attributes:r,bufferLayout:o}=KL(t,e);return new hE({topology:e.topology||"triangle-list",bufferLayout:o,vertexCount:e.vertexCount,indices:i,attributes:r})}function YL(t,e){if(!e.indices)return;const i=e.indices.value;return t.createBuffer({usage:cr.INDEX,data:i})}function KL(t,e){const i=[],r={};for(const[h,d]of Object.entries(e.attributes)){let c=h;switch(h){case"POSITION":c="positions";break;case"NORMAL":c="normals";break;case"TEXCOORD_0":c="texCoords";break;case"COLOR_0":c="colors";break}r[c]=t.createBuffer({data:d.value,id:`${h}-buffer`});const{value:x,size:S,normalized:P}=d;i.push({name:c,format:N4(x,S,P)})}const o=e._calculateVertexCount(e.attributes,e.indices);return{attributes:r,bufferLayout:i,vertexCount:o}}class JL{constructor(e){Z(this,"modules");Z(this,"moduleUniforms");Z(this,"moduleBindings");Z(this,"moduleUniformsChanged");const i=Em(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;it.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,o]of Object.entries(e)){const h=r;this.moduleUniforms[h]=o.defaultUniforms||{},this.moduleBindings[h]={}}}destroy(){}setProps(e){var i;for(const r of Object.keys(e)){const o=r,h=e[o],d=this.modules[o];if(!d){it.warn(`Module ${r} not found`)();continue}const c=this.moduleUniforms[o],x=this.moduleBindings[o],S=((i=d.getUniforms)==null?void 0:i.call(d,h,c))||h,{uniforms:P,bindings:M}=ex(S);this.moduleUniforms[o]={...c,...P},this.moduleBindings[o]={...x,...M}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const i of Object.values(this.moduleBindings))Object.assign(e,i);return e}getDebugTable(){var i;const e={};for(const[r,o]of Object.entries(this.moduleUniforms))for(const[h,d]of Object.entries(o))e[`${r}.${h}`]={type:(i=this.modules[r].uniformTypes)==null?void 0:i[h],value:String(d)};return e}}const rm=class rm{constructor(e){Z(this,"device");Z(this,"_hashCounter",0);Z(this,"_hashes",{});Z(this,"_renderPipelineCache",{});Z(this,"_computePipelineCache",{});this.device=e}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new rm(e),e._lumaData.defaultPipelineFactory}createRenderPipeline(e){const i={...hu.defaultProps,...e},r=this._hashRenderPipeline(i);if(!this._renderPipelineCache[r]){const o=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:void 0});o.hash=r,this._renderPipelineCache[r]={pipeline:o,useCount:0}}return this._renderPipelineCache[r].useCount++,this._renderPipelineCache[r].pipeline}createComputePipeline(e){const i={...xg.defaultProps,...e},r=this._hashComputePipeline(i);if(!this._computePipelineCache[r]){const o=this.device.createComputePipeline({...i,id:i.id?`${i.id}-cached`:void 0});o.hash=r,this._computePipelineCache[r]={pipeline:o,useCount:0}}return this._computePipelineCache[r].useCount++,this._computePipelineCache[r].pipeline}release(e){const i=e.hash,r=e instanceof xg?this._computePipelineCache:this._renderPipelineCache;r[i].useCount--,r[i].useCount===0&&(r[i].pipeline.destroy(),delete r[i])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const i=this._getHash(e.vs.source),r=e.fs?this._getHash(e.fs.source):0,o="-",h=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${i}/${r}V${o}BL${h}`;default:const d=this._getHash(JSON.stringify(e.parameters));return`${i}/${r}V${o}T${e.topology}P${d}BL${h}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};Z(rm,"defaultProps",{...hu.defaultProps});let Kb=rm;const sm=class sm{constructor(e){Z(this,"device");Z(this,"_cache",{});this.device=e}static getDefaultShaderFactory(e){var i;return(i=e._lumaData).defaultShaderFactory||(i.defaultShaderFactory=new sm(e)),e._lumaData.defaultShaderFactory}createShader(e){const i=this._hashShader(e);let r=this._cache[i];if(!r){const o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[i]=r={shader:o,useCount:0}}return r.useCount++,r.shader}release(e){const i=this._hashShader(e),r=this._cache[i];r&&(r.useCount--,r.useCount===0&&(delete this._cache[i],r.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}};Z(sm,"defaultProps",{...yg.defaultProps});let Jb=sm;function GL(t,e){var o;const i={},r="Values";if(t.attributes.length===0&&!((o=t.varyings)!=null&&o.length))return{"No attributes or varyings":{[r]:"N/A"}};for(const h of t.attributes)if(h){const d=`${h.location} ${h.name}: ${h.type}`;i[`in ${d}`]={[r]:h.stepMode||"vertex"}}for(const h of t.varyings||[]){const d=`${h.location} ${h.name}`;i[`out ${d}`]={[r]:JSON.stringify(h.accessor)}}return i}let Zr=null,q0=null;function QL(t,{id:e,minimap:i,opaque:r,top:o="0",left:h="0",rgbaScale:d=1}){Zr||(Zr=document.createElement("canvas"),Zr.id=e,Zr.title=e,Zr.style.zIndex="100",Zr.style.position="absolute",Zr.style.top=o,Zr.style.left=h,Zr.style.border="blue 1px solid",Zr.style.transform="scaleY(-1)",document.body.appendChild(Zr),q0=Zr.getContext("2d")),(Zr.width!==t.width||Zr.height!==t.height)&&(Zr.width=t.width/2,Zr.height=t.height/2,Zr.style.width="400px",Zr.style.height="400px");const c=t.device.readPixelsToArrayWebGL(t),x=q0.createImageData(t.width,t.height),S=0;for(let P=0;P[M.name,M]))||[]);this.setShaderInputs(i.shaderInputs||new JL(r));const o=tU(e),h=(((x=this.props.modules)==null?void 0:x.length)>0?this.props.modules:(S=this.shaderInputs)==null?void 0:S.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){(P=this.props).shaderLayout||(P.shaderLayout=Ez(this.props.source));const{source:M,getUniforms:D}=this.props.shaderAssembler.assembleShader({platformInfo:o,...this.props,modules:h});this.source=M,this._getModuleUniforms=D}else{const{vs:M,fs:D,getUniforms:H}=this.props.shaderAssembler.assembleShaderPair({platformInfo:o,...this.props,modules:h});this.vs=M,this.fs=D,this._getModuleUniforms=H}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,i.geometry&&this.setGeometry(i.geometry),this.pipelineFactory=i.pipelineFactory||Kb.getDefaultPipelineFactory(this.device),this.shaderFactory=i.shaderFactory||Jb.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in i&&(this.isInstanced=i.isInstanced),i.instanceCount&&this.setInstanceCount(i.instanceCount),i.vertexCount&&this.setVertexCount(i.vertexCount),i.indexBuffer&&this.setIndexBuffer(i.indexBuffer),i.attributes&&this.setAttributes(i.attributes),i.constantAttributes&&this.setConstantAttributes(i.constantAttributes),i.bindings&&this.setBindings(i.bindings),i.uniforms&&this.setUniforms(i.uniforms),i.moduleSettings&&this.updateModuleSettings(i.moduleSettings),i.transformFeedback&&(this.transformFeedback=i.transformFeedback),Object.seal(this)}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let i;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),gg(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var r;(r=this._gpuGeometry)==null||r.destroy();const i=e&&ZL(this.device,e);i&&(this.setTopology(i.topology||"triangle-list"),this.bufferLayout=uE(i.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i)),this._gpuGeometry=i}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?uE(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Ub(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new F4(this.shaderInputs.modules);for(const i of Object.keys(this.shaderInputs.modules)){const r=this._uniformStore.getManagedUniformBuffer(this.device,i);this.bindings[`${i}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,i){e.indices&&it.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[r,o]of Object.entries(e)){const h=this.bufferLayout.find(x=>dE(x).includes(r));if(!h){it.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const d=dE(h);let c=!1;for(const x of d){const S=this._attributeInfos[x];S&&(this.vertexArray.setBuffer(S.location,o),c=!0)}!c&&!((i==null?void 0:i.disableWarnings)??this.props.disableWarnings)&&it.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,i){for(const[r,o]of Object.entries(e)){const h=this._attributeInfos[r];h?this.vertexArray.setConstantWebGL(h.location,o):((i==null?void 0:i.disableWarnings)??this.props.disableWarnings)||it.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){gg(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:i,uniforms:r}=ex(this._getModuleUniforms(e));Object.assign(this.bindings,i),Object.assign(this.uniforms,r),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const i of Object.values(this.bindings))i instanceof mg?e=Math.max(e,i.texture.updateTimestamp):i instanceof cr||i instanceof Fn?e=Math.max(e,i.updateTimestamp):i instanceof bg||(e=Math.max(e,i.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const i={...e.attributes};for(const[r]of Object.entries(i))!this.pipeline.shaderLayout.attributes.find(o=>o.name===r)&&r!=="positions"&&delete i[r];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(i,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,i=null;this.pipeline&&(it.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,i=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const r=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let o=null;this.source?o=r:this.fs&&(o=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:r,fs:o}),this._attributeInfos=DI(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),i&&this.shaderFactory.release(i)}return this.pipeline}_logDrawCallStart(){const e=it.level>3?0:eU;it.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:it.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=GL(this.pipeline.shaderLayout,this.id);it.table(zh,e)();const i=this.shaderInputs.getDebugTable();for(const[o,h]of Object.entries(this.uniforms))i[o]={value:h};it.table(zh,i)();const r=this._getAttributeDebugTable();it.table(zh,this._attributeInfos)(),it.table(zh,r)(),it.groupEnd(zh)(),this._logOpen=!1}}_logFramebuffer(e){const i=it.get("framebuffer");if(this._drawCount++,!i||this._drawCount++>3&&this._drawCount%60)return;const r=e.props.framebuffer;r&&QL(r,{id:r.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[i,r]of Object.entries(this._attributeInfos))e[r.location]={name:i,type:r.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[r.location],r.bufferDataType)};if(this.vertexArray.indexBuffer){const{indexBuffer:i}=this.vertexArray,r=i.indexType==="uint32"?new Uint32Array(i.debugData):new Uint16Array(i.debugData);e.indices={name:"indices",type:i.indexType,values:r.toString()}}return e}_getBufferOrConstantValues(e,i){const r=NI(i);return(e instanceof cr?new r(e.debugData):e).toString()}};Z(nm,"defaultProps",{...hu.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:_g.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let gu=nm;function uE(t,e){const i=[...t];for(const r of e){const o=i.findIndex(h=>h.name===r.name);o<0?i.push(r):i[o]=r}return i}function tU(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function dE(t){var e;return t.attributes?(e=t.attributes)==null?void 0:e.map(i=>i.attribute):[t.name]}class Bf{constructor(e,i=gu.defaultProps){Z(this,"device");Z(this,"model");Z(this,"transformFeedback");Yi(Bf.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new gu(this.device,{id:i.id||"buffer-transform-model",fs:i.fs||BB(),topology:i.topology||"point-list",...i}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:i.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}static isSupported(e){var i;return((i=e==null?void 0:e.info)==null?void 0:i.type)==="webgl"}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const i=this.device.beginRenderPass(e);this.model.draw(i),i.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const i=this.getBuffer(e);if(i instanceof cr)return i.readAsync();const{buffer:r,byteOffset:o=0,byteLength:h=r.byteLength}=i;return r.readAsync(o,h)}}class iU{constructor(e){Z(this,"id");Z(this,"topology");Z(this,"vertexCount");Z(this,"indices");Z(this,"attributes");Z(this,"userData",{});const{attributes:i={},indices:r=null,vertexCount:o=null}=e;this.id=e.id||Nc("geometry"),this.topology=e.topology,r&&(this.indices=ArrayBuffer.isView(r)?{value:r,size:1}:r),this.attributes={};for(const[h,d]of Object.entries(i)){const c=ArrayBuffer.isView(d)?{value:d}:d;Yi(ArrayBuffer.isView(c.value),`${this._print(h)}: must be typed array or object with value as typed array`),(h==="POSITION"||h==="positions")&&!c.size&&(c.size=3),h==="indices"?(Yi(!this.indices),this.indices=c):this.attributes[h]=c}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,i){return this}_calculateVertexCount(e,i){if(i)return i.value.length;let r=1/0;for(const o of Object.values(e)){const{value:h,size:d,constant:c}=o;!c&&h&&d>=1&&(r=Math.min(r,h.length/d))}return Yi(Number.isFinite(r)),r}}const rU={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class uP extends nx{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:i,views:r,viewports:o,onViewportActive:h,pickingFBO:d,deviceRect:{x:c,y:x,width:S,height:P},cullRect:M,effects:D,pass:H="picking",pickZ:Q,moduleParameters:G}){this.pickZ=Q;const _e=this._resetColorEncoder(Q),ve=[c,x,S,P],be=super.render({target:d,layers:e,layerFilter:i,views:r,viewports:o,onViewportActive:h,cullRect:M,effects:D==null?void 0:D.filter(Be=>Be.useInPicking),pass:H,isPicking:!0,moduleParameters:G,clearColor:[0,0,0,0],colorMask:15,scissorRect:ve});return this._colorEncoderState=null,{decodePickingColor:_e&&nU.bind(null,_e),stats:be}}shouldDrawLayer(e){const{pickable:i,operation:r}=e.props;return i&&r.includes("draw")||r.includes("terrain")||r.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,i,r){const o={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:h,operation:d}=e.props;return!this._colorEncoderState||d.includes("terrain")?o.blend=!1:h&&d.includes("draw")&&(Object.assign(o,rU),o.blend=!0,o.blendColor=sU(this._colorEncoderState,e,r)),o}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function sU(t,e,i){const{byLayer:r,byAlpha:o}=t;let h,d=r.get(e);return d?(d.viewports.push(i),h=d.a):(h=r.size+1,h<=255?(d={a:h,layer:e,viewports:[i]},r.set(e,d),o[h]=d):(Ni.warn("Too many pickable layers, only picking the first 255")(),h=0)),[0,0,0,h/255]}function nU(t,e){const i=t.byAlpha[e[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(e)}}const jh={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},Cg=Symbol.for("component"),Tc=Symbol.for("propTypes"),Z0=Symbol.for("deprecatedProps"),nu=Symbol.for("asyncPropDefaults"),Pc=Symbol.for("asyncPropOriginal"),ll=Symbol.for("asyncPropResolved");function zf(t,e=()=>!0){return Array.isArray(t)?dP(t,e,[]):e(t)?[t]:[]}function dP(t,e,i){let r=-1;for(;++r0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,i){if(e===this._data&&!i)return;this._data=e;const r=++this._loadCount;let o=e;typeof e=="string"&&(o=Ib(e)),o instanceof Promise?(this.isLoaded=!1,this._loader=o.then(h=>{this._loadCount===r&&(this.isLoaded=!0,this._error=void 0,this._content=h)}).catch(h=>{this._loadCount===r&&(this.isLoaded=!0,this._error=h||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const h of this._subscribers)h.onChange(this.getData())}}class lU{constructor(e){var i;this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:(i=e.device)==null?void 0:i.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:i,forceUpdate:r=!1,persistent:o=!0}){let h=this._resources[e];h?h.setData(i,r):(h=new aU(e,i,this._context),this._resources[e]=h),h.persistent=o}remove(e){const i=this._resources[e];i&&(i.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const i=this._consumers[e];if(i){for(const r in i){const o=i[r],h=this._resources[o.resourceId];h&&h.unsubscribe(o)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:i,consumerId:r,requestId:o="default"}){const{_resources:h,protocol:d}=this;e.startsWith(d)&&(e=e.replace(d,""),h[e]||this.add({resourceId:e,data:null,persistent:!1}));const c=h[e];if(this._track(r,o,c,i),c)return c.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,i,r,o){const h=this._consumers,d=h[e]=h[e]||{};let c=d[i];const x=c&&c.resourceId&&this._resources[c.resourceId];x&&(x.unsubscribe(c),this.prune()),r&&(c?(c.onChange=o,c.resourceId=r.id):c={onChange:o,resourceId:r.id},d[i]=c,r.subscribe(c))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const i=this._resources[e];!i.persistent&&!i.inUse()&&(i.delete(),delete this._resources[e])}}}const cU="layerManager.setLayers",hU="layerManager.activateViewport";class uU{constructor(e,i){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=c=>{Os(hU,this,c),c&&(this.context.viewport=c)};const{deck:r,stats:o,viewport:h,timeline:d}=i||{};this.layers=[],this.resourceManager=new lU({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e==null?void 0:e.gl,deck:r,shaderAssembler:yL(),defaultShaderModules:[],renderPass:void 0,stats:o||new Tm({id:"deck.gl"}),viewport:h||new Rg({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:d||new hP,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let i=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const r of this.layers){const o=r.getNeedsRedraw(e);i=i||o}return i}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(i=>e.find(r=>i.id.indexOf(r)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,i){Os(cU,this,i,e),this._lastRenderedLayers=e;const r=zf(e,Boolean);for(const o of r)o.context=this.context;this._updateLayers(this.layers,r)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:i}=this.context;i.find(r=>r.name===e.name)||(i.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:i}=this.context,r=i.findIndex(o=>o.name===e.name);r>=0&&(i.splice(r,1),this._defaultShaderModulesChanged=!0)}_handleError(e,i,r){r.raiseError(i,`${e} of ${r}`)}_updateLayers(e,i){const r={};for(const d of e)r[d.id]?Ni.warn(`Multiple old layers with same id ${d.id}`)():r[d.id]=d;if(this._defaultShaderModulesChanged){for(const d of e)d.setNeedsUpdate(),d.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const o=[];this._updateSublayersRecursively(i,r,o),this._finalizeOldLayers(r);let h=!1;for(const d of o)if(d.hasUniformTransition()){h=`Uniform transition in ${d}`;break}this._needsUpdate=h,this.layers=o}_updateSublayersRecursively(e,i,r){for(const o of e){o.context=this.context;const h=i[o.id];h===null&&Ni.warn(`Multiple new layers with same id ${o.id}`)(),i[o.id]=null;let d=null;try{this._debug&&h!==o&&o.validateProps(),h?(this._transferLayerState(h,o),this._updateLayer(o)):this._initializeLayer(o),r.push(o),d=o.isComposite?o.getSubLayers():null}catch(c){this._handleError("matching",c,o)}d&&this._updateSublayersRecursively(d,i,r)}}_finalizeOldLayers(e){for(const i in e){const r=e[i];r&&this._finalizeLayer(r)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=jh.INITIALIZED}catch(i){this._handleError("initialization",i,e)}}_transferLayerState(e,i){i._transferState(e),i.lifecycle=jh.MATCHED,i!==e&&(e.lifecycle=jh.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(i){this._handleError("update",i,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=jh.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=jh.FINALIZED}catch(i){this._handleError("finalization",i,e)}}}function xn(t,e,i){if(t===e)return!0;if(!i||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;ri.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(i=>{e[i.id]=i}),e}getView(e){return this.views.find(i=>i.id===e)}getViewState(e){const i=typeof e=="string"?this.getView(e):e,r=i&&this.viewState[i.getViewStateId()]||this.viewState;return i?i.filterViewState(r):r}getViewport(e){return this._viewportMap[e]}unproject(e,i){const r=this.getViewports(),o={x:e[0],y:e[1]};for(let h=r.length-1;h>=0;--h){const d=r[h];if(d.containsPixel(o)){const c=e.slice();return c[0]-=d.x,c[1]-=d.y,d.unproject(c,i)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,i){(e!==this.width||i!==this.height)&&(this.width=e,this.height=i,this.setNeedsUpdate("Size changed"))}_setViews(e){e=zf(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!xn(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):Ni.warn("missing `viewState` or `initialViewState`")()}_createController(e,i){const r=i.type;return new r({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:h=>{var d;return(d=this.getView(e.id))==null?void 0:d.makeViewport({viewState:h,width:this.width,height:this.height})}})}_updateController(e,i,r,o){const h=e.controller;if(h&&r){const d={...i,...h,id:e.id,x:r.x,y:r.y,width:r.width,height:r.height};return(!o||o.constructor!==h.type)&&(o=this._createController(e,d)),o&&o.setProps(d),o}return null}_rebuildViewports(){const{views:e}=this,i=this.controllers;this._viewports=[],this.controllers={};let r=!1;for(let o=e.length;o--;){const h=e[o],d=this.getViewState(h),c=h.makeViewport({viewState:d,width:this.width,height:this.height});let x=i[h.id];const S=!!h.controller;S&&!x&&(r=!0),(r||!S)&&x&&(x.finalize(),x=null),this.controllers[h.id]=this._updateController(h,d,c,x),c&&this._viewports.unshift(c)}for(const o in i){const h=i[o];h&&!this.controllers[o]&&h.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,i){return e.length!==i.length?!0:e.some((r,o)=>!e[o].equals(i[o]))}}const fU=/([0-9]+\.?[0-9]*)(%|px)/;function Ya(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":const e=fU.exec(t);if(e&&e.length>=3){const i=e[2]==="%",r=parseFloat(e[1]);return{position:i?r/100:r,relative:i}}default:throw new Error(`Could not parse position string ${t}`)}}function Ka(t,e){return t.relative?Math.round(t.position*e):t.position}class pU{constructor(e){const{id:i,x:r=0,y:o=0,width:h="100%",height:d="100%",padding:c=null}=e;this.id=i||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Ya(r),this._y=Ya(o),this._width=Ya(h),this._height=Ya(d),this._padding=c&&{left:Ya(c.left||0),right:Ya(c.right||0),top:Ya(c.top||0),bottom:Ya(c.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&xn(this.props,e.props,2)}makeViewport({width:e,height:i,viewState:r}){r=this.filterViewState(r);const o=this.getDimensions({width:e,height:i});return!o.height||!o.width?null:new this.ViewportType({...r,...this.props,...o})}getViewStateId(){const{viewState:e}=this.props;return typeof e=="string"?e:(e==null?void 0:e.id)||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;const i={...e};for(const r in this.props.viewState)r!=="id"&&(i[r]=this.props.viewState[r]);return i}return e}getDimensions({width:e,height:i}){const r={x:Ka(this._x,e),y:Ka(this._y,i),width:Ka(this._width,e),height:Ka(this._height,i)};return this._padding&&(r.padding={left:Ka(this._padding.left,e),top:Ka(this._padding.top,i),right:Ka(this._padding.right,e),bottom:Ka(this._padding.bottom,i)}),r}get controller(){const e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}}class Im{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){var i,r;this.cancel(),this.settings=e,this._inProgress=!0,(r=(i=this.settings).onStart)==null||r.call(i,this)}end(){var e,i;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,(i=(e=this.settings).onEnd)==null||i.call(e,this))}cancel(){var e,i;this._inProgress&&((i=(e=this.settings).onInterrupt)==null||i.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var e,i;if(!this._inProgress)return!1;if(this._handle===null){const{_timeline:r,settings:o}=this;this._handle=r.addChannel({delay:r.getTime(),duration:o.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),(i=(e=this.settings).onUpdate)==null||i.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const fE=()=>{},Gb={BREAK:1,SNAP_TO_END:2,IGNORE:3},_U=t=>t,gU=Gb.BREAK;class mU{constructor(e){this._onTransitionUpdate=i=>{const{time:r,settings:{interpolator:o,startProps:h,endProps:d,duration:c,easing:x}}=i,S=x(r/c),P=o.interpolateProps(h,d,S);this.propsInTransition=this.getControllerState({...this.props,...P}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Im(e.timeline),this.onViewStateChange=e.onViewStateChange||fE,this.onStateChange=e.onStateChange||fE}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let i=!1;const r=this.props;if(this.props=e,!r||this._shouldIgnoreViewportChange(r,e))return!1;if(this._isTransitionEnabled(e)){let o=r;if(this.transition.inProgress){const{interruption:h,endProps:d}=this.transition.settings;o={...r,...h===Gb.SNAP_TO_END?d:this.propsInTransition||r}}this._triggerTransition(o,e),i=!0}else this.transition.cancel();return i}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:i,transitionInterpolator:r}=e;return(i>0||i==="auto")&&!!r}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,i){return this.transition.inProgress?this.transition.settings.interruption===Gb.IGNORE||this._isUpdateDueToCurrentTransition(i):this._isTransitionEnabled(i)?i.transitionInterpolator.arePropsEqual(e,i):!0}_triggerTransition(e,i){const r=this.getControllerState(e),o=this.getControllerState(i).shortestPathFrom(r),h=i.transitionInterpolator,d=h.getDuration?h.getDuration(e,i):i.transitionDuration;if(d===0)return;const c=h.initializeProps(e,o);this.propsInTransition={};const x={duration:d,easing:i.transitionEasing||_U,interpolator:h,interruption:i.transitionInterruption||gU,startProps:c.start,endProps:c.end,onStart:i.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(i.onTransitionInterrupt),onEnd:this._onTransitionEnd(i.onTransitionEnd)};this.transition.start(x),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return i=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e==null||e(i)}}}function Or(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}class yU{constructor(e){const{compare:i,extract:r,required:o}=e;this._propsToCompare=i,this._propsToExtract=r||i,this._requiredProps=o}arePropsEqual(e,i){for(const r of this._propsToCompare)if(!(r in e)||!(r in i)||!Df(e[r],i[r]))return!1;return!0}initializeProps(e,i){const r={},o={};for(const h of this._propsToExtract)(h in e||h in i)&&(r[h]=e[h],o[h]=i[h]);return this._checkRequiredProps(r),this._checkRequiredProps(o),{start:r,end:o}}getDuration(e,i){return i.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(i=>{const r=e[i];Or(Number.isFinite(r)||Array.isArray(r),`${i} is required for transition`)})}}const bU=["longitude","latitude","zoom","bearing","pitch"],vU=["longitude","latitude","zoom"];class fP extends yU{constructor(e={}){const i=Array.isArray(e)?e:e.transitionProps,r=Array.isArray(e)?{}:e;r.transitionProps=Array.isArray(i)?{compare:i,required:i}:i||{compare:bU,required:vU},super(r.transitionProps),this.opts=r}initializeProps(e,i){const r=super.initializeProps(e,i),{makeViewport:o,around:h}=this.opts;if(o&&h){const d=o(e),c=o(i),x=d.unproject(h);r.start.around=h,Object.assign(r.end,{around:c.project(x),aroundPosition:x,width:i.width,height:i.height})}return r}interpolateProps(e,i,r){const o={};for(const h of this._propsToExtract)o[h]=Sg(e[h]||0,i[h]||0,r);if(i.aroundPosition&&this.opts.makeViewport){const h=this.opts.makeViewport({...i,...o});Object.assign(o,h.panByPosition(i.aroundPosition,Sg(e.around,i.around,r)))}return o}}const Ja={transitionDuration:0},xU=300,B_=t=>1-(1-t)*(1-t),Lh={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},ac={};class wU{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new mU({...e,getControllerState:i=>new this.ControllerState(i),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){var e;for(const i in this._events)this._events[i]&&((e=this.eventManager)==null||e.off(i,this.handleEvent));this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const i=this._eventStartBlocked;switch(e.type){case"panstart":return i?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return i?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return i?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:i,y:r}=this.props,{offsetCenter:o}=e;return[o.x-i,o.y-r]}isPointInBounds(e,i){const{width:r,height:o}=this.props;if(i&&i.handled)return!1;const h=e[0]>=0&&e[0]<=r&&e[1]>=0&&e[1]<=o;return h&&i&&i.stopPropagation(),h}isFunctionKeyPressed(e){const{srcEvent:i}=e;return!!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const i=setTimeout(()=>{this._eventStartBlocked===i&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=i}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?xU:0;const{scrollZoom:r=!0,dragPan:o=!0,dragRotate:h=!0,doubleClickZoom:d=!0,touchZoom:c=!0,touchRotate:x=!1,keyboard:S=!0}=e,P=!!this.onViewStateChange;this.toggleEvents(Lh.WHEEL,P&&r),this.toggleEvents(Lh.PAN,P),this.toggleEvents(Lh.PINCH,P&&(c||x)),this.toggleEvents(Lh.TRIPLE_PAN,P&&x),this.toggleEvents(Lh.DOUBLE_TAP,P&&d),this.toggleEvents(Lh.KEYBOARD,P&&S),this.scrollZoom=r,this.dragPan=o,this.dragRotate=h,this.doubleClickZoom=d,this.touchZoom=c,this.touchRotate=x,this.keyboard=S}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,i){this.eventManager&&e.forEach(r=>{this._events[r]!==i&&(this._events[r]=i,i?this.eventManager.on(r,this.handleEvent):this.eventManager.off(r,this.handleEvent))})}updateViewport(e,i=null,r={}){const o={...e.getViewportProps(),...i},h=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(r),h){const d=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:o,interactionState:this._interactionState,oldViewState:d,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;let r=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(r=!r);const o=this.controllerState[r?"panStart":"rotateStart"]({pos:i});return this._panMove=r,this.updateViewport(o,Ja,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;const i=this.getCenter(e),r=this.controllerState.pan({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:i}=this;if(this.dragPan&&i&&e.velocity){const r=this.getCenter(e),o=[r[0]+e.velocityX*i/2,r[1]+e.velocityY*i/2],h=this.controllerState.pan({pos:o}).panEnd();this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isPanning:!0})}else{const r=this.controllerState.panEnd();this.updateViewport(r,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const i=this.getCenter(e),r=this.controllerState.rotate({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:i}=this;if(this.dragRotate&&i&&e.velocity){const r=this.getCenter(e),o=[r[0]+e.velocityX*i/2,r[1]+e.velocityY*i/2],h=this.controllerState.rotate({pos:o}).rotateEnd();this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isRotating:!0})}else{const r=this.controllerState.rotateEnd();this.updateViewport(r,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;e.srcEvent.preventDefault();const{speed:r=.01,smooth:o=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:h}=e;let d=2/(1+Math.exp(-Math.abs(h*r)));h<0&&d!==0&&(d=1/d);const c=this.controllerState.zoom({pos:i,scale:d});return this.updateViewport(c,{...this._getTransitionProps({around:i}),transitionDuration:o?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.controllerState.rotateStart({pos:i});return this.updateViewport(r,Ja,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;const i=this.getCenter(e);i[0]-=e.deltaX;const r=this.controllerState.rotate({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this;if(this.touchRotate&&i&&e.velocityY){const r=this.getCenter(e),o=[r[0],r[1]+=e.velocityY*i/2],h=this.controllerState.rotate({pos:o});this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isRotating:!0}),this.blockEvents(i)}else{const r=this.controllerState.rotateEnd();this.updateViewport(r,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.controllerState.zoomStart({pos:i}).rotateStart({pos:i});return ac._startPinchRotation=e.rotation,ac._lastPinchEvent=e,this.updateViewport(r,Ja,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let i=this.controllerState;if(this.touchZoom){const{scale:r}=e,o=this.getCenter(e);i=i.zoom({pos:o,scale:r})}if(this.touchRotate){const{rotation:r}=e;i=i.rotate({deltaAngleX:ac._startPinchRotation-r})}return this.updateViewport(i,Ja,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ac._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this,{_lastPinchEvent:r}=ac;if(this.touchZoom&&i&&r&&e.scale!==r.scale){const o=this.getCenter(e);let h=this.controllerState.rotateEnd();const d=Math.log2(e.scale),c=(d-Math.log2(r.scale))/(e.deltaTime-r.deltaTime),x=Math.pow(2,d+c*i/2);h=h.zoom({pos:o,scale:x}).zoomEnd(),this.updateViewport(h,{...this._getTransitionProps({around:o}),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(i)}else{const o=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return ac._startPinchRotation=null,ac._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.isFunctionKeyPressed(e),o=this.controllerState.zoom({pos:i,scale:r?.5:2});return this.updateViewport(o,this._getTransitionProps({around:i}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const i=this.isFunctionKeyPressed(e),{zoomSpeed:r,moveSpeed:o,rotateSpeedX:h,rotateSpeedY:d}=this.keyboard===!0?{}:this.keyboard,{controllerState:c}=this;let x;const S={};switch(e.srcEvent.code){case"Minus":x=i?c.zoomOut(r).zoomOut(r):c.zoomOut(r),S.isZooming=!0;break;case"Equal":x=i?c.zoomIn(r).zoomIn(r):c.zoomIn(r),S.isZooming=!0;break;case"ArrowLeft":i?(x=c.rotateLeft(h),S.isRotating=!0):(x=c.moveLeft(o),S.isPanning=!0);break;case"ArrowRight":i?(x=c.rotateRight(h),S.isRotating=!0):(x=c.moveRight(o),S.isPanning=!0);break;case"ArrowUp":i?(x=c.rotateUp(d),S.isRotating=!0):(x=c.moveUp(o),S.isPanning=!0);break;case"ArrowDown":i?(x=c.rotateDown(d),S.isRotating=!0):(x=c.moveDown(o),S.isPanning=!0);break;default:return!1}return this.updateViewport(x,this._getTransitionProps(),S),!0}_getTransitionProps(e){const{transition:i}=this;return!i||!i.transitionInterpolator?Ja:e?{...i,transitionInterpolator:new fP({...e,...i.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:i}}class TU{constructor(e,i){this._viewportProps=this.applyConstraints(e),this._state=i}getViewportProps(){return this._viewportProps}getState(){return this._state}}const pE=5,SU=1.2;class EU extends TU{constructor(e){const{width:i,height:r,latitude:o,longitude:h,zoom:d,bearing:c=0,pitch:x=0,altitude:S=1.5,position:P=[0,0,0],maxZoom:M=20,minZoom:D=0,maxPitch:H=60,minPitch:Q=0,startPanLngLat:G,startZoomLngLat:_e,startRotatePos:ve,startBearing:be,startPitch:Se,startZoom:Be,normalize:je=!0}=e;Or(Number.isFinite(h)),Or(Number.isFinite(o)),Or(Number.isFinite(d)),super({width:i,height:r,latitude:o,longitude:h,zoom:d,bearing:c,pitch:x,altitude:S,maxZoom:M,minZoom:D,maxPitch:H,minPitch:Q,normalize:je,position:P},{startPanLngLat:G,startZoomLngLat:_e,startRotatePos:ve,startBearing:be,startPitch:Se,startZoom:Be}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:i}){const r=this.getState().startPanLngLat||this._unproject(i);if(!r)return this;const h=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(h)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:i=0,deltaAngleY:r=0}){const{startRotatePos:o,startBearing:h,startPitch:d}=this.getState();if(!o||h===void 0||d===void 0)return this;let c;return e?c=this._getNewRotation(e,o,d,h):c={bearing:h+i,pitch:d+r},this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:i,scale:r}){let{startZoom:o,startZoomLngLat:h}=this.getState();if(h||(o=this.getViewportProps().zoom,h=this._unproject(i)||this._unproject(e)),!h)return this;const{maxZoom:d,minZoom:c}=this.getViewportProps();let x=o+Math.log2(r);x=al(x,c,d);const S=this.makeViewport({...this.getViewportProps(),zoom:x});return this._getUpdatedState({zoom:x,...S.panByPosition(h,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const i=e.getViewportProps(),r={...this.getViewportProps()},{bearing:o,longitude:h}=r;return Math.abs(o-i.bearing)>180&&(r.bearing=o<0?o+360:o-360),Math.abs(h-i.longitude)>180&&(r.longitude=h<0?h+360:h-360),r}applyConstraints(e){const{maxZoom:i,minZoom:r,zoom:o}=e;e.zoom=al(o,r,i);const{maxPitch:h,minPitch:d,pitch:c}=e;e.pitch=al(c,d,h);const{normalize:x=!0}=e;return x&&Object.assign(e,sL(e)),e}_zoomFromCenter(e){const{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e})}_panFromCenter(e){const{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const i=this.makeViewport(this.getViewportProps());return e&&i.unproject(e)}_getNewRotation(e,i,r,o){const h=e[0]-i[0],d=e[1]-i[1],c=e[1],x=i[1],{width:S,height:P}=this.getViewportProps(),M=h/S;let D=0;d>0?Math.abs(P-x)>pE&&(D=d/(x-P)*SU):d<0&&x>pE&&(D=1-c/x),D=al(D,-1,1);const{minPitch:H,maxPitch:Q}=this.getViewportProps(),G=o+180*M;let _e=r;return D>0?_e=r+D*(Q-r):D<0&&(_e=r-D*(H-r)),{pitch:_e,bearing:G}}}class AU extends wU{constructor(){super(...arguments),this.ControllerState=EU,this.transition={transitionDuration:300,transitionInterpolator:new fP({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const i=this.props;super.setProps(e),(!i||i.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}const j1=class j1 extends pU{constructor(e={}){super(e)}get ViewportType(){return Nf}get ControllerType(){return AU}};j1.displayName="MapView";let Mg=j1;const IU=new lP;function PU(t,e){const i=t.order??1/0,r=e.order??1/0;return i-r}class RU{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const i=this._defaultEffects;if(!i.find(r=>r.id===e.id)){const r=i.findIndex(o=>PU(o,e)>0);r<0?i.push(e):i.splice(r,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(xn(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}getEffects(){return this._resolvedEffects}_setEffects(e){const i={};for(const o of this.effects)i[o.id]=o;const r=[];for(const o of e){const h=i[o.id];let d=o;h&&h!==o?h.setProps?(h.setProps(o.props),d=h):h.cleanup(this._context):h||o.setup(this._context),r.push(d),delete i[o.id]}for(const o in i)i[o].cleanup(this._context);this.effects=r,this._resolvedEffects=r.concat(this._defaultEffects),e.some(o=>o instanceof lP)||this._resolvedEffects.push(IU),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class CU extends nx{shouldDrawLayer(e){const{operation:i}=e.props;return i.includes("draw")||i.includes("terrain")}}const MU="deckRenderer.renderLayers";class kU{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new CU(e),this.pickLayersPass=new uP(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const i=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,r={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};r.effects&&this._preRender(r.effects,r);const o=this.lastPostProcessEffect?this.renderBuffers[0]:r.target;this.lastPostProcessEffect&&(r.clearColor=[0,0,0,0],r.clearCanvas=!0);const h=i.render({...r,target:o});r.effects&&this._postRender(r.effects,r),this.renderCount++,Os(MU,this,h,e)}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}finalize(){const{renderBuffers:e}=this;for(const i of e)i.delete();e.length=0}_preRender(e,i){this.lastPostProcessEffect=null,i.preRenderStats=i.preRenderStats||{};for(const r of e)i.preRenderStats[r.id]=r.preRender(i),r.postRender&&(this.lastPostProcessEffect=r.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,i=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(r=>{const o=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${r}`,colorAttachments:[o]}))});for(const r of e)r.resize(i)}_postRender(e,i){const{renderBuffers:r}=this,o={...i,inputBuffer:r[0],swapBuffer:r[1]};for(const h of e)if(h.postRender){o.target=h.id===this.lastPostProcessEffect?i.target:void 0;const d=h.postRender(o);o.inputBuffer=d,o.swapBuffer=d===r[0]?r[1]:r[0]}}}const DU={pickedColor:null,pickedObjectIndex:-1};function OU({pickedColors:t,decodePickingColor:e,deviceX:i,deviceY:r,deviceRadius:o,deviceRect:h}){const{x:d,y:c,width:x,height:S}=h;let P=o*o,M=-1,D=0;for(let H=0;HP)D+=4*x;else for(let _e=0;_e=0){const be=_e+d-i,Se=be*be+G;Se<=P&&(P=Se,M=D)}D+=4}}if(M>=0){const H=t.slice(M,M+4),Q=e(H);if(Q){const G=Math.floor(M/4/x),_e=M/4-G*x;return{...Q,pickedColor:H,pickedX:d+_e,pickedY:c+G}}Ni.error("Picked non-existent layer. Is picking buffer corrupt?")()}return DU}function FU({pickedColors:t,decodePickingColor:e}){const i=new Map;if(t){for(let r=0;r=0){const h=t.slice(r,r+4),d=h.join(",");if(!i.has(d)){const c=e(h);c?i.set(d,{...c,color:h}):Ni.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(i.values())}function pP({pickInfo:t,viewports:e,pixelRatio:i,x:r,y:o,z:h}){let d=e[0];e.length>1&&(d=BU((t==null?void 0:t.pickedViewports)||e,{x:r,y:o}));let c;if(d){const x=[r-d.x,o-d.y];h!==void 0&&(x[2]=h),c=d.unproject(x)}return{color:null,layer:null,viewport:d,index:-1,picked:!1,x:r,y:o,pixel:[r,o],coordinate:c,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:i}}function NU(t){const{pickInfo:e,lastPickedInfo:i,mode:r,layers:o}=t,{pickedColor:h,pickedLayer:d,pickedObjectIndex:c}=e,x=d?[d]:[];if(r==="hover"){const M=i.index,D=i.layerId,H=d?d.props.id:null;if(H!==D||c!==M){if(H!==D){const Q=o.find(G=>G.props.id===D);Q&&x.unshift(Q)}i.layerId=H,i.index=c,i.info=null}}const S=pP(t),P=new Map;return P.set(null,S),x.forEach(M=>{let D={...S};M===d&&(D.color=h,D.index=c,D.picked=!0),D=_P({layer:M,info:D,mode:r});const H=D.layer;M===d&&r==="hover"&&(i.info=D),P.set(H.id,D),r==="hover"&&H.updateAutoHighlight(D)}),P}function _P({layer:t,info:e,mode:i}){for(;t&&e;){const r=e.layer||null;e.sourceLayer=r,e.layer=t,e=t.getPickingInfo({info:e,mode:i,sourceLayer:r}),t=t.parent}return e}function BU(t,e){for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.containsPixel(e))return r}return t[0]}class zU{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new uP(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:i,layers:r,viewports:o},h=this.lastPickedInfo.info){const d=h&&h.layer&&h.layer.id,c=h&&h.viewport&&h.viewport.id,x=d?r.find(D=>D.id===d):null,S=c&&o.find(D=>D.id===c)||o[0],P=S&&S.unproject([e-S.x,i-S.y]);return{...h,...{x:e,y:i,viewport:S,coordinate:P,layer:x}}}_resizeBuffer(){var i,r;if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const o=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}const{canvas:e}=this.device.getCanvasContext();(i=this.pickingFBO)==null||i.resize({width:e.width,height:e.height}),(r=this.depthFBO)==null||r.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;const i=e.filter(r=>this.pickLayersPass.shouldDrawLayer(r)&&!r.isComposite);return i.length?i:null}_pickClosestObject({layers:e,views:i,viewports:r,x:o,y:h,radius:d=0,depth:c=1,mode:x="query",unproject3D:S,onViewportActive:P,effects:M}){const D=this.device.canvasContext.cssToDeviceRatio(),H=this._getPickable(e);if(!H||r.length===0)return{result:[],emptyInfo:pP({viewports:r,x:o,y:h,pixelRatio:D})};this._resizeBuffer();const Q=this.device.canvasContext.cssToDevicePixels([o,h],!0),G=[Q.x+Math.floor(Q.width/2),Q.y+Math.floor(Q.height/2)],_e=Math.round(d*D),{width:ve,height:be}=this.pickingFBO,Se=this._getPickingRect({deviceX:G[0],deviceY:G[1],deviceRadius:_e,deviceWidth:ve,deviceHeight:be}),Be={x:o-d,y:h-d,width:d*2+1,height:d*2+1};let je;const Fe=[],rt=new Set;for(let vt=0;vt=S);Pt++){const ut=Fe[Pt];let ti={color:ut.pickedColor,layer:null,index:ut.pickedObjectIndex,picked:!0,x:o,y:h,pixelRatio:H};ti=_P({layer:ut.pickedLayer,info:ti,mode:x});const Ft=ti.layer.id;rt.has(Ft)||rt.set(Ft,new Set);const Dt=rt.get(Ft),Ji=ti.object??ti.index;Dt.has(Ji)||(Dt.add(Ji),vt.push(ti))}return vt}_drawAndSample({layers:e,views:i,viewports:r,onViewportActive:o,deviceRect:h,cullRect:d,effects:c,pass:x},S=!1){const P=S?this.depthFBO:this.pickingFBO,M={layers:e,layerFilter:this.layerFilter,views:i,viewports:r,onViewportActive:o,pickingFBO:P,deviceRect:h,cullRect:d,effects:c,pass:x,pickZ:S,preRenderStats:{}};for(const be of c)be.useInPicking&&(M.preRenderStats[be.id]=be.preRender(M));const{decodePickingColor:D}=this.pickLayersPass.render(M),{x:H,y:Q,width:G,height:_e}=h,ve=new(S?Float32Array:Uint8Array)(G*_e*4);return this.device.readPixelsToArrayWebGL(P,{sourceX:H,sourceY:Q,sourceWidth:G,sourceHeight:_e,target:ve}),{pickedColors:ve,decodePickingColor:D}}_getPickingRect({deviceX:e,deviceY:i,deviceRadius:r,deviceWidth:o,deviceHeight:h}){const d=Math.max(0,e-r),c=Math.max(0,i-r),x=Math.min(o,e+r+1)-d,S=Math.min(h,i+r+1)-c;return x<=0||S<=0?null:{x:d,y:c,width:x,height:S}}}const LU={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},UU="top-left",_E="__root";class VU{constructor({deck:e,parentElement:i}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=i}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!xn(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(i=>i.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const i={};for(const r of this.resolvedWidgets)i[r.id]=r;this.resolvedWidgets.length=0;for(const r of this.defaultWidgets)i[r.id]=null,this.resolvedWidgets.push(r);for(let r of e){const o=i[r.id];o?o.viewId!==r.viewId||o.placement!==r.placement?(this._remove(o),this._add(r)):r!==o&&(o.setProps(r.props),r=o):this._add(r),i[r.id]=null,this.resolvedWidgets.push(r)}for(const r in i){const o=i[r];o&&this._remove(o)}this.widgets=e}_add(e){const{viewId:i=null,placement:r=UU}=e,o=e.onAdd({deck:this.deck,viewId:i});o&&this._getContainer(i,r).append(o),e._element=o}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,i){var d;const r=e||_E;let o=this.containers[r];o||(o=document.createElement("div"),o.style.pointerEvents="none",o.style.position="absolute",o.style.overflow="hidden",(d=this.parentElement)==null||d.append(o),this.containers[r]=o);let h=o.querySelector(`.${i}`);return h||(h=document.createElement("div"),h.className=i,h.style.position="absolute",h.style.zIndex="2",Object.assign(h.style,LU[i]),o.append(h)),h}_updateContainers(){const e=this.deck.width,i=this.deck.height;for(const r in this.containers){const o=this.lastViewports[r]||null,h=r===_E||o,d=this.containers[r];h?(d.style.display="block",d.style.left=`${o?o.x:0}px`,d.style.top=`${o?o.y:0}px`,d.style.width=`${o?o.width:e}px`,d.style.height=`${o?o.height:i}px`):d.style.display="none"}}onRedraw({viewports:e,layers:i}){var h,d;const r=e.reduce((c,x)=>(c[x.id]=x,c),{}),{lastViewports:o}=this;for(const c of this.getWidgets()){const{viewId:x}=c;if(x){const S=r[x];S&&(c.onViewportChange&&!S.equals(o[x])&&c.onViewportChange(S),(h=c.onRedraw)==null||h.call(c,{viewports:[S],layers:i}))}else{if(c.onViewportChange)for(const S of e)S.equals(o[S.id])||c.onViewportChange(S);(d=c.onRedraw)==null||d.call(c,{viewports:e,layers:i})}}this.lastViewports=r,this._updateContainers()}onHover(e,i){var r,o;for(const h of this.getWidgets()){const{viewId:d}=h;(!d||d===((r=e.viewport)==null?void 0:r.id))&&((o=h.onHover)==null||o.call(h,e,i))}}onEvent(e,i){var o,h;const r=Xb[i.type];if(r)for(const d of this.getWidgets()){const{viewId:c}=d;(!c||c===((o=e.viewport)==null?void 0:o.id))&&((h=d[r.handler])==null||h.call(d,e,i))}}}const jU={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class $U{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const i=document.createElement("div");return i.className="deck-tooltip",Object.assign(i.style,jU),this.deck=e,this.element=i,i}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){var i;this.isVisible&&e.id===((i=this.lastViewport)==null?void 0:i.id)&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:i}=this,r=i&&i.props.getTooltip;if(!r)return;const o=r(e);this.lastViewport=e.viewport,this.setTooltip(o,e.x,e.y)}setTooltip(e,i,r){const o=this.element;if(o){if(typeof e=="string")o.innerText=e;else if(e)e.text&&(o.innerText=e.text),e.html&&(o.innerHTML=e.html),e.className&&(o.className=e.className);else{this.isVisible=!1,o.style.display="none";return}this.isVisible=!0,o.style.display="block",o.style.transform=`translate(${i}px, ${r}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(o.style,e.style)}}}var Wh;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Wh||(Wh={}));const ox={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Rr=(t,e,i)=>e?t.enable(i):t.disable(i),gE=(t,e,i)=>t.hint(i,e),mn=(t,e,i)=>t.pixelStorei(i,e),mE=(t,e,i)=>{const r=i===36006?36009:36008;return t.bindFramebuffer(r,e)},Qd=(t,e,i)=>{const o={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];t.bindBuffer(o,e)};function Y0(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}const WU={3042:Rr,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:Rr,2885:(t,e)=>t.cullFace(e),2929:Rr,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:Rr,35723:gE,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>{var i;return(i=t.bindTransformFeedback)==null?void 0:i.call(t,36386,e)},34229:(t,e)=>t.bindVertexArray(e),36006:mE,36010:mE,34964:Qd,36662:Qd,36663:Qd,35053:Qd,35055:Qd,2886:(t,e)=>t.frontFace(e),33170:gE,2849:(t,e)=>t.lineWidth(e),32823:Rr,32824:"polygonOffset",10752:"polygonOffset",35977:Rr,32926:Rr,32928:Rr,32938:"sampleCoverage",32939:"sampleCoverage",3089:Rr,3088:(t,e)=>t.scissor(...e),2960:Rr,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),34383:Rr,10754:Rr,12288:Rr,12289:Rr,12290:Rr,12291:Rr,12292:Rr,12293:Rr,12294:Rr,12295:Rr,3333:mn,3317:mn,37440:mn,37441:mn,37443:mn,3330:mn,3332:mn,3331:mn,3314:mn,32878:mn,3316:mn,3315:mn,32877:mn,framebuffer:(t,e)=>{const i=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,i)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{const i=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...i)},blendFunc:(t,e)=>{const i=(e==null?void 0:e.length)===2?[...e,...e]:e;t.blendFuncSeparate(...i)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Y0(e)?e:[e,e];const[i,r]=e;t.stencilMaskSeparate(1028,i),t.stencilMaskSeparate(1029,r)},stencilFunc:(t,e)=>{e=Y0(e)&&e.length===3?[...e,...e]:e;const[i,r,o,h,d,c]=e;t.stencilFuncSeparate(1028,i,r,o),t.stencilFuncSeparate(1029,h,d,c)},stencilOp:(t,e)=>{e=Y0(e)&&e.length===3?[...e,...e]:e;const[i,r,o,h,d,c]=e;t.stencilOpSeparate(1028,i,r,o),t.stencilOpSeparate(1029,h,d,c)},viewport:(t,e)=>t.viewport(...e)};function _r(t,e,i){return e[t]!==void 0?e[t]:i[t]}const HU={blendEquation:(t,e,i)=>t.blendEquationSeparate(_r(32777,e,i),_r(34877,e,i)),blendFunc:(t,e,i)=>t.blendFuncSeparate(_r(32969,e,i),_r(32968,e,i),_r(32971,e,i),_r(32970,e,i)),polygonOffset:(t,e,i)=>t.polygonOffset(_r(32824,e,i),_r(10752,e,i)),sampleCoverage:(t,e,i)=>t.sampleCoverage(_r(32938,e,i),_r(32939,e,i)),stencilFuncFront:(t,e,i)=>t.stencilFuncSeparate(1028,_r(2962,e,i),_r(2967,e,i),_r(2963,e,i)),stencilFuncBack:(t,e,i)=>t.stencilFuncSeparate(1029,_r(34816,e,i),_r(36003,e,i),_r(36004,e,i)),stencilOpFront:(t,e,i)=>t.stencilOpSeparate(1028,_r(2964,e,i),_r(2965,e,i),_r(2966,e,i)),stencilOpBack:(t,e,i)=>t.stencilOpSeparate(1029,_r(34817,e,i),_r(34818,e,i),_r(34819,e,i))},yE={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,i)=>t({[e]:i}),hint:(t,e,i)=>t({[e]:i}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,i)=>t({36007:i}),bindTransformFeedback:(t,e,i)=>t({36389:i}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,i)=>{switch(e){case 36160:return t({36006:i,36010:i});case 36009:return t({36006:i});case 36008:return t({36010:i});default:return null}},bindBuffer:(t,e,i)=>{const r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return r?t({[r]:i}):{valueChanged:!0}},blendColor:(t,e,i,r,o)=>t({32773:new Float32Array([e,i,r,o])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,i)=>t({32777:e,34877:i}),blendFunc:(t,e,i)=>t({32969:e,32968:i,32971:e,32970:i}),blendFuncSeparate:(t,e,i,r,o)=>t({32969:e,32968:i,32971:r,32970:o}),clearColor:(t,e,i,r,o)=>t({3106:new Float32Array([e,i,r,o])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,i,r,o)=>t({3107:[e,i,r,o]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,i)=>t({2928:new Float32Array([e,i])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,i)=>t({32824:e,10752:i}),sampleCoverage:(t,e,i)=>t({32938:e,32939:i}),scissor:(t,e,i,r,o)=>t({3088:new Int32Array([e,i,r,o])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,i)=>t({[e===1028?2968:36005]:i}),stencilFunc:(t,e,i,r)=>t({2962:e,2967:i,2963:r,34816:e,36003:i,36004:r}),stencilFuncSeparate:(t,e,i,r,o)=>t({[e===1028?2962:34816]:i,[e===1028?2967:36003]:r,[e===1028?2963:36004]:o}),stencilOp:(t,e,i,r)=>t({2964:e,2965:i,2966:r,34817:e,34818:i,34819:r}),stencilOpSeparate:(t,e,i,r,o)=>t({[e===1028?2964:34817]:i,[e===1028?2965:34818]:r,[e===1028?2966:34819]:o}),viewport:(t,e,i,r,o)=>t({2978:[e,i,r,o]})},wo=(t,e)=>t.isEnabled(e),bE={3042:wo,2884:wo,2929:wo,3024:wo,32823:wo,32926:wo,32928:wo,3089:wo,2960:wo,35977:wo},XU=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function Tu(t,e){if(ZU(e))return;const i={};for(const o in e){const h=Number(o),d=WU[o];d&&(typeof d=="string"?i[d]=!0:d(t,e[o],h))}const r=t.state&&t.state.cache;if(r)for(const o in i){const h=HU[o];h(t,e,r)}}function gP(t,e=ox){if(typeof e=="number"){const o=e,h=bE[o];return h?h(t,o):t.getParameter(o)}const i=Array.isArray(e)?e:Object.keys(e),r={};for(const o of i){const h=bE[o];r[o]=h?h(t,Number(o)):t.getParameter(Number(o))}return r}function qU(t){Tu(t,ox)}function ZU(t){for(const e in t)return!1;return!0}function YU(t,e){if(t===e)return!0;const i=Array.isArray(t)||ArrayBuffer.isView(t),r=Array.isArray(e)||ArrayBuffer.isView(e);if(i&&r&&t.length===e.length){for(let o=0;o{}}={}){Z(this,"gl");Z(this,"program",null);Z(this,"stateStack",[]);Z(this,"enable",!0);Z(this,"cache");Z(this,"log");this.gl=e,this.cache=i?gP(e):Object.assign({},ox),this.log=r,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){Yi(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];Tu(this.gl,e),this.stateStack.pop()}_updateCache(e){let i=!1,r;const o=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const h in e){Yi(h!==void 0);const d=e[h],c=this.cache[h];YU(d,c)||(i=!0,r=c,o&&!(h in o)&&(o[h]=c),this.cache[h]=d)}return{valueChanged:i,oldValue:r}}}function Rc(t){return t.state}function mP(t,e){const{enable:i=!0,copyState:r}=e;if(Yi(r!==void 0),!t.state){t.state=new KU(t,{copyState:r}),GU(t);for(const h in yE){const d=yE[h];JU(t,h,d)}vE(t,"getParameter"),vE(t,"isEnabled")}const o=Rc(t);return o.enable=i,t}function Pm(t){let e=Rc(t);e||(mP(t,{copyState:!1}),e=Rc(t)),e.push()}function Lf(t){const e=Rc(t);Yi(e),e.pop()}function vE(t,e){const i=t[e].bind(t);t[e]=function(o){if(o===void 0||XU.has(o))return i(o);const h=Rc(t);return o in h.cache||(h.cache[o]=i(o)),h.enable?h.cache[o]:i(o)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function JU(t,e,i){if(!t[e])return;const r=t[e].bind(t);t[e]=function(...h){const d=Rc(t),{valueChanged:c,oldValue:x}=i(d._updateCache,...h);return c&&r(...h),x},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function GU(t){const e=t.useProgram.bind(t);t.useProgram=function(r){const o=Rc(t);o.program!==r&&(e(r),o.program=r)}}const QU={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function e5(t,e){e={...QU,...e};let i=null;const r=h=>i=h.statusMessage||i;t.addEventListener("webglcontextcreationerror",r,!1);let o=null;if(o||(o=t.getContext("webgl2",e)),t.removeEventListener("webglcontextcreationerror",r,!1),!o)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(e.onContextLost){const{onContextLost:h}=e;t.addEventListener("webglcontextlost",d=>h(d),!1)}if(e.onContextRestored){const{onContextRestored:h}=e;t.addEventListener("webglcontextrestored",d=>h(d),!1)}return o}function yl(t,e,i){return i[e]===void 0&&(i[e]=t.getExtension(e)||null),i[e]}function t5(t,e){const i=t.getParameter(7936),r=t.getParameter(7937);yl(t,"WEBGL_debug_renderer_info",e);const o=e.WEBGL_debug_renderer_info,h=t.getParameter(o?o.UNMASKED_VENDOR_WEBGL:7936),d=t.getParameter(o?o.UNMASKED_RENDERER_WEBGL:7937),c=h||i,x=d||r,S=t.getParameter(7938),P=yP(c,x),M=i5(c,x),D=r5(c,x);return{type:"webgl",gpu:P,gpuType:D,gpuBackend:M,vendor:c,renderer:x,version:S,shadingLanguage:"glsl",shadingLanguageVersion:300}}function yP(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function i5(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function r5(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(yP(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function bP(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}const gs="texture-compression-bc",Oi="texture-compression-astc",To="texture-compression-etc2",s5="texture-compression-etc1-webgl",z_="texture-compression-pvrtc-webgl",K0="texture-compression-atc-webgl",ef="float32-renderable-webgl",J0="float16-renderable-webgl",n5="rgb9e5ufloat_renderable-webgl",G0="snorm8-renderable-webgl",tf="norm16-renderable-webgl",Q0="snorm16-renderable-webgl",L_="float32-filterable",xE="float16-filterable-webgl",uf="WEBGL_compressed_texture_s3tc",df="WEBGL_compressed_texture_s3tc_srgb",Hh="EXT_texture_compression_rgtc",Xh="EXT_texture_compression_bptc",o5="WEBGL_compressed_texture_etc",a5="WEBGL_compressed_texture_astc",l5="WEBGL_compressed_texture_etc1",c5="WEBGL_compressed_texture_pvrtc",h5="WEBGL_compressed_texture_atc",wE="EXT_texture_norm16",TE="EXT_render_snorm",u5="EXT_color_buffer_float",ax={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[TE],"norm16-renderable-webgl":[wE],"snorm16-renderable-webgl":[wE,TE],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[uf,df,Hh,Xh],"texture-compression-bc5-webgl":[Hh],"texture-compression-bc7-webgl":[Xh],"texture-compression-etc2":[o5],"texture-compression-astc":[a5],"texture-compression-etc1-webgl":[l5],"texture-compression-pvrtc-webgl":[c5],"texture-compression-atc-webgl":[h5]};function d5(t){return t in ax}function f5(t,e,i){return(ax[e]||[]).every(o=>yl(t,o,i))}const Rm={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:G0},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:G0},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:J0,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:tf,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:Q0},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:G0},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:J0,filter:xE,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:tf},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:Q0},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:ef,filter:L_},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:n5},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:ef,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:tf},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:tf},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:ef,filter:L_,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:J0,filter:xE},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:tf,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:Q0},"rgb32float-webgl":{gl:34837,render:ef,filter:L_,gl2ext:u5,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:ef,filter:L_,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:uf,f:gs},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:df,f:gs},"bc1-rgba-unorm":{gl:33777,x:uf,f:gs},"bc1-rgba-unorm-srgb":{gl:35916,x:df,f:gs},"bc2-rgba-unorm":{gl:33778,x:uf,f:gs},"bc2-rgba-unorm-srgb":{gl:35918,x:df,f:gs},"bc3-rgba-unorm":{gl:33779,x:uf,f:gs},"bc3-rgba-unorm-srgb":{gl:35919,x:df,f:gs},"bc4-r-unorm":{gl:36283,x:Hh,f:gs},"bc4-r-snorm":{gl:36284,x:Hh,f:gs},"bc5-rg-unorm":{gl:36285,x:Hh,f:gs},"bc5-rg-snorm":{gl:36286,x:Hh,f:gs},"bc6h-rgb-ufloat":{gl:36495,x:Xh,f:gs},"bc6h-rgb-float":{gl:36494,x:Xh,f:gs},"bc7-rgba-unorm":{gl:36492,x:Xh,f:gs},"bc7-rgba-unorm-srgb":{gl:36493,x:Xh,f:gs},"etc2-rgb8unorm":{gl:37492,f:To},"etc2-rgb8unorm-srgb":{gl:37494,f:To},"etc2-rgb8a1unorm":{gl:37496,f:To},"etc2-rgb8a1unorm-srgb":{gl:37497,f:To},"etc2-rgba8unorm":{gl:37493,f:To},"etc2-rgba8unorm-srgb":{gl:37495,f:To},"eac-r11unorm":{gl:37488,f:To},"eac-r11snorm":{gl:37489,f:To},"eac-rg11unorm":{gl:37490,f:To},"eac-rg11snorm":{gl:37491,f:To},"astc-4x4-unorm":{gl:37808,f:Oi},"astc-4x4-unorm-srgb":{gl:37840,f:Oi},"astc-5x4-unorm":{gl:37809,f:Oi},"astc-5x4-unorm-srgb":{gl:37841,f:Oi},"astc-5x5-unorm":{gl:37810,f:Oi},"astc-5x5-unorm-srgb":{gl:37842,f:Oi},"astc-6x5-unorm":{gl:37811,f:Oi},"astc-6x5-unorm-srgb":{gl:37843,f:Oi},"astc-6x6-unorm":{gl:37812,f:Oi},"astc-6x6-unorm-srgb":{gl:37844,f:Oi},"astc-8x5-unorm":{gl:37813,f:Oi},"astc-8x5-unorm-srgb":{gl:37845,f:Oi},"astc-8x6-unorm":{gl:37814,f:Oi},"astc-8x6-unorm-srgb":{gl:37846,f:Oi},"astc-8x8-unorm":{gl:37815,f:Oi},"astc-8x8-unorm-srgb":{gl:37847,f:Oi},"astc-10x5-unorm":{gl:37819,f:Oi},"astc-10x5-unorm-srgb":{gl:37851,f:Oi},"astc-10x6-unorm":{gl:37817,f:Oi},"astc-10x6-unorm-srgb":{gl:37849,f:Oi},"astc-10x8-unorm":{gl:37818,f:Oi},"astc-10x8-unorm-srgb":{gl:37850,f:Oi},"astc-10x10-unorm":{gl:37819,f:Oi},"astc-10x10-unorm-srgb":{gl:37851,f:Oi},"astc-12x10-unorm":{gl:37820,f:Oi},"astc-12x10-unorm-srgb":{gl:37852,f:Oi},"astc-12x12-unorm":{gl:37821,f:Oi},"astc-12x12-unorm-srgb":{gl:37853,f:Oi},"pvrtc-rgb4unorm-webgl":{gl:35840,f:z_},"pvrtc-rgba4unorm-webgl":{gl:35842,f:z_},"pvrtc-rbg2unorm-webgl":{gl:35841,f:z_},"pvrtc-rgba2unorm-webgl":{gl:35843,f:z_},"etc1-rbg-unorm-webgl":{gl:36196,f:s5},"atc-rgb-unorm-webgl":{gl:35986,f:K0},"atc-rgba-unorm-webgl":{gl:35986,f:K0},"atc-rgbai-unorm-webgl":{gl:34798,f:K0}},p5={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},_5={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function lx(t,e,i){const r=Rm[e];if(!r||r.gl===void 0)return!1;const o=r.x||r.gl2ext;return o?!!yl(t,o,i):!0}function vP(t){const e=Rm[t],i=e==null?void 0:e.gl;if(i===void 0)throw new Error(`Unsupported texture format ${t}`);return i}function g5(t,e,i){if(!lx(t,e,i)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(RI(e).signed)return!1}catch{return!1}return e.endsWith("32float")?!!yl(t,"OES_texture_float_linear, extensions",i):e.endsWith("16float")?!!yl(t,"OES_texture_half_float_linear, extensions",i):!0}function m5(t,e,i){return!(!lx(t,e,i)||typeof e=="number")}function kg(t){var o;const e=Rm[t],i=vP(t),r=RI(t);return{format:i,dataFormat:(e==null?void 0:e.dataFormat)||b5(r.format,r.integer,r.normalized,i),type:r.dataType?bP(r.dataType):((o=e==null?void 0:e.types)==null?void 0:o[0])||5121,compressed:r.compressed}}function y5(t){const e=Rm[t];if(!(e!=null&&e.attachment))throw new Error(`${t} is not a depth stencil format`);return e.attachment}function SE(t){const e=kg(t),i=p5[e.dataFormat]||4,r=_5[e.type]||1;return i*r}function b5(t,e,i,r){if(r===6408||r===6407)return r;switch(t){case"r":return e&&!i?36244:6403;case"rg":return e&&!i?33320:33319;case"rgb":return e&&!i?36248:6407;case"rgba":return e&&!i?36249:6408;default:return 6408}}const EE={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class v5 extends QB{constructor(i,r,o){super([],o);Z(this,"gl");Z(this,"extensions");Z(this,"testedFeatures",new Set);this.gl=i,this.extensions=r,yl(i,"EXT_color_buffer_float",r)}*[Symbol.iterator](){const i=this.getFeatures();for(const r of i)this.has(r)&&(yield r);return[]}has(i){return this.disabledFeatures[i]?!1:(this.testedFeatures.has(i)||(this.testedFeatures.add(i),d5(i)&&f5(this.gl,i,this.extensions)&&this.features.add(i),this.getWebGLFeature(i)&&this.features.add(i)),this.features.has(i))}initializeFeatures(){const i=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(const r of i)this.has(r)}getFeatures(){return[...Object.keys(EE),...Object.keys(ax)]}getWebGLFeature(i){const r=EE[i];return typeof r=="string"?!!yl(this.gl,r,this.extensions):!!r}}class x5 extends GB{constructor(i){super();Z(this,"gl");Z(this,"limits",{});this.gl=i}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(i){return this.limits[i]===void 0&&(this.limits[i]=this.gl.getParameter(i)),this.limits[i]}}function cl(t,e,i){if(w5(e))return i(t);const{nocatch:r=!0}=e;Pm(t),Tu(t,e);let o;if(r)o=i(t),Lf(t);else try{o=i(t)}finally{Lf(t)}return o}function w5(t){for(const e in t)return!1;return!0}function T5(t,e,i,r){if(gg(e))return r(t);const o=t;Pm(o.gl);try{return S5(t,e),Tu(o.gl,i),r(t)}finally{Lf(o.gl)}}function S5(t,e){const i=t,{gl:r}=i;if(e.cullMode)switch(e.cullMode){case"none":r.disable(2884);break;case"front":r.enable(2884),r.cullFace(1028);break;case"back":r.enable(2884),r.cullFace(1029);break}if(e.frontFace&&r.frontFace(Sc("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&r.enable(34383),e.depthBias!==void 0&&(r.enable(32823),r.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){const h=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,d=Sc("provokingVertex",e.provokingVertex,{first:36429,last:36430});h==null||h.provokingVertexWEBGL(d)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){const h=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,d=Sc("polygonMode",e.polygonMode,{fill:6914,line:6913});h==null||h.polygonModeWEBGL(1028,d),h==null||h.polygonModeWEBGL(1029,d)}e.polygonOffsetLine&&r.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&r.enable(12288),e.clipDistance1&&r.enable(12289),e.clipDistance2&&r.enable(12290),e.clipDistance3&&r.enable(12291),e.clipDistance4&&r.enable(12292),e.clipDistance5&&r.enable(12293),e.clipDistance6&&r.enable(12294),e.clipDistance7&&r.enable(12295)),e.depthWriteEnabled!==void 0&&r.depthMask(A5("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?r.enable(2929):r.disable(2929),r.depthFunc(Qb("depthCompare",e.depthCompare))),e.stencilWriteMask){const o=e.stencilWriteMask;r.stencilMaskSeparate(1028,o),r.stencilMaskSeparate(1029,o)}if(e.stencilReadMask&&it.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const o=e.stencilReadMask||4294967295,h=Qb("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?r.enable(2960):r.disable(2960),r.stencilFuncSeparate(1028,h,0,o),r.stencilFuncSeparate(1029,h,0,o)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const o=eb("stencilPassOperation",e.stencilPassOperation),h=eb("stencilFailOperation",e.stencilFailOperation),d=eb("stencilDepthFailOperation",e.stencilDepthFailOperation);r.stencilOpSeparate(1028,h,d,o),r.stencilOpSeparate(1029,h,d,o)}if(e.blendColorOperation||e.blendAlphaOperation){r.enable(3042);const o=AE("blendColorOperation",e.blendColorOperation||"add"),h=AE("blendAlphaOperation",e.blendAlphaOperation||"add");r.blendEquationSeparate(o,h);const d=U_("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=U_("blendColorDstFactor",e.blendColorDstFactor||"zero"),x=U_("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),S=U_("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");r.blendFuncSeparate(d,c,x,S)}}function Qb(t,e){return Sc(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function eb(t,e){return Sc(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function AE(t,e){return Sc(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function U_(t,e){return Sc(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function E5(t,e){return`Illegal parameter ${e} for ${t}`}function Sc(t,e,i){if(!(e in i))throw new Error(E5(t,e));return i[e]}function A5(t,e){return e}function xP(t){const e={};return t.addressModeU&&(e[10242]=tb(t.addressModeU)),t.addressModeV&&(e[10243]=tb(t.addressModeV)),t.addressModeW&&(e[32882]=tb(t.addressModeW)),t.magFilter&&(e[10240]=wP(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=I5(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=Qb("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function tb(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function wP(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function I5(t,e){if(!e)return wP(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}class fl extends cr{constructor(i,r={}){super(i,r);Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"glTarget");Z(this,"glUsage");Z(this,"glIndexType",5123);Z(this,"byteLength");Z(this,"bytesUsed");this.device=i,this.gl=this.device.gl;const o=typeof r=="object"?r.handle:void 0;this.handle=o||this.gl.createBuffer(),i.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=P5(this.props.usage),this.glUsage=R5(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(i,r=0,o=i.byteLength+r){const h=this.glTarget;this.gl.bindBuffer(h,this.handle),this.gl.bufferData(h,o,this.glUsage),this.gl.bufferSubData(h,r,i),this.gl.bindBuffer(h,null),this.bytesUsed=o,this.byteLength=o,this._setDebugData(i,r,o),this.trackAllocatedMemory(o)}_initWithByteLength(i){Yi(i>=0);let r=i;i===0&&(r=new Float32Array(0));const o=this.glTarget;return this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,r,this.glUsage),this.gl.bindBuffer(o,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(null,0,i),this.trackAllocatedMemory(i),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(i,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,i),this.gl.bindBuffer(36663,null),this._setDebugData(i,r,i.byteLength)}async readAsync(i=0,r){return this.readSyncWebGL(i,r)}readSyncWebGL(i=0,r){r=r??this.byteLength-i;const o=new Uint8Array(r),h=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,i,o,h,r),this.gl.bindBuffer(36662,null),this._setDebugData(o,i,r),o}}function P5(t){return t&cr.INDEX?34963:t&cr.VERTEX?34962:t&cr.UNIFORM?35345:34962}function R5(t){return t&cr.INDEX||t&cr.VERTEX?35044:t&cr.UNIFORM?35048:35044}class ev extends bg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");Z(this,"parameters");this.device=i,this.parameters=xP(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(i){for(const[r,o]of Object.entries(i)){const h=Number(r);switch(h){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,h,o);break;default:this.device.gl.samplerParameteri(this.handle,h,o);break}}}}class qh extends mg{constructor(i,r){super(i,{...Fn.defaultProps,...r});Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"texture");this.device=i,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}const C5={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Af=class Af extends Fn{constructor(i,r){var o;super(i,{...C5,format:"rgba8unorm",...r});Z(this,"MAX_ATTRIBUTES");Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"sampler");Z(this,"view");Z(this,"glFormat");Z(this,"type");Z(this,"dataFormat");Z(this,"mipmaps");Z(this,"target");Z(this,"textureUnit");Z(this,"loaded",!1);Z(this,"_video");this.device=i,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=M5(this.props),this.loaded=!1,typeof((o=this.props)==null?void 0:o.data)=="string"&&Object.assign(this.props,{data:U4(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(i){return new qh(this.device,{...i,texture:this})}initialize(i={}){if(this.props.dimension==="cube")return this.initializeCube(i);let r=i.data;if(r instanceof Promise)return r.then(ve=>this.initialize(Object.assign({},i,{pixels:ve,data:ve}))),this;const o=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(o&&r.readyStatethis.initialize(i)),this;const{parameters:h={}}=i,{pixels:d=null,pixelStore:c={},textureUnit:x=void 0,mipmaps:S=!0}=i;r||(r=d);let{width:P,height:M,dataFormat:D,type:H,compressed:Q=!1}=i;const{depth:G=0}=i,_e=vP(i.format);return{width:P,height:M,compressed:Q,dataFormat:D,type:H}=this._deduceParameters({format:i.format,type:H,dataFormat:D,compressed:Q,data:r,width:P,height:M}),this.width=P,this.height=M,this.glFormat=_e,this.type=H,this.dataFormat=D,this.textureUnit=x,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=S,this.setImageData({data:r,width:P,height:M,depth:G,format:_e,type:H,dataFormat:D,parameters:c,compressed:Q}),this.setSampler(i.sampler),this._setSamplerParameters(h),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),S&&this.device.isTextureFormatFilterable(i.format)&&this.generateMipmap(),o&&(this._video={video:r,parameters:h,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(i){const{mipmaps:r=!0,parameters:o={}}=i;return this.setCubeMapImageData(i).then(()=>{this.loaded=!0,r&&this.generateMipmap(i),this.setSampler(i.sampler),this._setSamplerParameters(o)}),this}setSampler(i={}){let r;i instanceof ev?(this.sampler=i,r=i.props):(this.sampler=new ev(this.device,i),r=i);const o=xP(r);return this._setSamplerParameters(o),this}resize(i){const{height:r,width:o,mipmaps:h=!1}=i;return o!==this.width||r!==this.height?this.initialize({width:o,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:h}):this}update(){if(this._video){const{video:i,parameters:r,lastTime:o}=this._video;if(o===i.currentTime||i.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(i){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(i);this.trackDeallocatedMemory("Texture");const{target:r=this.target,pixels:o=null,level:h=0,glFormat:d=this.glFormat,offset:c=0,parameters:x={}}=i;let{data:S=null,type:P=this.type,width:M=this.width,height:D=this.height,dataFormat:H=this.dataFormat,compressed:Q=!1}=i;S||(S=o),{type:P,dataFormat:H,compressed:Q,width:M,height:D}=this._deduceParameters({format:this.props.format,type:P,dataFormat:H,compressed:Q,data:S,width:M,height:D});const{gl:G}=this;G.bindTexture(this.target,this.handle);let _e=null;if({data:S,dataType:_e}=this._getDataType({data:S,compressed:Q}),cl(this.gl,x,()=>{switch(_e){case"null":G.texImage2D(r,h,d,M,D,0,H,P,S);break;case"typed-array":G.texImage2D(r,h,d,M,D,0,H,P,S,c);break;case"buffer":this.device.gl.bindBuffer(35052,S.handle||S),this.device.gl.texImage2D(r,h,d,M,D,0,H,P,c),this.device.gl.bindBuffer(35052,null);break;case"browser-object":G.texImage2D(r,h,d,M,D,0,H,P,S);break;case"compressed":for(const[ve,be]of S.entries())G.compressedTexImage2D(r,ve,be.format,be.width,be.height,0,be.data);break;default:Yi(!1,"Unknown image data type")}}),S&&S.byteLength)this.trackAllocatedMemory(S.byteLength,"Texture");else{const ve=SE(this.props.format);this.trackAllocatedMemory(this.width*this.height*ve,"Texture")}return this.loaded=!0,this}setSubImageData({target:i=this.target,pixels:r=null,data:o=null,x:h=0,y:d=0,width:c=this.width,height:x=this.height,level:S=0,glFormat:P=this.glFormat,type:M=this.type,dataFormat:D=this.dataFormat,compressed:H=!1,offset:Q=0,parameters:G={}}){if({type:M,dataFormat:D,compressed:H,width:c,height:x}=this._deduceParameters({format:this.props.format,type:M,dataFormat:D,compressed:H,data:o,width:c,height:x}),Yi(this.depth===1,"texSubImage not supported for 3D textures"),o||(o=r),o&&o.data){const _e=o;o=_e.data,c=_e.shape[0],x=_e.shape[1]}o instanceof fl&&(o=o.handle),this.gl.bindTexture(this.target,this.handle),cl(this.gl,G,()=>{H?this.gl.compressedTexSubImage2D(i,S,h,d,c,x,P,o):o===null?this.gl.texSubImage2D(i,S,h,d,c,x,D,M,null):ArrayBuffer.isView(o)?this.gl.texSubImage2D(i,S,h,d,c,x,D,M,o,Q):typeof WebGLBuffer<"u"&&o instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,o),this.device.gl.texSubImage2D(i,S,h,d,c,x,D,M,Q),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(i,S,h,d,c,x,D,M,o)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(i={}){return it.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(i=this.textureUnit){const{gl:r}=this;return i!==void 0&&(this.textureUnit=i,r.activeTexture(33984+i)),r.bindTexture(this.target,this.handle),i}unbind(i=this.textureUnit){const{gl:r}=this;return i!==void 0&&(this.textureUnit=i,r.activeTexture(33984+i)),r.bindTexture(this.target,null),i}_getDataType({data:i,compressed:r=!1}){return r?{data:i,dataType:"compressed"}:i===null?{data:i,dataType:"null"}:ArrayBuffer.isView(i)?{data:i,dataType:"typed-array"}:i instanceof fl?{data:i.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?{data:i,dataType:"buffer"}:{data:i,dataType:"browser-object"}}_deduceParameters(i){const{format:r,data:o}=i;let{width:h,height:d,dataFormat:c,type:x,compressed:S}=i;const P=kg(r);return c=c||P.dataFormat,x=x||P.type,S=S||P.compressed,{width:h,height:d}=this._deduceImageSize(o,h,d),{dataFormat:c,type:x,compressed:S,width:h,height:d,format:r,data:o}}_deduceImageSize(i,r,o){let h;return typeof ImageData<"u"&&i instanceof ImageData?h={width:i.width,height:i.height}:typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement?h={width:i.naturalWidth,height:i.naturalHeight}:typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement?h={width:i.width,height:i.height}:typeof ImageBitmap<"u"&&i instanceof ImageBitmap?h={width:i.width,height:i.height}:typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?h={width:i.videoWidth,height:i.videoHeight}:i?h={width:r,height:o}:h={width:r>=0?r:1,height:o>=0?o:1},Yi(h,"Could not deduced texture size"),Yi(r===void 0||h.width===r,"Deduced texture width does not match supplied width"),Yi(o===void 0||h.height===o,"Deduced texture height does not match supplied height"),h}async setCubeMapImageData(i){const{gl:r}=this,{width:o,height:h,pixels:d,data:c,format:x=6408,type:S=5121}=i,P=d||c,M=await Promise.all(Af.FACES.map(D=>{const H=P[D];return Promise.all(Array.isArray(H)?H:[H])}));this.bind(),Af.FACES.forEach((D,H)=>{M[H].length>1&&this.props.mipmaps!==!1&&it.warn(`${this.id} has mipmap and multiple LODs.`)(),M[H].forEach((Q,G)=>{o&&h?r.texImage2D(D,G,x,o,h,0,x,S,Q):r.texImage2D(D,G,x,x,S,Q)})}),this.unbind()}setImageDataForFace(i){const{face:r,width:o,height:h,pixels:d,data:c,format:x=6408,type:S=5121}=i,{gl:P}=this,M=d||c;return this.bind(),M instanceof Promise?M.then(D=>this.setImageDataForFace(Object.assign({},i,{face:r,data:D,pixels:D}))):this.width||this.height?P.texImage2D(r,0,x,o,h,0,x,S,M):P.texImage2D(r,0,x,x,S,M),this}setImageData3D(i){const{level:r=0,dataFormat:o,format:h,type:d,width:c,height:x,depth:S=1,offset:P=0,data:M,parameters:D={}}=i;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const H=kg(h);if(cl(this.gl,D,()=>{ArrayBuffer.isView(M)&&this.gl.texImage3D(this.target,r,H.format,c,x,S,0,H.dataFormat,H.type,M),M instanceof fl&&(this.gl.bindBuffer(35052,M.handle),this.gl.texImage3D(this.target,r,o,c,x,S,0,h,d,P))}),M&&M.byteLength)this.trackAllocatedMemory(M.byteLength,"Texture");else{const Q=SE(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*Q,"Texture")}return this.loaded=!0,this}_setSamplerParameters(i){if(!gg(i)){k5(i),this.gl.bindTexture(this.target,this.handle);for(const[r,o]of Object.entries(i)){const h=Number(r),d=o;switch(h){case 33082:case 33083:this.gl.texParameterf(this.target,h,d);break;default:this.gl.texParameteri(this.target,h,d);break}}this.gl.bindTexture(this.target,null)}}};Z(Af,"FACES",[34069,34070,34071,34072,34073,34074]);let Mo=Af;function M5(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function k5(t){it.log(1,"texture sampler parameters",t)()}class bf extends vg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"gl");Z(this,"handle");const o=r.handle===null;if(this.device=i,this.gl=i.gl,this.handle=this.props.handle||o?this.props.handle:this.gl.createFramebuffer(),!o){i.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const h=this.gl.bindFramebuffer(36160,this.handle);for(let d=0;dit.info("Spector capture started:",e)()),Fi==null||Fi.onCapture.add(e=>{it.info("Spector capture complete:",e)(),Fi==null||Fi.getResultUI(),Fi==null||Fi.resultView.display(),Fi==null||Fi.resultView.addCapture(e)})),t!=null&&t.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return Fi;Fi==null||Fi.startCapture(t==null?void 0:t.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{it.info("Spector capture stopped after 2 seconds")(),Fi==null||Fi.stopCapture()})}return Fi}const V5="https://unpkg.com/webgl-debug@2.0.1/index.js";function TP(t){return t.luma=t.luma||{},t.luma}async function j5(){El()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await BI(V5))}function $5(t,e={}){return t?e.debug?H5(t,e):W5(t):null}function W5(t){const e=TP(t);return e.realContext?e.realContext:t}function H5(t,e){if(!globalThis.WebGLDebugUtils)return it.warn("webgl-debug not loaded")(),t;const i=TP(t);if(i.debugContext)return i.debugContext;globalThis.WebGLDebugUtils.init({...Wh,...t});const r=globalThis.WebGLDebugUtils.makeDebugContext(t,X5.bind(null,e),q5.bind(null,e));for(const d in Wh)!(d in r)&&typeof Wh[d]=="number"&&(r[d]=Wh[d]);class o{}Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Object.setPrototypeOf(o,r);const h=Object.create(o);return i.realContext=t,i.debugContext=h,h.debug=!0,h}function ib(t,e){e=Array.from(e).map(r=>r===void 0?"undefined":r);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${t}(${i})`}function X5(t,e,i,r){r=Array.from(r).map(c=>c===void 0?"undefined":c);const o=globalThis.WebGLDebugUtils.glEnumToString(e),h=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,r),d=`${o} in gl.${i}(${h})`;it.error(d)();debugger;if(t.throwOnError)throw new Error(d)}function q5(t,e,i){let r="";if(it.level>=1&&(r=ib(e,i),it.log(1,r)()),t.break&&t.break.length>0&&(r=r||ib(e,i),t.break.every(h=>r.indexOf(h)!==-1)))debugger;for(const o of i)if(o===void 0){if(r=r||ib(e,i),t.throwOnError)throw new Error(`Undefined argument: ${r}`);it.error(`Undefined argument: ${r}`)();debugger}}function Z5(t){const e=t.split(/\r?\n/),i=[];for(const r of e){if(r.length<=1)continue;const o=r.split(":");if(o.length===2){const[M,D]=o;i.push({message:D.trim(),type:PE(M),lineNum:0,linePos:0});continue}const[h,d,c,...x]=o;let S=parseInt(c,10);isNaN(S)&&(S=0);let P=parseInt(d,10);isNaN(P)&&(P=0),i.push({message:x.join(":").trim(),type:PE(h),lineNum:S,linePos:P})}return i}function PE(t){const e=["warning","error","info"],i=t.toLowerCase();return e.includes(i)?i:"info"}class Y5 extends yg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");switch(this.device=i,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const i=this.device.gl.getShaderInfoLog(this.handle);return Z5(i)}getTranslatedSource(){const r=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return r==null?void 0:r.getTranslatedShaderSource(this.handle)}async _compile(i){i=(h=>h.startsWith("#version ")?h:`#version 100
+ `}}},gL=[ix],mL=["vs:DECKGL_FILTER_SIZE(inout vec3 size, VertexGeometry geometry)","vs:DECKGL_FILTER_GL_POSITION(inout vec4 position, VertexGeometry geometry)","vs:DECKGL_FILTER_COLOR(inout vec4 color, VertexGeometry geometry)","fs:DECKGL_FILTER_COLOR(inout vec4 color, FragmentGeometry geometry)"];function yL(){const t=_g.getDefaultShaderAssembler();for(const e of gL)t.addDefaultModule(e);for(const e of mL)t.addShaderHook(e);return t}const bL=[255,255,255],vL=1;let xL=0;class wL{constructor(e={}){this.type="ambient";const{color:i=bL}=e,{intensity:r=vL}=e;this.id=e.id||`ambient-${xL++}`,this.color=i,this.intensity=r}}const TL=[255,255,255],SL=1,EL=[0,0,-1];let AL=0;class nE{constructor(e={}){this.type="directional";const{color:i=TL}=e,{intensity:r=SL}=e,{direction:o=EL}=e,{_shadow:h=!1}=e;this.id=e.id||`directional-${AL++}`,this.color=i,this.intensity=r,this.type="directional",this.direction=new Fo(o).normalize().toArray(),this.shadow=h}getProjectedLight(e){return this}}class IL{constructor(e,i={id:"pass"}){const{id:r}=i;this.id=r,this.device=e,this.props={...i}}setProps(e){Object.assign(this.props,e)}render(e){}cleanup(){}}class nx extends IL{constructor(){super(...arguments),this._lastRenderIndex=-1}render(e){const[i,r]=this.device.canvasContext.getDrawingBufferSize(),o=e.clearCanvas??!0,h=e.clearColor??(o?[0,0,0,0]:!1),d=o?1:!1,c=o?0:!1,x=e.colorMask??15,S={viewport:[0,0,i,r]};e.colorMask&&(S.colorMask=x),e.scissorRect&&(S.scissorRect=e.scissorRect);const P=this.device.beginRenderPass({framebuffer:e.target,parameters:S,clearColor:h,clearDepth:d,clearStencil:c});try{return this._drawLayers(P,e)}finally{P.end()}}_drawLayers(e,i){const{target:r,moduleParameters:o,viewports:h,views:d,onViewportActive:c,clearStack:x=!0}=i;i.pass=i.pass||"unknown",x&&(this._lastRenderIndex=-1);const S=[];for(const P of h){const M=d&&d[P.id];c==null||c(P);const D=this._getDrawLayerParams(P,i),H=P.subViewports||[P];for(const Q of H){const G=this._drawLayersInViewport(e,{target:r,moduleParameters:o,viewport:Q,view:M,pass:i.pass,layers:i.layers},D);S.push(G)}}return S}_getDrawLayerParams(e,{layers:i,pass:r,isPicking:o=!1,layerFilter:h,cullRect:d,effects:c,moduleParameters:x},S=!1){var Q;const P=[],M=aP(this._lastRenderIndex+1),D={layer:i[0],viewport:e,isPicking:o,renderPass:r,cullRect:d},H={};for(let G=0;Gthis.device.clearWebGL(M))}const P={totalCount:i.length,visibleCount:0,compositeCount:0,pickableCount:0};e.setParameters({viewport:S});for(let M=0;M{const d=o.props._offset,c=o.id,x=o.parent&&o.parent.id;let S;if(x&&!(x in e)&&r(o.parent,!1),x in i){const P=i[x]=i[x]||aP(e[x],e);S=P(o,h),i[c]=P}else Number.isFinite(d)?(S=d+(e[x]||0),i[c]=null):S=t;return h&&S>=t&&(t=S+1),e[c]=S,S};return r}function PL(t,{moduleParameters:e,target:i,viewport:r}){const o=e&&e.devicePixelRatio||t.canvasContext.cssToDeviceRatio(),[,h]=t.canvasContext.getDrawingBufferSize(),d=i?i.height:h,c=r;return[c.x*o,d-(c.y+c.height)*o,c.width*o,c.height*o]}class RL extends nx{constructor(e,i){super(e,i),this.shadowMap=e.createTexture({width:1,height:1,sampler:{minFilter:"linear",magFilter:"linear",addressModeU:"clamp-to-edge",addressModeV:"clamp-to-edge"}}),this.depthBuffer=e.createTexture({format:"depth16unorm",width:1,height:1,mipmaps:!1,dataFormat:6402,type:5125}),this.fbo=e.createFramebuffer({id:"shadowmap",width:1,height:1,colorAttachments:[this.shadowMap],depthStencilAttachment:this.depthBuffer})}render(e){const i=this.fbo,r=this.device.canvasContext.cssToDeviceRatio(),o=e.viewports[0],h=o.width*r,d=o.height*r,c=[1,1,1,1];(h!==i.width||d!==i.height)&&i.resize({width:h,height:d}),super.render({...e,clearColor:c,target:i,pass:"shadow"})}getLayerParameters(e,i,r){return{...e.props.parameters,blend:!1,depthRange:[0,1],depthTest:!0}}shouldDrawLayer(e){return e.props.shadowEnabled!==!1}getModuleParameters(){return{drawToShadowMap:!0}}delete(){this.fbo&&(this.fbo.destroy(),this.fbo=null),this.shadowMap&&(this.shadowMap.destroy(),this.shadowMap=null),this.depthBuffer&&(this.depthBuffer.destroy(),this.depthBuffer=null)}}const CL={color:[255,255,255],intensity:1},oE=[{color:[255,255,255],intensity:1,direction:[-1,3,-1]},{color:[255,255,255],intensity:.9,direction:[1,-8,-2.5]}],ML=[0,0,0,200/255];class lP{constructor(e={}){this.id="lighting-effect",this.shadowColor=ML,this.shadow=!1,this.ambientLight=null,this.directionalLights=[],this.pointLights=[],this.shadowPasses=[],this.shadowMaps=[],this.dummyShadowMap=null,this.setProps(e)}setup(e){this.context=e;const{device:i,deck:r}=e;this.shadow&&!this.dummyShadowMap&&(this._createShadowPasses(i),r._addDefaultShaderModule(sE),this.dummyShadowMap=i.createTexture({width:1,height:1}))}setProps(e){this.ambientLight=null,this.directionalLights=[],this.pointLights=[];for(const i in e){const r=e[i];switch(r.type){case"ambient":this.ambientLight=r;break;case"directional":this.directionalLights.push(r);break;case"point":this.pointLights.push(r);break}}this._applyDefaultLights(),this.shadow=this.directionalLights.some(i=>i.shadow),this.context&&this.setup(this.context),this.props=e}preRender({layers:e,layerFilter:i,viewports:r,onViewportActive:o,views:h}){if(this.shadow){this.shadowMatrices=this._calculateMatrices();for(let d=0;dr.getProjectedLight({layer:e})),pointLights:this.pointLights.map(r=>r.getProjectedLight({layer:e}))},i}cleanup(e){for(const i of this.shadowPasses)i.delete();this.shadowPasses.length=0,this.shadowMaps.length=0,this.dummyShadowMap&&(this.dummyShadowMap.destroy(),this.dummyShadowMap=null,e.deck._removeDefaultShaderModule(sE))}_calculateMatrices(){const e=[];for(const i of this.directionalLights){const r=new No().lookAt({eye:new Fo(i.direction).negate()});e.push(r)}return e}_createShadowPasses(e){for(let i=0;io&&(h=o);const d=this._pool,c=e.BYTES_PER_ELEMENT*h,x=d.findIndex(S=>S.byteLength>=c);if(x>=0){const S=new e(d.splice(x,1)[0],0,h);return r&&S.fill(0),S}return new e(h)}_release(e){if(!ArrayBuffer.isView(e))return;const i=this._pool,{buffer:r}=e,{byteLength:o}=r,h=i.findIndex(d=>d.byteLength>=o);h<0?i.push(r):(h>0||i.lengththis.opts.poolSize&&i.shift()}}const Ff=new kL;function hf(){return[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]}function DL(t){return[t[12],t[13],t[14]]}function OL(t){return{left:Bh(t[3]+t[0],t[7]+t[4],t[11]+t[8],t[15]+t[12]),right:Bh(t[3]-t[0],t[7]-t[4],t[11]-t[8],t[15]-t[12]),bottom:Bh(t[3]+t[1],t[7]+t[5],t[11]+t[9],t[15]+t[13]),top:Bh(t[3]-t[1],t[7]-t[5],t[11]-t[9],t[15]-t[13]),near:Bh(t[3]+t[2],t[7]+t[6],t[11]+t[10],t[15]+t[14]),far:Bh(t[3]-t[2],t[7]-t[6],t[11]-t[10],t[15]-t[14])}}const aE=new Fo;function Bh(t,e,i,r){aE.set(t,e,i);const o=aE.len();return{distance:r/o,normal:new Fo(-t/o,-e/o,-i/o)}}function FL(t){return t-Math.fround(t)}let Gd;function H0(t,e){const{size:i=1,startIndex:r=0}=e,o=e.endIndex!==void 0?e.endIndex:t.length,h=(o-r)/i;Gd=Ff.allocate(Gd,h,{type:Float32Array,size:i*2});let d=r,c=0;for(;d=i.delay+i.duration*i.repeat}getTime(e){if(e===void 0)return this.time;const i=this.channels.get(e);return i===void 0?-1:i.time}setTime(e){this.time=Math.max(0,e);const i=this.channels.values();for(const o of i)this._setChannelTime(o,this.time);const r=this.animations.values();for(const o of r){const{animation:h,channel:d}=o;h.setTime(this.getTime(d))}}play(){this.playing=!0}pause(){this.playing=!1,this.lastEngineTime=-1}reset(){this.setTime(0)}attachAnimation(e,i){const r=WL++;return this.animations.set(r,{animation:e,channel:i}),e.setTime(this.getTime(i)),r}detachAnimation(e){this.animations.delete(e)}update(e){this.playing&&(this.lastEngineTime===-1&&(this.lastEngineTime=e),this.setTime(this.time+(e-this.lastEngineTime)),this.lastEngineTime=e)}_setChannelTime(e,i){const r=i-e.delay,o=e.duration*e.repeat;r>=o?e.time=e.duration*e.rate:(e.time=Math.max(0,r)%e.duration,e.time*=e.rate)}}let HL=0;const XL={device:null,onAddHTML:()=>"",onInitialize:async()=>null,onRender:()=>{},onFinalize:()=>{},onError:t=>console.error(t),stats:iu.stats.get(`animation-loop-${HL++}`),useDevicePixels:!0,autoResizeViewport:!1,autoResizeDrawingBuffer:!1};class qL{constructor(e){Z(this,"device",null);Z(this,"canvas",null);Z(this,"props");Z(this,"animationProps",null);Z(this,"timeline",null);Z(this,"stats");Z(this,"cpuTime");Z(this,"gpuTime");Z(this,"frameRate");Z(this,"display");Z(this,"needsRedraw","initialized");Z(this,"_initialized",!1);Z(this,"_running",!1);Z(this,"_animationFrameId",null);Z(this,"_nextFramePromise",null);Z(this,"_resolveNextFrame",null);Z(this,"_cpuStartTime",0);if(this.props={...XL,...e},e=this.props,!e.device)throw new Error("No device provided");const{useDevicePixels:i=!0}=this.props;this.stats=e.stats||new Tm({id:"animation-loop-stats"}),this.cpuTime=this.stats.get("CPU Time"),this.gpuTime=this.stats.get("GPU Time"),this.frameRate=this.stats.get("Frame Rate"),this.setProps({autoResizeViewport:e.autoResizeViewport,autoResizeDrawingBuffer:e.autoResizeDrawingBuffer,useDevicePixels:i}),this.start=this.start.bind(this),this.stop=this.stop.bind(this),this._onMousemove=this._onMousemove.bind(this),this._onMouseleave=this._onMouseleave.bind(this)}destroy(){this.stop(),this._setDisplay(null)}delete(){this.destroy()}setNeedsRedraw(e){return this.needsRedraw=this.needsRedraw||e,this}setProps(e){return"autoResizeViewport"in e&&(this.props.autoResizeViewport=e.autoResizeViewport||!1),"autoResizeDrawingBuffer"in e&&(this.props.autoResizeDrawingBuffer=e.autoResizeDrawingBuffer||!1),"useDevicePixels"in e&&(this.props.useDevicePixels=e.useDevicePixels||!1),this}async start(){if(this._running)return this;this._running=!0;try{let e;return this._initialized||(this._initialized=!0,await this._initDevice(),this._initialize(),await this.props.onInitialize(this._getAnimationProps())),this._running?(e!==!1&&(this._cancelAnimationFrame(),this._requestAnimationFrame()),this):null}catch(e){const i=e instanceof Error?e:new Error("Unknown error");throw this.props.onError(i),i}}stop(){return this._running&&(this.animationProps&&this.props.onFinalize(this.animationProps),this._cancelAnimationFrame(),this._nextFramePromise=null,this._resolveNextFrame=null,this._running=!1),this}redraw(){var e;return(e=this.device)!=null&&e.isLost?this:(this._beginFrameTimers(),this._setupFrame(),this._updateAnimationProps(),this._renderFrame(this._getAnimationProps()),this._clearNeedsRedraw(),this._resolveNextFrame&&(this._resolveNextFrame(this),this._nextFramePromise=null,this._resolveNextFrame=null),this._endFrameTimers(),this)}attachTimeline(e){return this.timeline=e,this.timeline}detachTimeline(){this.timeline=null}waitForRender(){return this.setNeedsRedraw("waitForRender"),this._nextFramePromise||(this._nextFramePromise=new Promise(e=>{this._resolveNextFrame=e})),this._nextFramePromise}async toDataURL(){if(this.setNeedsRedraw("toDataURL"),await this.waitForRender(),this.canvas instanceof HTMLCanvasElement)return this.canvas.toDataURL();throw new Error("OffscreenCanvas")}_initialize(){this._startEventHandling(),this._initializeAnimationProps(),this._updateAnimationProps(),this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_setDisplay(e){this.display&&(this.display.destroy(),this.display.animationLoop=null),e&&(e.animationLoop=this),this.display=e}_requestAnimationFrame(){this._running&&(this._animationFrameId=V4(this._animationFrame.bind(this)))}_cancelAnimationFrame(){this._animationFrameId!==null&&(j4(this._animationFrameId),this._animationFrameId=null)}_animationFrame(){this._running&&(this.redraw(),this._requestAnimationFrame())}_renderFrame(e){if(this.display){this.display._renderFrame(e);return}this.props.onRender(this._getAnimationProps()),this.device.submit()}_clearNeedsRedraw(){this.needsRedraw=!1}_setupFrame(){this._resizeCanvasDrawingBuffer(),this._resizeViewport()}_initializeAnimationProps(){var e,i;if(!this.device)throw new Error("loop");this.animationProps={animationLoop:this,device:this.device,canvas:(i=(e=this.device)==null?void 0:e.canvasContext)==null?void 0:i.canvas,timeline:this.timeline,useDevicePixels:this.props.useDevicePixels,needsRedraw:!1,width:1,height:1,aspect:1,time:0,startTime:Date.now(),engineTime:0,tick:0,tock:0,_mousePosition:null}}_getAnimationProps(){if(!this.animationProps)throw new Error("animationProps");return this.animationProps}_updateAnimationProps(){if(!this.animationProps)return;const{width:e,height:i,aspect:r}=this._getSizeAndAspect();(e!==this.animationProps.width||i!==this.animationProps.height)&&this.setNeedsRedraw("drawing buffer resized"),r!==this.animationProps.aspect&&this.setNeedsRedraw("drawing buffer aspect changed"),this.animationProps.width=e,this.animationProps.height=i,this.animationProps.aspect=r,this.animationProps.needsRedraw=this.needsRedraw,this.animationProps.engineTime=Date.now()-this.animationProps.startTime,this.timeline&&this.timeline.update(this.animationProps.engineTime),this.animationProps.tick=Math.floor(this.animationProps.time/1e3*60),this.animationProps.tock++,this.animationProps.time=this.timeline?this.timeline.getTime():this.animationProps.engineTime}async _initDevice(){var e;if(this.device=await this.props.device,!this.device)throw new Error("No device provided");this.canvas=((e=this.device.canvasContext)==null?void 0:e.canvas)||null}_createInfoDiv(){if(this.canvas&&this.props.onAddHTML){const e=document.createElement("div");document.body.appendChild(e),e.style.position="relative";const i=document.createElement("div");i.style.position="absolute",i.style.left="10px",i.style.bottom="10px",i.style.width="300px",i.style.background="white",this.canvas instanceof HTMLCanvasElement&&e.appendChild(this.canvas),e.appendChild(i);const r=this.props.onAddHTML(i);r&&(i.innerHTML=r)}}_getSizeAndAspect(){var h,d,c,x;if(!this.device)return{width:1,height:1,aspect:1};const[e,i]=((d=(h=this.device)==null?void 0:h.canvasContext)==null?void 0:d.getPixelSize())||[1,1];let r=1;const o=(x=(c=this.device)==null?void 0:c.canvasContext)==null?void 0:x.canvas;return o&&o.clientHeight?r=o.clientWidth/o.clientHeight:e>0&&i>0&&(r=e/i),{width:e,height:i,aspect:r}}_resizeViewport(){this.props.autoResizeViewport&&this.device.gl&&this.device.gl.viewport(0,0,this.device.gl.drawingBufferWidth,this.device.gl.drawingBufferHeight)}_resizeCanvasDrawingBuffer(){var e,i;this.props.autoResizeDrawingBuffer&&((i=(e=this.device)==null?void 0:e.canvasContext)==null||i.resize({useDevicePixels:this.props.useDevicePixels}))}_beginFrameTimers(){this.frameRate.timeEnd(),this.frameRate.timeStart(),this.cpuTime.timeStart()}_endFrameTimers(){this.cpuTime.timeEnd()}_startEventHandling(){this.canvas&&(this.canvas.addEventListener("mousemove",this._onMousemove.bind(this)),this.canvas.addEventListener("mouseleave",this._onMouseleave.bind(this)))}_onMousemove(e){e instanceof MouseEvent&&(this._getAnimationProps()._mousePosition=[e.offsetX,e.offsetY])}_onMouseleave(e){this._getAnimationProps()._mousePosition=null}}class hE{constructor(e){Z(this,"id");Z(this,"userData",{});Z(this,"topology");Z(this,"bufferLayout",[]);Z(this,"vertexCount");Z(this,"indices");Z(this,"attributes");this.id=e.id||Nc("geometry"),this.topology=e.topology,this.indices=e.indices||null,this.attributes=e.attributes,this.vertexCount=e.vertexCount,this.bufferLayout=e.bufferLayout||[],this.indices&&Yi(this.indices.usage===cr.INDEX)}destroy(){var e;(e=this.indices)==null||e.destroy();for(const i of Object.values(this.attributes))i.destroy()}getVertexCount(){return this.vertexCount}getAttributes(){return this.attributes}getIndexes(){return this.indices}_calculateVertexCount(e){return e.byteLength/12}}function ZL(t,e){if(e instanceof hE)return e;const i=YL(t,e),{attributes:r,bufferLayout:o}=KL(t,e);return new hE({topology:e.topology||"triangle-list",bufferLayout:o,vertexCount:e.vertexCount,indices:i,attributes:r})}function YL(t,e){if(!e.indices)return;const i=e.indices.value;return t.createBuffer({usage:cr.INDEX,data:i})}function KL(t,e){const i=[],r={};for(const[h,d]of Object.entries(e.attributes)){let c=h;switch(h){case"POSITION":c="positions";break;case"NORMAL":c="normals";break;case"TEXCOORD_0":c="texCoords";break;case"COLOR_0":c="colors";break}r[c]=t.createBuffer({data:d.value,id:`${h}-buffer`});const{value:x,size:S,normalized:P}=d;i.push({name:c,format:N4(x,S,P)})}const o=e._calculateVertexCount(e.attributes,e.indices);return{attributes:r,bufferLayout:i,vertexCount:o}}class JL{constructor(e){Z(this,"modules");Z(this,"moduleUniforms");Z(this,"moduleBindings");Z(this,"moduleUniformsChanged");const i=Em(Object.values(e).filter(r=>r.dependencies));for(const r of i)e[r.name]=r;it.log(1,"Creating ShaderInputs with modules",Object.keys(e))(),this.modules=e,this.moduleUniforms={},this.moduleBindings={};for(const[r,o]of Object.entries(e)){const h=r;this.moduleUniforms[h]=o.defaultUniforms||{},this.moduleBindings[h]={}}}destroy(){}setProps(e){var i;for(const r of Object.keys(e)){const o=r,h=e[o],d=this.modules[o];if(!d){it.warn(`Module ${r} not found`)();continue}const c=this.moduleUniforms[o],x=this.moduleBindings[o],S=((i=d.getUniforms)==null?void 0:i.call(d,h,c))||h,{uniforms:P,bindings:M}=ex(S);this.moduleUniforms[o]={...c,...P},this.moduleBindings[o]={...x,...M}}}getModules(){return Object.values(this.modules)}getUniformValues(){return this.moduleUniforms}getBindings(){const e={};for(const i of Object.values(this.moduleBindings))Object.assign(e,i);return e}getDebugTable(){var i;const e={};for(const[r,o]of Object.entries(this.moduleUniforms))for(const[h,d]of Object.entries(o))e[`${r}.${h}`]={type:(i=this.modules[r].uniformTypes)==null?void 0:i[h],value:String(d)};return e}}const rm=class rm{constructor(e){Z(this,"device");Z(this,"_hashCounter",0);Z(this,"_hashes",{});Z(this,"_renderPipelineCache",{});Z(this,"_computePipelineCache",{});this.device=e}static getDefaultPipelineFactory(e){return e._lumaData.defaultPipelineFactory=e._lumaData.defaultPipelineFactory||new rm(e),e._lumaData.defaultPipelineFactory}createRenderPipeline(e){const i={...hu.defaultProps,...e},r=this._hashRenderPipeline(i);if(!this._renderPipelineCache[r]){const o=this.device.createRenderPipeline({...i,id:i.id?`${i.id}-cached`:void 0});o.hash=r,this._renderPipelineCache[r]={pipeline:o,useCount:0}}return this._renderPipelineCache[r].useCount++,this._renderPipelineCache[r].pipeline}createComputePipeline(e){const i={...xg.defaultProps,...e},r=this._hashComputePipeline(i);if(!this._computePipelineCache[r]){const o=this.device.createComputePipeline({...i,id:i.id?`${i.id}-cached`:void 0});o.hash=r,this._computePipelineCache[r]={pipeline:o,useCount:0}}return this._computePipelineCache[r].useCount++,this._computePipelineCache[r].pipeline}release(e){const i=e.hash,r=e instanceof xg?this._computePipelineCache:this._renderPipelineCache;r[i].useCount--,r[i].useCount===0&&(r[i].pipeline.destroy(),delete r[i])}_hashComputePipeline(e){return`${this._getHash(e.shader.source)}`}_hashRenderPipeline(e){const i=this._getHash(e.vs.source),r=e.fs?this._getHash(e.fs.source):0,o="-",h=this._getHash(JSON.stringify(e.bufferLayout));switch(this.device.type){case"webgl":return`${i}/${r}V${o}BL${h}`;default:const d=this._getHash(JSON.stringify(e.parameters));return`${i}/${r}V${o}T${e.topology}P${d}BL${h}`}}_getHash(e){return this._hashes[e]===void 0&&(this._hashes[e]=this._hashCounter++),this._hashes[e]}};Z(rm,"defaultProps",{...hu.defaultProps});let Kb=rm;const sm=class sm{constructor(e){Z(this,"device");Z(this,"_cache",{});this.device=e}static getDefaultShaderFactory(e){var i;return(i=e._lumaData).defaultShaderFactory||(i.defaultShaderFactory=new sm(e)),e._lumaData.defaultShaderFactory}createShader(e){const i=this._hashShader(e);let r=this._cache[i];if(!r){const o=this.device.createShader({...e,id:e.id?`${e.id}-cached`:void 0});this._cache[i]=r={shader:o,useCount:0}}return r.useCount++,r.shader}release(e){const i=this._hashShader(e),r=this._cache[i];r&&(r.useCount--,r.useCount===0&&(delete this._cache[i],r.shader.destroy()))}_hashShader(e){return`${e.stage}:${e.source}`}};Z(sm,"defaultProps",{...yg.defaultProps});let Jb=sm;function GL(t,e){var o;const i={},r="Values";if(t.attributes.length===0&&!((o=t.varyings)!=null&&o.length))return{"No attributes or varyings":{[r]:"N/A"}};for(const h of t.attributes)if(h){const d=`${h.location} ${h.name}: ${h.type}`;i[`in ${d}`]={[r]:h.stepMode||"vertex"}}for(const h of t.varyings||[]){const d=`${h.location} ${h.name}`;i[`out ${d}`]={[r]:JSON.stringify(h.accessor)}}return i}let Zr=null,q0=null;function QL(t,{id:e,minimap:i,opaque:r,top:o="0",left:h="0",rgbaScale:d=1}){Zr||(Zr=document.createElement("canvas"),Zr.id=e,Zr.title=e,Zr.style.zIndex="100",Zr.style.position="absolute",Zr.style.top=o,Zr.style.left=h,Zr.style.border="blue 1px solid",Zr.style.transform="scaleY(-1)",document.body.appendChild(Zr),q0=Zr.getContext("2d")),(Zr.width!==t.width||Zr.height!==t.height)&&(Zr.width=t.width/2,Zr.height=t.height/2,Zr.style.width="400px",Zr.style.height="400px");const c=t.device.readPixelsToArrayWebGL(t),x=q0.createImageData(t.width,t.height),S=0;for(let P=0;P[M.name,M]))||[]);this.setShaderInputs(i.shaderInputs||new JL(r));const o=tU(e),h=(((x=this.props.modules)==null?void 0:x.length)>0?this.props.modules:(S=this.shaderInputs)==null?void 0:S.getModules())||[];if(this.device.type==="webgpu"&&this.props.source){(P=this.props).shaderLayout||(P.shaderLayout=E6(this.props.source));const{source:M,getUniforms:D}=this.props.shaderAssembler.assembleShader({platformInfo:o,...this.props,modules:h});this.source=M,this._getModuleUniforms=D}else{const{vs:M,fs:D,getUniforms:H}=this.props.shaderAssembler.assembleShaderPair({platformInfo:o,...this.props,modules:h});this.vs=M,this.fs=D,this._getModuleUniforms=H}this.vertexCount=this.props.vertexCount,this.instanceCount=this.props.instanceCount,this.topology=this.props.topology,this.bufferLayout=this.props.bufferLayout,this.parameters=this.props.parameters,i.geometry&&this.setGeometry(i.geometry),this.pipelineFactory=i.pipelineFactory||Kb.getDefaultPipelineFactory(this.device),this.shaderFactory=i.shaderFactory||Jb.getDefaultShaderFactory(this.device),this.pipeline=this._updatePipeline(),this.vertexArray=e.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry),"isInstanced"in i&&(this.isInstanced=i.isInstanced),i.instanceCount&&this.setInstanceCount(i.instanceCount),i.vertexCount&&this.setVertexCount(i.vertexCount),i.indexBuffer&&this.setIndexBuffer(i.indexBuffer),i.attributes&&this.setAttributes(i.attributes),i.constantAttributes&&this.setConstantAttributes(i.constantAttributes),i.bindings&&this.setBindings(i.bindings),i.uniforms&&this.setUniforms(i.uniforms),i.moduleSettings&&this.updateModuleSettings(i.moduleSettings),i.transformFeedback&&(this.transformFeedback=i.transformFeedback),Object.seal(this)}destroy(){var e;this._destroyed||(this.pipelineFactory.release(this.pipeline),this.shaderFactory.release(this.pipeline.vs),this.pipeline.fs&&this.shaderFactory.release(this.pipeline.fs),this._uniformStore.destroy(),(e=this._gpuGeometry)==null||e.destroy(),this._destroyed=!0)}needsRedraw(){this._getBindingsUpdateTimestamp()>this._lastDrawTimestamp&&this.setNeedsRedraw("contents of bound textures or buffers updated");const e=this._needsRedraw;return this._needsRedraw=!1,e}setNeedsRedraw(e){this._needsRedraw||(this._needsRedraw=e)}predraw(){this.updateShaderInputs(),this.pipeline=this._updatePipeline()}draw(e){this.predraw();let i;try{this._logDrawCallStart(),this.pipeline=this._updatePipeline(),this.pipeline.setBindings(this.bindings,{disableWarnings:this.props.disableWarnings}),gg(this.uniforms)||this.pipeline.setUniformsWebGL(this.uniforms);const{indexBuffer:r}=this.vertexArray,o=r?r.byteLength/(r.indexType==="uint32"?4:2):void 0;i=this.pipeline.draw({renderPass:e,vertexArray:this.vertexArray,isInstanced:this.isInstanced,vertexCount:this.vertexCount,instanceCount:this.instanceCount,indexCount:o,transformFeedback:this.transformFeedback||void 0,parameters:this.parameters,topology:this.topology})}finally{this._logDrawCallEnd()}return this._logFramebuffer(e),i?(this._lastDrawTimestamp=this.device.timestamp,this._needsRedraw=!1):this._needsRedraw="waiting for resource initialization",i}setGeometry(e){var r;(r=this._gpuGeometry)==null||r.destroy();const i=e&&ZL(this.device,e);i&&(this.setTopology(i.topology||"triangle-list"),this.bufferLayout=uE(i.bufferLayout,this.bufferLayout),this.vertexArray&&this._setGeometryAttributes(i)),this._gpuGeometry=i}setTopology(e){e!==this.topology&&(this.topology=e,this._setPipelineNeedsUpdate("topology"))}setBufferLayout(e){this.bufferLayout=this._gpuGeometry?uE(e,this._gpuGeometry.bufferLayout):e,this._setPipelineNeedsUpdate("bufferLayout"),this.pipeline=this._updatePipeline(),this.vertexArray=this.device.createVertexArray({renderPipeline:this.pipeline}),this._gpuGeometry&&this._setGeometryAttributes(this._gpuGeometry)}setParameters(e){Ub(e,this.parameters,2)||(this.parameters=e,this._setPipelineNeedsUpdate("parameters"))}setInstanceCount(e){this.instanceCount=e,this.isInstanced===void 0&&e>0&&(this.isInstanced=!0),this.setNeedsRedraw("instanceCount")}setVertexCount(e){this.vertexCount=e,this.setNeedsRedraw("vertexCount")}setShaderInputs(e){this.shaderInputs=e,this._uniformStore=new F4(this.shaderInputs.modules);for(const i of Object.keys(this.shaderInputs.modules)){const r=this._uniformStore.getManagedUniformBuffer(this.device,i);this.bindings[`${i}Uniforms`]=r}this.setNeedsRedraw("shaderInputs")}updateShaderInputs(){this._uniformStore.setUniforms(this.shaderInputs.getUniformValues()),this.setBindings(this.shaderInputs.getBindings()),this.setNeedsRedraw("shaderInputs")}setBindings(e){Object.assign(this.bindings,e),this.setNeedsRedraw("bindings")}setTransformFeedback(e){this.transformFeedback=e,this.setNeedsRedraw("transformFeedback")}setIndexBuffer(e){this.vertexArray.setIndexBuffer(e),this.setNeedsRedraw("indexBuffer")}setAttributes(e,i){e.indices&&it.warn(`Model:${this.id} setAttributes() - indexBuffer should be set using setIndexBuffer()`)();for(const[r,o]of Object.entries(e)){const h=this.bufferLayout.find(x=>dE(x).includes(r));if(!h){it.warn(`Model(${this.id}): Missing layout for buffer "${r}".`)();continue}const d=dE(h);let c=!1;for(const x of d){const S=this._attributeInfos[x];S&&(this.vertexArray.setBuffer(S.location,o),c=!0)}!c&&!((i==null?void 0:i.disableWarnings)??this.props.disableWarnings)&&it.warn(`Model(${this.id}): Ignoring buffer "${o.id}" for unknown attribute "${r}"`)()}this.setNeedsRedraw("attributes")}setConstantAttributes(e,i){for(const[r,o]of Object.entries(e)){const h=this._attributeInfos[r];h?this.vertexArray.setConstantWebGL(h.location,o):((i==null?void 0:i.disableWarnings)??this.props.disableWarnings)||it.warn(`Model "${this.id}: Ignoring constant supplied for unknown attribute "${r}"`)()}this.setNeedsRedraw("constants")}setUniforms(e){gg(e)||(this.pipeline.setUniformsWebGL(e),Object.assign(this.uniforms,e)),this.setNeedsRedraw("uniforms")}updateModuleSettings(e){const{bindings:i,uniforms:r}=ex(this._getModuleUniforms(e));Object.assign(this.bindings,i),Object.assign(this.uniforms,r),this.setNeedsRedraw("moduleSettings")}_getBindingsUpdateTimestamp(){let e=0;for(const i of Object.values(this.bindings))i instanceof mg?e=Math.max(e,i.texture.updateTimestamp):i instanceof cr||i instanceof Fn?e=Math.max(e,i.updateTimestamp):i instanceof bg||(e=Math.max(e,i.buffer.updateTimestamp));return e}_setGeometryAttributes(e){const i={...e.attributes};for(const[r]of Object.entries(i))!this.pipeline.shaderLayout.attributes.find(o=>o.name===r)&&r!=="positions"&&delete i[r];this.vertexCount=e.vertexCount,this.setIndexBuffer(e.indices||null),this.setAttributes(e.attributes,{disableWarnings:!0}),this.setAttributes(i,{disableWarnings:this.props.disableWarnings}),this.setNeedsRedraw("geometry attributes")}_setPipelineNeedsUpdate(e){this._pipelineNeedsUpdate||(this._pipelineNeedsUpdate=e),this.setNeedsRedraw(e)}_updatePipeline(){if(this._pipelineNeedsUpdate){let e=null,i=null;this.pipeline&&(it.log(1,`Model ${this.id}: Recreating pipeline because "${this._pipelineNeedsUpdate}".`)(),e=this.pipeline.vs,i=this.pipeline.fs),this._pipelineNeedsUpdate=!1;const r=this.shaderFactory.createShader({id:`${this.id}-vertex`,stage:"vertex",source:this.source||this.vs,debug:this.props.debugShaders});let o=null;this.source?o=r:this.fs&&(o=this.shaderFactory.createShader({id:`${this.id}-fragment`,stage:"fragment",source:this.source||this.fs,debug:this.props.debugShaders})),this.pipeline=this.pipelineFactory.createRenderPipeline({...this.props,bufferLayout:this.bufferLayout,topology:this.topology,parameters:this.parameters,vs:r,fs:o}),this._attributeInfos=DI(this.pipeline.shaderLayout,this.bufferLayout),e&&this.shaderFactory.release(e),i&&this.shaderFactory.release(i)}return this.pipeline}_logDrawCallStart(){const e=it.level>3?0:eU;it.level<2||Date.now()-this._lastLogTime>> DRAWING MODEL ${this.id}`,{collapsed:it.level<=2})())}_logDrawCallEnd(){if(this._logOpen){const e=GL(this.pipeline.shaderLayout,this.id);it.table(zh,e)();const i=this.shaderInputs.getDebugTable();for(const[o,h]of Object.entries(this.uniforms))i[o]={value:h};it.table(zh,i)();const r=this._getAttributeDebugTable();it.table(zh,this._attributeInfos)(),it.table(zh,r)(),it.groupEnd(zh)(),this._logOpen=!1}}_logFramebuffer(e){const i=it.get("framebuffer");if(this._drawCount++,!i||this._drawCount++>3&&this._drawCount%60)return;const r=e.props.framebuffer;r&&QL(r,{id:r.id,minimap:!0})}_getAttributeDebugTable(){const e={};for(const[i,r]of Object.entries(this._attributeInfos))e[r.location]={name:i,type:r.shaderType,values:this._getBufferOrConstantValues(this.vertexArray.attributes[r.location],r.bufferDataType)};if(this.vertexArray.indexBuffer){const{indexBuffer:i}=this.vertexArray,r=i.indexType==="uint32"?new Uint32Array(i.debugData):new Uint16Array(i.debugData);e.indices={name:"indices",type:i.indexType,values:r.toString()}}return e}_getBufferOrConstantValues(e,i){const r=NI(i);return(e instanceof cr?new r(e.debugData):e).toString()}};Z(nm,"defaultProps",{...hu.defaultProps,source:null,vs:null,fs:null,id:"unnamed",handle:void 0,userData:{},defines:{},modules:[],moduleSettings:void 0,geometry:null,indexBuffer:null,attributes:{},constantAttributes:{},varyings:[],isInstanced:void 0,instanceCount:0,vertexCount:0,shaderInputs:void 0,pipelineFactory:void 0,shaderFactory:void 0,transformFeedback:void 0,shaderAssembler:_g.getDefaultShaderAssembler(),debugShaders:void 0,disableWarnings:void 0});let gu=nm;function uE(t,e){const i=[...t];for(const r of e){const o=i.findIndex(h=>h.name===r.name);o<0?i.push(r):i[o]=r}return i}function tU(t){return{type:t.type,shaderLanguage:t.info.shadingLanguage,shaderLanguageVersion:t.info.shadingLanguageVersion,gpu:t.info.gpu,features:t.features}}function dE(t){var e;return t.attributes?(e=t.attributes)==null?void 0:e.map(i=>i.attribute):[t.name]}class Bf{constructor(e,i=gu.defaultProps){Z(this,"device");Z(this,"model");Z(this,"transformFeedback");Yi(Bf.isSupported(e),"BufferTransform not yet implemented on WebGPU"),this.device=e,this.model=new gu(this.device,{id:i.id||"buffer-transform-model",fs:i.fs||BB(),topology:i.topology||"point-list",...i}),this.transformFeedback=this.device.createTransformFeedback({layout:this.model.pipeline.shaderLayout,buffers:i.feedbackBuffers}),this.model.setTransformFeedback(this.transformFeedback),Object.seal(this)}static isSupported(e){var i;return((i=e==null?void 0:e.info)==null?void 0:i.type)==="webgl"}destroy(){this.model&&this.model.destroy()}delete(){this.destroy()}run(e){const i=this.device.beginRenderPass(e);this.model.draw(i),i.end()}update(...e){console.warn("TextureTransform#update() not implemented")}getBuffer(e){return this.transformFeedback.getBuffer(e)}readAsync(e){const i=this.getBuffer(e);if(i instanceof cr)return i.readAsync();const{buffer:r,byteOffset:o=0,byteLength:h=r.byteLength}=i;return r.readAsync(o,h)}}class iU{constructor(e){Z(this,"id");Z(this,"topology");Z(this,"vertexCount");Z(this,"indices");Z(this,"attributes");Z(this,"userData",{});const{attributes:i={},indices:r=null,vertexCount:o=null}=e;this.id=e.id||Nc("geometry"),this.topology=e.topology,r&&(this.indices=ArrayBuffer.isView(r)?{value:r,size:1}:r),this.attributes={};for(const[h,d]of Object.entries(i)){const c=ArrayBuffer.isView(d)?{value:d}:d;Yi(ArrayBuffer.isView(c.value),`${this._print(h)}: must be typed array or object with value as typed array`),(h==="POSITION"||h==="positions")&&!c.size&&(c.size=3),h==="indices"?(Yi(!this.indices),this.indices=c):this.attributes[h]=c}this.indices&&this.indices.isIndexed!==void 0&&(this.indices=Object.assign({},this.indices),delete this.indices.isIndexed),this.vertexCount=o||this._calculateVertexCount(this.attributes,this.indices)}getVertexCount(){return this.vertexCount}getAttributes(){return this.indices?{indices:this.indices,...this.attributes}:this.attributes}_print(e){return`Geometry ${this.id} attribute ${e}`}_setAttributes(e,i){return this}_calculateVertexCount(e,i){if(i)return i.value.length;let r=1/0;for(const o of Object.values(e)){const{value:h,size:d,constant:c}=o;!c&&h&&d>=1&&(r=Math.min(r,h.length/d))}return Yi(Number.isFinite(r)),r}}const rU={blendColorOperation:"add",blendColorSrcFactor:"one",blendColorDstFactor:"zero",blendAlphaOperation:"add",blendAlphaSrcFactor:"constant-alpha",blendAlphaDstFactor:"zero"};class uP extends nx{constructor(){super(...arguments),this._colorEncoderState=null}render(e){return"pickingFBO"in e?this._drawPickingBuffer(e):super.render(e)}_drawPickingBuffer({layers:e,layerFilter:i,views:r,viewports:o,onViewportActive:h,pickingFBO:d,deviceRect:{x:c,y:x,width:S,height:P},cullRect:M,effects:D,pass:H="picking",pickZ:Q,moduleParameters:G}){this.pickZ=Q;const _e=this._resetColorEncoder(Q),ve=[c,x,S,P],be=super.render({target:d,layers:e,layerFilter:i,views:r,viewports:o,onViewportActive:h,cullRect:M,effects:D==null?void 0:D.filter(Be=>Be.useInPicking),pass:H,isPicking:!0,moduleParameters:G,clearColor:[0,0,0,0],colorMask:15,scissorRect:ve});return this._colorEncoderState=null,{decodePickingColor:_e&&nU.bind(null,_e),stats:be}}shouldDrawLayer(e){const{pickable:i,operation:r}=e.props;return i&&r.includes("draw")||r.includes("terrain")||r.includes("mask")}getModuleParameters(){return{picking:{isActive:1,isAttribute:this.pickZ},lightSources:{}}}getLayerParameters(e,i,r){const o={depthMask:!0,depthTest:!0,depthRange:[0,1],...e.props.parameters},{pickable:h,operation:d}=e.props;return!this._colorEncoderState||d.includes("terrain")?o.blend=!1:h&&d.includes("draw")&&(Object.assign(o,rU),o.blend=!0,o.blendColor=sU(this._colorEncoderState,e,r)),o}_resetColorEncoder(e){return this._colorEncoderState=e?null:{byLayer:new Map,byAlpha:[]},this._colorEncoderState}}function sU(t,e,i){const{byLayer:r,byAlpha:o}=t;let h,d=r.get(e);return d?(d.viewports.push(i),h=d.a):(h=r.size+1,h<=255?(d={a:h,layer:e,viewports:[i]},r.set(e,d),o[h]=d):(Ni.warn("Too many pickable layers, only picking the first 255")(),h=0)),[0,0,0,h/255]}function nU(t,e){const i=t.byAlpha[e[3]];return i&&{pickedLayer:i.layer,pickedViewports:i.viewports,pickedObjectIndex:i.layer.decodePickingColor(e)}}const jh={NO_STATE:"Awaiting state",MATCHED:"Matched. State transferred from previous layer",INITIALIZED:"Initialized",AWAITING_GC:"Discarded. Awaiting garbage collection",AWAITING_FINALIZATION:"No longer matched. Awaiting garbage collection",FINALIZED:"Finalized! Awaiting garbage collection"},Cg=Symbol.for("component"),Tc=Symbol.for("propTypes"),Z0=Symbol.for("deprecatedProps"),nu=Symbol.for("asyncPropDefaults"),Pc=Symbol.for("asyncPropOriginal"),ll=Symbol.for("asyncPropResolved");function zf(t,e=()=>!0){return Array.isArray(t)?dP(t,e,[]):e(t)?[t]:[]}function dP(t,e,i){let r=-1;for(;++r0}delete(){}getData(){return this.isLoaded?this._error?Promise.reject(this._error):this._content:this._loader.then(()=>this.getData())}setData(e,i){if(e===this._data&&!i)return;this._data=e;const r=++this._loadCount;let o=e;typeof e=="string"&&(o=Ib(e)),o instanceof Promise?(this.isLoaded=!1,this._loader=o.then(h=>{this._loadCount===r&&(this.isLoaded=!0,this._error=void 0,this._content=h)}).catch(h=>{this._loadCount===r&&(this.isLoaded=!0,this._error=h||!0)})):(this.isLoaded=!0,this._error=void 0,this._content=e);for(const h of this._subscribers)h.onChange(this.getData())}}class lU{constructor(e){var i;this.protocol=e.protocol||"resource://",this._context={device:e.device,gl:(i=e.device)==null?void 0:i.gl,resourceManager:this},this._resources={},this._consumers={},this._pruneRequest=null}contains(e){return e.startsWith(this.protocol)?!0:e in this._resources}add({resourceId:e,data:i,forceUpdate:r=!1,persistent:o=!0}){let h=this._resources[e];h?h.setData(i,r):(h=new aU(e,i,this._context),this._resources[e]=h),h.persistent=o}remove(e){const i=this._resources[e];i&&(i.delete(),delete this._resources[e])}unsubscribe({consumerId:e}){const i=this._consumers[e];if(i){for(const r in i){const o=i[r],h=this._resources[o.resourceId];h&&h.unsubscribe(o)}delete this._consumers[e],this.prune()}}subscribe({resourceId:e,onChange:i,consumerId:r,requestId:o="default"}){const{_resources:h,protocol:d}=this;e.startsWith(d)&&(e=e.replace(d,""),h[e]||this.add({resourceId:e,data:null,persistent:!1}));const c=h[e];if(this._track(r,o,c,i),c)return c.getData()}prune(){this._pruneRequest||(this._pruneRequest=setTimeout(()=>this._prune(),0))}finalize(){for(const e in this._resources)this._resources[e].delete()}_track(e,i,r,o){const h=this._consumers,d=h[e]=h[e]||{};let c=d[i];const x=c&&c.resourceId&&this._resources[c.resourceId];x&&(x.unsubscribe(c),this.prune()),r&&(c?(c.onChange=o,c.resourceId=r.id):c={onChange:o,resourceId:r.id},d[i]=c,r.subscribe(c))}_prune(){this._pruneRequest=null;for(const e of Object.keys(this._resources)){const i=this._resources[e];!i.persistent&&!i.inUse()&&(i.delete(),delete this._resources[e])}}}const cU="layerManager.setLayers",hU="layerManager.activateViewport";class uU{constructor(e,i){this._lastRenderedLayers=[],this._needsRedraw=!1,this._needsUpdate=!1,this._nextLayers=null,this._debug=!1,this._defaultShaderModulesChanged=!1,this.activateViewport=c=>{Os(hU,this,c),c&&(this.context.viewport=c)};const{deck:r,stats:o,viewport:h,timeline:d}=i||{};this.layers=[],this.resourceManager=new lU({device:e,protocol:"deck://"}),this.context={mousePosition:null,userData:{},layerManager:this,device:e,gl:e==null?void 0:e.gl,deck:r,shaderAssembler:yL(),defaultShaderModules:[],renderPass:void 0,stats:o||new Tm({id:"deck.gl"}),viewport:h||new Rg({id:"DEFAULT-INITIAL-VIEWPORT"}),timeline:d||new hP,resourceManager:this.resourceManager,onError:void 0},Object.seal(this)}finalize(){this.resourceManager.finalize();for(const e of this.layers)this._finalizeLayer(e)}needsRedraw(e={clearRedrawFlags:!1}){let i=this._needsRedraw;e.clearRedrawFlags&&(this._needsRedraw=!1);for(const r of this.layers){const o=r.getNeedsRedraw(e);i=i||o}return i}needsUpdate(){return this._nextLayers&&this._nextLayers!==this._lastRenderedLayers?"layers changed":this._defaultShaderModulesChanged?"shader modules changed":this._needsUpdate}setNeedsRedraw(e){this._needsRedraw=this._needsRedraw||e}setNeedsUpdate(e){this._needsUpdate=this._needsUpdate||e}getLayers({layerIds:e}={}){return e?this.layers.filter(i=>e.find(r=>i.id.indexOf(r)===0)):this.layers}setProps(e){"debug"in e&&(this._debug=e.debug),"userData"in e&&(this.context.userData=e.userData),"layers"in e&&(this._nextLayers=e.layers),"onError"in e&&(this.context.onError=e.onError)}setLayers(e,i){Os(cU,this,i,e),this._lastRenderedLayers=e;const r=zf(e,Boolean);for(const o of r)o.context=this.context;this._updateLayers(this.layers,r)}updateLayers(){const e=this.needsUpdate();e&&(this.setNeedsRedraw(`updating layers: ${e}`),this.setLayers(this._nextLayers||this._lastRenderedLayers,e)),this._nextLayers=null}addDefaultShaderModule(e){const{defaultShaderModules:i}=this.context;i.find(r=>r.name===e.name)||(i.push(e),this._defaultShaderModulesChanged=!0)}removeDefaultShaderModule(e){const{defaultShaderModules:i}=this.context,r=i.findIndex(o=>o.name===e.name);r>=0&&(i.splice(r,1),this._defaultShaderModulesChanged=!0)}_handleError(e,i,r){r.raiseError(i,`${e} of ${r}`)}_updateLayers(e,i){const r={};for(const d of e)r[d.id]?Ni.warn(`Multiple old layers with same id ${d.id}`)():r[d.id]=d;if(this._defaultShaderModulesChanged){for(const d of e)d.setNeedsUpdate(),d.setChangeFlags({extensionsChanged:!0});this._defaultShaderModulesChanged=!1}const o=[];this._updateSublayersRecursively(i,r,o),this._finalizeOldLayers(r);let h=!1;for(const d of o)if(d.hasUniformTransition()){h=`Uniform transition in ${d}`;break}this._needsUpdate=h,this.layers=o}_updateSublayersRecursively(e,i,r){for(const o of e){o.context=this.context;const h=i[o.id];h===null&&Ni.warn(`Multiple new layers with same id ${o.id}`)(),i[o.id]=null;let d=null;try{this._debug&&h!==o&&o.validateProps(),h?(this._transferLayerState(h,o),this._updateLayer(o)):this._initializeLayer(o),r.push(o),d=o.isComposite?o.getSubLayers():null}catch(c){this._handleError("matching",c,o)}d&&this._updateSublayersRecursively(d,i,r)}}_finalizeOldLayers(e){for(const i in e){const r=e[i];r&&this._finalizeLayer(r)}}_initializeLayer(e){try{e._initialize(),e.lifecycle=jh.INITIALIZED}catch(i){this._handleError("initialization",i,e)}}_transferLayerState(e,i){i._transferState(e),i.lifecycle=jh.MATCHED,i!==e&&(e.lifecycle=jh.AWAITING_GC)}_updateLayer(e){try{e._update()}catch(i){this._handleError("update",i,e)}}_finalizeLayer(e){this._needsRedraw=this._needsRedraw||`finalized ${e}`,e.lifecycle=jh.AWAITING_FINALIZATION;try{e._finalize(),e.lifecycle=jh.FINALIZED}catch(i){this._handleError("finalization",i,e)}}}function xn(t,e,i){if(t===e)return!0;if(!i||!t||!e)return!1;if(Array.isArray(t)){if(!Array.isArray(e)||t.length!==e.length)return!1;for(let r=0;ri.containsPixel(e)):this._viewports}getViews(){const e={};return this.views.forEach(i=>{e[i.id]=i}),e}getView(e){return this.views.find(i=>i.id===e)}getViewState(e){const i=typeof e=="string"?this.getView(e):e,r=i&&this.viewState[i.getViewStateId()]||this.viewState;return i?i.filterViewState(r):r}getViewport(e){return this._viewportMap[e]}unproject(e,i){const r=this.getViewports(),o={x:e[0],y:e[1]};for(let h=r.length-1;h>=0;--h){const d=r[h];if(d.containsPixel(o)){const c=e.slice();return c[0]-=d.x,c[1]-=d.y,d.unproject(c,i)}}return null}setProps(e){e.views&&this._setViews(e.views),e.viewState&&this._setViewState(e.viewState),("width"in e||"height"in e)&&this._setSize(e.width,e.height),this._isUpdating||this._update()}_update(){this._isUpdating=!0,this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._needsUpdate&&(this._needsUpdate=!1,this._rebuildViewports()),this._isUpdating=!1}_setSize(e,i){(e!==this.width||i!==this.height)&&(this.width=e,this.height=i,this.setNeedsUpdate("Size changed"))}_setViews(e){e=zf(e,Boolean),this._diffViews(e,this.views)&&this.setNeedsUpdate("views changed"),this.views=e}_setViewState(e){e?(!xn(e,this.viewState,3)&&this.setNeedsUpdate("viewState changed"),this.viewState=e):Ni.warn("missing `viewState` or `initialViewState`")()}_createController(e,i){const r=i.type;return new r({timeline:this.timeline,eventManager:this._eventManager,onViewStateChange:this._eventCallbacks.onViewStateChange,onStateChange:this._eventCallbacks.onInteractionStateChange,makeViewport:h=>{var d;return(d=this.getView(e.id))==null?void 0:d.makeViewport({viewState:h,width:this.width,height:this.height})}})}_updateController(e,i,r,o){const h=e.controller;if(h&&r){const d={...i,...h,id:e.id,x:r.x,y:r.y,width:r.width,height:r.height};return(!o||o.constructor!==h.type)&&(o=this._createController(e,d)),o&&o.setProps(d),o}return null}_rebuildViewports(){const{views:e}=this,i=this.controllers;this._viewports=[],this.controllers={};let r=!1;for(let o=e.length;o--;){const h=e[o],d=this.getViewState(h),c=h.makeViewport({viewState:d,width:this.width,height:this.height});let x=i[h.id];const S=!!h.controller;S&&!x&&(r=!0),(r||!S)&&x&&(x.finalize(),x=null),this.controllers[h.id]=this._updateController(h,d,c,x),c&&this._viewports.unshift(c)}for(const o in i){const h=i[o];h&&!this.controllers[o]&&h.finalize()}this._buildViewportMap()}_buildViewportMap(){this._viewportMap={},this._viewports.forEach(e=>{e.id&&(this._viewportMap[e.id]=this._viewportMap[e.id]||e)})}_diffViews(e,i){return e.length!==i.length?!0:e.some((r,o)=>!e[o].equals(i[o]))}}const fU=/([0-9]+\.?[0-9]*)(%|px)/;function Ya(t){switch(typeof t){case"number":return{position:t,relative:!1};case"string":const e=fU.exec(t);if(e&&e.length>=3){const i=e[2]==="%",r=parseFloat(e[1]);return{position:i?r/100:r,relative:i}}default:throw new Error(`Could not parse position string ${t}`)}}function Ka(t,e){return t.relative?Math.round(t.position*e):t.position}class pU{constructor(e){const{id:i,x:r=0,y:o=0,width:h="100%",height:d="100%",padding:c=null}=e;this.id=i||this.constructor.displayName||"view",this.props={...e,id:this.id},this._x=Ya(r),this._y=Ya(o),this._width=Ya(h),this._height=Ya(d),this._padding=c&&{left:Ya(c.left||0),right:Ya(c.right||0),top:Ya(c.top||0),bottom:Ya(c.bottom||0)},this.equals=this.equals.bind(this),Object.seal(this)}equals(e){return this===e?!0:this.ViewportType===e.ViewportType&&xn(this.props,e.props,2)}makeViewport({width:e,height:i,viewState:r}){r=this.filterViewState(r);const o=this.getDimensions({width:e,height:i});return!o.height||!o.width?null:new this.ViewportType({...r,...this.props,...o})}getViewStateId(){const{viewState:e}=this.props;return typeof e=="string"?e:(e==null?void 0:e.id)||this.id}filterViewState(e){if(this.props.viewState&&typeof this.props.viewState=="object"){if(!this.props.viewState.id)return this.props.viewState;const i={...e};for(const r in this.props.viewState)r!=="id"&&(i[r]=this.props.viewState[r]);return i}return e}getDimensions({width:e,height:i}){const r={x:Ka(this._x,e),y:Ka(this._y,i),width:Ka(this._width,e),height:Ka(this._height,i)};return this._padding&&(r.padding={left:Ka(this._padding.left,e),top:Ka(this._padding.top,i),right:Ka(this._padding.right,e),bottom:Ka(this._padding.bottom,i)}),r}get controller(){const e=this.props.controller;return e?e===!0?{type:this.ControllerType}:typeof e=="function"?{type:e}:{type:this.ControllerType,...e}:null}}class Im{constructor(e){this._inProgress=!1,this._handle=null,this.time=0,this.settings={duration:0},this._timeline=e}get inProgress(){return this._inProgress}start(e){var i,r;this.cancel(),this.settings=e,this._inProgress=!0,(r=(i=this.settings).onStart)==null||r.call(i,this)}end(){var e,i;this._inProgress&&(this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1,(i=(e=this.settings).onEnd)==null||i.call(e,this))}cancel(){var e,i;this._inProgress&&((i=(e=this.settings).onInterrupt)==null||i.call(e,this),this._timeline.removeChannel(this._handle),this._handle=null,this._inProgress=!1)}update(){var e,i;if(!this._inProgress)return!1;if(this._handle===null){const{_timeline:r,settings:o}=this;this._handle=r.addChannel({delay:r.getTime(),duration:o.duration})}return this.time=this._timeline.getTime(this._handle),this._onUpdate(),(i=(e=this.settings).onUpdate)==null||i.call(e,this),this._timeline.isFinished(this._handle)&&this.end(),!0}_onUpdate(){}}const fE=()=>{},Gb={BREAK:1,SNAP_TO_END:2,IGNORE:3},_U=t=>t,gU=Gb.BREAK;class mU{constructor(e){this._onTransitionUpdate=i=>{const{time:r,settings:{interpolator:o,startProps:h,endProps:d,duration:c,easing:x}}=i,S=x(r/c),P=o.interpolateProps(h,d,S);this.propsInTransition=this.getControllerState({...this.props,...P}).getViewportProps(),this.onViewStateChange({viewState:this.propsInTransition,oldViewState:this.props})},this.getControllerState=e.getControllerState,this.propsInTransition=null,this.transition=new Im(e.timeline),this.onViewStateChange=e.onViewStateChange||fE,this.onStateChange=e.onStateChange||fE}finalize(){this.transition.cancel()}getViewportInTransition(){return this.propsInTransition}processViewStateChange(e){let i=!1;const r=this.props;if(this.props=e,!r||this._shouldIgnoreViewportChange(r,e))return!1;if(this._isTransitionEnabled(e)){let o=r;if(this.transition.inProgress){const{interruption:h,endProps:d}=this.transition.settings;o={...r,...h===Gb.SNAP_TO_END?d:this.propsInTransition||r}}this._triggerTransition(o,e),i=!0}else this.transition.cancel();return i}updateTransition(){this.transition.update()}_isTransitionEnabled(e){const{transitionDuration:i,transitionInterpolator:r}=e;return(i>0||i==="auto")&&!!r}_isUpdateDueToCurrentTransition(e){return this.transition.inProgress&&this.propsInTransition?this.transition.settings.interpolator.arePropsEqual(e,this.propsInTransition):!1}_shouldIgnoreViewportChange(e,i){return this.transition.inProgress?this.transition.settings.interruption===Gb.IGNORE||this._isUpdateDueToCurrentTransition(i):this._isTransitionEnabled(i)?i.transitionInterpolator.arePropsEqual(e,i):!0}_triggerTransition(e,i){const r=this.getControllerState(e),o=this.getControllerState(i).shortestPathFrom(r),h=i.transitionInterpolator,d=h.getDuration?h.getDuration(e,i):i.transitionDuration;if(d===0)return;const c=h.initializeProps(e,o);this.propsInTransition={};const x={duration:d,easing:i.transitionEasing||_U,interpolator:h,interruption:i.transitionInterruption||gU,startProps:c.start,endProps:c.end,onStart:i.onTransitionStart,onUpdate:this._onTransitionUpdate,onInterrupt:this._onTransitionEnd(i.onTransitionInterrupt),onEnd:this._onTransitionEnd(i.onTransitionEnd)};this.transition.start(x),this.onStateChange({inTransition:!0}),this.updateTransition()}_onTransitionEnd(e){return i=>{this.propsInTransition=null,this.onStateChange({inTransition:!1,isZooming:!1,isPanning:!1,isRotating:!1}),e==null||e(i)}}}function Or(t,e){if(!t)throw new Error(e||"deck.gl: assertion failed.")}class yU{constructor(e){const{compare:i,extract:r,required:o}=e;this._propsToCompare=i,this._propsToExtract=r||i,this._requiredProps=o}arePropsEqual(e,i){for(const r of this._propsToCompare)if(!(r in e)||!(r in i)||!Df(e[r],i[r]))return!1;return!0}initializeProps(e,i){const r={},o={};for(const h of this._propsToExtract)(h in e||h in i)&&(r[h]=e[h],o[h]=i[h]);return this._checkRequiredProps(r),this._checkRequiredProps(o),{start:r,end:o}}getDuration(e,i){return i.transitionDuration}_checkRequiredProps(e){this._requiredProps&&this._requiredProps.forEach(i=>{const r=e[i];Or(Number.isFinite(r)||Array.isArray(r),`${i} is required for transition`)})}}const bU=["longitude","latitude","zoom","bearing","pitch"],vU=["longitude","latitude","zoom"];class fP extends yU{constructor(e={}){const i=Array.isArray(e)?e:e.transitionProps,r=Array.isArray(e)?{}:e;r.transitionProps=Array.isArray(i)?{compare:i,required:i}:i||{compare:bU,required:vU},super(r.transitionProps),this.opts=r}initializeProps(e,i){const r=super.initializeProps(e,i),{makeViewport:o,around:h}=this.opts;if(o&&h){const d=o(e),c=o(i),x=d.unproject(h);r.start.around=h,Object.assign(r.end,{around:c.project(x),aroundPosition:x,width:i.width,height:i.height})}return r}interpolateProps(e,i,r){const o={};for(const h of this._propsToExtract)o[h]=Sg(e[h]||0,i[h]||0,r);if(i.aroundPosition&&this.opts.makeViewport){const h=this.opts.makeViewport({...i,...o});Object.assign(o,h.panByPosition(i.aroundPosition,Sg(e.around,i.around,r)))}return o}}const Ja={transitionDuration:0},xU=300,B_=t=>1-(1-t)*(1-t),Lh={WHEEL:["wheel"],PAN:["panstart","panmove","panend"],PINCH:["pinchstart","pinchmove","pinchend"],TRIPLE_PAN:["tripanstart","tripanmove","tripanend"],DOUBLE_TAP:["doubletap"],KEYBOARD:["keydown"]},ac={};class wU{constructor(e){this.state={},this._events={},this._interactionState={isDragging:!1},this._customEvents=[],this._eventStartBlocked=null,this._panMove=!1,this.invertPan=!1,this.dragMode="rotate",this.inertia=0,this.scrollZoom=!0,this.dragPan=!0,this.dragRotate=!0,this.doubleClickZoom=!0,this.touchZoom=!0,this.touchRotate=!1,this.keyboard=!0,this.transitionManager=new mU({...e,getControllerState:i=>new this.ControllerState(i),onViewStateChange:this._onTransition.bind(this),onStateChange:this._setInteractionState.bind(this)}),this.handleEvent=this.handleEvent.bind(this),this.eventManager=e.eventManager,this.onViewStateChange=e.onViewStateChange||(()=>{}),this.onStateChange=e.onStateChange||(()=>{}),this.makeViewport=e.makeViewport}set events(e){this.toggleEvents(this._customEvents,!1),this.toggleEvents(e,!0),this._customEvents=e,this.props&&this.setProps(this.props)}finalize(){var e;for(const i in this._events)this._events[i]&&((e=this.eventManager)==null||e.off(i,this.handleEvent));this.transitionManager.finalize()}handleEvent(e){this._controllerState=void 0;const i=this._eventStartBlocked;switch(e.type){case"panstart":return i?!1:this._onPanStart(e);case"panmove":return this._onPan(e);case"panend":return this._onPanEnd(e);case"pinchstart":return i?!1:this._onPinchStart(e);case"pinchmove":return this._onPinch(e);case"pinchend":return this._onPinchEnd(e);case"tripanstart":return i?!1:this._onTriplePanStart(e);case"tripanmove":return this._onTriplePan(e);case"tripanend":return this._onTriplePanEnd(e);case"doubletap":return this._onDoubleTap(e);case"wheel":return this._onWheel(e);case"keydown":return this._onKeyDown(e);default:return!1}}get controllerState(){return this._controllerState=this._controllerState||new this.ControllerState({makeViewport:this.makeViewport,...this.props,...this.state}),this._controllerState}getCenter(e){const{x:i,y:r}=this.props,{offsetCenter:o}=e;return[o.x-i,o.y-r]}isPointInBounds(e,i){const{width:r,height:o}=this.props;if(i&&i.handled)return!1;const h=e[0]>=0&&e[0]<=r&&e[1]>=0&&e[1]<=o;return h&&i&&i.stopPropagation(),h}isFunctionKeyPressed(e){const{srcEvent:i}=e;return!!(i.metaKey||i.altKey||i.ctrlKey||i.shiftKey)}isDragging(){return this._interactionState.isDragging||!1}blockEvents(e){const i=setTimeout(()=>{this._eventStartBlocked===i&&(this._eventStartBlocked=null)},e);this._eventStartBlocked=i}setProps(e){e.dragMode&&(this.dragMode=e.dragMode),this.props=e,"transitionInterpolator"in e||(e.transitionInterpolator=this._getTransitionProps().transitionInterpolator),this.transitionManager.processViewStateChange(e);const{inertia:i}=e;this.inertia=Number.isFinite(i)?i:i===!0?xU:0;const{scrollZoom:r=!0,dragPan:o=!0,dragRotate:h=!0,doubleClickZoom:d=!0,touchZoom:c=!0,touchRotate:x=!1,keyboard:S=!0}=e,P=!!this.onViewStateChange;this.toggleEvents(Lh.WHEEL,P&&r),this.toggleEvents(Lh.PAN,P),this.toggleEvents(Lh.PINCH,P&&(c||x)),this.toggleEvents(Lh.TRIPLE_PAN,P&&x),this.toggleEvents(Lh.DOUBLE_TAP,P&&d),this.toggleEvents(Lh.KEYBOARD,P&&S),this.scrollZoom=r,this.dragPan=o,this.dragRotate=h,this.doubleClickZoom=d,this.touchZoom=c,this.touchRotate=x,this.keyboard=S}updateTransition(){this.transitionManager.updateTransition()}toggleEvents(e,i){this.eventManager&&e.forEach(r=>{this._events[r]!==i&&(this._events[r]=i,i?this.eventManager.on(r,this.handleEvent):this.eventManager.off(r,this.handleEvent))})}updateViewport(e,i=null,r={}){const o={...e.getViewportProps(),...i},h=this.controllerState!==e;if(this.state=e.getState(),this._setInteractionState(r),h){const d=this.controllerState&&this.controllerState.getViewportProps();this.onViewStateChange&&this.onViewStateChange({viewState:o,interactionState:this._interactionState,oldViewState:d,viewId:this.props.id})}}_onTransition(e){this.onViewStateChange({...e,interactionState:this._interactionState,viewId:this.props.id})}_setInteractionState(e){Object.assign(this._interactionState,e),this.onStateChange(this._interactionState)}_onPanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;let r=this.isFunctionKeyPressed(e)||e.rightButton||!1;(this.invertPan||this.dragMode==="pan")&&(r=!r);const o=this.controllerState[r?"panStart":"rotateStart"]({pos:i});return this._panMove=r,this.updateViewport(o,Ja,{isDragging:!0}),!0}_onPan(e){return this.isDragging()?this._panMove?this._onPanMove(e):this._onPanRotate(e):!1}_onPanEnd(e){return this.isDragging()?this._panMove?this._onPanMoveEnd(e):this._onPanRotateEnd(e):!1}_onPanMove(e){if(!this.dragPan)return!1;const i=this.getCenter(e),r=this.controllerState.pan({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isPanning:!0}),!0}_onPanMoveEnd(e){const{inertia:i}=this;if(this.dragPan&&i&&e.velocity){const r=this.getCenter(e),o=[r[0]+e.velocityX*i/2,r[1]+e.velocityY*i/2],h=this.controllerState.pan({pos:o}).panEnd();this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isPanning:!0})}else{const r=this.controllerState.panEnd();this.updateViewport(r,null,{isDragging:!1,isPanning:!1})}return!0}_onPanRotate(e){if(!this.dragRotate)return!1;const i=this.getCenter(e),r=this.controllerState.rotate({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isRotating:!0}),!0}_onPanRotateEnd(e){const{inertia:i}=this;if(this.dragRotate&&i&&e.velocity){const r=this.getCenter(e),o=[r[0]+e.velocityX*i/2,r[1]+e.velocityY*i/2],h=this.controllerState.rotate({pos:o}).rotateEnd();this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isRotating:!0})}else{const r=this.controllerState.rotateEnd();this.updateViewport(r,null,{isDragging:!1,isRotating:!1})}return!0}_onWheel(e){if(!this.scrollZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;e.srcEvent.preventDefault();const{speed:r=.01,smooth:o=!1}=this.scrollZoom===!0?{}:this.scrollZoom,{delta:h}=e;let d=2/(1+Math.exp(-Math.abs(h*r)));h<0&&d!==0&&(d=1/d);const c=this.controllerState.zoom({pos:i,scale:d});return this.updateViewport(c,{...this._getTransitionProps({around:i}),transitionDuration:o?250:1},{isZooming:!0,isPanning:!0}),!0}_onTriplePanStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.controllerState.rotateStart({pos:i});return this.updateViewport(r,Ja,{isDragging:!0}),!0}_onTriplePan(e){if(!this.touchRotate||!this.isDragging())return!1;const i=this.getCenter(e);i[0]-=e.deltaX;const r=this.controllerState.rotate({pos:i});return this.updateViewport(r,Ja,{isDragging:!0,isRotating:!0}),!0}_onTriplePanEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this;if(this.touchRotate&&i&&e.velocityY){const r=this.getCenter(e),o=[r[0],r[1]+=e.velocityY*i/2],h=this.controllerState.rotate({pos:o});this.updateViewport(h,{...this._getTransitionProps(),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isRotating:!0}),this.blockEvents(i)}else{const r=this.controllerState.rotateEnd();this.updateViewport(r,null,{isDragging:!1,isRotating:!1})}return!0}_onPinchStart(e){const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.controllerState.zoomStart({pos:i}).rotateStart({pos:i});return ac._startPinchRotation=e.rotation,ac._lastPinchEvent=e,this.updateViewport(r,Ja,{isDragging:!0}),!0}_onPinch(e){if(!this.touchZoom&&!this.touchRotate||!this.isDragging())return!1;let i=this.controllerState;if(this.touchZoom){const{scale:r}=e,o=this.getCenter(e);i=i.zoom({pos:o,scale:r})}if(this.touchRotate){const{rotation:r}=e;i=i.rotate({deltaAngleX:ac._startPinchRotation-r})}return this.updateViewport(i,Ja,{isDragging:!0,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:this.touchRotate}),ac._lastPinchEvent=e,!0}_onPinchEnd(e){if(!this.isDragging())return!1;const{inertia:i}=this,{_lastPinchEvent:r}=ac;if(this.touchZoom&&i&&r&&e.scale!==r.scale){const o=this.getCenter(e);let h=this.controllerState.rotateEnd();const d=Math.log2(e.scale),c=(d-Math.log2(r.scale))/(e.deltaTime-r.deltaTime),x=Math.pow(2,d+c*i/2);h=h.zoom({pos:o,scale:x}).zoomEnd(),this.updateViewport(h,{...this._getTransitionProps({around:o}),transitionDuration:i,transitionEasing:B_},{isDragging:!1,isPanning:this.touchZoom,isZooming:this.touchZoom,isRotating:!1}),this.blockEvents(i)}else{const o=this.controllerState.zoomEnd().rotateEnd();this.updateViewport(o,null,{isDragging:!1,isPanning:!1,isZooming:!1,isRotating:!1})}return ac._startPinchRotation=null,ac._lastPinchEvent=null,!0}_onDoubleTap(e){if(!this.doubleClickZoom)return!1;const i=this.getCenter(e);if(!this.isPointInBounds(i,e))return!1;const r=this.isFunctionKeyPressed(e),o=this.controllerState.zoom({pos:i,scale:r?.5:2});return this.updateViewport(o,this._getTransitionProps({around:i}),{isZooming:!0,isPanning:!0}),this.blockEvents(100),!0}_onKeyDown(e){if(!this.keyboard)return!1;const i=this.isFunctionKeyPressed(e),{zoomSpeed:r,moveSpeed:o,rotateSpeedX:h,rotateSpeedY:d}=this.keyboard===!0?{}:this.keyboard,{controllerState:c}=this;let x;const S={};switch(e.srcEvent.code){case"Minus":x=i?c.zoomOut(r).zoomOut(r):c.zoomOut(r),S.isZooming=!0;break;case"Equal":x=i?c.zoomIn(r).zoomIn(r):c.zoomIn(r),S.isZooming=!0;break;case"ArrowLeft":i?(x=c.rotateLeft(h),S.isRotating=!0):(x=c.moveLeft(o),S.isPanning=!0);break;case"ArrowRight":i?(x=c.rotateRight(h),S.isRotating=!0):(x=c.moveRight(o),S.isPanning=!0);break;case"ArrowUp":i?(x=c.rotateUp(d),S.isRotating=!0):(x=c.moveUp(o),S.isPanning=!0);break;case"ArrowDown":i?(x=c.rotateDown(d),S.isRotating=!0):(x=c.moveDown(o),S.isPanning=!0);break;default:return!1}return this.updateViewport(x,this._getTransitionProps(),S),!0}_getTransitionProps(e){const{transition:i}=this;return!i||!i.transitionInterpolator?Ja:e?{...i,transitionInterpolator:new fP({...e,...i.transitionInterpolator.opts,makeViewport:this.controllerState.makeViewport})}:i}}class TU{constructor(e,i){this._viewportProps=this.applyConstraints(e),this._state=i}getViewportProps(){return this._viewportProps}getState(){return this._state}}const pE=5,SU=1.2;class EU extends TU{constructor(e){const{width:i,height:r,latitude:o,longitude:h,zoom:d,bearing:c=0,pitch:x=0,altitude:S=1.5,position:P=[0,0,0],maxZoom:M=20,minZoom:D=0,maxPitch:H=60,minPitch:Q=0,startPanLngLat:G,startZoomLngLat:_e,startRotatePos:ve,startBearing:be,startPitch:Se,startZoom:Be,normalize:je=!0}=e;Or(Number.isFinite(h)),Or(Number.isFinite(o)),Or(Number.isFinite(d)),super({width:i,height:r,latitude:o,longitude:h,zoom:d,bearing:c,pitch:x,altitude:S,maxZoom:M,minZoom:D,maxPitch:H,minPitch:Q,normalize:je,position:P},{startPanLngLat:G,startZoomLngLat:_e,startRotatePos:ve,startBearing:be,startPitch:Se,startZoom:Be}),this.makeViewport=e.makeViewport}panStart({pos:e}){return this._getUpdatedState({startPanLngLat:this._unproject(e)})}pan({pos:e,startPos:i}){const r=this.getState().startPanLngLat||this._unproject(i);if(!r)return this;const h=this.makeViewport(this.getViewportProps()).panByPosition(r,e);return this._getUpdatedState(h)}panEnd(){return this._getUpdatedState({startPanLngLat:null})}rotateStart({pos:e}){return this._getUpdatedState({startRotatePos:e,startBearing:this.getViewportProps().bearing,startPitch:this.getViewportProps().pitch})}rotate({pos:e,deltaAngleX:i=0,deltaAngleY:r=0}){const{startRotatePos:o,startBearing:h,startPitch:d}=this.getState();if(!o||h===void 0||d===void 0)return this;let c;return e?c=this._getNewRotation(e,o,d,h):c={bearing:h+i,pitch:d+r},this._getUpdatedState(c)}rotateEnd(){return this._getUpdatedState({startBearing:null,startPitch:null})}zoomStart({pos:e}){return this._getUpdatedState({startZoomLngLat:this._unproject(e),startZoom:this.getViewportProps().zoom})}zoom({pos:e,startPos:i,scale:r}){let{startZoom:o,startZoomLngLat:h}=this.getState();if(h||(o=this.getViewportProps().zoom,h=this._unproject(i)||this._unproject(e)),!h)return this;const{maxZoom:d,minZoom:c}=this.getViewportProps();let x=o+Math.log2(r);x=al(x,c,d);const S=this.makeViewport({...this.getViewportProps(),zoom:x});return this._getUpdatedState({zoom:x,...S.panByPosition(h,e)})}zoomEnd(){return this._getUpdatedState({startZoomLngLat:null,startZoom:null})}zoomIn(e=2){return this._zoomFromCenter(e)}zoomOut(e=2){return this._zoomFromCenter(1/e)}moveLeft(e=100){return this._panFromCenter([e,0])}moveRight(e=100){return this._panFromCenter([-e,0])}moveUp(e=100){return this._panFromCenter([0,e])}moveDown(e=100){return this._panFromCenter([0,-e])}rotateLeft(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing-e})}rotateRight(e=15){return this._getUpdatedState({bearing:this.getViewportProps().bearing+e})}rotateUp(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch+e})}rotateDown(e=10){return this._getUpdatedState({pitch:this.getViewportProps().pitch-e})}shortestPathFrom(e){const i=e.getViewportProps(),r={...this.getViewportProps()},{bearing:o,longitude:h}=r;return Math.abs(o-i.bearing)>180&&(r.bearing=o<0?o+360:o-360),Math.abs(h-i.longitude)>180&&(r.longitude=h<0?h+360:h-360),r}applyConstraints(e){const{maxZoom:i,minZoom:r,zoom:o}=e;e.zoom=al(o,r,i);const{maxPitch:h,minPitch:d,pitch:c}=e;e.pitch=al(c,d,h);const{normalize:x=!0}=e;return x&&Object.assign(e,sL(e)),e}_zoomFromCenter(e){const{width:i,height:r}=this.getViewportProps();return this.zoom({pos:[i/2,r/2],scale:e})}_panFromCenter(e){const{width:i,height:r}=this.getViewportProps();return this.pan({startPos:[i/2,r/2],pos:[i/2+e[0],r/2+e[1]]})}_getUpdatedState(e){return new this.constructor({makeViewport:this.makeViewport,...this.getViewportProps(),...this.getState(),...e})}_unproject(e){const i=this.makeViewport(this.getViewportProps());return e&&i.unproject(e)}_getNewRotation(e,i,r,o){const h=e[0]-i[0],d=e[1]-i[1],c=e[1],x=i[1],{width:S,height:P}=this.getViewportProps(),M=h/S;let D=0;d>0?Math.abs(P-x)>pE&&(D=d/(x-P)*SU):d<0&&x>pE&&(D=1-c/x),D=al(D,-1,1);const{minPitch:H,maxPitch:Q}=this.getViewportProps(),G=o+180*M;let _e=r;return D>0?_e=r+D*(Q-r):D<0&&(_e=r-D*(H-r)),{pitch:_e,bearing:G}}}class AU extends wU{constructor(){super(...arguments),this.ControllerState=EU,this.transition={transitionDuration:300,transitionInterpolator:new fP({transitionProps:{compare:["longitude","latitude","zoom","bearing","pitch","position"],required:["longitude","latitude","zoom"]}})},this.dragMode="pan"}setProps(e){e.position=e.position||[0,0,0];const i=this.props;super.setProps(e),(!i||i.height!==e.height)&&this.updateViewport(new this.ControllerState({makeViewport:this.makeViewport,...e,...this.state}))}}const j1=class j1 extends pU{constructor(e={}){super(e)}get ViewportType(){return Nf}get ControllerType(){return AU}};j1.displayName="MapView";let Mg=j1;const IU=new lP;function PU(t,e){const i=t.order??1/0,r=e.order??1/0;return i-r}class RU{constructor(e){this._resolvedEffects=[],this._defaultEffects=[],this.effects=[],this._context=e,this._needsRedraw="Initial render",this._setEffects([])}addDefaultEffect(e){const i=this._defaultEffects;if(!i.find(r=>r.id===e.id)){const r=i.findIndex(o=>PU(o,e)>0);r<0?i.push(e):i.splice(r,0,e),e.setup(this._context),this._setEffects(this.effects)}}setProps(e){"effects"in e&&(xn(e.effects,this.effects,1)||this._setEffects(e.effects))}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}getEffects(){return this._resolvedEffects}_setEffects(e){const i={};for(const o of this.effects)i[o.id]=o;const r=[];for(const o of e){const h=i[o.id];let d=o;h&&h!==o?h.setProps?(h.setProps(o.props),d=h):h.cleanup(this._context):h||o.setup(this._context),r.push(d),delete i[o.id]}for(const o in i)i[o].cleanup(this._context);this.effects=r,this._resolvedEffects=r.concat(this._defaultEffects),e.some(o=>o instanceof lP)||this._resolvedEffects.push(IU),this._needsRedraw="effects changed"}finalize(){for(const e of this._resolvedEffects)e.cleanup(this._context);this.effects.length=0,this._resolvedEffects.length=0,this._defaultEffects.length=0}}class CU extends nx{shouldDrawLayer(e){const{operation:i}=e.props;return i.includes("draw")||i.includes("terrain")}}const MU="deckRenderer.renderLayers";class kU{constructor(e){this.device=e,this.layerFilter=null,this.drawPickingColors=!1,this.drawLayersPass=new CU(e),this.pickLayersPass=new uP(e),this.renderCount=0,this._needsRedraw="Initial render",this.renderBuffers=[],this.lastPostProcessEffect=null}setProps(e){this.layerFilter!==e.layerFilter&&(this.layerFilter=e.layerFilter,this._needsRedraw="layerFilter changed"),this.drawPickingColors!==e.drawPickingColors&&(this.drawPickingColors=e.drawPickingColors,this._needsRedraw="drawPickingColors changed")}renderLayers(e){if(!e.viewports.length)return;const i=this.drawPickingColors?this.pickLayersPass:this.drawLayersPass,r={layerFilter:this.layerFilter,isPicking:this.drawPickingColors,...e};r.effects&&this._preRender(r.effects,r);const o=this.lastPostProcessEffect?this.renderBuffers[0]:r.target;this.lastPostProcessEffect&&(r.clearColor=[0,0,0,0],r.clearCanvas=!0);const h=i.render({...r,target:o});r.effects&&this._postRender(r.effects,r),this.renderCount++,Os(MU,this,h,e)}needsRedraw(e={clearRedrawFlags:!1}){const i=this._needsRedraw;return e.clearRedrawFlags&&(this._needsRedraw=!1),i}finalize(){const{renderBuffers:e}=this;for(const i of e)i.delete();e.length=0}_preRender(e,i){this.lastPostProcessEffect=null,i.preRenderStats=i.preRenderStats||{};for(const r of e)i.preRenderStats[r.id]=r.preRender(i),r.postRender&&(this.lastPostProcessEffect=r.id);this.lastPostProcessEffect&&this._resizeRenderBuffers()}_resizeRenderBuffers(){const{renderBuffers:e}=this,i=this.device.canvasContext.getDrawingBufferSize();e.length===0&&[0,1].map(r=>{const o=this.device.createTexture({sampler:{minFilter:"linear",magFilter:"linear"}});e.push(this.device.createFramebuffer({id:`deck-renderbuffer-${r}`,colorAttachments:[o]}))});for(const r of e)r.resize(i)}_postRender(e,i){const{renderBuffers:r}=this,o={...i,inputBuffer:r[0],swapBuffer:r[1]};for(const h of e)if(h.postRender){o.target=h.id===this.lastPostProcessEffect?i.target:void 0;const d=h.postRender(o);o.inputBuffer=d,o.swapBuffer=d===r[0]?r[1]:r[0]}}}const DU={pickedColor:null,pickedObjectIndex:-1};function OU({pickedColors:t,decodePickingColor:e,deviceX:i,deviceY:r,deviceRadius:o,deviceRect:h}){const{x:d,y:c,width:x,height:S}=h;let P=o*o,M=-1,D=0;for(let H=0;HP)D+=4*x;else for(let _e=0;_e=0){const be=_e+d-i,Se=be*be+G;Se<=P&&(P=Se,M=D)}D+=4}}if(M>=0){const H=t.slice(M,M+4),Q=e(H);if(Q){const G=Math.floor(M/4/x),_e=M/4-G*x;return{...Q,pickedColor:H,pickedX:d+_e,pickedY:c+G}}Ni.error("Picked non-existent layer. Is picking buffer corrupt?")()}return DU}function FU({pickedColors:t,decodePickingColor:e}){const i=new Map;if(t){for(let r=0;r=0){const h=t.slice(r,r+4),d=h.join(",");if(!i.has(d)){const c=e(h);c?i.set(d,{...c,color:h}):Ni.error("Picked non-existent layer. Is picking buffer corrupt?")()}}}return Array.from(i.values())}function pP({pickInfo:t,viewports:e,pixelRatio:i,x:r,y:o,z:h}){let d=e[0];e.length>1&&(d=BU((t==null?void 0:t.pickedViewports)||e,{x:r,y:o}));let c;if(d){const x=[r-d.x,o-d.y];h!==void 0&&(x[2]=h),c=d.unproject(x)}return{color:null,layer:null,viewport:d,index:-1,picked:!1,x:r,y:o,pixel:[r,o],coordinate:c,devicePixel:t&&"pickedX"in t?[t.pickedX,t.pickedY]:void 0,pixelRatio:i}}function NU(t){const{pickInfo:e,lastPickedInfo:i,mode:r,layers:o}=t,{pickedColor:h,pickedLayer:d,pickedObjectIndex:c}=e,x=d?[d]:[];if(r==="hover"){const M=i.index,D=i.layerId,H=d?d.props.id:null;if(H!==D||c!==M){if(H!==D){const Q=o.find(G=>G.props.id===D);Q&&x.unshift(Q)}i.layerId=H,i.index=c,i.info=null}}const S=pP(t),P=new Map;return P.set(null,S),x.forEach(M=>{let D={...S};M===d&&(D.color=h,D.index=c,D.picked=!0),D=_P({layer:M,info:D,mode:r});const H=D.layer;M===d&&r==="hover"&&(i.info=D),P.set(H.id,D),r==="hover"&&H.updateAutoHighlight(D)}),P}function _P({layer:t,info:e,mode:i}){for(;t&&e;){const r=e.layer||null;e.sourceLayer=r,e.layer=t,e=t.getPickingInfo({info:e,mode:i,sourceLayer:r}),t=t.parent}return e}function BU(t,e){for(let i=t.length-1;i>=0;i--){const r=t[i];if(r.containsPixel(e))return r}return t[0]}class zU{constructor(e){this._pickable=!0,this.device=e,this.pickLayersPass=new uP(e),this.lastPickedInfo={index:-1,layerId:null,info:null}}setProps(e){"layerFilter"in e&&(this.layerFilter=e.layerFilter),"_pickable"in e&&(this._pickable=e._pickable)}finalize(){this.pickingFBO&&this.pickingFBO.destroy(),this.depthFBO&&this.depthFBO.destroy()}pickObject(e){return this._pickClosestObject(e)}pickObjects(e){return this._pickVisibleObjects(e)}getLastPickedObject({x:e,y:i,layers:r,viewports:o},h=this.lastPickedInfo.info){const d=h&&h.layer&&h.layer.id,c=h&&h.viewport&&h.viewport.id,x=d?r.find(D=>D.id===d):null,S=c&&o.find(D=>D.id===c)||o[0],P=S&&S.unproject([e-S.x,i-S.y]);return{...h,...{x:e,y:i,viewport:S,coordinate:P,layer:x}}}_resizeBuffer(){var i,r;if(!this.pickingFBO&&(this.pickingFBO=this.device.createFramebuffer({colorAttachments:["rgba8unorm"],depthStencilAttachment:"depth16unorm"}),this.device.isTextureFormatRenderable("rgba32float"))){const o=this.device.createFramebuffer({colorAttachments:["rgba32float"],depthStencilAttachment:"depth16unorm"});this.depthFBO=o}const{canvas:e}=this.device.getCanvasContext();(i=this.pickingFBO)==null||i.resize({width:e.width,height:e.height}),(r=this.depthFBO)==null||r.resize({width:e.width,height:e.height})}_getPickable(e){if(this._pickable===!1)return null;const i=e.filter(r=>this.pickLayersPass.shouldDrawLayer(r)&&!r.isComposite);return i.length?i:null}_pickClosestObject({layers:e,views:i,viewports:r,x:o,y:h,radius:d=0,depth:c=1,mode:x="query",unproject3D:S,onViewportActive:P,effects:M}){const D=this.device.canvasContext.cssToDeviceRatio(),H=this._getPickable(e);if(!H||r.length===0)return{result:[],emptyInfo:pP({viewports:r,x:o,y:h,pixelRatio:D})};this._resizeBuffer();const Q=this.device.canvasContext.cssToDevicePixels([o,h],!0),G=[Q.x+Math.floor(Q.width/2),Q.y+Math.floor(Q.height/2)],_e=Math.round(d*D),{width:ve,height:be}=this.pickingFBO,Se=this._getPickingRect({deviceX:G[0],deviceY:G[1],deviceRadius:_e,deviceWidth:ve,deviceHeight:be}),Be={x:o-d,y:h-d,width:d*2+1,height:d*2+1};let je;const Fe=[],rt=new Set;for(let vt=0;vt=S);Pt++){const ut=Fe[Pt];let ti={color:ut.pickedColor,layer:null,index:ut.pickedObjectIndex,picked:!0,x:o,y:h,pixelRatio:H};ti=_P({layer:ut.pickedLayer,info:ti,mode:x});const Ft=ti.layer.id;rt.has(Ft)||rt.set(Ft,new Set);const Dt=rt.get(Ft),Ji=ti.object??ti.index;Dt.has(Ji)||(Dt.add(Ji),vt.push(ti))}return vt}_drawAndSample({layers:e,views:i,viewports:r,onViewportActive:o,deviceRect:h,cullRect:d,effects:c,pass:x},S=!1){const P=S?this.depthFBO:this.pickingFBO,M={layers:e,layerFilter:this.layerFilter,views:i,viewports:r,onViewportActive:o,pickingFBO:P,deviceRect:h,cullRect:d,effects:c,pass:x,pickZ:S,preRenderStats:{}};for(const be of c)be.useInPicking&&(M.preRenderStats[be.id]=be.preRender(M));const{decodePickingColor:D}=this.pickLayersPass.render(M),{x:H,y:Q,width:G,height:_e}=h,ve=new(S?Float32Array:Uint8Array)(G*_e*4);return this.device.readPixelsToArrayWebGL(P,{sourceX:H,sourceY:Q,sourceWidth:G,sourceHeight:_e,target:ve}),{pickedColors:ve,decodePickingColor:D}}_getPickingRect({deviceX:e,deviceY:i,deviceRadius:r,deviceWidth:o,deviceHeight:h}){const d=Math.max(0,e-r),c=Math.max(0,i-r),x=Math.min(o,e+r+1)-d,S=Math.min(h,i+r+1)-c;return x<=0||S<=0?null:{x:d,y:c,width:x,height:S}}}const LU={"top-left":{top:0,left:0},"top-right":{top:0,right:0},"bottom-left":{bottom:0,left:0},"bottom-right":{bottom:0,right:0},fill:{top:0,left:0,bottom:0,right:0}},UU="top-left",_E="__root";class VU{constructor({deck:e,parentElement:i}){this.defaultWidgets=[],this.widgets=[],this.resolvedWidgets=[],this.containers={},this.lastViewports={},this.deck=e,this.parentElement=i}getWidgets(){return this.resolvedWidgets}setProps(e){e.widgets&&!xn(e.widgets,this.widgets,1)&&this._setWidgets(e.widgets)}finalize(){for(const e of this.getWidgets())this._remove(e);this.defaultWidgets.length=0,this.resolvedWidgets.length=0;for(const e in this.containers)this.containers[e].remove()}addDefault(e){this.defaultWidgets.find(i=>i.id===e.id)||(this._add(e),this.defaultWidgets.push(e),this._setWidgets(this.widgets))}_setWidgets(e){const i={};for(const r of this.resolvedWidgets)i[r.id]=r;this.resolvedWidgets.length=0;for(const r of this.defaultWidgets)i[r.id]=null,this.resolvedWidgets.push(r);for(let r of e){const o=i[r.id];o?o.viewId!==r.viewId||o.placement!==r.placement?(this._remove(o),this._add(r)):r!==o&&(o.setProps(r.props),r=o):this._add(r),i[r.id]=null,this.resolvedWidgets.push(r)}for(const r in i){const o=i[r];o&&this._remove(o)}this.widgets=e}_add(e){const{viewId:i=null,placement:r=UU}=e,o=e.onAdd({deck:this.deck,viewId:i});o&&this._getContainer(i,r).append(o),e._element=o}_remove(e){e.onRemove(),e._element&&e._element.remove(),e._element=void 0}_getContainer(e,i){var d;const r=e||_E;let o=this.containers[r];o||(o=document.createElement("div"),o.style.pointerEvents="none",o.style.position="absolute",o.style.overflow="hidden",(d=this.parentElement)==null||d.append(o),this.containers[r]=o);let h=o.querySelector(`.${i}`);return h||(h=document.createElement("div"),h.className=i,h.style.position="absolute",h.style.zIndex="2",Object.assign(h.style,LU[i]),o.append(h)),h}_updateContainers(){const e=this.deck.width,i=this.deck.height;for(const r in this.containers){const o=this.lastViewports[r]||null,h=r===_E||o,d=this.containers[r];h?(d.style.display="block",d.style.left=`${o?o.x:0}px`,d.style.top=`${o?o.y:0}px`,d.style.width=`${o?o.width:e}px`,d.style.height=`${o?o.height:i}px`):d.style.display="none"}}onRedraw({viewports:e,layers:i}){var h,d;const r=e.reduce((c,x)=>(c[x.id]=x,c),{}),{lastViewports:o}=this;for(const c of this.getWidgets()){const{viewId:x}=c;if(x){const S=r[x];S&&(c.onViewportChange&&!S.equals(o[x])&&c.onViewportChange(S),(h=c.onRedraw)==null||h.call(c,{viewports:[S],layers:i}))}else{if(c.onViewportChange)for(const S of e)S.equals(o[S.id])||c.onViewportChange(S);(d=c.onRedraw)==null||d.call(c,{viewports:e,layers:i})}}this.lastViewports=r,this._updateContainers()}onHover(e,i){var r,o;for(const h of this.getWidgets()){const{viewId:d}=h;(!d||d===((r=e.viewport)==null?void 0:r.id))&&((o=h.onHover)==null||o.call(h,e,i))}}onEvent(e,i){var o,h;const r=Xb[i.type];if(r)for(const d of this.getWidgets()){const{viewId:c}=d;(!c||c===((o=e.viewport)==null?void 0:o.id))&&((h=d[r.handler])==null||h.call(d,e,i))}}}const jU={zIndex:"1",position:"absolute",pointerEvents:"none",color:"#a0a7b4",backgroundColor:"#29323c",padding:"10px",top:"0",left:"0",display:"none"};class $U{constructor(){this.id="default-tooltip",this.placement="fill",this.props={},this.isVisible=!1}onAdd({deck:e}){const i=document.createElement("div");return i.className="deck-tooltip",Object.assign(i.style,jU),this.deck=e,this.element=i,i}onRemove(){this.deck=void 0,this.element=void 0}setProps(){}onViewportChange(e){var i;this.isVisible&&e.id===((i=this.lastViewport)==null?void 0:i.id)&&e!==this.lastViewport&&this.setTooltip(null)}onHover(e){const{deck:i}=this,r=i&&i.props.getTooltip;if(!r)return;const o=r(e);this.lastViewport=e.viewport,this.setTooltip(o,e.x,e.y)}setTooltip(e,i,r){const o=this.element;if(o){if(typeof e=="string")o.innerText=e;else if(e)e.text&&(o.innerText=e.text),e.html&&(o.innerHTML=e.html),e.className&&(o.className=e.className);else{this.isVisible=!1,o.style.display="none";return}this.isVisible=!0,o.style.display="block",o.style.transform=`translate(${i}px, ${r}px)`,e&&typeof e=="object"&&"style"in e&&Object.assign(o.style,e.style)}}}var Wh;(function(t){t[t.DEPTH_BUFFER_BIT=256]="DEPTH_BUFFER_BIT",t[t.STENCIL_BUFFER_BIT=1024]="STENCIL_BUFFER_BIT",t[t.COLOR_BUFFER_BIT=16384]="COLOR_BUFFER_BIT",t[t.POINTS=0]="POINTS",t[t.LINES=1]="LINES",t[t.LINE_LOOP=2]="LINE_LOOP",t[t.LINE_STRIP=3]="LINE_STRIP",t[t.TRIANGLES=4]="TRIANGLES",t[t.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",t[t.TRIANGLE_FAN=6]="TRIANGLE_FAN",t[t.ZERO=0]="ZERO",t[t.ONE=1]="ONE",t[t.SRC_COLOR=768]="SRC_COLOR",t[t.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",t[t.SRC_ALPHA=770]="SRC_ALPHA",t[t.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",t[t.DST_ALPHA=772]="DST_ALPHA",t[t.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",t[t.DST_COLOR=774]="DST_COLOR",t[t.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",t[t.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",t[t.CONSTANT_COLOR=32769]="CONSTANT_COLOR",t[t.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",t[t.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",t[t.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",t[t.FUNC_ADD=32774]="FUNC_ADD",t[t.FUNC_SUBTRACT=32778]="FUNC_SUBTRACT",t[t.FUNC_REVERSE_SUBTRACT=32779]="FUNC_REVERSE_SUBTRACT",t[t.BLEND_EQUATION=32777]="BLEND_EQUATION",t[t.BLEND_EQUATION_RGB=32777]="BLEND_EQUATION_RGB",t[t.BLEND_EQUATION_ALPHA=34877]="BLEND_EQUATION_ALPHA",t[t.BLEND_DST_RGB=32968]="BLEND_DST_RGB",t[t.BLEND_SRC_RGB=32969]="BLEND_SRC_RGB",t[t.BLEND_DST_ALPHA=32970]="BLEND_DST_ALPHA",t[t.BLEND_SRC_ALPHA=32971]="BLEND_SRC_ALPHA",t[t.BLEND_COLOR=32773]="BLEND_COLOR",t[t.ARRAY_BUFFER_BINDING=34964]="ARRAY_BUFFER_BINDING",t[t.ELEMENT_ARRAY_BUFFER_BINDING=34965]="ELEMENT_ARRAY_BUFFER_BINDING",t[t.LINE_WIDTH=2849]="LINE_WIDTH",t[t.ALIASED_POINT_SIZE_RANGE=33901]="ALIASED_POINT_SIZE_RANGE",t[t.ALIASED_LINE_WIDTH_RANGE=33902]="ALIASED_LINE_WIDTH_RANGE",t[t.CULL_FACE_MODE=2885]="CULL_FACE_MODE",t[t.FRONT_FACE=2886]="FRONT_FACE",t[t.DEPTH_RANGE=2928]="DEPTH_RANGE",t[t.DEPTH_WRITEMASK=2930]="DEPTH_WRITEMASK",t[t.DEPTH_CLEAR_VALUE=2931]="DEPTH_CLEAR_VALUE",t[t.DEPTH_FUNC=2932]="DEPTH_FUNC",t[t.STENCIL_CLEAR_VALUE=2961]="STENCIL_CLEAR_VALUE",t[t.STENCIL_FUNC=2962]="STENCIL_FUNC",t[t.STENCIL_FAIL=2964]="STENCIL_FAIL",t[t.STENCIL_PASS_DEPTH_FAIL=2965]="STENCIL_PASS_DEPTH_FAIL",t[t.STENCIL_PASS_DEPTH_PASS=2966]="STENCIL_PASS_DEPTH_PASS",t[t.STENCIL_REF=2967]="STENCIL_REF",t[t.STENCIL_VALUE_MASK=2963]="STENCIL_VALUE_MASK",t[t.STENCIL_WRITEMASK=2968]="STENCIL_WRITEMASK",t[t.STENCIL_BACK_FUNC=34816]="STENCIL_BACK_FUNC",t[t.STENCIL_BACK_FAIL=34817]="STENCIL_BACK_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_FAIL=34818]="STENCIL_BACK_PASS_DEPTH_FAIL",t[t.STENCIL_BACK_PASS_DEPTH_PASS=34819]="STENCIL_BACK_PASS_DEPTH_PASS",t[t.STENCIL_BACK_REF=36003]="STENCIL_BACK_REF",t[t.STENCIL_BACK_VALUE_MASK=36004]="STENCIL_BACK_VALUE_MASK",t[t.STENCIL_BACK_WRITEMASK=36005]="STENCIL_BACK_WRITEMASK",t[t.VIEWPORT=2978]="VIEWPORT",t[t.SCISSOR_BOX=3088]="SCISSOR_BOX",t[t.COLOR_CLEAR_VALUE=3106]="COLOR_CLEAR_VALUE",t[t.COLOR_WRITEMASK=3107]="COLOR_WRITEMASK",t[t.UNPACK_ALIGNMENT=3317]="UNPACK_ALIGNMENT",t[t.PACK_ALIGNMENT=3333]="PACK_ALIGNMENT",t[t.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE",t[t.MAX_VIEWPORT_DIMS=3386]="MAX_VIEWPORT_DIMS",t[t.SUBPIXEL_BITS=3408]="SUBPIXEL_BITS",t[t.RED_BITS=3410]="RED_BITS",t[t.GREEN_BITS=3411]="GREEN_BITS",t[t.BLUE_BITS=3412]="BLUE_BITS",t[t.ALPHA_BITS=3413]="ALPHA_BITS",t[t.DEPTH_BITS=3414]="DEPTH_BITS",t[t.STENCIL_BITS=3415]="STENCIL_BITS",t[t.POLYGON_OFFSET_UNITS=10752]="POLYGON_OFFSET_UNITS",t[t.POLYGON_OFFSET_FACTOR=32824]="POLYGON_OFFSET_FACTOR",t[t.TEXTURE_BINDING_2D=32873]="TEXTURE_BINDING_2D",t[t.SAMPLE_BUFFERS=32936]="SAMPLE_BUFFERS",t[t.SAMPLES=32937]="SAMPLES",t[t.SAMPLE_COVERAGE_VALUE=32938]="SAMPLE_COVERAGE_VALUE",t[t.SAMPLE_COVERAGE_INVERT=32939]="SAMPLE_COVERAGE_INVERT",t[t.COMPRESSED_TEXTURE_FORMATS=34467]="COMPRESSED_TEXTURE_FORMATS",t[t.VENDOR=7936]="VENDOR",t[t.RENDERER=7937]="RENDERER",t[t.VERSION=7938]="VERSION",t[t.IMPLEMENTATION_COLOR_READ_TYPE=35738]="IMPLEMENTATION_COLOR_READ_TYPE",t[t.IMPLEMENTATION_COLOR_READ_FORMAT=35739]="IMPLEMENTATION_COLOR_READ_FORMAT",t[t.BROWSER_DEFAULT_WEBGL=37444]="BROWSER_DEFAULT_WEBGL",t[t.STATIC_DRAW=35044]="STATIC_DRAW",t[t.STREAM_DRAW=35040]="STREAM_DRAW",t[t.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.BUFFER_SIZE=34660]="BUFFER_SIZE",t[t.BUFFER_USAGE=34661]="BUFFER_USAGE",t[t.CURRENT_VERTEX_ATTRIB=34342]="CURRENT_VERTEX_ATTRIB",t[t.VERTEX_ATTRIB_ARRAY_ENABLED=34338]="VERTEX_ATTRIB_ARRAY_ENABLED",t[t.VERTEX_ATTRIB_ARRAY_SIZE=34339]="VERTEX_ATTRIB_ARRAY_SIZE",t[t.VERTEX_ATTRIB_ARRAY_STRIDE=34340]="VERTEX_ATTRIB_ARRAY_STRIDE",t[t.VERTEX_ATTRIB_ARRAY_TYPE=34341]="VERTEX_ATTRIB_ARRAY_TYPE",t[t.VERTEX_ATTRIB_ARRAY_NORMALIZED=34922]="VERTEX_ATTRIB_ARRAY_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_POINTER=34373]="VERTEX_ATTRIB_ARRAY_POINTER",t[t.VERTEX_ATTRIB_ARRAY_BUFFER_BINDING=34975]="VERTEX_ATTRIB_ARRAY_BUFFER_BINDING",t[t.CULL_FACE=2884]="CULL_FACE",t[t.FRONT=1028]="FRONT",t[t.BACK=1029]="BACK",t[t.FRONT_AND_BACK=1032]="FRONT_AND_BACK",t[t.BLEND=3042]="BLEND",t[t.DEPTH_TEST=2929]="DEPTH_TEST",t[t.DITHER=3024]="DITHER",t[t.POLYGON_OFFSET_FILL=32823]="POLYGON_OFFSET_FILL",t[t.SAMPLE_ALPHA_TO_COVERAGE=32926]="SAMPLE_ALPHA_TO_COVERAGE",t[t.SAMPLE_COVERAGE=32928]="SAMPLE_COVERAGE",t[t.SCISSOR_TEST=3089]="SCISSOR_TEST",t[t.STENCIL_TEST=2960]="STENCIL_TEST",t[t.NO_ERROR=0]="NO_ERROR",t[t.INVALID_ENUM=1280]="INVALID_ENUM",t[t.INVALID_VALUE=1281]="INVALID_VALUE",t[t.INVALID_OPERATION=1282]="INVALID_OPERATION",t[t.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",t[t.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL",t[t.CW=2304]="CW",t[t.CCW=2305]="CCW",t[t.DONT_CARE=4352]="DONT_CARE",t[t.FASTEST=4353]="FASTEST",t[t.NICEST=4354]="NICEST",t[t.GENERATE_MIPMAP_HINT=33170]="GENERATE_MIPMAP_HINT",t[t.BYTE=5120]="BYTE",t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.SHORT=5122]="SHORT",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.INT=5124]="INT",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.FLOAT=5126]="FLOAT",t[t.DOUBLE=5130]="DOUBLE",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.ALPHA=6406]="ALPHA",t[t.RGB=6407]="RGB",t[t.RGBA=6408]="RGBA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",t[t.VERTEX_SHADER=35633]="VERTEX_SHADER",t[t.COMPILE_STATUS=35713]="COMPILE_STATUS",t[t.DELETE_STATUS=35712]="DELETE_STATUS",t[t.LINK_STATUS=35714]="LINK_STATUS",t[t.VALIDATE_STATUS=35715]="VALIDATE_STATUS",t[t.ATTACHED_SHADERS=35717]="ATTACHED_SHADERS",t[t.ACTIVE_ATTRIBUTES=35721]="ACTIVE_ATTRIBUTES",t[t.ACTIVE_UNIFORMS=35718]="ACTIVE_UNIFORMS",t[t.MAX_VERTEX_ATTRIBS=34921]="MAX_VERTEX_ATTRIBS",t[t.MAX_VERTEX_UNIFORM_VECTORS=36347]="MAX_VERTEX_UNIFORM_VECTORS",t[t.MAX_VARYING_VECTORS=36348]="MAX_VARYING_VECTORS",t[t.MAX_COMBINED_TEXTURE_IMAGE_UNITS=35661]="MAX_COMBINED_TEXTURE_IMAGE_UNITS",t[t.MAX_VERTEX_TEXTURE_IMAGE_UNITS=35660]="MAX_VERTEX_TEXTURE_IMAGE_UNITS",t[t.MAX_TEXTURE_IMAGE_UNITS=34930]="MAX_TEXTURE_IMAGE_UNITS",t[t.MAX_FRAGMENT_UNIFORM_VECTORS=36349]="MAX_FRAGMENT_UNIFORM_VECTORS",t[t.SHADER_TYPE=35663]="SHADER_TYPE",t[t.SHADING_LANGUAGE_VERSION=35724]="SHADING_LANGUAGE_VERSION",t[t.CURRENT_PROGRAM=35725]="CURRENT_PROGRAM",t[t.NEVER=512]="NEVER",t[t.LESS=513]="LESS",t[t.EQUAL=514]="EQUAL",t[t.LEQUAL=515]="LEQUAL",t[t.GREATER=516]="GREATER",t[t.NOTEQUAL=517]="NOTEQUAL",t[t.GEQUAL=518]="GEQUAL",t[t.ALWAYS=519]="ALWAYS",t[t.KEEP=7680]="KEEP",t[t.REPLACE=7681]="REPLACE",t[t.INCR=7682]="INCR",t[t.DECR=7683]="DECR",t[t.INVERT=5386]="INVERT",t[t.INCR_WRAP=34055]="INCR_WRAP",t[t.DECR_WRAP=34056]="DECR_WRAP",t[t.NEAREST=9728]="NEAREST",t[t.LINEAR=9729]="LINEAR",t[t.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",t[t.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",t[t.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",t[t.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR",t[t.TEXTURE_MAG_FILTER=10240]="TEXTURE_MAG_FILTER",t[t.TEXTURE_MIN_FILTER=10241]="TEXTURE_MIN_FILTER",t[t.TEXTURE_WRAP_S=10242]="TEXTURE_WRAP_S",t[t.TEXTURE_WRAP_T=10243]="TEXTURE_WRAP_T",t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE=5890]="TEXTURE",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_BINDING_CUBE_MAP=34068]="TEXTURE_BINDING_CUBE_MAP",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t[t.MAX_CUBE_MAP_TEXTURE_SIZE=34076]="MAX_CUBE_MAP_TEXTURE_SIZE",t[t.TEXTURE0=33984]="TEXTURE0",t[t.ACTIVE_TEXTURE=34016]="ACTIVE_TEXTURE",t[t.REPEAT=10497]="REPEAT",t[t.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",t[t.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",t[t.TEXTURE_WIDTH=4096]="TEXTURE_WIDTH",t[t.TEXTURE_HEIGHT=4097]="TEXTURE_HEIGHT",t[t.FLOAT_VEC2=35664]="FLOAT_VEC2",t[t.FLOAT_VEC3=35665]="FLOAT_VEC3",t[t.FLOAT_VEC4=35666]="FLOAT_VEC4",t[t.INT_VEC2=35667]="INT_VEC2",t[t.INT_VEC3=35668]="INT_VEC3",t[t.INT_VEC4=35669]="INT_VEC4",t[t.BOOL=35670]="BOOL",t[t.BOOL_VEC2=35671]="BOOL_VEC2",t[t.BOOL_VEC3=35672]="BOOL_VEC3",t[t.BOOL_VEC4=35673]="BOOL_VEC4",t[t.FLOAT_MAT2=35674]="FLOAT_MAT2",t[t.FLOAT_MAT3=35675]="FLOAT_MAT3",t[t.FLOAT_MAT4=35676]="FLOAT_MAT4",t[t.SAMPLER_2D=35678]="SAMPLER_2D",t[t.SAMPLER_CUBE=35680]="SAMPLER_CUBE",t[t.LOW_FLOAT=36336]="LOW_FLOAT",t[t.MEDIUM_FLOAT=36337]="MEDIUM_FLOAT",t[t.HIGH_FLOAT=36338]="HIGH_FLOAT",t[t.LOW_INT=36339]="LOW_INT",t[t.MEDIUM_INT=36340]="MEDIUM_INT",t[t.HIGH_INT=36341]="HIGH_INT",t[t.FRAMEBUFFER=36160]="FRAMEBUFFER",t[t.RENDERBUFFER=36161]="RENDERBUFFER",t[t.RGBA4=32854]="RGBA4",t[t.RGB5_A1=32855]="RGB5_A1",t[t.RGB565=36194]="RGB565",t[t.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",t[t.STENCIL_INDEX=6401]="STENCIL_INDEX",t[t.STENCIL_INDEX8=36168]="STENCIL_INDEX8",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t[t.RENDERBUFFER_WIDTH=36162]="RENDERBUFFER_WIDTH",t[t.RENDERBUFFER_HEIGHT=36163]="RENDERBUFFER_HEIGHT",t[t.RENDERBUFFER_INTERNAL_FORMAT=36164]="RENDERBUFFER_INTERNAL_FORMAT",t[t.RENDERBUFFER_RED_SIZE=36176]="RENDERBUFFER_RED_SIZE",t[t.RENDERBUFFER_GREEN_SIZE=36177]="RENDERBUFFER_GREEN_SIZE",t[t.RENDERBUFFER_BLUE_SIZE=36178]="RENDERBUFFER_BLUE_SIZE",t[t.RENDERBUFFER_ALPHA_SIZE=36179]="RENDERBUFFER_ALPHA_SIZE",t[t.RENDERBUFFER_DEPTH_SIZE=36180]="RENDERBUFFER_DEPTH_SIZE",t[t.RENDERBUFFER_STENCIL_SIZE=36181]="RENDERBUFFER_STENCIL_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE=36048]="FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_OBJECT_NAME=36049]="FRAMEBUFFER_ATTACHMENT_OBJECT_NAME",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL=36050]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE=36051]="FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE",t[t.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",t[t.DEPTH_ATTACHMENT=36096]="DEPTH_ATTACHMENT",t[t.STENCIL_ATTACHMENT=36128]="STENCIL_ATTACHMENT",t[t.DEPTH_STENCIL_ATTACHMENT=33306]="DEPTH_STENCIL_ATTACHMENT",t[t.NONE=0]="NONE",t[t.FRAMEBUFFER_COMPLETE=36053]="FRAMEBUFFER_COMPLETE",t[t.FRAMEBUFFER_INCOMPLETE_ATTACHMENT=36054]="FRAMEBUFFER_INCOMPLETE_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT=36055]="FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT",t[t.FRAMEBUFFER_INCOMPLETE_DIMENSIONS=36057]="FRAMEBUFFER_INCOMPLETE_DIMENSIONS",t[t.FRAMEBUFFER_UNSUPPORTED=36061]="FRAMEBUFFER_UNSUPPORTED",t[t.FRAMEBUFFER_BINDING=36006]="FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_BINDING=36007]="RENDERBUFFER_BINDING",t[t.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",t[t.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER",t[t.MAX_RENDERBUFFER_SIZE=34024]="MAX_RENDERBUFFER_SIZE",t[t.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",t[t.UNPACK_FLIP_Y_WEBGL=37440]="UNPACK_FLIP_Y_WEBGL",t[t.UNPACK_PREMULTIPLY_ALPHA_WEBGL=37441]="UNPACK_PREMULTIPLY_ALPHA_WEBGL",t[t.UNPACK_COLORSPACE_CONVERSION_WEBGL=37443]="UNPACK_COLORSPACE_CONVERSION_WEBGL",t[t.READ_BUFFER=3074]="READ_BUFFER",t[t.UNPACK_ROW_LENGTH=3314]="UNPACK_ROW_LENGTH",t[t.UNPACK_SKIP_ROWS=3315]="UNPACK_SKIP_ROWS",t[t.UNPACK_SKIP_PIXELS=3316]="UNPACK_SKIP_PIXELS",t[t.PACK_ROW_LENGTH=3330]="PACK_ROW_LENGTH",t[t.PACK_SKIP_ROWS=3331]="PACK_SKIP_ROWS",t[t.PACK_SKIP_PIXELS=3332]="PACK_SKIP_PIXELS",t[t.TEXTURE_BINDING_3D=32874]="TEXTURE_BINDING_3D",t[t.UNPACK_SKIP_IMAGES=32877]="UNPACK_SKIP_IMAGES",t[t.UNPACK_IMAGE_HEIGHT=32878]="UNPACK_IMAGE_HEIGHT",t[t.MAX_3D_TEXTURE_SIZE=32883]="MAX_3D_TEXTURE_SIZE",t[t.MAX_ELEMENTS_VERTICES=33e3]="MAX_ELEMENTS_VERTICES",t[t.MAX_ELEMENTS_INDICES=33001]="MAX_ELEMENTS_INDICES",t[t.MAX_TEXTURE_LOD_BIAS=34045]="MAX_TEXTURE_LOD_BIAS",t[t.MAX_FRAGMENT_UNIFORM_COMPONENTS=35657]="MAX_FRAGMENT_UNIFORM_COMPONENTS",t[t.MAX_VERTEX_UNIFORM_COMPONENTS=35658]="MAX_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_ARRAY_TEXTURE_LAYERS=35071]="MAX_ARRAY_TEXTURE_LAYERS",t[t.MIN_PROGRAM_TEXEL_OFFSET=35076]="MIN_PROGRAM_TEXEL_OFFSET",t[t.MAX_PROGRAM_TEXEL_OFFSET=35077]="MAX_PROGRAM_TEXEL_OFFSET",t[t.MAX_VARYING_COMPONENTS=35659]="MAX_VARYING_COMPONENTS",t[t.FRAGMENT_SHADER_DERIVATIVE_HINT=35723]="FRAGMENT_SHADER_DERIVATIVE_HINT",t[t.RASTERIZER_DISCARD=35977]="RASTERIZER_DISCARD",t[t.VERTEX_ARRAY_BINDING=34229]="VERTEX_ARRAY_BINDING",t[t.MAX_VERTEX_OUTPUT_COMPONENTS=37154]="MAX_VERTEX_OUTPUT_COMPONENTS",t[t.MAX_FRAGMENT_INPUT_COMPONENTS=37157]="MAX_FRAGMENT_INPUT_COMPONENTS",t[t.MAX_SERVER_WAIT_TIMEOUT=37137]="MAX_SERVER_WAIT_TIMEOUT",t[t.MAX_ELEMENT_INDEX=36203]="MAX_ELEMENT_INDEX",t[t.RED=6403]="RED",t[t.RGB8=32849]="RGB8",t[t.RGBA8=32856]="RGBA8",t[t.RGB10_A2=32857]="RGB10_A2",t[t.TEXTURE_3D=32879]="TEXTURE_3D",t[t.TEXTURE_WRAP_R=32882]="TEXTURE_WRAP_R",t[t.TEXTURE_MIN_LOD=33082]="TEXTURE_MIN_LOD",t[t.TEXTURE_MAX_LOD=33083]="TEXTURE_MAX_LOD",t[t.TEXTURE_BASE_LEVEL=33084]="TEXTURE_BASE_LEVEL",t[t.TEXTURE_MAX_LEVEL=33085]="TEXTURE_MAX_LEVEL",t[t.TEXTURE_COMPARE_MODE=34892]="TEXTURE_COMPARE_MODE",t[t.TEXTURE_COMPARE_FUNC=34893]="TEXTURE_COMPARE_FUNC",t[t.SRGB=35904]="SRGB",t[t.SRGB8=35905]="SRGB8",t[t.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",t[t.COMPARE_REF_TO_TEXTURE=34894]="COMPARE_REF_TO_TEXTURE",t[t.RGBA32F=34836]="RGBA32F",t[t.RGB32F=34837]="RGB32F",t[t.RGBA16F=34842]="RGBA16F",t[t.RGB16F=34843]="RGB16F",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_BINDING_2D_ARRAY=35869]="TEXTURE_BINDING_2D_ARRAY",t[t.R11F_G11F_B10F=35898]="R11F_G11F_B10F",t[t.RGB9_E5=35901]="RGB9_E5",t[t.RGBA32UI=36208]="RGBA32UI",t[t.RGB32UI=36209]="RGB32UI",t[t.RGBA16UI=36214]="RGBA16UI",t[t.RGB16UI=36215]="RGB16UI",t[t.RGBA8UI=36220]="RGBA8UI",t[t.RGB8UI=36221]="RGB8UI",t[t.RGBA32I=36226]="RGBA32I",t[t.RGB32I=36227]="RGB32I",t[t.RGBA16I=36232]="RGBA16I",t[t.RGB16I=36233]="RGB16I",t[t.RGBA8I=36238]="RGBA8I",t[t.RGB8I=36239]="RGB8I",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.R8=33321]="R8",t[t.RG8=33323]="RG8",t[t.R16F=33325]="R16F",t[t.R32F=33326]="R32F",t[t.RG16F=33327]="RG16F",t[t.RG32F=33328]="RG32F",t[t.R8I=33329]="R8I",t[t.R8UI=33330]="R8UI",t[t.R16I=33331]="R16I",t[t.R16UI=33332]="R16UI",t[t.R32I=33333]="R32I",t[t.R32UI=33334]="R32UI",t[t.RG8I=33335]="RG8I",t[t.RG8UI=33336]="RG8UI",t[t.RG16I=33337]="RG16I",t[t.RG16UI=33338]="RG16UI",t[t.RG32I=33339]="RG32I",t[t.RG32UI=33340]="RG32UI",t[t.R8_SNORM=36756]="R8_SNORM",t[t.RG8_SNORM=36757]="RG8_SNORM",t[t.RGB8_SNORM=36758]="RGB8_SNORM",t[t.RGBA8_SNORM=36759]="RGBA8_SNORM",t[t.RGB10_A2UI=36975]="RGB10_A2UI",t[t.TEXTURE_IMMUTABLE_FORMAT=37167]="TEXTURE_IMMUTABLE_FORMAT",t[t.TEXTURE_IMMUTABLE_LEVELS=33503]="TEXTURE_IMMUTABLE_LEVELS",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.HALF_FLOAT=5131]="HALF_FLOAT",t[t.RG=33319]="RG",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.INT_2_10_10_10_REV=36255]="INT_2_10_10_10_REV",t[t.CURRENT_QUERY=34917]="CURRENT_QUERY",t[t.QUERY_RESULT=34918]="QUERY_RESULT",t[t.QUERY_RESULT_AVAILABLE=34919]="QUERY_RESULT_AVAILABLE",t[t.ANY_SAMPLES_PASSED=35887]="ANY_SAMPLES_PASSED",t[t.ANY_SAMPLES_PASSED_CONSERVATIVE=36202]="ANY_SAMPLES_PASSED_CONSERVATIVE",t[t.MAX_DRAW_BUFFERS=34852]="MAX_DRAW_BUFFERS",t[t.DRAW_BUFFER0=34853]="DRAW_BUFFER0",t[t.DRAW_BUFFER1=34854]="DRAW_BUFFER1",t[t.DRAW_BUFFER2=34855]="DRAW_BUFFER2",t[t.DRAW_BUFFER3=34856]="DRAW_BUFFER3",t[t.DRAW_BUFFER4=34857]="DRAW_BUFFER4",t[t.DRAW_BUFFER5=34858]="DRAW_BUFFER5",t[t.DRAW_BUFFER6=34859]="DRAW_BUFFER6",t[t.DRAW_BUFFER7=34860]="DRAW_BUFFER7",t[t.DRAW_BUFFER8=34861]="DRAW_BUFFER8",t[t.DRAW_BUFFER9=34862]="DRAW_BUFFER9",t[t.DRAW_BUFFER10=34863]="DRAW_BUFFER10",t[t.DRAW_BUFFER11=34864]="DRAW_BUFFER11",t[t.DRAW_BUFFER12=34865]="DRAW_BUFFER12",t[t.DRAW_BUFFER13=34866]="DRAW_BUFFER13",t[t.DRAW_BUFFER14=34867]="DRAW_BUFFER14",t[t.DRAW_BUFFER15=34868]="DRAW_BUFFER15",t[t.MAX_COLOR_ATTACHMENTS=36063]="MAX_COLOR_ATTACHMENTS",t[t.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",t[t.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",t[t.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",t[t.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",t[t.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",t[t.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",t[t.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",t[t.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",t[t.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",t[t.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",t[t.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",t[t.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",t[t.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",t[t.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",t[t.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15",t[t.SAMPLER_3D=35679]="SAMPLER_3D",t[t.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",t[t.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",t[t.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",t[t.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",t[t.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",t[t.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",t[t.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",t[t.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",t[t.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",t[t.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",t[t.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",t[t.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY",t[t.MAX_SAMPLES=36183]="MAX_SAMPLES",t[t.SAMPLER_BINDING=35097]="SAMPLER_BINDING",t[t.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",t[t.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",t[t.PIXEL_PACK_BUFFER_BINDING=35053]="PIXEL_PACK_BUFFER_BINDING",t[t.PIXEL_UNPACK_BUFFER_BINDING=35055]="PIXEL_UNPACK_BUFFER_BINDING",t[t.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",t[t.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",t[t.COPY_READ_BUFFER_BINDING=36662]="COPY_READ_BUFFER_BINDING",t[t.COPY_WRITE_BUFFER_BINDING=36663]="COPY_WRITE_BUFFER_BINDING",t[t.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",t[t.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",t[t.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",t[t.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",t[t.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",t[t.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",t[t.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",t[t.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",t[t.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",t[t.UNSIGNED_NORMALIZED=35863]="UNSIGNED_NORMALIZED",t[t.SIGNED_NORMALIZED=36764]="SIGNED_NORMALIZED",t[t.VERTEX_ATTRIB_ARRAY_INTEGER=35069]="VERTEX_ATTRIB_ARRAY_INTEGER",t[t.VERTEX_ATTRIB_ARRAY_DIVISOR=35070]="VERTEX_ATTRIB_ARRAY_DIVISOR",t[t.TRANSFORM_FEEDBACK_BUFFER_MODE=35967]="TRANSFORM_FEEDBACK_BUFFER_MODE",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS=35968]="MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS",t[t.TRANSFORM_FEEDBACK_VARYINGS=35971]="TRANSFORM_FEEDBACK_VARYINGS",t[t.TRANSFORM_FEEDBACK_BUFFER_START=35972]="TRANSFORM_FEEDBACK_BUFFER_START",t[t.TRANSFORM_FEEDBACK_BUFFER_SIZE=35973]="TRANSFORM_FEEDBACK_BUFFER_SIZE",t[t.TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN=35976]="TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN",t[t.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS=35978]="MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS",t[t.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS=35979]="MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS",t[t.INTERLEAVED_ATTRIBS=35980]="INTERLEAVED_ATTRIBS",t[t.SEPARATE_ATTRIBS=35981]="SEPARATE_ATTRIBS",t[t.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER",t[t.TRANSFORM_FEEDBACK_BUFFER_BINDING=35983]="TRANSFORM_FEEDBACK_BUFFER_BINDING",t[t.TRANSFORM_FEEDBACK=36386]="TRANSFORM_FEEDBACK",t[t.TRANSFORM_FEEDBACK_PAUSED=36387]="TRANSFORM_FEEDBACK_PAUSED",t[t.TRANSFORM_FEEDBACK_ACTIVE=36388]="TRANSFORM_FEEDBACK_ACTIVE",t[t.TRANSFORM_FEEDBACK_BINDING=36389]="TRANSFORM_FEEDBACK_BINDING",t[t.FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING=33296]="FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING",t[t.FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE=33297]="FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE",t[t.FRAMEBUFFER_ATTACHMENT_RED_SIZE=33298]="FRAMEBUFFER_ATTACHMENT_RED_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_GREEN_SIZE=33299]="FRAMEBUFFER_ATTACHMENT_GREEN_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_BLUE_SIZE=33300]="FRAMEBUFFER_ATTACHMENT_BLUE_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE=33301]="FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE=33302]="FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE",t[t.FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE=33303]="FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE",t[t.FRAMEBUFFER_DEFAULT=33304]="FRAMEBUFFER_DEFAULT",t[t.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",t[t.DRAW_FRAMEBUFFER_BINDING=36006]="DRAW_FRAMEBUFFER_BINDING",t[t.READ_FRAMEBUFFER_BINDING=36010]="READ_FRAMEBUFFER_BINDING",t[t.RENDERBUFFER_SAMPLES=36011]="RENDERBUFFER_SAMPLES",t[t.FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER=36052]="FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER",t[t.FRAMEBUFFER_INCOMPLETE_MULTISAMPLE=36182]="FRAMEBUFFER_INCOMPLETE_MULTISAMPLE",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t[t.UNIFORM_BUFFER_BINDING=35368]="UNIFORM_BUFFER_BINDING",t[t.UNIFORM_BUFFER_START=35369]="UNIFORM_BUFFER_START",t[t.UNIFORM_BUFFER_SIZE=35370]="UNIFORM_BUFFER_SIZE",t[t.MAX_VERTEX_UNIFORM_BLOCKS=35371]="MAX_VERTEX_UNIFORM_BLOCKS",t[t.MAX_FRAGMENT_UNIFORM_BLOCKS=35373]="MAX_FRAGMENT_UNIFORM_BLOCKS",t[t.MAX_COMBINED_UNIFORM_BLOCKS=35374]="MAX_COMBINED_UNIFORM_BLOCKS",t[t.MAX_UNIFORM_BUFFER_BINDINGS=35375]="MAX_UNIFORM_BUFFER_BINDINGS",t[t.MAX_UNIFORM_BLOCK_SIZE=35376]="MAX_UNIFORM_BLOCK_SIZE",t[t.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS=35377]="MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS",t[t.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS=35379]="MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS",t[t.UNIFORM_BUFFER_OFFSET_ALIGNMENT=35380]="UNIFORM_BUFFER_OFFSET_ALIGNMENT",t[t.ACTIVE_UNIFORM_BLOCKS=35382]="ACTIVE_UNIFORM_BLOCKS",t[t.UNIFORM_TYPE=35383]="UNIFORM_TYPE",t[t.UNIFORM_SIZE=35384]="UNIFORM_SIZE",t[t.UNIFORM_BLOCK_INDEX=35386]="UNIFORM_BLOCK_INDEX",t[t.UNIFORM_OFFSET=35387]="UNIFORM_OFFSET",t[t.UNIFORM_ARRAY_STRIDE=35388]="UNIFORM_ARRAY_STRIDE",t[t.UNIFORM_MATRIX_STRIDE=35389]="UNIFORM_MATRIX_STRIDE",t[t.UNIFORM_IS_ROW_MAJOR=35390]="UNIFORM_IS_ROW_MAJOR",t[t.UNIFORM_BLOCK_BINDING=35391]="UNIFORM_BLOCK_BINDING",t[t.UNIFORM_BLOCK_DATA_SIZE=35392]="UNIFORM_BLOCK_DATA_SIZE",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORMS=35394]="UNIFORM_BLOCK_ACTIVE_UNIFORMS",t[t.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES=35395]="UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES",t[t.UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER=35396]="UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER",t[t.UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER=35398]="UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER",t[t.OBJECT_TYPE=37138]="OBJECT_TYPE",t[t.SYNC_CONDITION=37139]="SYNC_CONDITION",t[t.SYNC_STATUS=37140]="SYNC_STATUS",t[t.SYNC_FLAGS=37141]="SYNC_FLAGS",t[t.SYNC_FENCE=37142]="SYNC_FENCE",t[t.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE",t[t.UNSIGNALED=37144]="UNSIGNALED",t[t.SIGNALED=37145]="SIGNALED",t[t.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",t[t.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",t[t.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",t[t.WAIT_FAILED=37149]="WAIT_FAILED",t[t.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT",t[t.COLOR=6144]="COLOR",t[t.DEPTH=6145]="DEPTH",t[t.STENCIL=6146]="STENCIL",t[t.MIN=32775]="MIN",t[t.MAX=32776]="MAX",t[t.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",t[t.STREAM_READ=35041]="STREAM_READ",t[t.STREAM_COPY=35042]="STREAM_COPY",t[t.STATIC_READ=35045]="STATIC_READ",t[t.STATIC_COPY=35046]="STATIC_COPY",t[t.DYNAMIC_READ=35049]="DYNAMIC_READ",t[t.DYNAMIC_COPY=35050]="DYNAMIC_COPY",t[t.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",t[t.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8",t[t.INVALID_INDEX=4294967295]="INVALID_INDEX",t[t.TIMEOUT_IGNORED=-1]="TIMEOUT_IGNORED",t[t.MAX_CLIENT_WAIT_TIMEOUT_WEBGL=37447]="MAX_CLIENT_WAIT_TIMEOUT_WEBGL",t[t.UNMASKED_VENDOR_WEBGL=37445]="UNMASKED_VENDOR_WEBGL",t[t.UNMASKED_RENDERER_WEBGL=37446]="UNMASKED_RENDERER_WEBGL",t[t.MAX_TEXTURE_MAX_ANISOTROPY_EXT=34047]="MAX_TEXTURE_MAX_ANISOTROPY_EXT",t[t.TEXTURE_MAX_ANISOTROPY_EXT=34046]="TEXTURE_MAX_ANISOTROPY_EXT",t[t.R16_EXT=33322]="R16_EXT",t[t.RG16_EXT=33324]="RG16_EXT",t[t.RGB16_EXT=32852]="RGB16_EXT",t[t.RGBA16_EXT=32859]="RGBA16_EXT",t[t.R16_SNORM_EXT=36760]="R16_SNORM_EXT",t[t.RG16_SNORM_EXT=36761]="RG16_SNORM_EXT",t[t.RGB16_SNORM_EXT=36762]="RGB16_SNORM_EXT",t[t.RGBA16_SNORM_EXT=36763]="RGBA16_SNORM_EXT",t[t.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",t[t.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",t[t.COMPRESSED_SRGB_S3TC_DXT1_EXT=35916]="COMPRESSED_SRGB_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=35917]="COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT=35918]="COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT",t[t.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=35919]="COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT",t[t.COMPRESSED_RED_RGTC1_EXT=36283]="COMPRESSED_RED_RGTC1_EXT",t[t.COMPRESSED_SIGNED_RED_RGTC1_EXT=36284]="COMPRESSED_SIGNED_RED_RGTC1_EXT",t[t.COMPRESSED_RED_GREEN_RGTC2_EXT=36285]="COMPRESSED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT=36286]="COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT",t[t.COMPRESSED_RGBA_BPTC_UNORM_EXT=36492]="COMPRESSED_RGBA_BPTC_UNORM_EXT",t[t.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=36493]="COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT",t[t.COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT=36494]="COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT",t[t.COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT=36495]="COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT",t[t.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",t[t.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",t[t.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",t[t.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",t[t.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",t[t.COMPRESSED_RGBA8_ETC2_EAC=37493]="COMPRESSED_RGBA8_ETC2_EAC",t[t.COMPRESSED_SRGB8_ETC2=37494]="COMPRESSED_SRGB8_ETC2",t[t.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37495]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC",t[t.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37496]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37497]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",t[t.COMPRESSED_RGB_PVRTC_4BPPV1_IMG=35840]="COMPRESSED_RGB_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG=35842]="COMPRESSED_RGBA_PVRTC_4BPPV1_IMG",t[t.COMPRESSED_RGB_PVRTC_2BPPV1_IMG=35841]="COMPRESSED_RGB_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG=35843]="COMPRESSED_RGBA_PVRTC_2BPPV1_IMG",t[t.COMPRESSED_RGB_ETC1_WEBGL=36196]="COMPRESSED_RGB_ETC1_WEBGL",t[t.COMPRESSED_RGB_ATC_WEBGL=35986]="COMPRESSED_RGB_ATC_WEBGL",t[t.COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL=35986]="COMPRESSED_RGBA_ATC_EXPLICIT_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL=34798]="COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL",t[t.COMPRESSED_RGBA_ASTC_4x4_KHR=37808]="COMPRESSED_RGBA_ASTC_4x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x4_KHR=37809]="COMPRESSED_RGBA_ASTC_5x4_KHR",t[t.COMPRESSED_RGBA_ASTC_5x5_KHR=37810]="COMPRESSED_RGBA_ASTC_5x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x5_KHR=37811]="COMPRESSED_RGBA_ASTC_6x5_KHR",t[t.COMPRESSED_RGBA_ASTC_6x6_KHR=37812]="COMPRESSED_RGBA_ASTC_6x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x5_KHR=37813]="COMPRESSED_RGBA_ASTC_8x5_KHR",t[t.COMPRESSED_RGBA_ASTC_8x6_KHR=37814]="COMPRESSED_RGBA_ASTC_8x6_KHR",t[t.COMPRESSED_RGBA_ASTC_8x8_KHR=37815]="COMPRESSED_RGBA_ASTC_8x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x5_KHR=37816]="COMPRESSED_RGBA_ASTC_10x5_KHR",t[t.COMPRESSED_RGBA_ASTC_10x6_KHR=37817]="COMPRESSED_RGBA_ASTC_10x6_KHR",t[t.COMPRESSED_RGBA_ASTC_10x8_KHR=37818]="COMPRESSED_RGBA_ASTC_10x8_KHR",t[t.COMPRESSED_RGBA_ASTC_10x10_KHR=37819]="COMPRESSED_RGBA_ASTC_10x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x10_KHR=37820]="COMPRESSED_RGBA_ASTC_12x10_KHR",t[t.COMPRESSED_RGBA_ASTC_12x12_KHR=37821]="COMPRESSED_RGBA_ASTC_12x12_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=37840]="COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR=37841]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x4_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR=37842]="COMPRESSED_SRGB8_ALPHA8_ASTC_5x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR=37843]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR=37844]="COMPRESSED_SRGB8_ALPHA8_ASTC_6x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR=37845]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR=37846]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR=37847]="COMPRESSED_SRGB8_ALPHA8_ASTC_8x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR=37848]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x5_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR=37849]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x6_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR=37850]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x8_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR=37851]="COMPRESSED_SRGB8_ALPHA8_ASTC_10x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR=37852]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x10_KHR",t[t.COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR=37853]="COMPRESSED_SRGB8_ALPHA8_ASTC_12x12_KHR",t[t.QUERY_COUNTER_BITS_EXT=34916]="QUERY_COUNTER_BITS_EXT",t[t.CURRENT_QUERY_EXT=34917]="CURRENT_QUERY_EXT",t[t.QUERY_RESULT_EXT=34918]="QUERY_RESULT_EXT",t[t.QUERY_RESULT_AVAILABLE_EXT=34919]="QUERY_RESULT_AVAILABLE_EXT",t[t.TIME_ELAPSED_EXT=35007]="TIME_ELAPSED_EXT",t[t.TIMESTAMP_EXT=36392]="TIMESTAMP_EXT",t[t.GPU_DISJOINT_EXT=36795]="GPU_DISJOINT_EXT",t[t.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR",t[t.DEPTH_CLAMP_EXT=34383]="DEPTH_CLAMP_EXT",t[t.FIRST_VERTEX_CONVENTION_WEBGL=36429]="FIRST_VERTEX_CONVENTION_WEBGL",t[t.LAST_VERTEX_CONVENTION_WEBGL=36430]="LAST_VERTEX_CONVENTION_WEBGL",t[t.PROVOKING_VERTEX_WEBL=36431]="PROVOKING_VERTEX_WEBL",t[t.POLYGON_MODE_WEBGL=2880]="POLYGON_MODE_WEBGL",t[t.POLYGON_OFFSET_LINE_WEBGL=10754]="POLYGON_OFFSET_LINE_WEBGL",t[t.LINE_WEBGL=6913]="LINE_WEBGL",t[t.FILL_WEBGL=6914]="FILL_WEBGL",t[t.MAX_CLIP_DISTANCES_WEBGL=3378]="MAX_CLIP_DISTANCES_WEBGL",t[t.MAX_CULL_DISTANCES_WEBGL=33529]="MAX_CULL_DISTANCES_WEBGL",t[t.MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL=33530]="MAX_COMBINED_CLIP_AND_CULL_DISTANCES_WEBGL",t[t.CLIP_DISTANCE0_WEBGL=12288]="CLIP_DISTANCE0_WEBGL",t[t.CLIP_DISTANCE1_WEBGL=12289]="CLIP_DISTANCE1_WEBGL",t[t.CLIP_DISTANCE2_WEBGL=12290]="CLIP_DISTANCE2_WEBGL",t[t.CLIP_DISTANCE3_WEBGL=12291]="CLIP_DISTANCE3_WEBGL",t[t.CLIP_DISTANCE4_WEBGL=12292]="CLIP_DISTANCE4_WEBGL",t[t.CLIP_DISTANCE5_WEBGL=12293]="CLIP_DISTANCE5_WEBGL",t[t.CLIP_DISTANCE6_WEBGL=12294]="CLIP_DISTANCE6_WEBGL",t[t.CLIP_DISTANCE7_WEBGL=12295]="CLIP_DISTANCE7_WEBGL",t[t.POLYGON_OFFSET_CLAMP_EXT=36379]="POLYGON_OFFSET_CLAMP_EXT",t[t.LOWER_LEFT_EXT=36001]="LOWER_LEFT_EXT",t[t.UPPER_LEFT_EXT=36002]="UPPER_LEFT_EXT",t[t.NEGATIVE_ONE_TO_ONE_EXT=37726]="NEGATIVE_ONE_TO_ONE_EXT",t[t.ZERO_TO_ONE_EXT=37727]="ZERO_TO_ONE_EXT",t[t.CLIP_ORIGIN_EXT=37724]="CLIP_ORIGIN_EXT",t[t.CLIP_DEPTH_MODE_EXT=37725]="CLIP_DEPTH_MODE_EXT",t[t.SRC1_COLOR_WEBGL=35065]="SRC1_COLOR_WEBGL",t[t.SRC1_ALPHA_WEBGL=34185]="SRC1_ALPHA_WEBGL",t[t.ONE_MINUS_SRC1_COLOR_WEBGL=35066]="ONE_MINUS_SRC1_COLOR_WEBGL",t[t.ONE_MINUS_SRC1_ALPHA_WEBGL=35067]="ONE_MINUS_SRC1_ALPHA_WEBGL",t[t.MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL=35068]="MAX_DUAL_SOURCE_DRAW_BUFFERS_WEBGL",t[t.MIRROR_CLAMP_TO_EDGE_EXT=34627]="MIRROR_CLAMP_TO_EDGE_EXT"})(Wh||(Wh={}));const ox={3042:!1,32773:new Float32Array([0,0,0,0]),32777:32774,34877:32774,32969:1,32968:0,32971:1,32970:0,3106:new Float32Array([0,0,0,0]),3107:[!0,!0,!0,!0],2884:!1,2885:1029,2929:!1,2931:1,2932:513,2928:new Float32Array([0,1]),2930:!0,3024:!0,35725:null,36006:null,36007:null,34229:null,34964:null,2886:2305,33170:4352,2849:1,32823:!1,32824:0,10752:0,32926:!1,32928:!1,32938:1,32939:!1,3089:!1,3088:new Int32Array([0,0,1024,1024]),2960:!1,2961:0,2968:4294967295,36005:4294967295,2962:519,2967:0,2963:4294967295,34816:519,36003:0,36004:4294967295,2964:7680,2965:7680,2966:7680,34817:7680,34818:7680,34819:7680,2978:[0,0,1024,1024],36389:null,36662:null,36663:null,35053:null,35055:null,35723:4352,36010:null,35977:!1,3333:4,3317:4,37440:!1,37441:!1,37443:37444,3330:0,3332:0,3331:0,3314:0,32878:0,3316:0,3315:0,32877:0},Rr=(t,e,i)=>e?t.enable(i):t.disable(i),gE=(t,e,i)=>t.hint(i,e),mn=(t,e,i)=>t.pixelStorei(i,e),mE=(t,e,i)=>{const r=i===36006?36009:36008;return t.bindFramebuffer(r,e)},Qd=(t,e,i)=>{const o={34964:34962,36662:36662,36663:36663,35053:35051,35055:35052}[i];t.bindBuffer(o,e)};function Y0(t){return Array.isArray(t)||ArrayBuffer.isView(t)&&!(t instanceof DataView)}const WU={3042:Rr,32773:(t,e)=>t.blendColor(...e),32777:"blendEquation",34877:"blendEquation",32969:"blendFunc",32968:"blendFunc",32971:"blendFunc",32970:"blendFunc",3106:(t,e)=>t.clearColor(...e),3107:(t,e)=>t.colorMask(...e),2884:Rr,2885:(t,e)=>t.cullFace(e),2929:Rr,2931:(t,e)=>t.clearDepth(e),2932:(t,e)=>t.depthFunc(e),2928:(t,e)=>t.depthRange(...e),2930:(t,e)=>t.depthMask(e),3024:Rr,35723:gE,35725:(t,e)=>t.useProgram(e),36007:(t,e)=>t.bindRenderbuffer(36161,e),36389:(t,e)=>{var i;return(i=t.bindTransformFeedback)==null?void 0:i.call(t,36386,e)},34229:(t,e)=>t.bindVertexArray(e),36006:mE,36010:mE,34964:Qd,36662:Qd,36663:Qd,35053:Qd,35055:Qd,2886:(t,e)=>t.frontFace(e),33170:gE,2849:(t,e)=>t.lineWidth(e),32823:Rr,32824:"polygonOffset",10752:"polygonOffset",35977:Rr,32926:Rr,32928:Rr,32938:"sampleCoverage",32939:"sampleCoverage",3089:Rr,3088:(t,e)=>t.scissor(...e),2960:Rr,2961:(t,e)=>t.clearStencil(e),2968:(t,e)=>t.stencilMaskSeparate(1028,e),36005:(t,e)=>t.stencilMaskSeparate(1029,e),2962:"stencilFuncFront",2967:"stencilFuncFront",2963:"stencilFuncFront",34816:"stencilFuncBack",36003:"stencilFuncBack",36004:"stencilFuncBack",2964:"stencilOpFront",2965:"stencilOpFront",2966:"stencilOpFront",34817:"stencilOpBack",34818:"stencilOpBack",34819:"stencilOpBack",2978:(t,e)=>t.viewport(...e),34383:Rr,10754:Rr,12288:Rr,12289:Rr,12290:Rr,12291:Rr,12292:Rr,12293:Rr,12294:Rr,12295:Rr,3333:mn,3317:mn,37440:mn,37441:mn,37443:mn,3330:mn,3332:mn,3331:mn,3314:mn,32878:mn,3316:mn,3315:mn,32877:mn,framebuffer:(t,e)=>{const i=e&&"handle"in e?e.handle:e;return t.bindFramebuffer(36160,i)},blend:(t,e)=>e?t.enable(3042):t.disable(3042),blendColor:(t,e)=>t.blendColor(...e),blendEquation:(t,e)=>{const i=typeof e=="number"?[e,e]:e;t.blendEquationSeparate(...i)},blendFunc:(t,e)=>{const i=(e==null?void 0:e.length)===2?[...e,...e]:e;t.blendFuncSeparate(...i)},clearColor:(t,e)=>t.clearColor(...e),clearDepth:(t,e)=>t.clearDepth(e),clearStencil:(t,e)=>t.clearStencil(e),colorMask:(t,e)=>t.colorMask(...e),cull:(t,e)=>e?t.enable(2884):t.disable(2884),cullFace:(t,e)=>t.cullFace(e),depthTest:(t,e)=>e?t.enable(2929):t.disable(2929),depthFunc:(t,e)=>t.depthFunc(e),depthMask:(t,e)=>t.depthMask(e),depthRange:(t,e)=>t.depthRange(...e),dither:(t,e)=>e?t.enable(3024):t.disable(3024),derivativeHint:(t,e)=>{t.hint(35723,e)},frontFace:(t,e)=>t.frontFace(e),mipmapHint:(t,e)=>t.hint(33170,e),lineWidth:(t,e)=>t.lineWidth(e),polygonOffsetFill:(t,e)=>e?t.enable(32823):t.disable(32823),polygonOffset:(t,e)=>t.polygonOffset(...e),sampleCoverage:(t,e)=>t.sampleCoverage(...e),scissorTest:(t,e)=>e?t.enable(3089):t.disable(3089),scissor:(t,e)=>t.scissor(...e),stencilTest:(t,e)=>e?t.enable(2960):t.disable(2960),stencilMask:(t,e)=>{e=Y0(e)?e:[e,e];const[i,r]=e;t.stencilMaskSeparate(1028,i),t.stencilMaskSeparate(1029,r)},stencilFunc:(t,e)=>{e=Y0(e)&&e.length===3?[...e,...e]:e;const[i,r,o,h,d,c]=e;t.stencilFuncSeparate(1028,i,r,o),t.stencilFuncSeparate(1029,h,d,c)},stencilOp:(t,e)=>{e=Y0(e)&&e.length===3?[...e,...e]:e;const[i,r,o,h,d,c]=e;t.stencilOpSeparate(1028,i,r,o),t.stencilOpSeparate(1029,h,d,c)},viewport:(t,e)=>t.viewport(...e)};function _r(t,e,i){return e[t]!==void 0?e[t]:i[t]}const HU={blendEquation:(t,e,i)=>t.blendEquationSeparate(_r(32777,e,i),_r(34877,e,i)),blendFunc:(t,e,i)=>t.blendFuncSeparate(_r(32969,e,i),_r(32968,e,i),_r(32971,e,i),_r(32970,e,i)),polygonOffset:(t,e,i)=>t.polygonOffset(_r(32824,e,i),_r(10752,e,i)),sampleCoverage:(t,e,i)=>t.sampleCoverage(_r(32938,e,i),_r(32939,e,i)),stencilFuncFront:(t,e,i)=>t.stencilFuncSeparate(1028,_r(2962,e,i),_r(2967,e,i),_r(2963,e,i)),stencilFuncBack:(t,e,i)=>t.stencilFuncSeparate(1029,_r(34816,e,i),_r(36003,e,i),_r(36004,e,i)),stencilOpFront:(t,e,i)=>t.stencilOpSeparate(1028,_r(2964,e,i),_r(2965,e,i),_r(2966,e,i)),stencilOpBack:(t,e,i)=>t.stencilOpSeparate(1029,_r(34817,e,i),_r(34818,e,i),_r(34819,e,i))},yE={enable:(t,e)=>t({[e]:!0}),disable:(t,e)=>t({[e]:!1}),pixelStorei:(t,e,i)=>t({[e]:i}),hint:(t,e,i)=>t({[e]:i}),useProgram:(t,e)=>t({35725:e}),bindRenderbuffer:(t,e,i)=>t({36007:i}),bindTransformFeedback:(t,e,i)=>t({36389:i}),bindVertexArray:(t,e)=>t({34229:e}),bindFramebuffer:(t,e,i)=>{switch(e){case 36160:return t({36006:i,36010:i});case 36009:return t({36006:i});case 36008:return t({36010:i});default:return null}},bindBuffer:(t,e,i)=>{const r={34962:[34964],36662:[36662],36663:[36663],35051:[35053],35052:[35055]}[e];return r?t({[r]:i}):{valueChanged:!0}},blendColor:(t,e,i,r,o)=>t({32773:new Float32Array([e,i,r,o])}),blendEquation:(t,e)=>t({32777:e,34877:e}),blendEquationSeparate:(t,e,i)=>t({32777:e,34877:i}),blendFunc:(t,e,i)=>t({32969:e,32968:i,32971:e,32970:i}),blendFuncSeparate:(t,e,i,r,o)=>t({32969:e,32968:i,32971:r,32970:o}),clearColor:(t,e,i,r,o)=>t({3106:new Float32Array([e,i,r,o])}),clearDepth:(t,e)=>t({2931:e}),clearStencil:(t,e)=>t({2961:e}),colorMask:(t,e,i,r,o)=>t({3107:[e,i,r,o]}),cullFace:(t,e)=>t({2885:e}),depthFunc:(t,e)=>t({2932:e}),depthRange:(t,e,i)=>t({2928:new Float32Array([e,i])}),depthMask:(t,e)=>t({2930:e}),frontFace:(t,e)=>t({2886:e}),lineWidth:(t,e)=>t({2849:e}),polygonOffset:(t,e,i)=>t({32824:e,10752:i}),sampleCoverage:(t,e,i)=>t({32938:e,32939:i}),scissor:(t,e,i,r,o)=>t({3088:new Int32Array([e,i,r,o])}),stencilMask:(t,e)=>t({2968:e,36005:e}),stencilMaskSeparate:(t,e,i)=>t({[e===1028?2968:36005]:i}),stencilFunc:(t,e,i,r)=>t({2962:e,2967:i,2963:r,34816:e,36003:i,36004:r}),stencilFuncSeparate:(t,e,i,r,o)=>t({[e===1028?2962:34816]:i,[e===1028?2967:36003]:r,[e===1028?2963:36004]:o}),stencilOp:(t,e,i,r)=>t({2964:e,2965:i,2966:r,34817:e,34818:i,34819:r}),stencilOpSeparate:(t,e,i,r,o)=>t({[e===1028?2964:34817]:i,[e===1028?2965:34818]:r,[e===1028?2966:34819]:o}),viewport:(t,e,i,r,o)=>t({2978:[e,i,r,o]})},wo=(t,e)=>t.isEnabled(e),bE={3042:wo,2884:wo,2929:wo,3024:wo,32823:wo,32926:wo,32928:wo,3089:wo,2960:wo,35977:wo},XU=new Set([34016,36388,36387,35983,35368,34965,35739,35738,3074,34853,34854,34855,34856,34857,34858,34859,34860,34861,34862,34863,34864,34865,34866,34867,34868,35097,32873,35869,32874,34068]);function Tu(t,e){if(ZU(e))return;const i={};for(const o in e){const h=Number(o),d=WU[o];d&&(typeof d=="string"?i[d]=!0:d(t,e[o],h))}const r=t.state&&t.state.cache;if(r)for(const o in i){const h=HU[o];h(t,e,r)}}function gP(t,e=ox){if(typeof e=="number"){const o=e,h=bE[o];return h?h(t,o):t.getParameter(o)}const i=Array.isArray(e)?e:Object.keys(e),r={};for(const o of i){const h=bE[o];r[o]=h?h(t,Number(o)):t.getParameter(Number(o))}return r}function qU(t){Tu(t,ox)}function ZU(t){for(const e in t)return!1;return!0}function YU(t,e){if(t===e)return!0;const i=Array.isArray(t)||ArrayBuffer.isView(t),r=Array.isArray(e)||ArrayBuffer.isView(e);if(i&&r&&t.length===e.length){for(let o=0;o{}}={}){Z(this,"gl");Z(this,"program",null);Z(this,"stateStack",[]);Z(this,"enable",!0);Z(this,"cache");Z(this,"log");this.gl=e,this.cache=i?gP(e):Object.assign({},ox),this.log=r,this._updateCache=this._updateCache.bind(this),Object.seal(this)}push(e={}){this.stateStack.push({})}pop(){Yi(this.stateStack.length>0);const e=this.stateStack[this.stateStack.length-1];Tu(this.gl,e),this.stateStack.pop()}_updateCache(e){let i=!1,r;const o=this.stateStack.length>0?this.stateStack[this.stateStack.length-1]:null;for(const h in e){Yi(h!==void 0);const d=e[h],c=this.cache[h];YU(d,c)||(i=!0,r=c,o&&!(h in o)&&(o[h]=c),this.cache[h]=d)}return{valueChanged:i,oldValue:r}}}function Rc(t){return t.state}function mP(t,e){const{enable:i=!0,copyState:r}=e;if(Yi(r!==void 0),!t.state){t.state=new KU(t,{copyState:r}),GU(t);for(const h in yE){const d=yE[h];JU(t,h,d)}vE(t,"getParameter"),vE(t,"isEnabled")}const o=Rc(t);return o.enable=i,t}function Pm(t){let e=Rc(t);e||(mP(t,{copyState:!1}),e=Rc(t)),e.push()}function Lf(t){const e=Rc(t);Yi(e),e.pop()}function vE(t,e){const i=t[e].bind(t);t[e]=function(o){if(o===void 0||XU.has(o))return i(o);const h=Rc(t);return o in h.cache||(h.cache[o]=i(o)),h.enable?h.cache[o]:i(o)},Object.defineProperty(t[e],"name",{value:`${e}-from-cache`,configurable:!1})}function JU(t,e,i){if(!t[e])return;const r=t[e].bind(t);t[e]=function(...h){const d=Rc(t),{valueChanged:c,oldValue:x}=i(d._updateCache,...h);return c&&r(...h),x},Object.defineProperty(t[e],"name",{value:`${e}-to-cache`,configurable:!1})}function GU(t){const e=t.useProgram.bind(t);t.useProgram=function(r){const o=Rc(t);o.program!==r&&(e(r),o.program=r)}}const QU={powerPreference:"high-performance",onContextLost:()=>console.error("WebGL context lost"),onContextRestored:()=>console.info("WebGL context restored")};function e5(t,e){e={...QU,...e};let i=null;const r=h=>i=h.statusMessage||i;t.addEventListener("webglcontextcreationerror",r,!1);let o=null;if(o||(o=t.getContext("webgl2",e)),t.removeEventListener("webglcontextcreationerror",r,!1),!o)throw new Error(`Failed to create WebGL context: ${i||"Unknown error"}`);if(e.onContextLost){const{onContextLost:h}=e;t.addEventListener("webglcontextlost",d=>h(d),!1)}if(e.onContextRestored){const{onContextRestored:h}=e;t.addEventListener("webglcontextrestored",d=>h(d),!1)}return o}function yl(t,e,i){return i[e]===void 0&&(i[e]=t.getExtension(e)||null),i[e]}function t5(t,e){const i=t.getParameter(7936),r=t.getParameter(7937);yl(t,"WEBGL_debug_renderer_info",e);const o=e.WEBGL_debug_renderer_info,h=t.getParameter(o?o.UNMASKED_VENDOR_WEBGL:7936),d=t.getParameter(o?o.UNMASKED_RENDERER_WEBGL:7937),c=h||i,x=d||r,S=t.getParameter(7938),P=yP(c,x),M=i5(c,x),D=r5(c,x);return{type:"webgl",gpu:P,gpuType:D,gpuBackend:M,vendor:c,renderer:x,version:S,shadingLanguage:"glsl",shadingLanguageVersion:300}}function yP(t,e){return/NVIDIA/i.exec(t)||/NVIDIA/i.exec(e)?"nvidia":/INTEL/i.exec(t)||/INTEL/i.exec(e)?"intel":/Apple/i.exec(t)||/Apple/i.exec(e)?"apple":/AMD/i.exec(t)||/AMD/i.exec(e)||/ATI/i.exec(t)||/ATI/i.exec(e)?"amd":/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e)?"software":"unknown"}function i5(t,e){return/Metal/i.exec(t)||/Metal/i.exec(e)?"metal":/ANGLE/i.exec(t)||/ANGLE/i.exec(e)?"opengl":"unknown"}function r5(t,e){if(/SwiftShader/i.exec(t)||/SwiftShader/i.exec(e))return"cpu";switch(yP(t,e)){case"intel":return"integrated";case"software":return"cpu";case"unknown":return"unknown";default:return"discrete"}}function bP(t){switch(t){case"uint8":return 5121;case"sint8":return 5120;case"unorm8":return 5121;case"snorm8":return 5120;case"uint16":return 5123;case"sint16":return 5122;case"unorm16":return 5123;case"snorm16":return 5122;case"uint32":return 5125;case"sint32":return 5124;case"float16":return 5131;case"float32":return 5126}throw new Error(String(t))}const gs="texture-compression-bc",Oi="texture-compression-astc",To="texture-compression-etc2",s5="texture-compression-etc1-webgl",z_="texture-compression-pvrtc-webgl",K0="texture-compression-atc-webgl",ef="float32-renderable-webgl",J0="float16-renderable-webgl",n5="rgb9e5ufloat_renderable-webgl",G0="snorm8-renderable-webgl",tf="norm16-renderable-webgl",Q0="snorm16-renderable-webgl",L_="float32-filterable",xE="float16-filterable-webgl",uf="WEBGL_compressed_texture_s3tc",df="WEBGL_compressed_texture_s3tc_srgb",Hh="EXT_texture_compression_rgtc",Xh="EXT_texture_compression_bptc",o5="WEBGL_compressed_texture_etc",a5="WEBGL_compressed_texture_astc",l5="WEBGL_compressed_texture_etc1",c5="WEBGL_compressed_texture_pvrtc",h5="WEBGL_compressed_texture_atc",wE="EXT_texture_norm16",TE="EXT_render_snorm",u5="EXT_color_buffer_float",ax={"float32-renderable-webgl":["EXT_color_buffer_float"],"float16-renderable-webgl":["EXT_color_buffer_half_float"],"rgb9e5ufloat_renderable-webgl":["WEBGL_render_shared_exponent"],"snorm8-renderable-webgl":[TE],"norm16-renderable-webgl":[wE],"snorm16-renderable-webgl":[wE,TE],"float32-filterable":["OES_texture_float_linear"],"float16-filterable-webgl":["OES_texture_half_float_linear"],"texture-filterable-anisotropic-webgl":["EXT_texture_filter_anisotropic"],"texture-blend-float-webgl":["EXT_float_blend"],"texture-compression-bc":[uf,df,Hh,Xh],"texture-compression-bc5-webgl":[Hh],"texture-compression-bc7-webgl":[Xh],"texture-compression-etc2":[o5],"texture-compression-astc":[a5],"texture-compression-etc1-webgl":[l5],"texture-compression-pvrtc-webgl":[c5],"texture-compression-atc-webgl":[h5]};function d5(t){return t in ax}function f5(t,e,i){return(ax[e]||[]).every(o=>yl(t,o,i))}const Rm={"rgb8unorm-unsized":{gl:6407,b:4,c:2,bpp:4,dataFormat:6407,types:[5121,33635]},"rgba8unorm-unsized":{gl:6408,b:4,c:2,bpp:4,dataFormat:6408,types:[5121,32819,32820]},r8unorm:{gl:33321,b:1,c:1,rb:!0},r8snorm:{gl:36756,b:1,c:1,render:G0},r8uint:{gl:33330,b:1,c:1,rb:!0},r8sint:{gl:33329,b:1,c:1,rb:!0},rg8unorm:{gl:33323,b:2,c:2,rb:!0},rg8snorm:{gl:36757,b:2,c:2,render:G0},rg8uint:{gl:33336,b:2,c:2,rb:!0},rg8sint:{gl:33335,b:2,c:2,rb:!0},r16uint:{gl:33332,b:2,c:1,rb:!0},r16sint:{gl:33331,b:2,c:1,rb:!0},r16float:{gl:33325,b:2,c:1,render:J0,filter:"float16-filterable-webgl",rb:!0},"r16unorm-webgl":{gl:33322,b:2,c:1,f:tf,rb:!0},"r16snorm-webgl":{gl:36760,b:2,c:1,f:Q0},"rgba4unorm-webgl":{gl:32854,b:2,c:4,wgpu:!1,rb:!0},"rgb565unorm-webgl":{gl:36194,b:2,c:4,wgpu:!1,rb:!0},"rgb5a1unorm-webgl":{gl:32855,b:2,c:4,wgpu:!1,rb:!0},"rgb8unorm-webgl":{gl:32849,b:3,c:3,wgpu:!1},"rgb8snorm-webgl":{gl:36758,b:3,c:3,wgpu:!1},rgba8unorm:{gl:32856,b:4,c:2,bpp:4},"rgba8unorm-srgb":{gl:35907,b:4,c:4,bpp:4},rgba8snorm:{gl:36759,b:4,c:4,render:G0},rgba8uint:{gl:36220,b:4,c:4,bpp:4},rgba8sint:{gl:36238,b:4,c:4,bpp:4},bgra8unorm:{b:4,c:4},"bgra8unorm-srgb":{b:4,c:4},rg16uint:{gl:33338,b:4,c:1,bpp:4},rg16sint:{gl:33337,b:4,c:2,bpp:4},rg16float:{gl:33327,bpp:4,b:4,c:2,render:J0,filter:xE,rb:!0},"rg16unorm-webgl":{gl:33324,b:2,c:2,render:tf},"rg16snorm-webgl":{gl:36761,b:2,c:2,render:Q0},r32uint:{gl:33334,b:4,c:1,bpp:4,rb:!0},r32sint:{gl:33333,b:4,c:1,bpp:4,rb:!0},r32float:{gl:33326,bpp:4,b:4,c:1,render:ef,filter:L_},rgb9e5ufloat:{gl:35901,b:4,c:3,p:1,render:n5},rg11b10ufloat:{gl:35898,b:4,c:3,p:1,render:ef,rb:!0},rgb10a2unorm:{gl:32857,b:4,c:4,p:1,rb:!0},"rgb10a2uint-webgl":{b:4,c:4,gl:36975,p:1,wgpu:!1,bpp:4,rb:!0},"rgb16unorm-webgl":{gl:32852,b:2,c:3,f:tf},"rgb16snorm-webgl":{gl:36762,b:2,c:3,f:tf},rg32uint:{gl:33340,b:8,c:2,rb:!0},rg32sint:{gl:33339,b:8,c:2,rb:!0},rg32float:{gl:33328,b:8,c:2,render:ef,filter:L_,rb:!0},rgba16uint:{gl:36214,b:8,c:4,rb:!0},rgba16sint:{gl:36232,b:8,c:4,rb:!0},rgba16float:{gl:34842,b:8,c:4,render:J0,filter:xE},"rgba16unorm-webgl":{gl:32859,b:2,c:4,render:tf,rb:!0},"rgba16snorm-webgl":{gl:36763,b:2,c:4,render:Q0},"rgb32float-webgl":{gl:34837,render:ef,filter:L_,gl2ext:u5,dataFormat:6407,types:[5126]},rgba32uint:{gl:36208,b:16,c:4,rb:!0},rgba32sint:{gl:36226,b:16,c:4,rb:!0},rgba32float:{gl:34836,b:16,c:4,render:ef,filter:L_,rb:!0},stencil8:{gl:36168,b:1,c:1,attachment:36128,rb:!0},depth16unorm:{gl:33189,b:2,c:1,attachment:36096,dataFormat:6402,types:[5123],rb:!0},depth24plus:{gl:33190,b:3,c:1,attachment:36096,dataFormat:6402,types:[5125]},depth32float:{gl:36012,b:4,c:1,attachment:36096,dataFormat:6402,types:[5126],rb:!0},"depth24plus-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,rb:!0,depthTexture:!0,dataFormat:34041,types:[34042]},"depth24unorm-stencil8":{gl:35056,b:4,c:2,p:1,attachment:33306,dataFormat:34041,types:[34042],rb:!0},"depth32float-stencil8":{gl:36013,b:5,c:2,p:1,attachment:33306,dataFormat:34041,types:[36269],rb:!0},"bc1-rgb-unorm-webgl":{gl:33776,x:uf,f:gs},"bc1-rgb-unorm-srgb-webgl":{gl:35916,x:df,f:gs},"bc1-rgba-unorm":{gl:33777,x:uf,f:gs},"bc1-rgba-unorm-srgb":{gl:35916,x:df,f:gs},"bc2-rgba-unorm":{gl:33778,x:uf,f:gs},"bc2-rgba-unorm-srgb":{gl:35918,x:df,f:gs},"bc3-rgba-unorm":{gl:33779,x:uf,f:gs},"bc3-rgba-unorm-srgb":{gl:35919,x:df,f:gs},"bc4-r-unorm":{gl:36283,x:Hh,f:gs},"bc4-r-snorm":{gl:36284,x:Hh,f:gs},"bc5-rg-unorm":{gl:36285,x:Hh,f:gs},"bc5-rg-snorm":{gl:36286,x:Hh,f:gs},"bc6h-rgb-ufloat":{gl:36495,x:Xh,f:gs},"bc6h-rgb-float":{gl:36494,x:Xh,f:gs},"bc7-rgba-unorm":{gl:36492,x:Xh,f:gs},"bc7-rgba-unorm-srgb":{gl:36493,x:Xh,f:gs},"etc2-rgb8unorm":{gl:37492,f:To},"etc2-rgb8unorm-srgb":{gl:37494,f:To},"etc2-rgb8a1unorm":{gl:37496,f:To},"etc2-rgb8a1unorm-srgb":{gl:37497,f:To},"etc2-rgba8unorm":{gl:37493,f:To},"etc2-rgba8unorm-srgb":{gl:37495,f:To},"eac-r11unorm":{gl:37488,f:To},"eac-r11snorm":{gl:37489,f:To},"eac-rg11unorm":{gl:37490,f:To},"eac-rg11snorm":{gl:37491,f:To},"astc-4x4-unorm":{gl:37808,f:Oi},"astc-4x4-unorm-srgb":{gl:37840,f:Oi},"astc-5x4-unorm":{gl:37809,f:Oi},"astc-5x4-unorm-srgb":{gl:37841,f:Oi},"astc-5x5-unorm":{gl:37810,f:Oi},"astc-5x5-unorm-srgb":{gl:37842,f:Oi},"astc-6x5-unorm":{gl:37811,f:Oi},"astc-6x5-unorm-srgb":{gl:37843,f:Oi},"astc-6x6-unorm":{gl:37812,f:Oi},"astc-6x6-unorm-srgb":{gl:37844,f:Oi},"astc-8x5-unorm":{gl:37813,f:Oi},"astc-8x5-unorm-srgb":{gl:37845,f:Oi},"astc-8x6-unorm":{gl:37814,f:Oi},"astc-8x6-unorm-srgb":{gl:37846,f:Oi},"astc-8x8-unorm":{gl:37815,f:Oi},"astc-8x8-unorm-srgb":{gl:37847,f:Oi},"astc-10x5-unorm":{gl:37819,f:Oi},"astc-10x5-unorm-srgb":{gl:37851,f:Oi},"astc-10x6-unorm":{gl:37817,f:Oi},"astc-10x6-unorm-srgb":{gl:37849,f:Oi},"astc-10x8-unorm":{gl:37818,f:Oi},"astc-10x8-unorm-srgb":{gl:37850,f:Oi},"astc-10x10-unorm":{gl:37819,f:Oi},"astc-10x10-unorm-srgb":{gl:37851,f:Oi},"astc-12x10-unorm":{gl:37820,f:Oi},"astc-12x10-unorm-srgb":{gl:37852,f:Oi},"astc-12x12-unorm":{gl:37821,f:Oi},"astc-12x12-unorm-srgb":{gl:37853,f:Oi},"pvrtc-rgb4unorm-webgl":{gl:35840,f:z_},"pvrtc-rgba4unorm-webgl":{gl:35842,f:z_},"pvrtc-rbg2unorm-webgl":{gl:35841,f:z_},"pvrtc-rgba2unorm-webgl":{gl:35843,f:z_},"etc1-rbg-unorm-webgl":{gl:36196,f:s5},"atc-rgb-unorm-webgl":{gl:35986,f:K0},"atc-rgba-unorm-webgl":{gl:35986,f:K0},"atc-rgbai-unorm-webgl":{gl:34798,f:K0}},p5={6403:1,36244:1,33319:2,33320:2,6407:3,36248:3,6408:4,36249:4,6402:1,34041:1,6406:1,6409:1,6410:2},_5={5126:4,5125:4,5124:4,5123:2,5122:2,5131:2,5120:1,5121:1};function lx(t,e,i){const r=Rm[e];if(!r||r.gl===void 0)return!1;const o=r.x||r.gl2ext;return o?!!yl(t,o,i):!0}function vP(t){const e=Rm[t],i=e==null?void 0:e.gl;if(i===void 0)throw new Error(`Unsupported texture format ${t}`);return i}function g5(t,e,i){if(!lx(t,e,i)||e.startsWith("depth")||e.startsWith("stencil"))return!1;try{if(RI(e).signed)return!1}catch{return!1}return e.endsWith("32float")?!!yl(t,"OES_texture_float_linear, extensions",i):e.endsWith("16float")?!!yl(t,"OES_texture_half_float_linear, extensions",i):!0}function m5(t,e,i){return!(!lx(t,e,i)||typeof e=="number")}function kg(t){var o;const e=Rm[t],i=vP(t),r=RI(t);return{format:i,dataFormat:(e==null?void 0:e.dataFormat)||b5(r.format,r.integer,r.normalized,i),type:r.dataType?bP(r.dataType):((o=e==null?void 0:e.types)==null?void 0:o[0])||5121,compressed:r.compressed}}function y5(t){const e=Rm[t];if(!(e!=null&&e.attachment))throw new Error(`${t} is not a depth stencil format`);return e.attachment}function SE(t){const e=kg(t),i=p5[e.dataFormat]||4,r=_5[e.type]||1;return i*r}function b5(t,e,i,r){if(r===6408||r===6407)return r;switch(t){case"r":return e&&!i?36244:6403;case"rg":return e&&!i?33320:33319;case"rgb":return e&&!i?36248:6407;case"rgba":return e&&!i?36249:6408;default:return 6408}}const EE={"depth-clip-control":"EXT_depth_clamp","timer-query-webgl":"EXT_disjoint_timer_query_webgl2","compilation-status-async-webgl":"KHR_parallel_shader_compile","polygon-mode-webgl":"WEBGL_polygon_mode","provoking-vertex-webgl":"WEBGL_provoking_vertex","shader-clip-cull-distance-webgl":"WEBGL_clip_cull_distance","shader-noperspective-interpolation-webgl":"NV_shader_noperspective_interpolation","shader-conservative-depth-webgl":"EXT_conservative_depth"};class v5 extends QB{constructor(i,r,o){super([],o);Z(this,"gl");Z(this,"extensions");Z(this,"testedFeatures",new Set);this.gl=i,this.extensions=r,yl(i,"EXT_color_buffer_float",r)}*[Symbol.iterator](){const i=this.getFeatures();for(const r of i)this.has(r)&&(yield r);return[]}has(i){return this.disabledFeatures[i]?!1:(this.testedFeatures.has(i)||(this.testedFeatures.add(i),d5(i)&&f5(this.gl,i,this.extensions)&&this.features.add(i),this.getWebGLFeature(i)&&this.features.add(i)),this.features.has(i))}initializeFeatures(){const i=this.getFeatures().filter(r=>r!=="polygon-mode-webgl");for(const r of i)this.has(r)}getFeatures(){return[...Object.keys(EE),...Object.keys(ax)]}getWebGLFeature(i){const r=EE[i];return typeof r=="string"?!!yl(this.gl,r,this.extensions):!!r}}class x5 extends GB{constructor(i){super();Z(this,"gl");Z(this,"limits",{});this.gl=i}get maxTextureDimension1D(){return 0}get maxTextureDimension2D(){return this.getParameter(3379)}get maxTextureDimension3D(){return this.getParameter(32883)}get maxTextureArrayLayers(){return this.getParameter(35071)}get maxBindGroups(){return 0}get maxDynamicUniformBuffersPerPipelineLayout(){return 0}get maxDynamicStorageBuffersPerPipelineLayout(){return 0}get maxSampledTexturesPerShaderStage(){return this.getParameter(35660)}get maxSamplersPerShaderStage(){return this.getParameter(35661)}get maxStorageBuffersPerShaderStage(){return 0}get maxStorageTexturesPerShaderStage(){return 0}get maxUniformBuffersPerShaderStage(){return this.getParameter(35375)}get maxUniformBufferBindingSize(){return this.getParameter(35376)}get maxStorageBufferBindingSize(){return 0}get minUniformBufferOffsetAlignment(){return this.getParameter(35380)}get minStorageBufferOffsetAlignment(){return 0}get maxVertexBuffers(){return 16}get maxVertexAttributes(){return this.getParameter(34921)}get maxVertexBufferArrayStride(){return 2048}get maxInterStageShaderComponents(){return this.getParameter(35659)}get maxComputeWorkgroupStorageSize(){return 0}get maxComputeInvocationsPerWorkgroup(){return 0}get maxComputeWorkgroupSizeX(){return 0}get maxComputeWorkgroupSizeY(){return 0}get maxComputeWorkgroupSizeZ(){return 0}get maxComputeWorkgroupsPerDimension(){return 0}getParameter(i){return this.limits[i]===void 0&&(this.limits[i]=this.gl.getParameter(i)),this.limits[i]}}function cl(t,e,i){if(w5(e))return i(t);const{nocatch:r=!0}=e;Pm(t),Tu(t,e);let o;if(r)o=i(t),Lf(t);else try{o=i(t)}finally{Lf(t)}return o}function w5(t){for(const e in t)return!1;return!0}function T5(t,e,i,r){if(gg(e))return r(t);const o=t;Pm(o.gl);try{return S5(t,e),Tu(o.gl,i),r(t)}finally{Lf(o.gl)}}function S5(t,e){const i=t,{gl:r}=i;if(e.cullMode)switch(e.cullMode){case"none":r.disable(2884);break;case"front":r.enable(2884),r.cullFace(1028);break;case"back":r.enable(2884),r.cullFace(1029);break}if(e.frontFace&&r.frontFace(Sc("frontFace",e.frontFace,{ccw:2305,cw:2304})),e.unclippedDepth&&t.features.has("depth-clip-control")&&r.enable(34383),e.depthBias!==void 0&&(r.enable(32823),r.polygonOffset(e.depthBias,e.depthBiasSlopeScale||0)),e.provokingVertex&&t.features.has("provoking-vertex-webgl")){const h=i.getExtension("WEBGL_provoking_vertex").WEBGL_provoking_vertex,d=Sc("provokingVertex",e.provokingVertex,{first:36429,last:36430});h==null||h.provokingVertexWEBGL(d)}if((e.polygonMode||e.polygonOffsetLine)&&t.features.has("polygon-mode-webgl")){if(e.polygonMode){const h=i.getExtension("WEBGL_polygon_mode").WEBGL_polygon_mode,d=Sc("polygonMode",e.polygonMode,{fill:6914,line:6913});h==null||h.polygonModeWEBGL(1028,d),h==null||h.polygonModeWEBGL(1029,d)}e.polygonOffsetLine&&r.enable(10754)}if(t.features.has("shader-clip-cull-distance-webgl")&&(e.clipDistance0&&r.enable(12288),e.clipDistance1&&r.enable(12289),e.clipDistance2&&r.enable(12290),e.clipDistance3&&r.enable(12291),e.clipDistance4&&r.enable(12292),e.clipDistance5&&r.enable(12293),e.clipDistance6&&r.enable(12294),e.clipDistance7&&r.enable(12295)),e.depthWriteEnabled!==void 0&&r.depthMask(A5("depthWriteEnabled",e.depthWriteEnabled)),e.depthCompare&&(e.depthCompare!=="always"?r.enable(2929):r.disable(2929),r.depthFunc(Qb("depthCompare",e.depthCompare))),e.stencilWriteMask){const o=e.stencilWriteMask;r.stencilMaskSeparate(1028,o),r.stencilMaskSeparate(1029,o)}if(e.stencilReadMask&&it.warn("stencilReadMask not supported under WebGL"),e.stencilCompare){const o=e.stencilReadMask||4294967295,h=Qb("depthCompare",e.stencilCompare);e.stencilCompare!=="always"?r.enable(2960):r.disable(2960),r.stencilFuncSeparate(1028,h,0,o),r.stencilFuncSeparate(1029,h,0,o)}if(e.stencilPassOperation&&e.stencilFailOperation&&e.stencilDepthFailOperation){const o=eb("stencilPassOperation",e.stencilPassOperation),h=eb("stencilFailOperation",e.stencilFailOperation),d=eb("stencilDepthFailOperation",e.stencilDepthFailOperation);r.stencilOpSeparate(1028,h,d,o),r.stencilOpSeparate(1029,h,d,o)}if(e.blendColorOperation||e.blendAlphaOperation){r.enable(3042);const o=AE("blendColorOperation",e.blendColorOperation||"add"),h=AE("blendAlphaOperation",e.blendAlphaOperation||"add");r.blendEquationSeparate(o,h);const d=U_("blendColorSrcFactor",e.blendColorSrcFactor||"one"),c=U_("blendColorDstFactor",e.blendColorDstFactor||"zero"),x=U_("blendAlphaSrcFactor",e.blendAlphaSrcFactor||"one"),S=U_("blendAlphaDstFactor",e.blendAlphaDstFactor||"zero");r.blendFuncSeparate(d,c,x,S)}}function Qb(t,e){return Sc(t,e,{never:512,less:513,equal:514,"less-equal":515,greater:516,"not-equal":517,"greater-equal":518,always:519})}function eb(t,e){return Sc(t,e,{keep:7680,zero:0,replace:7681,invert:5386,"increment-clamp":7682,"decrement-clamp":7683,"increment-wrap":34055,"decrement-wrap":34056})}function AE(t,e){return Sc(t,e,{add:32774,subtract:32778,"reverse-subtract":32779,min:32775,max:32776})}function U_(t,e){return Sc(t,e,{one:1,zero:0,"src-color":768,"one-minus-src-color":769,"dst-color":774,"one-minus-dst-color":775,"src-alpha":770,"one-minus-src-alpha":771,"dst-alpha":772,"one-minus-dst-alpha":773,"src-alpha-saturated":776,"constant-color":32769,"one-minus-constant-color":32770,"constant-alpha":32771,"one-minus-constant-alpha":32772})}function E5(t,e){return`Illegal parameter ${e} for ${t}`}function Sc(t,e,i){if(!(e in i))throw new Error(E5(t,e));return i[e]}function A5(t,e){return e}function xP(t){const e={};return t.addressModeU&&(e[10242]=tb(t.addressModeU)),t.addressModeV&&(e[10243]=tb(t.addressModeV)),t.addressModeW&&(e[32882]=tb(t.addressModeW)),t.magFilter&&(e[10240]=wP(t.magFilter)),(t.minFilter||t.mipmapFilter)&&(e[10241]=I5(t.minFilter||"linear",t.mipmapFilter)),t.lodMinClamp!==void 0&&(e[33082]=t.lodMinClamp),t.lodMaxClamp!==void 0&&(e[33083]=t.lodMaxClamp),t.type==="comparison-sampler"&&(e[34892]=34894),t.compare&&(e[34893]=Qb("compare",t.compare)),t.maxAnisotropy&&(e[34046]=t.maxAnisotropy),e}function tb(t){switch(t){case"clamp-to-edge":return 33071;case"repeat":return 10497;case"mirror-repeat":return 33648}}function wP(t){switch(t){case"nearest":return 9728;case"linear":return 9729}}function I5(t,e){if(!e)return wP(t);switch(t){case"nearest":return e==="nearest"?9984:9986;case"linear":return e==="nearest"?9985:9987}}class fl extends cr{constructor(i,r={}){super(i,r);Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"glTarget");Z(this,"glUsage");Z(this,"glIndexType",5123);Z(this,"byteLength");Z(this,"bytesUsed");this.device=i,this.gl=this.device.gl;const o=typeof r=="object"?r.handle:void 0;this.handle=o||this.gl.createBuffer(),i.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glTarget=P5(this.props.usage),this.glUsage=R5(this.props.usage),this.glIndexType=this.props.indexType==="uint32"?5125:5123,r.data?this._initWithData(r.data,r.byteOffset,r.byteLength):this._initWithByteLength(r.byteLength||0)}_initWithData(i,r=0,o=i.byteLength+r){const h=this.glTarget;this.gl.bindBuffer(h,this.handle),this.gl.bufferData(h,o,this.glUsage),this.gl.bufferSubData(h,r,i),this.gl.bindBuffer(h,null),this.bytesUsed=o,this.byteLength=o,this._setDebugData(i,r,o),this.trackAllocatedMemory(o)}_initWithByteLength(i){Yi(i>=0);let r=i;i===0&&(r=new Float32Array(0));const o=this.glTarget;return this.gl.bindBuffer(o,this.handle),this.gl.bufferData(o,r,this.glUsage),this.gl.bindBuffer(o,null),this.bytesUsed=i,this.byteLength=i,this._setDebugData(null,0,i),this.trackAllocatedMemory(i),this}destroy(){!this.destroyed&&this.handle&&(this.removeStats(),this.trackDeallocatedMemory(),this.gl.deleteBuffer(this.handle),this.destroyed=!0,this.handle=null)}write(i,r=0){this.gl.bindBuffer(36663,this.handle),this.gl.bufferSubData(36663,r,i),this.gl.bindBuffer(36663,null),this._setDebugData(i,r,i.byteLength)}async readAsync(i=0,r){return this.readSyncWebGL(i,r)}readSyncWebGL(i=0,r){r=r??this.byteLength-i;const o=new Uint8Array(r),h=0;return this.gl.bindBuffer(36662,this.handle),this.gl.getBufferSubData(36662,i,o,h,r),this.gl.bindBuffer(36662,null),this._setDebugData(o,i,r),o}}function P5(t){return t&cr.INDEX?34963:t&cr.VERTEX?34962:t&cr.UNIFORM?35345:34962}function R5(t){return t&cr.INDEX||t&cr.VERTEX?35044:t&cr.UNIFORM?35048:35044}class ev extends bg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");Z(this,"parameters");this.device=i,this.parameters=xP(r),this.handle=this.handle||this.device.gl.createSampler(),this._setSamplerParameters(this.parameters)}destroy(){this.handle&&(this.device.gl.deleteSampler(this.handle),this.handle=void 0)}toString(){return`Sampler(${this.id},${JSON.stringify(this.props)})`}_setSamplerParameters(i){for(const[r,o]of Object.entries(i)){const h=Number(r);switch(h){case 33082:case 33083:this.device.gl.samplerParameterf(this.handle,h,o);break;default:this.device.gl.samplerParameteri(this.handle,h,o);break}}}}class qh extends mg{constructor(i,r){super(i,{...Fn.defaultProps,...r});Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"texture");this.device=i,this.gl=this.device.gl,this.handle=null,this.texture=r.texture}}const C5={parameters:{},pixelStore:{},pixels:null,border:0,dataFormat:void 0,textureUnit:void 0,target:void 0},Af=class Af extends Fn{constructor(i,r){var o;super(i,{...C5,format:"rgba8unorm",...r});Z(this,"MAX_ATTRIBUTES");Z(this,"device");Z(this,"gl");Z(this,"handle");Z(this,"sampler");Z(this,"view");Z(this,"glFormat");Z(this,"type");Z(this,"dataFormat");Z(this,"mipmaps");Z(this,"target");Z(this,"textureUnit");Z(this,"loaded",!1);Z(this,"_video");this.device=i,this.gl=this.device.gl,this.handle=this.props.handle||this.gl.createTexture(),this.device.setSpectorMetadata(this.handle,{...this.props,data:typeof this.props.data}),this.glFormat=6408,this.target=M5(this.props),this.loaded=!1,typeof((o=this.props)==null?void 0:o.data)=="string"&&Object.assign(this.props,{data:U4(this.props.data)}),this.initialize(this.props),Object.seal(this)}destroy(){this.handle&&(this.gl.deleteTexture(this.handle),this.removeStats(),this.trackDeallocatedMemory("Texture"),this.destroyed=!0)}toString(){return`Texture(${this.id},${this.width}x${this.height})`}createView(i){return new qh(this.device,{...i,texture:this})}initialize(i={}){if(this.props.dimension==="cube")return this.initializeCube(i);let r=i.data;if(r instanceof Promise)return r.then(ve=>this.initialize(Object.assign({},i,{pixels:ve,data:ve}))),this;const o=typeof HTMLVideoElement<"u"&&r instanceof HTMLVideoElement;if(o&&r.readyStatethis.initialize(i)),this;const{parameters:h={}}=i,{pixels:d=null,pixelStore:c={},textureUnit:x=void 0,mipmaps:S=!0}=i;r||(r=d);let{width:P,height:M,dataFormat:D,type:H,compressed:Q=!1}=i;const{depth:G=0}=i,_e=vP(i.format);return{width:P,height:M,compressed:Q,dataFormat:D,type:H}=this._deduceParameters({format:i.format,type:H,dataFormat:D,compressed:Q,data:r,width:P,height:M}),this.width=P,this.height=M,this.glFormat=_e,this.type=H,this.dataFormat=D,this.textureUnit=x,Number.isFinite(this.textureUnit)&&(this.gl.activeTexture(33984+this.textureUnit),this.gl.bindTexture(this.target,this.handle)),this.mipmaps=S,this.setImageData({data:r,width:P,height:M,depth:G,format:_e,type:H,dataFormat:D,parameters:c,compressed:Q}),this.setSampler(i.sampler),this._setSamplerParameters(h),this.view=this.createView({...this.props,mipLevelCount:1,arrayLayerCount:1}),S&&this.device.isTextureFormatFilterable(i.format)&&this.generateMipmap(),o&&(this._video={video:r,parameters:h,lastTime:r.readyState>=HTMLVideoElement.HAVE_CURRENT_DATA?r.currentTime:-1}),this}initializeCube(i){const{mipmaps:r=!0,parameters:o={}}=i;return this.setCubeMapImageData(i).then(()=>{this.loaded=!0,r&&this.generateMipmap(i),this.setSampler(i.sampler),this._setSamplerParameters(o)}),this}setSampler(i={}){let r;i instanceof ev?(this.sampler=i,r=i.props):(this.sampler=new ev(this.device,i),r=i);const o=xP(r);return this._setSamplerParameters(o),this}resize(i){const{height:r,width:o,mipmaps:h=!1}=i;return o!==this.width||r!==this.height?this.initialize({width:o,height:r,format:this.format,type:this.type,dataFormat:this.dataFormat,mipmaps:h}):this}update(){if(this._video){const{video:i,parameters:r,lastTime:o}=this._video;if(o===i.currentTime||i.readyState{this.gl.generateMipmap(this.target)}),this.gl.bindTexture(this.target,null),this}setImageData(i){if(this.props.dimension==="3d"||this.props.dimension==="2d-array")return this.setImageData3D(i);this.trackDeallocatedMemory("Texture");const{target:r=this.target,pixels:o=null,level:h=0,glFormat:d=this.glFormat,offset:c=0,parameters:x={}}=i;let{data:S=null,type:P=this.type,width:M=this.width,height:D=this.height,dataFormat:H=this.dataFormat,compressed:Q=!1}=i;S||(S=o),{type:P,dataFormat:H,compressed:Q,width:M,height:D}=this._deduceParameters({format:this.props.format,type:P,dataFormat:H,compressed:Q,data:S,width:M,height:D});const{gl:G}=this;G.bindTexture(this.target,this.handle);let _e=null;if({data:S,dataType:_e}=this._getDataType({data:S,compressed:Q}),cl(this.gl,x,()=>{switch(_e){case"null":G.texImage2D(r,h,d,M,D,0,H,P,S);break;case"typed-array":G.texImage2D(r,h,d,M,D,0,H,P,S,c);break;case"buffer":this.device.gl.bindBuffer(35052,S.handle||S),this.device.gl.texImage2D(r,h,d,M,D,0,H,P,c),this.device.gl.bindBuffer(35052,null);break;case"browser-object":G.texImage2D(r,h,d,M,D,0,H,P,S);break;case"compressed":for(const[ve,be]of S.entries())G.compressedTexImage2D(r,ve,be.format,be.width,be.height,0,be.data);break;default:Yi(!1,"Unknown image data type")}}),S&&S.byteLength)this.trackAllocatedMemory(S.byteLength,"Texture");else{const ve=SE(this.props.format);this.trackAllocatedMemory(this.width*this.height*ve,"Texture")}return this.loaded=!0,this}setSubImageData({target:i=this.target,pixels:r=null,data:o=null,x:h=0,y:d=0,width:c=this.width,height:x=this.height,level:S=0,glFormat:P=this.glFormat,type:M=this.type,dataFormat:D=this.dataFormat,compressed:H=!1,offset:Q=0,parameters:G={}}){if({type:M,dataFormat:D,compressed:H,width:c,height:x}=this._deduceParameters({format:this.props.format,type:M,dataFormat:D,compressed:H,data:o,width:c,height:x}),Yi(this.depth===1,"texSubImage not supported for 3D textures"),o||(o=r),o&&o.data){const _e=o;o=_e.data,c=_e.shape[0],x=_e.shape[1]}o instanceof fl&&(o=o.handle),this.gl.bindTexture(this.target,this.handle),cl(this.gl,G,()=>{H?this.gl.compressedTexSubImage2D(i,S,h,d,c,x,P,o):o===null?this.gl.texSubImage2D(i,S,h,d,c,x,D,M,null):ArrayBuffer.isView(o)?this.gl.texSubImage2D(i,S,h,d,c,x,D,M,o,Q):typeof WebGLBuffer<"u"&&o instanceof WebGLBuffer?(this.device.gl.bindBuffer(35052,o),this.device.gl.texSubImage2D(i,S,h,d,c,x,D,M,Q),this.device.gl.bindBuffer(35052,null)):this.device.gl.texSubImage2D(i,S,h,d,c,x,D,M,o)}),this.gl.bindTexture(this.target,null)}copyFramebuffer(i={}){return it.error("Texture.copyFramebuffer({...}) is no logner supported, use copyToTexture(source, target, opts})")(),null}getActiveUnit(){return this.gl.getParameter(34016)-33984}bind(i=this.textureUnit){const{gl:r}=this;return i!==void 0&&(this.textureUnit=i,r.activeTexture(33984+i)),r.bindTexture(this.target,this.handle),i}unbind(i=this.textureUnit){const{gl:r}=this;return i!==void 0&&(this.textureUnit=i,r.activeTexture(33984+i)),r.bindTexture(this.target,null),i}_getDataType({data:i,compressed:r=!1}){return r?{data:i,dataType:"compressed"}:i===null?{data:i,dataType:"null"}:ArrayBuffer.isView(i)?{data:i,dataType:"typed-array"}:i instanceof fl?{data:i.handle,dataType:"buffer"}:typeof WebGLBuffer<"u"&&i instanceof WebGLBuffer?{data:i,dataType:"buffer"}:{data:i,dataType:"browser-object"}}_deduceParameters(i){const{format:r,data:o}=i;let{width:h,height:d,dataFormat:c,type:x,compressed:S}=i;const P=kg(r);return c=c||P.dataFormat,x=x||P.type,S=S||P.compressed,{width:h,height:d}=this._deduceImageSize(o,h,d),{dataFormat:c,type:x,compressed:S,width:h,height:d,format:r,data:o}}_deduceImageSize(i,r,o){let h;return typeof ImageData<"u"&&i instanceof ImageData?h={width:i.width,height:i.height}:typeof HTMLImageElement<"u"&&i instanceof HTMLImageElement?h={width:i.naturalWidth,height:i.naturalHeight}:typeof HTMLCanvasElement<"u"&&i instanceof HTMLCanvasElement?h={width:i.width,height:i.height}:typeof ImageBitmap<"u"&&i instanceof ImageBitmap?h={width:i.width,height:i.height}:typeof HTMLVideoElement<"u"&&i instanceof HTMLVideoElement?h={width:i.videoWidth,height:i.videoHeight}:i?h={width:r,height:o}:h={width:r>=0?r:1,height:o>=0?o:1},Yi(h,"Could not deduced texture size"),Yi(r===void 0||h.width===r,"Deduced texture width does not match supplied width"),Yi(o===void 0||h.height===o,"Deduced texture height does not match supplied height"),h}async setCubeMapImageData(i){const{gl:r}=this,{width:o,height:h,pixels:d,data:c,format:x=6408,type:S=5121}=i,P=d||c,M=await Promise.all(Af.FACES.map(D=>{const H=P[D];return Promise.all(Array.isArray(H)?H:[H])}));this.bind(),Af.FACES.forEach((D,H)=>{M[H].length>1&&this.props.mipmaps!==!1&&it.warn(`${this.id} has mipmap and multiple LODs.`)(),M[H].forEach((Q,G)=>{o&&h?r.texImage2D(D,G,x,o,h,0,x,S,Q):r.texImage2D(D,G,x,x,S,Q)})}),this.unbind()}setImageDataForFace(i){const{face:r,width:o,height:h,pixels:d,data:c,format:x=6408,type:S=5121}=i,{gl:P}=this,M=d||c;return this.bind(),M instanceof Promise?M.then(D=>this.setImageDataForFace(Object.assign({},i,{face:r,data:D,pixels:D}))):this.width||this.height?P.texImage2D(r,0,x,o,h,0,x,S,M):P.texImage2D(r,0,x,x,S,M),this}setImageData3D(i){const{level:r=0,dataFormat:o,format:h,type:d,width:c,height:x,depth:S=1,offset:P=0,data:M,parameters:D={}}=i;this.trackDeallocatedMemory("Texture"),this.gl.bindTexture(this.target,this.handle);const H=kg(h);if(cl(this.gl,D,()=>{ArrayBuffer.isView(M)&&this.gl.texImage3D(this.target,r,H.format,c,x,S,0,H.dataFormat,H.type,M),M instanceof fl&&(this.gl.bindBuffer(35052,M.handle),this.gl.texImage3D(this.target,r,o,c,x,S,0,h,d,P))}),M&&M.byteLength)this.trackAllocatedMemory(M.byteLength,"Texture");else{const Q=SE(this.props.format);this.trackAllocatedMemory(this.width*this.height*this.depth*Q,"Texture")}return this.loaded=!0,this}_setSamplerParameters(i){if(!gg(i)){k5(i),this.gl.bindTexture(this.target,this.handle);for(const[r,o]of Object.entries(i)){const h=Number(r),d=o;switch(h){case 33082:case 33083:this.gl.texParameterf(this.target,h,d);break;default:this.gl.texParameteri(this.target,h,d);break}}this.gl.bindTexture(this.target,null)}}};Z(Af,"FACES",[34069,34070,34071,34072,34073,34074]);let Mo=Af;function M5(t){switch(t.dimension){case"2d":return 3553;case"cube":return 34067;case"2d-array":return 35866;case"3d":return 32879;case"1d":case"cube-array":default:throw new Error(t.dimension)}}function k5(t){it.log(1,"texture sampler parameters",t)()}class bf extends vg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"gl");Z(this,"handle");const o=r.handle===null;if(this.device=i,this.gl=i.gl,this.handle=this.props.handle||o?this.props.handle:this.gl.createFramebuffer(),!o){i.setSpectorMetadata(this.handle,{id:this.props.id,props:this.props}),this.autoCreateAttachmentTextures();const h=this.gl.bindFramebuffer(36160,this.handle);for(let d=0;dit.info("Spector capture started:",e)()),Fi==null||Fi.onCapture.add(e=>{it.info("Spector capture complete:",e)(),Fi==null||Fi.getResultUI(),Fi==null||Fi.resultView.display(),Fi==null||Fi.resultView.addCapture(e)})),t!=null&&t.canvas){if(typeof t.spector=="string"&&t.spector!==t.canvas.id)return Fi;Fi==null||Fi.startCapture(t==null?void 0:t.canvas,500),new Promise(e=>setTimeout(e,2e3)).then(e=>{it.info("Spector capture stopped after 2 seconds")(),Fi==null||Fi.stopCapture()})}return Fi}const V5="https://unpkg.com/webgl-debug@2.0.1/index.js";function TP(t){return t.luma=t.luma||{},t.luma}async function j5(){El()&&!globalThis.WebGLDebugUtils&&(globalThis.global=globalThis.global||globalThis,globalThis.global.module={},await BI(V5))}function $5(t,e={}){return t?e.debug?H5(t,e):W5(t):null}function W5(t){const e=TP(t);return e.realContext?e.realContext:t}function H5(t,e){if(!globalThis.WebGLDebugUtils)return it.warn("webgl-debug not loaded")(),t;const i=TP(t);if(i.debugContext)return i.debugContext;globalThis.WebGLDebugUtils.init({...Wh,...t});const r=globalThis.WebGLDebugUtils.makeDebugContext(t,X5.bind(null,e),q5.bind(null,e));for(const d in Wh)!(d in r)&&typeof Wh[d]=="number"&&(r[d]=Wh[d]);class o{}Object.setPrototypeOf(r,Object.getPrototypeOf(t)),Object.setPrototypeOf(o,r);const h=Object.create(o);return i.realContext=t,i.debugContext=h,h.debug=!0,h}function ib(t,e){e=Array.from(e).map(r=>r===void 0?"undefined":r);let i=globalThis.WebGLDebugUtils.glFunctionArgsToString(t,e);return i=`${i.slice(0,100)}${i.length>100?"...":""}`,`gl.${t}(${i})`}function X5(t,e,i,r){r=Array.from(r).map(c=>c===void 0?"undefined":c);const o=globalThis.WebGLDebugUtils.glEnumToString(e),h=globalThis.WebGLDebugUtils.glFunctionArgsToString(i,r),d=`${o} in gl.${i}(${h})`;it.error(d)();debugger;if(t.throwOnError)throw new Error(d)}function q5(t,e,i){let r="";if(it.level>=1&&(r=ib(e,i),it.log(1,r)()),t.break&&t.break.length>0&&(r=r||ib(e,i),t.break.every(h=>r.indexOf(h)!==-1)))debugger;for(const o of i)if(o===void 0){if(r=r||ib(e,i),t.throwOnError)throw new Error(`Undefined argument: ${r}`);it.error(`Undefined argument: ${r}`)();debugger}}function Z5(t){const e=t.split(/\r?\n/),i=[];for(const r of e){if(r.length<=1)continue;const o=r.split(":");if(o.length===2){const[M,D]=o;i.push({message:D.trim(),type:PE(M),lineNum:0,linePos:0});continue}const[h,d,c,...x]=o;let S=parseInt(c,10);isNaN(S)&&(S=0);let P=parseInt(d,10);isNaN(P)&&(P=0),i.push({message:x.join(":").trim(),type:PE(h),lineNum:S,linePos:P})}return i}function PE(t){const e=["warning","error","info"],i=t.toLowerCase();return e.includes(i)?i:"info"}class Y5 extends yg{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");switch(this.device=i,this.props.stage){case"vertex":this.handle=this.props.handle||this.device.gl.createShader(35633);break;case"fragment":this.handle=this.props.handle||this.device.gl.createShader(35632);break;default:throw new Error(this.props.stage)}this._compile(this.source)}destroy(){this.handle&&(this.removeStats(),this.device.gl.deleteShader(this.handle),this.destroyed=!0)}async getCompilationInfo(){return await this._waitForCompilationComplete(),this.getCompilationInfoSync()}getCompilationInfoSync(){const i=this.device.gl.getShaderInfoLog(this.handle);return Z5(i)}getTranslatedSource(){const r=this.device.getExtension("WEBGL_debug_shaders").WEBGL_debug_shaders;return r==null?void 0:r.getTranslatedShaderSource(this.handle)}async _compile(i){i=(h=>h.startsWith("#version ")?h:`#version 100
${h}`)(i);const{gl:o}=this.device;if(o.shaderSource(this.handle,i),o.compileShader(this.handle),it.level===0){this.compilationStatus="pending";return}if(!this.device.features.has("compilation-status-async-webgl")){if(this._getCompilationStatus(),this.debugShader(),this.compilationStatus==="error")throw new Error(`GLSL compilation errors in ${this.props.stage} shader ${this.props.id}`);return}it.once(1,"Shader compilation is asynchronous")(),await this._waitForCompilationComplete(),it.info(2,`Shader ${this.id} - async compilation complete: ${this.compilationStatus}`)(),this._getCompilationStatus(),this.debugShader()}async _waitForCompilationComplete(){const i=async h=>await new Promise(d=>setTimeout(d,h));if(!this.device.features.has("compilation-status-async-webgl")){await i(10);return}const{gl:o}=this.device;for(;;){if(o.getShaderParameter(this.handle,37297))return;await i(10)}}_getCompilationStatus(){this.compilationStatus=this.device.gl.getShaderParameter(this.handle,35713)?"success":"error"}}const K5=256,J5=1024,G5=16384,rb=6144,Q5=[1,2,4,8];class eV extends Ob{constructor(i,r){super(i,r);Z(this,"device");Z(this,"glParameters");this.device=i,Pm(this.device.gl),this.setParameters(this.props.parameters),this.clear()}end(){Lf(this.device.gl)}pushDebugGroup(i){}popDebugGroup(){}insertDebugMarker(i){}setParameters(i={}){const r={...this.glParameters};this.props.framebuffer&&(r.framebuffer=this.props.framebuffer),this.props.depthReadOnly&&(r.depthMask=!this.props.depthReadOnly),r.stencilMask=this.props.stencilReadOnly?0:1,r[35977]=this.props.discard,i.viewport&&(i.viewport.length>=6?(r.viewport=i.viewport.slice(0,4),r.depthRange=[i.viewport[4],i.viewport[5]]):r.viewport=i.viewport),i.scissorRect&&(r.scissorTest=!0,r.scissor=i.scissorRect),i.blendConstant&&(r.blendColor=i.blendConstant),i.stencilReference&&(console.warn("RenderPassParameters.stencilReference not yet implemented in WebGL"),i[2967]=i.stencilReference),i.colorMask&&(r.colorMask=Q5.map(o=>!!(o&i.colorMask))),this.glParameters=r,Tu(this.device.gl,r)}beginOcclusionQuery(i){const r=this.props.occlusionQuerySet;r==null||r.beginOcclusionQuery()}endOcclusionQuery(){const i=this.props.occlusionQuerySet;i==null||i.endOcclusionQuery()}clear(){const i={...this.glParameters};let r=0;this.props.clearColor!==!1&&(r|=G5,i.clearColor=this.props.clearColor),this.props.clearDepth!==!1&&(r|=K5,i.clearDepth=this.props.clearDepth),this.props.clearStencil!==!1&&(r|=J5,i.clearStencil=this.props.clearStencil),r!==0&&cl(this.device.gl,i,()=>{this.device.gl.clear(r)})}clearColorBuffer(i=0,r=[0,0,0,0]){cl(this.device.gl,{framebuffer:this.props.framebuffer},()=>{switch(r.constructor){case Int32Array:this.device.gl.clearBufferiv(rb,i,r);break;case Uint32Array:this.device.gl.clearBufferuiv(rb,i,r);break;case Float32Array:default:this.device.gl.clearBufferfv(rb,i,r);break}})}}const tV="Failed to deduce GL constant from typed array";function iV(t){switch(ArrayBuffer.isView(t)?t.constructor:t){case Float32Array:return 5126;case Uint16Array:return 5123;case Uint32Array:return 5125;case Uint8Array:return 5121;case Uint8ClampedArray:return 5121;case Int8Array:return 5120;case Int16Array:return 5122;case Int32Array:return 5124;default:throw new Error(tV)}}function tv(t,e){const{clamped:i=!0}=e||{};switch(t){case 5126:return Float32Array;case 5123:case 33635:case 32819:case 32820:return Uint16Array;case 5125:return Uint32Array;case 5121:return i?Uint8ClampedArray:Uint8Array;case 5120:return Int8Array;case 5122:return Int16Array;case 5124:return Int32Array;default:throw new Error("Failed to deduce typed array type from GL constant")}}const rV={offset:0,stride:0,type:5126,size:1,divisor:0,normalized:!1,integer:!1},sV={deprecatedProps:{instanced:"divisor",isInstanced:"divisor"}};class vf{constructor(...e){Z(this,"offset");Z(this,"stride");Z(this,"type");Z(this,"size");Z(this,"divisor");Z(this,"normalized");Z(this,"integer");Z(this,"buffer");Z(this,"index");e.forEach(i=>this._assign(i)),Object.freeze(this)}static getBytesPerElement(e){return tv(e.type||5126).BYTES_PER_ELEMENT}static getBytesPerVertex(e){return Yi(e.size),tv(e.type||5126).BYTES_PER_ELEMENT*e.size}static resolve(...e){return new vf(rV,...e)}toString(){return JSON.stringify(this)}get BYTES_PER_ELEMENT(){return vf.getBytesPerElement(this)}get BYTES_PER_VERTEX(){return vf.getBytesPerVertex(this)}_assign(e={}){return e=z4("Accessor",e,sV),e.type!==void 0&&(this.type=e.type,(e.type===5124||e.type===5125)&&(this.integer=!0)),e.size!==void 0&&(this.size=e.size),e.offset!==void 0&&(this.offset=e.offset),e.stride!==void 0&&(this.stride=e.stride),e.normalize!==void 0&&(this.normalized=e.normalize),e.normalized!==void 0&&(this.normalized=e.normalized),e.integer!==void 0&&(this.integer=e.integer),e.divisor!==void 0&&(this.divisor=e.divisor),e.buffer!==void 0&&(this.buffer=e.buffer),e.index!==void 0&&(typeof e.index=="boolean"?this.index=e.index?1:0:this.index=e.index),e.instanced!==void 0&&(this.divisor=e.instanced?1:0),e.isInstanced!==void 0&&(this.divisor=e.isInstanced?1:0),this.offset===void 0&&delete this.offset,this.stride===void 0&&delete this.stride,this.type===void 0&&delete this.type,this.size===void 0&&delete this.size,this.divisor===void 0&&delete this.divisor,this.normalized===void 0&&delete this.normalized,this.integer===void 0&&delete this.integer,this.buffer===void 0&&delete this.buffer,this.index===void 0&&delete this.index,this}}function nV(t){return oV.includes(t)}const oV=[35678,35680,35679,35682,36289,36292,36293,36298,36299,36300,36303,36306,36307,36308,36311],SP={5126:[5126,1,"float","f32","float32"],35664:[5126,2,"vec2","vec2","float32x2"],35665:[5126,3,"vec3","vec3","float32x3"],35666:[5126,4,"vec4","vec4","float32x4"],5124:[5124,1,"int","i32","sint32"],35667:[5124,2,"ivec2","vec2","sint32x2"],35668:[5124,3,"ivec3","vec3","sint32x3"],35669:[5124,4,"ivec4","vec4","sint32x4"],5125:[5125,1,"uint","u32","uint32"],36294:[5125,2,"uvec2","vec2","uint32x2"],36295:[5125,3,"uvec3","vec3","uint32x3"],36296:[5125,4,"uvec4","vec4","uint32x4"],35670:[5126,1,"bool","f32","float32"],35671:[5126,2,"bvec2","vec2","float32x2"],35672:[5126,3,"bvec3","vec3","float32x3"],35673:[5126,4,"bvec4","vec4","float32x4"],35674:[5126,8,"mat2","mat2x2"],35685:[5126,8,"mat2x3","mat2x3"],35686:[5126,8,"mat2x4","mat2x4"],35687:[5126,12,"mat3x2","mat3x2"],35675:[5126,12,"mat3","mat3x3"],35688:[5126,12,"mat3x4","mat3x4"],35689:[5126,16,"mat4x2","mat4x2"],35690:[5126,16,"mat4x3","mat4x3"],35676:[5126,16,"mat4","mat4x4"]};function EP(t){const e=SP[t];if(!e)throw new Error("uniform");const[i,r,,o]=e;return{format:o,components:r,glType:i}}function aV(t){const e=SP[t];if(!e)throw new Error("attribute");const[,i,,r,o]=e;return{attributeType:r,vertexFormat:o,components:i}}function lV(t,e){const i={attributes:[],bindings:[]};i.attributes=cV(t,e);const r=dV(t,e);for(const c of r){const x=c.uniforms.map(S=>({name:S.name,format:S.format,byteOffset:S.byteOffset,byteStride:S.byteStride,arrayLength:S.arrayLength}));i.bindings.push({type:"uniform",name:c.name,location:c.location,visibility:(c.vertex?1:0)&(c.fragment?2:0),minBindingSize:c.byteLength,uniforms:x})}const o=uV(t,e);let h=0;for(const c of o)if(nV(c.type)){const{viewDimension:x,sampleType:S}=pV(c.type);i.bindings.push({type:"texture",name:c.name,location:h,viewDimension:x,sampleType:S}),c.textureUnit=h,h+=1}o.length&&(i.uniforms=o);const d=hV(t,e);return d!=null&&d.length&&(i.varyings=d),i}function cV(t,e){const i=[],r=t.getProgramParameter(e,35721);for(let o=0;o=0){const{attributeType:S}=aV(c),P=/instance/i.test(d)?"instance":"vertex";i.push({name:d,location:x,stepMode:P,type:S})}}return i.sort((o,h)=>o.location-h.location),i}function hV(t,e){const i=[],r=t.getProgramParameter(e,35971);for(let o=0;oo.location-h.location),i}function uV(t,e){const i=[],r=t.getProgramParameter(e,35718);for(let o=0;o1)for(let H=0;Ht.getActiveUniformBlockParameter(e,h,d),r=[],o=t.getProgramParameter(e,35382);for(let h=0;hh.location-d.location),r}const fV={35678:["2d","float"],35680:["cube","float"],35679:["3d","float"],35682:["3d","depth"],36289:["2d-array","float"],36292:["2d-array","depth"],36293:["cube","float"],36298:["2d","sint"],36299:["3d","sint"],36300:["cube","sint"],36303:["2d-array","uint"],36306:["2d","uint"],36307:["3d","uint"],36308:["cube","uint"],36311:["2d-array","uint"]};function pV(t){const e=fV[t];if(!e)throw new Error("sampler");const[i,r]=e;return{viewDimension:i,sampleType:r}}function _V(t){if(t[t.length-1]!=="]")return{name:t,length:1,isArray:!1};const i=/([^[]*)(\[[0-9]+\])?/.exec(t);if(!i||i.length<2)throw new Error(`Failed to parse GLSL uniform name ${t}`);return{name:i[1],length:i[2]?1:0,isArray:!!i[2]}}function gV(t,e,i,r){const o=t;let h=r;h===!0&&(h=1),h===!1&&(h=0);const d=typeof h=="number"?[h]:h;switch(i){case 35678:case 35680:case 35679:case 35682:case 36289:case 36292:case 36293:case 36298:case 36299:case 36300:case 36303:case 36306:case 36307:case 36308:case 36311:if(typeof r!="number")throw new Error("samplers must be set to integers");return t.uniform1i(e,r);case 5126:return t.uniform1fv(e,d);case 35664:return t.uniform2fv(e,d);case 35665:return t.uniform3fv(e,d);case 35666:return t.uniform4fv(e,d);case 5124:return t.uniform1iv(e,d);case 35667:return t.uniform2iv(e,d);case 35668:return t.uniform3iv(e,d);case 35669:return t.uniform4iv(e,d);case 35670:return t.uniform1iv(e,d);case 35671:return t.uniform2iv(e,d);case 35672:return t.uniform3iv(e,d);case 35673:return t.uniform4iv(e,d);case 5125:return o.uniform1uiv(e,d,1);case 36294:return o.uniform2uiv(e,d,2);case 36295:return o.uniform3uiv(e,d,3);case 36296:return o.uniform4uiv(e,d,4);case 35674:return t.uniformMatrix2fv(e,!1,d);case 35675:return t.uniformMatrix3fv(e,!1,d);case 35676:return t.uniformMatrix4fv(e,!1,d);case 35685:return o.uniformMatrix2x3fv(e,!1,d);case 35686:return o.uniformMatrix2x4fv(e,!1,d);case 35687:return o.uniformMatrix3x2fv(e,!1,d);case 35688:return o.uniformMatrix3x4fv(e,!1,d);case 35689:return o.uniformMatrix4x2fv(e,!1,d);case 35690:return o.uniformMatrix4x3fv(e,!1,d)}throw new Error("Illegal uniform")}function mV(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 3;case"line-loop-webgl":return 2;case"triangle-list":return 4;case"triangle-strip":return 5;case"triangle-fan-webgl":return 6;default:throw new Error(t)}}function yV(t){switch(t){case"point-list":return 0;case"line-list":return 1;case"line-strip":return 1;case"line-loop-webgl":return 1;case"triangle-list":return 4;case"triangle-strip":return 4;case"triangle-fan-webgl":return 4;default:throw new Error(t)}}const RE=4;class bV extends hu{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");Z(this,"vs");Z(this,"fs");Z(this,"introspectedLayout");Z(this,"uniforms",{});Z(this,"bindings",{});Z(this,"varyings",null);Z(this,"_uniformCount",0);Z(this,"_uniformSetters",{});this.device=i,this.handle=this.props.handle||this.device.gl.createProgram(),this.device.setSpectorMetadata(this.handle,{id:this.props.id}),this.vs=r.vs,this.fs=r.fs;const{varyings:o,bufferMode:h=35981}=r;switch(o&&o.length>0&&(this.varyings=o,this.device.gl.transformFeedbackVaryings(this.handle,o,h)),this._linkShaders(),it.time(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.introspectedLayout=lV(this.device.gl,this.handle),it.timeEnd(1,`RenderPipeline ${this.id} - shaderLayout introspection`)(),this.shaderLayout=E4(this.introspectedLayout,r.shaderLayout),this.props.topology){case"triangle-fan-webgl":case"line-loop-webgl":it.warn(`Primitive topology ${this.props.topology} is deprecated and will be removed in v9.1`);break}}destroy(){this.handle&&(this.device.gl.deleteProgram(this.handle),this.destroyed=!0)}setBindings(i,r){for(const[o,h]of Object.entries(i)){const d=this.shaderLayout.bindings.find(c=>c.name===o)||this.shaderLayout.bindings.find(c=>c.name===`${o}Uniforms`);if(!d){const c=this.shaderLayout.bindings.map(x=>`"${x.name}"`).join(", ");r!=null&&r.disableWarnings||it.warn(`Unknown binding "${o}" in render pipeline "${this.id}", expected one of ${c}`)();continue}switch(h||it.warn(`Unsetting binding "${o}" in render pipeline "${this.id}"`)(),d.type){case"uniform":if(!(h instanceof fl)&&!(h.buffer instanceof fl))throw new Error("buffer value");break;case"texture":if(!(h instanceof qh||h instanceof Mo||h instanceof bf))throw new Error("texture value");break;case"sampler":it.warn(`Ignoring sampler ${o}`)();break;default:throw new Error(d.type)}this.bindings[o]=h}}draw(i){var _e;const{renderPass:r,parameters:o=this.props.parameters,topology:h=this.props.topology,vertexArray:d,vertexCount:c,instanceCount:x,isInstanced:S=!1,firstVertex:P=0,transformFeedback:M}=i,D=mV(h),H=!!d.indexBuffer,Q=(_e=d.indexBuffer)==null?void 0:_e.glIndexType;if(this.linkStatus!=="success")return it.info(2,`RenderPipeline:${this.id}.draw() aborted - waiting for shader linking`)(),!1;if(!this._areTexturesRenderable()||c===0)return it.info(2,`RenderPipeline:${this.id}.draw() aborted - textures not yet loaded`)(),!1;if(c===0)return it.info(2,`RenderPipeline:${this.id}.draw() aborted - no vertices to draw`)(),!0;this.device.gl.useProgram(this.handle),d.bindBeforeRender(r),M&&M.begin(this.props.topology),this._applyBindings(),this._applyUniforms();const G=r;return T5(this.device,o,G.glParameters,()=>{H&&S?this.device.gl.drawElementsInstanced(D,c||0,Q,P,x||0):H?this.device.gl.drawElements(D,c||0,Q,P):S?this.device.gl.drawArraysInstanced(D,P,c||0,x||0):this.device.gl.drawArrays(D,P,c||0),M&&M.end()}),d.unbindAfterRender(r),!0}setUniformsWebGL(i){const{bindings:r}=ex(i);Object.keys(r).forEach(o=>{it.warn(`Unsupported value "${JSON.stringify(r[o])}" used in setUniforms() for key ${o}. Use setBindings() instead?`)()}),Object.assign(this.uniforms,i)}async _linkShaders(){const{gl:i}=this.device;if(i.attachShader(this.handle,this.vs.handle),i.attachShader(this.handle,this.fs.handle),it.time(RE,`linkProgram for ${this.id}`)(),i.linkProgram(this.handle),it.timeEnd(RE,`linkProgram for ${this.id}`)(),it.level,!this.device.features.has("compilation-status-async-webgl")){const o=this._getLinkStatus();this._reportLinkStatus(o);return}it.once(1,"RenderPipeline linking is asynchronous")(),await this._waitForLinkComplete(),it.info(2,`RenderPipeline ${this.id} - async linking complete: ${this.linkStatus}`)();const r=this._getLinkStatus();this._reportLinkStatus(r)}_reportLinkStatus(i){var r;switch(i){case"success":return;default:throw this.vs.compilationStatus==="error"?(this.vs.debugShader(),new Error(`Error during compilation of shader ${this.vs.id}`)):((r=this.fs)==null?void 0:r.compilationStatus)==="error"?(this.fs.debugShader(),new Error(`Error during compilation of shader ${this.fs.id}`)):new Error(`Error during ${i}: ${this.device.gl.getProgramInfoLog(this.handle)}`)}}_getLinkStatus(){const{gl:i}=this.device;return i.getProgramParameter(this.handle,35714)?(i.validateProgram(this.handle),i.getProgramParameter(this.handle,35715)?(this.linkStatus="success","success"):(this.linkStatus="error","validation")):(this.linkStatus="error","linking")}async _waitForLinkComplete(){const i=async h=>await new Promise(d=>setTimeout(d,h));if(!this.device.features.has("compilation-status-async-webgl")){await i(10);return}const{gl:o}=this.device;for(;;){if(o.getProgramParameter(this.handle,37297))return;await i(10)}}_areTexturesRenderable(){let i=!0;for(const[,r]of Object.entries(this.bindings))r instanceof Mo&&(r.update(),i=i&&r.loaded);return i}_applyBindings(){if(this.linkStatus!=="success")return;const{gl:i}=this.device;i.useProgram(this.handle);let r=0,o=0;for(const h of this.shaderLayout.bindings){const d=this.bindings[h.name]||this.bindings[h.name.replace(/Uniforms$/,"")];if(!d)throw new Error(`No value for binding ${h.name} in ${this.id}`);switch(h.type){case"uniform":const{name:c}=h,x=i.getUniformBlockIndex(this.handle,c);if(x===4294967295)throw new Error(`Invalid uniform block name ${c}`);i.uniformBlockBinding(this.handle,o,x),d instanceof fl?i.bindBufferBase(35345,o,d.handle):i.bindBufferRange(35345,o,d.buffer.handle,d.offset||0,d.size||d.buffer.byteLength-d.offset),o+=1;break;case"texture":if(!(d instanceof qh||d instanceof Mo||d instanceof bf))throw new Error("texture");let S;if(d instanceof qh)S=d.texture;else if(d instanceof Mo)S=d;else if(d instanceof bf&&d.colorAttachments[0]instanceof qh)it.warn("Passing framebuffer in texture binding may be deprecated. Use fbo.colorAttachments[0] instead")(),S=d.colorAttachments[0].texture;else throw new Error("No texture");i.activeTexture(33984+r),i.bindTexture(S.target,S.handle),r+=1;break;case"sampler":break;case"storage":case"read-only-storage":throw new Error(`binding type '${h.type}' not supported in WebGL`)}}}_applyUniforms(){for(const i of this.shaderLayout.uniforms||[]){const{name:r,location:o,type:h,textureUnit:d}=i,c=this.uniforms[r]??d;c!==void 0&&gV(this.device.gl,o,h,c)}}}class vV extends Nb{constructor(i){super(i,{});Z(this,"device");Z(this,"commands",[]);this.device=i}submitCommands(i=this.commands){for(const r of i)switch(r.name){case"copy-buffer-to-buffer":xV(this.device,r.options);break;case"copy-buffer-to-texture":wV(this.device,r.options);break;case"copy-texture-to-buffer":TV(this.device,r.options);break;case"copy-texture-to-texture":SV(this.device,r.options);break}}}function xV(t,e){const i=e.source,r=e.destination;t.gl.bindBuffer(36662,i.handle),t.gl.bindBuffer(36663,r.handle),t.gl.copyBufferSubData(36662,36663,e.sourceOffset??0,e.destinationOffset??0,e.size),t.gl.bindBuffer(36662,null),t.gl.bindBuffer(36663,null)}function wV(t,e){throw new Error("Not implemented")}function TV(t,e){const{source:i,mipLevel:r=0,aspect:o="all",width:h=e.source.width,height:d=e.source.height,depthOrArrayLayers:c=0,origin:x=[0,0],destination:S,byteOffset:P=0,bytesPerRow:M,rowsPerImage:D}=e;if(o!=="all")throw new Error("not supported");if(r!==0||c!==0||M||D)throw new Error("not implemented");const{framebuffer:H,destroyFramebuffer:Q}=AP(i);let G;try{const _e=S,ve=h||H.width,be=d||H.height,Se=kg(H.texture.props.format),Be=Se.dataFormat,je=Se.type;t.gl.bindBuffer(35051,_e.handle),G=t.gl.bindFramebuffer(36160,H.handle),t.gl.readPixels(x[0],x[1],ve,be,Be,je,P)}finally{t.gl.bindBuffer(35051,null),G!==void 0&&t.gl.bindFramebuffer(36160,G),Q&&H.destroy()}}function SV(t,e){const{source:i,destinationMipLevel:r=0,origin:o=[0,0],destinationOrigin:h=[0,0],destination:d}=e;let{width:c=e.destination.width,height:x=e.destination.height}=e;const{framebuffer:S,destroyFramebuffer:P}=AP(i),[M,D]=o,[H,Q,G]=h,_e=t.gl.bindFramebuffer(36160,S.handle);let ve=null,be;if(d instanceof Mo)ve=d,c=Number.isFinite(c)?c:ve.width,x=Number.isFinite(x)?x:ve.height,ve.bind(0),be=ve.target;else throw new Error("invalid destination");switch(be){case 3553:case 34067:t.gl.copyTexSubImage2D(be,r,H,Q,M,D,c,x);break;case 35866:case 32879:t.gl.copyTexSubImage3D(be,r,H,Q,G,M,D,c,x);break}ve&&ve.unbind(),t.gl.bindFramebuffer(36160,_e),P&&S.destroy()}function AP(t){if(t instanceof Fn){const{width:e,height:i,id:r}=t;return{framebuffer:t.device.createFramebuffer({id:`framebuffer-for-${r}`,width:e,height:i,colorAttachments:[t]}),destroyFramebuffer:!0}}return{framebuffer:t,destroyFramebuffer:!1}}class EV extends Fb{constructor(i,r){super(i,r);Z(this,"device");Z(this,"commandBuffer");this.device=i,this.commandBuffer=new vV(i)}destroy(){}finish(){this.commandBuffer.submitCommands()}copyBufferToBuffer(i){this.commandBuffer.commands.push({name:"copy-buffer-to-buffer",options:i})}copyBufferToTexture(i){this.commandBuffer.commands.push({name:"copy-buffer-to-texture",options:i})}copyTextureToBuffer(i){this.commandBuffer.commands.push({name:"copy-texture-to-buffer",options:i})}copyTextureToTexture(i){this.commandBuffer.commands.push({name:"copy-texture-to-texture",options:i})}pushDebugGroup(i){}popDebugGroup(){}insertDebugMarker(i){}resolveQuerySet(i,r,o){}}class cx extends Bb{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");Z(this,"buffer",null);Z(this,"bufferValue",null);this.device=i,this.handle=this.device.gl.createVertexArray()}get[Symbol.toStringTag](){return"VertexArray"}static isConstantAttributeZeroSupported(i){return XO()==="Chrome"}destroy(){var i;super.destroy(),this.buffer&&((i=this.buffer)==null||i.destroy()),this.handle&&(this.device.gl.deleteVertexArray(this.handle),this.handle=void 0)}setIndexBuffer(i){const r=i;if(r&&r.glTarget!==34963)throw new Error("Use .setBuffer()");this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34963,r?r.handle:null),this.indexBuffer=r,this.device.gl.bindVertexArray(null)}setBuffer(i,r){const o=r;if(o.glTarget===34963)throw new Error("Use .setIndexBuffer()");const{size:h,type:d,stride:c,offset:x,normalized:S,integer:P,divisor:M}=this._getAccessor(i);this.device.gl.bindVertexArray(this.handle),this.device.gl.bindBuffer(34962,o.handle),P?this.device.gl.vertexAttribIPointer(i,h,d,c,x):this.device.gl.vertexAttribPointer(i,h,d,S,c,x),this.device.gl.bindBuffer(34962,null),this.device.gl.enableVertexAttribArray(i),this.device.gl.vertexAttribDivisor(i,M||0),this.attributes[i]=o,this.device.gl.bindVertexArray(null)}setConstantWebGL(i,r){this._enable(i,!1),this.attributes[i]=r}bindBeforeRender(){this.device.gl.bindVertexArray(this.handle),this._applyConstantAttributes()}unbindAfterRender(){this.device.gl.bindVertexArray(null)}_applyConstantAttributes(){for(let i=0;i{for(const r in i)this.setBuffer(r,i[r])})}setBuffer(i,r){const o=this._getVaryingIndex(i),{buffer:h,byteLength:d,byteOffset:c}=this._getBufferRange(r);if(o<0){this.unusedBuffers[i]=h,it.warn(`${this.id} unusedBuffers varying buffer ${i}`)();return}this.buffers[o]={buffer:h,byteLength:d,byteOffset:c},this.bindOnUse||this._bindBuffer(o,h,c,d)}getBuffer(i){if(CE(i))return this.buffers[i]||null;const r=this._getVaryingIndex(i);return r>=0?this.buffers[r]:null}bind(i=this.handle){if(typeof i!="function")return this.gl.bindTransformFeedback(36386,i),this;let r;return this._bound?r=i():(this.gl.bindTransformFeedback(36386,this.handle),this._bound=!0,r=i(),this._bound=!1,this.gl.bindTransformFeedback(36386,null)),r}unbind(){this.bind(null)}_getBufferRange(i){if(i instanceof fl)return{buffer:i,byteOffset:0,byteLength:i.byteLength};const{buffer:r,byteOffset:o=0,byteLength:h=i.buffer.byteLength}=i;return{buffer:r,byteOffset:o,byteLength:h}}_getVaryingIndex(i){if(CE(i))return Number(i);for(const r of this.layout.varyings)if(i===r.name)return r.location;return-1}_bindBuffers(){for(const i in this.buffers){const{buffer:r,byteLength:o,byteOffset:h}=this._getBufferRange(this.buffers[i]);this._bindBuffer(Number(i),r,h,o)}}_unbindBuffers(){for(const i in this.buffers)this.gl.bindBufferBase(35982,Number(i),null)}_bindBuffer(i,r,o=0,h){const d=r&&r.handle;!d||h===void 0?this.gl.bindBufferBase(35982,i,d):this.gl.bindBufferRange(35982,i,d,o,h)}}function CE(t){return typeof t=="number"?Number.isInteger(t):/^\d+$/.test(t)}class RV extends Lb{constructor(i,r){super(i,r);Z(this,"device");Z(this,"handle");Z(this,"target",null);Z(this,"_queryPending",!1);Z(this,"_pollingPromise",null);if(this.device=i,r.count>1)throw new Error("WebGL QuerySet can only have one value");this.handle=this.device.gl.createQuery(),Object.seal(this)}get[Symbol.toStringTag](){return"Query"}destroy(){this.device.gl.deleteQuery(this.handle)}beginTimestampQuery(){return this._begin(35007)}endTimestampQuery(){this._end()}beginOcclusionQuery(i){return this._begin(i!=null&&i.conservative?36202:35887)}endOcclusionQuery(){this._end()}beginTransformFeedbackQuery(){return this._begin(35976)}endTransformFeedbackQuery(){this._end()}async resolveQuery(){return[await this.pollQuery()]}_begin(i){this._queryPending||(this.target=i,this.device.gl.beginQuery(this.target,this.handle))}_end(){this._queryPending||this.target&&(this.device.gl.endQuery(this.target),this.target=null,this._queryPending=!0)}isResultAvailable(){if(!this._queryPending)return!1;const i=this.device.gl.getQueryParameter(this.handle,34919);return i&&(this._queryPending=!1),i}isTimerDisjoint(){return this.device.gl.getParameter(36795)}getResult(){return this.device.gl.getQueryParameter(this.handle,34918)}getTimerMilliseconds(){return this.getResult()/1e6}pollQuery(i=Number.POSITIVE_INFINITY){if(this._pollingPromise)return this._pollingPromise;let r=0;return this._pollingPromise=new Promise((o,h)=>{const d=()=>{this.isResultAvailable()?(o(this.getResult()),this._pollingPromise=null):r++>i?(h("Timed out"),this._pollingPromise=null):requestAnimationFrame(d)};requestAnimationFrame(d)}),this._pollingPromise}}function IP(t){switch(t){case 6406:case 33326:case 6403:return 1;case 33328:case 33319:return 2;case 6407:case 34837:return 3;case 6408:case 34836:return 4;default:return Yi(!1),0}}function CV(t){switch(t){case 5121:return 1;case 33635:case 32819:case 32820:return 2;case 5126:return 4;default:return Yi(!1),0}}function MV(t,e){var _e,ve;const{sourceX:i=0,sourceY:r=0,sourceFormat:o=6408,sourceAttachment:h=36064}=e||{};let{target:d=null,sourceWidth:c,sourceHeight:x,sourceType:S}=e||{};const{framebuffer:P,deleteFramebuffer:M}=PP(t);Yi(P);const{gl:D,handle:H}=P;c=c||P.width,x=x||P.height;const Q=h-36064;S=S||((ve=(_e=P.colorAttachments[Q])==null?void 0:_e.texture)==null?void 0:ve.type)||5121,d=OV(d,S,o,c,x),S=S||iV(d);const G=D.bindFramebuffer(36160,H);return D.readPixels(i,r,c,x,o,S,d),D.bindFramebuffer(36160,G||null),M&&P.destroy(),d}function kV(t,e){const{target:i,sourceX:r=0,sourceY:o=0,sourceFormat:h=6408,targetByteOffset:d=0}=e||{};let{sourceWidth:c,sourceHeight:x,sourceType:S}=e||{};const{framebuffer:P,deleteFramebuffer:M}=PP(t);Yi(P),c=c||P.width,x=x||P.height;const D=P;S=S||5121;let H=i;if(!H){const G=IP(h),_e=CV(S),ve=d+c*x*G*_e;H=D.device.createBuffer({byteLength:ve})}const Q=t.device.createCommandEncoder();return Q.copyTextureToBuffer({source:t,width:c,height:x,origin:[r,o],destination:H,byteOffset:d}),Q.destroy(),M&&P.destroy(),H}function PP(t){return t instanceof vg?{framebuffer:t,deleteFramebuffer:!1}:{framebuffer:DV(t),deleteFramebuffer:!0}}function DV(t,e){const{device:i,width:r,height:o,id:h}=t;return i.createFramebuffer({...e,id:`framebuffer-for-${h}`,width:r,height:o,colorAttachments:[t]})}function OV(t,e,i,r,o){if(t)return t;e=e||5121;const h=tv(e,{clamped:!1}),d=IP(i);return new h(r*o*d)}const FV=256,NV=1024,BV=16384,zV="clear: bad arguments";function LV(t,e){const{framebuffer:i=null,color:r=null,depth:o=null,stencil:h=null}=e||{},d={};i&&(d.framebuffer=i);let c=0;r&&(c|=BV,r!==!0&&(d.clearColor=r)),o&&(c|=FV,o!==!0&&(d.clearDepth=o)),h&&(c|=NV,o!==!0&&(d.clearStencil=o)),Yi(c!==0,zV);const x=t.gl;cl(x,d,()=>{x.clear(c)})}const rf=1,_c=class _c extends cu{constructor(i){var x,S;super({...i,id:i.id||Nc("webgl-device")});Z(this,"type","webgl");Z(this,"handle");Z(this,"features");Z(this,"limits");Z(this,"info");Z(this,"canvasContext");Z(this,"lost");Z(this,"_resolveContextLost");Z(this,"renderPass",null);Z(this,"gl");Z(this,"debug",!1);Z(this,"_canvasSizeInfo",{clientWidth:0,clientHeight:0,devicePixelRatio:1});Z(this,"_extensions",{});Z(this,"_polyfilled",!1);Z(this,"spectorJS");Z(this,"_constants");const r=(x=i.gl)==null?void 0:x.device;if(r)throw new Error(`WebGL context already attached to device ${r.id}`);const o=((S=i.gl)==null?void 0:S.canvas)||i.canvas;this.canvasContext=new F5(this,{...i,canvas:o}),this.lost=new Promise(P=>{this._resolveContextLost=P});let h=i.gl||null;if(h||(h=e5(this.canvasContext.canvas,{...i,onContextLost:P=>{var M;return(M=this._resolveContextLost)==null?void 0:M.call(this,{reason:"destroyed",message:"Entered sleep mode, or too many apps or browser tabs are using the GPU."})}})),!h)throw new Error("WebGL context creation failed");this.handle=h,this.gl=h,this.gl.device=this,this.gl._version=2,i.spector&&(this.spectorJS=U5({...this.props,canvas:this.handle.canvas})),this.info=t5(this.gl,this._extensions),this.limits=new x5(this.gl),this.features=new v5(this.gl,this._extensions,this.props.disabledFeatures),this.props.initalizeFeatures&&this.features.initializeFeatures(),this.canvasContext.resize();const{enable:d=!0,copyState:c=!1}=i;mP(this.gl,{enable:d,copyState:c,log:(...P)=>it.log(1,...P)()}),i.debug&&(this.gl=$5(this.gl,{...i,throwOnError:!0}),this.debug=!0,it.level=Math.max(it.level,1),it.warn("WebGL debug mode activated. Performance reduced.")())}static isSupported(){return typeof WebGL2RenderingContext<"u"}static attach(i){if(i instanceof _c)return i;if((i==null?void 0:i.device)instanceof cu)return i.device;if(!UV(i))throw new Error("Invalid WebGL2RenderingContext");return new _c({gl:i})}static async create(i={}){var c;it.groupCollapsed(rf,"WebGLDevice created")();const r=[];i.debug&&r.push(j5()),i.spector&&r.push(L5()),typeof i.canvas=="string"&&r.push(Qv.pageLoaded);const o=await Promise.allSettled(r);for(const x of o)x.status==="rejected"&&it.error(`Failed to initialize debug libraries ${x.reason}`)();if(it.probe(rf+1,"DOM is loaded")(),(c=i.gl)!=null&&c.device)return it.warn("reattaching existing device")(),_c.attach(i.gl);const h=new _c(i),d=`Created ${h.type}${h.debug?" debug":""} context: ${h.info.vendor}, ${h.info.renderer} for canvas: ${h.canvasContext.id}`;return it.probe(rf,d)(),it.table(rf,h.info)(),it.groupEnd(rf)(),h}destroy(){}get isLost(){return this.gl.isContextLost()}getSize(){return[this.gl.drawingBufferWidth,this.gl.drawingBufferHeight]}isTextureFormatSupported(i){return lx(this.gl,i,this._extensions)}isTextureFormatFilterable(i){return g5(this.gl,i,this._extensions)}isTextureFormatRenderable(i){return m5(this.gl,i,this._extensions)}createCanvasContext(i){throw new Error("WebGL only supports a single canvas")}createBuffer(i){const r=this._getBufferProps(i);return new fl(this,r)}_createTexture(i){return new Mo(this,i)}createExternalTexture(i){throw new Error("createExternalTexture() not implemented")}createSampler(i){return new ev(this,i)}createShader(i){return new Y5(this,i)}createFramebuffer(i){return new bf(this,i)}createVertexArray(i){return new cx(this,i)}createTransformFeedback(i){return new PV(this,i)}createQuerySet(i){return new RV(this,i)}createRenderPipeline(i){return new bV(this,i)}beginRenderPass(i){return new eV(this,i)}createComputePipeline(i){throw new Error("ComputePipeline not supported in WebGL")}beginComputePass(i){throw new Error("ComputePass not supported in WebGL")}createCommandEncoder(i){return new EV(this,i)}submit(){var i;(i=this.renderPass)==null||i.end(),this.renderPass=null}readPixelsToArrayWebGL(i,r){return MV(i,r)}readPixelsToBufferWebGL(i,r){return kV(i,r)}setParametersWebGL(i){Tu(this.gl,i)}getParametersWebGL(i){return gP(this.gl,i)}withParametersWebGL(i,r){return cl(this.gl,i,r)}clearWebGL(i){LV(this,i)}resetWebGL(){it.warn("WebGLDevice.resetWebGL is deprecated, use only for debugging")(),qU(this.gl)}loseDevice(){var h;let i=!1;const o=this.getExtension("WEBGL_lose_context").WEBGL_lose_context;return o&&(i=!0,o.loseContext()),(h=this._resolveContextLost)==null||h.call(this,{reason:"destroyed",message:"Application triggered context loss"}),i}pushState(){Pm(this.gl)}popState(){Lf(this.gl)}setSpectorMetadata(i,r){i.__SPECTOR_Metadata=r}getGLKey(i,r){r=r||this.gl2||this.gl;const o=Number(i);for(const h in r)if(r[h]===o)return`GL.${h}`;return String(i)}setConstantAttributeWebGL(i,r){const o=this.limits.maxVertexAttributes;this._constants=this._constants||new Array(o).fill(null);const h=this._constants[i];switch(h&&WV(h,r)&&it.info(1,`setConstantAttributeWebGL(${i}) could have been skipped, value unchanged`)(),this._constants[i]=r,r.constructor){case Float32Array:VV(this,i,r);break;case Int32Array:jV(this,i,r);break;case Uint32Array:$V(this,i,r);break;default:Yi(!1)}}getExtension(i){return yl(this.gl,i,this._extensions),this._extensions}};Z(_c,"type","webgl");let xf=_c;function UV(t){return typeof WebGL2RenderingContext<"u"&&t instanceof WebGL2RenderingContext?!0:!!(t&&Number.isFinite(t._version))}function VV(t,e,i){switch(i.length){case 1:t.gl.vertexAttrib1fv(e,i);break;case 2:t.gl.vertexAttrib2fv(e,i);break;case 3:t.gl.vertexAttrib3fv(e,i);break;case 4:t.gl.vertexAttrib4fv(e,i);break;default:Yi(!1)}}function jV(t,e,i){t.gl.vertexAttribI4iv(e,i)}function $V(t,e,i){t.gl.vertexAttribI4uiv(e,i)}function WV(t,e){if(!t||!e||t.length!==e.length||t.constructor!==e.constructor)return!1;for(let i=0;i0||o.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}const W8=`#version 300 es
+`;function jP(t){return t.doublePrecision&&t.value instanceof Float64Array}function j8(t,e){const i=e.size,r=NP(i),o=BP(i),h=e.getBufferLayout();return jP(e)?new Bf(t,{vs:V8,bufferLayout:[{name:"aFrom",byteStride:8*i,attributes:[{attribute:"aFrom",format:o,byteOffset:0},{attribute:"aFrom64Low",format:o,byteOffset:4*i}]},{name:"aTo",byteStride:8*i,attributes:[{attribute:"aTo",format:o,byteOffset:0},{attribute:"aTo64Low",format:o,byteOffset:4*i}]}],modules:[z6],defines:{ATTRIBUTE_TYPE:r,ATTRIBUTE_SIZE:i},moduleSettings:{},varyings:["vCurrent","vCurrent64Low"],bufferMode:35980,disableWarnings:!0}):new Bf(t,{vs:U8,bufferLayout:[{name:"aFrom",format:o},{name:"aTo",format:h.attributes[0].format}],defines:{ATTRIBUTE_TYPE:r},varyings:["vCurrent"],disableWarnings:!0})}class $8 extends VP{constructor({device:e,attribute:i,timeline:r}){super({device:e,attribute:i,timeline:r}),this.type="spring",this.texture=q8(e),this.framebuffer=Z8(e,this.texture),this.transform=X8(e,i)}start(e,i){const r=this.currentLength,o=this.currentStartIndices;super.start(e,i);const{buffers:h,attribute:d}=this;for(let x=0;x<2;x++)h[x]=UP({device:this.device,buffer:h[x],attribute:d,fromLength:r,toLength:this.currentLength,fromStartIndices:o,getData:e.enter});h[2]=LP({device:this.device,source:h[0],target:h[2]}),this.setBuffer(h[1]);const{model:c}=this.transform;c.setVertexCount(Math.floor(this.currentLength/d.size)),d.isConstant?c.setConstantAttributes({aTo:d.value}):c.setAttributes({aTo:d.getBuffer()})}onUpdate(){const{buffers:e,transform:i,framebuffer:r,transition:o}=this,h=this.settings;i.model.setAttributes({aPrev:e[0],aCur:e[1]}),i.transformFeedback.setBuffers({vNext:e[2]}),i.model.setUniforms({stiffness:h.stiffness,damping:h.damping}),i.run({framebuffer:r,discard:!1,parameters:{viewport:[0,0,1,1]},clearColor:[0,0,0,0]}),zP(e),this.setBuffer(e[1]),this.device.readPixelsToArrayWebGL(r)[0]>0||o.end()}delete(){super.delete(),this.transform.destroy(),this.texture.destroy(),this.framebuffer.destroy()}}const W8=`#version 300 es
#define SHADER_NAME spring-transition-vertex-shader
#define EPSILON 0.00001
@@ -959,7 +959,7 @@ fragColor = vFillColor;
fragColor.a *= inCircle;
DECKGL_FILTER_COLOR(fragColor, geometry);
}
-`,iA=[0,0,0,255],r$={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:iA},getLineColor:{type:"accessor",value:iA},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},hm=class hm extends uv{getShaders(){return super.getShaders({vs:t$,fs:i$,modules:[q6,_L]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){var i;super.updateState(e),e.changeFlags.extensionsChanged&&((i=this.state.model)==null||i.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:i,radiusScale:r,radiusMinPixels:o,radiusMaxPixels:h,stroked:d,filled:c,billboard:x,antialiasing:S,lineWidthUnits:P,lineWidthScale:M,lineWidthMinPixels:D,lineWidthMaxPixels:H}=this.props,Q=this.state.model;Q.setUniforms(e),Q.setUniforms({stroked:d?1:0,filled:c,billboard:x,antialiasing:S,radiusUnits:Ag[i],radiusScale:r,radiusMinPixels:o,radiusMaxPixels:h,lineWidthUnits:Ag[P],lineWidthScale:M,lineWidthMinPixels:D,lineWidthMaxPixels:H}),Q.draw(this.context.renderPass)}_getModel(){const e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new gu(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new iU({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};hm.defaultProps=r$,hm.layerName="ScatterplotLayer";let fv=hm;const YP=`
+`,iA=[0,0,0,255],r$={radiusUnits:"meters",radiusScale:{type:"number",min:0,value:1},radiusMinPixels:{type:"number",min:0,value:0},radiusMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},lineWidthUnits:"meters",lineWidthScale:{type:"number",min:0,value:1},lineWidthMinPixels:{type:"number",min:0,value:0},lineWidthMaxPixels:{type:"number",min:0,value:Number.MAX_SAFE_INTEGER},stroked:!1,filled:!0,billboard:!1,antialiasing:!0,getPosition:{type:"accessor",value:t=>t.position},getRadius:{type:"accessor",value:1},getFillColor:{type:"accessor",value:iA},getLineColor:{type:"accessor",value:iA},getLineWidth:{type:"accessor",value:1},strokeWidth:{deprecatedFor:"getLineWidth"},outline:{deprecatedFor:"stroked"},getColor:{deprecatedFor:["getFillColor","getLineColor"]}},hm=class hm extends uv{getShaders(){return super.getShaders({vs:t$,fs:i$,modules:[qz,_L]})}initializeState(){this.getAttributeManager().addInstanced({instancePositions:{size:3,type:"float64",fp64:this.use64bitPositions(),transition:!0,accessor:"getPosition"},instanceRadius:{size:1,transition:!0,accessor:"getRadius",defaultValue:1},instanceFillColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getFillColor",defaultValue:[0,0,0,255]},instanceLineColors:{size:this.props.colorFormat.length,transition:!0,type:"unorm8",accessor:"getLineColor",defaultValue:[0,0,0,255]},instanceLineWidths:{size:1,transition:!0,accessor:"getLineWidth",defaultValue:1}})}updateState(e){var i;super.updateState(e),e.changeFlags.extensionsChanged&&((i=this.state.model)==null||i.destroy(),this.state.model=this._getModel(),this.getAttributeManager().invalidateAll())}draw({uniforms:e}){const{radiusUnits:i,radiusScale:r,radiusMinPixels:o,radiusMaxPixels:h,stroked:d,filled:c,billboard:x,antialiasing:S,lineWidthUnits:P,lineWidthScale:M,lineWidthMinPixels:D,lineWidthMaxPixels:H}=this.props,Q=this.state.model;Q.setUniforms(e),Q.setUniforms({stroked:d?1:0,filled:c,billboard:x,antialiasing:S,radiusUnits:Ag[i],radiusScale:r,radiusMinPixels:o,radiusMaxPixels:h,lineWidthUnits:Ag[P],lineWidthScale:M,lineWidthMinPixels:D,lineWidthMaxPixels:H}),Q.draw(this.context.renderPass)}_getModel(){const e=[-1,-1,0,1,-1,0,-1,1,0,1,1,0];return new gu(this.context.device,{...this.getShaders(),id:this.props.id,bufferLayout:this.getAttributeManager().getBufferLayouts(),geometry:new iU({topology:"triangle-strip",attributes:{positions:{size:3,value:new Float32Array(e)}}}),isInstanced:!0})}};hm.defaultProps=r$,hm.layerName="ScatterplotLayer";let fv=hm;const YP=`
uniform bool filter_useSoftMargin;
uniform bool filter_enabled;
uniform bool filter_transformSize;
@@ -1693,4 +1693,4 @@ uniform ${F} ${N} u_${V};
#endif
`}),staticAttributes:p,staticUniforms:T}}class Yo{constructor(){this.boundProgram=null,this.boundLayoutVertexBuffer=null,this.boundPaintVertexBuffers=[],this.boundIndexBuffer=null,this.boundVertexOffset=null,this.boundDynamicVertexBuffer=null,this.vao=null}bind(n,u,p,_,m,T,A,R,C){this.context=n;let F=this.boundPaintVertexBuffers.length!==_.length;for(let N=0;!F&&N<_.length;N++)this.boundPaintVertexBuffers[N]!==_[N]&&(F=!0);!this.vao||this.boundProgram!==u||this.boundLayoutVertexBuffer!==p||F||this.boundIndexBuffer!==m||this.boundVertexOffset!==T||this.boundDynamicVertexBuffer!==A||this.boundDynamicVertexBuffer2!==R||this.boundDynamicVertexBuffer3!==C?this.freshBind(u,p,_,m,T,A,R,C):(n.bindVertexArray.set(this.vao),A&&A.bind(),m&&m.dynamicDraw&&m.bind(),R&&R.bind(),C&&C.bind())}freshBind(n,u,p,_,m,T,A,R){const C=n.numAttributes,F=this.context,N=F.gl;this.vao&&this.destroy(),this.vao=F.createVertexArray(),F.bindVertexArray.set(this.vao),this.boundProgram=n,this.boundLayoutVertexBuffer=u,this.boundPaintVertexBuffers=p,this.boundIndexBuffer=_,this.boundVertexOffset=m,this.boundDynamicVertexBuffer=T,this.boundDynamicVertexBuffer2=A,this.boundDynamicVertexBuffer3=R,u.enableAttributes(N,n);for(const V of p)V.enableAttributes(N,n);T&&T.enableAttributes(N,n),A&&A.enableAttributes(N,n),R&&R.enableAttributes(N,n),u.bind(),u.setVertexAttribPointers(N,n,m);for(const V of p)V.bind(),V.setVertexAttribPointers(N,n,m);T&&(T.bind(),T.setVertexAttribPointers(N,n,m)),_&&_.bind(),A&&(A.bind(),A.setVertexAttribPointers(N,n,m)),R&&(R.bind(),R.setVertexAttribPointers(N,n,m)),F.currentNumAttributes=C}destroy(){this.vao&&(this.context.deleteVertexArray(this.vao),this.vao=null)}}const Ol=(y,n,u,p,_)=>({u_matrix:y,u_texture:0,u_ele_delta:n,u_fog_matrix:u,u_fog_color:p?p.properties.get("fog-color"):c.aN.white,u_fog_ground_blend:p?p.properties.get("fog-ground-blend"):1,u_fog_ground_blend_opacity:p?p.calculateFogBlendOpacity(_):0,u_horizon_color:p?p.properties.get("horizon-color"):c.aN.white,u_horizon_fog_blend:p?p.properties.get("horizon-fog-blend"):1});function Ko(y){const n=[];for(let u=0;u({u_depth:new c.aI(Re,Le.u_depth),u_terrain:new c.aI(Re,Le.u_terrain),u_terrain_dim:new c.aJ(Re,Le.u_terrain_dim),u_terrain_matrix:new c.aK(Re,Le.u_terrain_matrix),u_terrain_unpack:new c.aL(Re,Le.u_terrain_unpack),u_terrain_exaggeration:new c.aJ(Re,Le.u_terrain_exaggeration)}))(n,Ae),this.binderUniforms=p?p.getUniforms(n,Ae):[]}draw(n,u,p,_,m,T,A,R,C,F,N,V,W,K,se,ie,oe,de){const ee=n.gl;if(this.failedToCreate)return;if(n.program.set(this.program),n.setDepthMode(p),n.setStencilMode(_),n.setColorMode(m),n.setCullFace(T),R){n.activeTexture.set(ee.TEXTURE2),ee.bindTexture(ee.TEXTURE_2D,R.depthTexture),n.activeTexture.set(ee.TEXTURE3),ee.bindTexture(ee.TEXTURE_2D,R.texture);for(const Ae in this.terrainUniforms)this.terrainUniforms[Ae].set(R[Ae])}for(const Ae in this.fixedUniforms)this.fixedUniforms[Ae].set(A[Ae]);se&&se.setUniforms(n,this.binderUniforms,W,{zoom:K});let me=0;switch(u){case ee.LINES:me=2;break;case ee.TRIANGLES:me=3;break;case ee.LINE_STRIP:me=1}for(const Ae of V.get()){const Re=Ae.vaos||(Ae.vaos={});(Re[C]||(Re[C]=new Yo)).bind(n,this,F,se?se.getPaintVertexBuffers():[],N,Ae.vertexOffset,ie,oe,de),ee.drawElements(u,Ae.primitiveLength*me,ee.UNSIGNED_SHORT,Ae.primitiveOffset*me*2)}}}function Y(y,n,u){const p=1/Lt(u,1,n.transform.tileZoom),_=Math.pow(2,u.tileID.overscaledZ),m=u.tileSize*Math.pow(2,n.transform.tileZoom)/_,T=m*(u.tileID.canonical.x+u.tileID.wrap*_),A=m*u.tileID.canonical.y;return{u_image:0,u_texsize:u.imageAtlasTexture.size,u_scale:[p,y.fromScale,y.toScale],u_fade:y.t,u_pixel_coord_upper:[T>>16,A>>16],u_pixel_coord_lower:[65535&T,65535&A]}}const ue=(y,n,u,p)=>{const _=n.style.light,m=_.properties.get("position"),T=[m.x,m.y,m.z],A=function(){var C=new c.A(9);return c.A!=Float32Array&&(C[1]=0,C[2]=0,C[3]=0,C[5]=0,C[6]=0,C[7]=0),C[0]=1,C[4]=1,C[8]=1,C}();_.properties.get("anchor")==="viewport"&&function(C,F){var N=Math.sin(F),V=Math.cos(F);C[0]=V,C[1]=N,C[2]=0,C[3]=-N,C[4]=V,C[5]=0,C[6]=0,C[7]=0,C[8]=1}(A,-n.transform.angle),function(C,F,N){var V=F[0],W=F[1],K=F[2];C[0]=V*N[0]+W*N[3]+K*N[6],C[1]=V*N[1]+W*N[4]+K*N[7],C[2]=V*N[2]+W*N[5]+K*N[8]}(T,T,A);const R=_.properties.get("color");return{u_matrix:y,u_lightpos:T,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+u,u_opacity:p}},Me=(y,n,u,p,_,m,T)=>c.e(ue(y,n,u,p),Y(m,n,T),{u_height_factor:-Math.pow(2,_.overscaledZ)/T.tileSize/8}),qe=y=>({u_matrix:y}),gt=(y,n,u,p)=>c.e(qe(y),Y(u,n,p)),Zt=(y,n)=>({u_matrix:y,u_world:n}),dr=(y,n,u,p,_)=>c.e(gt(y,n,u,p),{u_world:_}),fr=(y,n,u,p)=>{const _=y.transform;let m,T;if(p.paint.get("circle-pitch-alignment")==="map"){const A=Lt(u,1,_.zoom);m=!0,T=[A,A]}else m=!1,T=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(p.paint.get("circle-pitch-scale")==="map"),u_matrix:y.translatePosMatrix(n.posMatrix,u,p.paint.get("circle-translate"),p.paint.get("circle-translate-anchor")),u_pitch_with_map:+m,u_device_pixel_ratio:y.pixelRatio,u_extrude_scale:T}},Mr=(y,n,u)=>({u_matrix:y,u_inv_matrix:n,u_camera_to_center_distance:u.cameraToCenterDistance,u_viewport_size:[u.width,u.height]}),yr=(y,n,u=1)=>({u_matrix:y,u_color:n,u_overlay:0,u_overlay_scale:u}),Fl=y=>({u_matrix:y}),Is=(y,n,u,p)=>({u_matrix:y,u_extrude_scale:Lt(n,1,u),u_intensity:p});function Ps(y,n){const u=Math.pow(2,n.canonical.z),p=n.canonical.y;return[new c.Z(0,p/u).toLngLat().lat,new c.Z(0,(p+1)/u).toLngLat().lat]}const Nl=(y,n,u,p)=>{const _=y.transform;return{u_matrix:vp(y,n,u,p),u_ratio:1/Lt(n,1,_.zoom),u_device_pixel_ratio:y.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},qc=(y,n,u,p,_)=>c.e(Nl(y,n,u,_),{u_image:0,u_image_height:p}),yp=(y,n,u,p,_)=>{const m=y.transform,T=Jo(n,m);return{u_matrix:vp(y,n,u,_),u_texsize:n.imageAtlasTexture.size,u_ratio:1/Lt(n,1,m.zoom),u_device_pixel_ratio:y.pixelRatio,u_image:0,u_scale:[T,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},bp=(y,n,u,p,_,m)=>{const T=y.lineAtlas,A=Jo(n,y.transform),R=u.layout.get("line-cap")==="round",C=T.getDash(p.from,R),F=T.getDash(p.to,R),N=C.width*_.fromScale,V=F.width*_.toScale;return c.e(Nl(y,n,u,m),{u_patternscale_a:[A/N,-C.height/2],u_patternscale_b:[A/V,-F.height/2],u_sdfgamma:T.width/(256*Math.min(N,V)*y.pixelRatio)/2,u_image:0,u_tex_y_a:C.y,u_tex_y_b:F.y,u_mix:_.t})};function Jo(y,n){return 1/Lt(y,1,n.tileZoom)}function vp(y,n,u,p){return y.translatePosMatrix(p?p.posMatrix:n.tileID.posMatrix,n,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}const yy=(y,n,u,p,_)=>{return{u_matrix:y,u_tl_parent:n,u_scale_parent:u,u_buffer_scale:1,u_fade_t:p.mix,u_opacity:p.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:(T=_.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(m=_.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:by(_.paint.get("raster-hue-rotate"))};var m,T};function by(y){y*=Math.PI/180;const n=Math.sin(y),u=Math.cos(y);return[(2*u+1)/3,(-Math.sqrt(3)*n-u+1)/3,(Math.sqrt(3)*n-u+1)/3]}const xp=(y,n,u,p,_,m,T,A,R,C,F,N,V,W)=>{const K=T.transform;return{u_is_size_zoom_constant:+(y==="constant"||y==="source"),u_is_size_feature_constant:+(y==="constant"||y==="camera"),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:K.cameraToCenterDistance,u_pitch:K.pitch/360*2*Math.PI,u_rotate_symbol:+u,u_aspect_ratio:K.width/K.height,u_fade_change:T.options.fadeDuration?T.symbolFadeChange:1,u_matrix:A,u_label_plane_matrix:R,u_coord_matrix:C,u_is_text:+N,u_pitch_with_map:+p,u_is_along_line:_,u_is_variable_anchor:m,u_texsize:V,u_texture:0,u_translation:F,u_pitched_scale:W}},wp=(y,n,u,p,_,m,T,A,R,C,F,N,V,W,K)=>{const se=T.transform;return c.e(xp(y,n,u,p,_,m,T,A,R,C,F,N,V,K),{u_gamma_scale:p?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:T.pixelRatio,u_is_halo:+W})},vy=(y,n,u,p,_,m,T,A,R,C,F,N,V,W)=>c.e(wp(y,n,u,p,_,m,T,A,R,C,F,!0,N,!0,W),{u_texsize_icon:V,u_texture_icon:1}),Zc=(y,n,u)=>({u_matrix:y,u_opacity:n,u_color:u}),Lu=(y,n,u,p,_,m)=>c.e(function(T,A,R,C){const F=R.imageManager.getPattern(T.from.toString()),N=R.imageManager.getPattern(T.to.toString()),{width:V,height:W}=R.imageManager.getPixelSize(),K=Math.pow(2,C.tileID.overscaledZ),se=C.tileSize*Math.pow(2,R.transform.tileZoom)/K,ie=se*(C.tileID.canonical.x+C.tileID.wrap*K),oe=se*C.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:F.tl,u_pattern_br_a:F.br,u_pattern_tl_b:N.tl,u_pattern_br_b:N.br,u_texsize:[V,W],u_mix:A.t,u_pattern_size_a:F.displaySize,u_pattern_size_b:N.displaySize,u_scale_a:A.fromScale,u_scale_b:A.toScale,u_tile_units_to_pixels:1/Lt(C,1,R.transform.tileZoom),u_pixel_coord_upper:[ie>>16,oe>>16],u_pixel_coord_lower:[65535&ie,65535&oe]}}(p,m,u,_),{u_matrix:y,u_opacity:n}),Yc={fillExtrusion:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_lightpos:new c.aO(y,n.u_lightpos),u_lightintensity:new c.aJ(y,n.u_lightintensity),u_lightcolor:new c.aO(y,n.u_lightcolor),u_vertical_gradient:new c.aJ(y,n.u_vertical_gradient),u_opacity:new c.aJ(y,n.u_opacity)}),fillExtrusionPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_lightpos:new c.aO(y,n.u_lightpos),u_lightintensity:new c.aJ(y,n.u_lightintensity),u_lightcolor:new c.aO(y,n.u_lightcolor),u_vertical_gradient:new c.aJ(y,n.u_vertical_gradient),u_height_factor:new c.aJ(y,n.u_height_factor),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade),u_opacity:new c.aJ(y,n.u_opacity)}),fill:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix)}),fillPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),fillOutline:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world)}),fillOutlinePattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),circle:(y,n)=>({u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_scale_with_map:new c.aI(y,n.u_scale_with_map),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_extrude_scale:new c.aP(y,n.u_extrude_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_matrix:new c.aK(y,n.u_matrix)}),collisionBox:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_pixel_extrude_scale:new c.aP(y,n.u_pixel_extrude_scale)}),collisionCircle:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_inv_matrix:new c.aK(y,n.u_inv_matrix),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_viewport_size:new c.aP(y,n.u_viewport_size)}),debug:(y,n)=>({u_color:new c.aM(y,n.u_color),u_matrix:new c.aK(y,n.u_matrix),u_overlay:new c.aI(y,n.u_overlay),u_overlay_scale:new c.aJ(y,n.u_overlay_scale)}),clippingMask:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix)}),heatmap:(y,n)=>({u_extrude_scale:new c.aJ(y,n.u_extrude_scale),u_intensity:new c.aJ(y,n.u_intensity),u_matrix:new c.aK(y,n.u_matrix)}),heatmapTexture:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world),u_image:new c.aI(y,n.u_image),u_color_ramp:new c.aI(y,n.u_color_ramp),u_opacity:new c.aJ(y,n.u_opacity)}),hillshade:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_latrange:new c.aP(y,n.u_latrange),u_light:new c.aP(y,n.u_light),u_shadow:new c.aM(y,n.u_shadow),u_highlight:new c.aM(y,n.u_highlight),u_accent:new c.aM(y,n.u_accent)}),hillshadePrepare:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_dimension:new c.aP(y,n.u_dimension),u_zoom:new c.aJ(y,n.u_zoom),u_unpack:new c.aL(y,n.u_unpack)}),line:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels)}),lineGradient:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_image:new c.aI(y,n.u_image),u_image_height:new c.aJ(y,n.u_image_height)}),linePattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texsize:new c.aP(y,n.u_texsize),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_image:new c.aI(y,n.u_image),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),lineSDF:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_patternscale_a:new c.aP(y,n.u_patternscale_a),u_patternscale_b:new c.aP(y,n.u_patternscale_b),u_sdfgamma:new c.aJ(y,n.u_sdfgamma),u_image:new c.aI(y,n.u_image),u_tex_y_a:new c.aJ(y,n.u_tex_y_a),u_tex_y_b:new c.aJ(y,n.u_tex_y_b),u_mix:new c.aJ(y,n.u_mix)}),raster:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_tl_parent:new c.aP(y,n.u_tl_parent),u_scale_parent:new c.aJ(y,n.u_scale_parent),u_buffer_scale:new c.aJ(y,n.u_buffer_scale),u_fade_t:new c.aJ(y,n.u_fade_t),u_opacity:new c.aJ(y,n.u_opacity),u_image0:new c.aI(y,n.u_image0),u_image1:new c.aI(y,n.u_image1),u_brightness_low:new c.aJ(y,n.u_brightness_low),u_brightness_high:new c.aJ(y,n.u_brightness_high),u_saturation_factor:new c.aJ(y,n.u_saturation_factor),u_contrast_factor:new c.aJ(y,n.u_contrast_factor),u_spin_weights:new c.aO(y,n.u_spin_weights)}),symbolIcon:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texture:new c.aI(y,n.u_texture),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),symbolSDF:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texture:new c.aI(y,n.u_texture),u_gamma_scale:new c.aJ(y,n.u_gamma_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_is_halo:new c.aI(y,n.u_is_halo),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),symbolTextAndIcon:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texsize_icon:new c.aP(y,n.u_texsize_icon),u_texture:new c.aI(y,n.u_texture),u_texture_icon:new c.aI(y,n.u_texture_icon),u_gamma_scale:new c.aJ(y,n.u_gamma_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_is_halo:new c.aI(y,n.u_is_halo),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),background:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_opacity:new c.aJ(y,n.u_opacity),u_color:new c.aM(y,n.u_color)}),backgroundPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_opacity:new c.aJ(y,n.u_opacity),u_image:new c.aI(y,n.u_image),u_pattern_tl_a:new c.aP(y,n.u_pattern_tl_a),u_pattern_br_a:new c.aP(y,n.u_pattern_br_a),u_pattern_tl_b:new c.aP(y,n.u_pattern_tl_b),u_pattern_br_b:new c.aP(y,n.u_pattern_br_b),u_texsize:new c.aP(y,n.u_texsize),u_mix:new c.aJ(y,n.u_mix),u_pattern_size_a:new c.aP(y,n.u_pattern_size_a),u_pattern_size_b:new c.aP(y,n.u_pattern_size_b),u_scale_a:new c.aJ(y,n.u_scale_a),u_scale_b:new c.aJ(y,n.u_scale_b),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_tile_units_to_pixels:new c.aJ(y,n.u_tile_units_to_pixels)}),terrain:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texture:new c.aI(y,n.u_texture),u_ele_delta:new c.aJ(y,n.u_ele_delta),u_fog_matrix:new c.aK(y,n.u_fog_matrix),u_fog_color:new c.aM(y,n.u_fog_color),u_fog_ground_blend:new c.aJ(y,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.aJ(y,n.u_fog_ground_blend_opacity),u_horizon_color:new c.aM(y,n.u_horizon_color),u_horizon_fog_blend:new c.aJ(y,n.u_horizon_fog_blend)}),terrainDepth:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ele_delta:new c.aJ(y,n.u_ele_delta)}),terrainCoords:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texture:new c.aI(y,n.u_texture),u_terrain_coords_id:new c.aJ(y,n.u_terrain_coords_id),u_ele_delta:new c.aJ(y,n.u_ele_delta)}),sky:(y,n)=>({u_sky_color:new c.aM(y,n.u_sky_color),u_horizon_color:new c.aM(y,n.u_horizon_color),u_horizon:new c.aJ(y,n.u_horizon),u_sky_horizon_blend:new c.aJ(y,n.u_sky_horizon_blend)})};class Uu{constructor(n,u,p){this.context=n;const _=n.gl;this.buffer=_.createBuffer(),this.dynamicDraw=!!p,this.context.unbindVAO(),n.bindElementBuffer.set(this.buffer),_.bufferData(_.ELEMENT_ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete u.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(n){const u=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),u.bufferSubData(u.ELEMENT_ARRAY_BUFFER,0,n.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Vu={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Pn{constructor(n,u,p,_){this.length=u.length,this.attributes=p,this.itemSize=u.bytesPerElement,this.dynamicDraw=_,this.context=n;const m=n.gl;this.buffer=m.createBuffer(),n.bindVertexBuffer.set(this.buffer),m.bufferData(m.ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||delete u.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(n){if(n.length!==this.length)throw new Error(`Length of new data is ${n.length}, which doesn't match current length of ${this.length}`);const u=this.context.gl;this.bind(),u.bufferSubData(u.ARRAY_BUFFER,0,n.arrayBuffer)}enableAttributes(n,u){for(let p=0;p0){const Re=c.H();c.aR(Re,ee.placementInvProjMatrix,y.transform.glCoordMatrix),c.aR(Re,Re,ee.placementViewportMatrix),R.push({circleArray:Ae,circleOffset:F,transform:de.posMatrix,invTransform:Re,coord:de}),C+=Ae.length/4,F=C}me&&A.draw(m,T.LINES,Yt.disabled,Vi.disabled,y.colorModeForRenderPass(),Pi.disabled,{u_matrix:de.posMatrix,u_pixel_extrude_scale:[1/(N=y.transform).width,1/N.height]},y.style.map.terrain&&y.style.map.terrain.getTerrainData(de),u.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,y.transform.zoom,null,null,me.collisionVertexBuffer)}var N;if(!_||!R.length)return;const V=y.useProgram("collisionCircle"),W=new c.aS;W.resize(4*C),W._trim();let K=0;for(const oe of R)for(let de=0;de=0&&(oe[ee.associatedIconIndex]={shiftedAnchor:Ot,angle:Ci})}else It(ee.numGlyphs,se)}if(C){ie.clear();const de=y.icon.placedSymbolArray;for(let ee=0;eey.style.map.terrain.getElevation(Ye,Rd,br):null,za=u.layout.get("text-rotation-alignment")==="map";q(yt,Ye.posMatrix,y,_,oa,Na,oe,C,za,se,Ye.toUnwrapped(),K.width,K.height,aa,Zi)}const kr=Ye.posMatrix,un=_&&Ze||Pd,po=de||un?Ku:oa,Ba=gh,jr=nt&&u.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let $r;$r=nt?yt.iconsInText?vy(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,Lr,Qr,dt):wp(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,_,Lr,!0,dt):xp(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,_,Lr,dt);const Ar={program:Ht,buffers:Ut,uniformValues:$r,atlasTexture:cn,atlasTextureIcon:Ur,atlasInterpolation:ki,atlasInterpolationIcon:hs,isSDF:nt,hasHalo:jr};if(Ae&&yt.canOverlap){Re=!0;const Zi=Ut.segments.get();for(const za of Zi)ct.push({segments:new c.a0([za]),sortKey:za.sortKey,state:Ar,terrainData:Mi})}else ct.push({segments:Ut.segments,sortKey:0,state:Ar,terrainData:Mi})}Re&&ct.sort((Ye,Qe)=>Ye.sortKey-Qe.sortKey);for(const Ye of ct){const Qe=Ye.state;if(V.activeTexture.set(W.TEXTURE0),Qe.atlasTexture.bind(Qe.atlasInterpolation,W.CLAMP_TO_EDGE),Qe.atlasTextureIcon&&(V.activeTexture.set(W.TEXTURE1),Qe.atlasTextureIcon&&Qe.atlasTextureIcon.bind(Qe.atlasInterpolationIcon,W.CLAMP_TO_EDGE)),Qe.isSDF){const yt=Qe.uniformValues;Qe.hasHalo&&(yt.u_is_halo=1,Qo(Qe.buffers,Ye.segments,u,y,Qe.program,Le,F,N,yt,Ye.terrainData)),yt.u_is_halo=0}Qo(Qe.buffers,Ye.segments,u,y,Qe.program,Le,F,N,Qe.uniformValues,Ye.terrainData)}}function Qo(y,n,u,p,_,m,T,A,R,C){const F=p.context;_.draw(F,F.gl.TRIANGLES,m,T,A,Pi.disabled,R,C,u.id,y.layoutVertexBuffer,y.indexBuffer,n,u.paint,p.transform.zoom,y.programConfigurations.get(u.id),y.dynamicLayoutVertexBuffer,y.opacityVertexBuffer)}function Rs(y,n,u,p,_){if(!u||!p||!p.imageAtlas)return;const m=p.imageAtlas.patternPositions;let T=m[u.to.toString()],A=m[u.from.toString()];if(!T&&A&&(T=A),!A&&T&&(A=T),!T||!A){const R=_.getPaintProperty(n);T=m[R],A=m[R]}T&&A&&y.setConstantPatternPositions(T,A)}function Gu(y,n,u,p,_,m,T){const A=y.context.gl,R="fill-pattern",C=u.paint.get(R),F=C&&C.constantOr(1),N=u.getCrossfadeParameters();let V,W,K,se,ie;T?(W=F&&!u.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",V=A.LINES):(W=F?"fillPattern":"fill",V=A.TRIANGLES);const oe=C.constantOr(null);for(const de of p){const ee=n.getTile(de);if(F&&!ee.patternsLoaded())continue;const me=ee.getBucket(u);if(!me)continue;const Ae=me.programConfigurations.get(u.id),Re=y.useProgram(W,Ae),Le=y.style.map.terrain&&y.style.map.terrain.getTerrainData(de);F&&(y.context.activeTexture.set(A.TEXTURE0),ee.imageAtlasTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),Ae.updatePaintBuffers(N)),Rs(Ae,R,oe,ee,u);const Ze=Le?de:null,ct=y.translatePosMatrix(Ze?Ze.posMatrix:de.posMatrix,ee,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));if(T){se=me.indexBuffer2,ie=me.segments2;const dt=[A.drawingBufferWidth,A.drawingBufferHeight];K=W==="fillOutlinePattern"&&F?dr(ct,y,N,ee,dt):Zt(ct,dt)}else se=me.indexBuffer,ie=me.segments,K=F?gt(ct,y,N,ee):qe(ct);Re.draw(y.context,V,_,y.stencilModeForClipping(de),m,Pi.disabled,K,Le,u.id,me.layoutVertexBuffer,se,ie,u.paint,y.transform.zoom,Ae)}}function ih(y,n,u,p,_,m,T){const A=y.context,R=A.gl,C="fill-extrusion-pattern",F=u.paint.get(C),N=F.constantOr(1),V=u.getCrossfadeParameters(),W=u.paint.get("fill-extrusion-opacity"),K=F.constantOr(null);for(const se of p){const ie=n.getTile(se),oe=ie.getBucket(u);if(!oe)continue;const de=y.style.map.terrain&&y.style.map.terrain.getTerrainData(se),ee=oe.programConfigurations.get(u.id),me=y.useProgram(N?"fillExtrusionPattern":"fillExtrusion",ee);N&&(y.context.activeTexture.set(R.TEXTURE0),ie.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ee.updatePaintBuffers(V)),Rs(ee,C,K,ie,u);const Ae=y.translatePosMatrix(se.posMatrix,ie,u.paint.get("fill-extrusion-translate"),u.paint.get("fill-extrusion-translate-anchor")),Re=u.paint.get("fill-extrusion-vertical-gradient"),Le=N?Me(Ae,y,Re,W,se,V,ie):ue(Ae,y,Re,W);me.draw(A,A.gl.TRIANGLES,_,m,T,Pi.backCCW,Le,de,u.id,oe.layoutVertexBuffer,oe.indexBuffer,oe.segments,u.paint,y.transform.zoom,ee,y.style.map.terrain&&oe.centroidVertexBuffer)}}function Qu(y,n,u,p,_,m,T){const A=y.context,R=A.gl,C=u.fbo;if(!C)return;const F=y.useProgram("hillshade"),N=y.style.map.terrain&&y.style.map.terrain.getTerrainData(n);A.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,C.colorAttachment.get()),F.draw(A,R.TRIANGLES,_,m,T,Pi.disabled,((V,W,K,se)=>{const ie=K.paint.get("hillshade-shadow-color"),oe=K.paint.get("hillshade-highlight-color"),de=K.paint.get("hillshade-accent-color");let ee=K.paint.get("hillshade-illumination-direction")*(Math.PI/180);K.paint.get("hillshade-illumination-anchor")==="viewport"&&(ee-=V.transform.angle);const me=!V.options.moving;return{u_matrix:se?se.posMatrix:V.transform.calculatePosMatrix(W.tileID.toUnwrapped(),me),u_image:0,u_latrange:Ps(0,W.tileID),u_light:[K.paint.get("hillshade-exaggeration"),ee],u_shadow:ie,u_highlight:oe,u_accent:de}})(y,u,p,N?n:null),N,p.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}function ea(y,n,u,p,_,m){const T=y.context,A=T.gl,R=n.dem;if(R&&R.data){const C=R.dim,F=R.stride,N=R.getPixels();if(T.activeTexture.set(A.TEXTURE1),T.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||y.getTileTexture(F),n.demTexture){const W=n.demTexture;W.update(N,{premultiply:!1}),W.bind(A.NEAREST,A.CLAMP_TO_EDGE)}else n.demTexture=new ut(T,N,A.RGBA,{premultiply:!1}),n.demTexture.bind(A.NEAREST,A.CLAMP_TO_EDGE);T.activeTexture.set(A.TEXTURE0);let V=n.fbo;if(!V){const W=new ut(T,{width:C,height:C,data:null},A.RGBA);W.bind(A.LINEAR,A.CLAMP_TO_EDGE),V=n.fbo=T.createFramebuffer(C,C,!0,!1),V.colorAttachment.set(W.texture)}T.bindFramebuffer.set(V.framebuffer),T.viewport.set([0,0,C,C]),y.useProgram("hillshadePrepare").draw(T,A.TRIANGLES,p,_,m,Pi.disabled,((W,K)=>{const se=K.stride,ie=c.H();return c.aQ(ie,0,c.X,-c.X,0,0,1),c.J(ie,ie,[0,-c.X,0]),{u_matrix:ie,u_image:1,u_dimension:[se,se],u_zoom:W.overscaledZ,u_unpack:K.getUnpackVector()}})(n.tileID,R),null,u.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments),n.needsHillshadePrepare=!1}}function rh(y,n,u,p,_,m){const T=p.paint.get("raster-fade-duration");if(!m&&T>0){const A=M.now(),R=(A-y.timeAdded)/T,C=n?(A-n.timeAdded)/T:-1,F=u.getSource(),N=_.coveringZoomLevel({tileSize:F.tileSize,roundZoom:F.roundZoom}),V=!n||Math.abs(n.tileID.overscaledZ-N)>Math.abs(y.tileID.overscaledZ-N),W=V&&y.refreshedUponExpiration?1:c.ad(V?R:1-C,0,1);return y.refreshedUponExpiration&&R>=1&&(y.refreshedUponExpiration=!1),n?{opacity:1,mix:1-W}:{opacity:W,mix:0}}return{opacity:1,mix:0}}const sh=new c.aN(1,0,0,1),Vl=new c.aN(0,1,0,1),nh=new c.aN(0,0,1,1),Bp=new c.aN(1,0,1,1),Pa=new c.aN(0,1,1,1);function ta(y,n,u,p){Ra(y,0,n+u/2,y.transform.width,u,p)}function ed(y,n,u,p){Ra(y,n-u/2,0,u,y.transform.height,p)}function Ra(y,n,u,p,_,m){const T=y.context,A=T.gl;A.enable(A.SCISSOR_TEST),A.scissor(n*y.pixelRatio,u*y.pixelRatio,p*y.pixelRatio,_*y.pixelRatio),T.clear({color:m}),A.disable(A.SCISSOR_TEST)}function oi(y,n,u){const p=y.context,_=p.gl,m=u.posMatrix,T=y.useProgram("debug"),A=Yt.disabled,R=Vi.disabled,C=y.colorModeForRenderPass(),F="$debug",N=y.style.map.terrain&&y.style.map.terrain.getTerrainData(u);p.activeTexture.set(_.TEXTURE0);const V=n.getTileByID(u.key).latestRawTileData,W=Math.floor((V&&V.byteLength||0)/1024),K=n.getTile(u).tileSize,se=512/Math.min(K,512)*(u.overscaledZ/y.transform.zoom)*.5;let ie=u.canonical.toString();u.overscaledZ!==u.canonical.z&&(ie+=` => ${u.overscaledZ}`),function(oe,de){oe.initDebugOverlayCanvas();const ee=oe.debugOverlayCanvas,me=oe.context.gl,Ae=oe.debugOverlayCanvas.getContext("2d");Ae.clearRect(0,0,ee.width,ee.height),Ae.shadowColor="white",Ae.shadowBlur=2,Ae.lineWidth=1.5,Ae.strokeStyle="white",Ae.textBaseline="top",Ae.font="bold 36px Open Sans, sans-serif",Ae.fillText(de,5,5),Ae.strokeText(de,5,5),oe.debugOverlayTexture.update(ee),oe.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(y,`${ie} ${W}kB`),T.draw(p,_.TRIANGLES,A,R,wi.alphaBlended,Pi.disabled,yr(m,c.aN.transparent,se),null,F,y.debugBuffer,y.quadTriangleIndexBuffer,y.debugSegments),T.draw(p,_.LINE_STRIP,A,R,C,Pi.disabled,yr(m,c.aN.red),N,F,y.debugBuffer,y.tileBorderIndexBuffer,y.debugSegments)}function jl(y,n,u){const p=y.context,_=p.gl,m=y.colorModeForRenderPass(),T=new Yt(_.LEQUAL,Yt.ReadWrite,y.depthRangeFor3D),A=y.useProgram("terrain"),R=n.getTerrainMesh();p.bindFramebuffer.set(null),p.viewport.set([0,0,y.width,y.height]);for(const C of u){const F=y.renderToTexture.getTexture(C),N=n.getTerrainData(C.tileID);p.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,F.texture);const V=y.transform.calculatePosMatrix(C.tileID.toUnwrapped()),W=n.getMeshFrameDelta(y.transform.zoom),K=y.transform.calculateFogMatrix(C.tileID.toUnwrapped()),se=Ol(V,W,K,y.style.sky,y.transform.pitch);A.draw(p,_.TRIANGLES,T,Vi.disabled,m,Pi.backCCW,se,N,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class zp{constructor(n,u,p){this.vertexBuffer=n,this.indexBuffer=u,this.segments=p}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Lp{constructor(n,u){this.context=new Zu(n),this.transform=u,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Rt.maxUnderzooming+Rt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new zr}resize(n,u,p){if(this.width=Math.floor(n*p),this.height=Math.floor(u*p),this.pixelRatio=p,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const _ of this.style._order)this.style._layers[_].resize()}setup(){const n=this.context,u=new c.aX;u.emplaceBack(0,0),u.emplaceBack(c.X,0),u.emplaceBack(0,c.X),u.emplaceBack(c.X,c.X),this.tileExtentBuffer=n.createVertexBuffer(u,Zo.members),this.tileExtentSegments=c.a0.simpleSegment(0,0,4,2);const p=new c.aX;p.emplaceBack(0,0),p.emplaceBack(c.X,0),p.emplaceBack(0,c.X),p.emplaceBack(c.X,c.X),this.debugBuffer=n.createVertexBuffer(p,Zo.members),this.debugSegments=c.a0.simpleSegment(0,0,4,5);const _=new c.$;_.emplaceBack(0,0,0,0),_.emplaceBack(c.X,0,c.X,0),_.emplaceBack(0,c.X,0,c.X),_.emplaceBack(c.X,c.X,c.X,c.X),this.rasterBoundsBuffer=n.createVertexBuffer(_,He.members),this.rasterBoundsSegments=c.a0.simpleSegment(0,0,4,2);const m=new c.aX;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=n.createVertexBuffer(m,Zo.members),this.viewportSegments=c.a0.simpleSegment(0,0,4,2);const T=new c.aZ;T.emplaceBack(0),T.emplaceBack(1),T.emplaceBack(3),T.emplaceBack(2),T.emplaceBack(0),this.tileBorderIndexBuffer=n.createIndexBuffer(T);const A=new c.aY;A.emplaceBack(0,1,2),A.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=n.createIndexBuffer(A);const R=this.context.gl;this.stencilClearMode=new Vi({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const n=this.context,u=n.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const p=c.H();c.aQ(p,0,this.width,this.height,0,0,1),c.K(p,p,[u.drawingBufferWidth,u.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(n,u.TRIANGLES,Yt.disabled,this.stencilClearMode,wi.disabled,Pi.disabled,Fl(p),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(n,u){if(this.currentStencilSource===n.source||!n.isTileClipped()||!u||!u.length)return;this.currentStencilSource=n.source;const p=this.context,_=p.gl;this.nextStencilID+u.length>256&&this.clearStencil(),p.setColorMode(wi.disabled),p.setDepthMode(Yt.disabled);const m=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const T of u){const A=this._tileClippingMaskIDs[T.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T);m.draw(p,_.TRIANGLES,Yt.disabled,new Vi({func:_.ALWAYS,mask:0},A,255,_.KEEP,_.KEEP,_.REPLACE),wi.disabled,Pi.disabled,Fl(T.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const n=this.nextStencilID++,u=this.context.gl;return new Vi({func:u.NOTEQUAL,mask:255},n,255,u.KEEP,u.KEEP,u.REPLACE)}stencilModeForClipping(n){const u=this.context.gl;return new Vi({func:u.EQUAL,mask:255},this._tileClippingMaskIDs[n.key],0,u.KEEP,u.KEEP,u.REPLACE)}stencilConfigForOverlap(n){const u=this.context.gl,p=n.sort((T,A)=>A.overscaledZ-T.overscaledZ),_=p[p.length-1].overscaledZ,m=p[0].overscaledZ-_+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();const T={};for(let A=0;A({u_sky_color:de.properties.get("sky-color"),u_horizon_color:de.properties.get("horizon-color"),u_horizon:(ee.height/2+ee.getHorizon())*me,u_sky_horizon_blend:de.properties.get("sky-horizon-blend")*ee.height/2*me}))(F,C.style.map.transform,C.pixelRatio),K=new Yt(V.LEQUAL,Yt.ReadWrite,[0,1]),se=Vi.disabled,ie=C.colorModeForRenderPass(),oe=C.useProgram("sky");if(!F.mesh){const de=new c.aX;de.emplaceBack(-1,-1),de.emplaceBack(1,-1),de.emplaceBack(1,1),de.emplaceBack(-1,1);const ee=new c.aY;ee.emplaceBack(0,1,2),ee.emplaceBack(0,2,3),F.mesh=new zp(N.createVertexBuffer(de,Zo.members),N.createIndexBuffer(ee),c.a0.simpleSegment(0,0,de.length,ee.length))}oe.draw(N,V.TRIANGLES,K,se,ie,Pi.disabled,W,void 0,"sky",F.mesh.vertexBuffer,F.mesh.indexBuffer,F.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=u.showOverdrawInspector,this.depthRangeFor3D=[0,1-(n._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=_.length-1;this.currentLayer>=0;this.currentLayer--){const C=this.style._layers[_[this.currentLayer]],F=m[C.source],N=T[C.source];this._renderTileClippingMasks(C,N),this.renderLayer(this,F,C,N)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){const C=this.style._layers[_[this.currentLayer]],F=m[C.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(C))continue;const N=(C.type==="symbol"?R:A)[C.source];this._renderTileClippingMasks(C,T[C.source]),this.renderLayer(this,F,C,N)}if(this.options.showTileBoundaries){const C=function(F,N){let V=null;const W=Object.values(F._layers).flatMap(oe=>oe.source&&!oe.isHidden(N)?[F.sourceCaches[oe.source]]:[]),K=W.filter(oe=>oe.getSource().type==="vector"),se=W.filter(oe=>oe.getSource().type!=="vector"),ie=oe=>{(!V||V.getSource().maxzoomie(oe)),V||se.forEach(oe=>ie(oe)),V}(this.style,this.transform.zoom);C&&function(F,N,V){for(let W=0;W0),_&&(c.b0(u,p),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(m,T){const A=m.context,R=A.gl,C=wi.unblended,F=new Yt(R.LEQUAL,Yt.ReadWrite,[0,1]),N=T.getTerrainMesh(),V=T.sourceCache.getRenderableTiles(),W=m.useProgram("terrainDepth");A.bindFramebuffer.set(T.getFramebuffer("depth").framebuffer),A.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),A.clear({color:c.aN.transparent,depth:1});for(const K of V){const se=T.getTerrainData(K.tileID),ie={u_matrix:m.transform.calculatePosMatrix(K.tileID.toUnwrapped()),u_ele_delta:T.getMeshFrameDelta(m.transform.zoom)};W.draw(A,R.TRIANGLES,F,Vi.disabled,C,Pi.backCCW,ie,se,"terrain",N.vertexBuffer,N.indexBuffer,N.segments)}A.bindFramebuffer.set(null),A.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain),function(m,T){const A=m.context,R=A.gl,C=wi.unblended,F=new Yt(R.LEQUAL,Yt.ReadWrite,[0,1]),N=T.getTerrainMesh(),V=T.getCoordsTexture(),W=T.sourceCache.getRenderableTiles(),K=m.useProgram("terrainCoords");A.bindFramebuffer.set(T.getFramebuffer("coords").framebuffer),A.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),A.clear({color:c.aN.transparent,depth:1}),T.coordsIndex=[];for(const se of W){const ie=T.getTerrainData(se.tileID);A.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,V.texture);const oe={u_matrix:m.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-T.coordsIndex.length)/255,u_texture:0,u_ele_delta:T.getMeshFrameDelta(m.transform.zoom)};K.draw(A,R.TRIANGLES,F,Vi.disabled,C,Pi.backCCW,oe,ie,"terrain",N.vertexBuffer,N.indexBuffer,N.segments),T.coordsIndex.push(se.tileID.key)}A.bindFramebuffer.set(null),A.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain))}renderLayer(n,u,p,_){if(!p.isHidden(this.transform.zoom)&&(p.type==="background"||p.type==="custom"||(_||[]).length))switch(this.id=p.id,p.type){case"symbol":(function(m,T,A,R,C){if(m.renderPass!=="translucent")return;const F=Vi.disabled,N=m.colorModeForRenderPass();(A._unevaluatedLayout.hasValue("text-variable-anchor")||A._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(V,W,K,se,ie,oe,de,ee,me){const Ae=W.transform,Re=qo(),Le=ie==="map",Ze=oe==="map";for(const ct of V){const dt=se.getTile(ct),Ye=dt.getBucket(K);if(!Ye||!Ye.text||!Ye.text.segments.get().length)continue;const Qe=c.ah(Ye.textSizeData,Ae.zoom),yt=Lt(dt,1,W.transform.zoom),Ut=nn(ct.posMatrix,Ze,Le,W.transform,yt),tt=K.layout.get("icon-text-fit")!=="none"&&Ye.hasIconData();if(Qe){const nt=Math.pow(2,Ae.zoom-dt.tileID.overscaledZ),Ot=W.style.map.terrain?(Ht,Kt)=>W.style.map.terrain.getElevation(ct,Ht,Kt):null,Ci=Re.translatePosition(Ae,dt,de,ee);th(Ye,Le,Ze,me,Ae,Ut,ct.posMatrix,nt,Qe,tt,Re,Ci,ct.toUnwrapped(),Ot)}}}(R,m,A,T,A.layout.get("text-rotation-alignment"),A.layout.get("text-pitch-alignment"),A.paint.get("text-translate"),A.paint.get("text-translate-anchor"),C),A.paint.get("icon-opacity").constantOr(1)!==0&&ho(m,T,A,R,!1,A.paint.get("icon-translate"),A.paint.get("icon-translate-anchor"),A.layout.get("icon-rotation-alignment"),A.layout.get("icon-pitch-alignment"),A.layout.get("icon-keep-upright"),F,N),A.paint.get("text-opacity").constantOr(1)!==0&&ho(m,T,A,R,!0,A.paint.get("text-translate"),A.paint.get("text-translate-anchor"),A.layout.get("text-rotation-alignment"),A.layout.get("text-pitch-alignment"),A.layout.get("text-keep-upright"),F,N),T.map.showCollisionBoxes&&(Np(m,T,A,R,!0),Np(m,T,A,R,!1))})(n,u,p,_,this.style.placement.variableOffsets);break;case"circle":(function(m,T,A,R){if(m.renderPass!=="translucent")return;const C=A.paint.get("circle-opacity"),F=A.paint.get("circle-stroke-width"),N=A.paint.get("circle-stroke-opacity"),V=!A.layout.get("circle-sort-key").isConstant();if(C.constantOr(1)===0&&(F.constantOr(1)===0||N.constantOr(1)===0))return;const W=m.context,K=W.gl,se=m.depthModeForSublayer(0,Yt.ReadOnly),ie=Vi.disabled,oe=m.colorModeForRenderPass(),de=[];for(let ee=0;eeee.sortKey-me.sortKey);for(const ee of de){const{programConfiguration:me,program:Ae,layoutVertexBuffer:Re,indexBuffer:Le,uniformValues:Ze,terrainData:ct}=ee.state;Ae.draw(W,K.TRIANGLES,se,ie,oe,Pi.disabled,Ze,ct,A.id,Re,Le,ee.segments,A.paint,m.transform.zoom,me)}})(n,u,p,_);break;case"heatmap":(function(m,T,A,R){if(A.paint.get("heatmap-opacity")!==0)if(m.renderPass==="offscreen"){const C=m.context,F=C.gl,N=Vi.disabled,V=new wi([F.ONE,F.ONE],c.aN.transparent,[!0,!0,!0,!0]);(function(W,K,se){const ie=W.gl;W.activeTexture.set(ie.TEXTURE1),W.viewport.set([0,0,K.width/4,K.height/4]);let oe=se.heatmapFbo;if(oe)ie.bindTexture(ie.TEXTURE_2D,oe.colorAttachment.get()),W.bindFramebuffer.set(oe.framebuffer);else{const de=ie.createTexture();ie.bindTexture(ie.TEXTURE_2D,de),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_S,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_T,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MIN_FILTER,ie.LINEAR),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MAG_FILTER,ie.LINEAR),oe=se.heatmapFbo=W.createFramebuffer(K.width/4,K.height/4,!1,!1),function(ee,me,Ae,Re){var Le,Ze;const ct=ee.gl,dt=(Le=ee.HALF_FLOAT)!==null&&Le!==void 0?Le:ct.UNSIGNED_BYTE,Ye=(Ze=ee.RGBA16F)!==null&&Ze!==void 0?Ze:ct.RGBA;ct.texImage2D(ct.TEXTURE_2D,0,Ye,me.width/4,me.height/4,0,ct.RGBA,dt,null),Re.colorAttachment.set(Ae)}(W,K,de,oe)}})(C,m,A),C.clear({color:c.aN.transparent});for(let W=0;W{const ee=c.H();c.aQ(ee,0,se.width,se.height,0,0,1);const me=se.context.gl;return{u_matrix:ee,u_world:[me.drawingBufferWidth,me.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:ie.paint.get("heatmap-opacity")}})(C,F),null,F.id,C.viewportBuffer,C.quadTriangleIndexBuffer,C.viewportSegments,F.paint,C.transform.zoom)}(m,A))})(n,u,p,_);break;case"line":(function(m,T,A,R){if(m.renderPass!=="translucent")return;const C=A.paint.get("line-opacity"),F=A.paint.get("line-width");if(C.constantOr(1)===0||F.constantOr(1)===0)return;const N=m.depthModeForSublayer(0,Yt.ReadOnly),V=m.colorModeForRenderPass(),W=A.paint.get("line-dasharray"),K=A.paint.get("line-pattern"),se=K.constantOr(1),ie=A.paint.get("line-gradient"),oe=A.getCrossfadeParameters(),de=se?"linePattern":W?"lineSDF":ie?"lineGradient":"line",ee=m.context,me=ee.gl;let Ae=!0;for(const Re of R){const Le=T.getTile(Re);if(se&&!Le.patternsLoaded())continue;const Ze=Le.getBucket(A);if(!Ze)continue;const ct=Ze.programConfigurations.get(A.id),dt=m.context.program.get(),Ye=m.useProgram(de,ct),Qe=Ae||Ye.program!==dt,yt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Re),Ut=K.constantOr(null);if(Ut&&Le.imageAtlas){const Ot=Le.imageAtlas,Ci=Ot.patternPositions[Ut.to.toString()],Ht=Ot.patternPositions[Ut.from.toString()];Ci&&Ht&&ct.setConstantPatternPositions(Ci,Ht)}const tt=yt?Re:null,nt=se?yp(m,Le,A,oe,tt):W?bp(m,Le,A,W,oe,tt):ie?qc(m,Le,A,Ze.lineClipsArray.length,tt):Nl(m,Le,A,tt);if(se)ee.activeTexture.set(me.TEXTURE0),Le.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),ct.updatePaintBuffers(oe);else if(W&&(Qe||m.lineAtlas.dirty))ee.activeTexture.set(me.TEXTURE0),m.lineAtlas.bind(ee);else if(ie){const Ot=Ze.gradients[A.id];let Ci=Ot.texture;if(A.gradientVersion!==Ot.version){let Ht=256;if(A.stepInterpolant){const Kt=T.getSource().maxzoom,Mi=Re.canonical.z===Kt?Math.ceil(1<20&&F.texParameterf(F.TEXTURE_2D,C.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,C.extTextureFilterAnisotropicMax);const Ye=m.style.map.terrain&&m.style.map.terrain.getTerrainData(de),Qe=Ye?de:null,yt=Qe?Qe.posMatrix:m.transform.calculatePosMatrix(de.toUnwrapped(),oe),Ut=yy(yt,ct||[0,0],Ze||1,Le,A);N instanceof ft?V.draw(C,F.TRIANGLES,ee,Vi.disabled,W,Pi.disabled,Ut,Ye,A.id,N.boundsBuffer,m.quadTriangleIndexBuffer,N.boundsSegments):V.draw(C,F.TRIANGLES,ee,K[de.overscaledZ],W,Pi.disabled,Ut,Ye,A.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}})(n,u,p,_);break;case"background":(function(m,T,A,R){const C=A.paint.get("background-color"),F=A.paint.get("background-opacity");if(F===0)return;const N=m.context,V=N.gl,W=m.transform,K=W.tileSize,se=A.paint.get("background-pattern");if(m.isPatternMissing(se))return;const ie=!se&&C.a===1&&F===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==ie)return;const oe=Vi.disabled,de=m.depthModeForSublayer(0,ie==="opaque"?Yt.ReadWrite:Yt.ReadOnly),ee=m.colorModeForRenderPass(),me=m.useProgram(se?"backgroundPattern":"background"),Ae=R||W.coveringTiles({tileSize:K,terrain:m.style.map.terrain});se&&(N.activeTexture.set(V.TEXTURE0),m.imageManager.bind(m.context));const Re=A.getCrossfadeParameters();for(const Le of Ae){const Ze=R?Le.posMatrix:m.transform.calculatePosMatrix(Le.toUnwrapped()),ct=se?Lu(Ze,F,m,se,{tileID:Le,tileSize:K},Re):Zc(Ze,F,C),dt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Le);me.draw(N,V.TRIANGLES,de,oe,ee,Pi.disabled,ct,dt,A.id,m.tileExtentBuffer,m.quadTriangleIndexBuffer,m.tileExtentSegments)}})(n,0,p,_);break;case"custom":(function(m,T,A){const R=m.context,C=A.implementation;if(m.renderPass==="offscreen"){const F=C.prerender;F&&(m.setCustomLayerDefaults(),R.setColorMode(m.colorModeForRenderPass()),F.call(C,R.gl,m.transform.customLayerMatrix()),R.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),R.setColorMode(m.colorModeForRenderPass()),R.setStencilMode(Vi.disabled);const F=C.renderingMode==="3d"?new Yt(m.context.gl.LEQUAL,Yt.ReadWrite,m.depthRangeFor3D):m.depthModeForSublayer(0,Yt.ReadOnly);R.setDepthMode(F),C.render(R.gl,m.transform.customLayerMatrix(),{farZ:m.transform.farZ,nearZ:m.transform.nearZ,fov:m.transform._fov,modelViewProjectionMatrix:m.transform.modelViewProjectionMatrix,projectionMatrix:m.transform.projectionMatrix}),R.setDirty(),m.setBaseState(),R.bindFramebuffer.set(null)}})(n,0,p)}}translatePosMatrix(n,u,p,_,m){if(!p[0]&&!p[1])return n;const T=m?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(T){const C=Math.sin(T),F=Math.cos(T);p=[p[0]*F-p[1]*C,p[0]*C+p[1]*F]}const A=[m?p[0]:Lt(u,p[0],this.transform.zoom),m?p[1]:Lt(u,p[1],this.transform.zoom),0],R=new Float32Array(16);return c.J(R,n,A),R}saveTileTexture(n){const u=this._tileTextures[n.size[0]];u?u.push(n):this._tileTextures[n.size[0]]=[n]}getTileTexture(n){const u=this._tileTextures[n];return u&&u.length>0?u.pop():null}isPatternMissing(n){if(!n)return!1;if(!n.from||!n.to)return!0;const u=this.imageManager.getPattern(n.from.toString()),p=this.imageManager.getPattern(n.to.toString());return!u||!p}useProgram(n,u){this.cache=this.cache||{};const p=n+(u?u.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[p]||(this.cache[p]=new $(this.context,on[n],u,Yc[n],this._showOverdrawInspector,this.style.map.terrain)),this.cache[p]}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 n=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(n.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new ut(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:n,drawingBufferHeight:u}=this.context.gl;return this.width!==n||this.height!==u}}class ia{constructor(n,u){this.points=n,this.planes=u}static fromInvProjectionMatrix(n,u,p){const _=Math.pow(2,p),m=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(A=>{const R=1/(A=c.ag([],A,n))[3]/u*_;return c.b1(A,A,[R,R,1/A[3],R])}),T=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(A=>{const R=function(V,W){var K=W[0],se=W[1],ie=W[2],oe=K*K+se*se+ie*ie;return oe>0&&(oe=1/Math.sqrt(oe)),V[0]=W[0]*oe,V[1]=W[1]*oe,V[2]=W[2]*oe,V}([],function(V,W,K){var se=W[0],ie=W[1],oe=W[2],de=K[0],ee=K[1],me=K[2];return V[0]=ie*me-oe*ee,V[1]=oe*de-se*me,V[2]=se*ee-ie*de,V}([],rt([],m[A[0]],m[A[1]]),rt([],m[A[2]],m[A[1]]))),C=-((F=R)[0]*(N=m[A[1]])[0]+F[1]*N[1]+F[2]*N[2]);var F,N;return R.concat(C)});return new ia(m,T)}}class oh{constructor(n,u){this.min=n,this.max=u,this.center=function(p,_,m){return p[0]=.5*_[0],p[1]=.5*_[1],p[2]=.5*_[2],p}([],function(p,_,m){return p[0]=_[0]+m[0],p[1]=_[1]+m[1],p[2]=_[2]+m[2],p}([],this.min,this.max))}quadrant(n){const u=[n%2==0,n<2],p=je(this.min),_=je(this.max);for(let m=0;m=0&&T++;if(T===0)return 0;T!==u.length&&(p=!1)}if(p)return 2;for(let _=0;_<3;_++){let m=Number.MAX_VALUE,T=-Number.MAX_VALUE;for(let A=0;Athis.max[_]-this.min[_])return 0}return 1}}class ah{constructor(n=0,u=0,p=0,_=0){if(isNaN(n)||n<0||isNaN(u)||u<0||isNaN(p)||p<0||isNaN(_)||_<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=n,this.bottom=u,this.left=p,this.right=_}interpolate(n,u,p){return u.top!=null&&n.top!=null&&(this.top=c.z.number(n.top,u.top,p)),u.bottom!=null&&n.bottom!=null&&(this.bottom=c.z.number(n.bottom,u.bottom,p)),u.left!=null&&n.left!=null&&(this.left=c.z.number(n.left,u.left,p)),u.right!=null&&n.right!=null&&(this.right=c.z.number(n.right,u.right,p)),this}getCenter(n,u){const p=c.ad((this.left+n-this.right)/2,0,n),_=c.ad((this.top+u-this.bottom)/2,0,u);return new c.P(p,_)}equals(n){return this.top===n.top&&this.bottom===n.bottom&&this.left===n.left&&this.right===n.right}clone(){return new ah(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const td=85.051129;class id{constructor(n,u,p,_,m){this.tileSize=512,this._renderWorldCopies=m===void 0||!!m,this._minZoom=n||0,this._maxZoom=u||22,this._minPitch=p??0,this._maxPitch=_??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new c.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ah,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const n=new id(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return n.apply(this),n}apply(n){this.tileSize=n.tileSize,this.latRange=n.latRange,this.width=n.width,this.height=n.height,this._center=n._center,this._elevation=n._elevation,this.minElevationForCurrentTile=n.minElevationForCurrentTile,this.zoom=n.zoom,this.angle=n.angle,this._fov=n._fov,this._pitch=n._pitch,this._unmodified=n._unmodified,this._edgeInsets=n._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(n){this._minZoom!==n&&(this._minZoom=n,this.zoom=Math.max(this.zoom,n))}get maxZoom(){return this._maxZoom}set maxZoom(n){this._maxZoom!==n&&(this._maxZoom=n,this.zoom=Math.min(this.zoom,n))}get minPitch(){return this._minPitch}set minPitch(n){this._minPitch!==n&&(this._minPitch=n,this.pitch=Math.max(this.pitch,n))}get maxPitch(){return this._maxPitch}set maxPitch(n){this._maxPitch!==n&&(this._maxPitch=n,this.pitch=Math.min(this.pitch,n))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(n){n===void 0?n=!0:n===null&&(n=!1),this._renderWorldCopies=n}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new c.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(n){const u=-c.b3(n,-180,180)*Math.PI/180;this.angle!==u&&(this._unmodified=!1,this.angle=u,this._calcMatrices(),this.rotationMatrix=function(){var p=new c.A(4);return c.A!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p}(),function(p,_,m){var T=_[0],A=_[1],R=_[2],C=_[3],F=Math.sin(m),N=Math.cos(m);p[0]=T*N+R*F,p[1]=A*N+C*F,p[2]=T*-F+R*N,p[3]=A*-F+C*N}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(n){const u=c.ad(n,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==u&&(this._unmodified=!1,this._pitch=u,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(n){n=Math.max(.01,Math.min(60,n)),this._fov!==n&&(this._unmodified=!1,this._fov=n/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(n){const u=Math.min(Math.max(n,this.minZoom),this.maxZoom);this._zoom!==u&&(this._unmodified=!1,this._zoom=u,this.tileZoom=Math.max(0,Math.floor(u)),this.scale=this.zoomScale(u),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(n){n.lat===this._center.lat&&n.lng===this._center.lng||(this._unmodified=!1,this._center=n,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(n){n!==this._elevation&&(this._elevation=n,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(n){this._edgeInsets.equals(n)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,n,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(n){return this._edgeInsets.equals(n)}interpolatePadding(n,u,p){this._unmodified=!1,this._edgeInsets.interpolate(n,u,p),this._constrain(),this._calcMatrices()}coveringZoomLevel(n){const u=(n.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/n.tileSize));return Math.max(0,u)}getVisibleUnwrappedCoordinates(n){const u=[new c.b4(0,n)];if(this._renderWorldCopies){const p=this.pointCoordinate(new c.P(0,0)),_=this.pointCoordinate(new c.P(this.width,0)),m=this.pointCoordinate(new c.P(this.width,this.height)),T=this.pointCoordinate(new c.P(0,this.height)),A=Math.floor(Math.min(p.x,_.x,m.x,T.x)),R=Math.floor(Math.max(p.x,_.x,m.x,T.x)),C=1;for(let F=A-C;F<=R+C;F++)F!==0&&u.push(new c.b4(F,n))}return u}coveringTiles(n){var u,p;let _=this.coveringZoomLevel(n);const m=_;if(n.minzoom!==void 0&&_n.maxzoom&&(_=n.maxzoom);const T=this.pointCoordinate(this.getCameraPoint()),A=c.Z.fromLngLat(this.center),R=Math.pow(2,_),C=[R*T.x,R*T.y,0],F=[R*A.x,R*A.y,0],N=ia.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let V=n.minzoom||0;!n.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(V=_);const W=n.terrain?2/Math.min(this.tileSize,n.tileSize)*this.tileSize:3,K=ee=>({aabb:new oh([ee*R,0,0],[(ee+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ee,fullyVisible:!1}),se=[],ie=[],oe=_,de=n.reparseOverscaled?m:_;if(this._renderWorldCopies)for(let ee=1;ee<=3;ee++)se.push(K(-ee)),se.push(K(ee));for(se.push(K(0));se.length>0;){const ee=se.pop(),me=ee.x,Ae=ee.y;let Re=ee.fullyVisible;if(!Re){const Ye=ee.aabb.intersects(N);if(Ye===0)continue;Re=Ye===2}const Le=n.terrain?C:F,Ze=ee.aabb.distanceX(Le),ct=ee.aabb.distanceY(Le),dt=Math.max(Math.abs(Ze),Math.abs(ct));if(ee.zoom===oe||dt>W+(1<=V){const Ye=oe-ee.zoom,Qe=C[0]-.5-(me<>1),Ut=ee.zoom+1;let tt=ee.aabb.quadrant(Ye);if(n.terrain){const nt=new c.S(Ut,ee.wrap,Ut,Qe,yt),Ot=n.terrain.getMinMaxElevation(nt),Ci=(u=Ot.minElevation)!==null&&u!==void 0?u:this.elevation,Ht=(p=Ot.maxElevation)!==null&&p!==void 0?p:this.elevation;tt=new oh([tt.min[0],tt.min[1],Ci],[tt.max[0],tt.max[1],Ht])}se.push({aabb:tt,zoom:Ut,x:Qe,y:yt,wrap:ee.wrap,fullyVisible:Re})}}return ie.sort((ee,me)=>ee.distanceSq-me.distanceSq).map(ee=>ee.tileID)}resize(n,u){this.width=n,this.height=u,this.pixelsToGLUnits=[2/n,-2/u],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(n){return Math.pow(2,n)}scaleZoom(n){return Math.log(n)/Math.LN2}project(n){const u=c.ad(n.lat,-85.051129,td);return new c.P(c.O(n.lng)*this.worldSize,c.Q(u)*this.worldSize)}unproject(n){return new c.Z(n.x/this.worldSize,n.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(n){const u=this.elevation,p=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,_=this.pointLocation(this.centerPoint,n),m=n.getElevationForLngLatZoom(_,this.tileZoom);if(!(this.elevation-m))return;const T=p+u-m,A=Math.cos(this._pitch)*this.cameraToCenterDistance/T/c.b5(1,_.lat),R=this.scaleZoom(A/this.tileSize);this._elevation=m,this._center=_,this.zoom=R}setLocationAtPoint(n,u){const p=this.pointCoordinate(u),_=this.pointCoordinate(this.centerPoint),m=this.locationCoordinate(n),T=new c.Z(m.x-(p.x-_.x),m.y-(p.y-_.y));this.center=this.coordinateLocation(T),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(n,u){return u?this.coordinatePoint(this.locationCoordinate(n),u.getElevationForLngLatZoom(n,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(n))}pointLocation(n,u){return this.coordinateLocation(this.pointCoordinate(n,u))}locationCoordinate(n){return c.Z.fromLngLat(n)}coordinateLocation(n){return n&&n.toLngLat()}pointCoordinate(n,u){if(u){const V=u.pointCoordinate(n);if(V!=null)return V}const p=[n.x,n.y,0,1],_=[n.x,n.y,1,1];c.ag(p,p,this.pixelMatrixInverse),c.ag(_,_,this.pixelMatrixInverse);const m=p[3],T=_[3],A=p[1]/m,R=_[1]/T,C=p[2]/m,F=_[2]/T,N=C===F?0:(0-C)/(F-C);return new c.Z(c.z.number(p[0]/m,_[0]/T,N)/this.worldSize,c.z.number(A,R,N)/this.worldSize)}coordinatePoint(n,u=0,p=this.pixelMatrix){const _=[n.x*this.worldSize,n.y*this.worldSize,u,1];return c.ag(_,_,p),new c.P(_[0]/_[3],_[1]/_[3])}getBounds(){const n=Math.max(0,this.height/2-this.getHorizon());return new ae().extend(this.pointLocation(new c.P(0,n))).extend(this.pointLocation(new c.P(this.width,n))).extend(this.pointLocation(new c.P(this.width,this.height))).extend(this.pointLocation(new c.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ae([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(n){n?(this.lngRange=[n.getWest(),n.getEast()],this.latRange=[n.getSouth(),n.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,td])}calculateTileMatrix(n){const u=n.canonical,p=this.worldSize/this.zoomScale(u.z),_=u.x+Math.pow(2,u.z)*n.wrap,m=c.ao(new Float64Array(16));return c.J(m,m,[_*p,u.y*p,0]),c.K(m,m,[p/c.X,p/c.X,1]),m}calculatePosMatrix(n,u=!1){const p=n.key,_=u?this._alignedPosMatrixCache:this._posMatrixCache;if(_[p])return _[p];const m=this.calculateTileMatrix(n);return c.L(m,u?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,m),_[p]=new Float32Array(m),_[p]}calculateFogMatrix(n){const u=n.key,p=this._fogMatrixCache;if(p[u])return p[u];const _=this.calculateTileMatrix(n);return c.L(_,this.fogMatrix,_),p[u]=new Float32Array(_),p[u]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(n,u){u=c.ad(+u,this.minZoom,this.maxZoom);const p={center:new c.N(n.lng,n.lat),zoom:u};let _=this.lngRange;if(!this._renderWorldCopies&&_===null){const ee=179.9999999999;_=[-ee,ee]}const m=this.tileSize*this.zoomScale(p.zoom);let T=0,A=m,R=0,C=m,F=0,N=0;const{x:V,y:W}=this.size;if(this.latRange){const ee=this.latRange;T=c.Q(ee[1])*m,A=c.Q(ee[0])*m,A-TA&&(oe=A-ee)}if(_){const ee=(R+C)/2;let me=K;this._renderWorldCopies&&(me=c.b3(K,ee-m/2,ee+m/2));const Ae=V/2;me-AeC&&(ie=C-Ae)}if(ie!==void 0||oe!==void 0){const ee=new c.P(ie??K,oe??se);p.center=this.unproject.call({worldSize:m},ee).wrap()}return p}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const n=this._unmodified,{center:u,zoom:p}=this.getConstrained(this.center,this.zoom);this.center=u,this.zoom=p,this._unmodified=n,this._constraining=!1}_calcMatrices(){if(!this.height)return;const n=this.centerOffset,u=this.point.x,p=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=c.b5(1,this.center.lat)*this.worldSize;let _=c.ao(new Float64Array(16));c.K(_,_,[this.width/2,-this.height/2,1]),c.J(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=c.ao(new Float64Array(16)),c.K(_,_,[1,-1,1]),c.J(_,_,[-1,-1,0]),c.K(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_;const m=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),T=Math.min(this.elevation,this.minElevationForCurrentTile),A=m-T*this._pixelPerMeter/Math.cos(this._pitch),R=T<0?A:m,C=Math.PI/2+this._pitch,F=this._fov*(.5+n.y/this.height),N=Math.sin(F)*R/Math.sin(c.ad(Math.PI-C-F,.01,Math.PI-.01)),V=this.getHorizon(),W=2*Math.atan(V/this.cameraToCenterDistance)*(.5+n.y/(2*V)),K=Math.sin(W)*R/Math.sin(c.ad(Math.PI-C-W,.01,Math.PI-.01)),se=Math.min(N,K);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+R),this.nearZ=this.height/50,_=new Float64Array(16),c.b6(_,this._fov,this.width/this.height,this.nearZ,this.farZ),_[8]=2*-n.x/this.width,_[9]=2*n.y/this.height,this.projectionMatrix=c.af(_),c.K(_,_,[1,-1,1]),c.J(_,_,[0,0,-this.cameraToCenterDistance]),c.b7(_,_,this._pitch),c.ae(_,_,this.angle),c.J(_,_,[-u,-p,0]),this.mercatorMatrix=c.K([],_,[this.worldSize,this.worldSize,this.worldSize]),c.K(_,_,[1,1,this._pixelPerMeter]),this.pixelMatrix=c.L(new Float64Array(16),this.labelPlaneMatrix,_),c.J(_,_,[0,0,-this.elevation]),this.modelViewProjectionMatrix=_,this.invModelViewProjectionMatrix=c.at([],_),this.fogMatrix=new Float64Array(16),c.b6(this.fogMatrix,this._fov,this.width/this.height,m,this.farZ),this.fogMatrix[8]=2*-n.x/this.width,this.fogMatrix[9]=2*n.y/this.height,c.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),c.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),c.b7(this.fogMatrix,this.fogMatrix,this._pitch),c.ae(this.fogMatrix,this.fogMatrix,this.angle),c.J(this.fogMatrix,this.fogMatrix,[-u,-p,0]),c.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),c.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=c.L(new Float64Array(16),this.labelPlaneMatrix,_);const ie=this.width%2/2,oe=this.height%2/2,de=Math.cos(this.angle),ee=Math.sin(this.angle),me=u-Math.round(u)+de*ie+ee*oe,Ae=p-Math.round(p)+de*oe+ee*ie,Re=new Float64Array(_);if(c.J(Re,Re,[me>.5?me-1:me,Ae>.5?Ae-1:Ae,0]),this.alignedModelViewProjectionMatrix=Re,_=c.at(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const n=this.pointCoordinate(new c.P(0,0)),u=[n.x*this.worldSize,n.y*this.worldSize,0,1];return c.ag(u,u,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const n=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.P(0,n))}getCameraQueryGeometry(n){const u=this.getCameraPoint();if(n.length===1)return[n[0],u];{let p=u.x,_=u.y,m=u.x,T=u.y;for(const A of n)p=Math.min(p,A.x),_=Math.min(_,A.y),m=Math.max(m,A.x),T=Math.max(T,A.y);return[new c.P(p,_),new c.P(m,_),new c.P(m,T),new c.P(p,T),new c.P(p,_)]}}lngLatToCameraDepth(n,u){const p=this.locationCoordinate(n),_=[p.x*this.worldSize,p.y*this.worldSize,u,1];return c.ag(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function lh(y,n){let u,p=!1,_=null,m=null;const T=()=>{_=null,p&&(y.apply(m,u),_=setTimeout(T,n),p=!1)};return(...A)=>(p=!0,m=this,u=A,_||T(),_)}class $l{constructor(n){this._getCurrentHash=()=>{const u=window.location.hash.replace("#","");if(this._hashName){let p;return u.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(p=_)}),(p&&p[1]||"").split("/")}return u.split("/")},this._onHashChange=()=>{const u=this._getCurrentHash();if(u.length>=3&&!u.some(p=>isNaN(p))){const p=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(u[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+u[2],+u[1]],zoom:+u[0],bearing:p,pitch:+(u[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const u=window.location.href.replace(/(#.+)?$/,this.getHashString());window.history.replaceState(window.history.state,null,u)},this._removeHash=()=>{const u=this._getCurrentHash();if(u.length===0)return;const p=u.join("/");let _=p;_.split("&").length>0&&(_=_.split("&")[0]),this._hashName&&(_=`${this._hashName}=${p}`);let m=window.location.hash.replace(_,"");m.startsWith("#&")?m=m.slice(0,1)+m.slice(2):m==="#"&&(m="");let T=window.location.href.replace(/(#.+)?$/,m);T=T.replace("&&","&"),window.history.replaceState(window.history.state,null,T)},this._updateHash=lh(this._updateHashUnthrottled,300),this._hashName=n&&encodeURIComponent(n)}addTo(n){return this._map=n,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(n){const u=this._map.getCenter(),p=Math.round(100*this._map.getZoom())/100,_=Math.ceil((p*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,_),T=Math.round(u.lng*m)/m,A=Math.round(u.lat*m)/m,R=this._map.getBearing(),C=this._map.getPitch();let F="";if(F+=n?`/${T}/${A}/${p}`:`${p}/${A}/${T}`,(R||C)&&(F+="/"+Math.round(10*R)/10),C&&(F+=`/${Math.round(C)}`),this._hashName){const N=this._hashName;let V=!1;const W=window.location.hash.slice(1).split("&").map(K=>{const se=K.split("=")[0];return se===N?(V=!0,`${se}=${F}`):K}).filter(K=>K);return V||W.push(`${N}=${F}`),`#${W.join("&")}`}return`#${F}`}}const ra={linearity:.3,easing:c.b8(0,0,.3,1)},rd=c.e({deceleration:2500,maxSpeed:1400},ra),sd=c.e({deceleration:20,maxSpeed:1400},ra),Up=c.e({deceleration:1e3,maxSpeed:360},ra),ch=c.e({deceleration:1e3,maxSpeed:90},ra);class hh{constructor(n){this._map=n,this.clear()}clear(){this._inertiaBuffer=[]}record(n){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:M.now(),settings:n})}_drainInertiaBuffer(){const n=this._inertiaBuffer,u=M.now();for(;n.length>0&&u-n[0].time>160;)n.shift()}_onMoveEnd(n){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const u={zoom:0,bearing:0,pitch:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:m}of this._inertiaBuffer)u.zoom+=m.zoomDelta||0,u.bearing+=m.bearingDelta||0,u.pitch+=m.pitchDelta||0,m.panDelta&&u.pan._add(m.panDelta),m.around&&(u.around=m.around),m.pinchAround&&(u.pinchAround=m.pinchAround);const p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(u.pan.mag()){const m=uh(u.pan.mag(),p,c.e({},rd,n||{}));_.offset=u.pan.mult(m.amount/u.pan.mag()),_.center=this._map.transform.center,Ca(_,m)}if(u.zoom){const m=uh(u.zoom,p,sd);_.zoom=this._map.transform.zoom+m.amount,Ca(_,m)}if(u.bearing){const m=uh(u.bearing,p,Up);_.bearing=this._map.transform.bearing+c.ad(m.amount,-179,179),Ca(_,m)}if(u.pitch){const m=uh(u.pitch,p,ch);_.pitch=this._map.transform.pitch+m.amount,Ca(_,m)}if(_.zoom||_.bearing){const m=u.pinchAround===void 0?u.around:u.pinchAround;_.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),c.e(_,{noMoveStart:!0})}}function Ca(y,n){(!y.duration||y.durationu.unproject(R)),A=m.reduce((R,C,F,N)=>R.add(C.div(N.length)),new c.P(0,0));super(n,{points:m,point:A,lngLats:T,lngLat:u.unproject(A),originalEvent:p}),this._defaultPrevented=!1}}class nd extends c.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(n,u,p){super(n,{originalEvent:p}),this._defaultPrevented=!1}}class dh{constructor(n,u){this._map=n,this._clickTolerance=u.clickTolerance}reset(){delete this._mousedownPos}wheel(n){return this._firePreventable(new nd(n.type,this._map,n))}mousedown(n,u){return this._mousedownPos=u,this._firePreventable(new Gr(n.type,this._map,n))}mouseup(n){this._map.fire(new Gr(n.type,this._map,n))}click(n,u){this._mousedownPos&&this._mousedownPos.dist(u)>=this._clickTolerance||this._map.fire(new Gr(n.type,this._map,n))}dblclick(n){return this._firePreventable(new Gr(n.type,this._map,n))}mouseover(n){this._map.fire(new Gr(n.type,this._map,n))}mouseout(n){this._map.fire(new Gr(n.type,this._map,n))}touchstart(n){return this._firePreventable(new Wl(n.type,this._map,n))}touchmove(n){this._map.fire(new Wl(n.type,this._map,n))}touchend(n){this._map.fire(new Wl(n.type,this._map,n))}touchcancel(n){this._map.fire(new Wl(n.type,this._map,n))}_firePreventable(n){if(this._map.fire(n),n.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class od{constructor(n){this._map=n}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(n){this._map.fire(new Gr(n.type,this._map,n))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Gr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(n){this._delayContextMenu?this._contextMenuEvent=n:this._ignoreContextMenu||this._map.fire(new Gr(n.type,this._map,n)),this._map.listens("contextmenu")&&n.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ma{constructor(n){this._map=n}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(n){return this.transform.pointLocation(c.P.convert(n),this._map.terrain)}}class ad{constructor(n,u){this._map=n,this._tr=new Ma(n),this._el=n.getCanvasContainer(),this._container=n.getContainer(),this._clickTolerance=u.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(n,u){this.isEnabled()&&n.shiftKey&&n.button===0&&(D.disableDrag(),this._startPos=this._lastPos=u,this._active=!0)}mousemoveWindow(n,u){if(!this._active)return;const p=u;if(this._lastPos.equals(p)||!this._box&&p.dist(this._startPos)m.fitScreenCoordinates(p,_,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",n)}keydown(n){this._active&&n.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",n))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(D.remove(this._box),this._box=null),D.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(n,u){return this._map.fire(new c.k(n,{originalEvent:u}))}}function ka(y,n){if(y.length!==n.length)throw new Error(`The number of touches and points are not equal - touches ${y.length}, points ${n.length}`);const u={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=n.timeStamp),p.length===this.numTouches&&(this.centroid=function(_){const m=new c.P(0,0);for(const T of _)m._add(T);return m.div(_.length)}(u),this.touches=ka(p,u)))}touchmove(n,u,p){if(this.aborted||!this.centroid)return;const _=ka(p,u);for(const m in this.touches){const T=_[m];(!T||T.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(n,u,p){if((!this.centroid||n.timeStamp-this.startTime>500)&&(this.aborted=!0),p.length===0){const _=!this.aborted&&this.centroid;if(this.reset(),_)return _}}}class cd{constructor(n){this.singleTap=new ld(n),this.numTaps=n.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(n,u,p){this.singleTap.touchstart(n,u,p)}touchmove(n,u,p){this.singleTap.touchmove(n,u,p)}touchend(n,u,p){const _=this.singleTap.touchend(n,u,p);if(_){const m=n.timeStamp-this.lastTime<500,T=!this.lastTap||this.lastTap.dist(_)<30;if(m&&T||this.reset(),this.count++,this.lastTime=n.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Vp{constructor(n){this._tr=new Ma(n),this._zoomIn=new cd({numTouches:1,numTaps:2}),this._zoomOut=new cd({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(n,u,p){this._zoomIn.touchstart(n,u,p),this._zoomOut.touchstart(n,u,p)}touchmove(n,u,p){this._zoomIn.touchmove(n,u,p),this._zoomOut.touchmove(n,u,p)}touchend(n,u,p){const _=this._zoomIn.touchend(n,u,p),m=this._zoomOut.touchend(n,u,p),T=this._tr;return _?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:A=>A.easeTo({duration:300,zoom:T.zoom+1,around:T.unproject(_)},{originalEvent:n})}):m?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:A=>A.easeTo({duration:300,zoom:T.zoom-1,around:T.unproject(m)},{originalEvent:n})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ri{constructor(n){this._enabled=!!n.enable,this._moveStateManager=n.moveStateManager,this._clickTolerance=n.clickTolerance||1,this._moveFunction=n.move,this._activateOnStart=!!n.activateOnStart,n.assignEvents(this),this.reset()}reset(n){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(n)}_move(...n){const u=this._moveFunction(...n);if(u.bearingDelta||u.pitchDelta||u.around||u.panDelta)return this._active=!0,u}dragStart(n,u){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(n)&&(this._moveStateManager.startMove(n),this._lastPoint=u.length?u[0]:u,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(n,u){if(!this.isEnabled())return;const p=this._lastPoint;if(!p)return;if(n.preventDefault(),!this._moveStateManager.isValidMoveEvent(n))return void this.reset(n);const _=u.length?u[0]:u;return!this._moved&&_.dist(p){y.mousedown=y.dragStart,y.mousemoveWindow=y.dragMove,y.mouseup=y.dragEnd,y.contextmenu=n=>{n.preventDefault()}},hd=({enable:y,clickTolerance:n,bearingDegreesPerPixelMoved:u=.8})=>{const p=new cs({checkCorrectEvent:_=>D.mouseButton(_)===0&&_.ctrlKey||D.mouseButton(_)===2});return new Ri({clickTolerance:n,move:(_,m)=>({bearingDelta:(m.x-_.x)*u}),moveStateManager:p,enable:y,assignEvents:Hl})},na=({enable:y,clickTolerance:n,pitchDegreesPerPixelMoved:u=-.5})=>{const p=new cs({checkCorrectEvent:_=>D.mouseButton(_)===0&&_.ctrlKey||D.mouseButton(_)===2});return new Ri({clickTolerance:n,move:(_,m)=>({pitchDelta:(m.y-_.y)*u}),moveStateManager:p,enable:y,assignEvents:Hl})};class Xl{constructor(n,u){this._clickTolerance=n.clickTolerance||1,this._map=u,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(n){return n<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(n,u,p){return this._calculateTransform(n,u,p)}touchmove(n,u,p){if(this._active){if(!this._shouldBePrevented(p.length))return n.preventDefault(),this._calculateTransform(n,u,p);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",n)}}touchend(n,u,p){this._calculateTransform(n,u,p),this._active&&this._shouldBePrevented(p.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(n,u,p){p.length>0&&(this._active=!0);const _=ka(p,u),m=new c.P(0,0),T=new c.P(0,0);let A=0;for(const C in _){const F=_[C],N=this._touches[C];N&&(m._add(F),T._add(F.sub(N)),A++,_[C]=F)}if(this._touches=_,this._shouldBePrevented(A)||!T.mag())return;const R=T.div(A);return this._sum._add(R),this._sum.mag()Math.abs(y.x)}class _d extends ql{constructor(n){super(),this._currentTouchCount=0,this._map=n}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(n,u,p){super.touchstart(n,u,p),this._currentTouchCount=p.length}_start(n){this._lastPoints=n,Wn(n[0].sub(n[1]))&&(this._valid=!1)}_move(n,u,p){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const _=n[0].sub(this._lastPoints[0]),m=n[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(_,m,p.timeStamp),this._valid?(this._lastPoints=n,this._active=!0,{pitchDelta:(_.y+m.y)/2*-.5}):void 0}gestureBeginsVertically(n,u,p){if(this._valid!==void 0)return this._valid;const _=n.mag()>=2,m=u.mag()>=2;if(!_&&!m)return;if(!_||!m)return this._firstMove===void 0&&(this._firstMove=p),p-this._firstMove<100&&void 0;const T=n.y>0==u.y>0;return Wn(n)&&Wn(u)&&T}}const jp={panStep:100,bearingStep:15,pitchStep:10};class gd{constructor(n){this._tr=new Ma(n);const u=jp;this._panStep=u.panStep,this._bearingStep=u.bearingStep,this._pitchStep=u.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(n){if(n.altKey||n.ctrlKey||n.metaKey)return;let u=0,p=0,_=0,m=0,T=0;switch(n.keyCode){case 61:case 107:case 171:case 187:u=1;break;case 189:case 109:case 173:u=-1;break;case 37:n.shiftKey?p=-1:(n.preventDefault(),m=-1);break;case 39:n.shiftKey?p=1:(n.preventDefault(),m=1);break;case 38:n.shiftKey?_=1:(n.preventDefault(),T=-1);break;case 40:n.shiftKey?_=-1:(n.preventDefault(),T=1);break;default:return}return this._rotationDisabled&&(p=0,_=0),{cameraAnimation:A=>{const R=this._tr;A.easeTo({duration:300,easeId:"keyboardHandler",easing:$p,zoom:u?Math.round(R.zoom)+u*(n.shiftKey?2:1):R.zoom,bearing:R.bearing+p*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-m*this._panStep,-T*this._panStep],center:R.center},{originalEvent:n})}}}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 $p(y){return y*(2-y)}const md=4.000244140625;class yd{constructor(n,u){this._onTimeout=p=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(p)},this._map=n,this._tr=new Ma(n),this._triggerRenderFrame=u,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(n){this._defaultZoomRate=n}setWheelZoomRate(n){this._wheelZoomRate=n}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(n){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!n&&n.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(n){return!!this._map.cooperativeGestures.isEnabled()&&!(n.ctrlKey||this._map.cooperativeGestures.isBypassed(n))}wheel(n){if(!this.isEnabled())return;if(this._shouldBePrevented(n))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",n);let u=n.deltaMode===WheelEvent.DOM_DELTA_LINE?40*n.deltaY:n.deltaY;const p=M.now(),_=p-(this._lastWheelEventTime||0);this._lastWheelEventTime=p,u!==0&&u%md==0?this._type="wheel":u!==0&&Math.abs(u)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=u,this._timeout=setTimeout(this._onTimeout,40,n)):this._type||(this._type=Math.abs(_*u)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,u+=this._lastValue)),n.shiftKey&&u&&(u/=4),this._type&&(this._lastWheelEvent=n,this._delta-=u,this._active||this._start(n)),n.preventDefault()}_start(n){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 u=D.mousePos(this._map.getCanvas(),n),p=this._tr;this._around=u.y>p.transform.height/2-p.transform.getHorizon()?c.N.convert(this._aroundCenter?p.center:p.unproject(u)):c.N.convert(p.center),this._aroundPoint=p.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const n=this._tr.transform;if(this._delta!==0){const R=this._type==="wheel"&&Math.abs(this._delta)>md?this._wheelZoomRate:this._defaultZoomRate;let C=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&C!==0&&(C=1/C);const F=typeof this._targetZoom=="number"?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(F*C))),this._type==="wheel"&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const u=typeof this._targetZoom=="number"?this._targetZoom:n.zoom,p=this._startZoom,_=this._easing;let m,T=!1;const A=M.now()-this._lastWheelEventTime;if(this._type==="wheel"&&p&&_&&A){const R=Math.min(A/200,1),C=_(R);m=c.z.number(p,u,C),R<1?this._frameId||(this._frameId=!0):T=!0}else m=u,T=!0;return this._active=!0,T&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!T,zoomDelta:m-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(n){let u=c.b9;if(this._prevEase){const p=this._prevEase,_=(M.now()-p.start)/p.duration,m=p.easing(_+.01)-p.easing(_),T=.27/Math.sqrt(m*m+1e-4)*.01,A=Math.sqrt(.0729-T*T);u=c.b8(T,A,.25,1)}return this._prevEase={start:M.now(),duration:n,easing:u},u}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class bd{constructor(n,u){this._clickZoom=n,this._tapZoom=u}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 Yl{constructor(n){this._tr=new Ma(n),this.reset()}reset(){this._active=!1}dblclick(n,u){return n.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:this._tr.zoom+(n.shiftKey?-1:1),around:this._tr.unproject(u)},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wp{constructor(){this._tap=new cd({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(n,u,p){if(!this._swipePoint)if(this._tapTime){const _=u[0],m=n.timeStamp-this._tapTime<500,T=this._tapPoint.dist(_)<30;m&&T?p.length>0&&(this._swipePoint=_,this._swipeTouch=p[0].identifier):this.reset()}else this._tap.touchstart(n,u,p)}touchmove(n,u,p){if(this._tapTime){if(this._swipePoint){if(p[0].identifier!==this._swipeTouch)return;const _=u[0],m=_.y-this._swipePoint.y;return this._swipePoint=_,n.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(n,u,p)}touchend(n,u,p){if(this._tapTime)this._swipePoint&&p.length===0&&this.reset();else{const _=this._tap.touchend(n,u,p);_&&(this._tapTime=n.timeStamp,this._tapPoint=_)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $s{constructor(n,u,p){this._el=n,this._mousePan=u,this._touchPan=p}enable(n){this._inertiaOptions=n||{},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 an{constructor(n,u,p){this._pitchWithRotate=n.pitchWithRotate,this._mouseRotate=u,this._mousePitch=p}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 vd{constructor(n,u,p,_){this._el=n,this._touchZoom=u,this._touchRotate=p,this._tapDragZoom=_,this._rotationDisabled=!1,this._enabled=!0}enable(n){this._touchZoom.enable(n),this._rotationDisabled||this._touchRotate.enable(n),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 ln{constructor(n,u){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=n,this._options=u,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const n=this._map.getCanvasContainer();n.classList.add("maplibregl-cooperative-gestures"),this._container=D.create("div","maplibregl-cooperative-gesture-screen",n);let u=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(u=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const p=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=u,this._container.appendChild(_);const m=document.createElement("div");m.className="maplibregl-mobile-message",m.textContent=p,this._container.appendChild(m),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(D.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(n){return n[this._bypassKey]}notifyGestureBlocked(n,u){this._enabled&&(this._map.fire(new c.k("cooperativegestureprevented",{gestureType:n,originalEvent:u})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Hn=y=>y.zoom||y.drag||y.pitch||y.rotate;class Cy extends c.k{}function xd(y){return y.panDelta&&y.panDelta.mag()||y.zoomDelta||y.bearingDelta||y.pitchDelta}class My{constructor(n,u){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,m)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const T=_.type==="renderFrame"?void 0:_,A={needsRenderFrame:!1},R={},C={},F=_.touches,N=F?this._getMapTouches(F):void 0,V=N?D.touchPos(this._map.getCanvas(),N):D.mousePos(this._map.getCanvas(),_);for(const{handlerName:se,handler:ie,allowed:oe}of this._handlers){if(!ie.isEnabled())continue;let de;this._blockedByActive(C,oe,se)?ie.reset():ie[m||_.type]&&(de=ie[m||_.type](_,V,N),this.mergeHandlerResult(A,R,de,se,T),de&&de.needsRenderFrame&&this._triggerRenderFrame()),(de||ie.isActive())&&(C[se]=ie)}const W={};for(const se in this._previousActiveHandlers)C[se]||(W[se]=T);this._previousActiveHandlers=C,(Object.keys(W).length||xd(A))&&(this._changes.push([A,R,W]),this._triggerRenderFrame()),(Object.keys(C).length||xd(A))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:K}=A;K&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],K(this._map))},this._map=n,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new hh(n),this._bearingSnap=u.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(u);const p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[window,"blur",void 0]];for(const[_,m,T]of this._listeners)D.addEventListener(_,m,_===document?this.handleWindowEvent:this.handleEvent,T)}destroy(){for(const[n,u,p]of this._listeners)D.removeEventListener(n,u,n===document?this.handleWindowEvent:this.handleEvent,p)}_addDefaultHandlers(n){const u=this._map,p=u.getCanvasContainer();this._add("mapEvent",new dh(u,n));const _=u.boxZoom=new ad(u,n);this._add("boxZoom",_),n.interactive&&n.boxZoom&&_.enable();const m=u.cooperativeGestures=new ln(u,n.cooperativeGestures);this._add("cooperativeGestures",m),n.cooperativeGestures&&m.enable();const T=new Vp(u),A=new Yl(u);u.doubleClickZoom=new bd(A,T),this._add("tapZoom",T),this._add("clickZoom",A),n.interactive&&n.doubleClickZoom&&u.doubleClickZoom.enable();const R=new Wp;this._add("tapDragZoom",R);const C=u.touchPitch=new _d(u);this._add("touchPitch",C),n.interactive&&n.touchPitch&&u.touchPitch.enable(n.touchPitch);const F=hd(n),N=na(n);u.dragRotate=new an(n,F,N),this._add("mouseRotate",F,["mousePitch"]),this._add("mousePitch",N,["mouseRotate"]),n.interactive&&n.dragRotate&&u.dragRotate.enable();const V=(({enable:de,clickTolerance:ee})=>{const me=new cs({checkCorrectEvent:Ae=>D.mouseButton(Ae)===0&&!Ae.ctrlKey});return new Ri({clickTolerance:ee,move:(Ae,Re)=>({around:Re,panDelta:Re.sub(Ae)}),activateOnStart:!0,moveStateManager:me,enable:de,assignEvents:Hl})})(n),W=new Xl(n,u);u.dragPan=new $s(p,V,W),this._add("mousePan",V),this._add("touchPan",W,["touchZoom","touchRotate"]),n.interactive&&n.dragPan&&u.dragPan.enable(n.dragPan);const K=new pd,se=new dd;u.touchZoomRotate=new vd(p,se,K,R),this._add("touchRotate",K,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),n.interactive&&n.touchZoomRotate&&u.touchZoomRotate.enable(n.touchZoomRotate);const ie=u.scrollZoom=new yd(u,()=>this._triggerRenderFrame());this._add("scrollZoom",ie,["mousePan"]),n.interactive&&n.scrollZoom&&u.scrollZoom.enable(n.scrollZoom);const oe=u.keyboard=new gd(u);this._add("keyboard",oe),n.interactive&&n.keyboard&&u.keyboard.enable(),this._add("blockableMapEvent",new od(u))}_add(n,u,p){this._handlers.push({handlerName:n,handler:u,allowed:p}),this._handlersById[n]=u}stop(n){if(!this._updatingCamera){for(const{handler:u}of this._handlers)u.reset();this._inertia.clear(),this._fireEvents({},{},n),this._changes=[]}}isActive(){for(const{handler:n}of this._handlers)if(n.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Hn(this._eventsInProgress)||this.isZooming()}_blockedByActive(n,u,p){for(const _ in n)if(_!==p&&(!u||u.indexOf(_)<0))return!0;return!1}_getMapTouches(n){const u=[];for(const p of n)this._el.contains(p.target)&&u.push(p);return u}mergeHandlerResult(n,u,p,_,m){if(!p)return;c.e(n,p);const T={handlerName:_,originalEvent:p.originalEvent||m};p.zoomDelta!==void 0&&(u.zoom=T),p.panDelta!==void 0&&(u.drag=T),p.pitchDelta!==void 0&&(u.pitch=T),p.bearingDelta!==void 0&&(u.rotate=T)}_applyChanges(){const n={},u={},p={};for(const[_,m,T]of this._changes)_.panDelta&&(n.panDelta=(n.panDelta||new c.P(0,0))._add(_.panDelta)),_.zoomDelta&&(n.zoomDelta=(n.zoomDelta||0)+_.zoomDelta),_.bearingDelta&&(n.bearingDelta=(n.bearingDelta||0)+_.bearingDelta),_.pitchDelta&&(n.pitchDelta=(n.pitchDelta||0)+_.pitchDelta),_.around!==void 0&&(n.around=_.around),_.pinchAround!==void 0&&(n.pinchAround=_.pinchAround),_.noInertia&&(n.noInertia=_.noInertia),c.e(u,m),c.e(p,T);this._updateMapTransform(n,u,p),this._changes=[]}_updateMapTransform(n,u,p){const _=this._map,m=_._getTransformForUpdate(),T=_.terrain;if(!(xd(n)||T&&this._terrainMovement))return this._fireEvents(u,p,!0);let{panDelta:A,zoomDelta:R,bearingDelta:C,pitchDelta:F,around:N,pinchAround:V}=n;V!==void 0&&(N=V),_._stop(!0),N=N||_.transform.centerPoint;const W=m.pointLocation(A?N.sub(A):N);C&&(m.bearing+=C),F&&(m.pitch+=F),R&&(m.zoom+=R),T?this._terrainMovement||!u.drag&&!u.zoom?u.drag&&this._terrainMovement?m.center=m.pointLocation(m.centerPoint.sub(A)):m.setLocationAtPoint(W,N):(this._terrainMovement=!0,this._map._elevationFreeze=!0,m.setLocationAtPoint(W,N)):m.setLocationAtPoint(W,N),_._applyUpdatedTransform(m),this._map._update(),n.noInertia||this._inertia.record(n),this._fireEvents(u,p,!0)}_fireEvents(n,u,p){const _=Hn(this._eventsInProgress),m=Hn(n),T={};for(const N in n){const{originalEvent:V}=n[N];this._eventsInProgress[N]||(T[`${N}start`]=V),this._eventsInProgress[N]=n[N]}!_&&m&&this._fireEvent("movestart",m.originalEvent);for(const N in T)this._fireEvent(N,T[N]);m&&this._fireEvent("move",m.originalEvent);for(const N in n){const{originalEvent:V}=n[N];this._fireEvent(N,V)}const A={};let R;for(const N in this._eventsInProgress){const{handlerName:V,originalEvent:W}=this._eventsInProgress[N];this._handlersById[V].isActive()||(delete this._eventsInProgress[N],R=u[V]||W,A[`${N}end`]=R)}for(const N in A)this._fireEvent(N,A[N]);const C=Hn(this._eventsInProgress),F=(_||m)&&!C;if(F&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const N=this._map._getTransformForUpdate();N.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(N)}if(p&&F){this._updatingCamera=!0;const N=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),V=W=>W!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Cy("renderFrame",{timeStamp:n})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class ky extends c.E{constructor(n,u){super(),this._renderFrameCallback=()=>{const p=Math.min((M.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(p)),p<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=u.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new c.N(this.transform.center.lng,this.transform.center.lat)}setCenter(n,u){return this.jumpTo({center:n},u)}panBy(n,u,p){return n=c.P.convert(n).mult(-1),this.panTo(this.transform.center,c.e({offset:n},u),p)}panTo(n,u,p){return this.easeTo(c.e({center:n},u),p)}getZoom(){return this.transform.zoom}setZoom(n,u){return this.jumpTo({zoom:n},u),this}zoomTo(n,u,p){return this.easeTo(c.e({zoom:n},u),p)}zoomIn(n,u){return this.zoomTo(this.getZoom()+1,n,u),this}zoomOut(n,u){return this.zoomTo(this.getZoom()-1,n,u),this}getBearing(){return this.transform.bearing}setBearing(n,u){return this.jumpTo({bearing:n},u),this}getPadding(){return this.transform.padding}setPadding(n,u){return this.jumpTo({padding:n},u),this}rotateTo(n,u,p){return this.easeTo(c.e({bearing:n},u),p)}resetNorth(n,u){return this.rotateTo(0,c.e({duration:1e3},n),u),this}resetNorthPitch(n,u){return this.easeTo(c.e({bearing:0,pitch:0,duration:1e3},n),u),this}snapToNorth(n,u){return Math.abs(this.getBearing()){if(this._zooming&&(_.zoom=c.z.number(m,ie,Le)),this._rotating&&(_.bearing=c.z.number(T,C,Le)),this._pitching&&(_.pitch=c.z.number(A,F,Le)),this._padding&&(_.interpolatePadding(R,N,Le),W=_.centerPoint.add(V)),this.terrain&&!n.freezeElevation&&this._updateElevation(Le),me)_.setLocationAtPoint(me,Ae);else{const Ze=_.zoomScale(_.zoom-m),ct=ie>m?Math.min(2,ee):Math.max(.5,ee),dt=Math.pow(ct,1-Le),Ye=_.unproject(oe.add(de.mult(Le*dt)).mult(Ze));_.setLocationAtPoint(_.renderWorldCopies?Ye.wrap():Ye,W)}this._applyUpdatedTransform(_),this._fireMoveEvents(u)},Le=>{this.terrain&&n.freezeElevation&&this._finalizeElevation(),this._afterEase(u,Le)},n),this}_prepareEase(n,u,p={}){this._moving=!0,u||p.moving||this.fire(new c.k("movestart",n)),this._zooming&&!p.zooming&&this.fire(new c.k("zoomstart",n)),this._rotating&&!p.rotating&&this.fire(new c.k("rotatestart",n)),this._pitching&&!p.pitching&&this.fire(new c.k("pitchstart",n))}_prepareElevation(n){this._elevationCenter=n,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(n){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const u=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(n<1&&u!==this._elevationTarget){const p=this._elevationTarget-this._elevationStart;this._elevationStart+=n*(p-(u-(p*n+this._elevationStart))/(1-n)),this._elevationTarget=u}this.transform.elevation=c.z.number(this._elevationStart,this._elevationTarget,n)}_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(n){const u=n.getCameraPosition(),p=this.terrain.getElevationForLngLatZoom(u.lngLat,n.zoom);if(u.altitudethis._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&u.push(_=>this.transformCameraUpdate(_)),!u.length)return;const p=n.clone();for(const _ of u){const m=p.clone(),{center:T,zoom:A,pitch:R,bearing:C,elevation:F}=_(m);T&&(m.center=T),A!==void 0&&(m.zoom=A),R!==void 0&&(m.pitch=R),C!==void 0&&(m.bearing=C),F!==void 0&&(m.elevation=F),p.apply(m)}this.transform.apply(p)}_fireMoveEvents(n){this.fire(new c.k("move",n)),this._zooming&&this.fire(new c.k("zoom",n)),this._rotating&&this.fire(new c.k("rotate",n)),this._pitching&&this.fire(new c.k("pitch",n))}_afterEase(n,u){if(this._easeId&&u&&this._easeId===u)return;delete this._easeId;const p=this._zooming,_=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,p&&this.fire(new c.k("zoomend",n)),_&&this.fire(new c.k("rotateend",n)),m&&this.fire(new c.k("pitchend",n)),this.fire(new c.k("moveend",n))}flyTo(n,u){var p;if(!n.essential&&M.prefersReducedMotion){const nt=c.M(n,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,u)}this.stop(),n=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.b9},n);const _=this._getTransformForUpdate(),m=_.zoom,T=_.bearing,A=_.pitch,R=_.padding,C="bearing"in n?this._normalizeBearing(n.bearing,T):T,F="pitch"in n?+n.pitch:A,N="padding"in n?n.padding:_.padding,V=c.P.convert(n.offset);let W=_.centerPoint.add(V);const K=_.pointLocation(W),{center:se,zoom:ie}=_.getConstrained(c.N.convert(n.center||K),(p=n.zoom)!==null&&p!==void 0?p:m);this._normalizeCenter(se,_);const oe=_.zoomScale(ie-m),de=_.project(K),ee=_.project(se).sub(de);let me=n.curve;const Ae=Math.max(_.width,_.height),Re=Ae/oe,Le=ee.mag();if("minZoom"in n){const nt=c.ad(Math.min(n.minZoom,m,ie),_.minZoom,_.maxZoom),Ot=Ae/_.zoomScale(nt-m);me=Math.sqrt(Ot/Le*2)}const Ze=me*me;function ct(nt){const Ot=(Re*Re-Ae*Ae+(nt?-1:1)*Ze*Ze*Le*Le)/(2*(nt?Re:Ae)*Ze*Le);return Math.log(Math.sqrt(Ot*Ot+1)-Ot)}function dt(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Ye(nt){return(Math.exp(nt)+Math.exp(-nt))/2}const Qe=ct(!1);let yt=function(nt){return Ye(Qe)/Ye(Qe+me*nt)},Ut=function(nt){return Ae*((Ye(Qe)*(dt(Ot=Qe+me*nt)/Ye(Ot))-dt(Qe))/Ze)/Le;var Ot},tt=(ct(!0)-Qe)/me;if(Math.abs(Le)<1e-6||!isFinite(tt)){if(Math.abs(Ae-Re)<1e-6)return this.easeTo(n,u);const nt=Re0,yt=Ot=>Math.exp(nt*me*Ot)}return n.duration="duration"in n?+n.duration:1e3*tt/("screenSpeed"in n?+n.screenSpeed/me:+n.speed),n.maxDuration&&n.duration>n.maxDuration&&(n.duration=0),this._zooming=!0,this._rotating=T!==C,this._pitching=F!==A,this._padding=!_.isPaddingEqual(N),this._prepareEase(u,!1),this.terrain&&this._prepareElevation(se),this._ease(nt=>{const Ot=nt*tt,Ci=1/yt(Ot);_.zoom=nt===1?ie:m+_.scaleZoom(Ci),this._rotating&&(_.bearing=c.z.number(T,C,nt)),this._pitching&&(_.pitch=c.z.number(A,F,nt)),this._padding&&(_.interpolatePadding(R,N,nt),W=_.centerPoint.add(V)),this.terrain&&!n.freezeElevation&&this._updateElevation(nt);const Ht=nt===1?se:_.unproject(de.add(ee.mult(Ut(Ot))).mult(Ci));_.setLocationAtPoint(_.renderWorldCopies?Ht.wrap():Ht,W),this._applyUpdatedTransform(_),this._fireMoveEvents(u)},()=>{this.terrain&&n.freezeElevation&&this._finalizeElevation(),this._afterEase(u)},n),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(n,u){var p;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const _=this._onEaseEnd;delete this._onEaseEnd,_.call(this,u)}return n||(p=this.handlers)===null||p===void 0||p.stop(!1),this}_ease(n,u,p){p.animate===!1||p.duration===0?(n(1),u()):(this._easeStart=M.now(),this._easeOptions=p,this._onEaseFrame=n,this._onEaseEnd=u,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(n,u){n=c.b3(n,-180,180);const p=Math.abs(n-u);return Math.abs(n-360-u)180?-360:p<-180?360:0}queryTerrainElevation(n){return this.terrain?this.terrain.getElevationForLngLatZoom(c.N.convert(n),this.transform.tileZoom)-this.transform.elevation:null}}const wd={compact:!0,customAttribution:'MapLibre'};class Da{constructor(n=wd){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=u=>{!u||u.sourceDataType!=="metadata"&&u.sourceDataType!=="visibility"&&u.dataType!=="style"&&u.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=n}getDefaultPosition(){return"bottom-right"}onAdd(n){return this._map=n,this._compact=this.options.compact,this._container=D.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=D.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=D.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(){D.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(n,u){const p=this._map._getUIString(`AttributionControl.${u}`);n.title=p,n.setAttribute("aria-label",p)}_updateAttributions(){if(!this._map.style)return;let n=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?n=n.concat(this.options.customAttribution.map(_=>typeof _!="string"?"":_)):typeof this.options.customAttribution=="string"&&n.push(this.options.customAttribution)),this._map.style.stylesheet){const _=this._map.style.stylesheet;this.styleOwner=_.owner,this.styleId=_.id}const u=this._map.style.sourceCaches;for(const _ in u){const m=u[_];if(m.used||m.usedForTerrain){const T=m.getSource();T.attribution&&n.indexOf(T.attribution)<0&&n.push(T.attribution)}}n=n.filter(_=>String(_).trim()),n.sort((_,m)=>_.length-m.length),n=n.filter((_,m)=>{for(let T=m+1;T=0)return!1;return!0});const p=n.join(" | ");p!==this._attribHTML&&(this._attribHTML=p,n.length?(this._innerContainer.innerHTML=p,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Rn{constructor(n={}){this._updateCompact=()=>{const u=this._container.children;if(u.length){const p=u[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&p.classList.add("maplibregl-compact"):p.classList.remove("maplibregl-compact")}},this.options=n}getDefaultPosition(){return"bottom-left"}onAdd(n){this._map=n,this._compact=this.options&&this.options.compact,this._container=D.create("div","maplibregl-ctrl");const u=D.create("a","maplibregl-ctrl-logo");return u.target="_blank",u.rel="noopener nofollow",u.href="https://maplibre.org/",u.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),u.setAttribute("rel","noopener nofollow"),this._container.appendChild(u),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){D.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class _t{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(n){const u=++this._id;return this._queue.push({callback:n,id:u,cancelled:!1}),u}remove(n){const u=this._currentlyRunning,p=u?this._queue.concat(u):this._queue;for(const _ of p)if(_.id===n)return void(_.cancelled=!0)}run(n=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const u=this._currentlyRunning=this._queue;this._queue=[];for(const p of u)if(!p.cancelled&&(p.callback(n),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Hp=c.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Td extends c.E{constructor(n){super(),this.sourceCache=n,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,n.usedForTerrain=!0,n.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(n,u){this.sourceCache.update(n,u),this._renderableTilesKeys=[];const p={};for(const _ of n.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:u}))p[_.key]=!0,this._renderableTilesKeys.push(_.key),this._tiles[_.key]||(_.posMatrix=new Float64Array(16),c.aQ(_.posMatrix,0,c.X,0,c.X,0,1),this._tiles[_.key]=new mr(_,this.tileSize));for(const _ in this._tiles)p[_]||delete this._tiles[_]}freeRtt(n){for(const u in this._tiles){const p=this._tiles[u];(!n||p.tileID.equals(n)||p.tileID.isChildOf(n)||n.isChildOf(p.tileID))&&(p.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(n=>this.getTileByID(n))}getTileByID(n){return this._tiles[n]}getTerrainCoords(n){const u={};for(const p of this._renderableTilesKeys){const _=this._tiles[p].tileID;if(_.canonical.equals(n.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16),c.aQ(m.posMatrix,0,c.X,0,c.X,0,1),u[p]=m}else if(_.canonical.isChildOf(n.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16);const T=_.canonical.z-n.canonical.z,A=_.canonical.x-(_.canonical.x>>T<>T<>T;c.aQ(m.posMatrix,0,C,0,C,0,1),c.J(m.posMatrix,m.posMatrix,[-A*C,-R*C,0]),u[p]=m}else if(n.canonical.isChildOf(_.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16);const T=n.canonical.z-_.canonical.z,A=n.canonical.x-(n.canonical.x>>T<>T<>T;c.aQ(m.posMatrix,0,c.X,0,c.X,0,1),c.J(m.posMatrix,m.posMatrix,[A*C,R*C,0]),c.K(m.posMatrix,m.posMatrix,[1/2**T,1/2**T,0]),u[p]=m}}return u}getSourceTile(n,u){const p=this.sourceCache._source;let _=n.overscaledZ-this.deltaZoom;if(_>p.maxzoom&&(_=p.maxzoom),_=p.minzoom&&(!m||!m.dem);)m=this.sourceCache.getTileByID(n.scaledTo(_--).key);return m}tilesAfterTime(n=Date.now()){return Object.values(this._tiles).filter(u=>u.timeAdded>=n)}}class Xp{constructor(n,u,p){this.painter=n,this.sourceCache=new Td(u),this.options=p,this.exaggeration=typeof p.exaggeration=="number"?p.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(n,u,p,_=c.X){var m;if(!(u>=0&&u<_&&p>=0&&p<_))return 0;const T=this.getTerrainData(n),A=(m=T.tile)===null||m===void 0?void 0:m.dem;if(!A)return 0;const R=function(K,se,ie){var oe=se[0],de=se[1];return K[0]=ie[0]*oe+ie[4]*de+ie[12],K[1]=ie[1]*oe+ie[5]*de+ie[13],K}([],[u/_*c.X,p/_*c.X],T.u_terrain_matrix),C=[R[0]*A.dim,R[1]*A.dim],F=Math.floor(C[0]),N=Math.floor(C[1]),V=C[0]-F,W=C[1]-N;return A.get(F,N)*(1-V)*(1-W)+A.get(F+1,N)*V*(1-W)+A.get(F,N+1)*(1-V)*W+A.get(F+1,N+1)*V*W}getElevationForLngLatZoom(n,u){const{tileID:p,mercatorX:_,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(n,u);return this.getElevation(p,_%c.X,m%c.X,c.X)}getElevation(n,u,p,_=c.X){return this.getDEMElevation(n,u,p,_)*this.exaggeration}getTerrainData(n){if(!this._emptyDemTexture){const _=this.painter.context,m=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ut(_,m,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ut(_,new c.R({width:1,height:1}),_.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ao([])}const u=this.sourceCache.getSourceTile(n,!0);if(u&&u.dem&&(!u.demTexture||u.needsTerrainPrepare)){const _=this.painter.context;u.demTexture=this.painter.getTileTexture(u.dem.stride),u.demTexture?u.demTexture.update(u.dem.getPixels(),{premultiply:!1}):u.demTexture=new ut(_,u.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),u.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),u.needsTerrainPrepare=!1}const p=u&&u+u.tileID.key+n.key;if(p&&!this._demMatrixCache[p]){const _=this.sourceCache.sourceCache._source.maxzoom;let m=n.canonical.z-u.tileID.canonical.z;n.overscaledZ>n.canonical.z&&(n.canonical.z>=_?m=n.canonical.z-_:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const T=n.canonical.x-(n.canonical.x>>m<>m<>8<<4|m>>8,u[T+3]=0;const p=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(u.buffer)),_=new ut(n,p,n.gl.RGBA,{premultiply:!1});return _.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._coordsTexture=_,_}pointCoordinate(n){this.painter.maybeDrawDepthAndCoords(!0);const u=new Uint8Array(4),p=this.painter.context,_=p.gl,m=Math.round(n.x*this.painter.pixelRatio/devicePixelRatio),T=Math.round(n.y*this.painter.pixelRatio/devicePixelRatio),A=Math.round(this.painter.height/devicePixelRatio);p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),_.readPixels(m,A-T-1,1,1,_.RGBA,_.UNSIGNED_BYTE,u),p.bindFramebuffer.set(null);const R=u[0]+(u[2]>>4<<8),C=u[1]+((15&u[2])<<8),F=this.coordsIndex[255-u[3]],N=F&&this.sourceCache.getTileByID(F);if(!N)return null;const V=this._coordsTextureSize,W=(1<n.id!==u),this._recentlyUsed.push(n.id)}stampObject(n){n.stamp=++this._stamp}getOrCreateFreeObject(){for(const u of this._recentlyUsed)if(!this._objects[u].inUse)return this._objects[u];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const n=this._createObject(this._objects.length);return this._objects.push(n),n}freeObject(n){n.inUse=!1}freeAllObjects(){for(const n of this._objects)this.freeObject(n)}isFull(){return!(this._objects.length!n.inUse)===!1}}const Cn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class qp{constructor(n,u){this.painter=n,this.terrain=u,this.pool=new Kl(n.context,30,u.sourceCache.tileSize*u.qualityFactor)}destruct(){this.pool.destruct()}getTexture(n){return this.pool.getObjectForId(n.rtt[this._stacks.length-1].id).texture}prepareForRender(n,u){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=n._order.filter(p=>!n._layers[p].isHidden(u)),this._coordsDescendingInv={};for(const p in n.sourceCaches){this._coordsDescendingInv[p]={};const _=n.sourceCaches[p].getVisibleCoordinates();for(const m of _){const T=this.terrain.sourceCache.getTerrainCoords(m);for(const A in T)this._coordsDescendingInv[p][A]||(this._coordsDescendingInv[p][A]=[]),this._coordsDescendingInv[p][A].push(T[A])}}this._coordsDescendingInvStr={};for(const p of n._order){const _=n._layers[p],m=_.source;if(Cn[_.type]&&!this._coordsDescendingInvStr[m]){this._coordsDescendingInvStr[m]={};for(const T in this._coordsDescendingInv[m])this._coordsDescendingInvStr[m][T]=this._coordsDescendingInv[m][T].map(A=>A.key).sort().join()}}for(const p of this._renderableTiles)for(const _ in this._coordsDescendingInvStr){const m=this._coordsDescendingInvStr[_][p.tileID.key];m&&m!==p.rttCoords[_]&&(p.rtt=[])}}renderLayer(n){if(n.isHidden(this.painter.transform.zoom))return!1;const u=n.type,p=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===n.id;if(Cn[u]&&(this._prevType&&Cn[this._prevType]||this._stacks.push([]),this._prevType=u,this._stacks[this._stacks.length-1].push(n.id),!_))return!0;if(Cn[this._prevType]||Cn[u]&&_){this._prevType=u;const m=this._stacks.length-1,T=this._stacks[m]||[];for(const A of this._renderableTiles){if(this.pool.isFull()&&(jl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(A),A.rtt[m]){const C=this.pool.getObjectForId(A.rtt[m].id);if(C.stamp===A.rtt[m].stamp){this.pool.useObject(C);continue}}const R=this.pool.getOrCreateFreeObject();this.pool.useObject(R),this.pool.stampObject(R),A.rtt[m]={id:R.id,stamp:R.stamp},p.context.bindFramebuffer.set(R.fbo.framebuffer),p.context.clear({color:c.aN.transparent,stencil:0}),p.currentStencilSource=void 0;for(let C=0;C{y.touchstart=y.dragStart,y.touchmoveWindow=y.dragMove,y.touchend=y.dragEnd},Ed={showCompass:!0,showZoom:!0,visualizePitch:!1};class Yp{constructor(n,u,p=!1){this.mousedown=T=>{this.startMouse(c.e({},T,{ctrlKey:!0,preventDefault:()=>T.preventDefault()}),D.mousePos(this.element,T)),D.addEventListener(window,"mousemove",this.mousemove),D.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=T=>{this.moveMouse(T,D.mousePos(this.element,T))},this.mouseup=T=>{this.mouseRotate.dragEnd(T),this.mousePitch&&this.mousePitch.dragEnd(T),this.offTemp()},this.touchstart=T=>{T.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=D.touchPos(this.element,T.targetTouches)[0],this.startTouch(T,this._startPos),D.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.addEventListener(window,"touchend",this.touchend))},this.touchmove=T=>{T.targetTouches.length!==1?this.reset():(this._lastPos=D.touchPos(this.element,T.targetTouches)[0],this.moveTouch(T,this._lastPos))},this.touchend=T=>{T.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const _=n.dragRotate._mouseRotate.getClickTolerance(),m=n.dragRotate._mousePitch.getClickTolerance();this.element=u,this.mouseRotate=hd({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:T,clickTolerance:A,bearingDegreesPerPixelMoved:R=.8})=>{const C=new fh;return new Ri({clickTolerance:A,move:(F,N)=>({bearingDelta:(N.x-F.x)*R}),moveStateManager:C,enable:T,assignEvents:Zp})})({clickTolerance:_,enable:!0}),this.map=n,p&&(this.mousePitch=na({clickTolerance:m,enable:!0}),this.touchPitch=(({enable:T,clickTolerance:A,pitchDegreesPerPixelMoved:R=-.5})=>{const C=new fh;return new Ri({clickTolerance:A,move:(F,N)=>({pitchDelta:(N.y-F.y)*R}),moveStateManager:C,enable:T,assignEvents:Zp})})({clickTolerance:m,enable:!0})),D.addEventListener(u,"mousedown",this.mousedown),D.addEventListener(u,"touchstart",this.touchstart,{passive:!1}),D.addEventListener(u,"touchcancel",this.reset)}startMouse(n,u){this.mouseRotate.dragStart(n,u),this.mousePitch&&this.mousePitch.dragStart(n,u),D.disableDrag()}startTouch(n,u){this.touchRotate.dragStart(n,u),this.touchPitch&&this.touchPitch.dragStart(n,u),D.disableDrag()}moveMouse(n,u){const p=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(n,u)||{};if(_&&p.setBearing(p.getBearing()+_),this.mousePitch){const{pitchDelta:m}=this.mousePitch.dragMove(n,u)||{};m&&p.setPitch(p.getPitch()+m)}}moveTouch(n,u){const p=this.map,{bearingDelta:_}=this.touchRotate.dragMove(n,u)||{};if(_&&p.setBearing(p.getBearing()+_),this.touchPitch){const{pitchDelta:m}=this.touchPitch.dragMove(n,u)||{};m&&p.setPitch(p.getPitch()+m)}}off(){const n=this.element;D.removeEventListener(n,"mousedown",this.mousedown),D.removeEventListener(n,"touchstart",this.touchstart,{passive:!1}),D.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.removeEventListener(window,"touchend",this.touchend),D.removeEventListener(n,"touchcancel",this.reset),this.offTemp()}offTemp(){D.enableDrag(),D.removeEventListener(window,"mousemove",this.mousemove),D.removeEventListener(window,"mouseup",this.mouseup),D.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.removeEventListener(window,"touchend",this.touchend)}}let uo;function Kp(y,n,u){const p=new c.N(y.lng,y.lat);if(y=new c.N(y.lng,y.lat),n){const _=new c.N(y.lng-360,y.lat),m=new c.N(y.lng+360,y.lat),T=u.locationPoint(y).distSqr(n);u.locationPoint(_).distSqr(n)180;){const _=u.locationPoint(y);if(_.x>=0&&_.y>=0&&_.x<=u.width&&_.y<=u.height)break;y.lng>u.center.lng?y.lng-=360:y.lng+=360}return y.lng!==p.lng&&u.locationPoint(y).y>u.height/2-u.getHorizon()?y:p}const Ad={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 fo(y,n,u){const p=y.classList;for(const _ in Ad)p.remove(`maplibregl-${u}-anchor-${_}`);p.add(`maplibregl-${u}-anchor-${n}`)}class Ti extends c.E{constructor(n){if(super(),this._onKeyPress=u=>{const p=u.code,_=u.charCode||u.keyCode;p!=="Space"&&p!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=u=>{const p=u.originalEvent.target,_=this._element;this._popup&&(p===_||_.contains(p))&&this.togglePopup()},this._update=u=>{var p;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((u==null?void 0:u.type)==="terrain"||(u==null?void 0:u.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Kp(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let m="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?m=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(m=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let T="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?T="rotateX(0deg)":this._pitchAlignment==="map"&&(T=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||u&&u.type!=="moveend"||(this._pos=this._pos.round()),D.setTransform(this._element,`${Ad[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${T} ${m}`),M.frameAsync(new AbortController).then(()=>{this._updateOpacity(u&&u.type==="moveend")}).catch(()=>{})},this._onMove=u=>{if(!this._isDragging){const p=this._clickTolerance||this._map._clickTolerance;this._isDragging=u.point.dist(this._pointerdownPos)>=p}this._isDragging&&(this._pos=u.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 c.k("dragstart"))),this.fire(new c.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 c.k("dragend")),this._state="inactive"},this._addDragHandler=u=>{this._element.contains(u.originalEvent.target)&&(u.preventDefault(),this._positionDelta=u.point.sub(this._pos).add(this._offset),this._pointerdownPos=u.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=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._scale=n&&n.scale||1,this._draggable=n&&n.draggable||!1,this._clickTolerance=n&&n.clickTolerance||0,this._subpixelPositioning=n&&n.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=n&&n.rotation||0,this._rotationAlignment=n&&n.rotationAlignment||"auto",this._pitchAlignment=n&&n.pitchAlignment&&n.pitchAlignment!=="auto"?n.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(n==null?void 0:n.opacity,n==null?void 0:n.opacityWhenCovered),n&&n.element)this._element=n.element,this._offset=c.P.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=D.create("div");const u=D.createNS("http://www.w3.org/2000/svg","svg"),p=41,_=27;u.setAttributeNS(null,"display","block"),u.setAttributeNS(null,"height",`${p}px`),u.setAttributeNS(null,"width",`${_}px`),u.setAttributeNS(null,"viewBox",`0 0 ${_} ${p}`);const m=D.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const T=D.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"fill-rule","nonzero");const A=D.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(3.0, 29.0)"),A.setAttributeNS(null,"fill","#000000");const R=[{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 oe of R){const de=D.createNS("http://www.w3.org/2000/svg","ellipse");de.setAttributeNS(null,"opacity","0.04"),de.setAttributeNS(null,"cx","10.5"),de.setAttributeNS(null,"cy","5.80029008"),de.setAttributeNS(null,"rx",oe.rx),de.setAttributeNS(null,"ry",oe.ry),A.appendChild(de)}const C=D.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill",this._color);const F=D.createNS("http://www.w3.org/2000/svg","path");F.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"),C.appendChild(F);const N=D.createNS("http://www.w3.org/2000/svg","g");N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"fill","#000000");const V=D.createNS("http://www.w3.org/2000/svg","path");V.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"),N.appendChild(V);const W=D.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(6.0, 7.0)"),W.setAttributeNS(null,"fill","#FFFFFF");const K=D.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=D.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const ie=D.createNS("http://www.w3.org/2000/svg","circle");ie.setAttributeNS(null,"fill","#FFFFFF"),ie.setAttributeNS(null,"cx","5.5"),ie.setAttributeNS(null,"cy","5.5"),ie.setAttributeNS(null,"r","5.4999962"),K.appendChild(se),K.appendChild(ie),T.appendChild(A),T.appendChild(C),T.appendChild(N),T.appendChild(W),T.appendChild(K),u.appendChild(T),u.setAttributeNS(null,"height",p*this._scale+"px"),u.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(u),this._offset=c.P.convert(n&&n.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",u=>{u.preventDefault()}),this._element.addEventListener("mousedown",u=>{u.preventDefault()}),fo(this._element,this._anchor,"marker"),n&&n.className)for(const u of n.className.split(" "))this._element.classList.add(u);this._popup=null}addTo(n){return this.remove(),this._map=n,this._element.setAttribute("aria-label",n._getUIString("Marker.Title")),n.getCanvasContainer().appendChild(this._element),n.on("move",this._update),n.on("moveend",this._update),n.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),D.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(n){return this._lngLat=c.N.convert(n),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(n){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),n){if(!("offset"in n.options)){const _=Math.abs(13.5)/Math.SQRT2;n.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[_,-1*(38.1-13.5+_)],"bottom-right":[-_,-1*(38.1-13.5+_)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=n,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(n){return this._subpixelPositioning=n,this}getPopup(){return this._popup}togglePopup(){const n=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:n?(n.isOpen()?n.remove():(n.setLngLat(this._lngLat),n.addTo(this._map)),this):this}_updateOpacity(n=!1){var u,p;if(!(!((u=this._map)===null||u===void 0)&&u.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(n)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const _=this._map,m=_.terrain.depthAtPoint(this._pos),T=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,T)-m<.006)return void(this._element.style.opacity=this._opacity);const A=-this._offset.y/_.transform._pixelPerMeter,R=Math.sin(_.getPitch()*Math.PI/180)*A,C=_.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),F=_.transform.lngLatToCameraDepth(this._lngLat,T+R)-C>.006;!((p=this._popup)===null||p===void 0)&&p.isOpen()&&F&&this._popup.remove(),this._element.style.opacity=F?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(n){return this._offset=c.P.convert(n),this._update(),this}addClassName(n){this._element.classList.add(n)}removeClassName(n){this._element.classList.remove(n)}toggleClassName(n){return this._element.classList.toggle(n)}setDraggable(n){return this._draggable=!!n,this._map&&(n?(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(n){return this._rotation=n||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(n){return this._rotationAlignment=n||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(n){return this._pitchAlignment=n&&n!=="auto"?n:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(n,u){return n===void 0&&u===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),n!==void 0&&(this._opacity=n),u!==void 0&&(this._opacityWhenCovered=u),this._map&&this._updateOpacity(!0),this}}const ph={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Oa=0,Fa=!1;const Jp={maxWidth:100,unit:"metric"};function Id(y,n,u){const p=u&&u.maxWidth||100,_=y._container.clientHeight/2,m=y.unproject([0,_]),T=y.unproject([p,_]),A=m.distanceTo(T);if(u&&u.unit==="imperial"){const R=3.2808*A;R>5280?Jl(n,p,R/5280,y._getUIString("ScaleControl.Miles")):Jl(n,p,R,y._getUIString("ScaleControl.Feet"))}else u&&u.unit==="nautical"?Jl(n,p,A/1852,y._getUIString("ScaleControl.NauticalMiles")):A>=1e3?Jl(n,p,A/1e3,y._getUIString("ScaleControl.Kilometers")):Jl(n,p,A,y._getUIString("ScaleControl.Meters"))}function Jl(y,n,u,p){const _=function(m){const T=Math.pow(10,`${Math.floor(m)}`.length-1);let A=m/T;return A=A>=10?10:A>=5?5:A>=3?3:A>=2?2:A>=1?1:function(R){const C=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*C)/C}(A),T*A}(u);y.style.width=n*(_/u)+"px",y.innerHTML=`${_} ${p}`}const Mn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},_h=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function St(y){if(y){if(typeof y=="number"){const n=Math.round(Math.abs(y)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,y),"top-left":new c.P(n,n),"top-right":new c.P(-n,n),bottom:new c.P(0,-y),"bottom-left":new c.P(n,-n),"bottom-right":new c.P(-n,-n),left:new c.P(y,0),right:new c.P(-y,0)}}if(y instanceof c.P||Array.isArray(y)){const n=c.P.convert(y);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:c.P.convert(y.center||[0,0]),top:c.P.convert(y.top||[0,0]),"top-left":c.P.convert(y["top-left"]||[0,0]),"top-right":c.P.convert(y["top-right"]||[0,0]),bottom:c.P.convert(y.bottom||[0,0]),"bottom-left":c.P.convert(y["bottom-left"]||[0,0]),"bottom-right":c.P.convert(y["bottom-right"]||[0,0]),left:c.P.convert(y.left||[0,0]),right:c.P.convert(y.right||[0,0])}}return St(new c.P(0,0))}const Mt=x;d.AJAXError=c.bg,d.Evented=c.E,d.LngLat=c.N,d.MercatorCoordinate=c.Z,d.Point=c.P,d.addProtocol=c.bh,d.config=c.a,d.removeProtocol=c.bi,d.AttributionControl=Da,d.BoxZoomHandler=ad,d.CanvasSource=bt,d.CooperativeGesturesHandler=ln,d.DoubleClickZoomHandler=bd,d.DragPanHandler=$s,d.DragRotateHandler=an,d.EdgeInsets=ah,d.FullscreenControl=class extends c.E{constructor(y={}){super(),this._onFullscreenChange=()=>{var n;let u=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((n=u==null?void 0:u.shadowRoot)===null||n===void 0)&&n.fullscreenElement;)u=u.shadowRoot.fullscreenElement;u===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,y&&y.container&&(y.container instanceof HTMLElement?this._container=y.container:c.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(y){return this._map=y,this._container||(this._container=this._map.getContainer()),this._controlContainer=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){D.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const y=this._fullscreenButton=D.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);D.create("span","maplibregl-ctrl-icon",y).setAttribute("aria-hidden","true"),y.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const y=this._getTitle();this._fullscreenButton.setAttribute("aria-label",y),this._fullscreenButton.title=y}_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 c.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.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()}},d.GeoJSONSource=Je,d.GeolocateControl=class extends c.E{constructor(y){super(),this._onSuccess=n=>{if(this._map){if(this._isOutOfMapMaxBounds(n))return this._setErrorState(),this.fire(new c.k("outofmaxbounds",n)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=n,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(n),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(n),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new c.k("geolocate",n)),this._finish()}},this._updateCamera=n=>{const u=new c.N(n.coords.longitude,n.coords.latitude),p=n.coords.accuracy,_=this._map.getBearing(),m=c.e({bearing:_},this.options.fitBoundsOptions),T=ae.fromLngLat(u,p);this._map.fitBounds(T,m,{geolocateSource:!0})},this._updateMarker=n=>{if(n){const u=new c.N(n.coords.longitude,n.coords.latitude);this._accuracyCircleMarker.setLngLat(u).addTo(this._map),this._userLocationDotMarker.setLngLat(u).addTo(this._map),this._accuracy=n.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=n=>{if(this._map){if(this.options.trackUserLocation)if(n.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 u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(n.code===3&&Fa)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.k("error",n)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=D.create("button","maplibregl-ctrl-geolocate",this._container),D.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=n=>{if(this._map){if(n===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u)}else{const u=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=D.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ti({element:this._dotElement}),this._circleElement=D.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ti({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",u=>{u.geolocateSource||this._watchState!=="ACTIVE_LOCK"||u.originalEvent&&u.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 c.k("trackuserlocationend")),this.fire(new c.k("userlocationlostfocus")))})}},this.options=c.e({},ph,y)}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,function*(n=!1){if(uo!==void 0&&!n)return uo;if(window.navigator.permissions===void 0)return uo=!!window.navigator.geolocation,uo;try{uo=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{uo=!!window.navigator.geolocation}return uo})}().then(n=>this._finishSetupUI(n)),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(),D.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Oa=0,Fa=!1}_isOutOfMapMaxBounds(y){const n=this._map.getMaxBounds(),u=y.coords;return n&&(u.longituden.getEast()||u.latituden.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 y=this._map.getBounds(),n=y.getSouthEast(),u=y.getNorthEast(),p=n.distanceTo(u),_=Math.ceil(this._accuracy/(p/this._map._container.clientHeight)*2);this._circleElement.style.width=`${_}px`,this._circleElement.style.height=`${_}px`}trigger(){if(!this._setup)return c.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 c.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Oa--,Fa=!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 c.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 c.k("trackuserlocationstart")),this.fire(new c.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 y;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Oa++,Oa>1?(y={maximumAge:6e5,timeout:0},Fa=!0):(y=this.options.positionOptions,Fa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,y)}}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)}},d.Hash=$l,d.ImageSource=ft,d.KeyboardHandler=gd,d.LngLatBounds=ae,d.LogoControl=Rn,d.Map=class extends ky{constructor(y){c.be.mark(c.bf.create);const n=Object.assign(Object.assign({},Dy),y);if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(n.minPitch!=null&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(n.maxPitch!=null&&n.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new id(n.minZoom,n.maxZoom,n.minPitch,n.maxPitch,n.renderWorldCopies),{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new _t,this._controls=[],this._mapId=c.a4(),this._contextLost=u=>{u.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new c.k("webglcontextlost",{originalEvent:u}))},this._contextRestored=u=>{this._setupPainter(),this.resize(),this._update(),this.fire(new c.k("webglcontextrestored",{originalEvent:u}))},this._onMapScroll=u=>{if(u.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=n.preserveDrawingBuffer===!0,this._antialias=n.antialias===!0,this._trackResize=n.trackResize===!0,this._bearingSnap=n.bearingSnap,this._refreshExpiredTiles=n.refreshExpiredTiles===!0,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=n.crossSourceCollisions===!0,this._collectResourceTiming=n.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},at),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=n.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Se.addThrottleControl(()=>this.isMoving()),this._requestManager=new Be(n.transformRequest),typeof n.container=="string"){if(this._container=document.getElementById(n.container),!this._container)throw new Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.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 u=!1;const p=lh(_=>{this._trackResize&&!this._removed&&this.resize(_)._update()},50);this._resizeObserver=new ResizeObserver(_=>{u?p(_):u=!0}),this._resizeObserver.observe(this._container)}this.handlers=new My(this,n),this._hash=n.hash&&new $l(typeof n.hash=="string"&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,c.e({},n.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new Da(typeof n.attributionControl=="boolean"?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Rn,n.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",u=>{this._update(u.dataType==="style"),this.fire(new c.k(`${u.dataType}data`,u))}),this.on("dataloading",u=>{this.fire(new c.k(`${u.dataType}dataloading`,u))}),this.on("dataabort",u=>{this.fire(new c.k("sourcedataabort",u))})}_getMapId(){return this._mapId}addControl(y,n){if(n===void 0&&(n=y.getDefaultPosition?y.getDefaultPosition():"top-right"),!y||!y.onAdd)return this.fire(new c.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const u=y.onAdd(this);this._controls.push(y);const p=this._controlPositions[n];return n.indexOf("bottom")!==-1?p.insertBefore(u,p.firstChild):p.appendChild(u),this}removeControl(y){if(!y||!y.onRemove)return this.fire(new c.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(y);return n>-1&&this._controls.splice(n,1),y.onRemove(this),this}hasControl(y){return this._controls.indexOf(y)>-1}calculateCameraOptionsFromTo(y,n,u,p){return p==null&&this.terrain&&(p=this.terrain.getElevationForLngLatZoom(u,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(y,n,u,p)}resize(y){var n;const u=this._containerDimensions(),p=u[0],_=u[1],m=this._getClampedPixelRatio(p,_);if(this._resizeCanvas(p,_,m),this.painter.resize(p,_,m),this.painter.overLimit()){const A=this.painter.context.gl;this._maxCanvasSize=[A.drawingBufferWidth,A.drawingBufferHeight];const R=this._getClampedPixelRatio(p,_);this._resizeCanvas(p,_,R),this.painter.resize(p,_,R)}this.transform.resize(p,_),(n=this._requestedCameraState)===null||n===void 0||n.resize(p,_);const T=!this._moving;return T&&(this.stop(),this.fire(new c.k("movestart",y)).fire(new c.k("move",y))),this.fire(new c.k("resize",y)),T&&this.fire(new c.k("moveend",y)),this}_getClampedPixelRatio(y,n){const{0:u,1:p}=this._maxCanvasSize,_=this.getPixelRatio(),m=y*_,T=n*_;return Math.min(m>u?u/m:1,T>p?p/T:1)*_}getPixelRatio(){var y;return(y=this._overridePixelRatio)!==null&&y!==void 0?y:devicePixelRatio}setPixelRatio(y){this._overridePixelRatio=y,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(y){return this.transform.setMaxBounds(ae.convert(y)),this._update()}setMinZoom(y){if((y=y??-2)>=-2&&y<=this.transform.maxZoom)return this.transform.minZoom=y,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=y,this._update(),this.getZoom()>y&&this.setZoom(y),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(y){if((y=y??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(y>=0&&y<=this.transform.maxPitch)return this.transform.minPitch=y,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(y>=this.transform.minPitch)return this.transform.maxPitch=y,this._update(),this.getPitch()>y&&this.setPitch(y),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(y){return this.transform.renderWorldCopies=y,this._update()}project(y){return this.transform.locationPoint(c.N.convert(y),this.style&&this.terrain)}unproject(y){return this.transform.pointLocation(c.P.convert(y),this.terrain)}isMoving(){var y;return this._moving||((y=this.handlers)===null||y===void 0?void 0:y.isMoving())}isZooming(){var y;return this._zooming||((y=this.handlers)===null||y===void 0?void 0:y.isZooming())}isRotating(){var y;return this._rotating||((y=this.handlers)===null||y===void 0?void 0:y.isRotating())}_createDelegatedListener(y,n,u){if(y==="mouseenter"||y==="mouseover"){let p=!1;return{layer:n,listener:u,delegates:{mousemove:m=>{const T=this.getLayer(n)?this.queryRenderedFeatures(m.point,{layers:[n]}):[];T.length?p||(p=!0,u.call(this,new Gr(y,this,m.originalEvent,{features:T}))):p=!1},mouseout:()=>{p=!1}}}}if(y==="mouseleave"||y==="mouseout"){let p=!1;return{layer:n,listener:u,delegates:{mousemove:T=>{(this.getLayer(n)?this.queryRenderedFeatures(T.point,{layers:[n]}):[]).length?p=!0:p&&(p=!1,u.call(this,new Gr(y,this,T.originalEvent)))},mouseout:T=>{p&&(p=!1,u.call(this,new Gr(y,this,T.originalEvent)))}}}}{const p=_=>{const m=this.getLayer(n)?this.queryRenderedFeatures(_.point,{layers:[n]}):[];m.length&&(_.features=m,u.call(this,_),delete _.features)};return{layer:n,listener:u,delegates:{[y]:p}}}}on(y,n,u){if(u===void 0)return super.on(y,n);const p=this._createDelegatedListener(y,n,u);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[y]=this._delegatedListeners[y]||[],this._delegatedListeners[y].push(p);for(const _ in p.delegates)this.on(_,p.delegates[_]);return this}once(y,n,u){if(u===void 0)return super.once(y,n);const p=this._createDelegatedListener(y,n,u);for(const _ in p.delegates)this.once(_,p.delegates[_]);return this}off(y,n,u){return u===void 0?super.off(y,n):(this._delegatedListeners&&this._delegatedListeners[y]&&(p=>{const _=this._delegatedListeners[y];for(let m=0;m<_.length;m++){const T=_[m];if(T.layer===n&&T.listener===u){for(const A in T.delegates)this.off(A,T.delegates[A]);return _.splice(m,1),this}}})(),this)}queryRenderedFeatures(y,n){if(!this.style)return[];let u;const p=y instanceof c.P||Array.isArray(y),_=p?y:[[0,0],[this.transform.width,this.transform.height]];if(n=n||(p?{}:y)||{},_ instanceof c.P||typeof _[0]=="number")u=[c.P.convert(_)];else{const m=c.P.convert(_[0]),T=c.P.convert(_[1]);u=[m,new c.P(T.x,m.y),T,new c.P(m.x,T.y),m]}return this.style.queryRenderedFeatures(u,n,this.transform)}querySourceFeatures(y,n){return this.style.querySourceFeatures(y,n)}setStyle(y,n){return(n=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff!==!1&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&y?(this._diffStyle(y,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(y,n))}setTransformRequest(y){return this._requestManager.setTransformRequest(y),this}_getUIString(y){const n=this._locale[y];if(n==null)throw new Error(`Missing UI string '${y}'`);return n}_updateStyle(y,n){if(n.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(y,n));const u=this.style&&n.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!y)),y?(this.style=new js(this,n||{}),this.style.setEventedParent(this,{style:this.style}),typeof y=="string"?this.style.loadURL(y,n,u):this.style.loadJSON(y,n,u),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new js(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(y,n){if(typeof y=="string"){const u=this._requestManager.transformRequest(y,"Style");c.h(u,new AbortController).then(p=>{this._updateDiff(p.data,n)}).catch(p=>{p&&this.fire(new c.j(p))})}else typeof y=="object"&&this._updateDiff(y,n)}_updateDiff(y,n){try{this.style.setState(y,n)&&this._update(!0)}catch(u){c.w(`Unable to perform style diff: ${u.message||u.error||u}. Rebuilding the style from scratch.`),this._updateStyle(y,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():c.w("There is no style added to the map.")}addSource(y,n){return this._lazyInitEmptyStyle(),this.style.addSource(y,n),this._update(!0)}isSourceLoaded(y){const n=this.style&&this.style.sourceCaches[y];if(n!==void 0)return n.loaded();this.fire(new c.j(new Error(`There is no source with ID '${y}'`)))}setTerrain(y){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),y){const n=this.style.sourceCaches[y.source];if(!n)throw new Error(`cannot load terrain, because there exists no source with ID: ${y.source}`);this.terrain===null&&n.reload();for(const u in this.style._layers){const p=this.style._layers[u];p.type==="hillshade"&&p.source===y.source&&c.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 Xp(this.painter,n,y),this.painter.renderToTexture=new qp(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=u=>{u.dataType==="style"?this.terrain.sourceCache.freeRtt():u.dataType==="source"&&u.tile&&(u.sourceId!==y.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(u.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 c.k("terrain",{terrain:y})),this}getTerrain(){var y,n;return(n=(y=this.terrain)===null||y===void 0?void 0:y.options)!==null&&n!==void 0?n:null}areTilesLoaded(){const y=this.style&&this.style.sourceCaches;for(const n in y){const u=y[n]._tiles;for(const p in u){const _=u[p];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(y){return this.style.removeSource(y),this._update(!0)}getSource(y){return this.style.getSource(y)}addImage(y,n,u={}){const{pixelRatio:p=1,sdf:_=!1,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C}=u;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||c.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new c.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:F,height:N,data:V}=n,W=n;return this.style.addImage(y,{data:new c.R({width:F,height:N},new Uint8Array(V)),pixelRatio:p,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C,sdf:_,version:0,userImage:W}),W.onAdd&&W.onAdd(this,y),this}}{const{width:F,height:N,data:V}=M.getImageData(n);this.style.addImage(y,{data:new c.R({width:F,height:N},V),pixelRatio:p,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C,sdf:_,version:0})}}updateImage(y,n){const u=this.style.getImage(y);if(!u)return this.fire(new c.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const p=n instanceof HTMLImageElement||c.b(n)?M.getImageData(n):n,{width:_,height:m,data:T}=p;if(_===void 0||m===void 0)return this.fire(new c.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(_!==u.data.width||m!==u.data.height)return this.fire(new c.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const A=!(n instanceof HTMLImageElement||c.b(n));return u.data.replace(T,A),this.style.updateImage(y,u),this}getImage(y){return this.style.getImage(y)}hasImage(y){return y?!!this.style.getImage(y):(this.fire(new c.j(new Error("Missing required image id"))),!1)}removeImage(y){this.style.removeImage(y)}loadImage(y){return Se.getImage(this._requestManager.transformRequest(y,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(y,n){return this._lazyInitEmptyStyle(),this.style.addLayer(y,n),this._update(!0)}moveLayer(y,n){return this.style.moveLayer(y,n),this._update(!0)}removeLayer(y){return this.style.removeLayer(y),this._update(!0)}getLayer(y){return this.style.getLayer(y)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(y,n,u){return this.style.setLayerZoomRange(y,n,u),this._update(!0)}setFilter(y,n,u={}){return this.style.setFilter(y,n,u),this._update(!0)}getFilter(y){return this.style.getFilter(y)}setPaintProperty(y,n,u,p={}){return this.style.setPaintProperty(y,n,u,p),this._update(!0)}getPaintProperty(y,n){return this.style.getPaintProperty(y,n)}setLayoutProperty(y,n,u,p={}){return this.style.setLayoutProperty(y,n,u,p),this._update(!0)}getLayoutProperty(y,n){return this.style.getLayoutProperty(y,n)}setGlyphs(y,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(y,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(y,n,u={}){return this._lazyInitEmptyStyle(),this.style.addSprite(y,n,u,p=>{p||this._update(!0)}),this}removeSprite(y){return this._lazyInitEmptyStyle(),this.style.removeSprite(y),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(y,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(y,n,u=>{u||this._update(!0)}),this}setLight(y,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(y,n),this._update(!0)}getLight(){return this.style.getLight()}setSky(y){return this._lazyInitEmptyStyle(),this.style.setSky(y),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(y,n){return this.style.setFeatureState(y,n),this._update()}removeFeatureState(y,n){return this.style.removeFeatureState(y,n),this._update()}getFeatureState(y){return this.style.getFeatureState(y)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let y=0,n=0;return this._container&&(y=this._container.clientWidth||400,n=this._container.clientHeight||300),[y,n]}_setupContainer(){const y=this._container;y.classList.add("maplibregl-map");const n=this._canvasContainer=D.create("div","maplibregl-canvas-container",y);this._interactive&&n.classList.add("maplibregl-interactive"),this._canvas=D.create("canvas","maplibregl-canvas",n),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 u=this._containerDimensions(),p=this._getClampedPixelRatio(u[0],u[1]);this._resizeCanvas(u[0],u[1],p);const _=this._controlContainer=D.create("div","maplibregl-control-container",y),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(T=>{m[T]=D.create("div",`maplibregl-ctrl-${T} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(y,n,u){this._canvas.width=Math.floor(u*y),this._canvas.height=Math.floor(u*n),this._canvas.style.width=`${y}px`,this._canvas.style.height=`${n}px`}_setupPainter(){const y={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let n=null;this._canvas.addEventListener("webglcontextcreationerror",p=>{n={requestedAttributes:y},p&&(n.statusMessage=p.statusMessage,n.type=p.type)},{once:!0});const u=this._canvas.getContext("webgl2",y)||this._canvas.getContext("webgl",y);if(!u){const p="Failed to initialize WebGL";throw n?(n.message=p,new Error(JSON.stringify(n))):new Error(p)}this.painter=new Lp(u,this.transform),H.testSupport(u)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(y){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||y,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(y){return this._update(),this._renderTaskQueue.add(y)}_cancelRenderFrame(y){this._renderTaskQueue.remove(y)}_render(y){const n=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(y),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,m=M.now();this.style.zoomHistory.update(_,m);const T=new c.a9(_,{now:m,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),A=T.crossFadingFactor();A===1&&A===this._crossFadingFactor||(u=!0,this._crossFadingFactor=A),this.style.update(T)}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,n,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding}),this.fire(new c.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.be.mark(c.bf.load),this.fire(new c.k("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.k("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0,c.be.mark(c.bf.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var y;this._hash&&this._hash.remove();for(const u of this._controls)u.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),Se.removeThrottleControl(this._imageQueueHandle),(y=this._resizeObserver)===null||y===void 0||y.disconnect();const n=this.painter.context.gl.getExtension("WEBGL_lose_context");n!=null&&n.loseContext&&n.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),D.remove(this._canvasContainer),D.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),c.be.clearMetrics(),this._removed=!0,this.fire(new c.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,M.frameAsync(this._frameRequest).then(y=>{c.be.frame(y),this._frameRequest=null,this._render(y)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(y){this._showTileBoundaries!==y&&(this._showTileBoundaries=y,this._update())}get showPadding(){return!!this._showPadding}set showPadding(y){this._showPadding!==y&&(this._showPadding=y,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(y){this._showCollisionBoxes!==y&&(this._showCollisionBoxes=y,y?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(y){this._showOverdrawInspector!==y&&(this._showOverdrawInspector=y,this._update())}get repaint(){return!!this._repaint}set repaint(y){this._repaint!==y&&(this._repaint=y,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(y){this._vertices=y,this._update()}get version(){return Sd}getCameraTargetElevation(){return this.transform.elevation}},d.MapMouseEvent=Gr,d.MapTouchEvent=Wl,d.MapWheelEvent=nd,d.Marker=Ti,d.NavigationControl=class{constructor(y){this._updateZoomButtons=()=>{const n=this._map.getZoom(),u=n===this._map.getMaxZoom(),p=n===this._map.getMinZoom();this._zoomInButton.disabled=u,this._zoomOutButton.disabled=p,this._zoomInButton.setAttribute("aria-disabled",u.toString()),this._zoomOutButton.setAttribute("aria-disabled",p.toString())},this._rotateCompassArrow=()=>{const n=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=n},this._setButtonTitle=(n,u)=>{const p=this._map._getUIString(`NavigationControl.${u}`);n.title=p,n.setAttribute("aria-label",p)},this.options=c.e({},Ed,y),this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",n=>n.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",n=>this._map.zoomIn({},{originalEvent:n})),D.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",n=>this._map.zoomOut({},{originalEvent:n})),D.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",n=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:n}):this._map.resetNorth({},{originalEvent:n})}),this._compassIcon=D.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(y){return this._map=y,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 Yp(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){D.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(y,n){const u=D.create("button",y,this._container);return u.type="button",u.addEventListener("click",n),u}},d.Popup=class extends c.E{constructor(y){super(),this.remove=()=>(this._content&&D.remove(this._content),this._container&&(D.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 c.k("close"))),this),this._onMouseUp=n=>{this._update(n.point)},this._onMouseMove=n=>{this._update(n.point)},this._onDrag=n=>{this._update(n.point)},this._update=n=>{var u;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=D.create("div","maplibregl-popup",this._map.getContainer()),this._tip=D.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const A of this.options.className.split(" "))this._container.classList.add(A);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?Kp(this._lngLat,this._flatPos,this._map.transform):(u=this._lngLat)===null||u===void 0?void 0:u.wrap(),this._trackPointer&&!n)return;const p=this._flatPos=this._pos=this._trackPointer&&n?n:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&n?n:this._map.transform.locationPoint(this._lngLat));let _=this.options.anchor;const m=St(this.options.offset);if(!_){const A=this._container.offsetWidth,R=this._container.offsetHeight;let C;C=p.y+m.bottom.ythis._map.transform.height-R?["bottom"]:[],p.xthis._map.transform.width-A/2&&C.push("right"),_=C.length===0?"bottom":C.join("-")}let T=p.add(m[_]);this.options.subpixelPositioning||(T=T.round()),D.setTransform(this._container,`${Ad[_]} translate(${T.x}px,${T.y}px)`),fo(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(Mn),y)}addTo(y){return this._map&&this.remove(),this._map=y,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 c.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(y){return this._lngLat=c.N.convert(y),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(y){return this.setDOMContent(document.createTextNode(y))}setHTML(y){const n=document.createDocumentFragment(),u=document.createElement("body");let p;for(u.innerHTML=y;p=u.firstChild,p;)n.appendChild(p);return this.setDOMContent(n)}getMaxWidth(){var y;return(y=this._container)===null||y===void 0?void 0:y.style.maxWidth}setMaxWidth(y){return this.options.maxWidth=y,this._update(),this}setDOMContent(y){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=D.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(y),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(y){return this._container&&this._container.classList.add(y),this}removeClassName(y){return this._container&&this._container.classList.remove(y),this}setOffset(y){return this.options.offset=y,this._update(),this}toggleClassName(y){if(this._container)return this._container.classList.toggle(y)}setSubpixelPositioning(y){this.options.subpixelPositioning=y}_createCloseButton(){this.options.closeButton&&(this._closeButton=D.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 y=this._container.querySelector(_h);y&&y.focus()}},d.RasterDEMTileSource=We,d.RasterTileSource=$e,d.ScaleControl=class{constructor(y){this._onMove=()=>{Id(this._map,this._container,this.options)},this.setUnit=n=>{this.options.unit=n,Id(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Jp),y)}getDefaultPosition(){return"bottom-left"}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-scale",y.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){D.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},d.ScrollZoomHandler=yd,d.Style=js,d.TerrainControl=class{constructor(y){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=y}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=D.create("button","maplibregl-ctrl-terrain",this._container),D.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(){D.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},d.TwoFingersTouchPitchHandler=_d,d.TwoFingersTouchRotateHandler=pd,d.TwoFingersTouchZoomHandler=dd,d.TwoFingersTouchZoomRotateHandler=vd,d.VectorTileSource=Ke,d.VideoSource=At,d.addSourceType=(y,n)=>c._(void 0,void 0,void 0,function*(){if($t(y))throw new Error(`A source type called "${y}" already exists.`);((u,p)=>{Bt[u]=p})(y,n)}),d.clearPrewarmedResources=function(){const y=ni;y&&(y.isPreloaded()&&y.numActive()===1?(y.release(os),ni=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()"))},d.getMaxParallelImageRequests=function(){return c.a.MAX_PARALLEL_IMAGE_REQUESTS},d.getRTLTextPluginStatus=function(){return xi().getRTLTextPluginStatus()},d.getVersion=function(){return Mt},d.getWorkerCount=function(){return as.workerCount},d.getWorkerUrl=function(){return c.a.WORKER_URL},d.importScriptInWorkers=function(y){return Ss().broadcast("IS",y)},d.prewarm=function(){ci().acquire(os)},d.setMaxParallelImageRequests=function(y){c.a.MAX_PARALLEL_IMAGE_REQUESTS=y},d.setRTLTextPlugin=function(y,n){return xi().setRTLTextPlugin(y,n)},d.setWorkerCount=function(y){as.workerCount=y},d.setWorkerUrl=function(y){c.a.WORKER_URL=y}});var h=i;return h})})(QP);var g$=QP.exports;const sA=RP(g$);function bn(t,e,i,r,o){return Qn(e,tR(t,e),i,r,o)}function Qn(t,e,i,r,o,h){const d=_v(e,i,r);if(o&&e!==d)throw new RangeError(wC(t,e,i,r,h));return d}function tR(t,e){const i=t[e];if(i===void 0)throw new TypeError(r1(e));return i}function zs(t){return t!==null&&/object|function/.test(typeof t)}function zn(t,e=Map){const i=new e;return(r,...o)=>{if(i.has(r))return i.get(r);const h=t(r,...o);return i.set(r,h),h}}function nA(t){return mu({name:t},1)}function mu(t,e){return Bo(i=>({value:i,configurable:1,writable:!e}),t)}function m$(t){return Bo(e=>({get:e,configurable:1}),t)}function fx(t){return{[Symbol.toStringTag]:{value:t,configurable:1}}}function Su(t,e){const i={};let r=t.length;for(const o of e)i[t[--r]]=o;return i}function Bo(t,e,i){const r={};for(const o in e)r[o]=t(e[o],o,i);return r}function Mm(t,e,i){const r={};for(let o=0;ot(...e,...i)}function aA(t){return t[0].toUpperCase()+t.substring(1)}function rp(t){return t.slice().sort()}function Og(t,e){return String(e).padStart(t,"0")}function pl(t,e){return Math.sign(t-e)}function _v(t,e,i){return Math.min(Math.max(t,e),i)}function ba(t,e){return[Math.floor(t/e),wf(t,e)]}function wf(t,e){return(t%e+e)%e}function bl(t,e){return[km(t,e),px(t,e)]}function km(t,e){return Math.trunc(t/e)||0}function px(t,e){return t%e||0}function $_(t){return Math.abs(t%1)===.5}function nR(t,e,i){let r=0,o=0;for(let c=0;c<=e;c++){const x=t[i[c]],S=zo[c],P=gr/S,[M,D]=bl(x,P);r+=D*S,o+=M}const[h,d]=bl(r,gr);return[o+h,d]}function Dm(t,e,i){const r={};for(let o=e;o>=0;o--){const h=zo[o];r[i[o]]=km(t,h),t=px(t,h)}return r}function v$(t){return t===vi?cy:[]}function x$(t){return t===vi?lp:[]}function w$(t){return t===vi?["year","day"]:[]}function T$(t){if(t!==void 0)return ns(t)}function S$(t){if(t!==void 0)return ko(t)}function oR(t){if(t!==void 0)return Om(t)}function ko(t){return cR(Om(t))}function Om(t){return lR(H7(t))}function lA(t){if(t==null)throw new TypeError("Cannot be null or undefined");return t}function aR(t,e){if(e==null)throw new RangeError(r1(t));return e}function Al(t){if(!zs(t))throw new TypeError(xC);return t}function Fm(t,e,i=t){if(typeof e!==t)throw new TypeError(op(i,e));return e}function lR(t,e="number"){if(!Number.isInteger(t))throw new RangeError(h7(e,t));return t||0}function cR(t,e="number"){if(t<=0)throw new RangeError(u7(e,t));return t}function _x(t){if(typeof t=="symbol")throw new TypeError(_7);return String(t)}function Fg(t,e){return zs(t)?String(t):ns(t,e)}function Nm(t){if(typeof t=="string")return BigInt(t);if(typeof t!="bigint")throw new TypeError(p7(t));return t}function hR(t,e="number"){if(typeof t=="bigint")throw new TypeError(f7(e));if(t=Number(t),!Number.isFinite(t))throw new RangeError(d7(e,t));return t}function Ys(t,e){return Math.trunc(hR(t,e))||0}function uR(t,e){return lR(hR(t,e),e)}function cA(t,e){return cR(Ys(t,e),e)}function gx(t,e){let[i,r]=bl(e,gr),o=t+i;const h=Math.sign(o);return h&&h===-Math.sign(r)&&(o-=h,r+=h*gr),[o,r]}function yu(t,e,i=1){return gx(t[0]+e[0]*i,t[1]+e[1]*i)}function bu(t,e){return gx(t[0],t[1]+e)}function so(t,e){return yu(e,t,-1)}function En(t,e){return pl(t[0],e[0])||pl(t[1],e[1])}function dR(t,e,i){return En(t,e)===-1||En(t,i)===1}function Bm(t,e=1){const i=BigInt(gr/e);return[Number(t/i),Number(t%i)*e]}function jf(t,e=1){const i=gr/e,[r,o]=bl(t,i);return[r,o*e]}function fR(t,e=1){const[i,r]=t,o=Math.floor(r/e),h=gr/e;return BigInt(i)*BigInt(h)+BigInt(o)}function no(t,e=1,i){const[r,o]=t,[h,d]=bl(o,e);return r*(gr/e)+(h+(i?d/e:0))}function mx(t,e,i=ba){const[r,o]=t,[h,d]=i(o,e);return[r*(gr/e)+h,d]}function yx(t,e){const i=t.formatToParts(e),r={};for(const o of i)r[o.type]=o.value;return r}function bx(t){return bn(t,"isoYear",qf,Xf,1),t.isoYear===qf?bn(t,"isoMonth",4,12,1):t.isoYear===Xf&&bn(t,"isoMonth",1,9,1),t}function _l(t){return Sa({...t,...Lo,isoHour:12}),t}function Sa(t){const e=bn(t,"isoYear",qf,Xf,1),i=e===qf?1:e===Xf?-1:0;return i&&Vn(Ks({...t,isoDay:t.isoDay+i,isoNanosecond:t.isoNanosecond-i})),t}function Vn(t){if(!t||dR(t,Q7,G7))throw new RangeError(sy);return t}function vl(t){return nR(t,5,jo)[1]}function zm(t){const[e,i]=ba(t,gr);return[Dm(i,5,jo),e]}function pR(t){return _R(t)[0]}function _R(t){return mx(t,io)}function Gs(t){return Eu(t.isoYear,t.isoMonth,t.isoDay,t.isoHour,t.isoMinute,t.isoSecond,t.isoMillisecond)}function Ks(t){const e=Gs(t);if(e!==void 0){const[i,r]=bl(e,Tn);return[i,r*Ea+(t.isoMicrosecond||0)*Hc+(t.isoNanosecond||0)]}}function vx(t,e){const[i,r]=zm(vl(t)-e);return Vn(Ks({...t,isoDay:t.isoDay+r,...i}))}function Ng(...t){return Eu(...t)/RC}function Eu(...t){const[e,i]=gR(...t),r=e.valueOf();if(!isNaN(r))return r-i*Tn}function gR(t,e=1,i=1,r=0,o=0,h=0,d=0){const c=t===qf?1:t===Xf?-1:0,x=new Date;return x.setUTCHours(r,o,h,d),x.setUTCFullYear(t,e-1,i+c),[x,c]}function zc(t,e){let[i,r]=bu(t,e);r<0&&(r+=gr,i-=1);const[o,h]=ba(r,Ea),[d,c]=ba(h,Hc);return Lm(i*Tn+o,d,c)}function Lm(t,e=0,i=0){const r=Math.ceil(Math.max(0,Math.abs(t)-J7)/Tn)*Math.sign(t),o=new Date(t-r*Tn);return Su(uy,[o.getUTCFullYear(),o.getUTCMonth()+1,o.getUTCDate()+r,o.getUTCHours(),o.getUTCMinutes(),o.getUTCSeconds(),o.getUTCMilliseconds(),e,i])}function mR(t){return[t.isoYear,t.isoMonth,t.isoDay]}function yR(){return fa}function xx(t,e){switch(e){case 2:return wx(t)?29:28;case 4:case 6:case 9:case 11:return 30}return 31}function bR(t){return wx(t)?366:365}function wx(t){return t%4==0&&(t%100!=0||t%400==0)}function vR(t){const[e,i]=gR(t.isoYear,t.isoMonth,t.isoDay);return wf(e.getUTCDay()-i,7)||7}function xR({isoYear:t}){return t<1?["bce",1-t]:["ce",t]}function E$(t){const e=Gs(t);if(eP<4?(P+2)%4:P)(x)),[d,S,c,x]}function $m(t,e=6,i){let r=Ex(t=Ix(t,jg));const o=hp(t,7);let h=cp(t,e);return h=aR(jg,h),r=Ax(r,h,void 0,i),[h,r,o]}function Tx(t){return _1(ao(t))}function SR(t,e){return Sx(ao(t),e)}function Sx(t,e=4){const i=AR(t);return[hp(t,4),...ER(cp(t,e),i)]}function ER(t,e){return t!=null?[zo[t],t<4?9-3*t:-1]:[e===void 0?1:10**(9-e),e]}function Ex(t){const e=t[Tf];return e===void 0?1:Ys(e,Tf)}function Ax(t,e,i,r){const o=r?gr:zo[e+1];if(o){const h=zo[e];if(o%((t=Qn(Tf,t,1,o/h-(r?0:1),1))*h))throw new RangeError(op(Tf,t))}else t=Qn(Tf,t,1,i?10**9:1,1);return t}function AR(t){let e=t[db];if(e!==void 0){if(typeof e!="number"){if(_x(e)==="auto")return;throw new RangeError(op(db,e))}e=Qn(db,Math.floor(e),0,9,1)}return e}function ao(t){return t===void 0?{}:Al(t)}function Ix(t,e){return typeof t=="string"?{[e]:t}:Al(t)}function Ts(t){if(t!==void 0){if(zs(t))return Object.assign(Object.create(null),t);throw new TypeError(xC)}}function Wm(t,e){return t&&Object.assign(Object.create(null),t,{overflow:rW[e]})}function Px(t,e,i=9,r=0,o){let h=e[t];if(h===void 0)return o?r:void 0;if(h=_x(h),h==="auto")return o?r:null;let d=bv[h];if(d===void 0&&(d=Y7[h]),d===void 0)throw new RangeError(EC(t,h,bv));return Qn(t,d,r,i,1,oy),d}function Uc(t,e,i,r=0){const o=i[t];if(o===void 0)return r;const h=_x(o),d=e[h];if(d===void 0)throw new RangeError(EC(t,h,e));return d}function IR(t,e){if(e>t)throw new RangeError(B7)}function Ns(t){return{branding:m1,epochNanoseconds:t}}function Qs(t,e,i){return{branding:kl,calendar:i,timeZone:e,epochNanoseconds:t}}function vs(t,e=t.calendar){return{branding:Nu,calendar:e,...Un(UC,t)}}function xs(t,e=t.calendar){return{branding:Fu,calendar:e,...Un(d1,t)}}function Cc(t,e=t.calendar){return{branding:Zf,calendar:e,...Un(d1,t)}}function Bg(t,e=t.calendar){return{branding:Yf,calendar:e,...Un(d1,t)}}function Uo(t){return{branding:g1,...Un(LC,t)}}function Jr(t){return{branding:y1,sign:Il(t),...Un(l1,t)}}function I$(t){return pR(t.epochNanoseconds)}function Rx(t){return mx(t.epochNanoseconds,Ea)[0]}function P$(t){return fR(t.epochNanoseconds,Hc)}function R$(t){return fR(t.epochNanoseconds)}function PR(t){return t.epochNanoseconds}function en(t){return typeof t=="string"?t:ns(t.id)}function Iu(t,e){return t===e||en(t)===en(e)}function C$(t,e,i,r,o){const h=Mc(r),[d,c]=((_e,ve)=>{const be=ve((_e=Ix(_e,wv))[jC]);let Se=hW(_e);return Se=aR(wv,Se),[Se,be]})(o,t);if(Wf(Math.max(d,h),c))return uA(r,d);if(!c)throw new RangeError(ny);const[x,S,P]=Ym(e,i,c),M=zx(P),D=Km(P),H=Lx(P),Q=D(S,x,r),G=H(S,x,Q,d);return Wf(d,c)?uA(G,d):((_e,ve,be,Se,Be,je,Fe)=>{const rt=Il(_e),[vt,lt]=Cx(Se,h1(be,_e),be,rt,Be,je,Fe),Pt=Mx(ve,vt,lt);return _e[tr[be]]+Pt*rt})(G,M(Q),d,S,x,M,D)}function uA(t,e){return no(ws(t),zo[e],1)}function Cx(t,e,i,r,o,h,d){const c=tr[i],x={...e,[c]:e[c]+r},S=d(t,o,e),P=d(t,o,x);return[h(S),h(P)]}function Mx(t,e,i){const r=no(so(e,i));if(!r)throw new RangeError(ap);return no(so(e,t))/r}function M$(t,e){const[i,r,o]=$m(e,5,1);return Ns(Xm(t.epochNanoseconds,i,r,o,1))}function k$(t,e,i){let{epochNanoseconds:r,timeZone:o,calendar:h}=e;const[d,c,x]=$m(i);if(d===0&&c===1)return e;const S=t(o);if(d===6)r=((P,M,D,H)=>{const Q=An(D,M),[G,_e]=P(Q),ve=D.epochNanoseconds,be=Ln(M,G),Se=Ln(M,_e);if(dR(ve,be,Se))throw new RangeError(ap);return DR(Mx(ve,be,Se),H)?Se:be})(MR,S,e,x);else{const P=S.getOffsetNanosecondsFor(r);r=Vc(S,RR(zc(r,P),d,c,x),P,2,0,1)}return Qs(r,o,h)}function D$(t,e){return vs(RR(t,...$m(e)),t.calendar)}function O$(t,e){const[i,r,o]=$m(e,5);var h;return Uo((h=o,kx(t,sp(i,r),h)[0]))}function F$(t,e){const i=t(e.timeZone),r=An(e,i),[o,h]=MR(r),d=no(so(Ln(i,o),Ln(i,h)),ly,1);if(d<=0)throw new RangeError(ap);return d}function N$(t,e){const{timeZone:i,calendar:r}=e,o=((h,d,c)=>Ln(d,h(An(c,d))))(kR,t(i),e);return Qs(o,i,r)}function RR(t,e,i,r){return CR(t,sp(e,i),r)}function CR(t,e,i){const[r,o]=kx(t,e,i);return Sa({...jc(t,o),...r})}function kx(t,e,i){return zm(xl(vl(t),e,i))}function zg(t){return xl(t,ay,7)}function sp(t,e){return zo[t]*e}function MR(t){const e=kR(t);return[e,jc(e,1)]}function kR(t){return K7(6,t)}function B$(t,e,i){const r=Math.min(Mc(t),6);return Cu(qm(ws(t,r),e,i),r)}function Hm(t,e,i,r,o,h,d,c,x,S){if(r===0&&o===1)return t;const P=Wf(r,c)?Jm(c)&&r<6&&i>=6?L$:z$:U$;let[M,D,H]=P(t,e,i,r,o,h,d,c,x,S);return H&&r!==7&&(M=((Q,G,_e,ve,be,Se,Be,je)=>{const Fe=Il(Q);for(let rt=ve+1;rt<=_e;rt++){if(rt===7&&_e!==7)continue;const vt=h1(rt,Q);vt[tr[rt]]+=Fe;const lt=no(so(Be(je(be,Se,vt)),G));if(lt&&Math.sign(lt)!==Fe)break;Q=vt}return Q})(M,D,i,Math.max(6,r),d,c,x,S)),M}function Xm(t,e,i,r,o){if(e===6){const h=(d=>d[0]+d[1]/gr)(t);return[xl(h,i,r),0]}return qm(t,sp(e,i),r,o)}function qm(t,e,i,r){let[o,h]=t;r&&h<0&&(h+=gr,o-=1);const[d,c]=ba(xl(h,e,i),gr);return gx(o+d,c)}function xl(t,e,i){return DR(t/e,i)*e}function DR(t,e){return pW[e](t)}function z$(t,e,i,r,o,h){const d=Il(t),c=ws(t),x=Xm(c,r,o,h),S=so(c,x),P=Math.sign(x[0]-c[0])===d,M=Cu(x,Math.min(i,6));return[{...t,...M},yu(e,S),P]}function L$(t,e,i,r,o,h,d,c,x,S){const P=Il(t),M=no(ws(t,5)),D=sp(r,o);let H=xl(M,D,h);const[Q,G]=Cx(d,{...t,...c1},6,P,c,x,S),_e=H-no(so(Q,G));let ve=0;_e&&Math.sign(_e)!==P?e=bu(Q,H):(ve+=P,H=xl(_e,D,h),e=bu(G,H));const be=Gm(H);return[{...t,...be,days:t.days+ve},e,!!ve]}function U$(t,e,i,r,o,h,d,c,x,S){const P=Il(t),M=tr[r],D=h1(r,t);r===7&&(t={...t,weeks:t.weeks+Math.trunc(t.days/7)});const H=km(t[M],o)*o;D[M]=H;const[Q,G]=Cx(d,D,r,o*P,c,x,S),_e=H+Mx(e,Q,G)*P*o,ve=xl(_e,o,h),be=Math.sign(ve-_e)===P;return D[M]=ve,[D,be?G:Q,be]}function dA(t,e,i,r){const[o,h,d,c]=(S=>{const P=Sx(S=ao(S));return[S.timeZone,...P]})(r),x=o!==void 0;return((S,P,M,D,H,Q)=>{M=qm(M,H,D,1);const G=P.getOffsetNanosecondsFor(M);return Dx(zc(M,G),Q)+(S?Pu(zg(G)):"Z")})(x,e(x?t(o):Xc),i.epochNanoseconds,h,d,c)}function fA(t,e,i){const[r,o,h,d,c,x]=(S=>{S=ao(S);const P=_1(S),M=AR(S),D=fW(S),H=hp(S,4),Q=cp(S,4);return[P,dW(S),D,H,...ER(Q,M)]})(i);return((S,P,M,D,H,Q,G,_e,ve,be)=>{D=qm(D,ve,_e,1);const Se=S(M).getOffsetNanosecondsFor(D);return Dx(zc(D,Se),be)+Pu(zg(Se),G)+((Be,je)=>je!==1?"["+(je===2?"!":"")+en(Be)+"]":"")(M,Q)+Ox(P,H)})(t,e.calendar,e.timeZone,e.epochNanoseconds,r,o,h,d,c,x)}function pA(t,e){const[i,r,o,h]=(S=>(S=ao(S),[_1(S),...Sx(S)]))(e);return d=t.calendar,c=i,x=h,Dx(CR(t,o,r),x)+Ox(d,c);var d,c,x}function _A(t,e){return i=t.calendar,r=t,o=Tx(e),Lg(r)+Ox(i,o);var i,r,o}function gA(t,e){return OR(t.calendar,FR,t,Tx(e))}function mA(t,e){return OR(t.calendar,V$,t,Tx(e))}function yA(t,e){const[i,r,o]=SR(e);return h=o,NR(kx(t,r,i)[0],h);var h}function lb(t,e){const[i,r,o]=SR(e,3);return r>1&&(t={...t,...B$(t,r,i)}),((h,d)=>{const{sign:c}=h,x=c===-1?tn(h):h,{hours:S,minutes:P}=x,[M,D]=mx(ws(x,3),io,bl);jR(M);const H=Fx(D,d),Q=d>=0||!c||H;return(c<0?"-":"")+"P"+bA({Y:lc(x.years),M:lc(x.months),W:lc(x.weeks),D:lc(x.days)})+(S||P||M||Q?"T"+bA({H:lc(S),M:lc(P),S:lc(M,Q)+H}):"")})(t,o)}function OR(t,e,i,r){const o=en(t),h=r>1||r===0&&o!==vi;return r===1?o===vi?e(i):Lg(i):h?Lg(i)+BR(o,r===2):e(i)}function bA(t){const e=[];for(const i in t){const r=t[i];r&&e.push(r,i)}return e.join("")}function Dx(t,e){return Lg(t)+"T"+NR(t,e)}function Lg(t){return FR(t)+"-"+to(t.isoDay)}function FR(t){const{isoYear:e}=t;return(e<0||e>9999?zR(e)+Og(6,Math.abs(e)):Og(4,e))+"-"+to(t.isoMonth)}function V$(t){return to(t.isoMonth)+"-"+to(t.isoDay)}function NR(t,e){const i=[to(t.isoHour),to(t.isoMinute)];return e!==-1&&i.push(to(t.isoSecond)+((r,o,h,d)=>Fx(r*Ea+o*Hc+h,d))(t.isoMillisecond,t.isoMicrosecond,t.isoNanosecond,e)),i.join(":")}function Pu(t,e=0){if(e===1)return"";const[i,r]=ba(Math.abs(t),ly),[o,h]=ba(r,ay),[d,c]=ba(h,io);return zR(t)+to(i)+":"+to(o)+(d||c?":"+to(d)+Fx(c):"")}function Ox(t,e){if(e!==1){const i=en(t);if(e>1||e===0&&i!==vi)return BR(i,e===2)}return""}function BR(t,e){return"["+(e?"!":"")+"u-ca="+t+"]"}function Fx(t,e){let i=Og(9,t);return i=e===void 0?i.replace(mW,""):i.slice(0,e),i?"."+i:""}function zR(t){return t<0?"-":"+"}function lc(t,e){return t||e?t.toLocaleString("fullwide",{useGrouping:0}):""}function j$(t,e){const{epochNanoseconds:i}=t,r=(e.getOffsetNanosecondsFor?e:e(t.timeZone)).getOffsetNanosecondsFor(i),o=zc(i,r);return{calendar:t.calendar,...o,offsetNanoseconds:r}}function $$(t,e){const i=An(e,t);return{calendar:e.calendar,...Un(UC,i),offset:Pu(i.offsetNanoseconds),timeZone:e.timeZone}}function Vc(t,e,i,r=0,o=0,h,d){if(i!==void 0&&r===1&&(r===1||d))return vx(e,i);const c=t.getPossibleInstantsFor(e);if(i!==void 0&&r!==3){const x=((S,P,M,D)=>{const H=Ks(P);D&&(M=zg(M));for(const Q of S){let G=no(so(Q,H));if(D&&(G=zg(G)),G===M)return Q}})(c,e,i,h);if(x!==void 0)return x;if(r===0)throw new RangeError(M7)}return d?Ks(e):Ln(t,e,o,c)}function Ln(t,e,i=0,r=t.getPossibleInstantsFor(e)){if(r.length===1)return r[0];if(i===1)throw new RangeError(k7);if(r.length)return r[i===3?1:0];const o=Ks(e),h=((c,x)=>{const S=c.getOffsetNanosecondsFor(bu(x,-gr));return UR(c.getOffsetNanosecondsFor(bu(x,gr))-S)})(t,o),d=h*(i===2?-1:1);return(r=t.getPossibleInstantsFor(zc(o,d)))[i===2?0:r.length-1]}function LR(t){if(Math.abs(t)>=gr)throw new RangeError(R7);return t}function UR(t){if(t>gr)throw new RangeError(C7);return t}function vA(t,e,i){return Ns(Vn(yu(e.epochNanoseconds,(r=>{if($R(r))throw new RangeError(F7);return ws(r,5)})(t?tn(i):i))))}function xA(t,e,i,r,o,h=Object.create(null)){const d=e(r.timeZone),c=t(r.calendar);return{...r,...Nx(d,c,r,i?tn(o):o,h)}}function wA(t,e,i,r,o=Object.create(null)){const{calendar:h}=i;return vs(Bx(t(h),i,e?tn(r):r,o),h)}function TA(t,e,i,r,o){const{calendar:h}=i;return xs(Zm(t(h),i,e?tn(r):r,o),h)}function SA(t,e,i,r,o=Object.create(null)){const h=i.calendar,d=t(h);let c=$f(d,i);e&&(r=Ux(r)),r.sign<0&&(c=d.dateAdd(c,{...Bs,months:1}),c=jc(c,-1));const x=d.dateAdd(c,r,o);return Cc($f(d,x),h)}function EA(t,e,i){return Uo(VR(e,t?tn(i):i)[0])}function Nx(t,e,i,r,o){const h=ws(r,5);let d=i.epochNanoseconds;if($R(r)){const c=An(i,t);d=yu(Ln(t,{...Zm(e,c,{...r,...c1},o),...Un(jo,c)}),h)}else d=yu(d,h),Ki(o);return{epochNanoseconds:Vn(d)}}function Bx(t,e,i,r){const[o,h]=VR(e,i);return Sa({...Zm(t,e,{...i,...c1,days:i.days+h},r),...o})}function Zm(t,e,i,r){if(i.years||i.months||i.weeks)return t.dateAdd(e,i,r);Ki(r);const o=i.days+ws(i,5)[0];return o?_l(jc(e,o)):e}function $f(t,e,i=1){return jc(e,i-t.day(e))}function VR(t,e){const[i,r]=ws(e,5),[o,h]=zm(vl(t)+r);return[o,i+h]}function jc(t,e){return e?{...t,...Lm(Gs(t)+e*Tn)}:t}function Ym(t,e,i){const r=t(i.calendar);return Jm(i)?[i,r,e(i.timeZone)]:[{...i,...Lo},r]}function zx(t){return t?PR:Ks}function Km(t){return t?gi(Nx,t):Bx}function Lx(t){return t?gi(f9,t):p9}function Jm(t){return t&&t.epochNanoseconds}function Wf(t,e){return t<=6-(Jm(e)?1:0)}function AA(t,e,i,r,o,h,d){const c=t(ao(d).relativeTo),x=Math.max(Mc(o),Mc(h));if(Wf(x,c))return Jr(Ru(((G,_e,ve,be)=>{const Se=yu(ws(G),ws(_e),be?-1:1);if(!Number.isFinite(Se[0]))throw new RangeError(sy);return{...Bs,...Cu(Se,ve)}})(o,h,x,r)));if(!c)throw new RangeError(ny);r&&(h=tn(h));const[S,P,M]=Ym(e,i,c),D=Km(M),H=Lx(M),Q=D(P,S,o);return Jr(H(P,S,D(P,Q,h),x))}function W$(t,e,i,r,o){const h=Mc(r),[d,c,x,S,P]=((Fe,rt,vt)=>{Fe=Ix(Fe,jg);let lt=p1(Fe);const Pt=vt(Fe[jC]);let ut=Ex(Fe);const ti=hp(Fe,7);let Ft=cp(Fe);if(lt===void 0&&Ft===void 0)throw new RangeError(N7);return Ft==null&&(Ft=0),lt==null&&(lt=Math.max(Ft,rt)),IR(lt,Ft),ut=Ax(ut,Ft,1),[lt,Ft,ut,ti,Pt]})(o,h,t),M=Math.max(h,d);if(!Jm(P)&&M<=6)return Jr(Ru(((Fe,rt,vt,lt,Pt)=>{const ut=Xm(ws(Fe),vt,lt,Pt);return{...Bs,...Cu(ut,rt)}})(r,d,c,x,S)));if(!P)throw new RangeError(ny);const[D,H,Q]=Ym(e,i,P),G=zx(Q),_e=Km(Q),ve=Lx(Q),be=_e(H,D,r);let Se=ve(H,D,be,d);const Be=r.sign,je=Il(Se);if(Be&&je&&Be!==je)throw new RangeError(ap);return je&&(Se=Hm(Se,G(be),d,c,x,S,H,D,G,_e)),Jr(Se)}function H$(t){return t.sign===-1?Ux(t):t}function Ux(t){return Jr(tn(t))}function tn(t){const e={};for(const i of tr)e[i]=-1*t[i]||0;return e}function X$(t){return!t.sign}function Il(t,e=tr){let i=0;for(const r of e){const o=Math.sign(t[r]);if(o){if(i&&i!==o)throw new RangeError(O7);i=o}}return i}function Ru(t){for(const e of Z7)Qn(e,t[e],-VA,VA,1);return jR(no(ws(t),io)),t}function jR(t){if(!Number.isSafeInteger(t))throw new RangeError(D7)}function ws(t,e=6){return nR(t,e,tr)}function Cu(t,e=6){const[i,r]=t,o=Dm(r,e,tr);if(o[tr[e]]+=i*(gr/zo[e]),!Number.isFinite(o[tr[e]]))throw new RangeError(sy);return o}function Gm(t,e=5){return Dm(t,e,tr)}function $R(t){return!!Il(t,zC)}function Mc(t){let e=9;for(;e>0&&!t[tr[e]];e--);return e}function q$(t,e){return[t,e]}function IA(t){const e=Math.floor(t/rg)*rg;return[e,e+rg]}function Z$(t){const e=Pl(t=Fg(t));if(!e)throw new RangeError(wn(t));let i;if(e.m)i=0;else{if(!e.offset)throw new RangeError(wn(t));i=Mu(e.offset)}return e.timeZone&&Hx(e.timeZone,1),Ns(vx(Um(e),i))}function Y$(t){const e=Pl(ns(t));if(!e)throw new RangeError(wn(t));if(e.timeZone)return WR(e,e.offset?Mu(e.offset):void 0);if(e.m)throw new RangeError(wn(t));return XR(e)}function K$(t,e){const i=Pl(ns(t));if(!i||!i.timeZone)throw new RangeError(wn(t));const{offset:r}=i,o=r?Mu(r):void 0,[,h,d]=jm(e);return WR(i,o,h,d)}function Mu(t){const e=Hx(t);if(e===void 0)throw new RangeError(wn(t));return e}function J$(t){const e=Pl(ns(t));if(!e||e.m)throw new RangeError(wn(t));return vs(HR(e))}function Vx(t){const e=Pl(ns(t));if(!e||e.m)throw new RangeError(wn(t));return xs(e.p?HR(e):XR(e))}function G$(t,e){const i=$x(ns(e));if(i)return jx(i),Cc(bx(Lc(i)));const r=Vx(e);return Cc($f(t(r.calendar),r))}function jx(t){if(t.calendar!==vi)throw new RangeError(va(t.calendar))}function Q$(t,e){const i=Wx(ns(e));if(i)return jx(i),Bg(Lc(i));const r=Vx(e),{calendar:o}=r,h=t(o),[d,c,x]=h.h(r),[S,P]=h.I(d,c),[M,D]=h.N(S,P,x);return Bg(_l(h.P(M,D,x)),o)}function e9(t){let e,i=(r=>{const o=SW.exec(r);return o?(Qm(o[10]),YR(o)):void 0})(ns(t));if(!i){if(i=Pl(t),!i)throw new RangeError(wn(t));if(!i.p)throw new RangeError(wn(t));if(i.m)throw new RangeError(va("Z"));jx(i)}if((e=$x(t))&&hA(e))throw new RangeError(wn(t));if((e=Wx(t))&&hA(e))throw new RangeError(wn(t));return Uo(Vm(i,1))}function t9(t){const e=(i=>{const r=IW.exec(i);return r?(o=>{function h(P,M,D){let H=0,Q=0;if(D&&([H,x]=ba(x,zo[D])),P!==void 0){if(c)throw new RangeError(va(P));Q=(G=>{const _e=parseInt(G);if(!Number.isFinite(_e))throw new RangeError(va(G));return _e})(P),d=1,M&&(x=Xx(M)*(zo[D]/io),c=1)}return H+Q}let d=0,c=0,x=0,S={...Su(tr,[h(o[2]),h(o[3]),h(o[4]),h(o[5]),h(o[6],o[7],5),h(o[8],o[9],4),h(o[10],o[11],3)]),...Dm(x,2,tr)};if(!d)throw new RangeError(SC(tr));return qx(o[1])<0&&(S=tn(S)),S})(r):void 0})(ns(t));if(!e)throw new RangeError(wn(t));return Jr(Ru(e))}function i9(t){const e=Pl(t)||$x(t)||Wx(t);return e?e.calendar:t}function r9(t){const e=Pl(t);return e&&(e.timeZone||e.m&&Xc||e.offset)||t}function WR(t,e,i=0,r=0){const o=Zx(t.timeZone),h=b1(o);return Qs(Vc(h,Um(t),e,i,r,!h.v,t.m),o,ry(t.calendar))}function HR(t){return qR(Sa(Um(t)))}function XR(t){return qR(_l(Lc(t)))}function qR(t){return{...t,calendar:ry(t.calendar)}}function Pl(t){const e=TW.exec(t);return e?(i=>{const r=i[10],o=(r||"").toUpperCase()==="Z";return{isoYear:ZR(i),isoMonth:parseInt(i[4]),isoDay:parseInt(i[5]),...YR(i.slice(5)),...Qm(i[16]),p:!!i[6],m:o,offset:o?void 0:r}})(e):void 0}function $x(t){const e=xW.exec(t);return e?(i=>({isoYear:ZR(i),isoMonth:parseInt(i[4]),isoDay:1,...Qm(i[5])}))(e):void 0}function Wx(t){const e=wW.exec(t);return e?(i=>({isoYear:xu,isoMonth:parseInt(i[1]),isoDay:parseInt(i[2]),...Qm(i[3])}))(e):void 0}function Hx(t,e){const i=EW.exec(t);return i?((r,o)=>{const h=r[4]||r[5];if(o&&h)throw new RangeError(va(h));return LR((ou(r[2])*ly+ou(r[3])*ay+ou(r[4])*io+Xx(r[5]||""))*qx(r[1]))})(i,e):void 0}function ZR(t){const e=qx(t[1]),i=parseInt(t[2]||t[3]);if(e<0&&!i)throw new RangeError(va(-0));return e*i}function YR(t){const e=ou(t[3]);return{...zm(Xx(t[4]||""))[0],isoHour:ou(t[1]),isoMinute:ou(t[2]),isoSecond:e===60?59:e}}function Qm(t){let e,i;const r=[];if(t.replace(AW,(o,h,d)=>{const c=!!h,[x,S]=d.split("=").reverse();if(S){if(S==="u-ca")r.push(x),e||(e=c);else if(c||/[A-Z]/.test(S))throw new RangeError(va(o))}else{if(i)throw new RangeError(va(o));i=x}return""}),r.length>1&&e)throw new RangeError(va(t));return{timeZone:i,calendar:r[0]||vi}}function Xx(t){return parseInt(t.padEnd(9,"0"))}function ku(t){return new RegExp(`^${t}$`,"i")}function qx(t){return t&&t!=="+"?-1:1}function ou(t){return t===void 0?0:parseInt(t)}function s9(t){return Zx(ns(t))}function Zx(t){const e=Yx(t);return typeof e=="number"?Pu(e):e?(i=>{if(RW.test(i))throw new RangeError(P7);return i.toLowerCase().split("/").map((r,o)=>(r.length<=3||/\d/.test(r))&&!/etc|yap/.test(r)?r.toUpperCase():r.replace(/baja|dumont|[a-z]+/g,(h,d)=>h.length<=2&&!o||h==="in"||h==="chat"?h.toUpperCase():h.length>2||!d?aA(h).replace(/island|noronha|murdo|rivadavia|urville/,aA):h)).join("/")})(t):Xc}function PA(t){const e=Yx(t);return typeof e=="number"?e:e?e.resolvedOptions().timeZone:Xc}function Yx(t){const e=Hx(t=t.toUpperCase(),1);return e!==void 0?e:t!==Xc?PW(t):void 0}function KR(t,e){return En(t.epochNanoseconds,e.epochNanoseconds)}function JR(t,e){return En(t.epochNanoseconds,e.epochNanoseconds)}function n9(t,e,i,r,o,h){const d=t(ao(h).relativeTo),c=Math.max(Mc(r),Mc(o));if(rR(tr,r,o))return 0;if(Wf(c,d))return En(ws(r),ws(o));if(!d)throw new RangeError(ny);const[x,S,P]=Ym(e,i,d),M=zx(P),D=Km(P);return En(M(D(S,x,r)),M(D(S,x,o)))}function GR(t,e){return Du(t,e)||Kx(t,e)}function Du(t,e){return pl(Gs(t),Gs(e))}function Kx(t,e){return pl(vl(t),vl(e))}function o9(t,e){return!KR(t,e)}function a9(t,e){return!JR(t,e)&&!!Jx(t.timeZone,e.timeZone)&&Iu(t.calendar,e.calendar)}function l9(t,e){return!GR(t,e)&&Iu(t.calendar,e.calendar)}function c9(t,e){return!Du(t,e)&&Iu(t.calendar,e.calendar)}function h9(t,e){return!Du(t,e)&&Iu(t.calendar,e.calendar)}function u9(t,e){return!Du(t,e)&&Iu(t.calendar,e.calendar)}function d9(t,e){return!Kx(t,e)}function Jx(t,e){if(t===e)return 1;const i=en(t),r=en(e);if(i===r)return 1;try{return PA(i)===PA(r)}catch{}}function RA(t,e,i,r){const o=Au(t,Ts(r),3,5),h=ey(e.epochNanoseconds,i.epochNanoseconds,...o);return Jr(t?tn(h):h)}function CA(t,e,i,r,o,h){const d=iy(r.calendar,o.calendar),c=Ts(h),[x,S,P,M]=Au(i,c,5),D=r.epochNanoseconds,H=o.epochNanoseconds,Q=En(H,D);let G;if(Q)if(x<6)G=ey(D,H,x,S,P,M);else{const _e=e(((be,Se)=>{if(!Jx(be,Se))throw new RangeError(IC);return be})(r.timeZone,o.timeZone)),ve=t(d);G=eC(ve,_e,r,o,Q,x,c),G=Hm(G,H,x,S,P,M,ve,r,PR,gi(Nx,_e))}else G=Bs;return Jr(i?tn(G):G)}function MA(t,e,i,r,o){const h=iy(i.calendar,r.calendar),d=Ts(o),[c,x,S,P]=Au(e,d,6),M=Ks(i),D=Ks(r),H=En(D,M);let Q;if(H)if(c<=6)Q=ey(M,D,c,x,S,P);else{const G=t(h);Q=tC(G,i,r,H,c,d),Q=Hm(Q,D,c,x,S,P,G,i,Ks,Bx)}else Q=Bs;return Jr(e?tn(Q):Q)}function kA(t,e,i,r,o){const h=iy(i.calendar,r.calendar),d=Ts(o);return QR(e,()=>t(h),i,r,...Au(e,d,6,9,6),d)}function DA(t,e,i,r,o){const h=iy(i.calendar,r.calendar),d=Ts(o),c=Au(e,d,9,9,8),x=t(h);return QR(e,()=>x,$f(x,i),$f(x,r),...c,d)}function QR(t,e,i,r,o,h,d,c,x){const S=Ks(i),P=Ks(r);let M;if(En(P,S))if(o===6)M=ey(S,P,o,h,d,c);else{const D=e();M=D.dateUntil(i,r,o,x),h===6&&d===1||(M=Hm(M,P,o,h,d,c,D,i,Ks,Zm))}else M=Bs;return Jr(t?tn(M):M)}function OA(t,e,i,r){const o=Ts(r),[h,d,c,x]=Au(t,o,5,5),S=xl(Gx(e,i),sp(d,c),x),P={...Bs,...Gm(S,h)};return Jr(t?tn(P):P)}function f9(t,e,i,r,o,h){const d=En(r.epochNanoseconds,i.epochNanoseconds);return d?o<6?iC(i.epochNanoseconds,r.epochNanoseconds,o):eC(e,t,i,r,d,o,h):Bs}function p9(t,e,i,r,o){const h=Ks(e),d=Ks(i),c=En(d,h);return c?r<=6?iC(h,d,r):tC(t,e,i,c,r,o):Bs}function eC(t,e,i,r,o,h,d){const[c,x,S]=((D,H,Q,G)=>{function _e(){return rt={...jc(Se,je++*-G),...be},vt=Ln(D,rt),En(Be,vt)===-G}const ve=An(H,D),be=Un(jo,ve),Se=An(Q,D),Be=Q.epochNanoseconds;let je=0;const Fe=Gx(ve,Se);let rt,vt;if(Math.sign(Fe)===-G&&je++,_e()&&(G===-1||_e()))throw new RangeError(ap);const lt=no(so(vt,Be));return[ve,rt,lt]})(e,i,r,o);var P,M;return{...h===6?(P=c,M=x,{...Bs,days:rC(P,M)}):t.dateUntil(c,x,h,d),...Gm(S)}}function tC(t,e,i,r,o,h){const[d,c,x]=((S,P,M)=>{let D=P,H=Gx(S,P);return Math.sign(H)===-M&&(D=jc(P,-M),H+=gr*M),[S,D,H]})(e,i,r);return{...t.dateUntil(d,c,o,h),...Gm(x)}}function ey(t,e,i,r,o,h){return{...Bs,...Cu(Xm(so(t,e),r,o,h),i)}}function iC(t,e,i){return{...Bs,...Cu(so(t,e),i)}}function rC(t,e){return ty(Gs(t),Gs(e))}function ty(t,e){return Math.trunc((e-t)/Tn)}function Gx(t,e){return vl(e)-vl(t)}function iy(t,e){if(!Iu(t,e))throw new RangeError(s1);return t}function _9(t){function e(o){return((h,d)=>({...sC(h,d),F:h.month,day:parseInt(h.day)}))(yx(i,o),r)}const i=T1(t),r=Ug(t);return{id:t,O:g9(e),B:m9(e)}}function g9(t){return zn(e=>{const i=Gs(e);return t(i)},WeakMap)}function m9(t){const e=t(0).year-eW;return zn(i=>{let r,o=Eu(i-e);const h=[],d=[];do o+=400*Tn;while((r=t(o)).year<=i);do o+=(1-r.day)*Tn,r.year===i&&(h.push(o),d.push(r.F)),o-=Tn;while((r=t(o)).year>=i);return{k:h.reverse(),C:PC(d.reverse())}})}function sC(t,e){let i,r,o=nC(t);if(t.era){const h=BC[e];h!==void 0&&(i=e==="islamic"?"ah":t.era.normalize("NFD").toLowerCase().replace(/[^a-z0-9]/g,""),i==="bc"||i==="b"?i="bce":i!=="ad"&&i!=="a"||(i="ce"),r=o,o=cC(r,h[i]||0))}return{era:i,eraYear:r,year:o}}function nC(t){return parseInt(t.relatedYear||t.year)}function gv(t){const{year:e,F:i,day:r}=this.O(t),{C:o}=this.B(e);return[e,o[i]+1,r]}function Hf(t,e=1,i=1){return this.B(t).k[e-1]+(i-1)*Tn}function W_(t){const e=NA(this,t),i=NA(this,t-1),r=e.length;if(r>i.length){const o=hC(this);if(o<0)return-o;for(let h=0;hi.length&&(r=1,o=this.B(t+1).k),ty(i[e-1],o[r-1])}function X_(t){return this.B(t).k.length}function NA(t,e){return Object.keys(t.B(e).C)}function y9(t){return ry(ns(t))}function ry(t){if((t=t.toLowerCase())!==vi&&t!==hy&&Ug(t)!==Ug(T1(t).resolvedOptions().calendar))throw new RangeError(I7(t));return t}function Ug(t){return t==="islamicc"&&(t="islamic"),t.split("-")[0]}function oC(t){return this.R(t)[0]}function aC(t){return this.R(t)[1]}function Qx(t){const[e]=this.h(t);return ty(this.q(e),Gs(t))+1}function lC(t){const e=MW.exec(t);if(!e)throw new RangeError(S7(t));return[parseInt(e[1]),!!e[2]]}function Vg(t,e,i){return t+(e||i&&t>=i?1:0)}function mv(t,e){return t-(e&&t>=e?1:0)}function cC(t,e){return(e+t)*(Math.sign(e)||1)||0}function yv(t){return BC[uC(t)]}function hC(t){return $7[uC(t)]}function uC(t){return Ug(t.id||vi)}function b9(t,e,i,r){const o=Rl(i,r,Vo,[],DC);if(o.timeZone!==void 0){const h=i.dateFromFields(o),d=$c(o),c=t(o.timeZone);return{epochNanoseconds:Vc(e(c),{...h,...d},o.offset!==void 0?Mu(o.offset):void 0),timeZone:c}}return{...i.dateFromFields(o),...Lo}}function v9(t,e,i,r,o,h){const d=Rl(i,o,Vo,MC,DC),c=t(d.timeZone),[x,S,P]=jm(h),M=i.dateFromFields(d,Wm(h,x)),D=$c(d,x);return Qs(Vc(e(c),{...M,...D},d.offset!==void 0?Mu(d.offset):void 0,S,P),c,r)}function x9(t,e,i){const r=Rl(t,e,Vo,[],Ml),o=Ki(i);return vs(Sa({...t.dateFromFields(r,Wm(i,o)),...$c(r,o)}))}function dC(t,e,i,r=[]){const o=Rl(t,e,Vo,r);return t.dateFromFields(o,i)}function fC(t,e,i,r){const o=Rl(t,e,a1,r);return t.yearMonthFromFields(o,i)}function pC(t,e,i,r,o=[]){const h=Rl(t,i,Vo,o);return e&&h.month!==void 0&&h.monthCode===void 0&&h.year===void 0&&(h.year=xu),t.monthDayFromFields(h,r)}function w9(t,e){const i=Ki(e);return Uo($c(Oo(t,vv,[],1),i))}function T9(t){const e=Oo(t,l1);return Jr(Ru({...Bs,...e}))}function Rl(t,e,i,r=[],o=[]){return Oo(e,[...t.fields(i),...o].sort(),r)}function Oo(t,e,i,r=!i){const o={};let h,d=0;for(const c of e){if(c===h)throw new RangeError(g7(c));if(c==="constructor"||c==="__proto__")throw new RangeError(TC(c));let x=t[c];if(x!==void 0)d=1,jA[c]&&(x=jA[c](x,c)),o[c]=x;else if(i){if(i.includes(c))throw new TypeError(r1(c));o[c]=NC[c]}h=c}if(r&&!d)throw new TypeError(SC(e));return o}function $c(t,e){return Vm(FW({...NC,...t}),e)}function S9(t,e,i,r,o,h){const d=Ts(h),{calendar:c,timeZone:x}=i;return Qs(((S,P,M,D,H)=>{const Q=np(S,M,D,Vo,kC,CC),[G,_e,ve]=jm(H,2);return Vc(P,{...S.dateFromFields(Q,Wm(H,G)),...$c(Q,G)},Mu(Q.offset),_e,ve)})(t(c),e(x),r,o,d),x,c)}function E9(t,e,i,r,o){const h=Ts(o);return vs(((d,c,x,S)=>{const P=np(d,c,x,Vo,Ml),M=Ki(S);return Sa({...d.dateFromFields(P,Wm(S,M)),...$c(P,M)})})(t(e.calendar),i,r,h))}function A9(t,e,i,r,o){const h=Ts(o);return((d,c,x,S)=>{const P=np(d,c,x,Vo);return d.dateFromFields(P,S)})(t(e.calendar),i,r,h)}function I9(t,e,i,r,o){const h=Ts(o);return Cc(((d,c,x,S)=>{const P=np(d,c,x,a1);return d.yearMonthFromFields(P,S)})(t(e.calendar),i,r,h))}function P9(t,e,i,r,o){const h=Ts(o);return((d,c,x,S)=>{const P=np(d,c,x,Vo);return d.monthDayFromFields(P,S)})(t(e.calendar),i,r,h)}function R9(t,e,i){return Uo(((r,o,h)=>{const d=Ki(h);return $c({...Un(vv,r),...Oo(o,vv)},d)})(t,e,i))}function C9(t,e){return Jr((i=t,r=e,Ru({...i,...Oo(r,l1)})));var i,r}function np(t,e,i,r,o=[],h=[]){const d=[...t.fields(r),...o].sort();let c=Oo(e,d,h);const x=Oo(i,d);return c=t.mergeFields(c,x),Oo(c,d,[])}function e1(t,e){const i=Rl(t,e,FC);return t.monthDayFromFields(i)}function t1(t,e,i){const r=Rl(t,e,OC);return t.yearMonthFromFields(r,i)}function _C(t,e,i,r,o){e=Un(i=t.fields(i),e),r=Oo(r,o=t.fields(o),[]);let h=t.mergeFields(e,r);return h=Oo(h,[...i,...o].sort(),[]),t.dateFromFields(h)}function cb(t,e){let{era:i,eraYear:r,year:o}=e;const h=yv(t);if(i!==void 0||r!==void 0){if(i===void 0||r===void 0)throw new TypeError(v7);if(!h)throw new RangeError(b7);const d=h[i];if(d===void 0)throw new RangeError(w7(i));const c=cC(r,d);if(o!==void 0&&o!==c)throw new RangeError(x7);o=c}else if(o===void 0)throw new TypeError(T7(h));return o}function hb(t,e,i,r){let{month:o,monthCode:h}=e;if(h!==void 0){const d=((c,x,S,P)=>{const M=c.U(S),[D,H]=lC(x);let Q=Vg(D,H,M);if(H){const G=hC(c);if(G===void 0)throw new RangeError(of);if(G>0){if(Q>G)throw new RangeError(of);if(M===void 0){if(P===1)throw new RangeError(of);Q--}}else{if(Q!==-G)throw new RangeError(of);if(M===void 0&&P===1)throw new RangeError(of)}}return Q})(t,h,i,r);if(o!==void 0&&o!==d)throw new RangeError(AC);o=d,r=1}else if(o===void 0)throw new TypeError(E7);return Qn("month",o,1,t.L(i),r)}function BA(t,e,i,r,o){return bn(e,"day",1,t.j(r,i),o)}function ub(t,e,i,r){let o=0;const h=[];for(const d of i)e[d]!==void 0?o=1:h.push(d);if(Object.assign(t,e),o)for(const d of r||h)delete t[d]}function M9(t){return Ns(Vn(Bm(Nm(t))))}function k9(t,e,i,r,o=vi){return Qs(Vn(Bm(Nm(i))),e(r),t(o))}function D9(t,e,i,r,o=0,h=0,d=0,c=0,x=0,S=0,P=vi){return vs(Sa(Um(Bo(Ys,Su(uy,[e,i,r,o,h,d,c,x,S])))),t(P))}function O9(t,e,i,r,o=vi){return xs(_l(Lc(Bo(Ys,{isoYear:e,isoMonth:i,isoDay:r}))),t(o))}function F9(t,e,i,r=vi,o=1){const h=Ys(e),d=Ys(i),c=t(r);return Cc(bx(Lc({isoYear:h,isoMonth:d,isoDay:Ys(o)})),c)}function N9(t,e,i,r=vi,o=xu){const h=Ys(e),d=Ys(i),c=t(r);return Bg(_l(Lc({isoYear:Ys(o),isoMonth:h,isoDay:d})),c)}function B9(t=0,e=0,i=0,r=0,o=0,h=0){return Uo(Vm(Bo(Ys,Su(jo,[t,e,i,r,o,h])),1))}function z9(t=0,e=0,i=0,r=0,o=0,h=0,d=0,c=0,x=0,S=0){return Jr(Ru(Bo(uR,Su(tr,[t,e,i,r,o,h,d,c,x,S]))))}function zA(t,e,i=vi){return Qs(t.epochNanoseconds,e,i)}function L9(t){return Ns(t.epochNanoseconds)}function gC(t,e){return vs(An(e,t))}function mC(t,e){return xs(An(e,t))}function U9(t,e,i){return t1(t(e.calendar),i)}function V9(t,e,i){return e1(t(e.calendar),i)}function yC(t,e){return Uo(An(e,t))}function j9(t,e,i,r){const o=((h,d,c,x)=>{const S=TR(x);return Ln(h(d),c,S)})(t,i,e,r);return Qs(Vn(o),i,e.calendar)}function $9(t,e,i){const r=t(e.calendar);return Cc({...e,...t1(r,i)})}function W9(t,e,i){return e1(t(e.calendar),i)}function H9(t,e,i,r,o){const h=t(o.timeZone),d=o.plainTime,c=d!==void 0?e(d):Lo;return Qs(Ln(i(h),{...r,...c}),h,r.calendar)}function X9(t,e=Lo){return vs(Sa({...t,...e}))}function q9(t,e,i){return t1(t(e.calendar),i)}function Z9(t,e,i){return e1(t(e.calendar),i)}function Y9(t,e,i,r){return((o,h,d)=>_C(o,h,OC,Al(d),lp))(t(e.calendar),i,r)}function K9(t,e,i,r){return((o,h,d)=>_C(o,h,FC,Al(d),cy))(t(e.calendar),i,r)}function J9(t,e,i,r,o){const h=Al(o),d=e(h.plainDate),c=t(h.timeZone);return Qs(Ln(i(c),{...d,...r}),c,d.calendar)}function G9(t,e){return vs(Sa({...t,...e}))}function Q9(t){return Ns(Vn(jf(t,io)))}function e7(t){return Ns(Vn(jf(t,Ea)))}function t7(t){return Ns(Vn(Bm(Nm(t),Hc)))}function i7(t){return Ns(Vn(Bm(Nm(t))))}function r7(t,e,i=Lo){const r=e.timeZone,o=t(r),h={...An(e,o),...i};return Qs(Vc(o,h,h.offsetNanoseconds,2),r,e.calendar)}function s7(t,e,i){const r=e.timeZone,o=t(r),h={...An(e,o),...i},d=bC(e.calendar,i.calendar);return Qs(Vc(o,h,h.offsetNanoseconds,2),r,d)}function n7(t,e=Lo){return vs({...t,...e})}function o7(t,e){return vs({...t,...e},bC(t.calendar,e.calendar))}function i1(t,e){return{...t,calendar:e}}function a7(t,e){return{...t,timeZone:e}}function bC(t,e){if(t===e)return t;const i=en(t),r=en(e);if(i===r||i===vi)return e;if(r===vi)return t;throw new RangeError(s1)}function l7(t,e){return i=>i===vi?t:i===hy||i===vu?Object.assign(Object.create(t),{id:i}):Object.assign(Object.create(e),CW(i))}function Wc(t,e,i){const r=new Set(i);return o=>(((h,d)=>{for(const c of d)if(c in h)return 1;return 0})(o=iR(r,o),t)||Object.assign(o,e),i&&(o.timeZone=Xc,["full","long"].includes(o.timeStyle)&&(o.timeStyle="medium")),o)}function Cl(t,e=vC){const[i,,,r]=t;return(o,h=JW,...d)=>{const c=e(r&&r(...d),o,h,i),x=c.resolvedOptions();return[c,...c7(t,x,d)]}}function vC(t,e,i,r){if(i=r(i),t){if(i.timeZone!==void 0)throw new TypeError(U7);i.timeZone=t}return new Ec(e,i)}function c7(t,e,i){const[,r,o]=t;return i.map(h=>(h.calendar&&((d,c,x)=>{if((x||d!==vi)&&d!==c)throw new RangeError(s1)})(en(h.calendar),e.calendar,o),r(h,e)))}function nf(t){const e=ig();return zc(e,t.getOffsetNanosecondsFor(e))}function ig(){return jf(Date.now(),Ea)}function Qa(){return WA||(WA=new Ec().resolvedOptions().timeZone)}const h7=(t,e)=>`Non-integer ${t}: ${e}`,u7=(t,e)=>`Non-positive ${t}: ${e}`,d7=(t,e)=>`Non-finite ${t}: ${e}`,f7=t=>`Cannot convert bigint to ${t}`,p7=t=>`Invalid bigint: ${t}`,_7="Cannot convert Symbol to string",xC="Invalid object",wC=(t,e,i,r,o)=>o?wC(t,o[e],o[i],o[r]):op(t,e)+`; must be between ${i}-${r}`,op=(t,e)=>`Invalid ${t}: ${e}`,r1=t=>`Missing ${t}`,TC=t=>`Invalid field ${t}`,g7=t=>`Duplicate field ${t}`,SC=t=>"No valid fields: "+t.join(),m7="Invalid bag",EC=(t,e,i)=>op(t,e)+"; must be "+Object.keys(i).join(),y7="Cannot use valueOf",LA="Invalid calling context",b7="Forbidden era/eraYear",v7="Mismatching era/eraYear",x7="Mismatching year/eraYear",w7=t=>`Invalid era: ${t}`,T7=t=>"Missing year"+(t?"/era/eraYear":""),S7=t=>`Invalid monthCode: ${t}`,AC="Mismatching month/monthCode",E7="Missing month/monthCode",UA="Cannot guess year",of="Invalid leap month",A7="Invalid protocol",ap="Invalid protocol results",s1="Mismatching Calendars",I7=t=>`Invalid Calendar: ${t}`,IC="Mismatching TimeZones",P7="Forbidden ICU TimeZone",R7="Out-of-bounds offset",C7="Out-of-bounds TimeZone gap",M7="Invalid TimeZone offset",k7="Ambiguous offset",sy="Out-of-bounds date",D7="Out-of-bounds duration",O7="Cannot mix duration signs",ny="Missing relativeTo",F7="Cannot use large units",N7="Required smallestUnit or largestUnit",B7="smallestUnit > largestUnit",wn=t=>`Cannot parse: ${t}`,va=t=>`Invalid substring: ${t}`,z7=t=>`Cannot format ${t}`,L7="Mismatching types for formatting",U7="Cannot specify TimeZone",PC=gi(Mm,(t,e)=>e),Ou=gi(Mm,(t,e,i)=>i),to=gi(Og,2),bv={nanosecond:0,microsecond:1,millisecond:2,second:3,minute:4,hour:5,day:6,week:7,month:8,year:9},oy=Object.keys(bv),Tn=864e5,RC=1e3,Hc=1e3,Ea=1e6,io=1e9,ay=6e10,ly=36e11,gr=864e11,zo=[1,Hc,Ea,io,ay,ly,gr],Ml=oy.slice(0,6),vv=rp(Ml),CC=["offset"],MC=["timeZone"],kC=Ml.concat(CC),DC=kC.concat(MC),xv=["era","eraYear"],V7=xv.concat(["year"]),cy=["year"],n1=["monthCode"],o1=["month"].concat(n1),lp=["day"],a1=o1.concat(cy),OC=n1.concat(cy),Vo=lp.concat(a1),j7=lp.concat(o1),FC=lp.concat(n1),NC=Ou(Ml,0),vi="iso8601",hy="gregory",vu="japanese",BC={[hy]:{bce:-1,ce:0},[vu]:{bce:-1,ce:0,meiji:1867,taisho:1911,showa:1925,heisei:1988,reiwa:2018},ethioaa:{era0:0},ethiopic:{era0:0,era1:5500},coptic:{era0:-1,era1:0},roc:{beforeroc:-1,minguo:0},buddhist:{be:0},islamic:{ah:0},indian:{saka:0},persian:{ap:0}},$7={chinese:13,dangi:13,hebrew:-6},ns=gi(Fm,"string"),W7=gi(Fm,"boolean"),H7=gi(Fm,"number"),X7=gi(Fm,"function"),tr=oy.map(t=>t+"s"),l1=rp(tr),q7=tr.slice(0,6),zC=tr.slice(6),Z7=zC.slice(1),Y7=PC(tr),Bs=Ou(tr,0),c1=Ou(q7,0),h1=gi(sR,tr),jo=["isoNanosecond","isoMicrosecond","isoMillisecond","isoSecond","isoMinute","isoHour"],u1=["isoDay","isoMonth","isoYear"],uy=jo.concat(u1),d1=rp(u1),LC=rp(jo),UC=rp(uy),Lo=Ou(LC,0),K7=gi(sR,uy),Ec=Intl.DateTimeFormat,VC="en-GB",f1=1e8,J7=f1*Tn,G7=[f1,0],Q7=[-f1,0],Xf=275760,qf=-271821,eW=1970,xu=1972,fa=12,tW=Eu(1868,9,8),iW=zn(E$,WeakMap),jg="smallestUnit",wv="unit",Tf="roundingIncrement",db="fractionalSecondDigits",jC="relativeTo",$C={constrain:0,reject:1},rW=Object.keys($C),sW={compatible:0,reject:1,earlier:2,later:3},nW={reject:0,use:1,prefer:2,ignore:3},oW={auto:0,never:1,critical:2,always:3},aW={auto:0,never:1,critical:2},lW={auto:0,never:1},cW={floor:0,halfFloor:1,ceil:2,halfCeil:3,trunc:4,halfTrunc:5,expand:6,halfExpand:7,halfEven:8},cp=gi(Px,jg),p1=gi(Px,"largestUnit"),hW=gi(Px,wv),WC=gi(Uc,"overflow",$C),HC=gi(Uc,"disambiguation",sW),uW=gi(Uc,"offset",nW),_1=gi(Uc,"calendarName",oW),dW=gi(Uc,"timeZoneName",aW),fW=gi(Uc,"offset",lW),hp=gi(Uc,"roundingMode",cW),Zf="PlainYearMonth",Yf="PlainMonthDay",Fu="PlainDate",Nu="PlainDateTime",g1="PlainTime",kl="ZonedDateTime",m1="Instant",y1="Duration",pW=[Math.floor,t=>$_(t)?Math.floor(t):Math.round(t),Math.ceil,t=>$_(t)?Math.ceil(t):Math.round(t),Math.trunc,t=>$_(t)?Math.trunc(t)||0:Math.round(t),t=>t<0?Math.floor(t):Math.ceil(t),t=>Math.sign(t)*Math.round(Math.abs(t))||0,t=>$_(t)?(t=Math.trunc(t)||0)+t%2:Math.round(t)],Xc="UTC",rg=5184e3,_W=Ng(1847),gW=Ng(new Date().getUTCFullYear()+10),mW=/0+$/,An=zn(j$,WeakMap),VA=2**32-1,b1=zn(t=>{const e=Yx(t);return typeof e=="object"?new bW(e):new yW(e||0)});class yW{constructor(e){this.v=e}getOffsetNanosecondsFor(){return this.v}getPossibleInstantsFor(e){return[vx(e,this.v)]}l(){}}class bW{constructor(e){this.$=(i=>{function r(S){const P=_v(S,c,x),[M,D]=IA(P),H=h(M),Q=h(D);return H===Q?H:o(d(M,D),H,Q,S)}function o(S,P,M,D){let H,Q;for(;(D===void 0||(H=D=S[1]?M:void 0)===void 0)&&(Q=S[1]-S[0]);){const G=S[0]+Math.floor(Q/2);i(G)===M?S[1]=G:S[0]=G+1}return H}const h=zn(i),d=zn(q$);let c=_W,x=gW;return{G(S){const P=r(S-86400),M=r(S+86400),D=S-P,H=S-M;if(P===M)return[D];const Q=r(D);return Q===r(H)?[S-Q]:P>M?[D,H]:[]},V:r,l(S,P){const M=_v(S,c,x);let[D,H]=IA(M);const Q=rg*P,G=P<0?()=>H>c||(c=M,0):()=>Dr=>{const o=yx(i,r*RC);return Ng(nC(o),parseInt(o.month),parseInt(o.day),parseInt(o.hour),parseInt(o.minute),parseInt(o.second))-r})(e))}getOffsetNanosecondsFor(e){return this.$.V(pR(e))*io}getPossibleInstantsFor(e){const[i,r]=[Ng((o=e).isoYear,o.isoMonth,o.isoDay,o.isoHour,o.isoMinute,o.isoSecond),o.isoMillisecond*Ea+o.isoMicrosecond*Hc+o.isoNanosecond];var o;return this.$.G(i).map(h=>Vn(bu(jf(h,io),r)))}l(e,i){const[r,o]=_R(e),h=this.$.l(r+(i>0||o?1:0),i);if(h!==void 0)return jf(h,io)}}const v1="([+−-])",sg="(?:[.,](\\d{1,9}))?",XC=`(?:(?:${v1}(\\d{6}))|(\\d{4}))-?(\\d{2})`,x1="(\\d{2})(?::?(\\d{2})(?::?(\\d{2})"+sg+")?)?",w1=v1+x1,vW=XC+"-?(\\d{2})(?:[T ]"+x1+"(Z|"+w1+")?)?",qC="\\[(!?)([^\\]]*)\\]",dy=`((?:${qC}){0,9})`,xW=ku(XC+dy),wW=ku("(?:--)?(\\d{2})-?(\\d{2})"+dy),TW=ku(vW+dy),SW=ku("T?"+x1+"(?:"+w1+")?"+dy),EW=ku(w1),AW=new RegExp(qC,"g"),IW=ku(`${v1}?P(\\d+Y)?(\\d+M)?(\\d+W)?(\\d+D)?(?:T(?:(\\d+)${sg}H)?(?:(\\d+)${sg}M)?(?:(\\d+)${sg}S)?)?`),PW=zn(t=>new Ec(VC,{timeZone:t,era:"short",year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric"})),RW=/^(AC|AE|AG|AR|AS|BE|BS|CA|CN|CS|CT|EA|EC|IE|IS|JS|MI|NE|NS|PL|PN|PR|PS|SS|VS)T$/,CW=zn(_9),T1=zn(t=>new Ec(VC,{calendar:t,timeZone:Xc,era:"short",year:"numeric",month:"short",day:"numeric"})),MW=/^M(\d{2})(L?)$/,kW={era:Fg,eraYear:Ys,year:Ys,month:cA,monthCode:Fg,day:cA},DW=Ou(Ml,Ys),OW=Ou(tr,uR),jA=Object.assign({},kW,DW,OW,{offset:Fg}),FW=gi(y$,Ml,jo),$A={dateAdd(t,e,i){const r=Ki(i);let o,{years:h,months:d,weeks:c,days:x}=e;if(x+=ws(e,5)[0],h||d)o=((S,P,M,D,H)=>{let[Q,G,_e]=S.h(P);if(M){const[ve,be]=S.I(Q,G);Q+=M,G=Vg(ve,be,S.U(Q)),G=Qn("month",G,1,S.L(Q),H)}return D&&([Q,G]=S._(Q,G,D)),_e=Qn("day",_e,1,S.j(Q,G),H),S.q(Q,G,_e)})(this,t,h,d,r);else{if(!c&&!x)return t;o=Gs(t)}return o+=(7*c+x)*Tn,_l(Lm(o))},dateUntil(t,e,i){if(i<=7){let x=0,S=rC({...t,...Lo},{...e,...Lo});return i===7&&([x,S]=bl(S,7)),{...Bs,weeks:x,days:S}}const r=this.h(t),o=this.h(e);let[h,d,c]=((x,S,P,M,D,H,Q)=>{let G=D-S,_e=H-P,ve=Q-M;if(G||_e){const be=Math.sign(G||_e);let Se=x.j(D,H),Be=0;if(Math.sign(ve)===-be){const je=Se;[D,H]=x._(D,H,-be),G=D-S,_e=H-P,Se=x.j(D,H),Be=be<0?-je:Se}if(ve=Q-Math.min(M,Se)+Be,G){const[je,Fe]=x.I(S,P),[rt,vt]=x.I(D,H);if(_e=rt-je||Number(vt)-Number(Fe),Math.sign(_e)===-be){const lt=be<0&&-x.L(D);G=(D-=be)-S,_e=H-Vg(je,Fe,x.U(D))+(lt||x.L(D))}}}return[G,_e,ve]})(this,...r,...o);return i===8&&(d+=this.J(h,r[0]),h=0),{...Bs,years:h,months:d,days:c}},dateFromFields(t,e){const i=Ki(e),r=cb(this,t),o=hb(this,t,r,i),h=BA(this,t,o,r,i);return xs(_l(this.P(r,o,h)),this.id||vi)},yearMonthFromFields(t,e){const i=Ki(e),r=cb(this,t),o=hb(this,t,r,i);return Cc(bx(this.P(r,o,1)),this.id||vi)},monthDayFromFields(t,e){const i=Ki(e),r=!this.id,{monthCode:o,year:h,month:d}=t;let c,x,S,P,M;if(o!==void 0){[c,x]=lC(o),M=tR(t,"day");const D=this.N(c,x,M);if(!D)throw new RangeError(UA);if([S,P]=D,d!==void 0&&d!==P)throw new RangeError(AC);r&&(P=Qn("month",P,1,fa,1),M=Qn("day",M,1,xx(h!==void 0?h:S,P),i))}else{S=h===void 0&&r?xu:cb(this,t),P=hb(this,t,S,i),M=BA(this,t,P,S,i);const D=this.U(S);x=P===D,c=mv(P,D);const H=this.N(c,x,M);if(!H)throw new RangeError(UA);[S,P]=H}return Bg(_l(this.P(S,P,M)),this.id||vi)},fields(t){return yv(this)&&t.includes("year")?[...t,...xv]:t},mergeFields(t,e){const i=Object.assign(Object.create(null),t);return ub(i,e,o1),yv(this)&&(ub(i,e,V7),this.id===vu&&ub(i,e,j7,xv)),i},inLeapYear(t){const[e]=this.h(t);return this.K(e)},monthsInYear(t){const[e]=this.h(t);return this.L(e)},daysInMonth(t){const[e,i]=this.h(t);return this.j(e,i)},daysInYear(t){const[e]=this.h(t);return this.X(e)},dayOfYear:Qx,era(t){return this.ee(t)[0]},eraYear(t){return this.ee(t)[1]},monthCode(t){const[e,i]=this.h(t),[r,o]=this.I(e,i);return((h,d)=>"M"+to(h)+(d?"L":""))(r,o)},dayOfWeek:vR,daysInWeek(){return 7}},NW={dayOfYear:Qx,h:mR,q:Eu},BW=Object.assign({},NW,{weekOfYear:oC,yearOfWeek:aC,R(t){function e(H){return(7-Hi(0)&&(M=1,D++):(M=i(-1),D--),[M,D,P]}}),zW={dayOfYear:Qx,h:gv,q:Hf,weekOfYear:oC,yearOfWeek:aC,R(){return[]}},up=l7(Object.assign({},$A,BW,{h:mR,ee(t){return this.id===hy?xR(t):this.id===vu?iW(t):[]},I:(t,e)=>[e,0],N(t,e){if(!e)return[xu,t]},K:wx,U(){},L:yR,J:t=>t*fa,j:xx,X:bR,P:(t,e,i)=>({isoYear:t,isoMonth:e,isoDay:i}),q:Eu,_:(t,e,i)=>(t+=km(i,fa),(e+=px(i,fa))<1?(t--,e+=fa):e>fa&&(t++,e-=fa),[t,e]),year(t){return t.isoYear},month(t){return t.isoMonth},day:t=>t.isoDay}),Object.assign({},$A,zW,{h:gv,ee(t){const e=this.O(t);return[e.era,e.eraYear]},I(t,e){const i=W_.call(this,t);return[mv(e,i),i===e]},N(t,e,i){let[r,o,h]=gv.call(this,{isoYear:xu,isoMonth:fa,isoDay:31});const d=W_.call(this,r),c=o===d;(pl(t,mv(o,d))||pl(Number(e),Number(c))||pl(i,h))===1&&r--;for(let x=0;x<100;x++){const S=r-x,P=W_.call(this,S),M=Vg(t,e,P);if(e===(M===P)&&i<=FA.call(this,S,M))return[S,M]}},K(t){const e=H_.call(this,t);return e>H_.call(this,t-1)&&e>H_.call(this,t+1)},U:W_,L:X_,J(t,e){const i=e+t,r=Math.sign(t),o=r<0?-1:0;let h=0;for(let d=e;d!==i;d+=r)h+=X_.call(this,d+o);return h},j:FA,X:H_,P(t,e,i){return Lm(Hf.call(this,t,e,i))},q:Hf,_(t,e,i){if(i){if(e+=i,!Number.isSafeInteger(e))throw new RangeError(sy);if(i<0)for(;e<1;)e+=X_.call(this,--t);else{let r;for(;e>(r=X_.call(this,t));)e-=r,t++}}return[t,e]},year(t){return this.O(t).year},month(t){const{year:e,F:i}=this.O(t),{C:r}=this.B(e);return r[i]+1},day(t){return this.O(t).day}})),gl="numeric",Bu=["timeZoneName"],ZC={month:gl,day:gl},S1={year:gl,month:gl},E1=Object.assign({},S1,{day:gl}),A1={hour:gl,minute:gl,second:gl},I1=Object.assign({},E1,A1),LW=Object.assign({},I1,{timeZoneName:"short"}),UW=Object.keys(S1),VW=Object.keys(ZC),jW=Object.keys(E1),$W=Object.keys(A1),P1=["dateStyle"],WW=UW.concat(P1),HW=VW.concat(P1),R1=jW.concat(P1,["weekday"]),dp=$W.concat(["dayPeriod","timeStyle"]),C1=R1.concat(dp),XW=C1.concat(Bu),qW=Bu.concat(dp),ZW=Bu.concat(R1),YW=Bu.concat(["day","weekday"],dp),KW=Bu.concat(["year","weekday"],dp),JW={},YC=[Wc(C1,I1),Rx],GW=[Wc(XW,LW),Rx,0,(t,e)=>{const i=en(t.timeZone);if(e&&en(e.timeZone)!==i)throw new RangeError(IC);return i}],KC=[Wc(C1,I1,Bu),Gs],JC=[Wc(R1,E1,qW),Gs],GC=[Wc(dp,A1,ZW),t=>vl(t)/Ea],QC=[Wc(WW,S1,YW),Gs,1],eM=[Wc(HW,ZC,KW),Gs,1];let WA;function $o(t,e,i,r,o){function h(...x){if(!(this instanceof h))throw new TypeError(LA);ZA(this,e(...x))}function d(x,S){return Object.defineProperties(function(...P){return x.call(this,c(this),...P)},nA(S))}function c(x){const S=Ls(x);if(!S||S.branding!==t)throw new TypeError(LA);return S}return Object.defineProperties(h.prototype,{...m$(Bo(d,i)),...mu(Bo(d,r)),...fx("Temporal."+t)}),Object.defineProperties(h,{...mu(o),...nA(t)}),[h,x=>{const S=Object.create(h.prototype);return ZA(S,x),S},c]}function tM(t){return t=t.concat("id").sort(),e=>{if(!b$(e,t))throw new TypeError(A7);return e}}function zu(t){if(Ls(t)||t.calendar!==void 0||t.timeZone!==void 0)throw new TypeError(m7);return t}function q_(t,e){const i={};for(const r in t)i[r]=({o},h)=>{const d=Ls(h)||{},{branding:c}=d,x=c===Fu||e.includes(c)?d:Zs(h);return o[r](x)};return i}function M1(t){const e={};for(const i in t)e[i]=r=>{const{calendar:o}=r;return(h=o,typeof h=="string"?up(h):(d=h,Object.assign(Object.create(pH),{i:d})))[i](r);var h,d};return e}function Dl(){throw new TypeError(y7)}function fp({calendar:t}){return typeof t=="string"?new U1(t):t}function HA(t,e){if(e=Ts(e),zs(t)){const r=Ls(t);if(r&&r.branding===Yf)return Ki(e),r;const o=sM(t);return pC(my(o||vi),!o,t,e)}const i=Q$(up,t);return Ki(e),i}function iM(t,e,i){return r=e.call(t,Xs(Ns(i))),LR(Om(r));var r}function ng(t,e=lM){const i=Object.keys(e).sort(),r={};for(const o of i)r[o]=gi(e[o],t,X7(t[o]));return r}function xr(t,e){return typeof t=="string"?b1(t):ng(t,e)}function ss(t){return xr(t,Sv)}function Io(t){if(zs(t)){const e=Ls(t);if(e)switch(e.branding){case m1:return e;case kl:return Ns(e.epochNanoseconds)}}return Z$(t)}function XA(t,e,i){const r=e.l(Io(i).epochNanoseconds,t);return r?Xs(Ns(r)):null}function Cr(t){return zs(t)?(Ls(t)||{}).timeZone||vH(t):(e=>Zx(r9(ns(e))))(t)}function rl(t,e){if(zs(t)){const i=Ls(t)||{};switch(i.branding){case g1:return Ki(e),i;case Nu:return Ki(e),Uo(i);case kl:return Ki(e),yC(ss,i)}return w9(t,e)}return Ki(e),e9(t)}function k1(t){return t===void 0?void 0:rl(t)}function Uh(t,e){if(e=Ts(e),zs(t)){const r=Ls(t);return r&&r.branding===Zf?(Ki(e),r):fC(_y(pp(t)),t,e)}const i=G$(up,t);return Ki(e),i}function sl(t,e){if(e=Ts(e),zs(t)){const r=Ls(t)||{};switch(r.branding){case Nu:return Ki(e),r;case Fu:return Ki(e),vs({...r,...Lo});case kl:return Ki(e),gC(ss,r)}return x9(gy(pp(t)),t,e)}const i=J$(t);return Ki(e),i}function Zs(t,e){if(e=Ts(e),zs(t)){const r=Ls(t)||{};switch(r.branding){case Fu:return Ki(e),r;case Nu:return Ki(e),xs(r);case kl:return Ki(e),mC(ss,r)}return dC(gy(pp(t)),t,e)}const i=Vx(t);return Ki(e),i}function rM(t,e,i){return ko(e.call(t,Kr(xs(i,t))))}function Wo(t){return e=>typeof e=="string"?up(e):((i,r)=>{const o=Object.keys(r).sort(),h={};for(const d of o)h[d]=gi(r[d],i,i[d]);return h})(e,t)}function Yr(t){if(zs(t)){const e=Ls(t);return e&&e.branding===y1?e:T9(t)}return t9(t)}function af(t){if(t!==void 0){if(zs(t)){const e=Ls(t)||{};switch(e.branding){case kl:case Fu:return e;case Nu:return xs(e)}const i=pp(t);return{...b9(Cr,xr,gy(i),t),calendar:i}}return Y$(t)}}function pp(t){return sM(t)||vi}function sM(t){const{calendar:e}=t;if(e!==void 0)return Fs(e)}function Fs(t){return zs(t)?(Ls(t)||{}).calendar||FH(t):(e=>ry(i9(ns(e))))(t)}function Vh(t,e){if(e=Ts(e),zs(t)){const i=Ls(t);if(i&&i.branding===kl)return jm(e),i;const r=pp(t);return v9(Cr,xr,gy(r),r,t,e)}return K$(t,e)}function qA(t){return Bo(e=>i=>e(Tv(i)),t)}function Tv(t){return An(t,ss)}function QW(){const t=Ec.prototype,e=Object.getOwnPropertyDescriptors(t),i=Object.getOwnPropertyDescriptors(Ec),r=function(o,h={}){if(!(this instanceof r))return new r(o,h);V1.set(this,((d,c={})=>{const x=new Ec(d,c),S=x.resolvedOptions(),P=S.locale,M=Un(Object.keys(c),S),D=zn(iH),H=(...Q)=>{let G;const _e=Q.map((ve,be)=>{const Se=Ls(ve),Be=(Se||{}).branding;if(be&&G&&G!==Be)throw new TypeError(L7);return G=Be,Se});return G?D(G)(P,M,..._e):[x,...Q]};return H.u=x,H})(o,h))};for(const o in e){const h=e[o],d=o.startsWith("format")&&eH(o);typeof h.value=="function"?h.value=o==="constructor"?r:d||tH(o):d&&(h.get=function(){return d.bind(this)})}return i.prototype.value=Object.create(t,e),Object.defineProperties(r,i),r}function eH(t){return function(...e){const i=V1.get(this),[r,...o]=i(...e);return r[t](...o)}}function tH(t){return function(...e){return V1.get(this).u[t](...e)}}function iH(t){const e=rH[t];if(!e)throw new TypeError(z7(t));return Cl(e,zn(vC))}const rH={Instant:YC,PlainDateTime:KC,PlainDate:JC,PlainTime:GC,PlainYearMonth:QC,PlainMonthDay:eM},sH=Cl(YC),nH=Cl(GW),oH=Cl(KC),aH=Cl(JC),lH=Cl(GC),cH=Cl(QC),hH=Cl(eM),D1={era:T$,eraYear:oR,year:Om,month:ko,daysInMonth:ko,daysInYear:ko,inLeapYear:W7,monthsInYear:ko},fy={monthCode:ns},O1={day:ko},nM={dayOfWeek:ko,dayOfYear:ko,weekOfYear:S$,yearOfWeek:oR,daysInWeek:ko},oM=Object.assign({},D1,fy,O1,nM),$g=new WeakMap,Ls=$g.get.bind($g),ZA=$g.set.bind($g),uH={...q_(D1,[Zf]),...q_(nM,[]),...q_(fy,[Zf,Yf]),...q_(O1,[Yf])},F1=M1(oM),dH=M1({...D1,...fy}),fH=M1({...fy,...O1}),_p={calendarId:t=>en(t.calendar)},pH=Bo((t,e)=>function(i){const{i:r}=this;return t(r[e](Kr(xs(i,r))))},oM),_H=Mm(t=>e=>e[t],tr.concat("sign")),N1=Mm((t,e)=>i=>i[jo[e]],Ml),aM={epochSeconds:I$,epochMilliseconds:Rx,epochMicroseconds:P$,epochNanoseconds:R$},gp=gi(iR,new Set(["branding"])),[gH,wu,mH]=$o(Yf,gi(N9,Fs),{..._p,...fH},{getISOFields:gp,getCalendar:fp,with(t,e,i){return wu(P9(kH,t,this,zu(e),i))},equals:(t,e)=>u9(t,HA(e)),toPlainDate(t,e){return Kr(K9(mp,t,this,e))},toLocaleString(t,e,i){const[r,o]=hH(e,i,t);return r.format(o)},toString:mA,toJSON:t=>mA(t),valueOf:Dl},{from:(t,e)=>wu(HA(t,e))}),lM={getOffsetNanosecondsFor:iM,getPossibleInstantsFor(t,e,i){const r=[...e.call(t,Ds(vs(i,vi)))].map(h=>bH(h).epochNanoseconds),o=r.length;return o>1&&(r.sort(En),UR(no(so(r[0],r[o-1])))),r}},Sv={getOffsetNanosecondsFor:iM},[yH,Xs,bH]=$o(m1,M9,aM,{add:(t,e)=>Xs(vA(0,t,Yr(e))),subtract:(t,e)=>Xs(vA(1,t,Yr(e))),until:(t,e,i)=>wr(RA(0,t,Io(e),i)),since:(t,e,i)=>wr(RA(1,t,Io(e),i)),round:(t,e)=>Xs(M$(t,e)),equals:(t,e)=>o9(t,Io(e)),toZonedDateTime(t,e){const i=Al(e);return rs(zA(t,Cr(i.timeZone),Fs(i.calendar)))},toZonedDateTimeISO:(t,e)=>rs(zA(t,Cr(e))),toLocaleString(t,e,i){const[r,o]=sH(e,i,t);return r.format(o)},toString:(t,e)=>dA(Cr,ss,t,e),toJSON:t=>dA(Cr,ss,t),valueOf:Dl},{from:t=>Xs(Io(t)),fromEpochSeconds:t=>Xs(Q9(t)),fromEpochMilliseconds:t=>Xs(e7(t)),fromEpochMicroseconds:t=>Xs(t7(t)),fromEpochNanoseconds:t=>Xs(i7(t)),compare:(t,e)=>KR(Io(t),Io(e))}),[py,nX]=$o("TimeZone",t=>{const e=s9(t);return{branding:"TimeZone",id:e,o:b1(e)}},{id:t=>t.id},{getPossibleInstantsFor:({o:t},e)=>t.getPossibleInstantsFor(sl(e)).map(i=>Xs(Ns(i))),getOffsetNanosecondsFor:({o:t},e)=>t.getOffsetNanosecondsFor(Io(e).epochNanoseconds),getOffsetStringFor(t,e){const i=Io(e).epochNanoseconds,r=ng(this,Sv).getOffsetNanosecondsFor(i);return Pu(r)},getPlainDateTimeFor(t,e,i=vi){const r=Io(e).epochNanoseconds,o=ng(this,Sv).getOffsetNanosecondsFor(r);return Ds(vs(zc(r,o),Fs(i)))},getInstantFor(t,e,i){const r=sl(e),o=TR(i),h=ng(this);return Xs(Ns(Ln(h,r,o)))},getNextTransition:({o:t},e)=>XA(1,t,e),getPreviousTransition:({o:t},e)=>XA(-1,t,e),equals(t,e){return!!Jx(this,Cr(e))},toString:t=>t.id,toJSON:t=>t.id},{from(t){const e=Cr(t);return typeof e=="string"?new py(e):e}}),vH=tM(Object.keys(lM)),[xH,ol]=$o(g1,B9,N1,{getISOFields:gp,with(t,e,i){return ol(R9(this,zu(e),i))},add:(t,e)=>ol(EA(0,t,Yr(e))),subtract:(t,e)=>ol(EA(1,t,Yr(e))),until:(t,e,i)=>wr(OA(0,t,rl(e),i)),since:(t,e,i)=>wr(OA(1,t,rl(e),i)),round:(t,e)=>ol(O$(t,e)),equals:(t,e)=>d9(t,rl(e)),toZonedDateTime:(t,e)=>rs(J9(Cr,Zs,xr,t,e)),toPlainDateTime:(t,e)=>Ds(G9(t,Zs(e))),toLocaleString(t,e,i){const[r,o]=lH(e,i,t);return r.format(o)},toString:yA,toJSON:t=>yA(t),valueOf:Dl},{from:(t,e)=>ol(rl(t,e)),compare:(t,e)=>Kx(rl(t),rl(e))}),[wH,hl,TH]=$o(Zf,gi(F9,Fs),{..._p,...dH},{getISOFields:gp,getCalendar:fp,with(t,e,i){return hl(I9(MH,t,this,zu(e),i))},add:(t,e,i)=>hl(SA(YA,0,t,Yr(e),i)),subtract:(t,e,i)=>hl(SA(YA,1,t,Yr(e),i)),until:(t,e,i)=>wr(DA(KA,0,t,Uh(e),i)),since:(t,e,i)=>wr(DA(KA,1,t,Uh(e),i)),equals:(t,e)=>h9(t,Uh(e)),toPlainDate(t,e){return Kr(Y9(mp,t,this,e))},toLocaleString(t,e,i){const[r,o]=cH(e,i,t);return r.format(o)},toString:gA,toJSON:t=>gA(t),valueOf:Dl},{from:(t,e)=>hl(Uh(t,e)),compare:(t,e)=>Du(Uh(t),Uh(e))}),[SH,Ds]=$o(Nu,gi(D9,Fs),{..._p,...F1,...N1},{getISOFields:gp,getCalendar:fp,with(t,e,i){return Ds(E9(mp,t,this,zu(e),i))},withCalendar:(t,e)=>Ds(i1(t,Fs(e))),withPlainDate:(t,e)=>Ds(o7(t,Zs(e))),withPlainTime:(t,e)=>Ds(n7(t,k1(e))),add:(t,e,i)=>Ds(wA(kc,0,t,Yr(e),i)),subtract:(t,e,i)=>Ds(wA(kc,1,t,Yr(e),i)),until:(t,e,i)=>wr(MA(Do,0,t,sl(e),i)),since:(t,e,i)=>wr(MA(Do,1,t,sl(e),i)),round:(t,e)=>Ds(D$(t,e)),equals:(t,e)=>l9(t,sl(e)),toZonedDateTime:(t,e,i)=>rs(j9(xr,t,Cr(e),i)),toPlainDate:t=>Kr(xs(t)),toPlainTime:t=>ol(Uo(t)),toPlainYearMonth(t){return hl($9(_y,t,this))},toPlainMonthDay(t){return wu(W9(my,t,this))},toLocaleString(t,e,i){const[r,o]=oH(e,i,t);return r.format(o)},toString:pA,toJSON:t=>pA(t),valueOf:Dl},{from:(t,e)=>Ds(sl(t,e)),compare:(t,e)=>GR(sl(t),sl(e))}),[EH,Kr,cM]=$o(Fu,gi(O9,Fs),{..._p,...F1},{getISOFields:gp,getCalendar:fp,with(t,e,i){return Kr(A9(mp,t,this,zu(e),i))},withCalendar:(t,e)=>Kr(i1(t,Fs(e))),add:(t,e,i)=>Kr(TA(kc,0,t,Yr(e),i)),subtract:(t,e,i)=>Kr(TA(kc,1,t,Yr(e),i)),until:(t,e,i)=>wr(kA(Do,0,t,Zs(e),i)),since:(t,e,i)=>wr(kA(Do,1,t,Zs(e),i)),equals:(t,e)=>c9(t,Zs(e)),toZonedDateTime(t,e){const i=!zs(e)||e instanceof py?{timeZone:e}:e;return rs(H9(Cr,rl,xr,t,i))},toPlainDateTime:(t,e)=>Ds(X9(t,k1(e))),toPlainYearMonth(t){return hl(q9(_y,t,this))},toPlainMonthDay(t){return wu(Z9(my,t,this))},toLocaleString(t,e,i){const[r,o]=aH(e,i,t);return r.format(o)},toString:_A,toJSON:t=>_A(t),valueOf:Dl},{from:(t,e)=>Kr(Zs(t,e)),compare:(t,e)=>Du(Zs(t),Zs(e))}),B1={fields(t,e,i){return[...e.call(t,i)]}},hM=Object.assign({dateFromFields(t,e,i,r){return cM(e.call(t,Object.assign(Object.create(null),i),r))}},B1),uM=Object.assign({yearMonthFromFields(t,e,i,r){return TH(e.call(t,Object.assign(Object.create(null),i),r))}},B1),dM=Object.assign({monthDayFromFields(t,e,i,r){return mH(e.call(t,Object.assign(Object.create(null),i),r))}},B1),z1={mergeFields(t,e,i,r){return Al(e.call(t,Object.assign(Object.create(null),i),Object.assign(Object.create(null),r)))}},AH=Object.assign({},hM,z1),IH=Object.assign({},uM,z1),PH=Object.assign({},dM,z1),L1={dateAdd(t,e,i,r,o){return cM(e.call(t,Kr(xs(i,t)),wr(Jr(r)),o))}},fM=Object.assign({},L1,{dateUntil(t,e,i,r,o,h){return OH(e.call(t,Kr(xs(i,t)),Kr(xs(r,t)),Object.assign(Object.create(null),h,{largestUnit:oy[o]})))}}),RH=Object.assign({},L1,{day:rM}),CH=Object.assign({},fM,{day:rM}),_y=Wo(uM),gy=Wo(hM),my=Wo(dM),MH=Wo(IH),mp=Wo(AH),kH=Wo(PH),kc=Wo(L1),Do=Wo(fM),YA=Wo(RH),KA=Wo(CH),[DH,wr,OH]=$o(y1,z9,{..._H,blank:X$},{with:(t,e)=>wr(C9(t,e)),negated:t=>wr(Ux(t)),abs:t=>wr(H$(t)),add:(t,e,i)=>wr(AA(af,Do,xr,0,t,Yr(e),i)),subtract:(t,e,i)=>wr(AA(af,Do,xr,1,t,Yr(e),i)),round:(t,e)=>wr(W$(af,Do,xr,t,e)),total:(t,e)=>C$(af,Do,xr,t,e),toLocaleString(t,e,i){return Intl.DurationFormat?new Intl.DurationFormat(e,i).format(this):lb(t)},toString:lb,toJSON:t=>lb(t),valueOf:Dl},{from:t=>wr(Yr(t)),compare:(t,e,i)=>n9(af,kc,xr,Yr(t),Yr(e),i)}),pM={toString:t=>t.id,toJSON:t=>t.id,...uH,dateAdd:({id:t,o:e},i,r,o)=>Kr(xs(e.dateAdd(Zs(i),Yr(r),o),t)),dateUntil:({o:t},e,i,r)=>wr(Jr(t.dateUntil(Zs(e),Zs(i),A$(r)))),dateFromFields:({id:t,o:e},i,r)=>Kr(dC(e,i,r,w$(t))),yearMonthFromFields:({id:t,o:e},i,r)=>hl(fC(e,i,r,v$(t))),monthDayFromFields:({id:t,o:e},i,r)=>wu(pC(e,0,i,r,x$(t))),fields({o:t},e){const i=new Set(Vo),r=[];for(const o of e){if(ns(o),!i.has(o))throw new RangeError(TC(o));i.delete(o),r.push(o)}return t.fields(r)},mergeFields:({o:t},e,i)=>t.mergeFields(oA(lA(e)),oA(lA(i)))},[U1]=$o("Calendar",t=>{const e=y9(t);return{branding:"Calendar",id:e,o:up(e)}},{id:t=>t.id},pM,{from(t){const e=Fs(t);return typeof e=="string"?new U1(e):e}}),FH=tM(Object.keys(pM).slice(4)),[NH,rs]=$o(kl,gi(k9,Fs,Cr),{...aM,..._p,...qA(F1),...qA(N1),offset:t=>Pu(Tv(t).offsetNanoseconds),offsetNanoseconds:t=>Tv(t).offsetNanoseconds,timeZoneId:t=>en(t.timeZone),hoursInDay:t=>F$(xr,t)},{getISOFields:t=>$$(ss,t),getCalendar:fp,getTimeZone:({timeZone:t})=>typeof t=="string"?new py(t):t,with(t,e,i){return rs(S9(mp,xr,t,this,zu(e),i))},withCalendar:(t,e)=>rs(i1(t,Fs(e))),withTimeZone:(t,e)=>rs(a7(t,Cr(e))),withPlainDate:(t,e)=>rs(s7(xr,t,Zs(e))),withPlainTime:(t,e)=>rs(r7(xr,t,k1(e))),add:(t,e,i)=>rs(xA(kc,xr,0,t,Yr(e),i)),subtract:(t,e,i)=>rs(xA(kc,xr,1,t,Yr(e),i)),until:(t,e,i)=>wr(Jr(CA(Do,xr,0,t,Vh(e),i))),since:(t,e,i)=>wr(Jr(CA(Do,xr,1,t,Vh(e),i))),round:(t,e)=>rs(k$(xr,t,e)),startOfDay:t=>rs(N$(xr,t)),equals:(t,e)=>a9(t,Vh(e)),toInstant:t=>Xs(L9(t)),toPlainDateTime:t=>Ds(gC(ss,t)),toPlainDate:t=>Kr(mC(ss,t)),toPlainTime:t=>ol(yC(ss,t)),toPlainYearMonth(t){return hl(U9(_y,t,this))},toPlainMonthDay(t){return wu(V9(my,t,this))},toLocaleString(t,e,i={}){const[r,o]=nH(e,i,t);return r.format(o)},toString:(t,e)=>fA(ss,t,e),toJSON:t=>fA(ss,t),valueOf:Dl},{from:(t,e)=>rs(Vh(t,e)),compare:(t,e)=>JR(Vh(t),Vh(e))}),BH=Object.defineProperties({},{...fx("Temporal.Now"),...mu({timeZoneId:()=>Qa(),instant:()=>Xs(Ns(ig())),zonedDateTime:(t,e=Qa())=>rs(Qs(ig(),Cr(e),Fs(t))),zonedDateTimeISO:(t=Qa())=>rs(Qs(ig(),Cr(t),vi)),plainDateTime:(t,e=Qa())=>Ds(vs(nf(ss(Cr(e))),Fs(t))),plainDateTimeISO:(t=Qa())=>Ds(vs(nf(ss(Cr(t))),vi)),plainDate:(t,e=Qa())=>Kr(xs(nf(ss(Cr(e))),Fs(t))),plainDateISO:(t=Qa())=>Kr(xs(nf(ss(Cr(t))),vi)),plainTimeISO:(t=Qa())=>ol(Uo(nf(ss(Cr(t)))))})}),JA=Object.defineProperties({},{...fx("Temporal"),...mu({PlainYearMonth:wH,PlainMonthDay:gH,PlainDate:EH,PlainTime:xH,PlainDateTime:SH,ZonedDateTime:NH,Instant:yH,Calendar:U1,TimeZone:py,Duration:DH,Now:BH})}),zH=QW(),V1=new WeakMap;Object.create(Intl),mu({DateTimeFormat:zH});const LH=P2({name:"TimeSlider",components:{},props:{numDays:Number,dailyTotals:{type:Object,required:!0},weeks:{type:Object,required:!0},initial:{type:Object,required:!0},labels:{type:Object,required:!1}},data:()=>({leftside:0,rightside:0,isDraggingDivider:0,isDragHappening:!1,dragStartWidth:100,thumbLeft:100,thumbWidth:0,pctStart:0,pctEnd:1,maxInfections:1,side:"",useInitial:!0}),computed:{},watch:{},mounted(){this.rightside=this.numDays||0,this.updateWeeks();const e=document.getElementById("dailybar").clientWidth;this.thumbLeft=Math.floor(this.initial[0]*e),this.thumbWidth=Math.ceil((this.initial[1]-this.initial[0])*e);const i=new ResizeObserver(o=>{const d=document.getElementById("dailybar").clientWidth;let c=this.useInitial?this.initial[0]:this.pctStart,x=this.useInitial?this.initial[1]:this.pctEnd;this.useInitial=!1,this.thumbLeft=Math.floor(c*d),this.thumbWidth=Math.ceil((x-c)*d)}),r=document.getElementById("dailybar");r&&i.observe(r)},methods:{updateWeeks(){this.maxInfections=Math.max(...this.weeks)},getWeekHeight(t){return Math.floor(100*t/this.maxInfections)},dividerDragStart(t,e){this.isDraggingDivider=t.clientX,this.dragStartWidth=this.thumbLeft,this.side=e},dividerDragEnd(t){this.isDraggingDivider=0,this.side=""},dividerDragging(t){if(!this.isDraggingDivider)return;if(this.side=="left")return this.adjustLeftSide(t);if(this.side=="right")return this.adjustRightSide(t);const i=document.getElementById("dailybar").clientWidth,r=t.clientX-this.isDraggingDivider;this.thumbLeft=Math.max(0,this.dragStartWidth+r),this.thumbLeft=Math.min(this.thumbLeft,i-this.thumbWidth),this.pctStart=this.thumbLeft/i,this.pctEnd=(this.thumbLeft+this.thumbWidth)/i,this.$emit("range",{start:this.pctStart,end:this.pctEnd})},adjustLeftSide(t){const i=document.getElementById("dailybar").clientWidth,r=t.clientX-this.isDraggingDivider,o=this.thumbLeft+r;o<0||o>=this.thumbLeft+this.thumbWidth-16||(this.isDraggingDivider+=r,this.thumbLeft+=r,this.thumbWidth-=r,this.thumbLeft=Math.max(0,this.thumbLeft),this.pctStart=this.thumbLeft/i,this.pctEnd=(this.thumbLeft+this.thumbWidth)/i,console.log(this.pctStart,this.pctEnd),this.$emit("range",{start:this.pctStart,end:this.pctEnd}))},adjustRightSide(t){const i=document.getElementById("dailybar").clientWidth,r=t.clientX-this.isDraggingDivider,o=this.thumbWidth+r;o<16||this.thumbLeft+o>i||(this.thumbWidth+=r,this.isDraggingDivider=t.clientX,this.pctStart=this.thumbLeft/i,this.pctEnd=(this.thumbLeft+this.thumbWidth)/i,console.log(this.pctStart,this.pctEnd),this.$emit("range",{start:this.pctStart,end:this.pctEnd}))},sizerDragStart(t){console.log("dragStart",t),this.isDraggingDivider=t.clientX,this.dragStartWidth=this.thumbLeft},sizerDragEnd(t){this.isDraggingDivider=0},sizerDragging(t){if(!this.isDraggingDivider)return;console.log("sizer",this.isDraggingDivider,t.clientX,this.thumbLeft,this.thumbWidth);const i=document.getElementById("dailybar").clientWidth,r=t.clientX-this.isDraggingDivider;console.log({deltaX:r});let o=r;console.log(o),console.log("oldwidth",this.thumbWidth,"newwidth",this.thumbWidth-o),console.log("oldleft",this.thumbLeft,"newleft",this.thumbLeft+o),this.thumbWidth-=o,this.thumbLeft+=o,this.pctStart=this.thumbLeft/i,this.pctEnd=(this.thumbLeft+this.thumbWidth)/i,this.$emit("range",{start:this.pctStart,end:this.pctEnd})},filterByDate(){}}}),UH={id:"dailybar"},VH={class:"bars"},jH={key:0,class:"labels"};function $H(t,e,i,r,o,h){return _a(),cc("div",{class:"time-slider",onMousemove:e[9]||(e[9]=Za((...d)=>t.dividerDragging&&t.dividerDragging(...d),["stop"])),onMouseup:e[10]||(e[10]=(...d)=>t.dividerDragEnd&&t.dividerDragEnd(...d))},[qs("div",UH,[qs("div",VH,[(_a(!0),cc(Kn,null,BT(t.weeks,d=>(_a(),cc("div",{class:"week",style:Gh({height:`${t.getWeekHeight(d)}%`})},null,4))),256))]),t.labels?(_a(),cc("div",jH,[(_a(!0),cc(Kn,null,BT(t.labels,d=>(_a(),cc("div",{class:"date-label",style:Gh({left:`${d.leftPct}%`})},og(d.text),5))),256))])):J2("",!0)]),qs("div",{id:"dragthumb",style:Gh({left:`${t.thumbLeft}px`,width:`${t.thumbWidth}px`}),onMousedown:e[6]||(e[6]=(...d)=>t.dividerDragStart&&t.dividerDragStart(...d)),onMouseup:e[7]||(e[7]=(...d)=>t.dividerDragEnd&&t.dividerDragEnd(...d)),onMousemove:e[8]||(e[8]=Za((...d)=>t.dividerDragging&&t.dividerDragging(...d),["stop"]))},[qs("div",{id:"dragleftie",onMousedown:e[0]||(e[0]=Za(d=>t.dividerDragStart(d,"left"),["stop"])),onMouseup:e[1]||(e[1]=Za(d=>t.dividerDragEnd(d,"left"),["stop"])),onMousemove:e[2]||(e[2]=Za(d=>t.dividerDragging(d,"left"),["stop"]))},null,32),qs("div",{id:"dragrightie",onMousedown:e[3]||(e[3]=Za(d=>t.dividerDragStart(d,"right"),["stop"])),onMouseup:e[4]||(e[4]=Za(d=>t.dividerDragEnd(d,"right"),["stop"])),onMousemove:e[5]||(e[5]=Za(d=>t.dividerDragging(d,"right"),["stop"]))},null,32)],36)],32)}const _M=(t,e)=>{const i=t.__vccOpts||t;for(const[r,o]of e)i[r]=o;return i},WH=_M(LH,[["render",$H],["__scopeId","data-v-04bdd2c0"]]);function HH(t){return new Worker("/assets/CSVStreamer.worker-DUKFFnIK.js",{name:t==null?void 0:t.name})}const XH="https://svn.vsp.tu-berlin.de/repos/public-svn/matsim/scenarios/countries/de/episim/battery",qH=P2({name:"InfectionMap",components:{TimeSlider:WH},data:()=>({map:{},allInfections:[],isLoaded:!1,population:[],numInfections:0,statusText:"Loading...",coordinates:new Float64Array(1),view:0,deckOverlay:{},startDate:"",numDays:0,dailyTotals:new Float32Array(0),filterStartDate:0,filterEndDate:0,weeks:[],labels:[],csvStreamer:null}),computed:{},watch:{view(){this.updateLayers()}},beforeDestroy(){this.csvStreamer&&this.csvStreamer.terminate(),this.allInfections=[],this.coordinates=new Float64Array(1),this.population=[]},mounted(){this.map=null,this.map=new sA.Map({container:"mymap",style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",center:[6.95,50.9],zoom:11,bearing:0,pitch:50}),this.loadInfections()},methods:{filterByDate(t){const e=Math.floor(this.numDays*t.start),i=Math.ceil(this.numDays*t.end);this.filterStartDate=e,this.filterEndDate=i,this.updateLayers()},loadInfections(){let e=new URLSearchParams(document.location.search).get("path")||"";e||(e="jakob/2023-11-06/1-bmbf-calibrate-eg-B/summaries/1-infections.csv.gz");const i=`${XH}/${e}`;console.log({batteryUrl:i}),this.csvStreamer=new HH,this.csvStreamer.onmessage=async r=>{if(r.data.status&&(this.statusText=r.data.status),r.data.error&&(this.statusText=r.data.error),r.data.finished&&this.finishedLoadingInfections(),r.data.data){const o=r.data.data;this.numInfections+=o.length,this.statusText="Reading infections: "+this.numInfections;for(const h of o)this.startDate||(this.startDate=h['"date']),this.allInfections.push({home_lon:h['"home_lon'],home_lat:h['"home_lat'],daysSinceStart:h['"daysSinceStart']})}},this.csvStreamer.postMessage({url:i,options:{header:!0,dynamicTyping:!0,skipEmptyLines:!0}})},finishedLoadingInfections(){if(this.csvStreamer.terminate(),!this.allInfections.length){this.statusText="ERROR: No infections file found";return}this.setupDailyTotals(),this.isLoaded=!0,this.buildDeckLayer()},setupDailyTotals(){this.numDays=this.allInfections[this.allInfections.length-1].daysSinceStart||0,this.dailyTotals=new Float32Array(this.numDays+1),this.allInfections.forEach(h=>{this.dailyTotals[h.daysSinceStart]+=1});let t=0;for(let h=0;h96.5&&(this.labels[this.labels.length-1].leftPct=96.5)},buildDeckLayer(){this.statusText="Generating map...",this.deckOverlay=new e$({layers:[]}),this.map.addControl(this.deckOverlay),this.map.addControl(new sA.NavigationControl),this.statusText="Home locations of infected people",this.updateLayers()},updateLayers(){const t=[];t.push(new fv({visible:this.view==0,id:"pointlayer-1",data:this.allInfections,getFillColor:[50,0,180],getRadius:20,getPosition:e=>[e.home_lon,e.home_lat],radiusScale:1,stroked:!1,filled:!0,autoHighlight:!0,highlightColor:[255,255,255],opacity:.05,pickable:!1,useDevicePixels:!1,transitions:{},parameters:{depthTest:!1},glOptions:{fp64:!1},extensions:[new pv({filterSize:1})],filterRange:[this.filterStartDate,this.filterEndDate],getFilterValue:e=>e.daysSinceStart})),this.deckOverlay._deck.setProps({layers:t})}}}),ZH=t=>(rD("data-v-3277f9cf"),t=t(),sD(),t),YH={class:"app"},KH={class:"button-row"},JH={class:"flex1",style:{margin:"auto 0"}},GH=ZH(()=>qs("div",{class:"mymap flex1",id:"mymap"},null,-1));function QH(t,e,i,r,o,h){const d=bD("time-slider");return _a(),cc("div",YH,[qs("div",KH,[qs("p",JH,[qs("b",null,og(t.statusText)+" "+og(t.filterStartDate+t.filterEndDate?`Day ${t.filterStartDate} - ${t.filterEndDate}`:""),1)]),qs("button",{onClick:e[0]||(e[0]=c=>t.view=0),class:Qh({isActive:t.view==0})},"Points",2),qs("button",{onClick:e[1]||(e[1]=c=>t.view=1),class:Qh({isActive:t.view==1})},"Hexagons",2),qs("button",{onClick:e[2]||(e[2]=c=>t.view=2),class:Qh({isActive:t.view==2})},"Districts",2)]),GH,t.isLoaded?(_a(),Y2(d,{key:0,class:"time-slider",numDays:t.numDays,dailyTotals:t.dailyTotals,weeks:t.weeks,initial:[0,30/t.numDays],labels:t.labels,onRange:t.filterByDate},null,8,["numDays","dailyTotals","weeks","initial","labels","onRange"])):J2("",!0)])}const eX=_M(qH,[["render",QH],["__scopeId","data-v-3277f9cf"]]);jO(eX).mount("#app");
+`),ee=A.createShader(A.FRAGMENT_SHADER);if(A.isContextLost())return void(this.failedToCreate=!0);if(A.shaderSource(ee,oe),A.compileShader(ee),!A.getShaderParameter(ee,A.COMPILE_STATUS))throw new Error(`Could not compile fragment shader: ${A.getShaderInfoLog(ee)}`);A.attachShader(this.program,ee);const me=A.createShader(A.VERTEX_SHADER);if(A.isContextLost())return void(this.failedToCreate=!0);if(A.shaderSource(me,de),A.compileShader(me),!A.getShaderParameter(me,A.COMPILE_STATUS))throw new Error(`Could not compile vertex shader: ${A.getShaderInfoLog(me)}`);A.attachShader(this.program,me),this.attributes={};const Ae={};this.numAttributes=F.length;for(let Re=0;Re({u_depth:new c.aI(Re,Le.u_depth),u_terrain:new c.aI(Re,Le.u_terrain),u_terrain_dim:new c.aJ(Re,Le.u_terrain_dim),u_terrain_matrix:new c.aK(Re,Le.u_terrain_matrix),u_terrain_unpack:new c.aL(Re,Le.u_terrain_unpack),u_terrain_exaggeration:new c.aJ(Re,Le.u_terrain_exaggeration)}))(n,Ae),this.binderUniforms=p?p.getUniforms(n,Ae):[]}draw(n,u,p,_,m,T,A,R,C,F,N,V,W,K,se,ie,oe,de){const ee=n.gl;if(this.failedToCreate)return;if(n.program.set(this.program),n.setDepthMode(p),n.setStencilMode(_),n.setColorMode(m),n.setCullFace(T),R){n.activeTexture.set(ee.TEXTURE2),ee.bindTexture(ee.TEXTURE_2D,R.depthTexture),n.activeTexture.set(ee.TEXTURE3),ee.bindTexture(ee.TEXTURE_2D,R.texture);for(const Ae in this.terrainUniforms)this.terrainUniforms[Ae].set(R[Ae])}for(const Ae in this.fixedUniforms)this.fixedUniforms[Ae].set(A[Ae]);se&&se.setUniforms(n,this.binderUniforms,W,{zoom:K});let me=0;switch(u){case ee.LINES:me=2;break;case ee.TRIANGLES:me=3;break;case ee.LINE_STRIP:me=1}for(const Ae of V.get()){const Re=Ae.vaos||(Ae.vaos={});(Re[C]||(Re[C]=new Yo)).bind(n,this,F,se?se.getPaintVertexBuffers():[],N,Ae.vertexOffset,ie,oe,de),ee.drawElements(u,Ae.primitiveLength*me,ee.UNSIGNED_SHORT,Ae.primitiveOffset*me*2)}}}function Y(y,n,u){const p=1/Lt(u,1,n.transform.tileZoom),_=Math.pow(2,u.tileID.overscaledZ),m=u.tileSize*Math.pow(2,n.transform.tileZoom)/_,T=m*(u.tileID.canonical.x+u.tileID.wrap*_),A=m*u.tileID.canonical.y;return{u_image:0,u_texsize:u.imageAtlasTexture.size,u_scale:[p,y.fromScale,y.toScale],u_fade:y.t,u_pixel_coord_upper:[T>>16,A>>16],u_pixel_coord_lower:[65535&T,65535&A]}}const ue=(y,n,u,p)=>{const _=n.style.light,m=_.properties.get("position"),T=[m.x,m.y,m.z],A=function(){var C=new c.A(9);return c.A!=Float32Array&&(C[1]=0,C[2]=0,C[3]=0,C[5]=0,C[6]=0,C[7]=0),C[0]=1,C[4]=1,C[8]=1,C}();_.properties.get("anchor")==="viewport"&&function(C,F){var N=Math.sin(F),V=Math.cos(F);C[0]=V,C[1]=N,C[2]=0,C[3]=-N,C[4]=V,C[5]=0,C[6]=0,C[7]=0,C[8]=1}(A,-n.transform.angle),function(C,F,N){var V=F[0],W=F[1],K=F[2];C[0]=V*N[0]+W*N[3]+K*N[6],C[1]=V*N[1]+W*N[4]+K*N[7],C[2]=V*N[2]+W*N[5]+K*N[8]}(T,T,A);const R=_.properties.get("color");return{u_matrix:y,u_lightpos:T,u_lightintensity:_.properties.get("intensity"),u_lightcolor:[R.r,R.g,R.b],u_vertical_gradient:+u,u_opacity:p}},Me=(y,n,u,p,_,m,T)=>c.e(ue(y,n,u,p),Y(m,n,T),{u_height_factor:-Math.pow(2,_.overscaledZ)/T.tileSize/8}),qe=y=>({u_matrix:y}),gt=(y,n,u,p)=>c.e(qe(y),Y(u,n,p)),Zt=(y,n)=>({u_matrix:y,u_world:n}),dr=(y,n,u,p,_)=>c.e(gt(y,n,u,p),{u_world:_}),fr=(y,n,u,p)=>{const _=y.transform;let m,T;if(p.paint.get("circle-pitch-alignment")==="map"){const A=Lt(u,1,_.zoom);m=!0,T=[A,A]}else m=!1,T=_.pixelsToGLUnits;return{u_camera_to_center_distance:_.cameraToCenterDistance,u_scale_with_map:+(p.paint.get("circle-pitch-scale")==="map"),u_matrix:y.translatePosMatrix(n.posMatrix,u,p.paint.get("circle-translate"),p.paint.get("circle-translate-anchor")),u_pitch_with_map:+m,u_device_pixel_ratio:y.pixelRatio,u_extrude_scale:T}},Mr=(y,n,u)=>({u_matrix:y,u_inv_matrix:n,u_camera_to_center_distance:u.cameraToCenterDistance,u_viewport_size:[u.width,u.height]}),yr=(y,n,u=1)=>({u_matrix:y,u_color:n,u_overlay:0,u_overlay_scale:u}),Fl=y=>({u_matrix:y}),Is=(y,n,u,p)=>({u_matrix:y,u_extrude_scale:Lt(n,1,u),u_intensity:p});function Ps(y,n){const u=Math.pow(2,n.canonical.z),p=n.canonical.y;return[new c.Z(0,p/u).toLngLat().lat,new c.Z(0,(p+1)/u).toLngLat().lat]}const Nl=(y,n,u,p)=>{const _=y.transform;return{u_matrix:vp(y,n,u,p),u_ratio:1/Lt(n,1,_.zoom),u_device_pixel_ratio:y.pixelRatio,u_units_to_pixels:[1/_.pixelsToGLUnits[0],1/_.pixelsToGLUnits[1]]}},qc=(y,n,u,p,_)=>c.e(Nl(y,n,u,_),{u_image:0,u_image_height:p}),yp=(y,n,u,p,_)=>{const m=y.transform,T=Jo(n,m);return{u_matrix:vp(y,n,u,_),u_texsize:n.imageAtlasTexture.size,u_ratio:1/Lt(n,1,m.zoom),u_device_pixel_ratio:y.pixelRatio,u_image:0,u_scale:[T,p.fromScale,p.toScale],u_fade:p.t,u_units_to_pixels:[1/m.pixelsToGLUnits[0],1/m.pixelsToGLUnits[1]]}},bp=(y,n,u,p,_,m)=>{const T=y.lineAtlas,A=Jo(n,y.transform),R=u.layout.get("line-cap")==="round",C=T.getDash(p.from,R),F=T.getDash(p.to,R),N=C.width*_.fromScale,V=F.width*_.toScale;return c.e(Nl(y,n,u,m),{u_patternscale_a:[A/N,-C.height/2],u_patternscale_b:[A/V,-F.height/2],u_sdfgamma:T.width/(256*Math.min(N,V)*y.pixelRatio)/2,u_image:0,u_tex_y_a:C.y,u_tex_y_b:F.y,u_mix:_.t})};function Jo(y,n){return 1/Lt(y,1,n.tileZoom)}function vp(y,n,u,p){return y.translatePosMatrix(p?p.posMatrix:n.tileID.posMatrix,n,u.paint.get("line-translate"),u.paint.get("line-translate-anchor"))}const yy=(y,n,u,p,_)=>{return{u_matrix:y,u_tl_parent:n,u_scale_parent:u,u_buffer_scale:1,u_fade_t:p.mix,u_opacity:p.opacity*_.paint.get("raster-opacity"),u_image0:0,u_image1:1,u_brightness_low:_.paint.get("raster-brightness-min"),u_brightness_high:_.paint.get("raster-brightness-max"),u_saturation_factor:(T=_.paint.get("raster-saturation"),T>0?1-1/(1.001-T):-T),u_contrast_factor:(m=_.paint.get("raster-contrast"),m>0?1/(1-m):1+m),u_spin_weights:by(_.paint.get("raster-hue-rotate"))};var m,T};function by(y){y*=Math.PI/180;const n=Math.sin(y),u=Math.cos(y);return[(2*u+1)/3,(-Math.sqrt(3)*n-u+1)/3,(Math.sqrt(3)*n-u+1)/3]}const xp=(y,n,u,p,_,m,T,A,R,C,F,N,V,W)=>{const K=T.transform;return{u_is_size_zoom_constant:+(y==="constant"||y==="source"),u_is_size_feature_constant:+(y==="constant"||y==="camera"),u_size_t:n?n.uSizeT:0,u_size:n?n.uSize:0,u_camera_to_center_distance:K.cameraToCenterDistance,u_pitch:K.pitch/360*2*Math.PI,u_rotate_symbol:+u,u_aspect_ratio:K.width/K.height,u_fade_change:T.options.fadeDuration?T.symbolFadeChange:1,u_matrix:A,u_label_plane_matrix:R,u_coord_matrix:C,u_is_text:+N,u_pitch_with_map:+p,u_is_along_line:_,u_is_variable_anchor:m,u_texsize:V,u_texture:0,u_translation:F,u_pitched_scale:W}},wp=(y,n,u,p,_,m,T,A,R,C,F,N,V,W,K)=>{const se=T.transform;return c.e(xp(y,n,u,p,_,m,T,A,R,C,F,N,V,K),{u_gamma_scale:p?Math.cos(se._pitch)*se.cameraToCenterDistance:1,u_device_pixel_ratio:T.pixelRatio,u_is_halo:+W})},vy=(y,n,u,p,_,m,T,A,R,C,F,N,V,W)=>c.e(wp(y,n,u,p,_,m,T,A,R,C,F,!0,N,!0,W),{u_texsize_icon:V,u_texture_icon:1}),Zc=(y,n,u)=>({u_matrix:y,u_opacity:n,u_color:u}),Lu=(y,n,u,p,_,m)=>c.e(function(T,A,R,C){const F=R.imageManager.getPattern(T.from.toString()),N=R.imageManager.getPattern(T.to.toString()),{width:V,height:W}=R.imageManager.getPixelSize(),K=Math.pow(2,C.tileID.overscaledZ),se=C.tileSize*Math.pow(2,R.transform.tileZoom)/K,ie=se*(C.tileID.canonical.x+C.tileID.wrap*K),oe=se*C.tileID.canonical.y;return{u_image:0,u_pattern_tl_a:F.tl,u_pattern_br_a:F.br,u_pattern_tl_b:N.tl,u_pattern_br_b:N.br,u_texsize:[V,W],u_mix:A.t,u_pattern_size_a:F.displaySize,u_pattern_size_b:N.displaySize,u_scale_a:A.fromScale,u_scale_b:A.toScale,u_tile_units_to_pixels:1/Lt(C,1,R.transform.tileZoom),u_pixel_coord_upper:[ie>>16,oe>>16],u_pixel_coord_lower:[65535&ie,65535&oe]}}(p,m,u,_),{u_matrix:y,u_opacity:n}),Yc={fillExtrusion:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_lightpos:new c.aO(y,n.u_lightpos),u_lightintensity:new c.aJ(y,n.u_lightintensity),u_lightcolor:new c.aO(y,n.u_lightcolor),u_vertical_gradient:new c.aJ(y,n.u_vertical_gradient),u_opacity:new c.aJ(y,n.u_opacity)}),fillExtrusionPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_lightpos:new c.aO(y,n.u_lightpos),u_lightintensity:new c.aJ(y,n.u_lightintensity),u_lightcolor:new c.aO(y,n.u_lightcolor),u_vertical_gradient:new c.aJ(y,n.u_vertical_gradient),u_height_factor:new c.aJ(y,n.u_height_factor),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade),u_opacity:new c.aJ(y,n.u_opacity)}),fill:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix)}),fillPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),fillOutline:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world)}),fillOutlinePattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world),u_image:new c.aI(y,n.u_image),u_texsize:new c.aP(y,n.u_texsize),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),circle:(y,n)=>({u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_scale_with_map:new c.aI(y,n.u_scale_with_map),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_extrude_scale:new c.aP(y,n.u_extrude_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_matrix:new c.aK(y,n.u_matrix)}),collisionBox:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_pixel_extrude_scale:new c.aP(y,n.u_pixel_extrude_scale)}),collisionCircle:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_inv_matrix:new c.aK(y,n.u_inv_matrix),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_viewport_size:new c.aP(y,n.u_viewport_size)}),debug:(y,n)=>({u_color:new c.aM(y,n.u_color),u_matrix:new c.aK(y,n.u_matrix),u_overlay:new c.aI(y,n.u_overlay),u_overlay_scale:new c.aJ(y,n.u_overlay_scale)}),clippingMask:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix)}),heatmap:(y,n)=>({u_extrude_scale:new c.aJ(y,n.u_extrude_scale),u_intensity:new c.aJ(y,n.u_intensity),u_matrix:new c.aK(y,n.u_matrix)}),heatmapTexture:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_world:new c.aP(y,n.u_world),u_image:new c.aI(y,n.u_image),u_color_ramp:new c.aI(y,n.u_color_ramp),u_opacity:new c.aJ(y,n.u_opacity)}),hillshade:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_latrange:new c.aP(y,n.u_latrange),u_light:new c.aP(y,n.u_light),u_shadow:new c.aM(y,n.u_shadow),u_highlight:new c.aM(y,n.u_highlight),u_accent:new c.aM(y,n.u_accent)}),hillshadePrepare:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_image:new c.aI(y,n.u_image),u_dimension:new c.aP(y,n.u_dimension),u_zoom:new c.aJ(y,n.u_zoom),u_unpack:new c.aL(y,n.u_unpack)}),line:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels)}),lineGradient:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_image:new c.aI(y,n.u_image),u_image_height:new c.aJ(y,n.u_image_height)}),linePattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texsize:new c.aP(y,n.u_texsize),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_image:new c.aI(y,n.u_image),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_scale:new c.aO(y,n.u_scale),u_fade:new c.aJ(y,n.u_fade)}),lineSDF:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ratio:new c.aJ(y,n.u_ratio),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_units_to_pixels:new c.aP(y,n.u_units_to_pixels),u_patternscale_a:new c.aP(y,n.u_patternscale_a),u_patternscale_b:new c.aP(y,n.u_patternscale_b),u_sdfgamma:new c.aJ(y,n.u_sdfgamma),u_image:new c.aI(y,n.u_image),u_tex_y_a:new c.aJ(y,n.u_tex_y_a),u_tex_y_b:new c.aJ(y,n.u_tex_y_b),u_mix:new c.aJ(y,n.u_mix)}),raster:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_tl_parent:new c.aP(y,n.u_tl_parent),u_scale_parent:new c.aJ(y,n.u_scale_parent),u_buffer_scale:new c.aJ(y,n.u_buffer_scale),u_fade_t:new c.aJ(y,n.u_fade_t),u_opacity:new c.aJ(y,n.u_opacity),u_image0:new c.aI(y,n.u_image0),u_image1:new c.aI(y,n.u_image1),u_brightness_low:new c.aJ(y,n.u_brightness_low),u_brightness_high:new c.aJ(y,n.u_brightness_high),u_saturation_factor:new c.aJ(y,n.u_saturation_factor),u_contrast_factor:new c.aJ(y,n.u_contrast_factor),u_spin_weights:new c.aO(y,n.u_spin_weights)}),symbolIcon:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texture:new c.aI(y,n.u_texture),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),symbolSDF:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texture:new c.aI(y,n.u_texture),u_gamma_scale:new c.aJ(y,n.u_gamma_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_is_halo:new c.aI(y,n.u_is_halo),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),symbolTextAndIcon:(y,n)=>({u_is_size_zoom_constant:new c.aI(y,n.u_is_size_zoom_constant),u_is_size_feature_constant:new c.aI(y,n.u_is_size_feature_constant),u_size_t:new c.aJ(y,n.u_size_t),u_size:new c.aJ(y,n.u_size),u_camera_to_center_distance:new c.aJ(y,n.u_camera_to_center_distance),u_pitch:new c.aJ(y,n.u_pitch),u_rotate_symbol:new c.aI(y,n.u_rotate_symbol),u_aspect_ratio:new c.aJ(y,n.u_aspect_ratio),u_fade_change:new c.aJ(y,n.u_fade_change),u_matrix:new c.aK(y,n.u_matrix),u_label_plane_matrix:new c.aK(y,n.u_label_plane_matrix),u_coord_matrix:new c.aK(y,n.u_coord_matrix),u_is_text:new c.aI(y,n.u_is_text),u_pitch_with_map:new c.aI(y,n.u_pitch_with_map),u_is_along_line:new c.aI(y,n.u_is_along_line),u_is_variable_anchor:new c.aI(y,n.u_is_variable_anchor),u_texsize:new c.aP(y,n.u_texsize),u_texsize_icon:new c.aP(y,n.u_texsize_icon),u_texture:new c.aI(y,n.u_texture),u_texture_icon:new c.aI(y,n.u_texture_icon),u_gamma_scale:new c.aJ(y,n.u_gamma_scale),u_device_pixel_ratio:new c.aJ(y,n.u_device_pixel_ratio),u_is_halo:new c.aI(y,n.u_is_halo),u_translation:new c.aP(y,n.u_translation),u_pitched_scale:new c.aJ(y,n.u_pitched_scale)}),background:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_opacity:new c.aJ(y,n.u_opacity),u_color:new c.aM(y,n.u_color)}),backgroundPattern:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_opacity:new c.aJ(y,n.u_opacity),u_image:new c.aI(y,n.u_image),u_pattern_tl_a:new c.aP(y,n.u_pattern_tl_a),u_pattern_br_a:new c.aP(y,n.u_pattern_br_a),u_pattern_tl_b:new c.aP(y,n.u_pattern_tl_b),u_pattern_br_b:new c.aP(y,n.u_pattern_br_b),u_texsize:new c.aP(y,n.u_texsize),u_mix:new c.aJ(y,n.u_mix),u_pattern_size_a:new c.aP(y,n.u_pattern_size_a),u_pattern_size_b:new c.aP(y,n.u_pattern_size_b),u_scale_a:new c.aJ(y,n.u_scale_a),u_scale_b:new c.aJ(y,n.u_scale_b),u_pixel_coord_upper:new c.aP(y,n.u_pixel_coord_upper),u_pixel_coord_lower:new c.aP(y,n.u_pixel_coord_lower),u_tile_units_to_pixels:new c.aJ(y,n.u_tile_units_to_pixels)}),terrain:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texture:new c.aI(y,n.u_texture),u_ele_delta:new c.aJ(y,n.u_ele_delta),u_fog_matrix:new c.aK(y,n.u_fog_matrix),u_fog_color:new c.aM(y,n.u_fog_color),u_fog_ground_blend:new c.aJ(y,n.u_fog_ground_blend),u_fog_ground_blend_opacity:new c.aJ(y,n.u_fog_ground_blend_opacity),u_horizon_color:new c.aM(y,n.u_horizon_color),u_horizon_fog_blend:new c.aJ(y,n.u_horizon_fog_blend)}),terrainDepth:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_ele_delta:new c.aJ(y,n.u_ele_delta)}),terrainCoords:(y,n)=>({u_matrix:new c.aK(y,n.u_matrix),u_texture:new c.aI(y,n.u_texture),u_terrain_coords_id:new c.aJ(y,n.u_terrain_coords_id),u_ele_delta:new c.aJ(y,n.u_ele_delta)}),sky:(y,n)=>({u_sky_color:new c.aM(y,n.u_sky_color),u_horizon_color:new c.aM(y,n.u_horizon_color),u_horizon:new c.aJ(y,n.u_horizon),u_sky_horizon_blend:new c.aJ(y,n.u_sky_horizon_blend)})};class Uu{constructor(n,u,p){this.context=n;const _=n.gl;this.buffer=_.createBuffer(),this.dynamicDraw=!!p,this.context.unbindVAO(),n.bindElementBuffer.set(this.buffer),_.bufferData(_.ELEMENT_ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?_.DYNAMIC_DRAW:_.STATIC_DRAW),this.dynamicDraw||delete u.arrayBuffer}bind(){this.context.bindElementBuffer.set(this.buffer)}updateData(n){const u=this.context.gl;if(!this.dynamicDraw)throw new Error("Attempted to update data while not in dynamic mode.");this.context.unbindVAO(),this.bind(),u.bufferSubData(u.ELEMENT_ARRAY_BUFFER,0,n.arrayBuffer)}destroy(){this.buffer&&(this.context.gl.deleteBuffer(this.buffer),delete this.buffer)}}const Vu={Int8:"BYTE",Uint8:"UNSIGNED_BYTE",Int16:"SHORT",Uint16:"UNSIGNED_SHORT",Int32:"INT",Uint32:"UNSIGNED_INT",Float32:"FLOAT"};class Pn{constructor(n,u,p,_){this.length=u.length,this.attributes=p,this.itemSize=u.bytesPerElement,this.dynamicDraw=_,this.context=n;const m=n.gl;this.buffer=m.createBuffer(),n.bindVertexBuffer.set(this.buffer),m.bufferData(m.ARRAY_BUFFER,u.arrayBuffer,this.dynamicDraw?m.DYNAMIC_DRAW:m.STATIC_DRAW),this.dynamicDraw||delete u.arrayBuffer}bind(){this.context.bindVertexBuffer.set(this.buffer)}updateData(n){if(n.length!==this.length)throw new Error(`Length of new data is ${n.length}, which doesn't match current length of ${this.length}`);const u=this.context.gl;this.bind(),u.bufferSubData(u.ARRAY_BUFFER,0,n.arrayBuffer)}enableAttributes(n,u){for(let p=0;p0){const Re=c.H();c.aR(Re,ee.placementInvProjMatrix,y.transform.glCoordMatrix),c.aR(Re,Re,ee.placementViewportMatrix),R.push({circleArray:Ae,circleOffset:F,transform:de.posMatrix,invTransform:Re,coord:de}),C+=Ae.length/4,F=C}me&&A.draw(m,T.LINES,Yt.disabled,Vi.disabled,y.colorModeForRenderPass(),Pi.disabled,{u_matrix:de.posMatrix,u_pixel_extrude_scale:[1/(N=y.transform).width,1/N.height]},y.style.map.terrain&&y.style.map.terrain.getTerrainData(de),u.id,me.layoutVertexBuffer,me.indexBuffer,me.segments,null,y.transform.zoom,null,null,me.collisionVertexBuffer)}var N;if(!_||!R.length)return;const V=y.useProgram("collisionCircle"),W=new c.aS;W.resize(4*C),W._trim();let K=0;for(const oe of R)for(let de=0;de=0&&(oe[ee.associatedIconIndex]={shiftedAnchor:Ot,angle:Ci})}else It(ee.numGlyphs,se)}if(C){ie.clear();const de=y.icon.placedSymbolArray;for(let ee=0;eey.style.map.terrain.getElevation(Ye,Rd,br):null,za=u.layout.get("text-rotation-alignment")==="map";q(yt,Ye.posMatrix,y,_,oa,Na,oe,C,za,se,Ye.toUnwrapped(),K.width,K.height,aa,Zi)}const kr=Ye.posMatrix,un=_&&Ze||Pd,po=de||un?Ku:oa,Ba=gh,jr=nt&&u.paint.get(_?"text-halo-width":"icon-halo-width").constantOr(1)!==0;let $r;$r=nt?yt.iconsInText?vy(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,Lr,Qr,dt):wp(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,_,Lr,!0,dt):xp(Ot.kind,Kt,ee,oe,de,un,y,kr,po,Ba,aa,_,Lr,dt);const Ar={program:Ht,buffers:Ut,uniformValues:$r,atlasTexture:cn,atlasTextureIcon:Ur,atlasInterpolation:ki,atlasInterpolationIcon:hs,isSDF:nt,hasHalo:jr};if(Ae&&yt.canOverlap){Re=!0;const Zi=Ut.segments.get();for(const za of Zi)ct.push({segments:new c.a0([za]),sortKey:za.sortKey,state:Ar,terrainData:Mi})}else ct.push({segments:Ut.segments,sortKey:0,state:Ar,terrainData:Mi})}Re&&ct.sort((Ye,Qe)=>Ye.sortKey-Qe.sortKey);for(const Ye of ct){const Qe=Ye.state;if(V.activeTexture.set(W.TEXTURE0),Qe.atlasTexture.bind(Qe.atlasInterpolation,W.CLAMP_TO_EDGE),Qe.atlasTextureIcon&&(V.activeTexture.set(W.TEXTURE1),Qe.atlasTextureIcon&&Qe.atlasTextureIcon.bind(Qe.atlasInterpolationIcon,W.CLAMP_TO_EDGE)),Qe.isSDF){const yt=Qe.uniformValues;Qe.hasHalo&&(yt.u_is_halo=1,Qo(Qe.buffers,Ye.segments,u,y,Qe.program,Le,F,N,yt,Ye.terrainData)),yt.u_is_halo=0}Qo(Qe.buffers,Ye.segments,u,y,Qe.program,Le,F,N,Qe.uniformValues,Ye.terrainData)}}function Qo(y,n,u,p,_,m,T,A,R,C){const F=p.context;_.draw(F,F.gl.TRIANGLES,m,T,A,Pi.disabled,R,C,u.id,y.layoutVertexBuffer,y.indexBuffer,n,u.paint,p.transform.zoom,y.programConfigurations.get(u.id),y.dynamicLayoutVertexBuffer,y.opacityVertexBuffer)}function Rs(y,n,u,p,_){if(!u||!p||!p.imageAtlas)return;const m=p.imageAtlas.patternPositions;let T=m[u.to.toString()],A=m[u.from.toString()];if(!T&&A&&(T=A),!A&&T&&(A=T),!T||!A){const R=_.getPaintProperty(n);T=m[R],A=m[R]}T&&A&&y.setConstantPatternPositions(T,A)}function Gu(y,n,u,p,_,m,T){const A=y.context.gl,R="fill-pattern",C=u.paint.get(R),F=C&&C.constantOr(1),N=u.getCrossfadeParameters();let V,W,K,se,ie;T?(W=F&&!u.getPaintProperty("fill-outline-color")?"fillOutlinePattern":"fillOutline",V=A.LINES):(W=F?"fillPattern":"fill",V=A.TRIANGLES);const oe=C.constantOr(null);for(const de of p){const ee=n.getTile(de);if(F&&!ee.patternsLoaded())continue;const me=ee.getBucket(u);if(!me)continue;const Ae=me.programConfigurations.get(u.id),Re=y.useProgram(W,Ae),Le=y.style.map.terrain&&y.style.map.terrain.getTerrainData(de);F&&(y.context.activeTexture.set(A.TEXTURE0),ee.imageAtlasTexture.bind(A.LINEAR,A.CLAMP_TO_EDGE),Ae.updatePaintBuffers(N)),Rs(Ae,R,oe,ee,u);const Ze=Le?de:null,ct=y.translatePosMatrix(Ze?Ze.posMatrix:de.posMatrix,ee,u.paint.get("fill-translate"),u.paint.get("fill-translate-anchor"));if(T){se=me.indexBuffer2,ie=me.segments2;const dt=[A.drawingBufferWidth,A.drawingBufferHeight];K=W==="fillOutlinePattern"&&F?dr(ct,y,N,ee,dt):Zt(ct,dt)}else se=me.indexBuffer,ie=me.segments,K=F?gt(ct,y,N,ee):qe(ct);Re.draw(y.context,V,_,y.stencilModeForClipping(de),m,Pi.disabled,K,Le,u.id,me.layoutVertexBuffer,se,ie,u.paint,y.transform.zoom,Ae)}}function ih(y,n,u,p,_,m,T){const A=y.context,R=A.gl,C="fill-extrusion-pattern",F=u.paint.get(C),N=F.constantOr(1),V=u.getCrossfadeParameters(),W=u.paint.get("fill-extrusion-opacity"),K=F.constantOr(null);for(const se of p){const ie=n.getTile(se),oe=ie.getBucket(u);if(!oe)continue;const de=y.style.map.terrain&&y.style.map.terrain.getTerrainData(se),ee=oe.programConfigurations.get(u.id),me=y.useProgram(N?"fillExtrusionPattern":"fillExtrusion",ee);N&&(y.context.activeTexture.set(R.TEXTURE0),ie.imageAtlasTexture.bind(R.LINEAR,R.CLAMP_TO_EDGE),ee.updatePaintBuffers(V)),Rs(ee,C,K,ie,u);const Ae=y.translatePosMatrix(se.posMatrix,ie,u.paint.get("fill-extrusion-translate"),u.paint.get("fill-extrusion-translate-anchor")),Re=u.paint.get("fill-extrusion-vertical-gradient"),Le=N?Me(Ae,y,Re,W,se,V,ie):ue(Ae,y,Re,W);me.draw(A,A.gl.TRIANGLES,_,m,T,Pi.backCCW,Le,de,u.id,oe.layoutVertexBuffer,oe.indexBuffer,oe.segments,u.paint,y.transform.zoom,ee,y.style.map.terrain&&oe.centroidVertexBuffer)}}function Qu(y,n,u,p,_,m,T){const A=y.context,R=A.gl,C=u.fbo;if(!C)return;const F=y.useProgram("hillshade"),N=y.style.map.terrain&&y.style.map.terrain.getTerrainData(n);A.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,C.colorAttachment.get()),F.draw(A,R.TRIANGLES,_,m,T,Pi.disabled,((V,W,K,se)=>{const ie=K.paint.get("hillshade-shadow-color"),oe=K.paint.get("hillshade-highlight-color"),de=K.paint.get("hillshade-accent-color");let ee=K.paint.get("hillshade-illumination-direction")*(Math.PI/180);K.paint.get("hillshade-illumination-anchor")==="viewport"&&(ee-=V.transform.angle);const me=!V.options.moving;return{u_matrix:se?se.posMatrix:V.transform.calculatePosMatrix(W.tileID.toUnwrapped(),me),u_image:0,u_latrange:Ps(0,W.tileID),u_light:[K.paint.get("hillshade-exaggeration"),ee],u_shadow:ie,u_highlight:oe,u_accent:de}})(y,u,p,N?n:null),N,p.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments)}function ea(y,n,u,p,_,m){const T=y.context,A=T.gl,R=n.dem;if(R&&R.data){const C=R.dim,F=R.stride,N=R.getPixels();if(T.activeTexture.set(A.TEXTURE1),T.pixelStoreUnpackPremultiplyAlpha.set(!1),n.demTexture=n.demTexture||y.getTileTexture(F),n.demTexture){const W=n.demTexture;W.update(N,{premultiply:!1}),W.bind(A.NEAREST,A.CLAMP_TO_EDGE)}else n.demTexture=new ut(T,N,A.RGBA,{premultiply:!1}),n.demTexture.bind(A.NEAREST,A.CLAMP_TO_EDGE);T.activeTexture.set(A.TEXTURE0);let V=n.fbo;if(!V){const W=new ut(T,{width:C,height:C,data:null},A.RGBA);W.bind(A.LINEAR,A.CLAMP_TO_EDGE),V=n.fbo=T.createFramebuffer(C,C,!0,!1),V.colorAttachment.set(W.texture)}T.bindFramebuffer.set(V.framebuffer),T.viewport.set([0,0,C,C]),y.useProgram("hillshadePrepare").draw(T,A.TRIANGLES,p,_,m,Pi.disabled,((W,K)=>{const se=K.stride,ie=c.H();return c.aQ(ie,0,c.X,-c.X,0,0,1),c.J(ie,ie,[0,-c.X,0]),{u_matrix:ie,u_image:1,u_dimension:[se,se],u_zoom:W.overscaledZ,u_unpack:K.getUnpackVector()}})(n.tileID,R),null,u.id,y.rasterBoundsBuffer,y.quadTriangleIndexBuffer,y.rasterBoundsSegments),n.needsHillshadePrepare=!1}}function rh(y,n,u,p,_,m){const T=p.paint.get("raster-fade-duration");if(!m&&T>0){const A=M.now(),R=(A-y.timeAdded)/T,C=n?(A-n.timeAdded)/T:-1,F=u.getSource(),N=_.coveringZoomLevel({tileSize:F.tileSize,roundZoom:F.roundZoom}),V=!n||Math.abs(n.tileID.overscaledZ-N)>Math.abs(y.tileID.overscaledZ-N),W=V&&y.refreshedUponExpiration?1:c.ad(V?R:1-C,0,1);return y.refreshedUponExpiration&&R>=1&&(y.refreshedUponExpiration=!1),n?{opacity:1,mix:1-W}:{opacity:W,mix:0}}return{opacity:1,mix:0}}const sh=new c.aN(1,0,0,1),Vl=new c.aN(0,1,0,1),nh=new c.aN(0,0,1,1),Bp=new c.aN(1,0,1,1),Pa=new c.aN(0,1,1,1);function ta(y,n,u,p){Ra(y,0,n+u/2,y.transform.width,u,p)}function ed(y,n,u,p){Ra(y,n-u/2,0,u,y.transform.height,p)}function Ra(y,n,u,p,_,m){const T=y.context,A=T.gl;A.enable(A.SCISSOR_TEST),A.scissor(n*y.pixelRatio,u*y.pixelRatio,p*y.pixelRatio,_*y.pixelRatio),T.clear({color:m}),A.disable(A.SCISSOR_TEST)}function oi(y,n,u){const p=y.context,_=p.gl,m=u.posMatrix,T=y.useProgram("debug"),A=Yt.disabled,R=Vi.disabled,C=y.colorModeForRenderPass(),F="$debug",N=y.style.map.terrain&&y.style.map.terrain.getTerrainData(u);p.activeTexture.set(_.TEXTURE0);const V=n.getTileByID(u.key).latestRawTileData,W=Math.floor((V&&V.byteLength||0)/1024),K=n.getTile(u).tileSize,se=512/Math.min(K,512)*(u.overscaledZ/y.transform.zoom)*.5;let ie=u.canonical.toString();u.overscaledZ!==u.canonical.z&&(ie+=` => ${u.overscaledZ}`),function(oe,de){oe.initDebugOverlayCanvas();const ee=oe.debugOverlayCanvas,me=oe.context.gl,Ae=oe.debugOverlayCanvas.getContext("2d");Ae.clearRect(0,0,ee.width,ee.height),Ae.shadowColor="white",Ae.shadowBlur=2,Ae.lineWidth=1.5,Ae.strokeStyle="white",Ae.textBaseline="top",Ae.font="bold 36px Open Sans, sans-serif",Ae.fillText(de,5,5),Ae.strokeText(de,5,5),oe.debugOverlayTexture.update(ee),oe.debugOverlayTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE)}(y,`${ie} ${W}kB`),T.draw(p,_.TRIANGLES,A,R,wi.alphaBlended,Pi.disabled,yr(m,c.aN.transparent,se),null,F,y.debugBuffer,y.quadTriangleIndexBuffer,y.debugSegments),T.draw(p,_.LINE_STRIP,A,R,C,Pi.disabled,yr(m,c.aN.red),N,F,y.debugBuffer,y.tileBorderIndexBuffer,y.debugSegments)}function jl(y,n,u){const p=y.context,_=p.gl,m=y.colorModeForRenderPass(),T=new Yt(_.LEQUAL,Yt.ReadWrite,y.depthRangeFor3D),A=y.useProgram("terrain"),R=n.getTerrainMesh();p.bindFramebuffer.set(null),p.viewport.set([0,0,y.width,y.height]);for(const C of u){const F=y.renderToTexture.getTexture(C),N=n.getTerrainData(C.tileID);p.activeTexture.set(_.TEXTURE0),_.bindTexture(_.TEXTURE_2D,F.texture);const V=y.transform.calculatePosMatrix(C.tileID.toUnwrapped()),W=n.getMeshFrameDelta(y.transform.zoom),K=y.transform.calculateFogMatrix(C.tileID.toUnwrapped()),se=Ol(V,W,K,y.style.sky,y.transform.pitch);A.draw(p,_.TRIANGLES,T,Vi.disabled,m,Pi.backCCW,se,N,"terrain",R.vertexBuffer,R.indexBuffer,R.segments)}}class zp{constructor(n,u,p){this.vertexBuffer=n,this.indexBuffer=u,this.segments=p}destroy(){this.vertexBuffer.destroy(),this.indexBuffer.destroy(),this.segments.destroy(),this.vertexBuffer=null,this.indexBuffer=null,this.segments=null}}class Lp{constructor(n,u){this.context=new Zu(n),this.transform=u,this._tileTextures={},this.terrainFacilitator={dirty:!0,matrix:c.ao(new Float64Array(16)),renderTime:0},this.setup(),this.numSublayers=Rt.maxUnderzooming+Rt.maxOverzooming+1,this.depthEpsilon=1/Math.pow(2,16),this.crossTileSymbolIndex=new zr}resize(n,u,p){if(this.width=Math.floor(n*p),this.height=Math.floor(u*p),this.pixelRatio=p,this.context.viewport.set([0,0,this.width,this.height]),this.style)for(const _ of this.style._order)this.style._layers[_].resize()}setup(){const n=this.context,u=new c.aX;u.emplaceBack(0,0),u.emplaceBack(c.X,0),u.emplaceBack(0,c.X),u.emplaceBack(c.X,c.X),this.tileExtentBuffer=n.createVertexBuffer(u,Zo.members),this.tileExtentSegments=c.a0.simpleSegment(0,0,4,2);const p=new c.aX;p.emplaceBack(0,0),p.emplaceBack(c.X,0),p.emplaceBack(0,c.X),p.emplaceBack(c.X,c.X),this.debugBuffer=n.createVertexBuffer(p,Zo.members),this.debugSegments=c.a0.simpleSegment(0,0,4,5);const _=new c.$;_.emplaceBack(0,0,0,0),_.emplaceBack(c.X,0,c.X,0),_.emplaceBack(0,c.X,0,c.X),_.emplaceBack(c.X,c.X,c.X,c.X),this.rasterBoundsBuffer=n.createVertexBuffer(_,He.members),this.rasterBoundsSegments=c.a0.simpleSegment(0,0,4,2);const m=new c.aX;m.emplaceBack(0,0),m.emplaceBack(1,0),m.emplaceBack(0,1),m.emplaceBack(1,1),this.viewportBuffer=n.createVertexBuffer(m,Zo.members),this.viewportSegments=c.a0.simpleSegment(0,0,4,2);const T=new c.aZ;T.emplaceBack(0),T.emplaceBack(1),T.emplaceBack(3),T.emplaceBack(2),T.emplaceBack(0),this.tileBorderIndexBuffer=n.createIndexBuffer(T);const A=new c.aY;A.emplaceBack(0,1,2),A.emplaceBack(2,1,3),this.quadTriangleIndexBuffer=n.createIndexBuffer(A);const R=this.context.gl;this.stencilClearMode=new Vi({func:R.ALWAYS,mask:0},0,255,R.ZERO,R.ZERO,R.ZERO)}clearStencil(){const n=this.context,u=n.gl;this.nextStencilID=1,this.currentStencilSource=void 0;const p=c.H();c.aQ(p,0,this.width,this.height,0,0,1),c.K(p,p,[u.drawingBufferWidth,u.drawingBufferHeight,0]),this.useProgram("clippingMask").draw(n,u.TRIANGLES,Yt.disabled,this.stencilClearMode,wi.disabled,Pi.disabled,Fl(p),null,"$clipping",this.viewportBuffer,this.quadTriangleIndexBuffer,this.viewportSegments)}_renderTileClippingMasks(n,u){if(this.currentStencilSource===n.source||!n.isTileClipped()||!u||!u.length)return;this.currentStencilSource=n.source;const p=this.context,_=p.gl;this.nextStencilID+u.length>256&&this.clearStencil(),p.setColorMode(wi.disabled),p.setDepthMode(Yt.disabled);const m=this.useProgram("clippingMask");this._tileClippingMaskIDs={};for(const T of u){const A=this._tileClippingMaskIDs[T.key]=this.nextStencilID++,R=this.style.map.terrain&&this.style.map.terrain.getTerrainData(T);m.draw(p,_.TRIANGLES,Yt.disabled,new Vi({func:_.ALWAYS,mask:0},A,255,_.KEEP,_.KEEP,_.REPLACE),wi.disabled,Pi.disabled,Fl(T.posMatrix),R,"$clipping",this.tileExtentBuffer,this.quadTriangleIndexBuffer,this.tileExtentSegments)}}stencilModeFor3D(){this.currentStencilSource=void 0,this.nextStencilID+1>256&&this.clearStencil();const n=this.nextStencilID++,u=this.context.gl;return new Vi({func:u.NOTEQUAL,mask:255},n,255,u.KEEP,u.KEEP,u.REPLACE)}stencilModeForClipping(n){const u=this.context.gl;return new Vi({func:u.EQUAL,mask:255},this._tileClippingMaskIDs[n.key],0,u.KEEP,u.KEEP,u.REPLACE)}stencilConfigForOverlap(n){const u=this.context.gl,p=n.sort((T,A)=>A.overscaledZ-T.overscaledZ),_=p[p.length-1].overscaledZ,m=p[0].overscaledZ-_+1;if(m>1){this.currentStencilSource=void 0,this.nextStencilID+m>256&&this.clearStencil();const T={};for(let A=0;A({u_sky_color:de.properties.get("sky-color"),u_horizon_color:de.properties.get("horizon-color"),u_horizon:(ee.height/2+ee.getHorizon())*me,u_sky_horizon_blend:de.properties.get("sky-horizon-blend")*ee.height/2*me}))(F,C.style.map.transform,C.pixelRatio),K=new Yt(V.LEQUAL,Yt.ReadWrite,[0,1]),se=Vi.disabled,ie=C.colorModeForRenderPass(),oe=C.useProgram("sky");if(!F.mesh){const de=new c.aX;de.emplaceBack(-1,-1),de.emplaceBack(1,-1),de.emplaceBack(1,1),de.emplaceBack(-1,1);const ee=new c.aY;ee.emplaceBack(0,1,2),ee.emplaceBack(0,2,3),F.mesh=new zp(N.createVertexBuffer(de,Zo.members),N.createIndexBuffer(ee),c.a0.simpleSegment(0,0,de.length,ee.length))}oe.draw(N,V.TRIANGLES,K,se,ie,Pi.disabled,W,void 0,"sky",F.mesh.vertexBuffer,F.mesh.indexBuffer,F.mesh.segments)}(this,this.style.sky),this._showOverdrawInspector=u.showOverdrawInspector,this.depthRangeFor3D=[0,1-(n._order.length+2)*this.numSublayers*this.depthEpsilon],!this.renderToTexture)for(this.renderPass="opaque",this.currentLayer=_.length-1;this.currentLayer>=0;this.currentLayer--){const C=this.style._layers[_[this.currentLayer]],F=m[C.source],N=T[C.source];this._renderTileClippingMasks(C,N),this.renderLayer(this,F,C,N)}for(this.renderPass="translucent",this.currentLayer=0;this.currentLayer<_.length;this.currentLayer++){const C=this.style._layers[_[this.currentLayer]],F=m[C.source];if(this.renderToTexture&&this.renderToTexture.renderLayer(C))continue;const N=(C.type==="symbol"?R:A)[C.source];this._renderTileClippingMasks(C,T[C.source]),this.renderLayer(this,F,C,N)}if(this.options.showTileBoundaries){const C=function(F,N){let V=null;const W=Object.values(F._layers).flatMap(oe=>oe.source&&!oe.isHidden(N)?[F.sourceCaches[oe.source]]:[]),K=W.filter(oe=>oe.getSource().type==="vector"),se=W.filter(oe=>oe.getSource().type!=="vector"),ie=oe=>{(!V||V.getSource().maxzoomie(oe)),V||se.forEach(oe=>ie(oe)),V}(this.style,this.transform.zoom);C&&function(F,N,V){for(let W=0;W0),_&&(c.b0(u,p),this.terrainFacilitator.renderTime=Date.now(),this.terrainFacilitator.dirty=!1,function(m,T){const A=m.context,R=A.gl,C=wi.unblended,F=new Yt(R.LEQUAL,Yt.ReadWrite,[0,1]),N=T.getTerrainMesh(),V=T.sourceCache.getRenderableTiles(),W=m.useProgram("terrainDepth");A.bindFramebuffer.set(T.getFramebuffer("depth").framebuffer),A.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),A.clear({color:c.aN.transparent,depth:1});for(const K of V){const se=T.getTerrainData(K.tileID),ie={u_matrix:m.transform.calculatePosMatrix(K.tileID.toUnwrapped()),u_ele_delta:T.getMeshFrameDelta(m.transform.zoom)};W.draw(A,R.TRIANGLES,F,Vi.disabled,C,Pi.backCCW,ie,se,"terrain",N.vertexBuffer,N.indexBuffer,N.segments)}A.bindFramebuffer.set(null),A.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain),function(m,T){const A=m.context,R=A.gl,C=wi.unblended,F=new Yt(R.LEQUAL,Yt.ReadWrite,[0,1]),N=T.getTerrainMesh(),V=T.getCoordsTexture(),W=T.sourceCache.getRenderableTiles(),K=m.useProgram("terrainCoords");A.bindFramebuffer.set(T.getFramebuffer("coords").framebuffer),A.viewport.set([0,0,m.width/devicePixelRatio,m.height/devicePixelRatio]),A.clear({color:c.aN.transparent,depth:1}),T.coordsIndex=[];for(const se of W){const ie=T.getTerrainData(se.tileID);A.activeTexture.set(R.TEXTURE0),R.bindTexture(R.TEXTURE_2D,V.texture);const oe={u_matrix:m.transform.calculatePosMatrix(se.tileID.toUnwrapped()),u_terrain_coords_id:(255-T.coordsIndex.length)/255,u_texture:0,u_ele_delta:T.getMeshFrameDelta(m.transform.zoom)};K.draw(A,R.TRIANGLES,F,Vi.disabled,C,Pi.backCCW,oe,ie,"terrain",N.vertexBuffer,N.indexBuffer,N.segments),T.coordsIndex.push(se.tileID.key)}A.bindFramebuffer.set(null),A.viewport.set([0,0,m.width,m.height])}(this,this.style.map.terrain))}renderLayer(n,u,p,_){if(!p.isHidden(this.transform.zoom)&&(p.type==="background"||p.type==="custom"||(_||[]).length))switch(this.id=p.id,p.type){case"symbol":(function(m,T,A,R,C){if(m.renderPass!=="translucent")return;const F=Vi.disabled,N=m.colorModeForRenderPass();(A._unevaluatedLayout.hasValue("text-variable-anchor")||A._unevaluatedLayout.hasValue("text-variable-anchor-offset"))&&function(V,W,K,se,ie,oe,de,ee,me){const Ae=W.transform,Re=qo(),Le=ie==="map",Ze=oe==="map";for(const ct of V){const dt=se.getTile(ct),Ye=dt.getBucket(K);if(!Ye||!Ye.text||!Ye.text.segments.get().length)continue;const Qe=c.ah(Ye.textSizeData,Ae.zoom),yt=Lt(dt,1,W.transform.zoom),Ut=nn(ct.posMatrix,Ze,Le,W.transform,yt),tt=K.layout.get("icon-text-fit")!=="none"&&Ye.hasIconData();if(Qe){const nt=Math.pow(2,Ae.zoom-dt.tileID.overscaledZ),Ot=W.style.map.terrain?(Ht,Kt)=>W.style.map.terrain.getElevation(ct,Ht,Kt):null,Ci=Re.translatePosition(Ae,dt,de,ee);th(Ye,Le,Ze,me,Ae,Ut,ct.posMatrix,nt,Qe,tt,Re,Ci,ct.toUnwrapped(),Ot)}}}(R,m,A,T,A.layout.get("text-rotation-alignment"),A.layout.get("text-pitch-alignment"),A.paint.get("text-translate"),A.paint.get("text-translate-anchor"),C),A.paint.get("icon-opacity").constantOr(1)!==0&&ho(m,T,A,R,!1,A.paint.get("icon-translate"),A.paint.get("icon-translate-anchor"),A.layout.get("icon-rotation-alignment"),A.layout.get("icon-pitch-alignment"),A.layout.get("icon-keep-upright"),F,N),A.paint.get("text-opacity").constantOr(1)!==0&&ho(m,T,A,R,!0,A.paint.get("text-translate"),A.paint.get("text-translate-anchor"),A.layout.get("text-rotation-alignment"),A.layout.get("text-pitch-alignment"),A.layout.get("text-keep-upright"),F,N),T.map.showCollisionBoxes&&(Np(m,T,A,R,!0),Np(m,T,A,R,!1))})(n,u,p,_,this.style.placement.variableOffsets);break;case"circle":(function(m,T,A,R){if(m.renderPass!=="translucent")return;const C=A.paint.get("circle-opacity"),F=A.paint.get("circle-stroke-width"),N=A.paint.get("circle-stroke-opacity"),V=!A.layout.get("circle-sort-key").isConstant();if(C.constantOr(1)===0&&(F.constantOr(1)===0||N.constantOr(1)===0))return;const W=m.context,K=W.gl,se=m.depthModeForSublayer(0,Yt.ReadOnly),ie=Vi.disabled,oe=m.colorModeForRenderPass(),de=[];for(let ee=0;eeee.sortKey-me.sortKey);for(const ee of de){const{programConfiguration:me,program:Ae,layoutVertexBuffer:Re,indexBuffer:Le,uniformValues:Ze,terrainData:ct}=ee.state;Ae.draw(W,K.TRIANGLES,se,ie,oe,Pi.disabled,Ze,ct,A.id,Re,Le,ee.segments,A.paint,m.transform.zoom,me)}})(n,u,p,_);break;case"heatmap":(function(m,T,A,R){if(A.paint.get("heatmap-opacity")!==0)if(m.renderPass==="offscreen"){const C=m.context,F=C.gl,N=Vi.disabled,V=new wi([F.ONE,F.ONE],c.aN.transparent,[!0,!0,!0,!0]);(function(W,K,se){const ie=W.gl;W.activeTexture.set(ie.TEXTURE1),W.viewport.set([0,0,K.width/4,K.height/4]);let oe=se.heatmapFbo;if(oe)ie.bindTexture(ie.TEXTURE_2D,oe.colorAttachment.get()),W.bindFramebuffer.set(oe.framebuffer);else{const de=ie.createTexture();ie.bindTexture(ie.TEXTURE_2D,de),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_S,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_WRAP_T,ie.CLAMP_TO_EDGE),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MIN_FILTER,ie.LINEAR),ie.texParameteri(ie.TEXTURE_2D,ie.TEXTURE_MAG_FILTER,ie.LINEAR),oe=se.heatmapFbo=W.createFramebuffer(K.width/4,K.height/4,!1,!1),function(ee,me,Ae,Re){var Le,Ze;const ct=ee.gl,dt=(Le=ee.HALF_FLOAT)!==null&&Le!==void 0?Le:ct.UNSIGNED_BYTE,Ye=(Ze=ee.RGBA16F)!==null&&Ze!==void 0?Ze:ct.RGBA;ct.texImage2D(ct.TEXTURE_2D,0,Ye,me.width/4,me.height/4,0,ct.RGBA,dt,null),Re.colorAttachment.set(Ae)}(W,K,de,oe)}})(C,m,A),C.clear({color:c.aN.transparent});for(let W=0;W{const ee=c.H();c.aQ(ee,0,se.width,se.height,0,0,1);const me=se.context.gl;return{u_matrix:ee,u_world:[me.drawingBufferWidth,me.drawingBufferHeight],u_image:0,u_color_ramp:1,u_opacity:ie.paint.get("heatmap-opacity")}})(C,F),null,F.id,C.viewportBuffer,C.quadTriangleIndexBuffer,C.viewportSegments,F.paint,C.transform.zoom)}(m,A))})(n,u,p,_);break;case"line":(function(m,T,A,R){if(m.renderPass!=="translucent")return;const C=A.paint.get("line-opacity"),F=A.paint.get("line-width");if(C.constantOr(1)===0||F.constantOr(1)===0)return;const N=m.depthModeForSublayer(0,Yt.ReadOnly),V=m.colorModeForRenderPass(),W=A.paint.get("line-dasharray"),K=A.paint.get("line-pattern"),se=K.constantOr(1),ie=A.paint.get("line-gradient"),oe=A.getCrossfadeParameters(),de=se?"linePattern":W?"lineSDF":ie?"lineGradient":"line",ee=m.context,me=ee.gl;let Ae=!0;for(const Re of R){const Le=T.getTile(Re);if(se&&!Le.patternsLoaded())continue;const Ze=Le.getBucket(A);if(!Ze)continue;const ct=Ze.programConfigurations.get(A.id),dt=m.context.program.get(),Ye=m.useProgram(de,ct),Qe=Ae||Ye.program!==dt,yt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Re),Ut=K.constantOr(null);if(Ut&&Le.imageAtlas){const Ot=Le.imageAtlas,Ci=Ot.patternPositions[Ut.to.toString()],Ht=Ot.patternPositions[Ut.from.toString()];Ci&&Ht&&ct.setConstantPatternPositions(Ci,Ht)}const tt=yt?Re:null,nt=se?yp(m,Le,A,oe,tt):W?bp(m,Le,A,W,oe,tt):ie?qc(m,Le,A,Ze.lineClipsArray.length,tt):Nl(m,Le,A,tt);if(se)ee.activeTexture.set(me.TEXTURE0),Le.imageAtlasTexture.bind(me.LINEAR,me.CLAMP_TO_EDGE),ct.updatePaintBuffers(oe);else if(W&&(Qe||m.lineAtlas.dirty))ee.activeTexture.set(me.TEXTURE0),m.lineAtlas.bind(ee);else if(ie){const Ot=Ze.gradients[A.id];let Ci=Ot.texture;if(A.gradientVersion!==Ot.version){let Ht=256;if(A.stepInterpolant){const Kt=T.getSource().maxzoom,Mi=Re.canonical.z===Kt?Math.ceil(1<20&&F.texParameterf(F.TEXTURE_2D,C.extTextureFilterAnisotropic.TEXTURE_MAX_ANISOTROPY_EXT,C.extTextureFilterAnisotropicMax);const Ye=m.style.map.terrain&&m.style.map.terrain.getTerrainData(de),Qe=Ye?de:null,yt=Qe?Qe.posMatrix:m.transform.calculatePosMatrix(de.toUnwrapped(),oe),Ut=yy(yt,ct||[0,0],Ze||1,Le,A);N instanceof ft?V.draw(C,F.TRIANGLES,ee,Vi.disabled,W,Pi.disabled,Ut,Ye,A.id,N.boundsBuffer,m.quadTriangleIndexBuffer,N.boundsSegments):V.draw(C,F.TRIANGLES,ee,K[de.overscaledZ],W,Pi.disabled,Ut,Ye,A.id,m.rasterBoundsBuffer,m.quadTriangleIndexBuffer,m.rasterBoundsSegments)}})(n,u,p,_);break;case"background":(function(m,T,A,R){const C=A.paint.get("background-color"),F=A.paint.get("background-opacity");if(F===0)return;const N=m.context,V=N.gl,W=m.transform,K=W.tileSize,se=A.paint.get("background-pattern");if(m.isPatternMissing(se))return;const ie=!se&&C.a===1&&F===1&&m.opaquePassEnabledForLayer()?"opaque":"translucent";if(m.renderPass!==ie)return;const oe=Vi.disabled,de=m.depthModeForSublayer(0,ie==="opaque"?Yt.ReadWrite:Yt.ReadOnly),ee=m.colorModeForRenderPass(),me=m.useProgram(se?"backgroundPattern":"background"),Ae=R||W.coveringTiles({tileSize:K,terrain:m.style.map.terrain});se&&(N.activeTexture.set(V.TEXTURE0),m.imageManager.bind(m.context));const Re=A.getCrossfadeParameters();for(const Le of Ae){const Ze=R?Le.posMatrix:m.transform.calculatePosMatrix(Le.toUnwrapped()),ct=se?Lu(Ze,F,m,se,{tileID:Le,tileSize:K},Re):Zc(Ze,F,C),dt=m.style.map.terrain&&m.style.map.terrain.getTerrainData(Le);me.draw(N,V.TRIANGLES,de,oe,ee,Pi.disabled,ct,dt,A.id,m.tileExtentBuffer,m.quadTriangleIndexBuffer,m.tileExtentSegments)}})(n,0,p,_);break;case"custom":(function(m,T,A){const R=m.context,C=A.implementation;if(m.renderPass==="offscreen"){const F=C.prerender;F&&(m.setCustomLayerDefaults(),R.setColorMode(m.colorModeForRenderPass()),F.call(C,R.gl,m.transform.customLayerMatrix()),R.setDirty(),m.setBaseState())}else if(m.renderPass==="translucent"){m.setCustomLayerDefaults(),R.setColorMode(m.colorModeForRenderPass()),R.setStencilMode(Vi.disabled);const F=C.renderingMode==="3d"?new Yt(m.context.gl.LEQUAL,Yt.ReadWrite,m.depthRangeFor3D):m.depthModeForSublayer(0,Yt.ReadOnly);R.setDepthMode(F),C.render(R.gl,m.transform.customLayerMatrix(),{farZ:m.transform.farZ,nearZ:m.transform.nearZ,fov:m.transform._fov,modelViewProjectionMatrix:m.transform.modelViewProjectionMatrix,projectionMatrix:m.transform.projectionMatrix}),R.setDirty(),m.setBaseState(),R.bindFramebuffer.set(null)}})(n,0,p)}}translatePosMatrix(n,u,p,_,m){if(!p[0]&&!p[1])return n;const T=m?_==="map"?this.transform.angle:0:_==="viewport"?-this.transform.angle:0;if(T){const C=Math.sin(T),F=Math.cos(T);p=[p[0]*F-p[1]*C,p[0]*C+p[1]*F]}const A=[m?p[0]:Lt(u,p[0],this.transform.zoom),m?p[1]:Lt(u,p[1],this.transform.zoom),0],R=new Float32Array(16);return c.J(R,n,A),R}saveTileTexture(n){const u=this._tileTextures[n.size[0]];u?u.push(n):this._tileTextures[n.size[0]]=[n]}getTileTexture(n){const u=this._tileTextures[n];return u&&u.length>0?u.pop():null}isPatternMissing(n){if(!n)return!1;if(!n.from||!n.to)return!0;const u=this.imageManager.getPattern(n.from.toString()),p=this.imageManager.getPattern(n.to.toString());return!u||!p}useProgram(n,u){this.cache=this.cache||{};const p=n+(u?u.cacheKey:"")+(this._showOverdrawInspector?"/overdraw":"")+(this.style.map.terrain?"/terrain":"");return this.cache[p]||(this.cache[p]=new $(this.context,on[n],u,Yc[n],this._showOverdrawInspector,this.style.map.terrain)),this.cache[p]}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 n=this.context.gl;this.context.cullFace.set(!1),this.context.viewport.set([0,0,this.width,this.height]),this.context.blendEquation.set(n.FUNC_ADD)}initDebugOverlayCanvas(){this.debugOverlayCanvas==null&&(this.debugOverlayCanvas=document.createElement("canvas"),this.debugOverlayCanvas.width=512,this.debugOverlayCanvas.height=512,this.debugOverlayTexture=new ut(this.context,this.debugOverlayCanvas,this.context.gl.RGBA))}destroy(){this.debugOverlayTexture&&this.debugOverlayTexture.destroy()}overLimit(){const{drawingBufferWidth:n,drawingBufferHeight:u}=this.context.gl;return this.width!==n||this.height!==u}}class ia{constructor(n,u){this.points=n,this.planes=u}static fromInvProjectionMatrix(n,u,p){const _=Math.pow(2,p),m=[[-1,1,-1,1],[1,1,-1,1],[1,-1,-1,1],[-1,-1,-1,1],[-1,1,1,1],[1,1,1,1],[1,-1,1,1],[-1,-1,1,1]].map(A=>{const R=1/(A=c.ag([],A,n))[3]/u*_;return c.b1(A,A,[R,R,1/A[3],R])}),T=[[0,1,2],[6,5,4],[0,3,7],[2,1,5],[3,2,6],[0,4,5]].map(A=>{const R=function(V,W){var K=W[0],se=W[1],ie=W[2],oe=K*K+se*se+ie*ie;return oe>0&&(oe=1/Math.sqrt(oe)),V[0]=W[0]*oe,V[1]=W[1]*oe,V[2]=W[2]*oe,V}([],function(V,W,K){var se=W[0],ie=W[1],oe=W[2],de=K[0],ee=K[1],me=K[2];return V[0]=ie*me-oe*ee,V[1]=oe*de-se*me,V[2]=se*ee-ie*de,V}([],rt([],m[A[0]],m[A[1]]),rt([],m[A[2]],m[A[1]]))),C=-((F=R)[0]*(N=m[A[1]])[0]+F[1]*N[1]+F[2]*N[2]);var F,N;return R.concat(C)});return new ia(m,T)}}class oh{constructor(n,u){this.min=n,this.max=u,this.center=function(p,_,m){return p[0]=.5*_[0],p[1]=.5*_[1],p[2]=.5*_[2],p}([],function(p,_,m){return p[0]=_[0]+m[0],p[1]=_[1]+m[1],p[2]=_[2]+m[2],p}([],this.min,this.max))}quadrant(n){const u=[n%2==0,n<2],p=je(this.min),_=je(this.max);for(let m=0;m=0&&T++;if(T===0)return 0;T!==u.length&&(p=!1)}if(p)return 2;for(let _=0;_<3;_++){let m=Number.MAX_VALUE,T=-Number.MAX_VALUE;for(let A=0;Athis.max[_]-this.min[_])return 0}return 1}}class ah{constructor(n=0,u=0,p=0,_=0){if(isNaN(n)||n<0||isNaN(u)||u<0||isNaN(p)||p<0||isNaN(_)||_<0)throw new Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=n,this.bottom=u,this.left=p,this.right=_}interpolate(n,u,p){return u.top!=null&&n.top!=null&&(this.top=c.z.number(n.top,u.top,p)),u.bottom!=null&&n.bottom!=null&&(this.bottom=c.z.number(n.bottom,u.bottom,p)),u.left!=null&&n.left!=null&&(this.left=c.z.number(n.left,u.left,p)),u.right!=null&&n.right!=null&&(this.right=c.z.number(n.right,u.right,p)),this}getCenter(n,u){const p=c.ad((this.left+n-this.right)/2,0,n),_=c.ad((this.top+u-this.bottom)/2,0,u);return new c.P(p,_)}equals(n){return this.top===n.top&&this.bottom===n.bottom&&this.left===n.left&&this.right===n.right}clone(){return new ah(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}}const td=85.051129;class id{constructor(n,u,p,_,m){this.tileSize=512,this._renderWorldCopies=m===void 0||!!m,this._minZoom=n||0,this._maxZoom=u||22,this._minPitch=p??0,this._maxPitch=_??60,this.setMaxBounds(),this.width=0,this.height=0,this._center=new c.N(0,0),this._elevation=0,this.zoom=0,this.angle=0,this._fov=.6435011087932844,this._pitch=0,this._unmodified=!0,this._edgeInsets=new ah,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={},this.minElevationForCurrentTile=0}clone(){const n=new id(this._minZoom,this._maxZoom,this._minPitch,this.maxPitch,this._renderWorldCopies);return n.apply(this),n}apply(n){this.tileSize=n.tileSize,this.latRange=n.latRange,this.width=n.width,this.height=n.height,this._center=n._center,this._elevation=n._elevation,this.minElevationForCurrentTile=n.minElevationForCurrentTile,this.zoom=n.zoom,this.angle=n.angle,this._fov=n._fov,this._pitch=n._pitch,this._unmodified=n._unmodified,this._edgeInsets=n._edgeInsets.clone(),this._calcMatrices()}get minZoom(){return this._minZoom}set minZoom(n){this._minZoom!==n&&(this._minZoom=n,this.zoom=Math.max(this.zoom,n))}get maxZoom(){return this._maxZoom}set maxZoom(n){this._maxZoom!==n&&(this._maxZoom=n,this.zoom=Math.min(this.zoom,n))}get minPitch(){return this._minPitch}set minPitch(n){this._minPitch!==n&&(this._minPitch=n,this.pitch=Math.max(this.pitch,n))}get maxPitch(){return this._maxPitch}set maxPitch(n){this._maxPitch!==n&&(this._maxPitch=n,this.pitch=Math.min(this.pitch,n))}get renderWorldCopies(){return this._renderWorldCopies}set renderWorldCopies(n){n===void 0?n=!0:n===null&&(n=!1),this._renderWorldCopies=n}get worldSize(){return this.tileSize*this.scale}get centerOffset(){return this.centerPoint._sub(this.size._div(2))}get size(){return new c.P(this.width,this.height)}get bearing(){return-this.angle/Math.PI*180}set bearing(n){const u=-c.b3(n,-180,180)*Math.PI/180;this.angle!==u&&(this._unmodified=!1,this.angle=u,this._calcMatrices(),this.rotationMatrix=function(){var p=new c.A(4);return c.A!=Float32Array&&(p[1]=0,p[2]=0),p[0]=1,p[3]=1,p}(),function(p,_,m){var T=_[0],A=_[1],R=_[2],C=_[3],F=Math.sin(m),N=Math.cos(m);p[0]=T*N+R*F,p[1]=A*N+C*F,p[2]=T*-F+R*N,p[3]=A*-F+C*N}(this.rotationMatrix,this.rotationMatrix,this.angle))}get pitch(){return this._pitch/Math.PI*180}set pitch(n){const u=c.ad(n,this.minPitch,this.maxPitch)/180*Math.PI;this._pitch!==u&&(this._unmodified=!1,this._pitch=u,this._calcMatrices())}get fov(){return this._fov/Math.PI*180}set fov(n){n=Math.max(.01,Math.min(60,n)),this._fov!==n&&(this._unmodified=!1,this._fov=n/180*Math.PI,this._calcMatrices())}get zoom(){return this._zoom}set zoom(n){const u=Math.min(Math.max(n,this.minZoom),this.maxZoom);this._zoom!==u&&(this._unmodified=!1,this._zoom=u,this.tileZoom=Math.max(0,Math.floor(u)),this.scale=this.zoomScale(u),this._constrain(),this._calcMatrices())}get center(){return this._center}set center(n){n.lat===this._center.lat&&n.lng===this._center.lng||(this._unmodified=!1,this._center=n,this._constrain(),this._calcMatrices())}get elevation(){return this._elevation}set elevation(n){n!==this._elevation&&(this._elevation=n,this._constrain(),this._calcMatrices())}get padding(){return this._edgeInsets.toJSON()}set padding(n){this._edgeInsets.equals(n)||(this._unmodified=!1,this._edgeInsets.interpolate(this._edgeInsets,n,1),this._calcMatrices())}get centerPoint(){return this._edgeInsets.getCenter(this.width,this.height)}isPaddingEqual(n){return this._edgeInsets.equals(n)}interpolatePadding(n,u,p){this._unmodified=!1,this._edgeInsets.interpolate(n,u,p),this._constrain(),this._calcMatrices()}coveringZoomLevel(n){const u=(n.roundZoom?Math.round:Math.floor)(this.zoom+this.scaleZoom(this.tileSize/n.tileSize));return Math.max(0,u)}getVisibleUnwrappedCoordinates(n){const u=[new c.b4(0,n)];if(this._renderWorldCopies){const p=this.pointCoordinate(new c.P(0,0)),_=this.pointCoordinate(new c.P(this.width,0)),m=this.pointCoordinate(new c.P(this.width,this.height)),T=this.pointCoordinate(new c.P(0,this.height)),A=Math.floor(Math.min(p.x,_.x,m.x,T.x)),R=Math.floor(Math.max(p.x,_.x,m.x,T.x)),C=1;for(let F=A-C;F<=R+C;F++)F!==0&&u.push(new c.b4(F,n))}return u}coveringTiles(n){var u,p;let _=this.coveringZoomLevel(n);const m=_;if(n.minzoom!==void 0&&_n.maxzoom&&(_=n.maxzoom);const T=this.pointCoordinate(this.getCameraPoint()),A=c.Z.fromLngLat(this.center),R=Math.pow(2,_),C=[R*T.x,R*T.y,0],F=[R*A.x,R*A.y,0],N=ia.fromInvProjectionMatrix(this.invModelViewProjectionMatrix,this.worldSize,_);let V=n.minzoom||0;!n.terrain&&this.pitch<=60&&this._edgeInsets.top<.1&&(V=_);const W=n.terrain?2/Math.min(this.tileSize,n.tileSize)*this.tileSize:3,K=ee=>({aabb:new oh([ee*R,0,0],[(ee+1)*R,R,0]),zoom:0,x:0,y:0,wrap:ee,fullyVisible:!1}),se=[],ie=[],oe=_,de=n.reparseOverscaled?m:_;if(this._renderWorldCopies)for(let ee=1;ee<=3;ee++)se.push(K(-ee)),se.push(K(ee));for(se.push(K(0));se.length>0;){const ee=se.pop(),me=ee.x,Ae=ee.y;let Re=ee.fullyVisible;if(!Re){const Ye=ee.aabb.intersects(N);if(Ye===0)continue;Re=Ye===2}const Le=n.terrain?C:F,Ze=ee.aabb.distanceX(Le),ct=ee.aabb.distanceY(Le),dt=Math.max(Math.abs(Ze),Math.abs(ct));if(ee.zoom===oe||dt>W+(1<=V){const Ye=oe-ee.zoom,Qe=C[0]-.5-(me<>1),Ut=ee.zoom+1;let tt=ee.aabb.quadrant(Ye);if(n.terrain){const nt=new c.S(Ut,ee.wrap,Ut,Qe,yt),Ot=n.terrain.getMinMaxElevation(nt),Ci=(u=Ot.minElevation)!==null&&u!==void 0?u:this.elevation,Ht=(p=Ot.maxElevation)!==null&&p!==void 0?p:this.elevation;tt=new oh([tt.min[0],tt.min[1],Ci],[tt.max[0],tt.max[1],Ht])}se.push({aabb:tt,zoom:Ut,x:Qe,y:yt,wrap:ee.wrap,fullyVisible:Re})}}return ie.sort((ee,me)=>ee.distanceSq-me.distanceSq).map(ee=>ee.tileID)}resize(n,u){this.width=n,this.height=u,this.pixelsToGLUnits=[2/n,-2/u],this._constrain(),this._calcMatrices()}get unmodified(){return this._unmodified}zoomScale(n){return Math.pow(2,n)}scaleZoom(n){return Math.log(n)/Math.LN2}project(n){const u=c.ad(n.lat,-85.051129,td);return new c.P(c.O(n.lng)*this.worldSize,c.Q(u)*this.worldSize)}unproject(n){return new c.Z(n.x/this.worldSize,n.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(n){const u=this.elevation,p=Math.cos(this._pitch)*this.cameraToCenterDistance/this._pixelPerMeter,_=this.pointLocation(this.centerPoint,n),m=n.getElevationForLngLatZoom(_,this.tileZoom);if(!(this.elevation-m))return;const T=p+u-m,A=Math.cos(this._pitch)*this.cameraToCenterDistance/T/c.b5(1,_.lat),R=this.scaleZoom(A/this.tileSize);this._elevation=m,this._center=_,this.zoom=R}setLocationAtPoint(n,u){const p=this.pointCoordinate(u),_=this.pointCoordinate(this.centerPoint),m=this.locationCoordinate(n),T=new c.Z(m.x-(p.x-_.x),m.y-(p.y-_.y));this.center=this.coordinateLocation(T),this._renderWorldCopies&&(this.center=this.center.wrap())}locationPoint(n,u){return u?this.coordinatePoint(this.locationCoordinate(n),u.getElevationForLngLatZoom(n,this.tileZoom),this.pixelMatrix3D):this.coordinatePoint(this.locationCoordinate(n))}pointLocation(n,u){return this.coordinateLocation(this.pointCoordinate(n,u))}locationCoordinate(n){return c.Z.fromLngLat(n)}coordinateLocation(n){return n&&n.toLngLat()}pointCoordinate(n,u){if(u){const V=u.pointCoordinate(n);if(V!=null)return V}const p=[n.x,n.y,0,1],_=[n.x,n.y,1,1];c.ag(p,p,this.pixelMatrixInverse),c.ag(_,_,this.pixelMatrixInverse);const m=p[3],T=_[3],A=p[1]/m,R=_[1]/T,C=p[2]/m,F=_[2]/T,N=C===F?0:(0-C)/(F-C);return new c.Z(c.z.number(p[0]/m,_[0]/T,N)/this.worldSize,c.z.number(A,R,N)/this.worldSize)}coordinatePoint(n,u=0,p=this.pixelMatrix){const _=[n.x*this.worldSize,n.y*this.worldSize,u,1];return c.ag(_,_,p),new c.P(_[0]/_[3],_[1]/_[3])}getBounds(){const n=Math.max(0,this.height/2-this.getHorizon());return new ae().extend(this.pointLocation(new c.P(0,n))).extend(this.pointLocation(new c.P(this.width,n))).extend(this.pointLocation(new c.P(this.width,this.height))).extend(this.pointLocation(new c.P(0,this.height)))}getMaxBounds(){return this.latRange&&this.latRange.length===2&&this.lngRange&&this.lngRange.length===2?new ae([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(n){n?(this.lngRange=[n.getWest(),n.getEast()],this.latRange=[n.getSouth(),n.getNorth()],this._constrain()):(this.lngRange=null,this.latRange=[-85.051129,td])}calculateTileMatrix(n){const u=n.canonical,p=this.worldSize/this.zoomScale(u.z),_=u.x+Math.pow(2,u.z)*n.wrap,m=c.ao(new Float64Array(16));return c.J(m,m,[_*p,u.y*p,0]),c.K(m,m,[p/c.X,p/c.X,1]),m}calculatePosMatrix(n,u=!1){const p=n.key,_=u?this._alignedPosMatrixCache:this._posMatrixCache;if(_[p])return _[p];const m=this.calculateTileMatrix(n);return c.L(m,u?this.alignedModelViewProjectionMatrix:this.modelViewProjectionMatrix,m),_[p]=new Float32Array(m),_[p]}calculateFogMatrix(n){const u=n.key,p=this._fogMatrixCache;if(p[u])return p[u];const _=this.calculateTileMatrix(n);return c.L(_,this.fogMatrix,_),p[u]=new Float32Array(_),p[u]}customLayerMatrix(){return this.mercatorMatrix.slice()}getConstrained(n,u){u=c.ad(+u,this.minZoom,this.maxZoom);const p={center:new c.N(n.lng,n.lat),zoom:u};let _=this.lngRange;if(!this._renderWorldCopies&&_===null){const ee=179.9999999999;_=[-ee,ee]}const m=this.tileSize*this.zoomScale(p.zoom);let T=0,A=m,R=0,C=m,F=0,N=0;const{x:V,y:W}=this.size;if(this.latRange){const ee=this.latRange;T=c.Q(ee[1])*m,A=c.Q(ee[0])*m,A-TA&&(oe=A-ee)}if(_){const ee=(R+C)/2;let me=K;this._renderWorldCopies&&(me=c.b3(K,ee-m/2,ee+m/2));const Ae=V/2;me-AeC&&(ie=C-Ae)}if(ie!==void 0||oe!==void 0){const ee=new c.P(ie??K,oe??se);p.center=this.unproject.call({worldSize:m},ee).wrap()}return p}_constrain(){if(!this.center||!this.width||!this.height||this._constraining)return;this._constraining=!0;const n=this._unmodified,{center:u,zoom:p}=this.getConstrained(this.center,this.zoom);this.center=u,this.zoom=p,this._unmodified=n,this._constraining=!1}_calcMatrices(){if(!this.height)return;const n=this.centerOffset,u=this.point.x,p=this.point.y;this.cameraToCenterDistance=.5/Math.tan(this._fov/2)*this.height,this._pixelPerMeter=c.b5(1,this.center.lat)*this.worldSize;let _=c.ao(new Float64Array(16));c.K(_,_,[this.width/2,-this.height/2,1]),c.J(_,_,[1,-1,0]),this.labelPlaneMatrix=_,_=c.ao(new Float64Array(16)),c.K(_,_,[1,-1,1]),c.J(_,_,[-1,-1,0]),c.K(_,_,[2/this.width,2/this.height,1]),this.glCoordMatrix=_;const m=this.cameraToCenterDistance+this._elevation*this._pixelPerMeter/Math.cos(this._pitch),T=Math.min(this.elevation,this.minElevationForCurrentTile),A=m-T*this._pixelPerMeter/Math.cos(this._pitch),R=T<0?A:m,C=Math.PI/2+this._pitch,F=this._fov*(.5+n.y/this.height),N=Math.sin(F)*R/Math.sin(c.ad(Math.PI-C-F,.01,Math.PI-.01)),V=this.getHorizon(),W=2*Math.atan(V/this.cameraToCenterDistance)*(.5+n.y/(2*V)),K=Math.sin(W)*R/Math.sin(c.ad(Math.PI-C-W,.01,Math.PI-.01)),se=Math.min(N,K);this.farZ=1.01*(Math.cos(Math.PI/2-this._pitch)*se+R),this.nearZ=this.height/50,_=new Float64Array(16),c.b6(_,this._fov,this.width/this.height,this.nearZ,this.farZ),_[8]=2*-n.x/this.width,_[9]=2*n.y/this.height,this.projectionMatrix=c.af(_),c.K(_,_,[1,-1,1]),c.J(_,_,[0,0,-this.cameraToCenterDistance]),c.b7(_,_,this._pitch),c.ae(_,_,this.angle),c.J(_,_,[-u,-p,0]),this.mercatorMatrix=c.K([],_,[this.worldSize,this.worldSize,this.worldSize]),c.K(_,_,[1,1,this._pixelPerMeter]),this.pixelMatrix=c.L(new Float64Array(16),this.labelPlaneMatrix,_),c.J(_,_,[0,0,-this.elevation]),this.modelViewProjectionMatrix=_,this.invModelViewProjectionMatrix=c.at([],_),this.fogMatrix=new Float64Array(16),c.b6(this.fogMatrix,this._fov,this.width/this.height,m,this.farZ),this.fogMatrix[8]=2*-n.x/this.width,this.fogMatrix[9]=2*n.y/this.height,c.K(this.fogMatrix,this.fogMatrix,[1,-1,1]),c.J(this.fogMatrix,this.fogMatrix,[0,0,-this.cameraToCenterDistance]),c.b7(this.fogMatrix,this.fogMatrix,this._pitch),c.ae(this.fogMatrix,this.fogMatrix,this.angle),c.J(this.fogMatrix,this.fogMatrix,[-u,-p,0]),c.K(this.fogMatrix,this.fogMatrix,[1,1,this._pixelPerMeter]),c.J(this.fogMatrix,this.fogMatrix,[0,0,-this.elevation]),this.pixelMatrix3D=c.L(new Float64Array(16),this.labelPlaneMatrix,_);const ie=this.width%2/2,oe=this.height%2/2,de=Math.cos(this.angle),ee=Math.sin(this.angle),me=u-Math.round(u)+de*ie+ee*oe,Ae=p-Math.round(p)+de*oe+ee*ie,Re=new Float64Array(_);if(c.J(Re,Re,[me>.5?me-1:me,Ae>.5?Ae-1:Ae,0]),this.alignedModelViewProjectionMatrix=Re,_=c.at(new Float64Array(16),this.pixelMatrix),!_)throw new Error("failed to invert matrix");this.pixelMatrixInverse=_,this._posMatrixCache={},this._alignedPosMatrixCache={},this._fogMatrixCache={}}maxPitchScaleFactor(){if(!this.pixelMatrixInverse)return 1;const n=this.pointCoordinate(new c.P(0,0)),u=[n.x*this.worldSize,n.y*this.worldSize,0,1];return c.ag(u,u,this.pixelMatrix)[3]/this.cameraToCenterDistance}getCameraPoint(){const n=Math.tan(this._pitch)*(this.cameraToCenterDistance||1);return this.centerPoint.add(new c.P(0,n))}getCameraQueryGeometry(n){const u=this.getCameraPoint();if(n.length===1)return[n[0],u];{let p=u.x,_=u.y,m=u.x,T=u.y;for(const A of n)p=Math.min(p,A.x),_=Math.min(_,A.y),m=Math.max(m,A.x),T=Math.max(T,A.y);return[new c.P(p,_),new c.P(m,_),new c.P(m,T),new c.P(p,T),new c.P(p,_)]}}lngLatToCameraDepth(n,u){const p=this.locationCoordinate(n),_=[p.x*this.worldSize,p.y*this.worldSize,u,1];return c.ag(_,_,this.modelViewProjectionMatrix),_[2]/_[3]}}function lh(y,n){let u,p=!1,_=null,m=null;const T=()=>{_=null,p&&(y.apply(m,u),_=setTimeout(T,n),p=!1)};return(...A)=>(p=!0,m=this,u=A,_||T(),_)}class $l{constructor(n){this._getCurrentHash=()=>{const u=window.location.hash.replace("#","");if(this._hashName){let p;return u.split("&").map(_=>_.split("=")).forEach(_=>{_[0]===this._hashName&&(p=_)}),(p&&p[1]||"").split("/")}return u.split("/")},this._onHashChange=()=>{const u=this._getCurrentHash();if(u.length>=3&&!u.some(p=>isNaN(p))){const p=this._map.dragRotate.isEnabled()&&this._map.touchZoomRotate.isEnabled()?+(u[3]||0):this._map.getBearing();return this._map.jumpTo({center:[+u[2],+u[1]],zoom:+u[0],bearing:p,pitch:+(u[4]||0)}),!0}return!1},this._updateHashUnthrottled=()=>{const u=window.location.href.replace(/(#.+)?$/,this.getHashString());window.history.replaceState(window.history.state,null,u)},this._removeHash=()=>{const u=this._getCurrentHash();if(u.length===0)return;const p=u.join("/");let _=p;_.split("&").length>0&&(_=_.split("&")[0]),this._hashName&&(_=`${this._hashName}=${p}`);let m=window.location.hash.replace(_,"");m.startsWith("#&")?m=m.slice(0,1)+m.slice(2):m==="#"&&(m="");let T=window.location.href.replace(/(#.+)?$/,m);T=T.replace("&&","&"),window.history.replaceState(window.history.state,null,T)},this._updateHash=lh(this._updateHashUnthrottled,300),this._hashName=n&&encodeURIComponent(n)}addTo(n){return this._map=n,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(n){const u=this._map.getCenter(),p=Math.round(100*this._map.getZoom())/100,_=Math.ceil((p*Math.LN2+Math.log(512/360/.5))/Math.LN10),m=Math.pow(10,_),T=Math.round(u.lng*m)/m,A=Math.round(u.lat*m)/m,R=this._map.getBearing(),C=this._map.getPitch();let F="";if(F+=n?`/${T}/${A}/${p}`:`${p}/${A}/${T}`,(R||C)&&(F+="/"+Math.round(10*R)/10),C&&(F+=`/${Math.round(C)}`),this._hashName){const N=this._hashName;let V=!1;const W=window.location.hash.slice(1).split("&").map(K=>{const se=K.split("=")[0];return se===N?(V=!0,`${se}=${F}`):K}).filter(K=>K);return V||W.push(`${N}=${F}`),`#${W.join("&")}`}return`#${F}`}}const ra={linearity:.3,easing:c.b8(0,0,.3,1)},rd=c.e({deceleration:2500,maxSpeed:1400},ra),sd=c.e({deceleration:20,maxSpeed:1400},ra),Up=c.e({deceleration:1e3,maxSpeed:360},ra),ch=c.e({deceleration:1e3,maxSpeed:90},ra);class hh{constructor(n){this._map=n,this.clear()}clear(){this._inertiaBuffer=[]}record(n){this._drainInertiaBuffer(),this._inertiaBuffer.push({time:M.now(),settings:n})}_drainInertiaBuffer(){const n=this._inertiaBuffer,u=M.now();for(;n.length>0&&u-n[0].time>160;)n.shift()}_onMoveEnd(n){if(this._drainInertiaBuffer(),this._inertiaBuffer.length<2)return;const u={zoom:0,bearing:0,pitch:0,pan:new c.P(0,0),pinchAround:void 0,around:void 0};for(const{settings:m}of this._inertiaBuffer)u.zoom+=m.zoomDelta||0,u.bearing+=m.bearingDelta||0,u.pitch+=m.pitchDelta||0,m.panDelta&&u.pan._add(m.panDelta),m.around&&(u.around=m.around),m.pinchAround&&(u.pinchAround=m.pinchAround);const p=this._inertiaBuffer[this._inertiaBuffer.length-1].time-this._inertiaBuffer[0].time,_={};if(u.pan.mag()){const m=uh(u.pan.mag(),p,c.e({},rd,n||{}));_.offset=u.pan.mult(m.amount/u.pan.mag()),_.center=this._map.transform.center,Ca(_,m)}if(u.zoom){const m=uh(u.zoom,p,sd);_.zoom=this._map.transform.zoom+m.amount,Ca(_,m)}if(u.bearing){const m=uh(u.bearing,p,Up);_.bearing=this._map.transform.bearing+c.ad(m.amount,-179,179),Ca(_,m)}if(u.pitch){const m=uh(u.pitch,p,ch);_.pitch=this._map.transform.pitch+m.amount,Ca(_,m)}if(_.zoom||_.bearing){const m=u.pinchAround===void 0?u.around:u.pinchAround;_.around=m?this._map.unproject(m):this._map.getCenter()}return this.clear(),c.e(_,{noMoveStart:!0})}}function Ca(y,n){(!y.duration||y.durationu.unproject(R)),A=m.reduce((R,C,F,N)=>R.add(C.div(N.length)),new c.P(0,0));super(n,{points:m,point:A,lngLats:T,lngLat:u.unproject(A),originalEvent:p}),this._defaultPrevented=!1}}class nd extends c.k{preventDefault(){this._defaultPrevented=!0}get defaultPrevented(){return this._defaultPrevented}constructor(n,u,p){super(n,{originalEvent:p}),this._defaultPrevented=!1}}class dh{constructor(n,u){this._map=n,this._clickTolerance=u.clickTolerance}reset(){delete this._mousedownPos}wheel(n){return this._firePreventable(new nd(n.type,this._map,n))}mousedown(n,u){return this._mousedownPos=u,this._firePreventable(new Gr(n.type,this._map,n))}mouseup(n){this._map.fire(new Gr(n.type,this._map,n))}click(n,u){this._mousedownPos&&this._mousedownPos.dist(u)>=this._clickTolerance||this._map.fire(new Gr(n.type,this._map,n))}dblclick(n){return this._firePreventable(new Gr(n.type,this._map,n))}mouseover(n){this._map.fire(new Gr(n.type,this._map,n))}mouseout(n){this._map.fire(new Gr(n.type,this._map,n))}touchstart(n){return this._firePreventable(new Wl(n.type,this._map,n))}touchmove(n){this._map.fire(new Wl(n.type,this._map,n))}touchend(n){this._map.fire(new Wl(n.type,this._map,n))}touchcancel(n){this._map.fire(new Wl(n.type,this._map,n))}_firePreventable(n){if(this._map.fire(n),n.defaultPrevented)return{}}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class od{constructor(n){this._map=n}reset(){this._delayContextMenu=!1,this._ignoreContextMenu=!0,delete this._contextMenuEvent}mousemove(n){this._map.fire(new Gr(n.type,this._map,n))}mousedown(){this._delayContextMenu=!0,this._ignoreContextMenu=!1}mouseup(){this._delayContextMenu=!1,this._contextMenuEvent&&(this._map.fire(new Gr("contextmenu",this._map,this._contextMenuEvent)),delete this._contextMenuEvent)}contextmenu(n){this._delayContextMenu?this._contextMenuEvent=n:this._ignoreContextMenu||this._map.fire(new Gr(n.type,this._map,n)),this._map.listens("contextmenu")&&n.preventDefault()}isEnabled(){return!0}isActive(){return!1}enable(){}disable(){}}class Ma{constructor(n){this._map=n}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(n){return this.transform.pointLocation(c.P.convert(n),this._map.terrain)}}class ad{constructor(n,u){this._map=n,this._tr=new Ma(n),this._el=n.getCanvasContainer(),this._container=n.getContainer(),this._clickTolerance=u.clickTolerance||1}isEnabled(){return!!this._enabled}isActive(){return!!this._active}enable(){this.isEnabled()||(this._enabled=!0)}disable(){this.isEnabled()&&(this._enabled=!1)}mousedown(n,u){this.isEnabled()&&n.shiftKey&&n.button===0&&(D.disableDrag(),this._startPos=this._lastPos=u,this._active=!0)}mousemoveWindow(n,u){if(!this._active)return;const p=u;if(this._lastPos.equals(p)||!this._box&&p.dist(this._startPos)m.fitScreenCoordinates(p,_,this._tr.bearing,{linear:!0})};this._fireEvent("boxzoomcancel",n)}keydown(n){this._active&&n.keyCode===27&&(this.reset(),this._fireEvent("boxzoomcancel",n))}reset(){this._active=!1,this._container.classList.remove("maplibregl-crosshair"),this._box&&(D.remove(this._box),this._box=null),D.enableDrag(),delete this._startPos,delete this._lastPos}_fireEvent(n,u){return this._map.fire(new c.k(n,{originalEvent:u}))}}function ka(y,n){if(y.length!==n.length)throw new Error(`The number of touches and points are not equal - touches ${y.length}, points ${n.length}`);const u={};for(let p=0;pthis.numTouches)&&(this.aborted=!0),this.aborted||(this.startTime===void 0&&(this.startTime=n.timeStamp),p.length===this.numTouches&&(this.centroid=function(_){const m=new c.P(0,0);for(const T of _)m._add(T);return m.div(_.length)}(u),this.touches=ka(p,u)))}touchmove(n,u,p){if(this.aborted||!this.centroid)return;const _=ka(p,u);for(const m in this.touches){const T=_[m];(!T||T.dist(this.touches[m])>30)&&(this.aborted=!0)}}touchend(n,u,p){if((!this.centroid||n.timeStamp-this.startTime>500)&&(this.aborted=!0),p.length===0){const _=!this.aborted&&this.centroid;if(this.reset(),_)return _}}}class cd{constructor(n){this.singleTap=new ld(n),this.numTaps=n.numTaps,this.reset()}reset(){this.lastTime=1/0,delete this.lastTap,this.count=0,this.singleTap.reset()}touchstart(n,u,p){this.singleTap.touchstart(n,u,p)}touchmove(n,u,p){this.singleTap.touchmove(n,u,p)}touchend(n,u,p){const _=this.singleTap.touchend(n,u,p);if(_){const m=n.timeStamp-this.lastTime<500,T=!this.lastTap||this.lastTap.dist(_)<30;if(m&&T||this.reset(),this.count++,this.lastTime=n.timeStamp,this.lastTap=_,this.count===this.numTaps)return this.reset(),_}}}class Vp{constructor(n){this._tr=new Ma(n),this._zoomIn=new cd({numTouches:1,numTaps:2}),this._zoomOut=new cd({numTouches:2,numTaps:1}),this.reset()}reset(){this._active=!1,this._zoomIn.reset(),this._zoomOut.reset()}touchstart(n,u,p){this._zoomIn.touchstart(n,u,p),this._zoomOut.touchstart(n,u,p)}touchmove(n,u,p){this._zoomIn.touchmove(n,u,p),this._zoomOut.touchmove(n,u,p)}touchend(n,u,p){const _=this._zoomIn.touchend(n,u,p),m=this._zoomOut.touchend(n,u,p),T=this._tr;return _?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:A=>A.easeTo({duration:300,zoom:T.zoom+1,around:T.unproject(_)},{originalEvent:n})}):m?(this._active=!0,n.preventDefault(),setTimeout(()=>this.reset(),0),{cameraAnimation:A=>A.easeTo({duration:300,zoom:T.zoom-1,around:T.unproject(m)},{originalEvent:n})}):void 0}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Ri{constructor(n){this._enabled=!!n.enable,this._moveStateManager=n.moveStateManager,this._clickTolerance=n.clickTolerance||1,this._moveFunction=n.move,this._activateOnStart=!!n.activateOnStart,n.assignEvents(this),this.reset()}reset(n){this._active=!1,this._moved=!1,delete this._lastPoint,this._moveStateManager.endMove(n)}_move(...n){const u=this._moveFunction(...n);if(u.bearingDelta||u.pitchDelta||u.around||u.panDelta)return this._active=!0,u}dragStart(n,u){this.isEnabled()&&!this._lastPoint&&this._moveStateManager.isValidStartEvent(n)&&(this._moveStateManager.startMove(n),this._lastPoint=u.length?u[0]:u,this._activateOnStart&&this._lastPoint&&(this._active=!0))}dragMove(n,u){if(!this.isEnabled())return;const p=this._lastPoint;if(!p)return;if(n.preventDefault(),!this._moveStateManager.isValidMoveEvent(n))return void this.reset(n);const _=u.length?u[0]:u;return!this._moved&&_.dist(p){y.mousedown=y.dragStart,y.mousemoveWindow=y.dragMove,y.mouseup=y.dragEnd,y.contextmenu=n=>{n.preventDefault()}},hd=({enable:y,clickTolerance:n,bearingDegreesPerPixelMoved:u=.8})=>{const p=new cs({checkCorrectEvent:_=>D.mouseButton(_)===0&&_.ctrlKey||D.mouseButton(_)===2});return new Ri({clickTolerance:n,move:(_,m)=>({bearingDelta:(m.x-_.x)*u}),moveStateManager:p,enable:y,assignEvents:Hl})},na=({enable:y,clickTolerance:n,pitchDegreesPerPixelMoved:u=-.5})=>{const p=new cs({checkCorrectEvent:_=>D.mouseButton(_)===0&&_.ctrlKey||D.mouseButton(_)===2});return new Ri({clickTolerance:n,move:(_,m)=>({pitchDelta:(m.y-_.y)*u}),moveStateManager:p,enable:y,assignEvents:Hl})};class Xl{constructor(n,u){this._clickTolerance=n.clickTolerance||1,this._map=u,this.reset()}reset(){this._active=!1,this._touches={},this._sum=new c.P(0,0)}_shouldBePrevented(n){return n<(this._map.cooperativeGestures.isEnabled()?2:1)}touchstart(n,u,p){return this._calculateTransform(n,u,p)}touchmove(n,u,p){if(this._active){if(!this._shouldBePrevented(p.length))return n.preventDefault(),this._calculateTransform(n,u,p);this._map.cooperativeGestures.notifyGestureBlocked("touch_pan",n)}}touchend(n,u,p){this._calculateTransform(n,u,p),this._active&&this._shouldBePrevented(p.length)&&this.reset()}touchcancel(){this.reset()}_calculateTransform(n,u,p){p.length>0&&(this._active=!0);const _=ka(p,u),m=new c.P(0,0),T=new c.P(0,0);let A=0;for(const C in _){const F=_[C],N=this._touches[C];N&&(m._add(F),T._add(F.sub(N)),A++,_[C]=F)}if(this._touches=_,this._shouldBePrevented(A)||!T.mag())return;const R=T.div(A);return this._sum._add(R),this._sum.mag()Math.abs(y.x)}class _d extends ql{constructor(n){super(),this._currentTouchCount=0,this._map=n}reset(){super.reset(),this._valid=void 0,delete this._firstMove,delete this._lastPoints}touchstart(n,u,p){super.touchstart(n,u,p),this._currentTouchCount=p.length}_start(n){this._lastPoints=n,Wn(n[0].sub(n[1]))&&(this._valid=!1)}_move(n,u,p){if(this._map.cooperativeGestures.isEnabled()&&this._currentTouchCount<3)return;const _=n[0].sub(this._lastPoints[0]),m=n[1].sub(this._lastPoints[1]);return this._valid=this.gestureBeginsVertically(_,m,p.timeStamp),this._valid?(this._lastPoints=n,this._active=!0,{pitchDelta:(_.y+m.y)/2*-.5}):void 0}gestureBeginsVertically(n,u,p){if(this._valid!==void 0)return this._valid;const _=n.mag()>=2,m=u.mag()>=2;if(!_&&!m)return;if(!_||!m)return this._firstMove===void 0&&(this._firstMove=p),p-this._firstMove<100&&void 0;const T=n.y>0==u.y>0;return Wn(n)&&Wn(u)&&T}}const jp={panStep:100,bearingStep:15,pitchStep:10};class gd{constructor(n){this._tr=new Ma(n);const u=jp;this._panStep=u.panStep,this._bearingStep=u.bearingStep,this._pitchStep=u.pitchStep,this._rotationDisabled=!1}reset(){this._active=!1}keydown(n){if(n.altKey||n.ctrlKey||n.metaKey)return;let u=0,p=0,_=0,m=0,T=0;switch(n.keyCode){case 61:case 107:case 171:case 187:u=1;break;case 189:case 109:case 173:u=-1;break;case 37:n.shiftKey?p=-1:(n.preventDefault(),m=-1);break;case 39:n.shiftKey?p=1:(n.preventDefault(),m=1);break;case 38:n.shiftKey?_=1:(n.preventDefault(),T=-1);break;case 40:n.shiftKey?_=-1:(n.preventDefault(),T=1);break;default:return}return this._rotationDisabled&&(p=0,_=0),{cameraAnimation:A=>{const R=this._tr;A.easeTo({duration:300,easeId:"keyboardHandler",easing:$p,zoom:u?Math.round(R.zoom)+u*(n.shiftKey?2:1):R.zoom,bearing:R.bearing+p*this._bearingStep,pitch:R.pitch+_*this._pitchStep,offset:[-m*this._panStep,-T*this._panStep],center:R.center},{originalEvent:n})}}}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 $p(y){return y*(2-y)}const md=4.000244140625;class yd{constructor(n,u){this._onTimeout=p=>{this._type="wheel",this._delta-=this._lastValue,this._active||this._start(p)},this._map=n,this._tr=new Ma(n),this._triggerRenderFrame=u,this._delta=0,this._defaultZoomRate=.01,this._wheelZoomRate=.0022222222222222222}setZoomRate(n){this._defaultZoomRate=n}setWheelZoomRate(n){this._wheelZoomRate=n}isEnabled(){return!!this._enabled}isActive(){return!!this._active||this._finishTimeout!==void 0}isZooming(){return!!this._zooming}enable(n){this.isEnabled()||(this._enabled=!0,this._aroundCenter=!!n&&n.around==="center")}disable(){this.isEnabled()&&(this._enabled=!1)}_shouldBePrevented(n){return!!this._map.cooperativeGestures.isEnabled()&&!(n.ctrlKey||this._map.cooperativeGestures.isBypassed(n))}wheel(n){if(!this.isEnabled())return;if(this._shouldBePrevented(n))return void this._map.cooperativeGestures.notifyGestureBlocked("wheel_zoom",n);let u=n.deltaMode===WheelEvent.DOM_DELTA_LINE?40*n.deltaY:n.deltaY;const p=M.now(),_=p-(this._lastWheelEventTime||0);this._lastWheelEventTime=p,u!==0&&u%md==0?this._type="wheel":u!==0&&Math.abs(u)<4?this._type="trackpad":_>400?(this._type=null,this._lastValue=u,this._timeout=setTimeout(this._onTimeout,40,n)):this._type||(this._type=Math.abs(_*u)<200?"trackpad":"wheel",this._timeout&&(clearTimeout(this._timeout),this._timeout=null,u+=this._lastValue)),n.shiftKey&&u&&(u/=4),this._type&&(this._lastWheelEvent=n,this._delta-=u,this._active||this._start(n)),n.preventDefault()}_start(n){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 u=D.mousePos(this._map.getCanvas(),n),p=this._tr;this._around=u.y>p.transform.height/2-p.transform.getHorizon()?c.N.convert(this._aroundCenter?p.center:p.unproject(u)):c.N.convert(p.center),this._aroundPoint=p.transform.locationPoint(this._around),this._frameId||(this._frameId=!0,this._triggerRenderFrame())}renderFrame(){if(!this._frameId||(this._frameId=null,!this.isActive()))return;const n=this._tr.transform;if(this._delta!==0){const R=this._type==="wheel"&&Math.abs(this._delta)>md?this._wheelZoomRate:this._defaultZoomRate;let C=2/(1+Math.exp(-Math.abs(this._delta*R)));this._delta<0&&C!==0&&(C=1/C);const F=typeof this._targetZoom=="number"?n.zoomScale(this._targetZoom):n.scale;this._targetZoom=Math.min(n.maxZoom,Math.max(n.minZoom,n.scaleZoom(F*C))),this._type==="wheel"&&(this._startZoom=n.zoom,this._easing=this._smoothOutEasing(200)),this._delta=0}const u=typeof this._targetZoom=="number"?this._targetZoom:n.zoom,p=this._startZoom,_=this._easing;let m,T=!1;const A=M.now()-this._lastWheelEventTime;if(this._type==="wheel"&&p&&_&&A){const R=Math.min(A/200,1),C=_(R);m=c.z.number(p,u,C),R<1?this._frameId||(this._frameId=!0):T=!0}else m=u,T=!0;return this._active=!0,T&&(this._active=!1,this._finishTimeout=setTimeout(()=>{this._zooming=!1,this._triggerRenderFrame(),delete this._targetZoom,delete this._finishTimeout},200)),{noInertia:!0,needsRenderFrame:!T,zoomDelta:m-n.zoom,around:this._aroundPoint,originalEvent:this._lastWheelEvent}}_smoothOutEasing(n){let u=c.b9;if(this._prevEase){const p=this._prevEase,_=(M.now()-p.start)/p.duration,m=p.easing(_+.01)-p.easing(_),T=.27/Math.sqrt(m*m+1e-4)*.01,A=Math.sqrt(.0729-T*T);u=c.b8(T,A,.25,1)}return this._prevEase={start:M.now(),duration:n,easing:u},u}reset(){this._active=!1,this._zooming=!1,delete this._targetZoom,this._finishTimeout&&(clearTimeout(this._finishTimeout),delete this._finishTimeout)}}class bd{constructor(n,u){this._clickZoom=n,this._tapZoom=u}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 Yl{constructor(n){this._tr=new Ma(n),this.reset()}reset(){this._active=!1}dblclick(n,u){return n.preventDefault(),{cameraAnimation:p=>{p.easeTo({duration:300,zoom:this._tr.zoom+(n.shiftKey?-1:1),around:this._tr.unproject(u)},{originalEvent:n})}}}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class Wp{constructor(){this._tap=new cd({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(n,u,p){if(!this._swipePoint)if(this._tapTime){const _=u[0],m=n.timeStamp-this._tapTime<500,T=this._tapPoint.dist(_)<30;m&&T?p.length>0&&(this._swipePoint=_,this._swipeTouch=p[0].identifier):this.reset()}else this._tap.touchstart(n,u,p)}touchmove(n,u,p){if(this._tapTime){if(this._swipePoint){if(p[0].identifier!==this._swipeTouch)return;const _=u[0],m=_.y-this._swipePoint.y;return this._swipePoint=_,n.preventDefault(),this._active=!0,{zoomDelta:m/128}}}else this._tap.touchmove(n,u,p)}touchend(n,u,p){if(this._tapTime)this._swipePoint&&p.length===0&&this.reset();else{const _=this._tap.touchend(n,u,p);_&&(this._tapTime=n.timeStamp,this._tapPoint=_)}}touchcancel(){this.reset()}enable(){this._enabled=!0}disable(){this._enabled=!1,this.reset()}isEnabled(){return this._enabled}isActive(){return this._active}}class $s{constructor(n,u,p){this._el=n,this._mousePan=u,this._touchPan=p}enable(n){this._inertiaOptions=n||{},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 an{constructor(n,u,p){this._pitchWithRotate=n.pitchWithRotate,this._mouseRotate=u,this._mousePitch=p}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 vd{constructor(n,u,p,_){this._el=n,this._touchZoom=u,this._touchRotate=p,this._tapDragZoom=_,this._rotationDisabled=!1,this._enabled=!0}enable(n){this._touchZoom.enable(n),this._rotationDisabled||this._touchRotate.enable(n),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 ln{constructor(n,u){this._bypassKey=navigator.userAgent.indexOf("Mac")!==-1?"metaKey":"ctrlKey",this._map=n,this._options=u,this._enabled=!1}isActive(){return!1}reset(){}_setupUI(){if(this._container)return;const n=this._map.getCanvasContainer();n.classList.add("maplibregl-cooperative-gestures"),this._container=D.create("div","maplibregl-cooperative-gesture-screen",n);let u=this._map._getUIString("CooperativeGesturesHandler.WindowsHelpText");this._bypassKey==="metaKey"&&(u=this._map._getUIString("CooperativeGesturesHandler.MacHelpText"));const p=this._map._getUIString("CooperativeGesturesHandler.MobileHelpText"),_=document.createElement("div");_.className="maplibregl-desktop-message",_.textContent=u,this._container.appendChild(_);const m=document.createElement("div");m.className="maplibregl-mobile-message",m.textContent=p,this._container.appendChild(m),this._container.setAttribute("aria-hidden","true")}_destroyUI(){this._container&&(D.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(n){return n[this._bypassKey]}notifyGestureBlocked(n,u){this._enabled&&(this._map.fire(new c.k("cooperativegestureprevented",{gestureType:n,originalEvent:u})),this._container.classList.add("maplibregl-show"),setTimeout(()=>{this._container.classList.remove("maplibregl-show")},100))}}const Hn=y=>y.zoom||y.drag||y.pitch||y.rotate;class Cy extends c.k{}function xd(y){return y.panDelta&&y.panDelta.mag()||y.zoomDelta||y.bearingDelta||y.pitchDelta}class My{constructor(n,u){this.handleWindowEvent=_=>{this.handleEvent(_,`${_.type}Window`)},this.handleEvent=(_,m)=>{if(_.type==="blur")return void this.stop(!0);this._updatingCamera=!0;const T=_.type==="renderFrame"?void 0:_,A={needsRenderFrame:!1},R={},C={},F=_.touches,N=F?this._getMapTouches(F):void 0,V=N?D.touchPos(this._map.getCanvas(),N):D.mousePos(this._map.getCanvas(),_);for(const{handlerName:se,handler:ie,allowed:oe}of this._handlers){if(!ie.isEnabled())continue;let de;this._blockedByActive(C,oe,se)?ie.reset():ie[m||_.type]&&(de=ie[m||_.type](_,V,N),this.mergeHandlerResult(A,R,de,se,T),de&&de.needsRenderFrame&&this._triggerRenderFrame()),(de||ie.isActive())&&(C[se]=ie)}const W={};for(const se in this._previousActiveHandlers)C[se]||(W[se]=T);this._previousActiveHandlers=C,(Object.keys(W).length||xd(A))&&(this._changes.push([A,R,W]),this._triggerRenderFrame()),(Object.keys(C).length||xd(A))&&this._map._stop(!0),this._updatingCamera=!1;const{cameraAnimation:K}=A;K&&(this._inertia.clear(),this._fireEvents({},{},!0),this._changes=[],K(this._map))},this._map=n,this._el=this._map.getCanvasContainer(),this._handlers=[],this._handlersById={},this._changes=[],this._inertia=new hh(n),this._bearingSnap=u.bearingSnap,this._previousActiveHandlers={},this._eventsInProgress={},this._addDefaultHandlers(u);const p=this._el;this._listeners=[[p,"touchstart",{passive:!0}],[p,"touchmove",{passive:!1}],[p,"touchend",void 0],[p,"touchcancel",void 0],[p,"mousedown",void 0],[p,"mousemove",void 0],[p,"mouseup",void 0],[document,"mousemove",{capture:!0}],[document,"mouseup",void 0],[p,"mouseover",void 0],[p,"mouseout",void 0],[p,"dblclick",void 0],[p,"click",void 0],[p,"keydown",{capture:!1}],[p,"keyup",void 0],[p,"wheel",{passive:!1}],[p,"contextmenu",void 0],[window,"blur",void 0]];for(const[_,m,T]of this._listeners)D.addEventListener(_,m,_===document?this.handleWindowEvent:this.handleEvent,T)}destroy(){for(const[n,u,p]of this._listeners)D.removeEventListener(n,u,n===document?this.handleWindowEvent:this.handleEvent,p)}_addDefaultHandlers(n){const u=this._map,p=u.getCanvasContainer();this._add("mapEvent",new dh(u,n));const _=u.boxZoom=new ad(u,n);this._add("boxZoom",_),n.interactive&&n.boxZoom&&_.enable();const m=u.cooperativeGestures=new ln(u,n.cooperativeGestures);this._add("cooperativeGestures",m),n.cooperativeGestures&&m.enable();const T=new Vp(u),A=new Yl(u);u.doubleClickZoom=new bd(A,T),this._add("tapZoom",T),this._add("clickZoom",A),n.interactive&&n.doubleClickZoom&&u.doubleClickZoom.enable();const R=new Wp;this._add("tapDragZoom",R);const C=u.touchPitch=new _d(u);this._add("touchPitch",C),n.interactive&&n.touchPitch&&u.touchPitch.enable(n.touchPitch);const F=hd(n),N=na(n);u.dragRotate=new an(n,F,N),this._add("mouseRotate",F,["mousePitch"]),this._add("mousePitch",N,["mouseRotate"]),n.interactive&&n.dragRotate&&u.dragRotate.enable();const V=(({enable:de,clickTolerance:ee})=>{const me=new cs({checkCorrectEvent:Ae=>D.mouseButton(Ae)===0&&!Ae.ctrlKey});return new Ri({clickTolerance:ee,move:(Ae,Re)=>({around:Re,panDelta:Re.sub(Ae)}),activateOnStart:!0,moveStateManager:me,enable:de,assignEvents:Hl})})(n),W=new Xl(n,u);u.dragPan=new $s(p,V,W),this._add("mousePan",V),this._add("touchPan",W,["touchZoom","touchRotate"]),n.interactive&&n.dragPan&&u.dragPan.enable(n.dragPan);const K=new pd,se=new dd;u.touchZoomRotate=new vd(p,se,K,R),this._add("touchRotate",K,["touchPan","touchZoom"]),this._add("touchZoom",se,["touchPan","touchRotate"]),n.interactive&&n.touchZoomRotate&&u.touchZoomRotate.enable(n.touchZoomRotate);const ie=u.scrollZoom=new yd(u,()=>this._triggerRenderFrame());this._add("scrollZoom",ie,["mousePan"]),n.interactive&&n.scrollZoom&&u.scrollZoom.enable(n.scrollZoom);const oe=u.keyboard=new gd(u);this._add("keyboard",oe),n.interactive&&n.keyboard&&u.keyboard.enable(),this._add("blockableMapEvent",new od(u))}_add(n,u,p){this._handlers.push({handlerName:n,handler:u,allowed:p}),this._handlersById[n]=u}stop(n){if(!this._updatingCamera){for(const{handler:u}of this._handlers)u.reset();this._inertia.clear(),this._fireEvents({},{},n),this._changes=[]}}isActive(){for(const{handler:n}of this._handlers)if(n.isActive())return!0;return!1}isZooming(){return!!this._eventsInProgress.zoom||this._map.scrollZoom.isZooming()}isRotating(){return!!this._eventsInProgress.rotate}isMoving(){return!!Hn(this._eventsInProgress)||this.isZooming()}_blockedByActive(n,u,p){for(const _ in n)if(_!==p&&(!u||u.indexOf(_)<0))return!0;return!1}_getMapTouches(n){const u=[];for(const p of n)this._el.contains(p.target)&&u.push(p);return u}mergeHandlerResult(n,u,p,_,m){if(!p)return;c.e(n,p);const T={handlerName:_,originalEvent:p.originalEvent||m};p.zoomDelta!==void 0&&(u.zoom=T),p.panDelta!==void 0&&(u.drag=T),p.pitchDelta!==void 0&&(u.pitch=T),p.bearingDelta!==void 0&&(u.rotate=T)}_applyChanges(){const n={},u={},p={};for(const[_,m,T]of this._changes)_.panDelta&&(n.panDelta=(n.panDelta||new c.P(0,0))._add(_.panDelta)),_.zoomDelta&&(n.zoomDelta=(n.zoomDelta||0)+_.zoomDelta),_.bearingDelta&&(n.bearingDelta=(n.bearingDelta||0)+_.bearingDelta),_.pitchDelta&&(n.pitchDelta=(n.pitchDelta||0)+_.pitchDelta),_.around!==void 0&&(n.around=_.around),_.pinchAround!==void 0&&(n.pinchAround=_.pinchAround),_.noInertia&&(n.noInertia=_.noInertia),c.e(u,m),c.e(p,T);this._updateMapTransform(n,u,p),this._changes=[]}_updateMapTransform(n,u,p){const _=this._map,m=_._getTransformForUpdate(),T=_.terrain;if(!(xd(n)||T&&this._terrainMovement))return this._fireEvents(u,p,!0);let{panDelta:A,zoomDelta:R,bearingDelta:C,pitchDelta:F,around:N,pinchAround:V}=n;V!==void 0&&(N=V),_._stop(!0),N=N||_.transform.centerPoint;const W=m.pointLocation(A?N.sub(A):N);C&&(m.bearing+=C),F&&(m.pitch+=F),R&&(m.zoom+=R),T?this._terrainMovement||!u.drag&&!u.zoom?u.drag&&this._terrainMovement?m.center=m.pointLocation(m.centerPoint.sub(A)):m.setLocationAtPoint(W,N):(this._terrainMovement=!0,this._map._elevationFreeze=!0,m.setLocationAtPoint(W,N)):m.setLocationAtPoint(W,N),_._applyUpdatedTransform(m),this._map._update(),n.noInertia||this._inertia.record(n),this._fireEvents(u,p,!0)}_fireEvents(n,u,p){const _=Hn(this._eventsInProgress),m=Hn(n),T={};for(const N in n){const{originalEvent:V}=n[N];this._eventsInProgress[N]||(T[`${N}start`]=V),this._eventsInProgress[N]=n[N]}!_&&m&&this._fireEvent("movestart",m.originalEvent);for(const N in T)this._fireEvent(N,T[N]);m&&this._fireEvent("move",m.originalEvent);for(const N in n){const{originalEvent:V}=n[N];this._fireEvent(N,V)}const A={};let R;for(const N in this._eventsInProgress){const{handlerName:V,originalEvent:W}=this._eventsInProgress[N];this._handlersById[V].isActive()||(delete this._eventsInProgress[N],R=u[V]||W,A[`${N}end`]=R)}for(const N in A)this._fireEvent(N,A[N]);const C=Hn(this._eventsInProgress),F=(_||m)&&!C;if(F&&this._terrainMovement){this._map._elevationFreeze=!1,this._terrainMovement=!1;const N=this._map._getTransformForUpdate();N.recalculateZoom(this._map.terrain),this._map._applyUpdatedTransform(N)}if(p&&F){this._updatingCamera=!0;const N=this._inertia._onMoveEnd(this._map.dragPan._inertiaOptions),V=W=>W!==0&&-this._bearingSnap{delete this._frameId,this.handleEvent(new Cy("renderFrame",{timeStamp:n})),this._applyChanges()})}_triggerRenderFrame(){this._frameId===void 0&&(this._frameId=this._requestFrame())}}class ky extends c.E{constructor(n,u){super(),this._renderFrameCallback=()=>{const p=Math.min((M.now()-this._easeStart)/this._easeOptions.duration,1);this._onEaseFrame(this._easeOptions.easing(p)),p<1&&this._easeFrameId?this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback):this.stop()},this._moving=!1,this._zooming=!1,this.transform=n,this._bearingSnap=u.bearingSnap,this.on("moveend",()=>{delete this._requestedCameraState})}getCenter(){return new c.N(this.transform.center.lng,this.transform.center.lat)}setCenter(n,u){return this.jumpTo({center:n},u)}panBy(n,u,p){return n=c.P.convert(n).mult(-1),this.panTo(this.transform.center,c.e({offset:n},u),p)}panTo(n,u,p){return this.easeTo(c.e({center:n},u),p)}getZoom(){return this.transform.zoom}setZoom(n,u){return this.jumpTo({zoom:n},u),this}zoomTo(n,u,p){return this.easeTo(c.e({zoom:n},u),p)}zoomIn(n,u){return this.zoomTo(this.getZoom()+1,n,u),this}zoomOut(n,u){return this.zoomTo(this.getZoom()-1,n,u),this}getBearing(){return this.transform.bearing}setBearing(n,u){return this.jumpTo({bearing:n},u),this}getPadding(){return this.transform.padding}setPadding(n,u){return this.jumpTo({padding:n},u),this}rotateTo(n,u,p){return this.easeTo(c.e({bearing:n},u),p)}resetNorth(n,u){return this.rotateTo(0,c.e({duration:1e3},n),u),this}resetNorthPitch(n,u){return this.easeTo(c.e({bearing:0,pitch:0,duration:1e3},n),u),this}snapToNorth(n,u){return Math.abs(this.getBearing()){if(this._zooming&&(_.zoom=c.z.number(m,ie,Le)),this._rotating&&(_.bearing=c.z.number(T,C,Le)),this._pitching&&(_.pitch=c.z.number(A,F,Le)),this._padding&&(_.interpolatePadding(R,N,Le),W=_.centerPoint.add(V)),this.terrain&&!n.freezeElevation&&this._updateElevation(Le),me)_.setLocationAtPoint(me,Ae);else{const Ze=_.zoomScale(_.zoom-m),ct=ie>m?Math.min(2,ee):Math.max(.5,ee),dt=Math.pow(ct,1-Le),Ye=_.unproject(oe.add(de.mult(Le*dt)).mult(Ze));_.setLocationAtPoint(_.renderWorldCopies?Ye.wrap():Ye,W)}this._applyUpdatedTransform(_),this._fireMoveEvents(u)},Le=>{this.terrain&&n.freezeElevation&&this._finalizeElevation(),this._afterEase(u,Le)},n),this}_prepareEase(n,u,p={}){this._moving=!0,u||p.moving||this.fire(new c.k("movestart",n)),this._zooming&&!p.zooming&&this.fire(new c.k("zoomstart",n)),this._rotating&&!p.rotating&&this.fire(new c.k("rotatestart",n)),this._pitching&&!p.pitching&&this.fire(new c.k("pitchstart",n))}_prepareElevation(n){this._elevationCenter=n,this._elevationStart=this.transform.elevation,this._elevationTarget=this.terrain.getElevationForLngLatZoom(n,this.transform.tileZoom),this._elevationFreeze=!0}_updateElevation(n){this.transform.minElevationForCurrentTile=this.terrain.getMinTileElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);const u=this.terrain.getElevationForLngLatZoom(this._elevationCenter,this.transform.tileZoom);if(n<1&&u!==this._elevationTarget){const p=this._elevationTarget-this._elevationStart;this._elevationStart+=n*(p-(u-(p*n+this._elevationStart))/(1-n)),this._elevationTarget=u}this.transform.elevation=c.z.number(this._elevationStart,this._elevationTarget,n)}_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(n){const u=n.getCameraPosition(),p=this.terrain.getElevationForLngLatZoom(u.lngLat,n.zoom);if(u.altitudethis._elevateCameraIfInsideTerrain(_)),this.transformCameraUpdate&&u.push(_=>this.transformCameraUpdate(_)),!u.length)return;const p=n.clone();for(const _ of u){const m=p.clone(),{center:T,zoom:A,pitch:R,bearing:C,elevation:F}=_(m);T&&(m.center=T),A!==void 0&&(m.zoom=A),R!==void 0&&(m.pitch=R),C!==void 0&&(m.bearing=C),F!==void 0&&(m.elevation=F),p.apply(m)}this.transform.apply(p)}_fireMoveEvents(n){this.fire(new c.k("move",n)),this._zooming&&this.fire(new c.k("zoom",n)),this._rotating&&this.fire(new c.k("rotate",n)),this._pitching&&this.fire(new c.k("pitch",n))}_afterEase(n,u){if(this._easeId&&u&&this._easeId===u)return;delete this._easeId;const p=this._zooming,_=this._rotating,m=this._pitching;this._moving=!1,this._zooming=!1,this._rotating=!1,this._pitching=!1,this._padding=!1,p&&this.fire(new c.k("zoomend",n)),_&&this.fire(new c.k("rotateend",n)),m&&this.fire(new c.k("pitchend",n)),this.fire(new c.k("moveend",n))}flyTo(n,u){var p;if(!n.essential&&M.prefersReducedMotion){const nt=c.M(n,["center","zoom","bearing","pitch","around"]);return this.jumpTo(nt,u)}this.stop(),n=c.e({offset:[0,0],speed:1.2,curve:1.42,easing:c.b9},n);const _=this._getTransformForUpdate(),m=_.zoom,T=_.bearing,A=_.pitch,R=_.padding,C="bearing"in n?this._normalizeBearing(n.bearing,T):T,F="pitch"in n?+n.pitch:A,N="padding"in n?n.padding:_.padding,V=c.P.convert(n.offset);let W=_.centerPoint.add(V);const K=_.pointLocation(W),{center:se,zoom:ie}=_.getConstrained(c.N.convert(n.center||K),(p=n.zoom)!==null&&p!==void 0?p:m);this._normalizeCenter(se,_);const oe=_.zoomScale(ie-m),de=_.project(K),ee=_.project(se).sub(de);let me=n.curve;const Ae=Math.max(_.width,_.height),Re=Ae/oe,Le=ee.mag();if("minZoom"in n){const nt=c.ad(Math.min(n.minZoom,m,ie),_.minZoom,_.maxZoom),Ot=Ae/_.zoomScale(nt-m);me=Math.sqrt(Ot/Le*2)}const Ze=me*me;function ct(nt){const Ot=(Re*Re-Ae*Ae+(nt?-1:1)*Ze*Ze*Le*Le)/(2*(nt?Re:Ae)*Ze*Le);return Math.log(Math.sqrt(Ot*Ot+1)-Ot)}function dt(nt){return(Math.exp(nt)-Math.exp(-nt))/2}function Ye(nt){return(Math.exp(nt)+Math.exp(-nt))/2}const Qe=ct(!1);let yt=function(nt){return Ye(Qe)/Ye(Qe+me*nt)},Ut=function(nt){return Ae*((Ye(Qe)*(dt(Ot=Qe+me*nt)/Ye(Ot))-dt(Qe))/Ze)/Le;var Ot},tt=(ct(!0)-Qe)/me;if(Math.abs(Le)<1e-6||!isFinite(tt)){if(Math.abs(Ae-Re)<1e-6)return this.easeTo(n,u);const nt=Re0,yt=Ot=>Math.exp(nt*me*Ot)}return n.duration="duration"in n?+n.duration:1e3*tt/("screenSpeed"in n?+n.screenSpeed/me:+n.speed),n.maxDuration&&n.duration>n.maxDuration&&(n.duration=0),this._zooming=!0,this._rotating=T!==C,this._pitching=F!==A,this._padding=!_.isPaddingEqual(N),this._prepareEase(u,!1),this.terrain&&this._prepareElevation(se),this._ease(nt=>{const Ot=nt*tt,Ci=1/yt(Ot);_.zoom=nt===1?ie:m+_.scaleZoom(Ci),this._rotating&&(_.bearing=c.z.number(T,C,nt)),this._pitching&&(_.pitch=c.z.number(A,F,nt)),this._padding&&(_.interpolatePadding(R,N,nt),W=_.centerPoint.add(V)),this.terrain&&!n.freezeElevation&&this._updateElevation(nt);const Ht=nt===1?se:_.unproject(de.add(ee.mult(Ut(Ot))).mult(Ci));_.setLocationAtPoint(_.renderWorldCopies?Ht.wrap():Ht,W),this._applyUpdatedTransform(_),this._fireMoveEvents(u)},()=>{this.terrain&&n.freezeElevation&&this._finalizeElevation(),this._afterEase(u)},n),this}isEasing(){return!!this._easeFrameId}stop(){return this._stop()}_stop(n,u){var p;if(this._easeFrameId&&(this._cancelRenderFrame(this._easeFrameId),delete this._easeFrameId,delete this._onEaseFrame),this._onEaseEnd){const _=this._onEaseEnd;delete this._onEaseEnd,_.call(this,u)}return n||(p=this.handlers)===null||p===void 0||p.stop(!1),this}_ease(n,u,p){p.animate===!1||p.duration===0?(n(1),u()):(this._easeStart=M.now(),this._easeOptions=p,this._onEaseFrame=n,this._onEaseEnd=u,this._easeFrameId=this._requestRenderFrame(this._renderFrameCallback))}_normalizeBearing(n,u){n=c.b3(n,-180,180);const p=Math.abs(n-u);return Math.abs(n-360-u)180?-360:p<-180?360:0}queryTerrainElevation(n){return this.terrain?this.terrain.getElevationForLngLatZoom(c.N.convert(n),this.transform.tileZoom)-this.transform.elevation:null}}const wd={compact:!0,customAttribution:'MapLibre'};class Da{constructor(n=wd){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=u=>{!u||u.sourceDataType!=="metadata"&&u.sourceDataType!=="visibility"&&u.dataType!=="style"&&u.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=n}getDefaultPosition(){return"bottom-right"}onAdd(n){return this._map=n,this._compact=this.options.compact,this._container=D.create("details","maplibregl-ctrl maplibregl-ctrl-attrib"),this._compactButton=D.create("summary","maplibregl-ctrl-attrib-button",this._container),this._compactButton.addEventListener("click",this._toggleAttribution),this._setElementTitle(this._compactButton,"ToggleAttribution"),this._innerContainer=D.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(){D.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(n,u){const p=this._map._getUIString(`AttributionControl.${u}`);n.title=p,n.setAttribute("aria-label",p)}_updateAttributions(){if(!this._map.style)return;let n=[];if(this.options.customAttribution&&(Array.isArray(this.options.customAttribution)?n=n.concat(this.options.customAttribution.map(_=>typeof _!="string"?"":_)):typeof this.options.customAttribution=="string"&&n.push(this.options.customAttribution)),this._map.style.stylesheet){const _=this._map.style.stylesheet;this.styleOwner=_.owner,this.styleId=_.id}const u=this._map.style.sourceCaches;for(const _ in u){const m=u[_];if(m.used||m.usedForTerrain){const T=m.getSource();T.attribution&&n.indexOf(T.attribution)<0&&n.push(T.attribution)}}n=n.filter(_=>String(_).trim()),n.sort((_,m)=>_.length-m.length),n=n.filter((_,m)=>{for(let T=m+1;T=0)return!1;return!0});const p=n.join(" | ");p!==this._attribHTML&&(this._attribHTML=p,n.length?(this._innerContainer.innerHTML=p,this._container.classList.remove("maplibregl-attrib-empty")):this._container.classList.add("maplibregl-attrib-empty"),this._updateCompact(),this._editLink=null)}}class Rn{constructor(n={}){this._updateCompact=()=>{const u=this._container.children;if(u.length){const p=u[0];this._map.getCanvasContainer().offsetWidth<=640||this._compact?this._compact!==!1&&p.classList.add("maplibregl-compact"):p.classList.remove("maplibregl-compact")}},this.options=n}getDefaultPosition(){return"bottom-left"}onAdd(n){this._map=n,this._compact=this.options&&this.options.compact,this._container=D.create("div","maplibregl-ctrl");const u=D.create("a","maplibregl-ctrl-logo");return u.target="_blank",u.rel="noopener nofollow",u.href="https://maplibre.org/",u.setAttribute("aria-label",this._map._getUIString("LogoControl.Title")),u.setAttribute("rel","noopener nofollow"),this._container.appendChild(u),this._container.style.display="block",this._map.on("resize",this._updateCompact),this._updateCompact(),this._container}onRemove(){D.remove(this._container),this._map.off("resize",this._updateCompact),this._map=void 0,this._compact=void 0}}class _t{constructor(){this._queue=[],this._id=0,this._cleared=!1,this._currentlyRunning=!1}add(n){const u=++this._id;return this._queue.push({callback:n,id:u,cancelled:!1}),u}remove(n){const u=this._currentlyRunning,p=u?this._queue.concat(u):this._queue;for(const _ of p)if(_.id===n)return void(_.cancelled=!0)}run(n=0){if(this._currentlyRunning)throw new Error("Attempting to run(), but is already running.");const u=this._currentlyRunning=this._queue;this._queue=[];for(const p of u)if(!p.cancelled&&(p.callback(n),this._cleared))break;this._cleared=!1,this._currentlyRunning=!1}clear(){this._currentlyRunning&&(this._cleared=!0),this._queue=[]}}var Hp=c.Y([{name:"a_pos3d",type:"Int16",components:3}]);class Td extends c.E{constructor(n){super(),this.sourceCache=n,this._tiles={},this._renderableTilesKeys=[],this._sourceTileCache={},this.minzoom=0,this.maxzoom=22,this.tileSize=512,this.deltaZoom=1,n.usedForTerrain=!0,n.tileSize=this.tileSize*2**this.deltaZoom}destruct(){this.sourceCache.usedForTerrain=!1,this.sourceCache.tileSize=null}update(n,u){this.sourceCache.update(n,u),this._renderableTilesKeys=[];const p={};for(const _ of n.coveringTiles({tileSize:this.tileSize,minzoom:this.minzoom,maxzoom:this.maxzoom,reparseOverscaled:!1,terrain:u}))p[_.key]=!0,this._renderableTilesKeys.push(_.key),this._tiles[_.key]||(_.posMatrix=new Float64Array(16),c.aQ(_.posMatrix,0,c.X,0,c.X,0,1),this._tiles[_.key]=new mr(_,this.tileSize));for(const _ in this._tiles)p[_]||delete this._tiles[_]}freeRtt(n){for(const u in this._tiles){const p=this._tiles[u];(!n||p.tileID.equals(n)||p.tileID.isChildOf(n)||n.isChildOf(p.tileID))&&(p.rtt=[])}}getRenderableTiles(){return this._renderableTilesKeys.map(n=>this.getTileByID(n))}getTileByID(n){return this._tiles[n]}getTerrainCoords(n){const u={};for(const p of this._renderableTilesKeys){const _=this._tiles[p].tileID;if(_.canonical.equals(n.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16),c.aQ(m.posMatrix,0,c.X,0,c.X,0,1),u[p]=m}else if(_.canonical.isChildOf(n.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16);const T=_.canonical.z-n.canonical.z,A=_.canonical.x-(_.canonical.x>>T<>T<>T;c.aQ(m.posMatrix,0,C,0,C,0,1),c.J(m.posMatrix,m.posMatrix,[-A*C,-R*C,0]),u[p]=m}else if(n.canonical.isChildOf(_.canonical)){const m=n.clone();m.posMatrix=new Float64Array(16);const T=n.canonical.z-_.canonical.z,A=n.canonical.x-(n.canonical.x>>T<>T<>T;c.aQ(m.posMatrix,0,c.X,0,c.X,0,1),c.J(m.posMatrix,m.posMatrix,[A*C,R*C,0]),c.K(m.posMatrix,m.posMatrix,[1/2**T,1/2**T,0]),u[p]=m}}return u}getSourceTile(n,u){const p=this.sourceCache._source;let _=n.overscaledZ-this.deltaZoom;if(_>p.maxzoom&&(_=p.maxzoom),_=p.minzoom&&(!m||!m.dem);)m=this.sourceCache.getTileByID(n.scaledTo(_--).key);return m}tilesAfterTime(n=Date.now()){return Object.values(this._tiles).filter(u=>u.timeAdded>=n)}}class Xp{constructor(n,u,p){this.painter=n,this.sourceCache=new Td(u),this.options=p,this.exaggeration=typeof p.exaggeration=="number"?p.exaggeration:1,this.qualityFactor=2,this.meshSize=128,this._demMatrixCache={},this.coordsIndex=[],this._coordsTextureSize=1024}getDEMElevation(n,u,p,_=c.X){var m;if(!(u>=0&&u<_&&p>=0&&p<_))return 0;const T=this.getTerrainData(n),A=(m=T.tile)===null||m===void 0?void 0:m.dem;if(!A)return 0;const R=function(K,se,ie){var oe=se[0],de=se[1];return K[0]=ie[0]*oe+ie[4]*de+ie[12],K[1]=ie[1]*oe+ie[5]*de+ie[13],K}([],[u/_*c.X,p/_*c.X],T.u_terrain_matrix),C=[R[0]*A.dim,R[1]*A.dim],F=Math.floor(C[0]),N=Math.floor(C[1]),V=C[0]-F,W=C[1]-N;return A.get(F,N)*(1-V)*(1-W)+A.get(F+1,N)*V*(1-W)+A.get(F,N+1)*(1-V)*W+A.get(F+1,N+1)*V*W}getElevationForLngLatZoom(n,u){const{tileID:p,mercatorX:_,mercatorY:m}=this._getOverscaledTileIDFromLngLatZoom(n,u);return this.getElevation(p,_%c.X,m%c.X,c.X)}getElevation(n,u,p,_=c.X){return this.getDEMElevation(n,u,p,_)*this.exaggeration}getTerrainData(n){if(!this._emptyDemTexture){const _=this.painter.context,m=new c.R({width:1,height:1},new Uint8Array(4));this._emptyDepthTexture=new ut(_,m,_.gl.RGBA,{premultiply:!1}),this._emptyDemUnpack=[0,0,0,0],this._emptyDemTexture=new ut(_,new c.R({width:1,height:1}),_.gl.RGBA,{premultiply:!1}),this._emptyDemTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),this._emptyDemMatrix=c.ao([])}const u=this.sourceCache.getSourceTile(n,!0);if(u&&u.dem&&(!u.demTexture||u.needsTerrainPrepare)){const _=this.painter.context;u.demTexture=this.painter.getTileTexture(u.dem.stride),u.demTexture?u.demTexture.update(u.dem.getPixels(),{premultiply:!1}):u.demTexture=new ut(_,u.dem.getPixels(),_.gl.RGBA,{premultiply:!1}),u.demTexture.bind(_.gl.NEAREST,_.gl.CLAMP_TO_EDGE),u.needsTerrainPrepare=!1}const p=u&&u+u.tileID.key+n.key;if(p&&!this._demMatrixCache[p]){const _=this.sourceCache.sourceCache._source.maxzoom;let m=n.canonical.z-u.tileID.canonical.z;n.overscaledZ>n.canonical.z&&(n.canonical.z>=_?m=n.canonical.z-_:c.w("cannot calculate elevation if elevation maxzoom > source.maxzoom"));const T=n.canonical.x-(n.canonical.x>>m<>m<>8<<4|m>>8,u[T+3]=0;const p=new c.R({width:this._coordsTextureSize,height:this._coordsTextureSize},new Uint8Array(u.buffer)),_=new ut(n,p,n.gl.RGBA,{premultiply:!1});return _.bind(n.gl.NEAREST,n.gl.CLAMP_TO_EDGE),this._coordsTexture=_,_}pointCoordinate(n){this.painter.maybeDrawDepthAndCoords(!0);const u=new Uint8Array(4),p=this.painter.context,_=p.gl,m=Math.round(n.x*this.painter.pixelRatio/devicePixelRatio),T=Math.round(n.y*this.painter.pixelRatio/devicePixelRatio),A=Math.round(this.painter.height/devicePixelRatio);p.bindFramebuffer.set(this.getFramebuffer("coords").framebuffer),_.readPixels(m,A-T-1,1,1,_.RGBA,_.UNSIGNED_BYTE,u),p.bindFramebuffer.set(null);const R=u[0]+(u[2]>>4<<8),C=u[1]+((15&u[2])<<8),F=this.coordsIndex[255-u[3]],N=F&&this.sourceCache.getTileByID(F);if(!N)return null;const V=this._coordsTextureSize,W=(1<n.id!==u),this._recentlyUsed.push(n.id)}stampObject(n){n.stamp=++this._stamp}getOrCreateFreeObject(){for(const u of this._recentlyUsed)if(!this._objects[u].inUse)return this._objects[u];if(this._objects.length>=this._size)throw new Error("No free RenderPool available, call freeAllObjects() required!");const n=this._createObject(this._objects.length);return this._objects.push(n),n}freeObject(n){n.inUse=!1}freeAllObjects(){for(const n of this._objects)this.freeObject(n)}isFull(){return!(this._objects.length!n.inUse)===!1}}const Cn={background:!0,fill:!0,line:!0,raster:!0,hillshade:!0};class qp{constructor(n,u){this.painter=n,this.terrain=u,this.pool=new Kl(n.context,30,u.sourceCache.tileSize*u.qualityFactor)}destruct(){this.pool.destruct()}getTexture(n){return this.pool.getObjectForId(n.rtt[this._stacks.length-1].id).texture}prepareForRender(n,u){this._stacks=[],this._prevType=null,this._rttTiles=[],this._renderableTiles=this.terrain.sourceCache.getRenderableTiles(),this._renderableLayerIds=n._order.filter(p=>!n._layers[p].isHidden(u)),this._coordsDescendingInv={};for(const p in n.sourceCaches){this._coordsDescendingInv[p]={};const _=n.sourceCaches[p].getVisibleCoordinates();for(const m of _){const T=this.terrain.sourceCache.getTerrainCoords(m);for(const A in T)this._coordsDescendingInv[p][A]||(this._coordsDescendingInv[p][A]=[]),this._coordsDescendingInv[p][A].push(T[A])}}this._coordsDescendingInvStr={};for(const p of n._order){const _=n._layers[p],m=_.source;if(Cn[_.type]&&!this._coordsDescendingInvStr[m]){this._coordsDescendingInvStr[m]={};for(const T in this._coordsDescendingInv[m])this._coordsDescendingInvStr[m][T]=this._coordsDescendingInv[m][T].map(A=>A.key).sort().join()}}for(const p of this._renderableTiles)for(const _ in this._coordsDescendingInvStr){const m=this._coordsDescendingInvStr[_][p.tileID.key];m&&m!==p.rttCoords[_]&&(p.rtt=[])}}renderLayer(n){if(n.isHidden(this.painter.transform.zoom))return!1;const u=n.type,p=this.painter,_=this._renderableLayerIds[this._renderableLayerIds.length-1]===n.id;if(Cn[u]&&(this._prevType&&Cn[this._prevType]||this._stacks.push([]),this._prevType=u,this._stacks[this._stacks.length-1].push(n.id),!_))return!0;if(Cn[this._prevType]||Cn[u]&&_){this._prevType=u;const m=this._stacks.length-1,T=this._stacks[m]||[];for(const A of this._renderableTiles){if(this.pool.isFull()&&(jl(this.painter,this.terrain,this._rttTiles),this._rttTiles=[],this.pool.freeAllObjects()),this._rttTiles.push(A),A.rtt[m]){const C=this.pool.getObjectForId(A.rtt[m].id);if(C.stamp===A.rtt[m].stamp){this.pool.useObject(C);continue}}const R=this.pool.getOrCreateFreeObject();this.pool.useObject(R),this.pool.stampObject(R),A.rtt[m]={id:R.id,stamp:R.stamp},p.context.bindFramebuffer.set(R.fbo.framebuffer),p.context.clear({color:c.aN.transparent,stencil:0}),p.currentStencilSource=void 0;for(let C=0;C{y.touchstart=y.dragStart,y.touchmoveWindow=y.dragMove,y.touchend=y.dragEnd},Ed={showCompass:!0,showZoom:!0,visualizePitch:!1};class Yp{constructor(n,u,p=!1){this.mousedown=T=>{this.startMouse(c.e({},T,{ctrlKey:!0,preventDefault:()=>T.preventDefault()}),D.mousePos(this.element,T)),D.addEventListener(window,"mousemove",this.mousemove),D.addEventListener(window,"mouseup",this.mouseup)},this.mousemove=T=>{this.moveMouse(T,D.mousePos(this.element,T))},this.mouseup=T=>{this.mouseRotate.dragEnd(T),this.mousePitch&&this.mousePitch.dragEnd(T),this.offTemp()},this.touchstart=T=>{T.targetTouches.length!==1?this.reset():(this._startPos=this._lastPos=D.touchPos(this.element,T.targetTouches)[0],this.startTouch(T,this._startPos),D.addEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.addEventListener(window,"touchend",this.touchend))},this.touchmove=T=>{T.targetTouches.length!==1?this.reset():(this._lastPos=D.touchPos(this.element,T.targetTouches)[0],this.moveTouch(T,this._lastPos))},this.touchend=T=>{T.targetTouches.length===0&&this._startPos&&this._lastPos&&this._startPos.dist(this._lastPos){this.mouseRotate.reset(),this.mousePitch&&this.mousePitch.reset(),this.touchRotate.reset(),this.touchPitch&&this.touchPitch.reset(),delete this._startPos,delete this._lastPos,this.offTemp()},this._clickTolerance=10;const _=n.dragRotate._mouseRotate.getClickTolerance(),m=n.dragRotate._mousePitch.getClickTolerance();this.element=u,this.mouseRotate=hd({clickTolerance:_,enable:!0}),this.touchRotate=(({enable:T,clickTolerance:A,bearingDegreesPerPixelMoved:R=.8})=>{const C=new fh;return new Ri({clickTolerance:A,move:(F,N)=>({bearingDelta:(N.x-F.x)*R}),moveStateManager:C,enable:T,assignEvents:Zp})})({clickTolerance:_,enable:!0}),this.map=n,p&&(this.mousePitch=na({clickTolerance:m,enable:!0}),this.touchPitch=(({enable:T,clickTolerance:A,pitchDegreesPerPixelMoved:R=-.5})=>{const C=new fh;return new Ri({clickTolerance:A,move:(F,N)=>({pitchDelta:(N.y-F.y)*R}),moveStateManager:C,enable:T,assignEvents:Zp})})({clickTolerance:m,enable:!0})),D.addEventListener(u,"mousedown",this.mousedown),D.addEventListener(u,"touchstart",this.touchstart,{passive:!1}),D.addEventListener(u,"touchcancel",this.reset)}startMouse(n,u){this.mouseRotate.dragStart(n,u),this.mousePitch&&this.mousePitch.dragStart(n,u),D.disableDrag()}startTouch(n,u){this.touchRotate.dragStart(n,u),this.touchPitch&&this.touchPitch.dragStart(n,u),D.disableDrag()}moveMouse(n,u){const p=this.map,{bearingDelta:_}=this.mouseRotate.dragMove(n,u)||{};if(_&&p.setBearing(p.getBearing()+_),this.mousePitch){const{pitchDelta:m}=this.mousePitch.dragMove(n,u)||{};m&&p.setPitch(p.getPitch()+m)}}moveTouch(n,u){const p=this.map,{bearingDelta:_}=this.touchRotate.dragMove(n,u)||{};if(_&&p.setBearing(p.getBearing()+_),this.touchPitch){const{pitchDelta:m}=this.touchPitch.dragMove(n,u)||{};m&&p.setPitch(p.getPitch()+m)}}off(){const n=this.element;D.removeEventListener(n,"mousedown",this.mousedown),D.removeEventListener(n,"touchstart",this.touchstart,{passive:!1}),D.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.removeEventListener(window,"touchend",this.touchend),D.removeEventListener(n,"touchcancel",this.reset),this.offTemp()}offTemp(){D.enableDrag(),D.removeEventListener(window,"mousemove",this.mousemove),D.removeEventListener(window,"mouseup",this.mouseup),D.removeEventListener(window,"touchmove",this.touchmove,{passive:!1}),D.removeEventListener(window,"touchend",this.touchend)}}let uo;function Kp(y,n,u){const p=new c.N(y.lng,y.lat);if(y=new c.N(y.lng,y.lat),n){const _=new c.N(y.lng-360,y.lat),m=new c.N(y.lng+360,y.lat),T=u.locationPoint(y).distSqr(n);u.locationPoint(_).distSqr(n)180;){const _=u.locationPoint(y);if(_.x>=0&&_.y>=0&&_.x<=u.width&&_.y<=u.height)break;y.lng>u.center.lng?y.lng-=360:y.lng+=360}return y.lng!==p.lng&&u.locationPoint(y).y>u.height/2-u.getHorizon()?y:p}const Ad={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 fo(y,n,u){const p=y.classList;for(const _ in Ad)p.remove(`maplibregl-${u}-anchor-${_}`);p.add(`maplibregl-${u}-anchor-${n}`)}class Ti extends c.E{constructor(n){if(super(),this._onKeyPress=u=>{const p=u.code,_=u.charCode||u.keyCode;p!=="Space"&&p!=="Enter"&&_!==32&&_!==13||this.togglePopup()},this._onMapClick=u=>{const p=u.originalEvent.target,_=this._element;this._popup&&(p===_||_.contains(p))&&this.togglePopup()},this._update=u=>{var p;if(!this._map)return;const _=this._map.loaded()&&!this._map.isMoving();((u==null?void 0:u.type)==="terrain"||(u==null?void 0:u.type)==="render"&&!_)&&this._map.once("render",this._update),this._lngLat=this._map.transform.renderWorldCopies?Kp(this._lngLat,this._flatPos,this._map.transform):(p=this._lngLat)===null||p===void 0?void 0:p.wrap(),this._flatPos=this._pos=this._map.project(this._lngLat)._add(this._offset),this._map.terrain&&(this._flatPos=this._map.transform.locationPoint(this._lngLat)._add(this._offset));let m="";this._rotationAlignment==="viewport"||this._rotationAlignment==="auto"?m=`rotateZ(${this._rotation}deg)`:this._rotationAlignment==="map"&&(m=`rotateZ(${this._rotation-this._map.getBearing()}deg)`);let T="";this._pitchAlignment==="viewport"||this._pitchAlignment==="auto"?T="rotateX(0deg)":this._pitchAlignment==="map"&&(T=`rotateX(${this._map.getPitch()}deg)`),this._subpixelPositioning||u&&u.type!=="moveend"||(this._pos=this._pos.round()),D.setTransform(this._element,`${Ad[this._anchor]} translate(${this._pos.x}px, ${this._pos.y}px) ${T} ${m}`),M.frameAsync(new AbortController).then(()=>{this._updateOpacity(u&&u.type==="moveend")}).catch(()=>{})},this._onMove=u=>{if(!this._isDragging){const p=this._clickTolerance||this._map._clickTolerance;this._isDragging=u.point.dist(this._pointerdownPos)>=p}this._isDragging&&(this._pos=u.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 c.k("dragstart"))),this.fire(new c.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 c.k("dragend")),this._state="inactive"},this._addDragHandler=u=>{this._element.contains(u.originalEvent.target)&&(u.preventDefault(),this._positionDelta=u.point.sub(this._pos).add(this._offset),this._pointerdownPos=u.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=n&&n.anchor||"center",this._color=n&&n.color||"#3FB1CE",this._scale=n&&n.scale||1,this._draggable=n&&n.draggable||!1,this._clickTolerance=n&&n.clickTolerance||0,this._subpixelPositioning=n&&n.subpixelPositioning||!1,this._isDragging=!1,this._state="inactive",this._rotation=n&&n.rotation||0,this._rotationAlignment=n&&n.rotationAlignment||"auto",this._pitchAlignment=n&&n.pitchAlignment&&n.pitchAlignment!=="auto"?n.pitchAlignment:this._rotationAlignment,this.setOpacity(),this.setOpacity(n==null?void 0:n.opacity,n==null?void 0:n.opacityWhenCovered),n&&n.element)this._element=n.element,this._offset=c.P.convert(n&&n.offset||[0,0]);else{this._defaultMarker=!0,this._element=D.create("div");const u=D.createNS("http://www.w3.org/2000/svg","svg"),p=41,_=27;u.setAttributeNS(null,"display","block"),u.setAttributeNS(null,"height",`${p}px`),u.setAttributeNS(null,"width",`${_}px`),u.setAttributeNS(null,"viewBox",`0 0 ${_} ${p}`);const m=D.createNS("http://www.w3.org/2000/svg","g");m.setAttributeNS(null,"stroke","none"),m.setAttributeNS(null,"stroke-width","1"),m.setAttributeNS(null,"fill","none"),m.setAttributeNS(null,"fill-rule","evenodd");const T=D.createNS("http://www.w3.org/2000/svg","g");T.setAttributeNS(null,"fill-rule","nonzero");const A=D.createNS("http://www.w3.org/2000/svg","g");A.setAttributeNS(null,"transform","translate(3.0, 29.0)"),A.setAttributeNS(null,"fill","#000000");const R=[{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 oe of R){const de=D.createNS("http://www.w3.org/2000/svg","ellipse");de.setAttributeNS(null,"opacity","0.04"),de.setAttributeNS(null,"cx","10.5"),de.setAttributeNS(null,"cy","5.80029008"),de.setAttributeNS(null,"rx",oe.rx),de.setAttributeNS(null,"ry",oe.ry),A.appendChild(de)}const C=D.createNS("http://www.w3.org/2000/svg","g");C.setAttributeNS(null,"fill",this._color);const F=D.createNS("http://www.w3.org/2000/svg","path");F.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"),C.appendChild(F);const N=D.createNS("http://www.w3.org/2000/svg","g");N.setAttributeNS(null,"opacity","0.25"),N.setAttributeNS(null,"fill","#000000");const V=D.createNS("http://www.w3.org/2000/svg","path");V.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"),N.appendChild(V);const W=D.createNS("http://www.w3.org/2000/svg","g");W.setAttributeNS(null,"transform","translate(6.0, 7.0)"),W.setAttributeNS(null,"fill","#FFFFFF");const K=D.createNS("http://www.w3.org/2000/svg","g");K.setAttributeNS(null,"transform","translate(8.0, 8.0)");const se=D.createNS("http://www.w3.org/2000/svg","circle");se.setAttributeNS(null,"fill","#000000"),se.setAttributeNS(null,"opacity","0.25"),se.setAttributeNS(null,"cx","5.5"),se.setAttributeNS(null,"cy","5.5"),se.setAttributeNS(null,"r","5.4999962");const ie=D.createNS("http://www.w3.org/2000/svg","circle");ie.setAttributeNS(null,"fill","#FFFFFF"),ie.setAttributeNS(null,"cx","5.5"),ie.setAttributeNS(null,"cy","5.5"),ie.setAttributeNS(null,"r","5.4999962"),K.appendChild(se),K.appendChild(ie),T.appendChild(A),T.appendChild(C),T.appendChild(N),T.appendChild(W),T.appendChild(K),u.appendChild(T),u.setAttributeNS(null,"height",p*this._scale+"px"),u.setAttributeNS(null,"width",_*this._scale+"px"),this._element.appendChild(u),this._offset=c.P.convert(n&&n.offset||[0,-14])}if(this._element.classList.add("maplibregl-marker"),this._element.addEventListener("dragstart",u=>{u.preventDefault()}),this._element.addEventListener("mousedown",u=>{u.preventDefault()}),fo(this._element,this._anchor,"marker"),n&&n.className)for(const u of n.className.split(" "))this._element.classList.add(u);this._popup=null}addTo(n){return this.remove(),this._map=n,this._element.setAttribute("aria-label",n._getUIString("Marker.Title")),n.getCanvasContainer().appendChild(this._element),n.on("move",this._update),n.on("moveend",this._update),n.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),D.remove(this._element),this._popup&&this._popup.remove(),this}getLngLat(){return this._lngLat}setLngLat(n){return this._lngLat=c.N.convert(n),this._pos=null,this._popup&&this._popup.setLngLat(this._lngLat),this._update(),this}getElement(){return this._element}setPopup(n){if(this._popup&&(this._popup.remove(),this._popup=null,this._element.removeEventListener("keypress",this._onKeyPress),this._originalTabIndex||this._element.removeAttribute("tabindex")),n){if(!("offset"in n.options)){const _=Math.abs(13.5)/Math.SQRT2;n.options.offset=this._defaultMarker?{top:[0,0],"top-left":[0,0],"top-right":[0,0],bottom:[0,-38.1],"bottom-left":[_,-1*(38.1-13.5+_)],"bottom-right":[-_,-1*(38.1-13.5+_)],left:[13.5,-1*(38.1-13.5)],right:[-13.5,-1*(38.1-13.5)]}:this._offset}this._popup=n,this._originalTabIndex=this._element.getAttribute("tabindex"),this._originalTabIndex||this._element.setAttribute("tabindex","0"),this._element.addEventListener("keypress",this._onKeyPress)}return this}setSubpixelPositioning(n){return this._subpixelPositioning=n,this}getPopup(){return this._popup}togglePopup(){const n=this._popup;return this._element.style.opacity===this._opacityWhenCovered?this:n?(n.isOpen()?n.remove():(n.setLngLat(this._lngLat),n.addTo(this._map)),this):this}_updateOpacity(n=!1){var u,p;if(!(!((u=this._map)===null||u===void 0)&&u.terrain))return void(this._element.style.opacity!==this._opacity&&(this._element.style.opacity=this._opacity));if(n)this._opacityTimeout=null;else{if(this._opacityTimeout)return;this._opacityTimeout=setTimeout(()=>{this._opacityTimeout=null},100)}const _=this._map,m=_.terrain.depthAtPoint(this._pos),T=_.terrain.getElevationForLngLatZoom(this._lngLat,_.transform.tileZoom);if(_.transform.lngLatToCameraDepth(this._lngLat,T)-m<.006)return void(this._element.style.opacity=this._opacity);const A=-this._offset.y/_.transform._pixelPerMeter,R=Math.sin(_.getPitch()*Math.PI/180)*A,C=_.terrain.depthAtPoint(new c.P(this._pos.x,this._pos.y-this._offset.y)),F=_.transform.lngLatToCameraDepth(this._lngLat,T+R)-C>.006;!((p=this._popup)===null||p===void 0)&&p.isOpen()&&F&&this._popup.remove(),this._element.style.opacity=F?this._opacityWhenCovered:this._opacity}getOffset(){return this._offset}setOffset(n){return this._offset=c.P.convert(n),this._update(),this}addClassName(n){this._element.classList.add(n)}removeClassName(n){this._element.classList.remove(n)}toggleClassName(n){return this._element.classList.toggle(n)}setDraggable(n){return this._draggable=!!n,this._map&&(n?(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(n){return this._rotation=n||0,this._update(),this}getRotation(){return this._rotation}setRotationAlignment(n){return this._rotationAlignment=n||"auto",this._update(),this}getRotationAlignment(){return this._rotationAlignment}setPitchAlignment(n){return this._pitchAlignment=n&&n!=="auto"?n:this._rotationAlignment,this._update(),this}getPitchAlignment(){return this._pitchAlignment}setOpacity(n,u){return n===void 0&&u===void 0&&(this._opacity="1",this._opacityWhenCovered="0.2"),n!==void 0&&(this._opacity=n),u!==void 0&&(this._opacityWhenCovered=u),this._map&&this._updateOpacity(!0),this}}const ph={positionOptions:{enableHighAccuracy:!1,maximumAge:0,timeout:6e3},fitBoundsOptions:{maxZoom:15},trackUserLocation:!1,showAccuracyCircle:!0,showUserLocation:!0};let Oa=0,Fa=!1;const Jp={maxWidth:100,unit:"metric"};function Id(y,n,u){const p=u&&u.maxWidth||100,_=y._container.clientHeight/2,m=y.unproject([0,_]),T=y.unproject([p,_]),A=m.distanceTo(T);if(u&&u.unit==="imperial"){const R=3.2808*A;R>5280?Jl(n,p,R/5280,y._getUIString("ScaleControl.Miles")):Jl(n,p,R,y._getUIString("ScaleControl.Feet"))}else u&&u.unit==="nautical"?Jl(n,p,A/1852,y._getUIString("ScaleControl.NauticalMiles")):A>=1e3?Jl(n,p,A/1e3,y._getUIString("ScaleControl.Kilometers")):Jl(n,p,A,y._getUIString("ScaleControl.Meters"))}function Jl(y,n,u,p){const _=function(m){const T=Math.pow(10,`${Math.floor(m)}`.length-1);let A=m/T;return A=A>=10?10:A>=5?5:A>=3?3:A>=2?2:A>=1?1:function(R){const C=Math.pow(10,Math.ceil(-Math.log(R)/Math.LN10));return Math.round(R*C)/C}(A),T*A}(u);y.style.width=n*(_/u)+"px",y.innerHTML=`${_} ${p}`}const Mn={closeButton:!0,closeOnClick:!0,focusAfterOpen:!0,className:"",maxWidth:"240px",subpixelPositioning:!1},_h=["a[href]","[tabindex]:not([tabindex='-1'])","[contenteditable]:not([contenteditable='false'])","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])"].join(", ");function St(y){if(y){if(typeof y=="number"){const n=Math.round(Math.abs(y)/Math.SQRT2);return{center:new c.P(0,0),top:new c.P(0,y),"top-left":new c.P(n,n),"top-right":new c.P(-n,n),bottom:new c.P(0,-y),"bottom-left":new c.P(n,-n),"bottom-right":new c.P(-n,-n),left:new c.P(y,0),right:new c.P(-y,0)}}if(y instanceof c.P||Array.isArray(y)){const n=c.P.convert(y);return{center:n,top:n,"top-left":n,"top-right":n,bottom:n,"bottom-left":n,"bottom-right":n,left:n,right:n}}return{center:c.P.convert(y.center||[0,0]),top:c.P.convert(y.top||[0,0]),"top-left":c.P.convert(y["top-left"]||[0,0]),"top-right":c.P.convert(y["top-right"]||[0,0]),bottom:c.P.convert(y.bottom||[0,0]),"bottom-left":c.P.convert(y["bottom-left"]||[0,0]),"bottom-right":c.P.convert(y["bottom-right"]||[0,0]),left:c.P.convert(y.left||[0,0]),right:c.P.convert(y.right||[0,0])}}return St(new c.P(0,0))}const Mt=x;d.AJAXError=c.bg,d.Evented=c.E,d.LngLat=c.N,d.MercatorCoordinate=c.Z,d.Point=c.P,d.addProtocol=c.bh,d.config=c.a,d.removeProtocol=c.bi,d.AttributionControl=Da,d.BoxZoomHandler=ad,d.CanvasSource=bt,d.CooperativeGesturesHandler=ln,d.DoubleClickZoomHandler=bd,d.DragPanHandler=$s,d.DragRotateHandler=an,d.EdgeInsets=ah,d.FullscreenControl=class extends c.E{constructor(y={}){super(),this._onFullscreenChange=()=>{var n;let u=window.document.fullscreenElement||window.document.mozFullScreenElement||window.document.webkitFullscreenElement||window.document.msFullscreenElement;for(;!((n=u==null?void 0:u.shadowRoot)===null||n===void 0)&&n.fullscreenElement;)u=u.shadowRoot.fullscreenElement;u===this._container!==this._fullscreen&&this._handleFullscreenChange()},this._onClickFullscreen=()=>{this._isFullscreen()?this._exitFullscreen():this._requestFullscreen()},this._fullscreen=!1,y&&y.container&&(y.container instanceof HTMLElement?this._container=y.container:c.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(y){return this._map=y,this._container||(this._container=this._map.getContainer()),this._controlContainer=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),this._controlContainer}onRemove(){D.remove(this._controlContainer),this._map=null,window.document.removeEventListener(this._fullscreenchange,this._onFullscreenChange)}_setupUI(){const y=this._fullscreenButton=D.create("button","maplibregl-ctrl-fullscreen",this._controlContainer);D.create("span","maplibregl-ctrl-icon",y).setAttribute("aria-hidden","true"),y.type="button",this._updateTitle(),this._fullscreenButton.addEventListener("click",this._onClickFullscreen),window.document.addEventListener(this._fullscreenchange,this._onFullscreenChange)}_updateTitle(){const y=this._getTitle();this._fullscreenButton.setAttribute("aria-label",y),this._fullscreenButton.title=y}_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 c.k("fullscreenstart")),this._prevCooperativeGesturesEnabled=this._map.cooperativeGestures.isEnabled(),this._map.cooperativeGestures.disable()):(this.fire(new c.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()}},d.GeoJSONSource=Je,d.GeolocateControl=class extends c.E{constructor(y){super(),this._onSuccess=n=>{if(this._map){if(this._isOutOfMapMaxBounds(n))return this._setErrorState(),this.fire(new c.k("outofmaxbounds",n)),this._updateMarker(),void this._finish();if(this.options.trackUserLocation)switch(this._lastKnownPosition=n,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(n),this.options.trackUserLocation&&this._watchState!=="ACTIVE_LOCK"||this._updateCamera(n),this.options.showUserLocation&&this._dotElement.classList.remove("maplibregl-user-location-dot-stale"),this.fire(new c.k("geolocate",n)),this._finish()}},this._updateCamera=n=>{const u=new c.N(n.coords.longitude,n.coords.latitude),p=n.coords.accuracy,_=this._map.getBearing(),m=c.e({bearing:_},this.options.fitBoundsOptions),T=ae.fromLngLat(u,p);this._map.fitBounds(T,m,{geolocateSource:!0})},this._updateMarker=n=>{if(n){const u=new c.N(n.coords.longitude,n.coords.latitude);this._accuracyCircleMarker.setLngLat(u).addTo(this._map),this._userLocationDotMarker.setLngLat(u).addTo(this._map),this._accuracy=n.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=n=>{if(this._map){if(this.options.trackUserLocation)if(n.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 u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u),this._geolocationWatchID!==void 0&&this._clearWatch()}else{if(n.code===3&&Fa)return;this._setErrorState()}this._watchState!=="OFF"&&this.options.showUserLocation&&this._dotElement.classList.add("maplibregl-user-location-dot-stale"),this.fire(new c.k("error",n)),this._finish()}},this._finish=()=>{this._timeoutId&&clearTimeout(this._timeoutId),this._timeoutId=void 0},this._setupUI=()=>{this._map&&(this._container.addEventListener("contextmenu",n=>n.preventDefault()),this._geolocateButton=D.create("button","maplibregl-ctrl-geolocate",this._container),D.create("span","maplibregl-ctrl-icon",this._geolocateButton).setAttribute("aria-hidden","true"),this._geolocateButton.type="button",this._geolocateButton.disabled=!0)},this._finishSetupUI=n=>{if(this._map){if(n===!1){c.w("Geolocation support is not available so the GeolocateControl will be disabled.");const u=this._map._getUIString("GeolocateControl.LocationNotAvailable");this._geolocateButton.disabled=!0,this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u)}else{const u=this._map._getUIString("GeolocateControl.FindMyLocation");this._geolocateButton.disabled=!1,this._geolocateButton.title=u,this._geolocateButton.setAttribute("aria-label",u)}this.options.trackUserLocation&&(this._geolocateButton.setAttribute("aria-pressed","false"),this._watchState="OFF"),this.options.showUserLocation&&(this._dotElement=D.create("div","maplibregl-user-location-dot"),this._userLocationDotMarker=new Ti({element:this._dotElement}),this._circleElement=D.create("div","maplibregl-user-location-accuracy-circle"),this._accuracyCircleMarker=new Ti({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",u=>{u.geolocateSource||this._watchState!=="ACTIVE_LOCK"||u.originalEvent&&u.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 c.k("trackuserlocationend")),this.fire(new c.k("userlocationlostfocus")))})}},this.options=c.e({},ph,y)}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._setupUI(),function(){return c._(this,arguments,void 0,function*(n=!1){if(uo!==void 0&&!n)return uo;if(window.navigator.permissions===void 0)return uo=!!window.navigator.geolocation,uo;try{uo=(yield window.navigator.permissions.query({name:"geolocation"})).state!=="denied"}catch{uo=!!window.navigator.geolocation}return uo})}().then(n=>this._finishSetupUI(n)),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(),D.remove(this._container),this._map.off("zoom",this._onZoom),this._map=void 0,Oa=0,Fa=!1}_isOutOfMapMaxBounds(y){const n=this._map.getMaxBounds(),u=y.coords;return n&&(u.longituden.getEast()||u.latituden.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 y=this._map.getBounds(),n=y.getSouthEast(),u=y.getNorthEast(),p=n.distanceTo(u),_=Math.ceil(this._accuracy/(p/this._map._container.clientHeight)*2);this._circleElement.style.width=`${_}px`,this._circleElement.style.height=`${_}px`}trigger(){if(!this._setup)return c.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 c.k("trackuserlocationstart"));break;case"WAITING_ACTIVE":case"ACTIVE_LOCK":case"ACTIVE_ERROR":case"BACKGROUND_ERROR":Oa--,Fa=!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 c.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 c.k("trackuserlocationstart")),this.fire(new c.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 y;this._geolocateButton.classList.add("maplibregl-ctrl-geolocate-waiting"),this._geolocateButton.setAttribute("aria-pressed","true"),Oa++,Oa>1?(y={maximumAge:6e5,timeout:0},Fa=!0):(y=this.options.positionOptions,Fa=!1),this._geolocationWatchID=window.navigator.geolocation.watchPosition(this._onSuccess,this._onError,y)}}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)}},d.Hash=$l,d.ImageSource=ft,d.KeyboardHandler=gd,d.LngLatBounds=ae,d.LogoControl=Rn,d.Map=class extends ky{constructor(y){c.be.mark(c.bf.create);const n=Object.assign(Object.assign({},Dy),y);if(n.minZoom!=null&&n.maxZoom!=null&&n.minZoom>n.maxZoom)throw new Error("maxZoom must be greater than or equal to minZoom");if(n.minPitch!=null&&n.maxPitch!=null&&n.minPitch>n.maxPitch)throw new Error("maxPitch must be greater than or equal to minPitch");if(n.minPitch!=null&&n.minPitch<0)throw new Error("minPitch must be greater than or equal to 0");if(n.maxPitch!=null&&n.maxPitch>85)throw new Error("maxPitch must be less than or equal to 85");if(super(new id(n.minZoom,n.maxZoom,n.minPitch,n.maxPitch,n.renderWorldCopies),{bearingSnap:n.bearingSnap}),this._idleTriggered=!1,this._crossFadingFactor=1,this._renderTaskQueue=new _t,this._controls=[],this._mapId=c.a4(),this._contextLost=u=>{u.preventDefault(),this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this.fire(new c.k("webglcontextlost",{originalEvent:u}))},this._contextRestored=u=>{this._setupPainter(),this.resize(),this._update(),this.fire(new c.k("webglcontextrestored",{originalEvent:u}))},this._onMapScroll=u=>{if(u.target===this._container)return this._container.scrollTop=0,this._container.scrollLeft=0,!1},this._onWindowOnline=()=>{this._update()},this._interactive=n.interactive,this._maxTileCacheSize=n.maxTileCacheSize,this._maxTileCacheZoomLevels=n.maxTileCacheZoomLevels,this._failIfMajorPerformanceCaveat=n.failIfMajorPerformanceCaveat===!0,this._preserveDrawingBuffer=n.preserveDrawingBuffer===!0,this._antialias=n.antialias===!0,this._trackResize=n.trackResize===!0,this._bearingSnap=n.bearingSnap,this._refreshExpiredTiles=n.refreshExpiredTiles===!0,this._fadeDuration=n.fadeDuration,this._crossSourceCollisions=n.crossSourceCollisions===!0,this._collectResourceTiming=n.collectResourceTiming===!0,this._locale=Object.assign(Object.assign({},at),n.locale),this._clickTolerance=n.clickTolerance,this._overridePixelRatio=n.pixelRatio,this._maxCanvasSize=n.maxCanvasSize,this.transformCameraUpdate=n.transformCameraUpdate,this.cancelPendingTileRequestsWhileZooming=n.cancelPendingTileRequestsWhileZooming===!0,this._imageQueueHandle=Se.addThrottleControl(()=>this.isMoving()),this._requestManager=new Be(n.transformRequest),typeof n.container=="string"){if(this._container=document.getElementById(n.container),!this._container)throw new Error(`Container '${n.container}' not found.`)}else{if(!(n.container instanceof HTMLElement))throw new Error("Invalid type: 'container' must be a String or HTMLElement.");this._container=n.container}if(n.maxBounds&&this.setMaxBounds(n.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 u=!1;const p=lh(_=>{this._trackResize&&!this._removed&&this.resize(_)._update()},50);this._resizeObserver=new ResizeObserver(_=>{u?p(_):u=!0}),this._resizeObserver.observe(this._container)}this.handlers=new My(this,n),this._hash=n.hash&&new $l(typeof n.hash=="string"&&n.hash||void 0).addTo(this),this._hash&&this._hash._onHashChange()||(this.jumpTo({center:n.center,zoom:n.zoom,bearing:n.bearing,pitch:n.pitch}),n.bounds&&(this.resize(),this.fitBounds(n.bounds,c.e({},n.fitBoundsOptions,{duration:0})))),this.resize(),this._localIdeographFontFamily=n.localIdeographFontFamily,this._validateStyle=n.validateStyle,n.style&&this.setStyle(n.style,{localIdeographFontFamily:n.localIdeographFontFamily}),n.attributionControl&&this.addControl(new Da(typeof n.attributionControl=="boolean"?void 0:n.attributionControl)),n.maplibreLogo&&this.addControl(new Rn,n.logoPosition),this.on("style.load",()=>{this.transform.unmodified&&this.jumpTo(this.style.stylesheet)}),this.on("data",u=>{this._update(u.dataType==="style"),this.fire(new c.k(`${u.dataType}data`,u))}),this.on("dataloading",u=>{this.fire(new c.k(`${u.dataType}dataloading`,u))}),this.on("dataabort",u=>{this.fire(new c.k("sourcedataabort",u))})}_getMapId(){return this._mapId}addControl(y,n){if(n===void 0&&(n=y.getDefaultPosition?y.getDefaultPosition():"top-right"),!y||!y.onAdd)return this.fire(new c.j(new Error("Invalid argument to map.addControl(). Argument must be a control with onAdd and onRemove methods.")));const u=y.onAdd(this);this._controls.push(y);const p=this._controlPositions[n];return n.indexOf("bottom")!==-1?p.insertBefore(u,p.firstChild):p.appendChild(u),this}removeControl(y){if(!y||!y.onRemove)return this.fire(new c.j(new Error("Invalid argument to map.removeControl(). Argument must be a control with onAdd and onRemove methods.")));const n=this._controls.indexOf(y);return n>-1&&this._controls.splice(n,1),y.onRemove(this),this}hasControl(y){return this._controls.indexOf(y)>-1}calculateCameraOptionsFromTo(y,n,u,p){return p==null&&this.terrain&&(p=this.terrain.getElevationForLngLatZoom(u,this.transform.tileZoom)),super.calculateCameraOptionsFromTo(y,n,u,p)}resize(y){var n;const u=this._containerDimensions(),p=u[0],_=u[1],m=this._getClampedPixelRatio(p,_);if(this._resizeCanvas(p,_,m),this.painter.resize(p,_,m),this.painter.overLimit()){const A=this.painter.context.gl;this._maxCanvasSize=[A.drawingBufferWidth,A.drawingBufferHeight];const R=this._getClampedPixelRatio(p,_);this._resizeCanvas(p,_,R),this.painter.resize(p,_,R)}this.transform.resize(p,_),(n=this._requestedCameraState)===null||n===void 0||n.resize(p,_);const T=!this._moving;return T&&(this.stop(),this.fire(new c.k("movestart",y)).fire(new c.k("move",y))),this.fire(new c.k("resize",y)),T&&this.fire(new c.k("moveend",y)),this}_getClampedPixelRatio(y,n){const{0:u,1:p}=this._maxCanvasSize,_=this.getPixelRatio(),m=y*_,T=n*_;return Math.min(m>u?u/m:1,T>p?p/T:1)*_}getPixelRatio(){var y;return(y=this._overridePixelRatio)!==null&&y!==void 0?y:devicePixelRatio}setPixelRatio(y){this._overridePixelRatio=y,this.resize()}getBounds(){return this.transform.getBounds()}getMaxBounds(){return this.transform.getMaxBounds()}setMaxBounds(y){return this.transform.setMaxBounds(ae.convert(y)),this._update()}setMinZoom(y){if((y=y??-2)>=-2&&y<=this.transform.maxZoom)return this.transform.minZoom=y,this._update(),this.getZoom()=this.transform.minZoom)return this.transform.maxZoom=y,this._update(),this.getZoom()>y&&this.setZoom(y),this;throw new Error("maxZoom must be greater than the current minZoom")}getMaxZoom(){return this.transform.maxZoom}setMinPitch(y){if((y=y??0)<0)throw new Error("minPitch must be greater than or equal to 0");if(y>=0&&y<=this.transform.maxPitch)return this.transform.minPitch=y,this._update(),this.getPitch()85)throw new Error("maxPitch must be less than or equal to 85");if(y>=this.transform.minPitch)return this.transform.maxPitch=y,this._update(),this.getPitch()>y&&this.setPitch(y),this;throw new Error("maxPitch must be greater than the current minPitch")}getMaxPitch(){return this.transform.maxPitch}getRenderWorldCopies(){return this.transform.renderWorldCopies}setRenderWorldCopies(y){return this.transform.renderWorldCopies=y,this._update()}project(y){return this.transform.locationPoint(c.N.convert(y),this.style&&this.terrain)}unproject(y){return this.transform.pointLocation(c.P.convert(y),this.terrain)}isMoving(){var y;return this._moving||((y=this.handlers)===null||y===void 0?void 0:y.isMoving())}isZooming(){var y;return this._zooming||((y=this.handlers)===null||y===void 0?void 0:y.isZooming())}isRotating(){var y;return this._rotating||((y=this.handlers)===null||y===void 0?void 0:y.isRotating())}_createDelegatedListener(y,n,u){if(y==="mouseenter"||y==="mouseover"){let p=!1;return{layer:n,listener:u,delegates:{mousemove:m=>{const T=this.getLayer(n)?this.queryRenderedFeatures(m.point,{layers:[n]}):[];T.length?p||(p=!0,u.call(this,new Gr(y,this,m.originalEvent,{features:T}))):p=!1},mouseout:()=>{p=!1}}}}if(y==="mouseleave"||y==="mouseout"){let p=!1;return{layer:n,listener:u,delegates:{mousemove:T=>{(this.getLayer(n)?this.queryRenderedFeatures(T.point,{layers:[n]}):[]).length?p=!0:p&&(p=!1,u.call(this,new Gr(y,this,T.originalEvent)))},mouseout:T=>{p&&(p=!1,u.call(this,new Gr(y,this,T.originalEvent)))}}}}{const p=_=>{const m=this.getLayer(n)?this.queryRenderedFeatures(_.point,{layers:[n]}):[];m.length&&(_.features=m,u.call(this,_),delete _.features)};return{layer:n,listener:u,delegates:{[y]:p}}}}on(y,n,u){if(u===void 0)return super.on(y,n);const p=this._createDelegatedListener(y,n,u);this._delegatedListeners=this._delegatedListeners||{},this._delegatedListeners[y]=this._delegatedListeners[y]||[],this._delegatedListeners[y].push(p);for(const _ in p.delegates)this.on(_,p.delegates[_]);return this}once(y,n,u){if(u===void 0)return super.once(y,n);const p=this._createDelegatedListener(y,n,u);for(const _ in p.delegates)this.once(_,p.delegates[_]);return this}off(y,n,u){return u===void 0?super.off(y,n):(this._delegatedListeners&&this._delegatedListeners[y]&&(p=>{const _=this._delegatedListeners[y];for(let m=0;m<_.length;m++){const T=_[m];if(T.layer===n&&T.listener===u){for(const A in T.delegates)this.off(A,T.delegates[A]);return _.splice(m,1),this}}})(),this)}queryRenderedFeatures(y,n){if(!this.style)return[];let u;const p=y instanceof c.P||Array.isArray(y),_=p?y:[[0,0],[this.transform.width,this.transform.height]];if(n=n||(p?{}:y)||{},_ instanceof c.P||typeof _[0]=="number")u=[c.P.convert(_)];else{const m=c.P.convert(_[0]),T=c.P.convert(_[1]);u=[m,new c.P(T.x,m.y),T,new c.P(m.x,T.y),m]}return this.style.queryRenderedFeatures(u,n,this.transform)}querySourceFeatures(y,n){return this.style.querySourceFeatures(y,n)}setStyle(y,n){return(n=c.e({},{localIdeographFontFamily:this._localIdeographFontFamily,validate:this._validateStyle},n)).diff!==!1&&n.localIdeographFontFamily===this._localIdeographFontFamily&&this.style&&y?(this._diffStyle(y,n),this):(this._localIdeographFontFamily=n.localIdeographFontFamily,this._updateStyle(y,n))}setTransformRequest(y){return this._requestManager.setTransformRequest(y),this}_getUIString(y){const n=this._locale[y];if(n==null)throw new Error(`Missing UI string '${y}'`);return n}_updateStyle(y,n){if(n.transformStyle&&this.style&&!this.style._loaded)return void this.style.once("style.load",()=>this._updateStyle(y,n));const u=this.style&&n.transformStyle?this.style.serialize():void 0;return this.style&&(this.style.setEventedParent(null),this.style._remove(!y)),y?(this.style=new js(this,n||{}),this.style.setEventedParent(this,{style:this.style}),typeof y=="string"?this.style.loadURL(y,n,u):this.style.loadJSON(y,n,u),this):(delete this.style,this)}_lazyInitEmptyStyle(){this.style||(this.style=new js(this,{}),this.style.setEventedParent(this,{style:this.style}),this.style.loadEmpty())}_diffStyle(y,n){if(typeof y=="string"){const u=this._requestManager.transformRequest(y,"Style");c.h(u,new AbortController).then(p=>{this._updateDiff(p.data,n)}).catch(p=>{p&&this.fire(new c.j(p))})}else typeof y=="object"&&this._updateDiff(y,n)}_updateDiff(y,n){try{this.style.setState(y,n)&&this._update(!0)}catch(u){c.w(`Unable to perform style diff: ${u.message||u.error||u}. Rebuilding the style from scratch.`),this._updateStyle(y,n)}}getStyle(){if(this.style)return this.style.serialize()}isStyleLoaded(){return this.style?this.style.loaded():c.w("There is no style added to the map.")}addSource(y,n){return this._lazyInitEmptyStyle(),this.style.addSource(y,n),this._update(!0)}isSourceLoaded(y){const n=this.style&&this.style.sourceCaches[y];if(n!==void 0)return n.loaded();this.fire(new c.j(new Error(`There is no source with ID '${y}'`)))}setTerrain(y){if(this.style._checkLoaded(),this._terrainDataCallback&&this.style.off("data",this._terrainDataCallback),y){const n=this.style.sourceCaches[y.source];if(!n)throw new Error(`cannot load terrain, because there exists no source with ID: ${y.source}`);this.terrain===null&&n.reload();for(const u in this.style._layers){const p=this.style._layers[u];p.type==="hillshade"&&p.source===y.source&&c.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 Xp(this.painter,n,y),this.painter.renderToTexture=new qp(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=u=>{u.dataType==="style"?this.terrain.sourceCache.freeRtt():u.dataType==="source"&&u.tile&&(u.sourceId!==y.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(u.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 c.k("terrain",{terrain:y})),this}getTerrain(){var y,n;return(n=(y=this.terrain)===null||y===void 0?void 0:y.options)!==null&&n!==void 0?n:null}areTilesLoaded(){const y=this.style&&this.style.sourceCaches;for(const n in y){const u=y[n]._tiles;for(const p in u){const _=u[p];if(_.state!=="loaded"&&_.state!=="errored")return!1}}return!0}removeSource(y){return this.style.removeSource(y),this._update(!0)}getSource(y){return this.style.getSource(y)}addImage(y,n,u={}){const{pixelRatio:p=1,sdf:_=!1,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C}=u;if(this._lazyInitEmptyStyle(),!(n instanceof HTMLImageElement||c.b(n))){if(n.width===void 0||n.height===void 0)return this.fire(new c.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:F,height:N,data:V}=n,W=n;return this.style.addImage(y,{data:new c.R({width:F,height:N},new Uint8Array(V)),pixelRatio:p,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C,sdf:_,version:0,userImage:W}),W.onAdd&&W.onAdd(this,y),this}}{const{width:F,height:N,data:V}=M.getImageData(n);this.style.addImage(y,{data:new c.R({width:F,height:N},V),pixelRatio:p,stretchX:m,stretchY:T,content:A,textFitWidth:R,textFitHeight:C,sdf:_,version:0})}}updateImage(y,n){const u=this.style.getImage(y);if(!u)return this.fire(new c.j(new Error("The map has no image with that id. If you are adding a new image use `map.addImage(...)` instead.")));const p=n instanceof HTMLImageElement||c.b(n)?M.getImageData(n):n,{width:_,height:m,data:T}=p;if(_===void 0||m===void 0)return this.fire(new c.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(_!==u.data.width||m!==u.data.height)return this.fire(new c.j(new Error("The width and height of the updated image must be that same as the previous version of the image")));const A=!(n instanceof HTMLImageElement||c.b(n));return u.data.replace(T,A),this.style.updateImage(y,u),this}getImage(y){return this.style.getImage(y)}hasImage(y){return y?!!this.style.getImage(y):(this.fire(new c.j(new Error("Missing required image id"))),!1)}removeImage(y){this.style.removeImage(y)}loadImage(y){return Se.getImage(this._requestManager.transformRequest(y,"Image"),new AbortController)}listImages(){return this.style.listImages()}addLayer(y,n){return this._lazyInitEmptyStyle(),this.style.addLayer(y,n),this._update(!0)}moveLayer(y,n){return this.style.moveLayer(y,n),this._update(!0)}removeLayer(y){return this.style.removeLayer(y),this._update(!0)}getLayer(y){return this.style.getLayer(y)}getLayersOrder(){return this.style.getLayersOrder()}setLayerZoomRange(y,n,u){return this.style.setLayerZoomRange(y,n,u),this._update(!0)}setFilter(y,n,u={}){return this.style.setFilter(y,n,u),this._update(!0)}getFilter(y){return this.style.getFilter(y)}setPaintProperty(y,n,u,p={}){return this.style.setPaintProperty(y,n,u,p),this._update(!0)}getPaintProperty(y,n){return this.style.getPaintProperty(y,n)}setLayoutProperty(y,n,u,p={}){return this.style.setLayoutProperty(y,n,u,p),this._update(!0)}getLayoutProperty(y,n){return this.style.getLayoutProperty(y,n)}setGlyphs(y,n={}){return this._lazyInitEmptyStyle(),this.style.setGlyphs(y,n),this._update(!0)}getGlyphs(){return this.style.getGlyphsUrl()}addSprite(y,n,u={}){return this._lazyInitEmptyStyle(),this.style.addSprite(y,n,u,p=>{p||this._update(!0)}),this}removeSprite(y){return this._lazyInitEmptyStyle(),this.style.removeSprite(y),this._update(!0)}getSprite(){return this.style.getSprite()}setSprite(y,n={}){return this._lazyInitEmptyStyle(),this.style.setSprite(y,n,u=>{u||this._update(!0)}),this}setLight(y,n={}){return this._lazyInitEmptyStyle(),this.style.setLight(y,n),this._update(!0)}getLight(){return this.style.getLight()}setSky(y){return this._lazyInitEmptyStyle(),this.style.setSky(y),this._update(!0)}getSky(){return this.style.getSky()}setFeatureState(y,n){return this.style.setFeatureState(y,n),this._update()}removeFeatureState(y,n){return this.style.removeFeatureState(y,n),this._update()}getFeatureState(y){return this.style.getFeatureState(y)}getContainer(){return this._container}getCanvasContainer(){return this._canvasContainer}getCanvas(){return this._canvas}_containerDimensions(){let y=0,n=0;return this._container&&(y=this._container.clientWidth||400,n=this._container.clientHeight||300),[y,n]}_setupContainer(){const y=this._container;y.classList.add("maplibregl-map");const n=this._canvasContainer=D.create("div","maplibregl-canvas-container",y);this._interactive&&n.classList.add("maplibregl-interactive"),this._canvas=D.create("canvas","maplibregl-canvas",n),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 u=this._containerDimensions(),p=this._getClampedPixelRatio(u[0],u[1]);this._resizeCanvas(u[0],u[1],p);const _=this._controlContainer=D.create("div","maplibregl-control-container",y),m=this._controlPositions={};["top-left","top-right","bottom-left","bottom-right"].forEach(T=>{m[T]=D.create("div",`maplibregl-ctrl-${T} `,_)}),this._container.addEventListener("scroll",this._onMapScroll,!1)}_resizeCanvas(y,n,u){this._canvas.width=Math.floor(u*y),this._canvas.height=Math.floor(u*n),this._canvas.style.width=`${y}px`,this._canvas.style.height=`${n}px`}_setupPainter(){const y={alpha:!0,stencil:!0,depth:!0,failIfMajorPerformanceCaveat:this._failIfMajorPerformanceCaveat,preserveDrawingBuffer:this._preserveDrawingBuffer,antialias:this._antialias||!1};let n=null;this._canvas.addEventListener("webglcontextcreationerror",p=>{n={requestedAttributes:y},p&&(n.statusMessage=p.statusMessage,n.type=p.type)},{once:!0});const u=this._canvas.getContext("webgl2",y)||this._canvas.getContext("webgl",y);if(!u){const p="Failed to initialize WebGL";throw n?(n.message=p,new Error(JSON.stringify(n))):new Error(p)}this.painter=new Lp(u,this.transform),H.testSupport(u)}loaded(){return!this._styleDirty&&!this._sourcesDirty&&!!this.style&&this.style.loaded()}_update(y){return this.style&&this.style._loaded?(this._styleDirty=this._styleDirty||y,this._sourcesDirty=!0,this.triggerRepaint(),this):this}_requestRenderFrame(y){return this._update(),this._renderTaskQueue.add(y)}_cancelRenderFrame(y){this._renderTaskQueue.remove(y)}_render(y){const n=this._idleTriggered?this._fadeDuration:0;if(this.painter.context.setDirty(),this.painter.setBaseState(),this._renderTaskQueue.run(y),this._removed)return;let u=!1;if(this.style&&this._styleDirty){this._styleDirty=!1;const _=this.transform.zoom,m=M.now();this.style.zoomHistory.update(_,m);const T=new c.a9(_,{now:m,fadeDuration:n,zoomHistory:this.style.zoomHistory,transition:this.style.getTransition()}),A=T.crossFadingFactor();A===1&&A===this._crossFadingFactor||(u=!0,this._crossFadingFactor=A),this.style.update(T)}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,n,this._crossSourceCollisions),this.painter.render(this.style,{showTileBoundaries:this.showTileBoundaries,showOverdrawInspector:this._showOverdrawInspector,rotating:this.isRotating(),zooming:this.isZooming(),moving:this.isMoving(),fadeDuration:n,showPadding:this.showPadding}),this.fire(new c.k("render")),this.loaded()&&!this._loaded&&(this._loaded=!0,c.be.mark(c.bf.load),this.fire(new c.k("load"))),this.style&&(this.style.hasTransitions()||u)&&(this._styleDirty=!0),this.style&&!this._placementDirty&&this.style._releaseSymbolFadeTiles();const p=this._sourcesDirty||this._styleDirty||this._placementDirty;return p||this._repaint?this.triggerRepaint():!this.isMoving()&&this.loaded()&&this.fire(new c.k("idle")),!this._loaded||this._fullyLoaded||p||(this._fullyLoaded=!0,c.be.mark(c.bf.fullLoad)),this}redraw(){return this.style&&(this._frameRequest&&(this._frameRequest.abort(),this._frameRequest=null),this._render(0)),this}remove(){var y;this._hash&&this._hash.remove();for(const u of this._controls)u.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),Se.removeThrottleControl(this._imageQueueHandle),(y=this._resizeObserver)===null||y===void 0||y.disconnect();const n=this.painter.context.gl.getExtension("WEBGL_lose_context");n!=null&&n.loseContext&&n.loseContext(),this._canvas.removeEventListener("webglcontextrestored",this._contextRestored,!1),this._canvas.removeEventListener("webglcontextlost",this._contextLost,!1),D.remove(this._canvasContainer),D.remove(this._controlContainer),this._container.classList.remove("maplibregl-map"),c.be.clearMetrics(),this._removed=!0,this.fire(new c.k("remove"))}triggerRepaint(){this.style&&!this._frameRequest&&(this._frameRequest=new AbortController,M.frameAsync(this._frameRequest).then(y=>{c.be.frame(y),this._frameRequest=null,this._render(y)}).catch(()=>{}))}get showTileBoundaries(){return!!this._showTileBoundaries}set showTileBoundaries(y){this._showTileBoundaries!==y&&(this._showTileBoundaries=y,this._update())}get showPadding(){return!!this._showPadding}set showPadding(y){this._showPadding!==y&&(this._showPadding=y,this._update())}get showCollisionBoxes(){return!!this._showCollisionBoxes}set showCollisionBoxes(y){this._showCollisionBoxes!==y&&(this._showCollisionBoxes=y,y?this.style._generateCollisionBoxes():this._update())}get showOverdrawInspector(){return!!this._showOverdrawInspector}set showOverdrawInspector(y){this._showOverdrawInspector!==y&&(this._showOverdrawInspector=y,this._update())}get repaint(){return!!this._repaint}set repaint(y){this._repaint!==y&&(this._repaint=y,this.triggerRepaint())}get vertices(){return!!this._vertices}set vertices(y){this._vertices=y,this._update()}get version(){return Sd}getCameraTargetElevation(){return this.transform.elevation}},d.MapMouseEvent=Gr,d.MapTouchEvent=Wl,d.MapWheelEvent=nd,d.Marker=Ti,d.NavigationControl=class{constructor(y){this._updateZoomButtons=()=>{const n=this._map.getZoom(),u=n===this._map.getMaxZoom(),p=n===this._map.getMinZoom();this._zoomInButton.disabled=u,this._zoomOutButton.disabled=p,this._zoomInButton.setAttribute("aria-disabled",u.toString()),this._zoomOutButton.setAttribute("aria-disabled",p.toString())},this._rotateCompassArrow=()=>{const n=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=n},this._setButtonTitle=(n,u)=>{const p=this._map._getUIString(`NavigationControl.${u}`);n.title=p,n.setAttribute("aria-label",p)},this.options=c.e({},Ed,y),this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._container.addEventListener("contextmenu",n=>n.preventDefault()),this.options.showZoom&&(this._zoomInButton=this._createButton("maplibregl-ctrl-zoom-in",n=>this._map.zoomIn({},{originalEvent:n})),D.create("span","maplibregl-ctrl-icon",this._zoomInButton).setAttribute("aria-hidden","true"),this._zoomOutButton=this._createButton("maplibregl-ctrl-zoom-out",n=>this._map.zoomOut({},{originalEvent:n})),D.create("span","maplibregl-ctrl-icon",this._zoomOutButton).setAttribute("aria-hidden","true")),this.options.showCompass&&(this._compass=this._createButton("maplibregl-ctrl-compass",n=>{this.options.visualizePitch?this._map.resetNorthPitch({},{originalEvent:n}):this._map.resetNorth({},{originalEvent:n})}),this._compassIcon=D.create("span","maplibregl-ctrl-icon",this._compass),this._compassIcon.setAttribute("aria-hidden","true"))}onAdd(y){return this._map=y,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 Yp(this._map,this._compass,this.options.visualizePitch)),this._container}onRemove(){D.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(y,n){const u=D.create("button",y,this._container);return u.type="button",u.addEventListener("click",n),u}},d.Popup=class extends c.E{constructor(y){super(),this.remove=()=>(this._content&&D.remove(this._content),this._container&&(D.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 c.k("close"))),this),this._onMouseUp=n=>{this._update(n.point)},this._onMouseMove=n=>{this._update(n.point)},this._onDrag=n=>{this._update(n.point)},this._update=n=>{var u;if(!this._map||!this._lngLat&&!this._trackPointer||!this._content)return;if(!this._container){if(this._container=D.create("div","maplibregl-popup",this._map.getContainer()),this._tip=D.create("div","maplibregl-popup-tip",this._container),this._container.appendChild(this._content),this.options.className)for(const A of this.options.className.split(" "))this._container.classList.add(A);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?Kp(this._lngLat,this._flatPos,this._map.transform):(u=this._lngLat)===null||u===void 0?void 0:u.wrap(),this._trackPointer&&!n)return;const p=this._flatPos=this._pos=this._trackPointer&&n?n:this._map.project(this._lngLat);this._map.terrain&&(this._flatPos=this._trackPointer&&n?n:this._map.transform.locationPoint(this._lngLat));let _=this.options.anchor;const m=St(this.options.offset);if(!_){const A=this._container.offsetWidth,R=this._container.offsetHeight;let C;C=p.y+m.bottom.ythis._map.transform.height-R?["bottom"]:[],p.xthis._map.transform.width-A/2&&C.push("right"),_=C.length===0?"bottom":C.join("-")}let T=p.add(m[_]);this.options.subpixelPositioning||(T=T.round()),D.setTransform(this._container,`${Ad[_]} translate(${T.x}px,${T.y}px)`),fo(this._container,_,"popup")},this._onClose=()=>{this.remove()},this.options=c.e(Object.create(Mn),y)}addTo(y){return this._map&&this.remove(),this._map=y,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 c.k("open")),this}isOpen(){return!!this._map}getLngLat(){return this._lngLat}setLngLat(y){return this._lngLat=c.N.convert(y),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(y){return this.setDOMContent(document.createTextNode(y))}setHTML(y){const n=document.createDocumentFragment(),u=document.createElement("body");let p;for(u.innerHTML=y;p=u.firstChild,p;)n.appendChild(p);return this.setDOMContent(n)}getMaxWidth(){var y;return(y=this._container)===null||y===void 0?void 0:y.style.maxWidth}setMaxWidth(y){return this.options.maxWidth=y,this._update(),this}setDOMContent(y){if(this._content)for(;this._content.hasChildNodes();)this._content.firstChild&&this._content.removeChild(this._content.firstChild);else this._content=D.create("div","maplibregl-popup-content",this._container);return this._content.appendChild(y),this._createCloseButton(),this._update(),this._focusFirstElement(),this}addClassName(y){return this._container&&this._container.classList.add(y),this}removeClassName(y){return this._container&&this._container.classList.remove(y),this}setOffset(y){return this.options.offset=y,this._update(),this}toggleClassName(y){if(this._container)return this._container.classList.toggle(y)}setSubpixelPositioning(y){this.options.subpixelPositioning=y}_createCloseButton(){this.options.closeButton&&(this._closeButton=D.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 y=this._container.querySelector(_h);y&&y.focus()}},d.RasterDEMTileSource=We,d.RasterTileSource=$e,d.ScaleControl=class{constructor(y){this._onMove=()=>{Id(this._map,this._container,this.options)},this.setUnit=n=>{this.options.unit=n,Id(this._map,this._container,this.options)},this.options=Object.assign(Object.assign({},Jp),y)}getDefaultPosition(){return"bottom-left"}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-scale",y.getContainer()),this._map.on("move",this._onMove),this._onMove(),this._container}onRemove(){D.remove(this._container),this._map.off("move",this._onMove),this._map=void 0}},d.ScrollZoomHandler=yd,d.Style=js,d.TerrainControl=class{constructor(y){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=y}onAdd(y){return this._map=y,this._container=D.create("div","maplibregl-ctrl maplibregl-ctrl-group"),this._terrainButton=D.create("button","maplibregl-ctrl-terrain",this._container),D.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(){D.remove(this._container),this._map.off("terrain",this._updateTerrainIcon),this._map=void 0}},d.TwoFingersTouchPitchHandler=_d,d.TwoFingersTouchRotateHandler=pd,d.TwoFingersTouchZoomHandler=dd,d.TwoFingersTouchZoomRotateHandler=vd,d.VectorTileSource=Ke,d.VideoSource=At,d.addSourceType=(y,n)=>c._(void 0,void 0,void 0,function*(){if($t(y))throw new Error(`A source type called "${y}" already exists.`);((u,p)=>{Bt[u]=p})(y,n)}),d.clearPrewarmedResources=function(){const y=ni;y&&(y.isPreloaded()&&y.numActive()===1?(y.release(os),ni=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()"))},d.getMaxParallelImageRequests=function(){return c.a.MAX_PARALLEL_IMAGE_REQUESTS},d.getRTLTextPluginStatus=function(){return xi().getRTLTextPluginStatus()},d.getVersion=function(){return Mt},d.getWorkerCount=function(){return as.workerCount},d.getWorkerUrl=function(){return c.a.WORKER_URL},d.importScriptInWorkers=function(y){return Ss().broadcast("IS",y)},d.prewarm=function(){ci().acquire(os)},d.setMaxParallelImageRequests=function(y){c.a.MAX_PARALLEL_IMAGE_REQUESTS=y},d.setRTLTextPlugin=function(y,n){return xi().setRTLTextPlugin(y,n)},d.setWorkerCount=function(y){as.workerCount=y},d.setWorkerUrl=function(y){c.a.WORKER_URL=y}});var h=i;return h})})(QP);var g$=QP.exports;const sA=RP(g$);function bn(t,e,i,r,o){return Qn(e,tR(t,e),i,r,o)}function Qn(t,e,i,r,o,h){const d=_v(e,i,r);if(o&&e!==d)throw new RangeError(wC(t,e,i,r,h));return d}function tR(t,e){const i=t[e];if(i===void 0)throw new TypeError(r1(e));return i}function zs(t){return t!==null&&/object|function/.test(typeof t)}function zn(t,e=Map){const i=new e;return(r,...o)=>{if(i.has(r))return i.get(r);const h=t(r,...o);return i.set(r,h),h}}function nA(t){return mu({name:t},1)}function mu(t,e){return Bo(i=>({value:i,configurable:1,writable:!e}),t)}function m$(t){return Bo(e=>({get:e,configurable:1}),t)}function fx(t){return{[Symbol.toStringTag]:{value:t,configurable:1}}}function Su(t,e){const i={};let r=t.length;for(const o of e)i[t[--r]]=o;return i}function Bo(t,e,i){const r={};for(const o in e)r[o]=t(e[o],o,i);return r}function Mm(t,e,i){const r={};for(let o=0;o